@royalschedule/maps 3.3.13 → 3.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/Additio/to/index.d.ts +2 -2
  2. package/dist/PlanDigital/to/index.d.ts +2 -2
  3. package/dist/RS/v3/to/available-dependencies.js.map +1 -1
  4. package/dist/RS/v3/to/collections.js +1 -1
  5. package/dist/RS/v3/to/collections.js.map +1 -1
  6. package/dist/RS/v3/to/configurations.js.map +1 -1
  7. package/dist/RS/v3/to/constraints.js +0 -4
  8. package/dist/RS/v3/to/constraints.js.map +1 -1
  9. package/dist/RS/v3/to/course-events/days.js.map +1 -1
  10. package/dist/RS/v3/to/course-events/dependencies.js.map +1 -1
  11. package/dist/RS/v3/to/course-events/groups.js.map +1 -1
  12. package/dist/RS/v3/to/course-events/in-locations.js.map +1 -1
  13. package/dist/RS/v3/to/course-events/index.js.map +1 -1
  14. package/dist/RS/v3/to/course-events/intervals.js.map +1 -1
  15. package/dist/RS/v3/to/course-events/meta.js.map +1 -1
  16. package/dist/RS/v3/to/default.js.map +1 -1
  17. package/dist/RS/v3/to/dependencies.js.map +1 -1
  18. package/dist/RS/v3/to/destructure.js.map +1 -1
  19. package/dist/RS/v3/to/dynamic-locked-times.js +67 -58
  20. package/dist/RS/v3/to/dynamic-locked-times.js.map +1 -1
  21. package/dist/RS/v3/to/groups.js.map +1 -1
  22. package/dist/RS/v3/to/index.d.ts +13 -33
  23. package/dist/RS/v3/to/index.js +0 -26
  24. package/dist/RS/v3/to/index.js.map +1 -1
  25. package/dist/RS/v3/to/individuals.js.map +1 -1
  26. package/dist/RS/v3/to/locked-times.js.map +1 -1
  27. package/dist/RS/v3/to/schedules.js +19 -2
  28. package/dist/RS/v3/to/schedules.js.map +1 -1
  29. package/dist/RS/v3/to/teachers.js.map +1 -1
  30. package/dist/RS/v3/to/util.js.map +1 -1
  31. package/dist/RS/v3/types/algorithm-parameters.d.ts +6 -0
  32. package/dist/RS/v3/types/out-options.d.ts +9 -5
  33. package/dist/RS/v3/types/schedules.d.ts +4 -0
  34. package/dist/core/v2/to/schedules.d.ts +6 -6
  35. package/package.json +1 -1
  36. package/dist/RS/v3/to/available-dependencies.d.ts +0 -10
  37. package/dist/RS/v3/to/course-events/index.d.ts +0 -13
  38. package/dist/RS/v3/to/dependencies.d.ts +0 -10
  39. package/dist/RS/v3/to/persons.js +0 -22
  40. package/dist/RS/v3/to/persons.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { Types } from "../../core/v2/types/index.js";
2
- import * as xlsx1 from "xlsx";
2
+ import * as xlsx0 from "xlsx";
3
3
 
4
4
  //#region src/Additio/to/index.d.ts
5
5
  declare class export_default {
@@ -12,7 +12,7 @@ declare class export_default {
12
12
  teachers: Types.teacher[];
13
13
  courses: Types.course[];
14
14
  events: Types.event[];
15
- }) => xlsx1.WorkBook;
15
+ }) => xlsx0.WorkBook;
16
16
  }
17
17
  //#endregion
18
18
  export { export_default };
@@ -1,9 +1,9 @@
1
1
  import { Types } from "../../core/v2/types/index.js";
2
- import * as xlsx0 from "xlsx";
2
+ import * as xlsx1 from "xlsx";
3
3
 
4
4
  //#region src/PlanDigital/to/index.d.ts
5
5
  declare class export_default {
6
- static schedules: (courseEvents: Types.course[]) => xlsx0.WorkBook;
6
+ static schedules: (courseEvents: Types.course[]) => xlsx1.WorkBook;
7
7
  }
8
8
  //#endregion
9
9
  export { export_default };
@@ -1 +1 @@
1
- {"version":3,"file":"available-dependencies.js","names":["idKey: keyof CoreTypes.location"],"sources":["../../../../src/RS/v3/to/available-dependencies.ts"],"sourcesContent":["import { OutOptions } from '../types/out-options';\nimport { AvailableDependency } from '../types/available-dependencies';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { groupBy, pick, values } from 'lodash-es';\n\nexport default function (\n availableLocations: Deserialized<CoreTypes.availableLocation>[],\n options: OutOptions\n) {\n const idKey: keyof CoreTypes.location = options.idKey || 'id';\n\n if (!idKey) {\n throw new Error('(RS::V3::To::AvailableDependencies) property \"idKey\" in options is undefined');\n }\n\n\n const A = availableLocations\n .map(({ locations, groupIndex, rank }) => {\n const id = locations?.at(0)?.[idKey]?.toString();\n if (!id) return;\n\n return {\n dependency: id,\n ...rank != null && { rank },\n groupBy: groupIndex\n };\n })\n .filter((x): x is NonNullable<typeof x> => !!x)\n .filter(x => {\n // filter location references based on partial schedule options\n const includedLocations = options.partialScheduleOptions?.includedLocations;\n if (!includedLocations) return true;\n return includedLocations.has(x.dependency);\n });\n\n const B = values(groupBy(A, x => x.groupBy))\n\n return B.map(xs => xs.map((x): AvailableDependency => pick(x, 'dependency', 'rank')));\n}"],"mappings":";;;AAOA,wCACE,oBACA,SACA;CACA,MAAMA,QAAkC,QAAQ,SAAS;AAEzD,KAAI,CAAC,MACH,OAAM,IAAI,MAAM;CAIlB,MAAM,IAAI,mBACP,KAAK,EAAE,WAAW,YAAY,WAAW;EACxC,MAAM,KAAK,WAAW,GAAG,KAAK,QAAQ;AACtC,MAAI,CAAC,GAAI;AAET,SAAO;GACL,YAAY;GACZ,GAAG,QAAQ,QAAQ,EAAE;GACrB,SAAY;;IAGf,QAAQ,MAAkC,CAAC,CAAC,GAC5C,QAAO,MAAK;EAEX,MAAM,oBAAoB,QAAQ,wBAAwB;AAC1D,MAAI,CAAC,kBAAmB,QAAO;AAC/B,SAAO,kBAAkB,IAAI,EAAE;;CAGnC,MAAM,IAAI,OAAO,QAAQ,IAAG,MAAK,EAAE;AAEnC,QAAO,EAAE,KAAI,OAAM,GAAG,KAAK,MAA2B,KAAK,GAAG,cAAc"}
1
+ {"version":3,"file":"available-dependencies.js","names":["idKey: keyof CoreTypes.location"],"sources":["../../../../src/RS/v3/to/available-dependencies.ts"],"sourcesContent":["import { ParsedOutOptions as OutOptions } from '../types/out-options';\nimport { AvailableDependency } from '../types/available-dependencies';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { groupBy, pick, values } from 'lodash-es';\n\nexport default function (\n availableLocations: Deserialized<CoreTypes.availableLocation>[],\n options: OutOptions\n) {\n const idKey: keyof CoreTypes.location = options.idKey || 'id';\n\n if (!idKey) {\n throw new Error('(RS::V3::To::AvailableDependencies) property \"idKey\" in options is undefined');\n }\n\n\n const A = availableLocations\n .map(({ locations, groupIndex, rank }) => {\n const id = locations?.at(0)?.[idKey]?.toString();\n if (!id) return;\n\n return {\n dependency: id,\n ...rank != null && { rank },\n groupBy: groupIndex\n };\n })\n .filter((x): x is NonNullable<typeof x> => !!x)\n .filter(x => {\n // filter location references based on partial schedule options\n const includedLocations = options.partialScheduleOptions?.includedLocations;\n if (!includedLocations) return true;\n return includedLocations.has(x.dependency);\n });\n\n const B = values(groupBy(A, x => x.groupBy))\n\n return B.map(xs => xs.map((x): AvailableDependency => pick(x, 'dependency', 'rank')));\n}"],"mappings":";;;AAOA,wCACE,oBACA,SACA;CACA,MAAMA,QAAkC,QAAQ,SAAS;AAEzD,KAAI,CAAC,MACH,OAAM,IAAI,MAAM;CAIlB,MAAM,IAAI,mBACP,KAAK,EAAE,WAAW,YAAY,WAAW;EACxC,MAAM,KAAK,WAAW,GAAG,KAAK,QAAQ;AACtC,MAAI,CAAC,GAAI;AAET,SAAO;GACL,YAAY;GACZ,GAAG,QAAQ,QAAQ,EAAE;GACrB,SAAY;;IAGf,QAAQ,MAAkC,CAAC,CAAC,GAC5C,QAAO,MAAK;EAEX,MAAM,oBAAoB,QAAQ,wBAAwB;AAC1D,MAAI,CAAC,kBAAmB,QAAO;AAC/B,SAAO,kBAAkB,IAAI,EAAE;;CAGnC,MAAM,IAAI,OAAO,QAAQ,IAAG,MAAK,EAAE;AAEnC,QAAO,EAAE,KAAI,OAAM,GAAG,KAAK,MAA2B,KAAK,GAAG,cAAc"}
@@ -1,8 +1,8 @@
1
- import available_dependencies_default from "./available-dependencies.js";
2
1
  import days_default from "./days.js";
3
2
  import locked_times_default from "./locked-times.js";
4
3
  import break_lengths_default from "./break-lengths.js";
5
4
  import intervals_default from "./intervals.js";
5
+ import available_dependencies_default from "./available-dependencies.js";
6
6
  import { mapGroupReferences } from "./course-events/groups.js";
7
7
  import course_events_default from "./course-events/index.js";
8
8
  import { groupBy, omit, values } from "lodash-es";
@@ -1 +1 @@
1
- {"version":3,"file":"collections.js","names":["idKey: keyof CoreTypes.course","doc: Collection & { groupBy?: string }","courseEvents","availableDependencies","intervals","days","breakLength","lockedTimes"],"sources":["../../../../src/RS/v3/to/collections.ts"],"sourcesContent":["import days from './days';\nimport lockedTimes from './locked-times';\nimport intervals from './intervals';\nimport availableDependencies from './available-dependencies';\nimport courseEvents from './course-events';\nimport breakLength from './break-lengths';\n\nimport { Collection } from '../types/collections';\nimport { OutOptions } from '../types/out-options';\nimport { Individual } from '../types/individuals';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { mapGroupReferences } from './course-events/groups';\nimport { groupBy, omit, values } from 'lodash-es';\n\nexport default (\n courses: Deserialized<CoreTypes.course> | Deserialized<CoreTypes.course>[],\n events: Deserialized<CoreTypes.event>[] = [],\n overlapGroups: Deserialized<CoreTypes.overlapGroup>[] = [],\n settings: CoreTypes.divisionSettings,\n options: OutOptions,\n periodsMap: Map<string | undefined, number>,\n destructMap: Map<string | null, Individual> = new Map()\n): (Collection[] | Collection)[] => {\n\n const idKey: keyof CoreTypes.course = options.idKey || 'id';\n\n const eventMap = new Map(events\n .map(x => x.id ? [x.id, x] as [string, typeof x] : null)\n .filter((x): x is NonNullable<typeof x> => !!x)\n );\n\n const collections = (Array.isArray(courses) ? courses : [courses])\n .map(course => {\n const id = course[idKey]?.toString();\n\n if (!id) {\n throw new Error('(RS::V3::To::Collections) A course does not have a unique key');\n }\n\n // link events to course if not already done\n course.events ??= events.filter(x => x.course?.[idKey]?.toString() == id);\n\n // merge potentially missing event data\n course.events.forEach(event => {\n if (!event.id) return;\n Object.assign(event, eventMap.get(event.id), { course });\n });\n\n\n if (course.period && periodsMap.size && !periodsMap.has(course.period.id)) {\n throw new Error(`(RS::V3::To::Collections) Course ${course[idKey]} has a period that does not exist`);\n }\n\n const doc: Collection & { groupBy?: string } = {\n id,\n distributionKey: id,\n events: courseEvents(course.events, overlapGroups, settings, options, periodsMap, destructMap),\n // optional\n ...'weight' in course && { weight: course.weight },\n ...'density' in course && { density: course.density },\n ...course.eventDurationVariance != null && { maxEventLengthVariance: course.eventDurationVariance },\n ...course.locations?.length && { dependencies: availableDependencies(course.locations, options) },\n ...course.intervals?.length && { intervals: intervals(course.intervals, settings) },\n ...course.days?.length && { days: days(course.days, settings.numDays) },\n ...(course.minBreakLength != null) && { minBreakLength: breakLength(course.minBreakLength) },\n ...course.lockedTimes?.length && { lockedTimes: lockedTimes(course.lockedTimes, options) },\n ...course.lockedTimes?.length && { lockedTimes: lockedTimes(course.lockedTimes, options) },\n ...course.centerOfAttraction && { potentialCenter: parseFloat(course.centerOfAttraction.replace(':', '.')) },\n ...course.period && periodsMap.size && { period: periodsMap.get(course.period?.id) }\n };\n\n const groups = mapGroupReferences(course, options, destructMap);\n if (groups) doc.groups = groups;\n\n if (options.meta) {\n Object.assign(doc, {\n ...'color' in course && { color: course.color },\n ...'ids' in course && { ids: course.ids },\n ...course.displayName && { name: course.displayName },\n });\n }\n\n // temporarily attach overlap group\n doc.groupBy = course.overlapGroup?.id?.toString();\n\n return doc;\n });\n\n const overlapping = values(groupBy(\n collections.filter(x => x.groupBy != null),\n x => x.groupBy\n ))\n .map(xs => xs.map(x => omit(x, 'groupBy') as Collection));\n\n const plain = collections\n .filter(x => x.groupBy == null)\n .map(x => omit(x, 'groupBy') as Collection);\n\n return overlapping.concat(plain);\n};"],"mappings":";;;;;;;;;;AAgBA,2BACE,SACA,SAAiD,IACjD,gBAAwD,IACxD,UACA,SACA,YACA,8BAAgD,IAAI,UAClB;CAElC,MAAMA,QAAgC,QAAQ,SAAS;CAEvD,MAAM,WAAW,IAAI,IAAI,OACtB,KAAI,MAAK,EAAE,KAAK,CAAC,EAAE,IAAI,KAA2B,MAClD,QAAQ,MAAkC,CAAC,CAAC;CAG/C,MAAM,eAAe,MAAM,QAAQ,WAAW,UAAU,CAAC,UACtD,KAAI,WAAU;EACb,MAAM,KAAK,OAAO,QAAQ;AAE1B,MAAI,CAAC,GACH,OAAM,IAAI,MAAM;AAIlB,SAAO,WAAW,OAAO,QAAO,MAAK,EAAE,SAAS,QAAQ,cAAc;AAGtE,SAAO,OAAO,SAAQ,UAAS;AAC7B,OAAI,CAAC,MAAM,GAAI;AACf,UAAO,OAAO,OAAO,SAAS,IAAI,MAAM,KAAK,EAAE;;AAIjD,MAAI,OAAO,UAAU,WAAW,QAAQ,CAAC,WAAW,IAAI,OAAO,OAAO,IACpE,OAAM,IAAI,MAAM,oCAAoC,OAAO,OAAO;EAGpE,MAAMC,MAAyC;GAC7C;GACA,iBAAiB;GACjB,QAAiBC,sBAAa,OAAO,QAAQ,eAAe,UAAU,SAAS,YAAY;GAE3F,GAAG,YAA2B,UAAa,EAAE,QAAwB,OAAO;GAC5E,GAAG,aAA2B,UAAa,EAAE,SAAwB,OAAO;GAC5E,GAAG,OAAO,yBAAyB,QAAQ,EAAE,wBAAwB,OAAO;GAC5E,GAAG,OAAO,WAAW,UAAsB,EAAE,cAAwBC,+BAAsB,OAAO,WAAW;GAC7G,GAAG,OAAO,WAAW,UAAsB,EAAE,WAAwBC,kBAAU,OAAO,WAAW;GACjG,GAAG,OAAO,MAAM,UAA2B,EAAE,MAAwBC,aAAK,OAAO,MAAM,SAAS;GAChG,GAAI,OAAO,kBAAkB,QAAc,EAAE,gBAAwBC,sBAAY,OAAO;GACxF,GAAG,OAAO,aAAa,UAAoB,EAAE,aAAwBC,qBAAY,OAAO,aAAa;GACrG,GAAG,OAAO,aAAa,UAAoB,EAAE,aAAwBA,qBAAY,OAAO,aAAa;GACrG,GAAG,OAAO,sBAAiC,EAAE,iBAAwB,WAAW,OAAO,mBAAmB,QAAQ,KAAK;GACvH,GAAG,OAAO,UAAU,WAAW,QAAY,EAAE,QAAwB,WAAW,IAAI,OAAO,QAAQ;;EAGrG,MAAM,SAAS,mBAAmB,QAAQ,SAAS;AACnD,MAAI,OAAQ,KAAI,SAAS;AAEzB,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,GAAG,WAAkB,UAAU,EAAE,OAAO,OAAO;GAC/C,GAAG,SAAkB,UAAU,EAAE,KAAO,OAAO;GAC/C,GAAG,OAAO,eAAqB,EAAE,MAAO,OAAO;;AAKnD,MAAI,UAAU,OAAO,cAAc,IAAI;AAEvC,SAAO;;CAGX,MAAM,cAAc,OAAO,QACzB,YAAY,QAAO,MAAK,EAAE,WAAW,QACrC,MAAK,EAAE,UAEN,KAAI,OAAM,GAAG,KAAI,MAAK,KAAK,GAAG;CAEjC,MAAM,QAAQ,YACX,QAAO,MAAK,EAAE,WAAW,MACzB,KAAI,MAAK,KAAK,GAAG;AAEpB,QAAO,YAAY,OAAO"}
1
+ {"version":3,"file":"collections.js","names":["idKey: keyof CoreTypes.course","doc: Collection & { groupBy?: string }","courseEvents","availableDependencies","intervals","days","breakLength","lockedTimes"],"sources":["../../../../src/RS/v3/to/collections.ts"],"sourcesContent":["import days from './days';\nimport lockedTimes from './locked-times';\nimport intervals from './intervals';\nimport availableDependencies from './available-dependencies';\nimport courseEvents from './course-events';\nimport breakLength from './break-lengths';\n\nimport { Collection } from '../types/collections';\nimport { ParsedOutOptions as OutOptions } from '../types/out-options';\nimport { Individual } from '../types/individuals';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { mapGroupReferences } from './course-events/groups';\nimport { groupBy, omit, values } from 'lodash-es';\n\nexport default (\n courses: Deserialized<CoreTypes.course> | Deserialized<CoreTypes.course>[],\n events: Deserialized<CoreTypes.event>[] = [],\n overlapGroups: Deserialized<CoreTypes.overlapGroup>[] = [],\n settings: CoreTypes.divisionSettings,\n options: OutOptions,\n periodsMap: Map<string | undefined, number>,\n destructMap: Map<string | null, Individual> = new Map()\n): (Collection[] | Collection)[] => {\n\n const idKey: keyof CoreTypes.course = options.idKey || 'id';\n\n const eventMap = new Map(events\n .map(x => x.id ? [x.id, x] as [string, typeof x] : null)\n .filter((x): x is NonNullable<typeof x> => !!x)\n );\n\n const collections = (Array.isArray(courses) ? courses : [courses])\n .map(course => {\n const id = course[idKey]?.toString();\n\n if (!id) {\n throw new Error('(RS::V3::To::Collections) A course does not have a unique key');\n }\n\n // link events to course if not already done\n course.events ??= events.filter(x => x.course?.[idKey]?.toString() == id);\n\n // merge potentially missing event data\n course.events.forEach(event => {\n if (!event.id) return;\n Object.assign(event, eventMap.get(event.id), { course });\n });\n\n\n if (course.period && periodsMap.size && !periodsMap.has(course.period.id)) {\n throw new Error(`(RS::V3::To::Collections) Course ${course[idKey]} has a period that does not exist`);\n }\n\n const doc: Collection & { groupBy?: string } = {\n id,\n distributionKey: id,\n events: courseEvents(course.events, overlapGroups, settings, options, periodsMap, destructMap),\n // optional\n ...'weight' in course && { weight: course.weight },\n ...'density' in course && { density: course.density },\n ...course.eventDurationVariance != null && { maxEventLengthVariance: course.eventDurationVariance },\n ...course.locations?.length && { dependencies: availableDependencies(course.locations, options) },\n ...course.intervals?.length && { intervals: intervals(course.intervals, settings) },\n ...course.days?.length && { days: days(course.days, settings.numDays) },\n ...(course.minBreakLength != null) && { minBreakLength: breakLength(course.minBreakLength) },\n ...course.lockedTimes?.length && { lockedTimes: lockedTimes(course.lockedTimes, options) },\n ...course.lockedTimes?.length && { lockedTimes: lockedTimes(course.lockedTimes, options) },\n ...course.centerOfAttraction && { potentialCenter: parseFloat(course.centerOfAttraction.replace(':', '.')) },\n ...course.period && periodsMap.size && { period: periodsMap.get(course.period?.id) }\n };\n\n const groups = mapGroupReferences(course, options, destructMap);\n if (groups) doc.groups = groups;\n\n if (options.meta) {\n Object.assign(doc, {\n ...'color' in course && { color: course.color },\n ...'ids' in course && { ids: course.ids },\n ...course.displayName && { name: course.displayName },\n });\n }\n\n // temporarily attach overlap group\n doc.groupBy = course.overlapGroup?.id?.toString();\n\n return doc;\n });\n\n const overlapping = values(groupBy(\n collections.filter(x => x.groupBy != null),\n x => x.groupBy\n ))\n .map(xs => xs.map(x => omit(x, 'groupBy') as Collection));\n\n const plain = collections\n .filter(x => x.groupBy == null)\n .map(x => omit(x, 'groupBy') as Collection);\n\n return overlapping.concat(plain);\n};"],"mappings":";;;;;;;;;;AAgBA,2BACE,SACA,SAAiD,IACjD,gBAAwD,IACxD,UACA,SACA,YACA,8BAAgD,IAAI,UAClB;CAElC,MAAMA,QAAgC,QAAQ,SAAS;CAEvD,MAAM,WAAW,IAAI,IAAI,OACtB,KAAI,MAAK,EAAE,KAAK,CAAC,EAAE,IAAI,KAA2B,MAClD,QAAQ,MAAkC,CAAC,CAAC;CAG/C,MAAM,eAAe,MAAM,QAAQ,WAAW,UAAU,CAAC,UACtD,KAAI,WAAU;EACb,MAAM,KAAK,OAAO,QAAQ;AAE1B,MAAI,CAAC,GACH,OAAM,IAAI,MAAM;AAIlB,SAAO,WAAW,OAAO,QAAO,MAAK,EAAE,SAAS,QAAQ,cAAc;AAGtE,SAAO,OAAO,SAAQ,UAAS;AAC7B,OAAI,CAAC,MAAM,GAAI;AACf,UAAO,OAAO,OAAO,SAAS,IAAI,MAAM,KAAK,EAAE;;AAIjD,MAAI,OAAO,UAAU,WAAW,QAAQ,CAAC,WAAW,IAAI,OAAO,OAAO,IACpE,OAAM,IAAI,MAAM,oCAAoC,OAAO,OAAO;EAGpE,MAAMC,MAAyC;GAC7C;GACA,iBAAiB;GACjB,QAAiBC,sBAAa,OAAO,QAAQ,eAAe,UAAU,SAAS,YAAY;GAE3F,GAAG,YAA2B,UAAa,EAAE,QAAwB,OAAO;GAC5E,GAAG,aAA2B,UAAa,EAAE,SAAwB,OAAO;GAC5E,GAAG,OAAO,yBAAyB,QAAQ,EAAE,wBAAwB,OAAO;GAC5E,GAAG,OAAO,WAAW,UAAsB,EAAE,cAAwBC,+BAAsB,OAAO,WAAW;GAC7G,GAAG,OAAO,WAAW,UAAsB,EAAE,WAAwBC,kBAAU,OAAO,WAAW;GACjG,GAAG,OAAO,MAAM,UAA2B,EAAE,MAAwBC,aAAK,OAAO,MAAM,SAAS;GAChG,GAAI,OAAO,kBAAkB,QAAc,EAAE,gBAAwBC,sBAAY,OAAO;GACxF,GAAG,OAAO,aAAa,UAAoB,EAAE,aAAwBC,qBAAY,OAAO,aAAa;GACrG,GAAG,OAAO,aAAa,UAAoB,EAAE,aAAwBA,qBAAY,OAAO,aAAa;GACrG,GAAG,OAAO,sBAAiC,EAAE,iBAAwB,WAAW,OAAO,mBAAmB,QAAQ,KAAK;GACvH,GAAG,OAAO,UAAU,WAAW,QAAY,EAAE,QAAwB,WAAW,IAAI,OAAO,QAAQ;;EAGrG,MAAM,SAAS,mBAAmB,QAAQ,SAAS;AACnD,MAAI,OAAQ,KAAI,SAAS;AAEzB,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,GAAG,WAAkB,UAAU,EAAE,OAAO,OAAO;GAC/C,GAAG,SAAkB,UAAU,EAAE,KAAO,OAAO;GAC/C,GAAG,OAAO,eAAqB,EAAE,MAAO,OAAO;;AAKnD,MAAI,UAAU,OAAO,cAAc,IAAI;AAEvC,SAAO;;CAGX,MAAM,cAAc,OAAO,QACzB,YAAY,QAAO,MAAK,EAAE,WAAW,QACrC,MAAK,EAAE,UAEN,KAAI,OAAM,GAAG,KAAI,MAAK,KAAK,GAAG;CAEjC,MAAM,QAAQ,YACX,QAAO,MAAK,EAAE,WAAW,MACzB,KAAI,MAAK,KAAK,GAAG;AAEpB,QAAO,YAAY,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"configurations.js","names":["idKey: keyof (CoreTypes.event & CoreTypes.course)"],"sources":["../../../../src/RS/v3/to/configurations.ts"],"sourcesContent":["import moment from 'moment';\nimport { isObject } from 'lodash-es';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\n\nimport { OutOptions } from '../types/out-options';\nimport { Configuration } from '../types/configurations';\nimport { Placement } from '../types/placements';\n\nexport default (events: Deserialized<CoreTypes.event>[], options: OutOptions): Configuration[] => {\n\n const idKey: keyof (CoreTypes.event & CoreTypes.course) = options.idKey || 'id';\n\n return [\n {\n events: (events || []).reduce((acc: Placement[], event) => {\n if (event.parked) return acc;\n\n const mmtMidnight = moment.utc(event.start).clone()\n .startOf('day');\n\n return acc.concat({\n id: event[idKey],\n collection: event.course?.[idKey],\n day: (moment.utc(event.start).day() + 6) % 7,\n dependencies: (event.inLocations)?.map(x => isObject(x) ? x[idKey] : null).filter(x => x !== null) ?? [],\n end: moment.utc(event.end).diff(mmtMidnight, 'minutes'),\n start: moment.utc(event.start).diff(mmtMidnight, 'minutes')\n } as Placement);\n }, [])\n }\n ];\n};"],"mappings":";;;;AAUA,8BAAgB,QAAyC,YAAyC;CAEhG,MAAMA,QAAoD,QAAQ,SAAS;AAE3E,QAAO,CACL,EACE,SAAS,UAAU,IAAI,QAAQ,KAAkB,UAAU;AACzD,MAAI,MAAM,OAAQ,QAAO;EAEzB,MAAM,cAAc,OAAO,IAAI,MAAM,OAAO,QACzC,QAAQ;AAEX,SAAO,IAAI,OAAO;GAChB,IAAc,MAAM;GACpB,YAAc,MAAM,SAAS;GAC7B,MAAe,OAAO,IAAI,MAAM,OAAO,QAAQ,KAAK;GACpD,cAAe,MAAM,aAAc,KAAI,MAAK,SAAS,KAAK,EAAE,SAAS,MAAM,QAAO,MAAK,MAAM,SAAS;GACtG,KAAc,OAAO,IAAI,MAAM,KAAK,KAAK,aAAa;GACtD,OAAc,OAAO,IAAI,MAAM,OAAO,KAAK,aAAa;;IAEzD"}
1
+ {"version":3,"file":"configurations.js","names":["idKey: keyof (CoreTypes.event & CoreTypes.course)"],"sources":["../../../../src/RS/v3/to/configurations.ts"],"sourcesContent":["import moment from 'moment';\nimport { isObject } from 'lodash-es';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\n\nimport { ParsedOutOptions as OutOptions } from '../types/out-options';\nimport { Configuration } from '../types/configurations';\nimport { Placement } from '../types/placements';\n\nexport default (events: Deserialized<CoreTypes.event>[], options: OutOptions): Configuration[] => {\n\n const idKey: keyof (CoreTypes.event & CoreTypes.course) = options.idKey || 'id';\n\n return [\n {\n events: (events || []).reduce((acc: Placement[], event) => {\n if (event.parked) return acc;\n\n const mmtMidnight = moment.utc(event.start).clone()\n .startOf('day');\n\n return acc.concat({\n id: event[idKey],\n collection: event.course?.[idKey],\n day: (moment.utc(event.start).day() + 6) % 7,\n dependencies: (event.inLocations)?.map(x => isObject(x) ? x[idKey] : null).filter(x => x !== null) ?? [],\n end: moment.utc(event.end).diff(mmtMidnight, 'minutes'),\n start: moment.utc(event.start).diff(mmtMidnight, 'minutes')\n } as Placement);\n }, [])\n }\n ];\n};"],"mappings":";;;;AAUA,8BAAgB,QAAyC,YAAyC;CAEhG,MAAMA,QAAoD,QAAQ,SAAS;AAE3E,QAAO,CACL,EACE,SAAS,UAAU,IAAI,QAAQ,KAAkB,UAAU;AACzD,MAAI,MAAM,OAAQ,QAAO;EAEzB,MAAM,cAAc,OAAO,IAAI,MAAM,OAAO,QACzC,QAAQ;AAEX,SAAO,IAAI,OAAO;GAChB,IAAc,MAAM;GACpB,YAAc,MAAM,SAAS;GAC7B,MAAe,OAAO,IAAI,MAAM,OAAO,QAAQ,KAAK;GACpD,cAAe,MAAM,aAAc,KAAI,MAAK,SAAS,KAAK,EAAE,SAAS,MAAM,QAAO,MAAK,MAAM,SAAS;GACtG,KAAc,OAAO,IAAI,MAAM,KAAK,KAAK,aAAa;GACtD,OAAc,OAAO,IAAI,MAAM,OAAO,KAAK,aAAa;;IAEzD"}
@@ -12,10 +12,6 @@ import { pick } from "lodash-es";
12
12
 
13
13
  //#region src/RS/v3/to/constraints.ts
14
14
  var constraints_default = (schedule, options = {}) => {
15
- if (options.partialScheduleOptions?.includedEvents?.size) options.partialScheduleOptions.includedEvents = new Set([...options.partialScheduleOptions.includedEvents].map((x) => {
16
- if (x.startsWith("events.") || x.startsWith("lockedTimes.")) return x;
17
- return `events.${x}`;
18
- }));
19
15
  schedule = structuredClone(schedule);
20
16
  if (schedule == null) return {};
21
17
  const idKey = options.idKey || "id";
@@ -1 +1 @@
1
- {"version":3,"file":"constraints.js","names":["idKey: keyof CoreTypes.course","groupMap","_destructure","data: Constraint","getSettings","getDefault","getCollections","getDependencies","getGroups","getTeachers","getDynamicLockedTimes"],"sources":["../../../../src/RS/v3/to/constraints.ts"],"sourcesContent":["import { pick } from 'lodash-es';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\n\nimport { Constraint } from '../types/constraints';\nimport { OutOptions } from '../types/out-options';\n\nimport _destructure from './destructure';\nimport getDependencies from './dependencies';\nimport getTeachers from './teachers';\nimport getGroups from './groups';\nimport getCollections from './collections';\nimport getSettings from './settings';\nimport getDefault from './default';\nimport getDynamicLockedTimes from './dynamic-locked-times';\nimport { parsePeriods } from './periods';\nimport { personsToIndividuals,\n groupsToIndividuals,\n teachersToIndividuals } from './individuals';\n\nexport default (\n schedule: Partial<Deserialized<CoreTypes.schedule> & { division: Deserialized<CoreTypes.division> }>,\n options: OutOptions = {}\n): Constraint => {\n ////\n //// for backward compatibility: add default collection to included events set\n ////\n if (options.partialScheduleOptions?.includedEvents?.size) {\n options.partialScheduleOptions.includedEvents = new Set(\n [...options.partialScheduleOptions.includedEvents]\n .map(x => {\n // should start with 'events.' or 'lockedTimes.' prefix\n if (x.startsWith('events.') || x.startsWith('lockedTimes.')) return x;\n return `events.${x}`;\n })\n );\n }\n\n\n // clone schedule to avoid mutating the original object\n schedule = structuredClone(schedule);\n\n if (schedule == null) return {};\n const idKey: keyof CoreTypes.course = options.idKey || 'id';\n\n const settings = schedule.settings;\n if (!settings) throw new Error('settings missing in schedule');\n\n const area = schedule.area;\n const groups = schedule.groups ?? [];\n const teachers = schedule.teachers ?? [];\n const locations = schedule.locations ?? [];\n const events = schedule.events ?? [];\n const overlapGroups = schedule.overlapGroups ?? [];\n const courses = schedule.courses ?? [];\n const periods = schedule.periods ?? [];\n const persons = schedule.persons ?? [];\n\n ////\n //// populate some group references to ensure that the types are correct\n ////\n {\n const groupMap = new Map(groups\n .map(x => ([x[idKey]?.toString(), x] as const))\n .filter(x => !!x[0])\n );\n // group.parentGroups\n groups?.forEach(item => {\n if (!item.parentGroups) return;\n item.parentGroups = item.parentGroups\n .map((x: Deserialized<CoreTypes.group> | string) => {\n return typeof x === 'string' ? groupMap.get(x) : groupMap.get(x[idKey]?.toString());\n })\n .filter((x): x is NonNullable<typeof x> => !!x);\n });\n // course.groups.to and event.groups.to\n courses.concat(events).forEach(item => {\n if (!item.groups) return;\n item.groups.forEach((x: { to: Deserialized<CoreTypes.group> | string }) => {\n const group = typeof x.to === 'string' ? groupMap.get(x.to) : groupMap.get(x.to[idKey]?.toString());\n if (group) x.to = group;\n });\n });\n }\n\n // unfortunately the division is set either as \"division\" or \"divisions\" so we need to handle both cases\n const division = schedule.divisions ?? schedule.division;\n\n // map periods\n const { map: periodsMap, matrix: periodsMatrix } = parsePeriods(periods, pick(division, 'start', 'end'));\n\n const destructMap = _destructure(courses, events, groups, settings, options);\n\n const data: Constraint = {\n settings: getSettings(settings),\n default: getDefault(settings, periodsMap, options),\n ...periodsMatrix && { periods: periodsMatrix },\n ...area && {\n areas: {\n breakLengthMatrix: area.breakLengthMatrix,\n list: area.list\n }\n },\n // intervals: getRootIntervals(rootIntervals, settings!),\n events: getCollections(courses, events, overlapGroups, settings, options, periodsMap, destructMap),\n dependencies: getDependencies(locations, settings, options),\n groups: getGroups(groups, settings, options)\n .concat(getTeachers(teachers, settings, options)),\n individuals: personsToIndividuals(persons, settings, options)\n .concat(groupsToIndividuals(groups, settings, options))\n .concat(teachersToIndividuals(teachers, settings, options)),\n };\n\n /*\n create map of groups if some groups are destructed\n groupMap: group id -> group\n */\n const groupMap = new Map<string, Deserialized<CoreTypes.group>>();\n if (destructMap.size) {\n groups?.forEach(x => groupMap.set(x[idKey]!.toString(), x));\n\n /*\n Find group and clone and substitute id with person id\n */\n data.individuals = data.individuals?.concat(Array.from(destructMap.values()));\n }\n\n /*\n handle groups.lunch and teachers.lunch\n append to events list\n */\n const lunchSet = new Set<string>();\n /**\n * Only add lunch if the group is a class\n */\n if (groups?.some(group => 'lunch' in group))\n data.events = (data.events ?? []).concat(getDynamicLockedTimes(groups.filter(x => x.species == 'class'), settings, options, lunchSet, destructMap));\n\n if (teachers?.some(teacher => 'lunch' in teacher || 'complementaryTimes' in teacher))\n data.events = (data.events ?? []).concat(getDynamicLockedTimes(teachers, settings, options, lunchSet));\n\n return data;\n};"],"mappings":";;;;;;;;;;;;;AAqBA,2BACE,UACA,UAAuB,OACR;AAIf,KAAI,QAAQ,wBAAwB,gBAAgB,KAClD,SAAQ,uBAAuB,iBAAiB,IAAI,IAClD,CAAC,GAAG,QAAQ,uBAAuB,gBAChC,KAAI,MAAK;AAER,MAAI,EAAE,WAAW,cAAc,EAAE,WAAW,gBAAiB,QAAO;AACpE,SAAO,UAAU;;AAOzB,YAAW,gBAAgB;AAE3B,KAAI,YAAY,KAAM,QAAO;CAC7B,MAAMA,QAAgC,QAAQ,SAAS;CAEvD,MAAM,WAAW,SAAS;AAC1B,KAAI,CAAC,SAAU,OAAM,IAAI,MAAM;CAE/B,MAAM,OAAgB,SAAS;CAC/B,MAAM,SAAgB,SAAS,UAAiB;CAChD,MAAM,WAAgB,SAAS,YAAiB;CAChD,MAAM,YAAgB,SAAS,aAAiB;CAChD,MAAM,SAAgB,SAAS,UAAiB;CAChD,MAAM,gBAAgB,SAAS,iBAAiB;CAChD,MAAM,UAAgB,SAAS,WAAiB;CAChD,MAAM,UAAgB,SAAS,WAAiB;CAChD,MAAM,UAAgB,SAAS,WAAiB;CAKhD;EACE,MAAMC,aAAW,IAAI,IAAI,OACtB,KAAI,MAAM,CAAC,EAAE,QAAQ,YAAY,IACjC,QAAO,MAAK,CAAC,CAAC,EAAE;AAGnB,UAAQ,SAAQ,SAAQ;AACtB,OAAI,CAAC,KAAK,aAAc;AACxB,QAAK,eAAe,KAAK,aACtB,KAAK,MAA8C;AAClD,WAAO,OAAO,MAAM,WAAWA,WAAS,IAAI,KAAKA,WAAS,IAAI,EAAE,QAAQ;MAEzE,QAAQ,MAAkC,CAAC,CAAC;;AAGjD,UAAQ,OAAO,QAAQ,SAAQ,SAAQ;AACrC,OAAI,CAAC,KAAK,OAAQ;AAClB,QAAK,OAAO,SAAS,MAAsD;IACzE,MAAM,QAAQ,OAAO,EAAE,OAAO,WAAWA,WAAS,IAAI,EAAE,MAAMA,WAAS,IAAI,EAAE,GAAG,QAAQ;AACxF,QAAI,MAAO,GAAE,KAAK;;;;CAMxB,MAAM,WAAW,SAAS,aAAa,SAAS;CAGhD,MAAM,EAAE,KAAK,YAAY,QAAQ,kBAAkB,aAAa,SAAS,KAAK,UAAU,SAAS;CAEjG,MAAM,cAAcC,oBAAa,SAAS,QAAQ,QAAQ,UAAU;CAEpE,MAAMC,OAAmB;EACvB,UAAUC,iBAAY;EACtB,SAAUC,gBAAW,UAAU,YAAY;EAC3C,GAAG,iBAAiB,EAAE,SAAS;EAC/B,GAAG,QAAQ,EACT,OAAO;GACL,mBAAmB,KAAK;GACxB,MAAmB,KAAK;;EAI5B,QAAcC,oBAAe,SAAS,QAAQ,eAAe,UAAU,SAAS,YAAY;EAC5F,cAAcC,qBAAgB,WAAW,UAAU;EACnD,QAAcC,eAAU,QAAQ,UAAU,SACvC,OAAOC,iBAAY,UAAU,UAAU;EAC1C,aAAa,qBAAqB,SAAS,UAAU,SAClD,OAAO,oBAAoB,QAAQ,UAAU,UAC7C,OAAO,sBAAsB,UAAU,UAAU;;CAOtD,MAAM,2BAAW,IAAI;AACrB,KAAI,YAAY,MAAM;AACpB,UAAQ,SAAQ,MAAK,SAAS,IAAI,EAAE,OAAQ,YAAY;AAKxD,OAAK,cAAc,KAAK,aAAa,OAAO,MAAM,KAAK,YAAY;;CAOrE,MAAM,2BAAW,IAAI;;;;AAIrB,KAAI,QAAQ,MAAK,UAAS,WAAW,OACnC,MAAK,UAAU,KAAK,UAAU,IAAI,OAAOC,6BAAsB,OAAO,QAAO,MAAK,EAAE,WAAW,UAAU,UAAU,SAAS,UAAU;AAExI,KAAI,UAAU,MAAK,YAAW,WAAW,WAAW,wBAAwB,SAC1E,MAAK,UAAU,KAAK,UAAU,IAAI,OAAOA,6BAAsB,UAAU,UAAU,SAAS;AAE9F,QAAO"}
1
+ {"version":3,"file":"constraints.js","names":["idKey: keyof CoreTypes.course","groupMap","_destructure","data: Constraint","getSettings","getDefault","getCollections","getDependencies","getGroups","getTeachers","getDynamicLockedTimes"],"sources":["../../../../src/RS/v3/to/constraints.ts"],"sourcesContent":["import { pick } from 'lodash-es';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\n\nimport { Constraint } from '../types/constraints';\nimport { ParsedOutOptions } from '../types/out-options';\n\nimport _destructure from './destructure';\nimport getDependencies from './dependencies';\nimport getTeachers from './teachers';\nimport getGroups from './groups';\nimport getCollections from './collections';\nimport getSettings from './settings';\nimport getDefault from './default';\nimport getDynamicLockedTimes from './dynamic-locked-times';\nimport { parsePeriods } from './periods';\nimport { personsToIndividuals,\n groupsToIndividuals,\n teachersToIndividuals } from './individuals';\n\nexport default (\n schedule: Partial<Deserialized<CoreTypes.schedule> & { division: Deserialized<CoreTypes.division> }>,\n options: ParsedOutOptions = {}\n): Constraint => {\n\n // clone schedule to avoid mutating the original object\n schedule = structuredClone(schedule);\n\n if (schedule == null) return {};\n const idKey: keyof CoreTypes.course = options.idKey || 'id';\n\n const settings = schedule.settings;\n if (!settings) throw new Error('settings missing in schedule');\n\n const area = schedule.area;\n const groups = schedule.groups ?? [];\n const teachers = schedule.teachers ?? [];\n const locations = schedule.locations ?? [];\n const events = schedule.events ?? [];\n const overlapGroups = schedule.overlapGroups ?? [];\n const courses = schedule.courses ?? [];\n const periods = schedule.periods ?? [];\n const persons = schedule.persons ?? [];\n\n ////\n //// populate some group references to ensure that the types are correct\n ////\n {\n const groupMap = new Map(groups\n .map(x => ([x[idKey]?.toString(), x] as const))\n .filter(x => !!x[0])\n );\n // group.parentGroups\n groups?.forEach(item => {\n if (!item.parentGroups) return;\n item.parentGroups = item.parentGroups\n .map((x: Deserialized<CoreTypes.group> | string) => {\n return typeof x === 'string' ? groupMap.get(x) : groupMap.get(x[idKey]?.toString());\n })\n .filter((x): x is NonNullable<typeof x> => !!x);\n });\n // course.groups.to and event.groups.to\n courses.concat(events).forEach(item => {\n if (!item.groups) return;\n item.groups.forEach((x: { to: Deserialized<CoreTypes.group> | string }) => {\n const group = typeof x.to === 'string' ? groupMap.get(x.to) : groupMap.get(x.to[idKey]?.toString());\n if (group) x.to = group;\n });\n });\n }\n\n // unfortunately the division is set either as \"division\" or \"divisions\" so we need to handle both cases\n const division = schedule.divisions ?? schedule.division;\n\n // map periods\n const { map: periodsMap, matrix: periodsMatrix } = parsePeriods(periods, pick(division, 'start', 'end'));\n\n const destructMap = _destructure(courses, events, groups, settings, options);\n\n const data: Constraint = {\n settings: getSettings(settings),\n default: getDefault(settings, periodsMap, options),\n ...periodsMatrix && { periods: periodsMatrix },\n ...area && {\n areas: {\n breakLengthMatrix: area.breakLengthMatrix,\n list: area.list\n }\n },\n // intervals: getRootIntervals(rootIntervals, settings!),\n events: getCollections(courses, events, overlapGroups, settings, options, periodsMap, destructMap),\n dependencies: getDependencies(locations, settings, options),\n groups: getGroups(groups, settings, options)\n .concat(getTeachers(teachers, settings, options)),\n individuals: personsToIndividuals(persons, settings, options)\n .concat(groupsToIndividuals(groups, settings, options))\n .concat(teachersToIndividuals(teachers, settings, options)),\n };\n\n /*\n create map of groups if some groups are destructed\n groupMap: group id -> group\n */\n const groupMap = new Map<string, Deserialized<CoreTypes.group>>();\n if (destructMap.size) {\n groups?.forEach(x => groupMap.set(x[idKey]!.toString(), x));\n\n /*\n Find group and clone and substitute id with person id\n */\n data.individuals = data.individuals?.concat(Array.from(destructMap.values()));\n }\n\n /*\n handle groups.lunch and teachers.lunch\n append to events list\n */\n const lunchSet = new Set<string>();\n /**\n * Only add lunch if the group is a class\n */\n if (groups?.some(group => 'lunch' in group))\n data.events = (data.events ?? []).concat(getDynamicLockedTimes(groups.filter(x => x.species == 'class'), settings, options, lunchSet, destructMap));\n\n if (teachers?.some(teacher => 'lunch' in teacher || 'complementaryTimes' in teacher))\n data.events = (data.events ?? []).concat(getDynamicLockedTimes(teachers, settings, options, lunchSet));\n\n return data;\n};"],"mappings":";;;;;;;;;;;;;AAqBA,2BACE,UACA,UAA6B,OACd;AAGf,YAAW,gBAAgB;AAE3B,KAAI,YAAY,KAAM,QAAO;CAC7B,MAAMA,QAAgC,QAAQ,SAAS;CAEvD,MAAM,WAAW,SAAS;AAC1B,KAAI,CAAC,SAAU,OAAM,IAAI,MAAM;CAE/B,MAAM,OAAgB,SAAS;CAC/B,MAAM,SAAgB,SAAS,UAAiB;CAChD,MAAM,WAAgB,SAAS,YAAiB;CAChD,MAAM,YAAgB,SAAS,aAAiB;CAChD,MAAM,SAAgB,SAAS,UAAiB;CAChD,MAAM,gBAAgB,SAAS,iBAAiB;CAChD,MAAM,UAAgB,SAAS,WAAiB;CAChD,MAAM,UAAgB,SAAS,WAAiB;CAChD,MAAM,UAAgB,SAAS,WAAiB;CAKhD;EACE,MAAMC,aAAW,IAAI,IAAI,OACtB,KAAI,MAAM,CAAC,EAAE,QAAQ,YAAY,IACjC,QAAO,MAAK,CAAC,CAAC,EAAE;AAGnB,UAAQ,SAAQ,SAAQ;AACtB,OAAI,CAAC,KAAK,aAAc;AACxB,QAAK,eAAe,KAAK,aACtB,KAAK,MAA8C;AAClD,WAAO,OAAO,MAAM,WAAWA,WAAS,IAAI,KAAKA,WAAS,IAAI,EAAE,QAAQ;MAEzE,QAAQ,MAAkC,CAAC,CAAC;;AAGjD,UAAQ,OAAO,QAAQ,SAAQ,SAAQ;AACrC,OAAI,CAAC,KAAK,OAAQ;AAClB,QAAK,OAAO,SAAS,MAAsD;IACzE,MAAM,QAAQ,OAAO,EAAE,OAAO,WAAWA,WAAS,IAAI,EAAE,MAAMA,WAAS,IAAI,EAAE,GAAG,QAAQ;AACxF,QAAI,MAAO,GAAE,KAAK;;;;CAMxB,MAAM,WAAW,SAAS,aAAa,SAAS;CAGhD,MAAM,EAAE,KAAK,YAAY,QAAQ,kBAAkB,aAAa,SAAS,KAAK,UAAU,SAAS;CAEjG,MAAM,cAAcC,oBAAa,SAAS,QAAQ,QAAQ,UAAU;CAEpE,MAAMC,OAAmB;EACvB,UAAUC,iBAAY;EACtB,SAAUC,gBAAW,UAAU,YAAY;EAC3C,GAAG,iBAAiB,EAAE,SAAS;EAC/B,GAAG,QAAQ,EACT,OAAO;GACL,mBAAmB,KAAK;GACxB,MAAmB,KAAK;;EAI5B,QAAcC,oBAAe,SAAS,QAAQ,eAAe,UAAU,SAAS,YAAY;EAC5F,cAAcC,qBAAgB,WAAW,UAAU;EACnD,QAAcC,eAAU,QAAQ,UAAU,SACvC,OAAOC,iBAAY,UAAU,UAAU;EAC1C,aAAa,qBAAqB,SAAS,UAAU,SAClD,OAAO,oBAAoB,QAAQ,UAAU,UAC7C,OAAO,sBAAsB,UAAU,UAAU;;CAOtD,MAAM,2BAAW,IAAI;AACrB,KAAI,YAAY,MAAM;AACpB,UAAQ,SAAQ,MAAK,SAAS,IAAI,EAAE,OAAQ,YAAY;AAKxD,OAAK,cAAc,KAAK,aAAa,OAAO,MAAM,KAAK,YAAY;;CAOrE,MAAM,2BAAW,IAAI;;;;AAIrB,KAAI,QAAQ,MAAK,UAAS,WAAW,OACnC,MAAK,UAAU,KAAK,UAAU,IAAI,OAAOC,6BAAsB,OAAO,QAAO,MAAK,EAAE,WAAW,UAAU,UAAU,SAAS,UAAU;AAExI,KAAI,UAAU,MAAK,YAAW,WAAW,WAAW,wBAAwB,SAC1E,MAAK,UAAU,KAAK,UAAU,IAAI,OAAOA,6BAAsB,UAAU,UAAU,SAAS;AAE9F,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"days.js","names":["inherit: boolean","_days"],"sources":["../../../../../src/RS/v3/to/course-events/days.ts"],"sourcesContent":["import _days from '../days';\n\nimport { Types as CoreTypes } from '../../../../core/types';\nimport { Deserialized } from '../../../../core/types';\n\nimport { OutOptions } from '../../types/out-options';\n\nexport default function (event: Deserialized<CoreTypes.event>,\n settings: CoreTypes.divisionSettings,\n options: OutOptions) {\n const inherit: boolean = event.days === null;\n\n if (inherit || !('days' in event)) {\n return undefined;\n } else {\n return { days: _days(event.days!, settings.numDays) };\n }\n}"],"mappings":";;;AAOA,wBAAyB,OACvB,UACA,SAAsB;CACtB,MAAMA,UAAmB,MAAM,SAAS;AAExC,KAAI,WAAW,EAAE,UAAU,OACzB,QAAO;KAEP,QAAO,EAAE,MAAMC,aAAM,MAAM,MAAO,SAAS"}
1
+ {"version":3,"file":"days.js","names":["inherit: boolean","_days"],"sources":["../../../../../src/RS/v3/to/course-events/days.ts"],"sourcesContent":["import _days from '../days';\n\nimport { Types as CoreTypes } from '../../../../core/types';\nimport { Deserialized } from '../../../../core/types';\n\nimport { ParsedOutOptions as OutOptions } from '../../types/out-options';\n\nexport default function (event: Deserialized<CoreTypes.event>,\n settings: CoreTypes.divisionSettings,\n options: OutOptions) {\n const inherit: boolean = event.days === null;\n\n if (inherit || !('days' in event)) {\n return undefined;\n } else {\n return { days: _days(event.days!, settings.numDays) };\n }\n}"],"mappings":";;;AAOA,wBAAyB,OACvB,UACA,SAAsB;CACtB,MAAMA,UAAmB,MAAM,SAAS;AAExC,KAAI,WAAW,EAAE,UAAU,OACzB,QAAO;KAEP,QAAO,EAAE,MAAMC,aAAM,MAAM,MAAO,SAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.js","names":["inherit: boolean","availableDependencies"],"sources":["../../../../../src/RS/v3/to/course-events/dependencies.ts"],"sourcesContent":["import { Types as CoreTypes } from '../../../../core/types';\nimport { Deserialized } from '../../../../core/types';\n\nimport { OutOptions } from '../../types/out-options';\n\nimport availableDependencies from '../available-dependencies';\n\nexport default function (event: Deserialized<CoreTypes.event>,\n options: OutOptions) {\n if (!('locations' in event))\n return undefined;\n\n const inherit: boolean = event.locations === null;\n\n if (inherit) {\n return undefined;\n }\n\n const dependencies = availableDependencies(event.locations!, options);\n return { dependencies: [...new Set(dependencies)] };\n}\n"],"mappings":";;;AAOA,8BAAyB,OACvB,SAAqB;AACrB,KAAI,EAAE,eAAe,OACnB,QAAO;CAET,MAAMA,UAAmB,MAAM,cAAc;AAE7C,KAAI,QACF,QAAO;CAGT,MAAM,eAAeC,+BAAsB,MAAM,WAAY;AAC7D,QAAO,EAAE,cAAc,CAAC,GAAG,IAAI,IAAI"}
1
+ {"version":3,"file":"dependencies.js","names":["inherit: boolean","availableDependencies"],"sources":["../../../../../src/RS/v3/to/course-events/dependencies.ts"],"sourcesContent":["import { Types as CoreTypes } from '../../../../core/types';\nimport { Deserialized } from '../../../../core/types';\n\nimport { ParsedOutOptions as OutOptions } from '../../types/out-options';\n\nimport availableDependencies from '../available-dependencies';\n\nexport default function (event: Deserialized<CoreTypes.event>,\n options: OutOptions) {\n if (!('locations' in event))\n return undefined;\n\n const inherit: boolean = event.locations === null;\n\n if (inherit) {\n return undefined;\n }\n\n const dependencies = availableDependencies(event.locations!, options);\n return { dependencies: [...new Set(dependencies)] };\n}\n"],"mappings":";;;AAOA,8BAAyB,OACvB,SAAqB;AACrB,KAAI,EAAE,eAAe,OACnB,QAAO;CAET,MAAMA,UAAmB,MAAM,cAAc;AAE7C,KAAI,QACF,QAAO;CAGT,MAAM,eAAeC,+BAAsB,MAAM,WAAY;AAC7D,QAAO,EAAE,cAAc,CAAC,GAAG,IAAI,IAAI"}
@@ -1 +1 @@
1
- {"version":3,"file":"groups.js","names":[],"sources":["../../../../../src/RS/v3/to/course-events/groups.ts"],"sourcesContent":["import { Types as CoreTypes } from '../../../../core/types';\nimport { Deserialized } from '../../../../core/types';\n\nimport { Individual } from '../../types/individuals';\nimport { OutOptions } from '../../types/out-options';\nimport { mergeWithParentGroups } from '../util';\n\n/**\n * @description replaces groups references with their composites while taking into account excluded participants\n */\nexport function deconstructGroups (\n groups: NonNullable<Deserialized<CoreTypes.event>['groups']>,\n participantIds: { individuals: string | string[] }[],\n destructMap: Map<string | null, Individual>,\n options: OutOptions\n): NonNullable<Deserialized<CoreTypes.event>['groups']> {\n const idKey = options.idKey || 'id';\n\n // include and prioritize parent groups by replacing references to the same group\n\n if (destructMap.size) {\n groups = groups\n .map(group => {\n\n if (!group.exclude?.length) return group;\n\n const arr = [group.to[idKey]?.toString()].concat(group.exclude.map(y => y[idKey]?.toString()!));\n const key = arr.sort().join('.');\n const destructed = destructMap.get(key);\n if (!destructed) return group;\n\n // push to array of participants\n participantIds.push({ individuals: destructed.id });\n return null;\n })\n .filter((x): x is NonNullable<typeof x> => x != null);\n }\n\n return groups;\n}\n\nexport function mapGroupReferences (\n source: Deserialized<CoreTypes.event> & Deserialized<CoreTypes.course>,\n options: OutOptions,\n destructMap: Map<string | null, Individual>\n) {\n const idKey = options.idKey || 'id';\n\n const teachers = (source.teachers ?? source.course?.teachers ?? []).filter(x => x.to != null); // filter out dead references\n const groups = (source.groups ?? source.course?.groups ?? []).filter(x => x.to != null); // filter out dead references\n const participants = (source.participants ?? source.course?.participants ?? []).filter(x => x.to != null); // filter out dead references\n\n const teacherIds = teachers .map(({ to }) => to[idKey]).filter((x): x is NonNullable<typeof x> => !!x)\n .map(x => ({ individuals: ['teachers.individuals.' + x.toString()] }));\n const participantIds = participants.map(({ to }) => to[idKey]).filter((x): x is NonNullable<typeof x> => !!x)\n .map(x => ({ individuals: ['persons.' + x.toString()] }));\n\n // merge the group references with their parent groups\n const groupReferences = mergeWithParentGroups(groups, options);\n\n const deconstructed = deconstructGroups(groupReferences, participantIds, destructMap, options);\n\n const groupIds = deconstructed.map(({ to }) => {\n const id = 'groups.' + to[idKey]?.toString();\n if (to.species == null) return { individuals: id };\n return id;\n });\n\n const out = [...new Set(teacherIds), ...new Set(groupIds), ...new Set(participantIds)].map(x => [x]);\n return out;\n}"],"mappings":";;;;;;AAUA,SAAgB,kBACd,QACA,gBACA,aACA,SACsD;CACtD,MAAM,QAAQ,QAAQ,SAAS;AAI/B,KAAI,YAAY,KACd,UAAS,OACN,KAAI,UAAS;AAEZ,MAAI,CAAC,MAAM,SAAS,OAAQ,QAAO;EAEnC,MAAM,MAAM,CAAC,MAAM,GAAG,QAAQ,YAAY,OAAO,MAAM,QAAQ,KAAI,MAAK,EAAE,QAAQ;EAClF,MAAM,MAAM,IAAI,OAAO,KAAK;EAC5B,MAAM,aAAa,YAAY,IAAI;AACnC,MAAI,CAAC,WAAY,QAAO;AAGxB,iBAAe,KAAK,EAAE,aAAa,WAAW;AAC9C,SAAO;IAER,QAAQ,MAAkC,KAAK;AAGpD,QAAO;;AAGT,SAAgB,mBACd,QACA,SACA,aACA;CACA,MAAM,QAAQ,QAAQ,SAAS;CAE/B,MAAM,YAAgB,OAAO,YAAgB,OAAO,QAAQ,YAAgB,IAAI,QAAO,MAAK,EAAE,MAAM;CACpG,MAAM,UAAgB,OAAO,UAAgB,OAAO,QAAQ,UAAgB,IAAI,QAAO,MAAK,EAAE,MAAM;CACpG,MAAM,gBAAgB,OAAO,gBAAgB,OAAO,QAAQ,gBAAgB,IAAI,QAAO,MAAK,EAAE,MAAM;CAEpG,MAAM,aAAiB,SAAa,KAAK,EAAE,SAAS,GAAG,QAAQ,QAAQ,MAAkC,CAAC,CAAC,GACxG,KAAI,OAAM,EAAE,aAAa,CAAC,0BAA0B,EAAE;CACzD,MAAM,iBAAiB,aAAa,KAAK,EAAE,SAAS,GAAG,QAAQ,QAAQ,MAAkC,CAAC,CAAC,GACxG,KAAI,OAAM,EAAE,aAAa,CAAC,aAAc,EAAE;CAG7C,MAAM,kBAAkB,sBAAsB,QAAQ;CAEtD,MAAM,gBAAgB,kBAAkB,iBAAiB,gBAAgB,aAAa;CAEtF,MAAM,WAAW,cAAc,KAAK,EAAE,SAAS;EAC7C,MAAM,KAAK,YAAY,GAAG,QAAQ;AAClC,MAAI,GAAG,WAAW,KAAM,QAAO,EAAE,aAAa;AAC9C,SAAO;;CAGT,MAAM,MAAM;EAAC,GAAG,IAAI,IAAI;EAAa,GAAG,IAAI,IAAI;EAAW,GAAG,IAAI,IAAI;GAAiB,KAAI,MAAK,CAAC;AACjG,QAAO"}
1
+ {"version":3,"file":"groups.js","names":[],"sources":["../../../../../src/RS/v3/to/course-events/groups.ts"],"sourcesContent":["import { Types as CoreTypes } from '../../../../core/types';\nimport { Deserialized } from '../../../../core/types';\n\nimport { Individual } from '../../types/individuals';\nimport { ParsedOutOptions as OutOptions } from '../../types/out-options';\nimport { mergeWithParentGroups } from '../util';\n\n/**\n * @description replaces groups references with their composites while taking into account excluded participants\n */\nexport function deconstructGroups (\n groups: NonNullable<Deserialized<CoreTypes.event>['groups']>,\n participantIds: { individuals: string | string[] }[],\n destructMap: Map<string | null, Individual>,\n options: OutOptions\n): NonNullable<Deserialized<CoreTypes.event>['groups']> {\n const idKey = options.idKey || 'id';\n\n // include and prioritize parent groups by replacing references to the same group\n\n if (destructMap.size) {\n groups = groups\n .map(group => {\n\n if (!group.exclude?.length) return group;\n\n const arr = [group.to[idKey]?.toString()].concat(group.exclude.map(y => y[idKey]?.toString()!));\n const key = arr.sort().join('.');\n const destructed = destructMap.get(key);\n if (!destructed) return group;\n\n // push to array of participants\n participantIds.push({ individuals: destructed.id });\n return null;\n })\n .filter((x): x is NonNullable<typeof x> => x != null);\n }\n\n return groups;\n}\n\nexport function mapGroupReferences (\n source: Deserialized<CoreTypes.event> & Deserialized<CoreTypes.course>,\n options: OutOptions,\n destructMap: Map<string | null, Individual>\n) {\n const idKey = options.idKey || 'id';\n\n const teachers = (source.teachers ?? source.course?.teachers ?? []).filter(x => x.to != null); // filter out dead references\n const groups = (source.groups ?? source.course?.groups ?? []).filter(x => x.to != null); // filter out dead references\n const participants = (source.participants ?? source.course?.participants ?? []).filter(x => x.to != null); // filter out dead references\n\n const teacherIds = teachers .map(({ to }) => to[idKey]).filter((x): x is NonNullable<typeof x> => !!x)\n .map(x => ({ individuals: ['teachers.individuals.' + x.toString()] }));\n const participantIds = participants.map(({ to }) => to[idKey]).filter((x): x is NonNullable<typeof x> => !!x)\n .map(x => ({ individuals: ['persons.' + x.toString()] }));\n\n // merge the group references with their parent groups\n const groupReferences = mergeWithParentGroups(groups, options);\n\n const deconstructed = deconstructGroups(groupReferences, participantIds, destructMap, options);\n\n const groupIds = deconstructed.map(({ to }) => {\n const id = 'groups.' + to[idKey]?.toString();\n if (to.species == null) return { individuals: id };\n return id;\n });\n\n const out = [...new Set(teacherIds), ...new Set(groupIds), ...new Set(participantIds)].map(x => [x]);\n return out;\n}"],"mappings":";;;;;;AAUA,SAAgB,kBACd,QACA,gBACA,aACA,SACsD;CACtD,MAAM,QAAQ,QAAQ,SAAS;AAI/B,KAAI,YAAY,KACd,UAAS,OACN,KAAI,UAAS;AAEZ,MAAI,CAAC,MAAM,SAAS,OAAQ,QAAO;EAEnC,MAAM,MAAM,CAAC,MAAM,GAAG,QAAQ,YAAY,OAAO,MAAM,QAAQ,KAAI,MAAK,EAAE,QAAQ;EAClF,MAAM,MAAM,IAAI,OAAO,KAAK;EAC5B,MAAM,aAAa,YAAY,IAAI;AACnC,MAAI,CAAC,WAAY,QAAO;AAGxB,iBAAe,KAAK,EAAE,aAAa,WAAW;AAC9C,SAAO;IAER,QAAQ,MAAkC,KAAK;AAGpD,QAAO;;AAGT,SAAgB,mBACd,QACA,SACA,aACA;CACA,MAAM,QAAQ,QAAQ,SAAS;CAE/B,MAAM,YAAgB,OAAO,YAAgB,OAAO,QAAQ,YAAgB,IAAI,QAAO,MAAK,EAAE,MAAM;CACpG,MAAM,UAAgB,OAAO,UAAgB,OAAO,QAAQ,UAAgB,IAAI,QAAO,MAAK,EAAE,MAAM;CACpG,MAAM,gBAAgB,OAAO,gBAAgB,OAAO,QAAQ,gBAAgB,IAAI,QAAO,MAAK,EAAE,MAAM;CAEpG,MAAM,aAAiB,SAAa,KAAK,EAAE,SAAS,GAAG,QAAQ,QAAQ,MAAkC,CAAC,CAAC,GACxG,KAAI,OAAM,EAAE,aAAa,CAAC,0BAA0B,EAAE;CACzD,MAAM,iBAAiB,aAAa,KAAK,EAAE,SAAS,GAAG,QAAQ,QAAQ,MAAkC,CAAC,CAAC,GACxG,KAAI,OAAM,EAAE,aAAa,CAAC,aAAc,EAAE;CAG7C,MAAM,kBAAkB,sBAAsB,QAAQ;CAEtD,MAAM,gBAAgB,kBAAkB,iBAAiB,gBAAgB,aAAa;CAEtF,MAAM,WAAW,cAAc,KAAK,EAAE,SAAS;EAC7C,MAAM,KAAK,YAAY,GAAG,QAAQ;AAClC,MAAI,GAAG,WAAW,KAAM,QAAO,EAAE,aAAa;AAC9C,SAAO;;CAGT,MAAM,MAAM;EAAC,GAAG,IAAI,IAAI;EAAa,GAAG,IAAI,IAAI;EAAW,GAAG,IAAI,IAAI;GAAiB,KAAI,MAAK,CAAC;AACjG,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"in-locations.js","names":["idKey: Id","inherit: boolean","availableDependencies"],"sources":["../../../../../src/RS/v3/to/course-events/in-locations.ts"],"sourcesContent":["import availableDependencies from '../available-dependencies';\n\nimport { Types as CoreTypes } from '../../../../core/types';\nimport { Deserialized } from '../../../../core/types';\n\nimport { OutOptions,\n Id } from '../../types/out-options';\n\nexport default function (event: Deserialized<CoreTypes.event>, options: OutOptions) {\n const idKey: Id = options.idKey || 'id';\n\n if (!event)\n throw new Error('(RS::V3::To::CourseEvent::InLocations) Mapping in-locations failed due to event being undefined');\n\n const course = event.course;\n\n if (!course)\n throw new Error('(RS::V3::To::CourseEvent::InLocations) Mapping in-locations failed due to event course being undefined');\n\n const inherit: boolean = event.locations === null;\n\n const dependencies = inherit\n ? availableDependencies(course.locations!, options) :\n availableDependencies(event.locations!, options);\n\n const inLocation = event.inLocations || [];\n\n if (inLocation.length === dependencies.length) {\n return inLocation\n .map(x => typeof x === 'string' ? x : x?.[idKey]?.toString() ?? null);\n } else {\n return inLocation\n .map(x => typeof x === 'string' ? x : x?.[idKey]?.toString() ?? null)\n .concat(Array.from({ length: Math.max(dependencies.length - inLocation.length, 0) }).map(() => null as string | null));\n }\n}"],"mappings":";;;AAQA,8BAAyB,OAAsC,SAAqB;CAClF,MAAMA,QAAwB,QAAQ,SAAS;AAE/C,KAAI,CAAC,MACH,OAAM,IAAI,MAAM;CAElB,MAAM,SAAS,MAAM;AAErB,KAAI,CAAC,OACH,OAAM,IAAI,MAAM;CAElB,MAAMC,UAAwB,MAAM,cAAc;CAElD,MAAM,eAAe,UACjBC,+BAAsB,OAAO,WAAY,WAC3CA,+BAAsB,MAAM,WAAY;CAE1C,MAAM,aAAa,MAAM,eAAe;AAExC,KAAI,WAAW,WAAW,aAAa,OACrC,QAAO,WACJ,KAAI,MAAK,OAAO,MAAM,WAAW,IAAI,IAAI,QAAQ,cAAc;KAElE,QAAO,WACJ,KAAI,MAAK,OAAO,MAAM,WAAW,IAAI,IAAI,QAAQ,cAAc,MAC/D,OAAO,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,aAAa,SAAS,WAAW,QAAQ,MAAM,UAAU"}
1
+ {"version":3,"file":"in-locations.js","names":["idKey: Id","inherit: boolean","availableDependencies"],"sources":["../../../../../src/RS/v3/to/course-events/in-locations.ts"],"sourcesContent":["import availableDependencies from '../available-dependencies';\n\nimport { Types as CoreTypes } from '../../../../core/types';\nimport { Deserialized } from '../../../../core/types';\n\nimport { ParsedOutOptions as OutOptions,\n Id } from '../../types/out-options';\n\nexport default function (event: Deserialized<CoreTypes.event>, options: OutOptions) {\n const idKey: Id = options.idKey || 'id';\n\n if (!event)\n throw new Error('(RS::V3::To::CourseEvent::InLocations) Mapping in-locations failed due to event being undefined');\n\n const course = event.course;\n\n if (!course)\n throw new Error('(RS::V3::To::CourseEvent::InLocations) Mapping in-locations failed due to event course being undefined');\n\n const inherit: boolean = event.locations === null;\n\n const dependencies = inherit\n ? availableDependencies(course.locations!, options) :\n availableDependencies(event.locations!, options);\n\n const inLocation = event.inLocations || [];\n\n if (inLocation.length === dependencies.length) {\n return inLocation\n .map(x => typeof x === 'string' ? x : x?.[idKey]?.toString() ?? null);\n } else {\n return inLocation\n .map(x => typeof x === 'string' ? x : x?.[idKey]?.toString() ?? null)\n .concat(Array.from({ length: Math.max(dependencies.length - inLocation.length, 0) }).map(() => null as string | null));\n }\n}"],"mappings":";;;AAQA,8BAAyB,OAAsC,SAAqB;CAClF,MAAMA,QAAwB,QAAQ,SAAS;AAE/C,KAAI,CAAC,MACH,OAAM,IAAI,MAAM;CAElB,MAAM,SAAS,MAAM;AAErB,KAAI,CAAC,OACH,OAAM,IAAI,MAAM;CAElB,MAAMC,UAAwB,MAAM,cAAc;CAElD,MAAM,eAAe,UACjBC,+BAAsB,OAAO,WAAY,WAC3CA,+BAAsB,MAAM,WAAY;CAE1C,MAAM,aAAa,MAAM,eAAe;AAExC,KAAI,WAAW,WAAW,aAAa,OACrC,QAAO,WACJ,KAAI,MAAK,OAAO,MAAM,WAAW,IAAI,IAAI,QAAQ,cAAc;KAElE,QAAO,WACJ,KAAI,MAAK,OAAO,MAAM,WAAW,IAAI,IAAI,QAAQ,cAAc,MAC/D,OAAO,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,aAAa,SAAS,WAAW,QAAQ,MAAM,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["idKey: keyof CoreTypes.event","id","doc: CourseEvent","lockedTimes","breakLength","_dependencies","_meta","_days","_intervals"],"sources":["../../../../../src/RS/v3/to/course-events/index.ts"],"sourcesContent":["import moment from 'moment';\n\nimport breakLength from '../break-lengths';\nimport lockedTimes from '../locked-times';\n\nimport { CourseEvent } from '../../types/course-events';\nimport { OutOptions } from '../../types/out-options';\nimport { Individual } from '../../types/individuals';\n\nimport { Types as CoreTypes } from '../../../../core/types';\nimport { Deserialized } from '../../../../core/types';\n\n\nimport { mapGroupReferences } from './groups';\nimport _meta from './meta';\nimport _dependencies from './dependencies';\nimport _days from './days';\nimport _intervals from './intervals';\nimport { AvailableDependency } from '../../types/available-dependencies';\n\nexport function toDayAndStart (start: string | moment.Moment | Date) {\n return {\n start: parseFloat(moment.utc(start).format('HH.mm')),\n day: (moment.utc(start).day() + 6) % 7\n };\n}\n\nexport default function (\n courseEvents: Deserialized<CoreTypes.event>[] | Deserialized<CoreTypes.event>,\n overlapGroups: Deserialized<CoreTypes.overlapGroup>[] = [],\n settings: CoreTypes.divisionSettings,\n options: OutOptions,\n periodsMap: Map<string | undefined, number>,\n destructMap: Map<string | null, Individual> = new Map()\n): CourseEvent[] {\n const idKey: keyof CoreTypes.event = options.idKey ?? 'id';\n\n return (Array.isArray(courseEvents) ? courseEvents : [courseEvents])\n .map(event => {\n const id = (event[idKey] ?? event._id)?.toString();\n if (!id) return;\n\n let forcedOverlapId;\n if (event?.overlapSpecies != null) {\n const { species: _species = [] } = overlapGroups.find(({ id }) => event.overlapSpecies!.id == id) ?? {};\n const species = _species.find(({ to: { id }, toModel }) => (toModel == 'events' || toModel == 'courseevents') && event.id == id);\n if (species) forcedOverlapId = species.id;\n }\n\n if (event.period && periodsMap.size && !periodsMap.has(event.period.id)) {\n throw new Error(`(RS::V3::To::Collections) Course ${event[idKey]} has a period that does not exist`);\n }\n\n const duration = event.preferredDuration ?? event.duration;\n if (!duration) return;\n\n /*\n preferredDuration overrides duration\n */\n const doc: CourseEvent = {\n id: `events.${ id }`,\n // temporary, should be preferred duration only!\n length: duration,\n // optional\n ...event.durationVariance != null && { maxLengthVariance: event.durationVariance },\n ...'weight' in event && { weight: event.weight },\n ...'density' in event && { density: event.density },\n ...event.lockedTimes?.length && { lockedTimes: lockedTimes((event.lockedTimes), options) },\n ...(event.minBreakLength != null) && { minBreakLength: breakLength(event.minBreakLength) },\n ...event.centerOfAttraction && { potentialCenter: parseFloat(event.centerOfAttraction.replace(':', '.')) },\n ...(forcedOverlapId != null) && { forcedOverlapId },\n ...event.period && periodsMap.size && { period: periodsMap.get(event.period?.id) },\n };\n\n const groups = mapGroupReferences(event, options, destructMap);\n if (groups) doc.groups = groups;\n\n const dependencies = _dependencies(event, options);\n if (dependencies)\n Object.assign(doc, dependencies);\n\n if (options.meta) {\n Object.assign(doc, _meta(event, options));\n }\n\n const days = _days(event, settings, options);\n if (days)\n Object.assign(doc, days);\n\n const intervals = _intervals(event, settings, options);\n if (intervals)\n Object.assign(doc, intervals);\n\n if (event.fixedStart && event.start) {\n Object.assign(doc, toDayAndStart(event.start));\n }\n\n ////\n //// filter events based on partialScheduleOptions\n ////\n if (options.partialScheduleOptions) {\n const { includedEvents, omittedEventsHandling } = options.partialScheduleOptions;\n if (includedEvents && !includedEvents.has(doc.id)) {\n\n if (omittedEventsHandling == 'ignore') return;\n\n if (omittedEventsHandling == 'freeze') {\n // must not be parked and have a start and duration to be frozen, otherwise it's ignored\n if (event.parked || !event.start || !event.duration) return;\n\n // fix day, start and end\n Object.assign(doc, toDayAndStart(event.start));\n doc.length = event.duration;\n doc.maxLengthVariance = 0;\n\n // override intervals and days to not cause conflicts\n const numDays = settings.numDays ?? 5;\n doc.days = Array.from({ length: numDays }, (_, i) => i);\n doc.intervals = Array.from({ length: numDays }, () => [{ beg: 0, end: 23.55 }]);\n\n // fix locations\n doc.dependencies = (event.inLocations ?? [])\n .map(x => {\n const id = typeof x === 'string' ? x : x?.[idKey]?.toString();\n if (!id) return;\n\n const includedLocations = options.partialScheduleOptions?.includedLocations;\n if (includedLocations && !includedLocations.has(id)) return;\n\n return [{ dependency: id }] as AvailableDependency[];\n })\n .filter((x): x is NonNullable<typeof x> => !!x);\n }\n\n }\n }\n\n return doc;\n })\n .filter((x): x is NonNullable<typeof x> => !!x);\n}"],"mappings":"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"}
1
+ {"version":3,"file":"index.js","names":["idKey: keyof CoreTypes.event","id","doc: CourseEvent","lockedTimes","breakLength","_dependencies","_meta","_days","_intervals"],"sources":["../../../../../src/RS/v3/to/course-events/index.ts"],"sourcesContent":["import moment from 'moment';\n\nimport breakLength from '../break-lengths';\nimport lockedTimes from '../locked-times';\n\nimport { CourseEvent } from '../../types/course-events';\nimport { ParsedOutOptions as OutOptions } from '../../types/out-options';\nimport { Individual } from '../../types/individuals';\n\nimport { Types as CoreTypes } from '../../../../core/types';\nimport { Deserialized } from '../../../../core/types';\n\n\nimport { mapGroupReferences } from './groups';\nimport _meta from './meta';\nimport _dependencies from './dependencies';\nimport _days from './days';\nimport _intervals from './intervals';\nimport { AvailableDependency } from '../../types/available-dependencies';\n\nexport function toDayAndStart (start: string | moment.Moment | Date) {\n return {\n start: parseFloat(moment.utc(start).format('HH.mm')),\n day: (moment.utc(start).day() + 6) % 7\n };\n}\n\nexport default function (\n courseEvents: Deserialized<CoreTypes.event>[] | Deserialized<CoreTypes.event>,\n overlapGroups: Deserialized<CoreTypes.overlapGroup>[] = [],\n settings: CoreTypes.divisionSettings,\n options: OutOptions,\n periodsMap: Map<string | undefined, number>,\n destructMap: Map<string | null, Individual> = new Map()\n): CourseEvent[] {\n const idKey: keyof CoreTypes.event = options.idKey ?? 'id';\n\n return (Array.isArray(courseEvents) ? courseEvents : [courseEvents])\n .map(event => {\n const id = (event[idKey] ?? event._id)?.toString();\n if (!id) return;\n\n let forcedOverlapId;\n if (event?.overlapSpecies != null) {\n const { species: _species = [] } = overlapGroups.find(({ id }) => event.overlapSpecies!.id == id) ?? {};\n const species = _species.find(({ to: { id }, toModel }) => (toModel == 'events' || toModel == 'courseevents') && event.id == id);\n if (species) forcedOverlapId = species.id;\n }\n\n if (event.period && periodsMap.size && !periodsMap.has(event.period.id)) {\n throw new Error(`(RS::V3::To::Collections) Course ${event[idKey]} has a period that does not exist`);\n }\n\n const duration = event.preferredDuration ?? event.duration;\n if (!duration) return;\n\n /*\n preferredDuration overrides duration\n */\n const doc: CourseEvent = {\n id: `events.${ id }`,\n // temporary, should be preferred duration only!\n length: duration,\n // optional\n ...event.durationVariance != null && { maxLengthVariance: event.durationVariance },\n ...'weight' in event && { weight: event.weight },\n ...'density' in event && { density: event.density },\n ...event.lockedTimes?.length && { lockedTimes: lockedTimes((event.lockedTimes), options) },\n ...(event.minBreakLength != null) && { minBreakLength: breakLength(event.minBreakLength) },\n ...event.centerOfAttraction && { potentialCenter: parseFloat(event.centerOfAttraction.replace(':', '.')) },\n ...(forcedOverlapId != null) && { forcedOverlapId },\n ...event.period && periodsMap.size && { period: periodsMap.get(event.period?.id) },\n };\n\n const groups = mapGroupReferences(event, options, destructMap);\n if (groups) doc.groups = groups;\n\n const dependencies = _dependencies(event, options);\n if (dependencies)\n Object.assign(doc, dependencies);\n\n if (options.meta) {\n Object.assign(doc, _meta(event, options));\n }\n\n const days = _days(event, settings, options);\n if (days)\n Object.assign(doc, days);\n\n const intervals = _intervals(event, settings, options);\n if (intervals)\n Object.assign(doc, intervals);\n\n if (event.fixedStart && event.start) {\n Object.assign(doc, toDayAndStart(event.start));\n }\n\n ////\n //// filter events based on partialScheduleOptions\n ////\n if (options.partialScheduleOptions) {\n const { includedEvents, omittedEventsHandling } = options.partialScheduleOptions;\n if (includedEvents && !includedEvents.has(doc.id)) {\n\n if (omittedEventsHandling == 'ignore') return;\n\n if (omittedEventsHandling == 'freeze') {\n // must not be parked and have a start and duration to be frozen, otherwise it's ignored\n if (event.parked || !event.start || !event.duration) return;\n\n // fix day, start and end\n Object.assign(doc, toDayAndStart(event.start));\n doc.length = event.duration;\n doc.maxLengthVariance = 0;\n\n // override intervals and days to not cause conflicts\n const numDays = settings.numDays ?? 5;\n doc.days = Array.from({ length: numDays }, (_, i) => i);\n doc.intervals = Array.from({ length: numDays }, () => [{ beg: 0, end: 23.55 }]);\n\n // fix locations\n doc.dependencies = (event.inLocations ?? [])\n .map(x => {\n const id = typeof x === 'string' ? x : x?.[idKey]?.toString();\n if (!id) return;\n\n const includedLocations = options.partialScheduleOptions?.includedLocations;\n if (includedLocations && !includedLocations.has(id)) return;\n\n return [{ dependency: id }] as AvailableDependency[];\n })\n .filter((x): x is NonNullable<typeof x> => !!x);\n }\n\n }\n }\n\n return doc;\n })\n .filter((x): x is NonNullable<typeof x> => !!x);\n}"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"intervals.js","names":["_intervals"],"sources":["../../../../../src/RS/v3/to/course-events/intervals.ts"],"sourcesContent":["import _intervals from '../intervals';\n\nimport { Types as CoreTypes } from '../../../../core/types';\n\nimport { OutOptions } from '../../types/out-options';\n\nexport default function (event: CoreTypes.event,\n settings: CoreTypes.divisionSettings,\n options: OutOptions) {\n\n if (event.intervals?.length)\n return { intervals: _intervals(event.intervals, settings) };\n return undefined;\n}"],"mappings":";;;AAMA,6BAAyB,OACvB,UACA,SAAsB;AAEtB,KAAI,MAAM,WAAW,OACnB,QAAO,EAAE,WAAWA,kBAAW,MAAM,WAAW;AAClD,QAAO"}
1
+ {"version":3,"file":"intervals.js","names":["_intervals"],"sources":["../../../../../src/RS/v3/to/course-events/intervals.ts"],"sourcesContent":["import _intervals from '../intervals';\n\nimport { Types as CoreTypes } from '../../../../core/types';\n\nimport { ParsedOutOptions as OutOptions } from '../../types/out-options';\n\nexport default function (event: CoreTypes.event,\n settings: CoreTypes.divisionSettings,\n options: OutOptions) {\n\n if (event.intervals?.length)\n return { intervals: _intervals(event.intervals, settings) };\n return undefined;\n}"],"mappings":";;;AAMA,6BAAyB,OACvB,UACA,SAAsB;AAEtB,KAAI,MAAM,WAAW,OACnB,QAAO,EAAE,WAAWA,kBAAW,MAAM,WAAW;AAClD,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"meta.js","names":["meta: Meta","_inLocations"],"sources":["../../../../../src/RS/v3/to/course-events/meta.ts"],"sourcesContent":["import moment from 'moment';\n\nimport { Types as CoreTypes } from '../../../../core/types';\nimport { Deserialized } from '../../../../core/types';\n\nimport { OutOptions,\n Id } from '../../types/out-options';\n\nimport _inLocations from './in-locations';\n\ntype Meta = {\n course?: string;\n name?: string;\n ids?: string;\n parked?: boolean;\n visible?: boolean;\n start?: moment.Moment;\n end?: moment.Moment;\n inLocations?: (string | null)[];\n};\n\nexport default function (event: Deserialized<CoreTypes.event>,\n options: OutOptions): Meta {\n const idKey: Id = options.idKey || 'id';\n\n const meta: Meta = {\n ...event.displayName && { name: event.displayName },\n ...event.hasOwnProperty('ids') && { ids: event.ids },\n ...event.hasOwnProperty('parked') && { parked: event.parked },\n ...event.hasOwnProperty('visible') && { visible: event.visible },\n ...event.hasOwnProperty('start') && { startDate: event.start as moment.Moment },\n ...event.hasOwnProperty('end') && { endDate: event.end as moment.Moment },\n };\n\n if (event.course?.id)\n meta.course = event.course.id;\n\n if (event.inLocations)\n meta.inLocations = _inLocations(event, options);\n\n return meta;\n}"],"mappings":";;;AAqBA,sBAAyB,OACvB,SAA2B;AACG,SAAQ;CAEtC,MAAMA,OAAa;EACjB,GAAG,MAAM,eAAoC,EAAE,MAAgB,MAAM;EACrE,GAAG,MAAM,eAAe,UAAqB,EAAE,KAAgB,MAAM;EACrE,GAAG,MAAM,eAAe,aAAqB,EAAE,QAAgB,MAAM;EACrE,GAAG,MAAM,eAAe,cAAqB,EAAE,SAAgB,MAAM;EACrE,GAAG,MAAM,eAAe,YAAqB,EAAE,WAAgB,MAAM;EACrE,GAAG,MAAM,eAAe,UAAqB,EAAE,SAAgB,MAAM;;AAGvE,KAAI,MAAM,QAAQ,GAChB,MAAK,SAAc,MAAM,OAAO;AAElC,KAAI,MAAM,YACR,MAAK,cAAcC,qBAAa,OAAO;AAEzC,QAAO"}
1
+ {"version":3,"file":"meta.js","names":["meta: Meta","_inLocations"],"sources":["../../../../../src/RS/v3/to/course-events/meta.ts"],"sourcesContent":["import moment from 'moment';\n\nimport { Types as CoreTypes } from '../../../../core/types';\nimport { Deserialized } from '../../../../core/types';\n\nimport { ParsedOutOptions as OutOptions,\n Id } from '../../types/out-options';\n\nimport _inLocations from './in-locations';\n\ntype Meta = {\n course?: string;\n name?: string;\n ids?: string;\n parked?: boolean;\n visible?: boolean;\n start?: moment.Moment;\n end?: moment.Moment;\n inLocations?: (string | null)[];\n};\n\nexport default function (event: Deserialized<CoreTypes.event>,\n options: OutOptions): Meta {\n const idKey: Id = options.idKey || 'id';\n\n const meta: Meta = {\n ...event.displayName && { name: event.displayName },\n ...event.hasOwnProperty('ids') && { ids: event.ids },\n ...event.hasOwnProperty('parked') && { parked: event.parked },\n ...event.hasOwnProperty('visible') && { visible: event.visible },\n ...event.hasOwnProperty('start') && { startDate: event.start as moment.Moment },\n ...event.hasOwnProperty('end') && { endDate: event.end as moment.Moment },\n };\n\n if (event.course?.id)\n meta.course = event.course.id;\n\n if (event.inLocations)\n meta.inLocations = _inLocations(event, options);\n\n return meta;\n}"],"mappings":";;;AAqBA,sBAAyB,OACvB,SAA2B;AACG,SAAQ;CAEtC,MAAMA,OAAa;EACjB,GAAG,MAAM,eAAoC,EAAE,MAAgB,MAAM;EACrE,GAAG,MAAM,eAAe,UAAqB,EAAE,KAAgB,MAAM;EACrE,GAAG,MAAM,eAAe,aAAqB,EAAE,QAAgB,MAAM;EACrE,GAAG,MAAM,eAAe,cAAqB,EAAE,SAAgB,MAAM;EACrE,GAAG,MAAM,eAAe,YAAqB,EAAE,WAAgB,MAAM;EACrE,GAAG,MAAM,eAAe,UAAqB,EAAE,SAAgB,MAAM;;AAGvE,KAAI,MAAM,QAAQ,GAChB,MAAK,SAAc,MAAM,OAAO;AAElC,KAAI,MAAM,YACR,MAAK,cAAcC,qBAAa,OAAO;AAEzC,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"default.js","names":["res: Default"],"sources":["../../../../src/RS/v3/to/default.ts"],"sourcesContent":["import { Default } from '../types/default';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { OutOptions } from '../types/out-options';\nimport { min2hrs } from './util';\n\nfunction toTime (str: string) {\n return parseFloat(str.replace(':', '.'));\n}\n\nexport default (\n settings: Deserialized<CoreTypes.divisionSettings>,\n periodMap: Map<string | undefined, number>,\n options: OutOptions\n) => {\n\n\n const { dayStart, dayEnd } = settings;\n\n if (!dayStart) throw new Error('(RS::V3::To::Default) \"dayStart\" is falsy');\n if (!dayEnd) throw new Error('(RS::V3::To::Default) \"dayEnd\" is falsy');\n\n if (periodMap.size && !periodMap.has(settings.period?.id)) throw new Error('(RS::V3::To::Default) \"period\" is not in periodMap');\n\n const maxNumWorkingHours = options.useMaximumScheduleSpan\n ? min2hrs(settings.defaultMaximumScheduleSpan?.daily) ?? false\n : settings.defaultMaxNumWorkingHours ?? false;\n\n const maxNumDailyWorkingHours = options.useMaximumScheduleSpan\n ? min2hrs(settings.defaultMaximumScheduleSpan?.daily) ?? false\n : settings.defaultMaxNumDailyWorkingHours ?? false;\n\n const res: Default = {\n intervals: [[{ beg: toTime(dayStart), end: toTime(dayEnd) }]],\n\n groupMinBreakLength: settings.defaultGroupMinimumBreakLength ?? 0,\n dependencyMinBreakLength: settings.defaultDependencyMinimumBreakLength ?? 0,\n eventMinBreakLength: settings.defaultEventMinimumBreakLength ?? 0,\n\n potentialCenter: toTime(settings.potentialCenter ?? '12:00'),\n eventDensity: settings.defaultEventDensity ?? 0,\n\n maxEventLengthVariance: settings.defaultEventDurationVariance ?? 0,\n\n maxNumWorkingHours: maxNumWorkingHours,\n maxNumDailyWorkingHours: maxNumDailyWorkingHours,\n\n dependencyRank: settings.defaultDependencyRank ?? 0,\n groupRank: settings.defaultGroupRank ?? 0,\n dayRank: settings.defaultDayRank ?? 0,\n\n groupWeight: settings.defaultGroupWeight ?? 0,\n collectionWeight: settings.defaultCourseWeight ?? 0,\n eventWeight: settings.defaultEventWeight ?? 0,\n\n ...periodMap.size && { period: periodMap.get(settings.period?.id)! }\n };\n\n return res;\n};"],"mappings":";;;AAOA,SAAS,OAAQ,KAAa;AAC5B,QAAO,WAAW,IAAI,QAAQ,KAAK;;AAGrC,uBACE,UACA,WACA,YACG;CAGH,MAAM,EAAE,UAAU,WAAW;AAE7B,KAAI,CAAC,SAAU,OAAM,IAAI,MAAM;AAC/B,KAAI,CAAC,OAAU,OAAM,IAAI,MAAM;AAE/B,KAAI,UAAU,QAAQ,CAAC,UAAU,IAAI,SAAS,QAAQ,IAAK,OAAM,IAAI,MAAM;CAE3E,MAAM,qBAAqB,QAAQ,yBAC/B,QAAQ,SAAS,4BAA4B,UAAU,QACvD,SAAS,6BAA8C;CAE3D,MAAM,0BAA0B,QAAQ,yBACpC,QAAQ,SAAS,4BAA4B,UAAU,QACvD,SAAS,kCAA8C;CAE3D,MAAMA,MAAe;EACnB,WAAW,CAAC,CAAC;GAAE,KAAK,OAAO;GAAW,KAAK,OAAO;;EAElD,qBAA0B,SAAS,kCAAuC;EAC1E,0BAA0B,SAAS,uCAAuC;EAC1E,qBAA0B,SAAS,kCAAuC;EAE1E,iBAAiB,OAAO,SAAS,mBAAuC;EACxE,cAAiB,SAAS,uBAAuC;EAEjE,wBAAwB,SAAS,gCAAuC;EAE/C;EACA;EAEzB,gBAAgB,SAAS,yBAAuC;EAChE,WAAgB,SAAS,oBAAuC;EAChE,SAAgB,SAAS,kBAAuC;EAEhE,aAAkB,SAAS,sBAAuC;EAClE,kBAAkB,SAAS,uBAAuC;EAClE,aAAkB,SAAS,sBAAuC;EAElE,GAAG,UAAU,QAAQ,EAAE,QAAQ,UAAU,IAAI,SAAS,QAAQ;;AAGhE,QAAO"}
1
+ {"version":3,"file":"default.js","names":["res: Default"],"sources":["../../../../src/RS/v3/to/default.ts"],"sourcesContent":["import { Default } from '../types/default';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { ParsedOutOptions as OutOptions } from '../types/out-options';\nimport { min2hrs } from './util';\n\nfunction toTime (str: string) {\n return parseFloat(str.replace(':', '.'));\n}\n\nexport default (\n settings: Deserialized<CoreTypes.divisionSettings>,\n periodMap: Map<string | undefined, number>,\n options: OutOptions\n) => {\n\n\n const { dayStart, dayEnd } = settings;\n\n if (!dayStart) throw new Error('(RS::V3::To::Default) \"dayStart\" is falsy');\n if (!dayEnd) throw new Error('(RS::V3::To::Default) \"dayEnd\" is falsy');\n\n if (periodMap.size && !periodMap.has(settings.period?.id)) throw new Error('(RS::V3::To::Default) \"period\" is not in periodMap');\n\n const maxNumWorkingHours = options.useMaximumScheduleSpan\n ? min2hrs(settings.defaultMaximumScheduleSpan?.daily) ?? false\n : settings.defaultMaxNumWorkingHours ?? false;\n\n const maxNumDailyWorkingHours = options.useMaximumScheduleSpan\n ? min2hrs(settings.defaultMaximumScheduleSpan?.daily) ?? false\n : settings.defaultMaxNumDailyWorkingHours ?? false;\n\n const res: Default = {\n intervals: [[{ beg: toTime(dayStart), end: toTime(dayEnd) }]],\n\n groupMinBreakLength: settings.defaultGroupMinimumBreakLength ?? 0,\n dependencyMinBreakLength: settings.defaultDependencyMinimumBreakLength ?? 0,\n eventMinBreakLength: settings.defaultEventMinimumBreakLength ?? 0,\n\n potentialCenter: toTime(settings.potentialCenter ?? '12:00'),\n eventDensity: settings.defaultEventDensity ?? 0,\n\n maxEventLengthVariance: settings.defaultEventDurationVariance ?? 0,\n\n maxNumWorkingHours: maxNumWorkingHours,\n maxNumDailyWorkingHours: maxNumDailyWorkingHours,\n\n dependencyRank: settings.defaultDependencyRank ?? 0,\n groupRank: settings.defaultGroupRank ?? 0,\n dayRank: settings.defaultDayRank ?? 0,\n\n groupWeight: settings.defaultGroupWeight ?? 0,\n collectionWeight: settings.defaultCourseWeight ?? 0,\n eventWeight: settings.defaultEventWeight ?? 0,\n\n ...periodMap.size && { period: periodMap.get(settings.period?.id)! }\n };\n\n return res;\n};"],"mappings":";;;AAOA,SAAS,OAAQ,KAAa;AAC5B,QAAO,WAAW,IAAI,QAAQ,KAAK;;AAGrC,uBACE,UACA,WACA,YACG;CAGH,MAAM,EAAE,UAAU,WAAW;AAE7B,KAAI,CAAC,SAAU,OAAM,IAAI,MAAM;AAC/B,KAAI,CAAC,OAAU,OAAM,IAAI,MAAM;AAE/B,KAAI,UAAU,QAAQ,CAAC,UAAU,IAAI,SAAS,QAAQ,IAAK,OAAM,IAAI,MAAM;CAE3E,MAAM,qBAAqB,QAAQ,yBAC/B,QAAQ,SAAS,4BAA4B,UAAU,QACvD,SAAS,6BAA8C;CAE3D,MAAM,0BAA0B,QAAQ,yBACpC,QAAQ,SAAS,4BAA4B,UAAU,QACvD,SAAS,kCAA8C;CAE3D,MAAMA,MAAe;EACnB,WAAW,CAAC,CAAC;GAAE,KAAK,OAAO;GAAW,KAAK,OAAO;;EAElD,qBAA0B,SAAS,kCAAuC;EAC1E,0BAA0B,SAAS,uCAAuC;EAC1E,qBAA0B,SAAS,kCAAuC;EAE1E,iBAAiB,OAAO,SAAS,mBAAuC;EACxE,cAAiB,SAAS,uBAAuC;EAEjE,wBAAwB,SAAS,gCAAuC;EAE/C;EACA;EAEzB,gBAAgB,SAAS,yBAAuC;EAChE,WAAgB,SAAS,oBAAuC;EAChE,SAAgB,SAAS,kBAAuC;EAEhE,aAAkB,SAAS,sBAAuC;EAClE,kBAAkB,SAAS,uBAAuC;EAClE,aAAkB,SAAS,sBAAuC;EAElE,GAAG,UAAU,QAAQ,EAAE,QAAQ,UAAU,IAAI,SAAS,QAAQ;;AAGhE,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.js","names":["idKey: keyof CoreTypes.location","doc: Dependency","days","breakLengths","lockedTimes"],"sources":["../../../../src/RS/v3/to/dependencies.ts"],"sourcesContent":["import days from './days';\nimport lockedTimes from './locked-times';\nimport breakLengths from './break-lengths';\n\nimport { Dependency } from '../types/dependencies';\nimport { OutOptions } from '../types/out-options';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\n\nexport default function (\n locations: Deserialized<CoreTypes.location>[],\n settings: CoreTypes.divisionSettings,\n options: OutOptions\n) {\n const idKey: keyof CoreTypes.location = options.idKey || 'id';\n\n if (locations == null) return [];\n\n return (Array.isArray(locations) ? locations : [locations])\n .map((location, index) => {\n const id = location[idKey]?.toString();\n if (!id) {\n throw new Error(`(RS::V3::To::Dependencies) A location must have an id, index: ${ index }`);\n }\n\n // filter location references based on partial schedule options\n const includedLocations = options.partialScheduleOptions?.includedLocations;\n if (includedLocations && !includedLocations.has(id)) return;\n\n const doc: Dependency = {\n id: location[idKey]!.toString(),\n ...location.area && { area: location.area },\n ...location.days?.length && { days: days(location.days, settings.numDays) },\n ...(location.minBreakLength != null) && { minBreakLength: breakLengths(location.minBreakLength) as number },\n ...location.lockedTimes?.length && { lockedTimes: lockedTimes(location.lockedTimes, options) }\n };\n\n if (options.meta) {\n Object.assign(doc, {\n ...location.ids && { ids: location.ids },\n ...location.displayName && { name: location.displayName }\n });\n }\n\n return doc;\n })\n .filter((x): x is NonNullable<typeof x> => !!x);\n}"],"mappings":";;;;;AAUA,8BACE,WACA,UACA,SACA;CACA,MAAMA,QAAkC,QAAQ,SAAS;AAEzD,KAAI,aAAa,KAAM,QAAO;AAE9B,SAAQ,MAAM,QAAQ,aAAa,YAAY,CAAC,YAC7C,KAAK,UAAU,UAAU;EACxB,MAAM,KAAK,SAAS,QAAQ;AAC5B,MAAI,CAAC,GACH,OAAM,IAAI,MAAM,iEAAkE;EAIpF,MAAM,oBAAoB,QAAQ,wBAAwB;AAC1D,MAAI,qBAAqB,CAAC,kBAAkB,IAAI,IAAK;EAErD,MAAMC,MAAkB;GACtB,IAAI,SAAS,OAAQ;GACrB,GAAG,SAAS,QAA4B,EAAE,MAAgB,SAAS;GACnE,GAAG,SAAS,MAAM,UAAsB,EAAE,MAAgBC,aAAK,SAAS,MAAM,SAAS;GACvF,GAAI,SAAS,kBAAkB,QAAS,EAAE,gBAAgBC,sBAAa,SAAS;GAChF,GAAG,SAAS,aAAa,UAAe,EAAE,aAAgBC,qBAAY,SAAS,aAAa;;AAG9F,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,GAAG,SAAS,OAA0B,EAAE,KAAgB,SAAS;GACjE,GAAG,SAAS,eAA0B,EAAE,MAAgB,SAAS;;AAIrE,SAAO;IAER,QAAQ,MAAkC,CAAC,CAAC"}
1
+ {"version":3,"file":"dependencies.js","names":["idKey: keyof CoreTypes.location","doc: Dependency","days","breakLengths","lockedTimes"],"sources":["../../../../src/RS/v3/to/dependencies.ts"],"sourcesContent":["import days from './days';\nimport lockedTimes from './locked-times';\nimport breakLengths from './break-lengths';\n\nimport { Dependency } from '../types/dependencies';\nimport { ParsedOutOptions as OutOptions } from '../types/out-options';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\n\nexport default function (\n locations: Deserialized<CoreTypes.location>[],\n settings: CoreTypes.divisionSettings,\n options: OutOptions\n) {\n const idKey: keyof CoreTypes.location = options.idKey || 'id';\n\n if (locations == null) return [];\n\n return (Array.isArray(locations) ? locations : [locations])\n .map((location, index) => {\n const id = location[idKey]?.toString();\n if (!id) {\n throw new Error(`(RS::V3::To::Dependencies) A location must have an id, index: ${ index }`);\n }\n\n // filter location references based on partial schedule options\n const includedLocations = options.partialScheduleOptions?.includedLocations;\n if (includedLocations && !includedLocations.has(id)) return;\n\n const doc: Dependency = {\n id: location[idKey]!.toString(),\n ...location.area && { area: location.area },\n ...location.days?.length && { days: days(location.days, settings.numDays) },\n ...(location.minBreakLength != null) && { minBreakLength: breakLengths(location.minBreakLength) as number },\n ...location.lockedTimes?.length && { lockedTimes: lockedTimes(location.lockedTimes, options) }\n };\n\n if (options.meta) {\n Object.assign(doc, {\n ...location.ids && { ids: location.ids },\n ...location.displayName && { name: location.displayName }\n });\n }\n\n return doc;\n })\n .filter((x): x is NonNullable<typeof x> => !!x);\n}"],"mappings":";;;;;AAUA,8BACE,WACA,UACA,SACA;CACA,MAAMA,QAAkC,QAAQ,SAAS;AAEzD,KAAI,aAAa,KAAM,QAAO;AAE9B,SAAQ,MAAM,QAAQ,aAAa,YAAY,CAAC,YAC7C,KAAK,UAAU,UAAU;EACxB,MAAM,KAAK,SAAS,QAAQ;AAC5B,MAAI,CAAC,GACH,OAAM,IAAI,MAAM,iEAAkE;EAIpF,MAAM,oBAAoB,QAAQ,wBAAwB;AAC1D,MAAI,qBAAqB,CAAC,kBAAkB,IAAI,IAAK;EAErD,MAAMC,MAAkB;GACtB,IAAI,SAAS,OAAQ;GACrB,GAAG,SAAS,QAA4B,EAAE,MAAgB,SAAS;GACnE,GAAG,SAAS,MAAM,UAAsB,EAAE,MAAgBC,aAAK,SAAS,MAAM,SAAS;GACvF,GAAI,SAAS,kBAAkB,QAAS,EAAE,gBAAgBC,sBAAa,SAAS;GAChF,GAAG,SAAS,aAAa,UAAe,EAAE,aAAgBC,qBAAY,SAAS,aAAa;;AAG9F,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,GAAG,SAAS,OAA0B,EAAE,KAAgB,SAAS;GACjE,GAAG,SAAS,eAA0B,EAAE,MAAgB,SAAS;;AAIrE,SAAO;IAER,QAAQ,MAAkC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"destructure.js","names":["idKey: keyof CoreTypes.course"],"sources":["../../../../src/RS/v3/to/destructure.ts"],"sourcesContent":["import { OutOptions } from '../types/out-options';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { groupsToIndividuals } from './individuals';\nimport { Individual } from '../types/individuals';\nimport { mergeWithParentGroups } from './util';\n\nexport default (\n courses: Deserialized<CoreTypes.course> | Deserialized<CoreTypes.course>[],\n events: Deserialized<CoreTypes.event> | Deserialized<CoreTypes.event>[] = [],\n groups: Deserialized<CoreTypes.group>[] = [],\n settings: CoreTypes.divisionSettings,\n options: OutOptions\n) => {\n\n const groupMembersMap = new Map<string, Set<Deserialized<CoreTypes.person>>>();\n groups.forEach(group => groupMembersMap.set(group.id!, new Set(group.members)));\n const destructMap = new Map<string | null, Individual>();\n\n const idKey: keyof CoreTypes.course = options.idKey || 'id';\n\n courses = Array.isArray(courses) ? courses : [courses];\n events = Array.isArray(events) ? events : [events];\n /*\n if a person is excluded or included add said person to list of groups and decompose every instance of the group\n into two parts. one with the person and one with the remainder of the group\n [g_m] => [(g_m-p_i), p_i]\n */\n courses.concat(events).forEach(source => {\n if (!source[idKey])\n throw new Error('(RS::V3::To::Destructure) A course/event does not have a unique key');\n\n if (!source.groups) return;\n /*\n destructure every group with persons excluded\n this should become a new individuals group\n */\n\n // merge the group references with their parent groups\n const groupReferences = mergeWithParentGroups(source.groups, options);\n\n groupReferences.forEach(x => {\n if (!x.exclude?.length) return;\n const arr = [x.to[idKey]?.toString()].concat(x.exclude.map(y => y[idKey]?.toString()!));\n const key = arr.sort().join('.');\n if (destructMap.has(key)) return;\n const group = groupsToIndividuals({\n [idKey]: key,\n members: Array.from(groupMembersMap.get(x.to.id!)!).filter(y => !x.exclude?.some(z => z[idKey]?.toString() == y[idKey]?.toString()))\n }, settings, options)[0];\n destructMap.set(key, group);\n });\n });\n\n return destructMap;\n};"],"mappings":";;;;AAQA,2BACE,SACA,SAA4E,IAC5E,SAA4C,IAC5C,UACA,YACG;CAEH,MAAM,kCAAkB,IAAI;AAC5B,QAAO,SAAQ,UAAS,gBAAgB,IAAI,MAAM,IAAK,IAAI,IAAI,MAAM;CACrE,MAAM,8BAAc,IAAI;CAExB,MAAMA,QAAgC,QAAQ,SAAS;AAEvD,WAAU,MAAM,QAAQ,WAAW,UAAU,CAAC;AAC9C,UAAU,MAAM,QAAQ,UAAW,SAAU,CAAC;AAM9C,SAAQ,OAAO,QAAQ,SAAQ,WAAU;AACvC,MAAI,CAAC,OAAO,OACV,OAAM,IAAI,MAAM;AAElB,MAAI,CAAC,OAAO,OAAQ;EAOpB,MAAM,kBAAkB,sBAAsB,OAAO,QAAQ;AAE7D,kBAAgB,SAAQ,MAAK;AAC3B,OAAI,CAAC,EAAE,SAAS,OAAQ;GACxB,MAAM,MAAM,CAAC,EAAE,GAAG,QAAQ,YAAY,OAAO,EAAE,QAAQ,KAAI,MAAK,EAAE,QAAQ;GAC1E,MAAM,MAAM,IAAI,OAAO,KAAK;AAC5B,OAAI,YAAY,IAAI,KAAM;GAC1B,MAAM,QAAQ,oBAAoB;KAC/B,QAAQ;IACT,SAAS,MAAM,KAAK,gBAAgB,IAAI,EAAE,GAAG,KAAO,QAAO,MAAK,CAAC,EAAE,SAAS,MAAK,MAAK,EAAE,QAAQ,cAAc,EAAE,QAAQ;MACvH,UAAU,SAAS;AACtB,eAAY,IAAI,KAAK;;;AAIzB,QAAO"}
1
+ {"version":3,"file":"destructure.js","names":["idKey: keyof CoreTypes.course"],"sources":["../../../../src/RS/v3/to/destructure.ts"],"sourcesContent":["import { ParsedOutOptions as OutOptions } from '../types/out-options';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { groupsToIndividuals } from './individuals';\nimport { Individual } from '../types/individuals';\nimport { mergeWithParentGroups } from './util';\n\nexport default (\n courses: Deserialized<CoreTypes.course> | Deserialized<CoreTypes.course>[],\n events: Deserialized<CoreTypes.event> | Deserialized<CoreTypes.event>[] = [],\n groups: Deserialized<CoreTypes.group>[] = [],\n settings: CoreTypes.divisionSettings,\n options: OutOptions\n) => {\n\n const groupMembersMap = new Map<string, Set<Deserialized<CoreTypes.person>>>();\n groups.forEach(group => groupMembersMap.set(group.id!, new Set(group.members)));\n const destructMap = new Map<string | null, Individual>();\n\n const idKey: keyof CoreTypes.course = options.idKey || 'id';\n\n courses = Array.isArray(courses) ? courses : [courses];\n events = Array.isArray(events) ? events : [events];\n /*\n if a person is excluded or included add said person to list of groups and decompose every instance of the group\n into two parts. one with the person and one with the remainder of the group\n [g_m] => [(g_m-p_i), p_i]\n */\n courses.concat(events).forEach(source => {\n if (!source[idKey])\n throw new Error('(RS::V3::To::Destructure) A course/event does not have a unique key');\n\n if (!source.groups) return;\n /*\n destructure every group with persons excluded\n this should become a new individuals group\n */\n\n // merge the group references with their parent groups\n const groupReferences = mergeWithParentGroups(source.groups, options);\n\n groupReferences.forEach(x => {\n if (!x.exclude?.length) return;\n const arr = [x.to[idKey]?.toString()].concat(x.exclude.map(y => y[idKey]?.toString()!));\n const key = arr.sort().join('.');\n if (destructMap.has(key)) return;\n const group = groupsToIndividuals({\n [idKey]: key,\n members: Array.from(groupMembersMap.get(x.to.id!)!).filter(y => !x.exclude?.some(z => z[idKey]?.toString() == y[idKey]?.toString()))\n }, settings, options)[0];\n destructMap.set(key, group);\n });\n });\n\n return destructMap;\n};"],"mappings":";;;;AAQA,2BACE,SACA,SAA4E,IAC5E,SAA4C,IAC5C,UACA,YACG;CAEH,MAAM,kCAAkB,IAAI;AAC5B,QAAO,SAAQ,UAAS,gBAAgB,IAAI,MAAM,IAAK,IAAI,IAAI,MAAM;CACrE,MAAM,8BAAc,IAAI;CAExB,MAAMA,QAAgC,QAAQ,SAAS;AAEvD,WAAU,MAAM,QAAQ,WAAW,UAAU,CAAC;AAC9C,UAAU,MAAM,QAAQ,UAAW,SAAU,CAAC;AAM9C,SAAQ,OAAO,QAAQ,SAAQ,WAAU;AACvC,MAAI,CAAC,OAAO,OACV,OAAM,IAAI,MAAM;AAElB,MAAI,CAAC,OAAO,OAAQ;EAOpB,MAAM,kBAAkB,sBAAsB,OAAO,QAAQ;AAE7D,kBAAgB,SAAQ,MAAK;AAC3B,OAAI,CAAC,EAAE,SAAS,OAAQ;GACxB,MAAM,MAAM,CAAC,EAAE,GAAG,QAAQ,YAAY,OAAO,EAAE,QAAQ,KAAI,MAAK,EAAE,QAAQ;GAC1E,MAAM,MAAM,IAAI,OAAO,KAAK;AAC5B,OAAI,YAAY,IAAI,KAAM;GAC1B,MAAM,QAAQ,oBAAoB;KAC/B,QAAQ;IACT,SAAS,MAAM,KAAK,gBAAgB,IAAI,EAAE,GAAG,KAAO,QAAO,MAAK,CAAC,EAAE,SAAS,MAAK,MAAK,EAAE,QAAQ,cAAc,EAAE,QAAQ;MACvH,UAAU,SAAS;AACtB,eAAY,IAAI,KAAK;;;AAIzB,QAAO"}
@@ -1,7 +1,6 @@
1
1
  import intervals_default from "./intervals.js";
2
2
  import { toDayAndStart } from "./course-events/index.js";
3
3
  import moment from "moment";
4
- import { pick } from "lodash-es";
5
4
  import { nanoid } from "nanoid";
6
5
 
7
6
  //#region src/RS/v3/to/dynamic-locked-times.ts
@@ -21,66 +20,76 @@ function mapCoalescedReferences(coalesced, options, destructMap) {
21
20
  ].map((x) => [x]);
22
21
  return out;
23
22
  }
23
+ function parseDynamicLockedTime(lockedTime, parent, idKey, settings, options, set, destructMap) {
24
+ const { _id, intervals, duration, durationVariance, coalesced } = lockedTime;
25
+ const id = (lockedTime[idKey] || _id)?.toString() ?? nanoid();
26
+ if (set.has(id)) return;
27
+ set.add(id);
28
+ if (duration == null) throw new Error("(RS::V3::To::DynamicLockedTimes) Length of a locked time is null");
29
+ if (duration < 5) throw new Error("(RS::V3::To::DynamicLockedTimes) Length of a locked time is less than 5 min");
30
+ if (!coalesced) throw new Error("(RS::V3::To::DynamicLockedTimes) Length of a locked time is less than 5 min");
31
+ let days = intervals?.length ? intervals.map(({ start }) => (moment(start).day() + 6) % 7) : void 0;
32
+ if (days) days = [...new Set(days)];
33
+ const day = days?.length == 1 ? days[0] : void 0;
34
+ if (day != null && parent.days?.length && !parent.days.some((x) => x.day == day)) return;
35
+ const groups = mapCoalescedReferences(coalesced, options, destructMap);
36
+ const distributionKey = lockedTime.type == "COMPLEMENTARY_TIME" ? "COMPLEMENTARY_TIME." + lockedTime.tags?.at(0)?.value : void 0;
37
+ const doc = {
38
+ id: `${parent.lunch == null ? "virtual" : "lockedTimes"}.${id}`,
39
+ groups: [...new Set(groups.filter(Boolean))],
40
+ dependencies: [...new Set(coalesced.filter((x) => x.toModel == "locations").map(({ to }) => to[idKey]?.toString()).filter(Boolean))].map((x) => [x]),
41
+ length: duration,
42
+ minBreakLength: false,
43
+ intervals: intervals?.length ? intervals_default(intervals, settings) : void 0,
44
+ ...distributionKey && { distributionKey },
45
+ ...days && { days },
46
+ ...day && { day },
47
+ ...durationVariance != null && { maxLengthVariance: durationVariance }
48
+ };
49
+ if (options.partialScheduleOptions) {
50
+ const { includedEvents, omittedEventsHandling } = options.partialScheduleOptions;
51
+ if (includedEvents && !includedEvents.has(doc.id)) {
52
+ if (omittedEventsHandling == "ignore") return;
53
+ if (omittedEventsHandling == "freeze") {
54
+ if (lockedTime.parked || !lockedTime.start || !lockedTime.duration) return;
55
+ Object.assign(doc, toDayAndStart(lockedTime.start));
56
+ doc.length = lockedTime.duration;
57
+ doc.maxLengthVariance = 0;
58
+ const numDays = settings.numDays ?? 5;
59
+ doc.days = Array.from({ length: numDays }, (_, i) => i);
60
+ doc.intervals = Array.from({ length: numDays }, () => [{
61
+ beg: 0,
62
+ end: 23.55
63
+ }]);
64
+ }
65
+ }
66
+ }
67
+ return doc;
68
+ }
24
69
  var dynamic_locked_times_default = (docs, settings, options, set, destructMap) => {
25
70
  const idKey = options.idKey ?? "id";
26
- return docs.filter((x) => !!x).reduce((acc, group) => {
27
- let lunch = group.lunch;
28
- if (lunch == null) lunch = settings.defaultLunch?.map((lunch$1) => ({
29
- ...lunch$1,
30
- coalesced: [{
31
- to: pick(group, idKey),
32
- toModel: ""
33
- }]
71
+ const lunches = docs.filter((x) => !!x).map((group) => {
72
+ return (group.lunch ?? []).map((lockedTime) => {
73
+ return parseDynamicLockedTime(lockedTime, group, idKey, settings, options, set, destructMap);
74
+ }).filter((x) => x != null);
75
+ }).flat();
76
+ const complementaryTimes = (() => {
77
+ const grouped = docs.filter((x) => !!x).map((group) => {
78
+ return (("complementaryTimes" in group ? group.complementaryTimes : null) ?? []).map((lockedTime) => {
79
+ return parseDynamicLockedTime(lockedTime, group, idKey, settings, options, set, destructMap);
80
+ }).filter((x) => x != null);
81
+ }).flat().reduce((acc, x) => {
82
+ const key = [x.distributionKey || "NO_DISTRIBUTION_KEY"].flat().toSorted().join("|");
83
+ if (acc[key]) acc[key].push(x);
84
+ else acc[key] = [x];
85
+ return acc;
86
+ }, {});
87
+ return Object.entries(grouped).map(([id, events]) => ({
88
+ id,
89
+ events
34
90
  }));
35
- if ("complementaryTimes" in group) lunch = lunch?.concat(group.complementaryTimes ?? []);
36
- if (lunch == null) return acc;
37
- return acc.concat(lunch.reduce((acc$1, lockedTime) => {
38
- const { _id, intervals, duration, durationVariance, coalesced } = lockedTime;
39
- const id = (lockedTime[idKey] || _id)?.toString() ?? nanoid();
40
- if (set.has(id)) return acc$1;
41
- set.add(id);
42
- if (duration == null) throw new Error("(RS::V3::To::DynamicLockedTimes) Length of a locked time is null");
43
- if (duration < 5) throw new Error("(RS::V3::To::DynamicLockedTimes) Length of a locked time is less than 5 min");
44
- if (!coalesced) throw new Error("(RS::V3::To::DynamicLockedTimes) Length of a locked time is less than 5 min");
45
- let days = intervals?.length ? intervals.map(({ start }) => (moment(start).day() + 6) % 7) : void 0;
46
- if (days) days = [...new Set(days)];
47
- const day = days?.length == 1 ? days[0] : void 0;
48
- if (day != null && group.days?.length && !group.days.some((x) => x.day == day)) return acc$1;
49
- const groups = mapCoalescedReferences(coalesced, options, destructMap);
50
- const distributionKey = lockedTime.type == "COMPLEMENTARY_TIME" ? "COMPLEMENTARY_TIME." + lockedTime.tags?.at(0)?.value : void 0;
51
- const doc = {
52
- id: `${group.lunch == null ? "virtual" : "lockedTimes"}.${id}`,
53
- groups: [...new Set(groups.filter(Boolean))],
54
- dependencies: [...new Set(coalesced.filter((x) => x.toModel == "locations").map(({ to }) => to[idKey]?.toString()).filter(Boolean))].map((x) => [x]),
55
- length: duration,
56
- minBreakLength: false,
57
- intervals: intervals?.length ? intervals_default(intervals, settings) : void 0,
58
- ...distributionKey && { distributionKey },
59
- ...days && { days },
60
- ...day && { day },
61
- ...durationVariance != null && { maxLengthVariance: durationVariance }
62
- };
63
- if (options.partialScheduleOptions) {
64
- const { includedEvents, omittedEventsHandling } = options.partialScheduleOptions;
65
- if (includedEvents && !includedEvents.has(doc.id)) {
66
- if (omittedEventsHandling == "ignore") return acc$1;
67
- if (omittedEventsHandling == "freeze") {
68
- if (lockedTime.parked || !lockedTime.start || !lockedTime.duration) return acc$1;
69
- Object.assign(doc, toDayAndStart(lockedTime.start));
70
- doc.length = lockedTime.duration;
71
- doc.maxLengthVariance = 0;
72
- const numDays = settings.numDays ?? 5;
73
- doc.days = Array.from({ length: numDays }, (_, i) => i);
74
- doc.intervals = Array.from({ length: numDays }, () => [{
75
- beg: 0,
76
- end: 23.55
77
- }]);
78
- }
79
- }
80
- }
81
- return acc$1.concat(doc);
82
- }, []));
83
- }, []).flat().filter(Boolean);
91
+ })();
92
+ return [...lunches, ...complementaryTimes];
84
93
  };
85
94
 
86
95
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-locked-times.js","names":["idKey: 'id' | '_id' | 'ids'","lunch","id: string","acc","doc: CourseEvent","_intervals"],"sources":["../../../../src/RS/v3/to/dynamic-locked-times.ts"],"sourcesContent":["import moment from 'moment';\nimport { nanoid } from 'nanoid';\nimport { pick } from 'lodash-es';\n\nimport { OutOptions } from '../types/out-options';\nimport { CourseEvent } from '../types/course-events';\nimport { Individual } from '../types/individuals';\n\nimport _intervals from './intervals';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { toDayAndStart } from './course-events';\n\nfunction mapCoalescedReferences (\n coalesced: Deserialized<CoreTypes.lockedTime>['coalesced'],\n options: OutOptions,\n destructMap?: Map<string | null, Individual>\n) {\n const idKey = options.idKey || 'id';\n\n if (!coalesced) return [];\n\n const teachers = coalesced.filter(x => x.toModel == 'teachers');\n const groups = coalesced.filter(x => x.toModel == 'groups');\n const participants = coalesced.filter(x => x.toModel == 'persons');\n\n const teacherIds = teachers .map(({ to }) => to[idKey]).filter((x): x is NonNullable<typeof x> => !!x)\n .map(x => ({ individuals: ['teachers.individuals.' + x.toString()] }));\n const groupIds = groups .map(({ to }) => to[idKey]).filter((x): x is NonNullable<typeof x> => !!x)\n .map(x => 'groups.' + x.toString());\n const participantIds = participants.map(({ to }) => to[idKey]).filter((x): x is NonNullable<typeof x> => !!x)\n .map(x => ({ individuals: ['persons.' + x.toString()] }));\n\n\n const out = [...new Set(teacherIds), ...new Set(groupIds), ...new Set(participantIds)].map(x => [x]);\n return out;\n}\n\nexport default (\n docs: (Deserialized<CoreTypes.group> | Deserialized<CoreTypes.teacher>)[],\n settings: Deserialized<CoreTypes.divisionSettings>,\n options: OutOptions,\n set: Set<string>,\n destructMap?: Map<string | null, Individual>\n) => {\n //let docs: SourceLockedTime[] = (Array.isArray(lockedTimes) ? lockedTimes : [lockedTimes]);\n const idKey: 'id' | '_id' | 'ids' = (options.idKey ?? 'id');\n\n return docs\n .filter(x => !!x)\n .reduce((acc: CourseEvent[], group): CourseEvent[] => {\n let lunch = group.lunch;\n if (lunch == null) {\n lunch = settings.defaultLunch?.map(lunch => ({ ...lunch, coalesced: [{ to: pick(group, idKey), toModel: '' }] }));\n }\n\n if ('complementaryTimes' in group) {\n lunch = lunch?.concat(group.complementaryTimes ?? []);\n }\n\n if (lunch == null)\n return acc;\n\n return acc.concat(\n lunch.reduce((acc: CourseEvent[], lockedTime) => {\n\n const { _id, intervals, duration, durationVariance, coalesced } = lockedTime;\n\n const id: string = (lockedTime[idKey as keyof CoreTypes.lockedTime] || _id)?.toString() ?? nanoid();\n\n if (set.has(id))\n return acc;\n\n set.add(id);\n\n if (duration == null)\n throw new Error('(RS::V3::To::DynamicLockedTimes) Length of a locked time is null');\n\n if (duration < 5)\n throw new Error('(RS::V3::To::DynamicLockedTimes) Length of a locked time is less than 5 min');\n\n if (!coalesced)\n throw new Error('(RS::V3::To::DynamicLockedTimes) Length of a locked time is less than 5 min');\n\n /*\n find the day(s) the events should be placed on\n */\n let days = intervals?.length\n ? intervals.map(({ start }) => (moment(start).day() + 6) % 7)\n : undefined;\n if (days) days = [...new Set(days)];\n const day = days?.length == 1 ? days[0] : undefined;\n\n // ignore locked times that reside on days that are not part of the group's days\n if (day != null && group.days?.length && !group.days.some(x => x.day == day)) return acc;\n\n const groups = mapCoalescedReferences(coalesced, options, destructMap);\n\n const distributionKey = lockedTime.type == 'COMPLEMENTARY_TIME'\n ? 'COMPLEMENTARY_TIME.' + lockedTime.tags?.at(0)?.value\n : undefined;\n\n\n const doc: CourseEvent = {\n id: `${ group.lunch == null ? 'virtual' : 'lockedTimes' }.${ id }`,\n groups: [...new Set(groups.filter(Boolean))],\n dependencies: [...new Set(coalesced.filter(x => x.toModel == 'locations').map(({ to }) => to[idKey]?.toString()!)\n .filter(Boolean))].map(x => [x]),\n length: duration,\n minBreakLength: false,\n intervals: intervals?.length ? _intervals(intervals, settings) : undefined,\n ...distributionKey && { distributionKey },\n ...days && { days },\n ...day && { day },\n ...durationVariance != null && { maxLengthVariance: durationVariance },\n };\n\n\n\n ////\n //// filter events based on partialScheduleOptions\n ////\n if (options.partialScheduleOptions) {\n const { includedEvents, omittedEventsHandling } = options.partialScheduleOptions;\n if (includedEvents && !includedEvents.has(doc.id)) {\n\n if (omittedEventsHandling == 'ignore') return acc;\n\n if (omittedEventsHandling == 'freeze') {\n // must not be parked and have a start and duration to be frozen, otherwise it's ignored\n if (lockedTime.parked || !lockedTime.start || !lockedTime.duration) return acc;\n\n // fix day, start and end\n Object.assign(doc, toDayAndStart(lockedTime.start));\n doc.length = lockedTime.duration;\n doc.maxLengthVariance = 0;\n\n // override intervals and days to not cause conflicts\n const numDays = settings.numDays ?? 5;\n doc.days = Array.from({ length: numDays }, (_, i) => i);\n doc.intervals = Array.from({ length: numDays }, () => [{ beg: 0, end: 23.55 }]);\n\n // fix locations\n // > locations are always fixed for locked times\n }\n }\n }\n\n return acc.concat(doc);\n }, []));\n\n }, [])\n .flat()\n .filter(Boolean);\n};"],"mappings":"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"}
1
+ {"version":3,"file":"dynamic-locked-times.js","names":["id: string","doc: CourseEvent","_intervals","idKey: 'id' | '_id' | 'ids'"],"sources":["../../../../src/RS/v3/to/dynamic-locked-times.ts"],"sourcesContent":["import moment from 'moment';\nimport { nanoid } from 'nanoid';\n\nimport { ParsedOutOptions as OutOptions } from '../types/out-options';\nimport { CourseEvent } from '../types/course-events';\nimport { Collection } from '../types/collections';\nimport { Individual } from '../types/individuals';\n\nimport _intervals from './intervals';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { toDayAndStart } from './course-events';\n\nfunction mapCoalescedReferences (\n coalesced: Deserialized<CoreTypes.lockedTime>['coalesced'],\n options: OutOptions,\n destructMap?: Map<string | null, Individual>\n) {\n const idKey = options.idKey || 'id';\n\n if (!coalesced) return [];\n\n const teachers = coalesced.filter(x => x.toModel == 'teachers');\n const groups = coalesced.filter(x => x.toModel == 'groups');\n const participants = coalesced.filter(x => x.toModel == 'persons');\n\n const teacherIds = teachers .map(({ to }) => to[idKey]).filter((x): x is NonNullable<typeof x> => !!x)\n .map(x => ({ individuals: ['teachers.individuals.' + x.toString()] }));\n const groupIds = groups .map(({ to }) => to[idKey]).filter((x): x is NonNullable<typeof x> => !!x)\n .map(x => 'groups.' + x.toString());\n const participantIds = participants.map(({ to }) => to[idKey]).filter((x): x is NonNullable<typeof x> => !!x)\n .map(x => ({ individuals: ['persons.' + x.toString()] }));\n\n\n const out = [...new Set(teacherIds), ...new Set(groupIds), ...new Set(participantIds)].map(x => [x]);\n return out;\n}\n\n\nfunction parseDynamicLockedTime (\n lockedTime: Deserialized<CoreTypes.lockedTime>,\n parent: Deserialized<CoreTypes.group> | Deserialized<CoreTypes.teacher>,\n //\n idKey: 'id' | '_id' | 'ids',\n settings: Deserialized<CoreTypes.divisionSettings>,\n options: OutOptions,\n set: Set<string>,\n destructMap?: Map<string | null, Individual>\n) {\n\n const { _id, intervals, duration, durationVariance, coalesced } = lockedTime;\n\n const id: string = (lockedTime[idKey as keyof CoreTypes.lockedTime] || _id)?.toString() ?? nanoid();\n\n if (set.has(id)) return;\n\n set.add(id);\n\n if (duration == null)\n throw new Error('(RS::V3::To::DynamicLockedTimes) Length of a locked time is null');\n\n if (duration < 5)\n throw new Error('(RS::V3::To::DynamicLockedTimes) Length of a locked time is less than 5 min');\n\n if (!coalesced)\n throw new Error('(RS::V3::To::DynamicLockedTimes) Length of a locked time is less than 5 min');\n\n /*\n find the day(s) the events should be placed on\n */\n let days = intervals?.length\n ? intervals.map(({ start }) => (moment(start).day() + 6) % 7)\n : undefined;\n if (days) days = [...new Set(days)];\n const day = days?.length == 1 ? days[0] : undefined;\n\n // ignore locked times that reside on days that are not part of the group's days\n if (day != null && parent.days?.length && !parent.days.some(x => x.day == day)) return;\n\n const groups = mapCoalescedReferences(coalesced, options, destructMap);\n\n const distributionKey = lockedTime.type == 'COMPLEMENTARY_TIME'\n ? 'COMPLEMENTARY_TIME.' + lockedTime.tags?.at(0)?.value\n : undefined;\n\n\n const doc: CourseEvent = {\n id: `${ parent.lunch == null ? 'virtual' : 'lockedTimes' }.${ id }`,\n groups: [...new Set(groups.filter(Boolean))],\n dependencies: [...new Set(coalesced.filter(x => x.toModel == 'locations').map(({ to }) => to[idKey]?.toString()!).filter(Boolean))].map(x => [x]),\n length: duration,\n minBreakLength: false,\n intervals: intervals?.length ? _intervals(intervals, settings) : undefined,\n ...distributionKey && { distributionKey },\n ...days && { days },\n ...day && { day },\n ...durationVariance != null && { maxLengthVariance: durationVariance },\n };\n\n\n\n ////\n //// filter events based on partialScheduleOptions\n ////\n if (options.partialScheduleOptions) {\n const { includedEvents, omittedEventsHandling } = options.partialScheduleOptions;\n if (includedEvents && !includedEvents.has(doc.id)) {\n\n if (omittedEventsHandling == 'ignore') return;\n\n if (omittedEventsHandling == 'freeze') {\n // must not be parked and have a start and duration to be frozen, otherwise it's ignored\n if (lockedTime.parked || !lockedTime.start || !lockedTime.duration) return;\n\n // fix day, start and end\n Object.assign(doc, toDayAndStart(lockedTime.start));\n doc.length = lockedTime.duration;\n doc.maxLengthVariance = 0;\n\n // override intervals and days to not cause conflicts\n const numDays = settings.numDays ?? 5;\n doc.days = Array.from({ length: numDays }, (_, i) => i);\n doc.intervals = Array.from({ length: numDays }, () => [{ beg: 0, end: 23.55 }]);\n\n // fix locations\n // > locations are always fixed for locked times\n }\n }\n }\n\n return doc;\n}\n\n\n\nexport default (\n docs: (Deserialized<CoreTypes.group> | Deserialized<CoreTypes.teacher>)[],\n settings: Deserialized<CoreTypes.divisionSettings>,\n options: OutOptions,\n set: Set<string>,\n destructMap?: Map<string | null, Individual>\n) => {\n const idKey: 'id' | '_id' | 'ids' = (options.idKey ?? 'id');\n\n const lunches = docs\n .filter(x => !!x)\n .map(group => {\n return (group.lunch ?? [])\n .map(lockedTime => {\n return parseDynamicLockedTime(lockedTime, group, idKey, settings, options, set, destructMap);\n })\n .filter(x => x != null);\n })\n .flat();\n\n const complementaryTimes = (() => {\n const grouped = docs\n .filter(x => !!x)\n .map(group => {\n return (('complementaryTimes' in group ? group.complementaryTimes : null) ?? [])\n .map(lockedTime => {\n return parseDynamicLockedTime(lockedTime, group, idKey, settings, options, set, destructMap);\n })\n .filter(x => x != null);\n })\n .flat()\n // group by distribution key\n .reduce<Record<string, CourseEvent[]>>((acc, x) => {\n const key = [x.distributionKey || 'NO_DISTRIBUTION_KEY'].flat().toSorted().join('|');\n if (acc[key]) acc[key].push(x);\n else acc[key] = [x];\n return acc;\n }, { })\n\n // create a group out of each _complementaryTimes group\n return Object.entries(grouped).map(([id, events]): Collection => ({ id, events }));\n })();\n\n return [...lunches, ...complementaryTimes];\n};"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"groups.js","names":["idKey: keyof CoreTypes.group","doc: Group","intervals","days","lockedTimes","breakLengths"],"sources":["../../../../src/RS/v3/to/groups.ts"],"sourcesContent":["import breakLengths from './break-lengths';\nimport days from './days';\nimport lockedTimes from './locked-times';\nimport intervals from './intervals';\n\nimport { Group } from '../types/groups';\nimport { OutOptions } from '../types/out-options';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { parseMaxWorkingHours } from './util';\n\nexport default (\n groups: Deserialized<CoreTypes.group>[] | Deserialized<CoreTypes.group>,\n settings: CoreTypes.divisionSettings,\n options: OutOptions\n): Group[] => {\n if (groups == null)\n return [];\n\n const idKey: keyof CoreTypes.group = options.idKey || 'id';\n\n return (Array.isArray(groups) ? groups : [groups])\n .filter(group => group.species == 'class')\n .map((group, index) => {\n\n if (group[idKey] == undefined) throw new Error(`(RS::V3::To::Groups) A group must have an id, index: ${ index }`);\n\n const hasIntervals = Boolean(group.intervals?.length || (group.rootInterval ?? settings.defaultRootInterval));\n\n const doc: Group = {\n id: `groups.${ group[idKey]!.toString() }`,\n group_type: 'classes',\n ...parseMaxWorkingHours(group, options),\n ...'weight' in group && { weight: group.weight },\n ...hasIntervals && { intervals: intervals(group.intervals, settings, group.rootInterval ?? settings.defaultRootInterval as CoreTypes.rootInterval) },\n ...(group.days?.length) && { days: days(group.days, settings.numDays) },\n ...(group.lockedTimes?.length) && { lockedTimes: lockedTimes(group.lockedTimes, options) },\n ...(group.minBreakLength != null) && { minBreakLength: breakLengths(group.minBreakLength) },\n minimizeGaps: true,\n minimizeDependencyAlternation: false,\n };\n\n if (options.meta) {\n Object.assign(doc, {\n ...group.ids && { ids: group.ids },\n ...group.displayName && { name: group.displayName },\n });\n }\n\n return doc;\n }, []);\n};\n"],"mappings":";;;;;;;AAYA,sBACE,QACA,UACA,YACY;AACZ,KAAI,UAAU,KACZ,QAAO;CAET,MAAMA,QAA+B,QAAQ,SAAS;AAEtD,SAAQ,MAAM,QAAQ,UAAU,SAAS,CAAC,SACvC,QAAO,UAAS,MAAM,WAAW,SACjC,KAAK,OAAO,UAAU;AAErB,MAAI,MAAM,UAAU,OAAW,OAAM,IAAI,MAAM,wDAAyD;EAExG,MAAM,eAAe,QAAQ,MAAM,WAAW,WAAW,MAAM,gBAAgB,SAAS;EAExF,MAAMC,MAAa;GACjB,IAA+B,UAAW,MAAM,OAAQ;GACxD,YAA+B;GAC/B,GAAG,qBAAqB,OAAO;GAC/B,GAAG,YAAgC,SAAS,EAAE,QAA4B,MAAM;GAChF,GAAG,gBAAyC,EAAE,WAA4BC,kBAAU,MAAM,WAAW,UAAU,MAAM,gBAAgB,SAAS;GAC9I,GAAI,MAAM,MAAM,UAA4B,EAAE,MAA4BC,aAAK,MAAM,MAAM,SAAS;GACpG,GAAI,MAAM,aAAa,UAAqB,EAAE,aAA4BC,qBAAY,MAAM,aAAa;GACzG,GAAI,MAAM,kBAAkB,QAAgB,EAAE,gBAA4BC,sBAAa,MAAM;GAC7F,cAA+B;GAC/B,+BAA+B;;AAGjC,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,GAAG,MAAM,OAAiC,EAAE,KAA4B,MAAM;GAC9E,GAAG,MAAM,eAAiC,EAAE,MAA4B,MAAM;;AAIlF,SAAO;IACN"}
1
+ {"version":3,"file":"groups.js","names":["idKey: keyof CoreTypes.group","doc: Group","intervals","days","lockedTimes","breakLengths"],"sources":["../../../../src/RS/v3/to/groups.ts"],"sourcesContent":["import breakLengths from './break-lengths';\nimport days from './days';\nimport lockedTimes from './locked-times';\nimport intervals from './intervals';\n\nimport { Group } from '../types/groups';\nimport { ParsedOutOptions as OutOptions } from '../types/out-options';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { parseMaxWorkingHours } from './util';\n\nexport default (\n groups: Deserialized<CoreTypes.group>[] | Deserialized<CoreTypes.group>,\n settings: CoreTypes.divisionSettings,\n options: OutOptions\n): Group[] => {\n if (groups == null)\n return [];\n\n const idKey: keyof CoreTypes.group = options.idKey || 'id';\n\n return (Array.isArray(groups) ? groups : [groups])\n .filter(group => group.species == 'class')\n .map((group, index) => {\n\n if (group[idKey] == undefined) throw new Error(`(RS::V3::To::Groups) A group must have an id, index: ${ index }`);\n\n const hasIntervals = Boolean(group.intervals?.length || (group.rootInterval ?? settings.defaultRootInterval));\n\n const doc: Group = {\n id: `groups.${ group[idKey]!.toString() }`,\n group_type: 'classes',\n ...parseMaxWorkingHours(group, options),\n ...'weight' in group && { weight: group.weight },\n ...hasIntervals && { intervals: intervals(group.intervals, settings, group.rootInterval ?? settings.defaultRootInterval as CoreTypes.rootInterval) },\n ...(group.days?.length) && { days: days(group.days, settings.numDays) },\n ...(group.lockedTimes?.length) && { lockedTimes: lockedTimes(group.lockedTimes, options) },\n ...(group.minBreakLength != null) && { minBreakLength: breakLengths(group.minBreakLength) },\n minimizeGaps: true,\n minimizeDependencyAlternation: false,\n };\n\n if (options.meta) {\n Object.assign(doc, {\n ...group.ids && { ids: group.ids },\n ...group.displayName && { name: group.displayName },\n });\n }\n\n return doc;\n }, []);\n};\n"],"mappings":";;;;;;;AAYA,sBACE,QACA,UACA,YACY;AACZ,KAAI,UAAU,KACZ,QAAO;CAET,MAAMA,QAA+B,QAAQ,SAAS;AAEtD,SAAQ,MAAM,QAAQ,UAAU,SAAS,CAAC,SACvC,QAAO,UAAS,MAAM,WAAW,SACjC,KAAK,OAAO,UAAU;AAErB,MAAI,MAAM,UAAU,OAAW,OAAM,IAAI,MAAM,wDAAyD;EAExG,MAAM,eAAe,QAAQ,MAAM,WAAW,WAAW,MAAM,gBAAgB,SAAS;EAExF,MAAMC,MAAa;GACjB,IAA+B,UAAW,MAAM,OAAQ;GACxD,YAA+B;GAC/B,GAAG,qBAAqB,OAAO;GAC/B,GAAG,YAAgC,SAAS,EAAE,QAA4B,MAAM;GAChF,GAAG,gBAAyC,EAAE,WAA4BC,kBAAU,MAAM,WAAW,UAAU,MAAM,gBAAgB,SAAS;GAC9I,GAAI,MAAM,MAAM,UAA4B,EAAE,MAA4BC,aAAK,MAAM,MAAM,SAAS;GACpG,GAAI,MAAM,aAAa,UAAqB,EAAE,aAA4BC,qBAAY,MAAM,aAAa;GACzG,GAAI,MAAM,kBAAkB,QAAgB,EAAE,gBAA4BC,sBAAa,MAAM;GAC7F,cAA+B;GAC/B,+BAA+B;;AAGjC,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,GAAG,MAAM,OAAiC,EAAE,KAA4B,MAAM;GAC9E,GAAG,MAAM,eAAiC,EAAE,MAA4B,MAAM;;AAIlF,SAAO;IACN"}
@@ -13,41 +13,20 @@ import { DivisionSettings } from "../../../core/v2/types/division-settings.js";
13
13
  import { Division } from "../../../core/v2/types/divisions.js";
14
14
  import { Types as Types$1 } from "../../../core/v2/types/index.js";
15
15
  import { Deserialized, Serialized } from "../../../core/types/index.js";
16
+ import { AlgorithmWeightParameters } from "../types/algorithm-parameters.js";
16
17
  import { Configuration } from "../types/configurations.js";
17
- import { Settings } from "../types/settings.js";
18
- import { LockedTime as LockedTime$1 } from "../types/locked-times.js";
19
- import { Interval as Interval$1 } from "../types/intervals.js";
20
- import { Collection } from "../types/collections.js";
21
- import { Group } from "../types/groups.js";
22
- import { Individual } from "../types/individuals.js";
23
18
  import { Constraint } from "../types/constraints.js";
24
19
  import { OutOptions } from "../types/out-options.js";
25
- import { export_default } from "./available-dependencies.js";
26
- import { export_default as export_default$1 } from "./course-events/index.js";
27
- import { export_default as export_default$2 } from "./dependencies.js";
28
- import * as mongoose5 from "mongoose";
29
- import * as lodash1 from "lodash";
20
+ import * as mongoose2 from "mongoose";
21
+ import * as lodash0 from "lodash";
30
22
 
31
23
  //#region src/RS/v3/to/index.d.ts
32
- declare class export_default$3 {
33
- static availableDependency: typeof export_default;
34
- static configuration: (events: Deserialized<Types$1.event>[], options: OutOptions) => Configuration[];
35
- static constraints: (schedule: Partial<Deserialized<Types$1.schedule> & {
36
- division: Deserialized<Types$1.division>;
37
- }>, options?: OutOptions) => Constraint;
38
- static courseEvent: typeof export_default$1;
39
- static course: (courses: Deserialized<Types$1.course> | Deserialized<Types$1.course>[], events: Deserialized<Types$1.event>[] | undefined, overlapGroups: Deserialized<Types$1.overlapGroup>[] | undefined, settings: Types$1.divisionSettings, options: OutOptions, periodsMap: Map<string | undefined, number>, destructMap?: Map<string | null, Individual>) => (Collection[] | Collection)[];
40
- static day: (days: Types$1.day[], numDays: number) => number[];
41
- static dependency: typeof export_default$2;
42
- static group: (groups: Deserialized<Types$1.group>[] | Deserialized<Types$1.group>, settings: Types$1.divisionSettings, options: OutOptions) => Group[];
43
- static interval: (intervals: Types$1.interval[] | undefined, settings: Types$1.divisionSettings, rootInterval?: Types$1.rootInterval) => Interval$1[][];
44
- static lockedTime: (lockedTimes: Types$1.lockedTime[] | Types$1.lockedTime, options: OutOptions) => LockedTime$1[] | never;
45
- static persons: (persons: Deserialized<Types$1.person>[] | Deserialized<Types$1.person>, settings: Types$1.divisionSettings, options: OutOptions) => Group[];
46
- static schedules: (schedule: Deserialized<Types$1.schedule>, options?: OutOptions) => {
24
+ declare class export_default {
25
+ static schedules: (schedule: Deserialized<Types$1.schedule>, _options?: OutOptions) => {
47
26
  input: Constraint;
48
27
  output?: Configuration[] | undefined;
49
28
  coreData?: {
50
- syllabuses: lodash1.Omit<Deserialized<Syllabus>, "_id" | "belongsTo" | "createdAt" | "updatedAt" | "lastModifiedBy">[];
29
+ syllabuses: lodash0.Omit<Deserialized<Syllabus>, "_id" | "belongsTo" | "createdAt" | "updatedAt" | "lastModifiedBy">[];
51
30
  settings: DivisionSettings;
52
31
  rootIntervals: RootInterval[];
53
32
  overlapGroups: Serialized<Omit<OverlapGroup, "belongsTo" | "lastModifiedBy">>[];
@@ -75,7 +54,7 @@ declare class export_default$3 {
75
54
  to: string;
76
55
  }[] | undefined;
77
56
  course: string | undefined;
78
- _id?: mongoose5.Types.ObjectId | undefined;
57
+ _id?: mongoose2.Types.ObjectId | undefined;
79
58
  id?: string | undefined;
80
59
  belongsTo?: Deserialized<Division> | undefined;
81
60
  density?: number | undefined;
@@ -160,7 +139,7 @@ declare class export_default$3 {
160
139
  persons: {
161
140
  exceptions?: string[] | undefined;
162
141
  group: string | undefined;
163
- _id?: mongoose5.Types.ObjectId | undefined;
142
+ _id?: mongoose2.Types.ObjectId | undefined;
164
143
  id?: string | undefined;
165
144
  belongsTo?: Deserialized<Division> | undefined;
166
145
  ids?: string | undefined;
@@ -244,7 +223,7 @@ declare class export_default$3 {
244
223
  }[];
245
224
  locations: {
246
225
  exceptions?: string[] | Deserialized<Exception>[] | undefined;
247
- _id?: mongoose5.Types.ObjectId | undefined;
226
+ _id?: mongoose2.Types.ObjectId | undefined;
248
227
  id?: string | undefined;
249
228
  belongsTo?: Deserialized<Division> | undefined;
250
229
  ids?: string | undefined;
@@ -277,10 +256,11 @@ declare class export_default$3 {
277
256
  structure: "RS/algorithm-3.0.0";
278
257
  division: Pick<Deserialized<Division>, "start" | "end" | "displayName">;
279
258
  };
259
+ algorithmParameters: {
260
+ weights: AlgorithmWeightParameters | undefined;
261
+ };
280
262
  };
281
- static setting: (settings: Types$1.divisionSettings) => Settings;
282
- static teacher: (teachers: Deserialized<Types$1.teacher>[] | Deserialized<Types$1.teacher>, settings: Types$1.divisionSettings, options: OutOptions) => Group[];
283
263
  }
284
264
  //#endregion
285
- export { export_default$3 as export_default };
265
+ export { export_default };
286
266
  //# sourceMappingURL=index.d.ts.map
@@ -1,34 +1,8 @@
1
- import available_dependencies_default from "./available-dependencies.js";
2
- import configurations_default from "./configurations.js";
3
- import days_default from "./days.js";
4
- import locked_times_default from "./locked-times.js";
5
- import dependencies_default from "./dependencies.js";
6
- import intervals_default from "./intervals.js";
7
- import teachers_default from "./teachers.js";
8
- import groups_default from "./groups.js";
9
- import course_events_default from "./course-events/index.js";
10
- import collections_default from "./collections.js";
11
- import settings_default from "./settings.js";
12
- import constraints_default from "./constraints.js";
13
- import persons_default from "./persons.js";
14
1
  import schedules_default from "./schedules.js";
15
2
 
16
3
  //#region src/RS/v3/to/index.ts
17
4
  var to_default = class {
18
- static availableDependency = available_dependencies_default;
19
- static configuration = configurations_default;
20
- static constraints = constraints_default;
21
- static courseEvent = course_events_default;
22
- static course = collections_default;
23
- static day = days_default;
24
- static dependency = dependencies_default;
25
- static group = groups_default;
26
- static interval = intervals_default;
27
- static lockedTime = locked_times_default;
28
- static persons = persons_default;
29
5
  static schedules = schedules_default;
30
- static setting = settings_default;
31
- static teacher = teachers_default;
32
6
  };
33
7
 
34
8
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_availableDependency","_configuration","_constraints","_courseEvent","_collection","_day","_dependency","_group","_interval","_lockedTime","_persons","_schedules","_setting","_teacher"],"sources":["../../../../src/RS/v3/to/index.ts"],"sourcesContent":["import _availableDependency from './available-dependencies';\nimport _configuration from './configurations';\nimport _constraints from './constraints';\nimport _courseEvent from './course-events';\nimport _collection from './collections';\nimport _day from './days';\nimport _dependency from './dependencies';\nimport _group from './groups';\nimport _interval from './intervals';\nimport _lockedTime from './locked-times';\nimport _persons from './persons';\nimport _schedules from './schedules';\nimport _setting from './settings';\nimport _teacher from './teachers';\n\nexport default class {\n static availableDependency = _availableDependency;\n static configuration = _configuration;\n static constraints = _constraints;\n static courseEvent = _courseEvent;\n static course = _collection;\n static day = _day;\n static dependency = _dependency;\n static group = _group;\n static interval = _interval;\n static lockedTime = _lockedTime;\n static persons = _persons;\n static schedules = _schedules;\n static setting = _setting;\n static teacher = _teacher;\n}"],"mappings":";;;;;;;;;;;;;;;;AAeA,uBAAqB;CACnB,OAAO,sBAAsBA;CAC7B,OAAO,gBAAsBC;CAC7B,OAAO,cAAsBC;CAC7B,OAAO,cAAsBC;CAC7B,OAAO,SAAsBC;CAC7B,OAAO,MAAsBC;CAC7B,OAAO,aAAsBC;CAC7B,OAAO,QAAsBC;CAC7B,OAAO,WAAsBC;CAC7B,OAAO,aAAsBC;CAC7B,OAAO,UAAsBC;CAC7B,OAAO,YAAsBC;CAC7B,OAAO,UAAsBC;CAC7B,OAAO,UAAsBC"}
1
+ {"version":3,"file":"index.js","names":["_schedules"],"sources":["../../../../src/RS/v3/to/index.ts"],"sourcesContent":["\nimport _schedules from './schedules';\n\nexport default class {\n static schedules = _schedules;\n}"],"mappings":";;;AAGA,uBAAqB;CACnB,OAAO,YAAYA"}
@@ -1 +1 @@
1
- {"version":3,"file":"individuals.js","names":["idKey: keyof CoreTypes.group","doc: Individual","idKey: keyof CoreTypes.person"],"sources":["../../../../src/RS/v3/to/individuals.ts"],"sourcesContent":["import { OutOptions } from '../types/out-options';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { Individual } from '../types/individuals';\n\ntype GroupType = Exclude<Deserialized<CoreTypes.group>, { species: string }>;\n\nexport function groupsToIndividuals (\n groups: GroupType[] | GroupType,\n settings: CoreTypes.divisionSettings,\n options: OutOptions\n): Individual[] {\n if (groups == null)\n return [];\n\n const idKey: keyof CoreTypes.group = options.idKey || 'id';\n\n return (Array.isArray(groups) ? groups : [groups])\n .filter(group => group.species == null)\n .map((group, index) => {\n\n if (group[idKey] == undefined) throw new Error(`(RS::V3::To::Individuals) A group must have an id, index: ${ index }`);\n\n const doc: Individual = {\n id: `groups.${ group[idKey]!.toString() }`,\n individuals: group.members?.map((member) => `persons.${ member[idKey] }`) || [],\n };\n\n if (options.meta) {\n Object.assign(doc, {\n ...group.ids && { ids: group.ids },\n ...group.displayName && { name: group.displayName },\n });\n }\n\n return doc;\n }, []);\n}\n\nexport function personsToIndividuals (\n persons: Deserialized<CoreTypes.person>[] | Deserialized<CoreTypes.person>,\n settings: CoreTypes.divisionSettings,\n options: OutOptions\n): Individual[] {\n if (persons == null)\n return [];\n\n const idKey: keyof CoreTypes.person = options.idKey || 'id';\n\n return (Array.isArray(persons) ? persons : [persons]).map((person, index) => {\n\n if (person[idKey] == undefined) throw new Error(`(RS::V3::To::Individuals) A person must have an id, index: ${ index }`);\n\n const doc: Individual = {\n id: `persons.${ person[idKey]!.toString() }`,\n ...(person.group && person.group.species) && { group: `groups.${ person.group[idKey]!.toString() }` },\n };\n\n if (options.meta) {\n Object.assign(doc, {\n ...person.ids && { ids: person.ids },\n ...person.displayName && { name: person.displayName },\n });\n }\n\n return doc;\n }, []);\n}\n\nexport function teachersToIndividuals (\n teachers: Deserialized<CoreTypes.teacher>[] | Deserialized<CoreTypes.teacher>,\n settings: CoreTypes.divisionSettings,\n options: OutOptions\n): Individual[] {\n if (teachers == null)\n return [];\n\n const idKey: keyof CoreTypes.person = options.idKey || 'id';\n\n return (Array.isArray(teachers) ? teachers : [teachers]).map((person, index) => {\n\n if (person[idKey] == undefined) throw new Error(`(RS::V3::To::Individuals) A teacher must have an id, index: ${ index }`);\n\n const doc: Individual = {\n id: `teachers.individuals.${ person[idKey]!.toString() }`,\n group: `teachers.${ person[idKey]!.toString() }`,\n };\n\n return doc;\n }, []);\n}"],"mappings":";AAQA,SAAgB,oBACd,QACA,UACA,SACc;AACd,KAAI,UAAU,KACZ,QAAO;CAET,MAAMA,QAA+B,QAAQ,SAAS;AAEtD,SAAQ,MAAM,QAAQ,UAAU,SAAS,CAAC,SACvC,QAAO,UAAS,MAAM,WAAW,MACjC,KAAK,OAAO,UAAU;AAErB,MAAI,MAAM,UAAU,OAAW,OAAM,IAAI,MAAM,6DAA8D;EAE7G,MAAMC,MAAkB;GACtB,IAAa,UAAW,MAAM,OAAQ;GACtC,aAAa,MAAM,SAAS,KAAK,WAAW,WAAY,OAAO,aAAc;;AAG/E,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,GAAG,MAAM,OAAiC,EAAE,KAA4B,MAAM;GAC9E,GAAG,MAAM,eAAiC,EAAE,MAA4B,MAAM;;AAIlF,SAAO;IACN;;AAGP,SAAgB,qBACd,SACA,UACA,SACc;AACd,KAAI,WAAW,KACb,QAAO;CAET,MAAMC,QAAgC,QAAQ,SAAS;AAEvD,SAAQ,MAAM,QAAQ,WAAW,UAAU,CAAC,UAAU,KAAK,QAAQ,UAAU;AAE3E,MAAI,OAAO,UAAU,OAAW,OAAM,IAAI,MAAM,8DAA+D;EAE/G,MAAMD,MAAkB;GACtB,IAAI,WAAY,OAAO,OAAQ;GAC/B,GAAI,OAAO,SAAS,OAAO,MAAM,WAAY,EAAE,OAAO,UAAW,OAAO,MAAM,OAAQ;;AAGxF,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,GAAG,OAAO,OAAgB,EAAE,KAA4B,OAAO;GAC/D,GAAG,OAAO,eAAgB,EAAE,MAA4B,OAAO;;AAInE,SAAO;IACN;;AAGL,SAAgB,sBACd,UACA,UACA,SACc;AACd,KAAI,YAAY,KACd,QAAO;CAET,MAAMC,QAAgC,QAAQ,SAAS;AAEvD,SAAQ,MAAM,QAAQ,YAAY,WAAW,CAAC,WAAW,KAAK,QAAQ,UAAU;AAE9E,MAAI,OAAO,UAAU,OAAW,OAAM,IAAI,MAAM,+DAAgE;EAEhH,MAAMD,MAAkB;GACtB,IAAO,wBAAyB,OAAO,OAAQ;GAC/C,OAAO,YAAa,OAAO,OAAQ;;AAGrC,SAAO;IACN"}
1
+ {"version":3,"file":"individuals.js","names":["idKey: keyof CoreTypes.group","doc: Individual","idKey: keyof CoreTypes.person"],"sources":["../../../../src/RS/v3/to/individuals.ts"],"sourcesContent":["import { ParsedOutOptions as OutOptions } from '../types/out-options';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { Individual } from '../types/individuals';\n\ntype GroupType = Exclude<Deserialized<CoreTypes.group>, { species: string }>;\n\nexport function groupsToIndividuals (\n groups: GroupType[] | GroupType,\n settings: CoreTypes.divisionSettings,\n options: OutOptions\n): Individual[] {\n if (groups == null)\n return [];\n\n const idKey: keyof CoreTypes.group = options.idKey || 'id';\n\n return (Array.isArray(groups) ? groups : [groups])\n .filter(group => group.species == null)\n .map((group, index) => {\n\n if (group[idKey] == undefined) throw new Error(`(RS::V3::To::Individuals) A group must have an id, index: ${ index }`);\n\n const doc: Individual = {\n id: `groups.${ group[idKey]!.toString() }`,\n individuals: group.members?.map((member) => `persons.${ member[idKey] }`) || [],\n };\n\n if (options.meta) {\n Object.assign(doc, {\n ...group.ids && { ids: group.ids },\n ...group.displayName && { name: group.displayName },\n });\n }\n\n return doc;\n }, []);\n}\n\nexport function personsToIndividuals (\n persons: Deserialized<CoreTypes.person>[] | Deserialized<CoreTypes.person>,\n settings: CoreTypes.divisionSettings,\n options: OutOptions\n): Individual[] {\n if (persons == null)\n return [];\n\n const idKey: keyof CoreTypes.person = options.idKey || 'id';\n\n return (Array.isArray(persons) ? persons : [persons]).map((person, index) => {\n\n if (person[idKey] == undefined) throw new Error(`(RS::V3::To::Individuals) A person must have an id, index: ${ index }`);\n\n const doc: Individual = {\n id: `persons.${ person[idKey]!.toString() }`,\n ...(person.group && person.group.species) && { group: `groups.${ person.group[idKey]!.toString() }` },\n };\n\n if (options.meta) {\n Object.assign(doc, {\n ...person.ids && { ids: person.ids },\n ...person.displayName && { name: person.displayName },\n });\n }\n\n return doc;\n }, []);\n}\n\nexport function teachersToIndividuals (\n teachers: Deserialized<CoreTypes.teacher>[] | Deserialized<CoreTypes.teacher>,\n settings: CoreTypes.divisionSettings,\n options: OutOptions\n): Individual[] {\n if (teachers == null)\n return [];\n\n const idKey: keyof CoreTypes.person = options.idKey || 'id';\n\n return (Array.isArray(teachers) ? teachers : [teachers]).map((person, index) => {\n\n if (person[idKey] == undefined) throw new Error(`(RS::V3::To::Individuals) A teacher must have an id, index: ${ index }`);\n\n const doc: Individual = {\n id: `teachers.individuals.${ person[idKey]!.toString() }`,\n group: `teachers.${ person[idKey]!.toString() }`,\n };\n\n return doc;\n }, []);\n}"],"mappings":";AAQA,SAAgB,oBACd,QACA,UACA,SACc;AACd,KAAI,UAAU,KACZ,QAAO;CAET,MAAMA,QAA+B,QAAQ,SAAS;AAEtD,SAAQ,MAAM,QAAQ,UAAU,SAAS,CAAC,SACvC,QAAO,UAAS,MAAM,WAAW,MACjC,KAAK,OAAO,UAAU;AAErB,MAAI,MAAM,UAAU,OAAW,OAAM,IAAI,MAAM,6DAA8D;EAE7G,MAAMC,MAAkB;GACtB,IAAa,UAAW,MAAM,OAAQ;GACtC,aAAa,MAAM,SAAS,KAAK,WAAW,WAAY,OAAO,aAAc;;AAG/E,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,GAAG,MAAM,OAAiC,EAAE,KAA4B,MAAM;GAC9E,GAAG,MAAM,eAAiC,EAAE,MAA4B,MAAM;;AAIlF,SAAO;IACN;;AAGP,SAAgB,qBACd,SACA,UACA,SACc;AACd,KAAI,WAAW,KACb,QAAO;CAET,MAAMC,QAAgC,QAAQ,SAAS;AAEvD,SAAQ,MAAM,QAAQ,WAAW,UAAU,CAAC,UAAU,KAAK,QAAQ,UAAU;AAE3E,MAAI,OAAO,UAAU,OAAW,OAAM,IAAI,MAAM,8DAA+D;EAE/G,MAAMD,MAAkB;GACtB,IAAI,WAAY,OAAO,OAAQ;GAC/B,GAAI,OAAO,SAAS,OAAO,MAAM,WAAY,EAAE,OAAO,UAAW,OAAO,MAAM,OAAQ;;AAGxF,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,GAAG,OAAO,OAAgB,EAAE,KAA4B,OAAO;GAC/D,GAAG,OAAO,eAAgB,EAAE,MAA4B,OAAO;;AAInE,SAAO;IACN;;AAGL,SAAgB,sBACd,UACA,UACA,SACc;AACd,KAAI,YAAY,KACd,QAAO;CAET,MAAMC,QAAgC,QAAQ,SAAS;AAEvD,SAAQ,MAAM,QAAQ,YAAY,WAAW,CAAC,WAAW,KAAK,QAAQ,UAAU;AAE9E,MAAI,OAAO,UAAU,OAAW,OAAM,IAAI,MAAM,+DAAgE;EAEhH,MAAMD,MAAkB;GACtB,IAAO,wBAAyB,OAAO,OAAQ;GAC/C,OAAO,YAAa,OAAO,OAAQ;;AAGrC,SAAO;IACN"}
@@ -1 +1 @@
1
- {"version":3,"file":"locked-times.js","names":["startDate: moment.Moment","endDate: moment.Moment","length: number | undefined","start: number | undefined","doc: LockedTime"],"sources":["../../../../src/RS/v3/to/locked-times.ts"],"sourcesContent":["import moment from 'moment';\n\nimport { LockedTime } from '../types/locked-times';\nimport { OutOptions } from '../types/out-options';\n\nimport { Types as CoreTypes } from '../../../core/types';\n\nconst typeMap = new Map();\ntypeMap.set('teachers', 'teachers');\ntypeMap.set('groups', 'groups');\ntypeMap.set('locations', 'dependencies');\ntypeMap.set('courses', 'courses');\ntypeMap.set('courseevents', 'events');\n\nexport default (lockedTimes: CoreTypes.lockedTime[] | CoreTypes.lockedTime,\n options: OutOptions): LockedTime[] | never => {\n\n const docs = (Array.isArray(lockedTimes) ? lockedTimes : [lockedTimes]);\n\n return docs.map((lockedTime): LockedTime => {\n let startDate: moment.Moment;\n let endDate: moment.Moment;\n if (lockedTime.start) {\n startDate = moment.utc(lockedTime.start);\n\n if (!startDate.isValid())\n throw new Error('(RS::V3::To::LockedTimes) start is not a valid date');\n } else {\n throw new Error('(RS::V3::To::LockedTimes) A locked time must have a start time');\n }\n\n if (lockedTime.end) {\n endDate = moment.utc(lockedTime.end);\n\n if (!endDate.isValid())\n throw new Error('(RS::V3::To::LockedTimes) end is not a valid date');\n } else {\n throw new Error('(RS::V3::To::LockedTimes) A locked time must have an end time');\n }\n\n if (endDate.isBefore(startDate))\n throw new Error('(RS::V3::To::LockedTimes) start is after end');\n\n let length: number | undefined;\n\n if (startDate && endDate)\n length = endDate.diff(startDate, 'minutes', true);\n\n if (length == null)\n throw new Error('(RS::V3::To::LockedTimes) Length of a locked time is null');\n\n if (length < 5)\n throw new Error('(RS::V3::To::LockedTimes) Length of a locked time is less than 5 min');\n\n let start: number | undefined;\n if (startDate) {\n start = parseFloat(startDate.format('HH.mm'));\n if (start == null) {\n throw new Error('(RS::V3::To::LockedTimes) start could not be converted to float');\n }\n }\n\n const doc: LockedTime = {\n length: length,\n day: (startDate.day() + 6) % 7,\n start: start,\n };\n\n if (options.meta) {\n Object.assign(doc, {\n id: lockedTime.id,\n ...lockedTime.hasOwnProperty('visible') && { visible: lockedTime.visible },\n ...lockedTime.displayName && { name: lockedTime.displayName },\n });\n }\n return doc;\n });\n};"],"mappings":";;;AAOA,MAAM,0BAAiB,IAAI;AAC3B,QAAQ,IAAI,YAAkB;AAC9B,QAAQ,IAAI,UAAkB;AAC9B,QAAQ,IAAI,aAAkB;AAC9B,QAAQ,IAAI,WAAkB;AAC9B,QAAQ,IAAI,gBAAkB;AAE9B,4BAAgB,aACd,YAAkD;CAElD,MAAM,OAAQ,MAAM,QAAQ,eAAe,cAAc,CAAC;AAE1D,QAAO,KAAK,KAAK,eAA2B;EAC1C,IAAIA;EACJ,IAAIC;AACJ,MAAI,WAAW,OAAO;AACpB,eAAY,OAAO,IAAI,WAAW;AAElC,OAAI,CAAC,UAAU,UACb,OAAM,IAAI,MAAM;QAElB,OAAM,IAAI,MAAM;AAGlB,MAAI,WAAW,KAAK;AAClB,aAAU,OAAO,IAAI,WAAW;AAEhC,OAAI,CAAC,QAAQ,UACX,OAAM,IAAI,MAAM;QAElB,OAAM,IAAI,MAAM;AAGlB,MAAI,QAAQ,SAAS,WACnB,OAAM,IAAI,MAAM;EAElB,IAAIC;AAEJ,MAAI,aAAa,QACf,UAAS,QAAQ,KAAK,WAAW,WAAW;AAE9C,MAAI,UAAU,KACZ,OAAM,IAAI,MAAM;AAElB,MAAI,SAAS,EACX,OAAM,IAAI,MAAM;EAElB,IAAIC;AACJ,MAAI,WAAW;AACb,WAAQ,WAAW,UAAU,OAAO;AACpC,OAAI,SAAS,KACX,OAAM,IAAI,MAAM;;EAIpB,MAAMC,MAAkB;GACd;GACR,MAAS,UAAU,QAAQ,KAAK;GACxB;;AAGV,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,IAAI,WAAW;GACf,GAAG,WAAW,eAAe,cAAc,EAAE,SAAW,WAAW;GACnE,GAAG,WAAW,eAA6B,EAAE,MAAW,WAAW;;AAGvE,SAAO"}
1
+ {"version":3,"file":"locked-times.js","names":["startDate: moment.Moment","endDate: moment.Moment","length: number | undefined","start: number | undefined","doc: LockedTime"],"sources":["../../../../src/RS/v3/to/locked-times.ts"],"sourcesContent":["import moment from 'moment';\n\nimport { LockedTime } from '../types/locked-times';\nimport { ParsedOutOptions as OutOptions } from '../types/out-options';\n\nimport { Types as CoreTypes } from '../../../core/types';\n\nconst typeMap = new Map();\ntypeMap.set('teachers', 'teachers');\ntypeMap.set('groups', 'groups');\ntypeMap.set('locations', 'dependencies');\ntypeMap.set('courses', 'courses');\ntypeMap.set('courseevents', 'events');\n\nexport default (lockedTimes: CoreTypes.lockedTime[] | CoreTypes.lockedTime,\n options: OutOptions): LockedTime[] | never => {\n\n const docs = (Array.isArray(lockedTimes) ? lockedTimes : [lockedTimes]);\n\n return docs.map((lockedTime): LockedTime => {\n let startDate: moment.Moment;\n let endDate: moment.Moment;\n if (lockedTime.start) {\n startDate = moment.utc(lockedTime.start);\n\n if (!startDate.isValid())\n throw new Error('(RS::V3::To::LockedTimes) start is not a valid date');\n } else {\n throw new Error('(RS::V3::To::LockedTimes) A locked time must have a start time');\n }\n\n if (lockedTime.end) {\n endDate = moment.utc(lockedTime.end);\n\n if (!endDate.isValid())\n throw new Error('(RS::V3::To::LockedTimes) end is not a valid date');\n } else {\n throw new Error('(RS::V3::To::LockedTimes) A locked time must have an end time');\n }\n\n if (endDate.isBefore(startDate))\n throw new Error('(RS::V3::To::LockedTimes) start is after end');\n\n let length: number | undefined;\n\n if (startDate && endDate)\n length = endDate.diff(startDate, 'minutes', true);\n\n if (length == null)\n throw new Error('(RS::V3::To::LockedTimes) Length of a locked time is null');\n\n if (length < 5)\n throw new Error('(RS::V3::To::LockedTimes) Length of a locked time is less than 5 min');\n\n let start: number | undefined;\n if (startDate) {\n start = parseFloat(startDate.format('HH.mm'));\n if (start == null) {\n throw new Error('(RS::V3::To::LockedTimes) start could not be converted to float');\n }\n }\n\n const doc: LockedTime = {\n length: length,\n day: (startDate.day() + 6) % 7,\n start: start,\n };\n\n if (options.meta) {\n Object.assign(doc, {\n id: lockedTime.id,\n ...lockedTime.hasOwnProperty('visible') && { visible: lockedTime.visible },\n ...lockedTime.displayName && { name: lockedTime.displayName },\n });\n }\n return doc;\n });\n};"],"mappings":";;;AAOA,MAAM,0BAAiB,IAAI;AAC3B,QAAQ,IAAI,YAAkB;AAC9B,QAAQ,IAAI,UAAkB;AAC9B,QAAQ,IAAI,aAAkB;AAC9B,QAAQ,IAAI,WAAkB;AAC9B,QAAQ,IAAI,gBAAkB;AAE9B,4BAAgB,aACd,YAAkD;CAElD,MAAM,OAAQ,MAAM,QAAQ,eAAe,cAAc,CAAC;AAE1D,QAAO,KAAK,KAAK,eAA2B;EAC1C,IAAIA;EACJ,IAAIC;AACJ,MAAI,WAAW,OAAO;AACpB,eAAY,OAAO,IAAI,WAAW;AAElC,OAAI,CAAC,UAAU,UACb,OAAM,IAAI,MAAM;QAElB,OAAM,IAAI,MAAM;AAGlB,MAAI,WAAW,KAAK;AAClB,aAAU,OAAO,IAAI,WAAW;AAEhC,OAAI,CAAC,QAAQ,UACX,OAAM,IAAI,MAAM;QAElB,OAAM,IAAI,MAAM;AAGlB,MAAI,QAAQ,SAAS,WACnB,OAAM,IAAI,MAAM;EAElB,IAAIC;AAEJ,MAAI,aAAa,QACf,UAAS,QAAQ,KAAK,WAAW,WAAW;AAE9C,MAAI,UAAU,KACZ,OAAM,IAAI,MAAM;AAElB,MAAI,SAAS,EACX,OAAM,IAAI,MAAM;EAElB,IAAIC;AACJ,MAAI,WAAW;AACb,WAAQ,WAAW,UAAU,OAAO;AACpC,OAAI,SAAS,KACX,OAAM,IAAI,MAAM;;EAIpB,MAAMC,MAAkB;GACd;GACR,MAAS,UAAU,QAAQ,KAAK;GACxB;;AAGV,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,IAAI,WAAW;GACf,GAAG,WAAW,eAAe,cAAc,EAAE,SAAW,WAAW;GACnE,GAAG,WAAW,eAA6B,EAAE,MAAW,WAAW;;AAGvE,SAAO"}
@@ -1,16 +1,33 @@
1
1
  import { CoreMap } from "../../../core/index.js";
2
- import configurations_default from "./configurations.js";
3
2
  import constraints_default from "./constraints.js";
3
+ import configurations_default from "./configurations.js";
4
4
  import "../../../index.js";
5
5
  import { pick } from "lodash-es";
6
6
 
7
7
  //#region src/RS/v3/to/schedules.ts
8
- var schedules_default = (schedule, options = {}) => {
8
+ var schedules_default = (schedule, _options = {}) => {
9
+ const options = (() => {
10
+ const pso = _options.partialScheduleOptions;
11
+ const partialScheduleOptions = pso ? {
12
+ includedEvents: pso.includedEvents ? new Set(pso.includedEvents) : void 0,
13
+ includedLocations: pso.includedLocations ? new Set(pso.includedLocations) : void 0,
14
+ omittedEventsHandling: pso.omittedEventsHandling
15
+ } : void 0;
16
+ return {
17
+ ..._options,
18
+ partialScheduleOptions
19
+ };
20
+ })();
21
+ if (options.partialScheduleOptions?.includedEvents?.size) options.partialScheduleOptions.includedEvents = new Set([...options.partialScheduleOptions.includedEvents].map((x) => {
22
+ if (x.startsWith("events.") || x.startsWith("lockedTimes.")) return x;
23
+ return `events.${x}`;
24
+ }));
9
25
  return {
10
26
  meta: {
11
27
  structure: "RS/algorithm-3.0.0",
12
28
  division: pick(schedule.divisions, "displayName", "start", "end")
13
29
  },
30
+ algorithmParameters: { weights: options.algorithmWeightParameters },
14
31
  ...options.appendCoreData && { coreData: CoreMap.to.schedules(JSON.parse(JSON.stringify(schedule))) },
15
32
  ...options.appendOutput && schedule.events && { output: configurations_default(schedule.events, options) },
16
33
  input: constraints_default(schedule, options)
@@ -1 +1 @@
1
- {"version":3,"file":"schedules.js","names":["_configurations","_constraints"],"sources":["../../../../src/RS/v3/to/schedules.ts"],"sourcesContent":["import { pick } from 'lodash-es';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { CoreMap } from '../../../index';\n\nimport { Schedule } from '../types/schedules';\nimport { OutOptions } from '../types/out-options';\n\nimport _constraints from './constraints';\nimport _configurations from './configurations';\n\nexport default (schedule: Deserialized<CoreTypes.schedule>, options: OutOptions = {}) => {\n\n return {\n meta: {\n structure: 'RS/algorithm-3.0.0',\n division: pick(schedule.divisions, 'displayName', 'start', 'end'),\n },\n ...options.appendCoreData && { coreData: CoreMap.to.schedules(JSON.parse(JSON.stringify(schedule))) },\n ...options.appendOutput && schedule.events && { output: _configurations(schedule.events, options) },\n input: _constraints(schedule, options),\n } satisfies Schedule;\n};"],"mappings":";;;;;;;AAYA,yBAAgB,UAA4C,UAAsB,OAAO;AAEvF,QAAO;EACL,MAAM;GACJ,WAAW;GACX,UAAW,KAAK,SAAS,WAAW,eAAe,SAAS;;EAE9D,GAAG,QAAQ,kBAAkB,EAAE,UAAU,QAAQ,GAAG,UAAU,KAAK,MAAM,KAAK,UAAU;EACxF,GAAG,QAAQ,gBAAgB,SAAS,UAAU,EAAE,QAAQA,uBAAgB,SAAS,QAAQ;EACzF,OAAOC,oBAAa,UAAU"}
1
+ {"version":3,"file":"schedules.js","names":["partialScheduleOptions: ParsedOutOptions['partialScheduleOptions']","_configurations","_constraints"],"sources":["../../../../src/RS/v3/to/schedules.ts"],"sourcesContent":["import { pick } from 'lodash-es';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { CoreMap } from '../../../index';\n\nimport { Schedule } from '../types/schedules';\nimport { OutOptions, ParsedOutOptions } from '../types/out-options';\n\nimport _constraints from './constraints';\nimport _configurations from './configurations';\n\nexport default (schedule: Deserialized<CoreTypes.schedule>, _options: OutOptions = {}) => {\n\n ////\n //// parse the output options\n ////\n const options = ((): ParsedOutOptions => {\n const pso = _options.partialScheduleOptions;\n const partialScheduleOptions: ParsedOutOptions['partialScheduleOptions'] = pso\n ? {\n includedEvents: pso.includedEvents ? new Set(pso.includedEvents) : undefined,\n includedLocations: pso.includedLocations ? new Set(pso.includedLocations) : undefined,\n omittedEventsHandling: pso.omittedEventsHandling\n }\n : undefined;\n\n return { ..._options, partialScheduleOptions };\n })();\n\n ////\n //// for backward compatibility: add default collection to included events set\n ////\n if (options.partialScheduleOptions?.includedEvents?.size) {\n options.partialScheduleOptions.includedEvents = new Set(\n [...options.partialScheduleOptions.includedEvents]\n .map(x => {\n // should start with 'events.' or 'lockedTimes.' prefix\n if (x.startsWith('events.') || x.startsWith('lockedTimes.')) return x;\n return `events.${x}`;\n })\n );\n }\n\n return {\n meta: {\n structure: 'RS/algorithm-3.0.0',\n division: pick(schedule.divisions, 'displayName', 'start', 'end'),\n },\n algorithmParameters: {\n weights: options.algorithmWeightParameters,\n },\n ...options.appendCoreData && { coreData: CoreMap.to.schedules(JSON.parse(JSON.stringify(schedule))) },\n ...options.appendOutput && schedule.events && { output: _configurations(schedule.events, options) },\n input: _constraints(schedule, options),\n } satisfies Schedule;\n};"],"mappings":";;;;;;;AAYA,yBAAgB,UAA4C,WAAuB,OAAO;CAKxF,MAAM,iBAAmC;EACvC,MAAM,MAAM,SAAS;EACrB,MAAMA,yBAAqE,MACvE;GACA,gBAAuB,IAAI,iBAAoB,IAAI,IAAI,IAAI,kBAAqB;GAChF,mBAAuB,IAAI,oBAAoB,IAAI,IAAI,IAAI,qBAAqB;GAChF,uBAAuB,IAAI;MAE3B;AAEJ,SAAO;GAAE,GAAG;GAAU;;;AAMxB,KAAI,QAAQ,wBAAwB,gBAAgB,KAClD,SAAQ,uBAAuB,iBAAiB,IAAI,IAClD,CAAC,GAAG,QAAQ,uBAAuB,gBAChC,KAAI,MAAK;AAER,MAAI,EAAE,WAAW,cAAc,EAAE,WAAW,gBAAiB,QAAO;AACpE,SAAO,UAAU;;AAKzB,QAAO;EACL,MAAM;GACJ,WAAW;GACX,UAAW,KAAK,SAAS,WAAW,eAAe,SAAS;;EAE9D,qBAAqB,EACnB,SAAS,QAAQ;EAEnB,GAAG,QAAQ,kBAAkB,EAAE,UAAU,QAAQ,GAAG,UAAU,KAAK,MAAM,KAAK,UAAU;EACxF,GAAG,QAAQ,gBAAgB,SAAS,UAAU,EAAE,QAAQC,uBAAgB,SAAS,QAAQ;EACzF,OAAOC,oBAAa,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"teachers.js","names":["idKey: keyof CoreTypes.teacher","doc: Group","intervals","days","lockedTimes","breakLengths"],"sources":["../../../../src/RS/v3/to/teachers.ts"],"sourcesContent":["import breakLengths from './break-lengths';\nimport days from './days';\nimport lockedTimes from './locked-times';\nimport intervals from './intervals';\n\nimport { Group } from '../types/groups';\nimport { OutOptions } from '../types/out-options';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { parseMaxWorkingHours } from './util';\n\nexport default (\n teachers: Deserialized<CoreTypes.teacher>[] | Deserialized<CoreTypes.teacher>,\n settings: CoreTypes.divisionSettings,\n options: OutOptions\n): Group[] => {\n if (teachers == null)\n return [];\n\n const idKey: keyof CoreTypes.teacher = options.idKey || 'id';\n\n return (Array.isArray(teachers) ? teachers : [teachers]).map((teacher, index: number) => {\n\n if (teacher[idKey] == undefined) throw new Error(`(RS::V3::To::Teachers) Teachers must have an id, index: ${ index }`);\n\n const hasIntervals = Boolean(teacher.intervals?.length || (teacher.rootInterval ?? settings.defaultRootInterval));\n\n const doc: Group = {\n id: `teachers.${ teacher[idKey]!.toString() }`,\n group_type: 'personal',\n ...parseMaxWorkingHours(teacher, options),\n ...'weight' in teacher && { weight: teacher.weight },\n ...hasIntervals && { intervals: intervals(teacher.intervals, settings, teacher.rootInterval ?? settings.defaultRootInterval as CoreTypes.rootInterval) },\n ...teacher.days?.length && { days: days(teacher.days, settings.numDays) },\n ...teacher.lockedTimes?.length && { lockedTimes: lockedTimes(teacher.lockedTimes, options) },\n ...(teacher.minBreakLength != null) && { minBreakLength: breakLengths(teacher.minBreakLength) },\n minimizeGaps: false,\n minimizeDependencyAlternation: true,\n };\n\n if (options.meta) {\n Object.assign(doc, {\n ...teacher.ids && { ids: teacher.ids },\n ...teacher.displayName && { name: teacher.displayName },\n });\n }\n\n return doc;\n }, []);\n};\n"],"mappings":";;;;;;;AAYA,wBACE,UACA,UACA,YACY;AACZ,KAAI,YAAY,KACd,QAAO;CAET,MAAMA,QAAiC,QAAQ,SAAS;AAExD,SAAQ,MAAM,QAAQ,YAAY,WAAW,CAAC,WAAW,KAAK,SAAS,UAAkB;AAEvF,MAAI,QAAQ,UAAU,OAAW,OAAM,IAAI,MAAM,2DAA4D;EAE7G,MAAM,eAAe,QAAQ,QAAQ,WAAW,WAAW,QAAQ,gBAAgB,SAAS;EAE5F,MAAMC,MAAa;GACjB,IAA+B,YAAa,QAAQ,OAAQ;GAC5D,YAA+B;GAC/B,GAAG,qBAAqB,SAAS;GACjC,GAAG,YAAgC,WAAW,EAAE,QAA4B,QAAQ;GACpF,GAAG,gBAA2C,EAAE,WAA4BC,kBAAU,QAAQ,WAAW,UAAU,QAAQ,gBAAgB,SAAS;GACpJ,GAAG,QAAQ,MAAM,UAA6B,EAAE,MAA4BC,aAAK,QAAQ,MAAM,SAAS;GACxG,GAAG,QAAQ,aAAa,UAAsB,EAAE,aAA4BC,qBAAY,QAAQ,aAAa;GAC7G,GAAI,QAAQ,kBAAkB,QAAgB,EAAE,gBAA4BC,sBAAa,QAAQ;GACjG,cAA+B;GAC/B,+BAA+B;;AAGjC,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,GAAG,QAAQ,OAAiC,EAAE,KAA4B,QAAQ;GAClF,GAAG,QAAQ,eAAiC,EAAE,MAA4B,QAAQ;;AAItF,SAAO;IACN"}
1
+ {"version":3,"file":"teachers.js","names":["idKey: keyof CoreTypes.teacher","doc: Group","intervals","days","lockedTimes","breakLengths"],"sources":["../../../../src/RS/v3/to/teachers.ts"],"sourcesContent":["import breakLengths from './break-lengths';\nimport days from './days';\nimport lockedTimes from './locked-times';\nimport intervals from './intervals';\n\nimport { Group } from '../types/groups';\nimport { ParsedOutOptions as OutOptions } from '../types/out-options';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\nimport { parseMaxWorkingHours } from './util';\n\nexport default (\n teachers: Deserialized<CoreTypes.teacher>[] | Deserialized<CoreTypes.teacher>,\n settings: CoreTypes.divisionSettings,\n options: OutOptions\n): Group[] => {\n if (teachers == null)\n return [];\n\n const idKey: keyof CoreTypes.teacher = options.idKey || 'id';\n\n return (Array.isArray(teachers) ? teachers : [teachers]).map((teacher, index: number) => {\n\n if (teacher[idKey] == undefined) throw new Error(`(RS::V3::To::Teachers) Teachers must have an id, index: ${ index }`);\n\n const hasIntervals = Boolean(teacher.intervals?.length || (teacher.rootInterval ?? settings.defaultRootInterval));\n\n const doc: Group = {\n id: `teachers.${ teacher[idKey]!.toString() }`,\n group_type: 'personal',\n ...parseMaxWorkingHours(teacher, options),\n ...'weight' in teacher && { weight: teacher.weight },\n ...hasIntervals && { intervals: intervals(teacher.intervals, settings, teacher.rootInterval ?? settings.defaultRootInterval as CoreTypes.rootInterval) },\n ...teacher.days?.length && { days: days(teacher.days, settings.numDays) },\n ...teacher.lockedTimes?.length && { lockedTimes: lockedTimes(teacher.lockedTimes, options) },\n ...(teacher.minBreakLength != null) && { minBreakLength: breakLengths(teacher.minBreakLength) },\n minimizeGaps: false,\n minimizeDependencyAlternation: true,\n };\n\n if (options.meta) {\n Object.assign(doc, {\n ...teacher.ids && { ids: teacher.ids },\n ...teacher.displayName && { name: teacher.displayName },\n });\n }\n\n return doc;\n }, []);\n};\n"],"mappings":";;;;;;;AAYA,wBACE,UACA,UACA,YACY;AACZ,KAAI,YAAY,KACd,QAAO;CAET,MAAMA,QAAiC,QAAQ,SAAS;AAExD,SAAQ,MAAM,QAAQ,YAAY,WAAW,CAAC,WAAW,KAAK,SAAS,UAAkB;AAEvF,MAAI,QAAQ,UAAU,OAAW,OAAM,IAAI,MAAM,2DAA4D;EAE7G,MAAM,eAAe,QAAQ,QAAQ,WAAW,WAAW,QAAQ,gBAAgB,SAAS;EAE5F,MAAMC,MAAa;GACjB,IAA+B,YAAa,QAAQ,OAAQ;GAC5D,YAA+B;GAC/B,GAAG,qBAAqB,SAAS;GACjC,GAAG,YAAgC,WAAW,EAAE,QAA4B,QAAQ;GACpF,GAAG,gBAA2C,EAAE,WAA4BC,kBAAU,QAAQ,WAAW,UAAU,QAAQ,gBAAgB,SAAS;GACpJ,GAAG,QAAQ,MAAM,UAA6B,EAAE,MAA4BC,aAAK,QAAQ,MAAM,SAAS;GACxG,GAAG,QAAQ,aAAa,UAAsB,EAAE,aAA4BC,qBAAY,QAAQ,aAAa;GAC7G,GAAI,QAAQ,kBAAkB,QAAgB,EAAE,gBAA4BC,sBAAa,QAAQ;GACjG,cAA+B;GAC/B,+BAA+B;;AAGjC,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,GAAG,QAAQ,OAAiC,EAAE,KAA4B,QAAQ;GAClF,GAAG,QAAQ,eAAiC,EAAE,MAA4B,QAAQ;;AAItF,SAAO;IACN"}
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","names":[],"sources":["../../../../src/RS/v3/to/util.ts"],"sourcesContent":["import { Types as CoreTypes, Deserialized } from '../../../core/types';\nimport { Group } from '../types/groups';\nimport { OutOptions } from '../types/out-options';\nimport { groupBy, values } from 'lodash-es';\n\nexport function min2hrs (min: number | undefined | null) {\n return min ? min / 60 : undefined;\n}\n\nexport function parseMaxWorkingHours (\n group: Deserialized<CoreTypes.group>,\n options: OutOptions\n): Pick<Group, 'maxNumWorkingHours' | 'maxNumDailyWorkingHours'> | undefined {\n // new format\n if (options.useMaximumScheduleSpan && group.maximumScheduleSpan) {\n return {\n maxNumWorkingHours: min2hrs(group.maximumScheduleSpan.daily) ?? false,\n maxNumDailyWorkingHours: min2hrs(group.maximumScheduleSpan.daily) ?? false,\n };\n }\n\n // old format, to become deprecated\n if (!options.useMaximumScheduleSpan) {\n return {\n ...'maxNumWorkingHours' in group && { maxNumWorkingHours: group.maxNumWorkingHours },\n ...'maxNumDailyWorkingHours' in group && { maxNumDailyWorkingHours: group.maxNumDailyWorkingHours },\n };\n }\n\n return;\n}\n\n\ntype GroupReferences = NonNullable<Deserialized<CoreTypes.event>['groups']>;\n/**\n * Merges group references with their parent groups while ensuring that a group is present at\n * most once while ensuring that parent groups are prioritized as they carry no member exclusions.\n */\nexport function mergeWithParentGroups (\n references: GroupReferences,\n options: OutOptions\n): GroupReferences {\n if (!references) return [];\n\n const idKey = options.idKey || 'id';\n\n return values(groupBy(\n references\n .flatMap((x): ((typeof x) & { isParentGroup?: boolean })[] => ([\n x, ...(x.to.parentGroups ?? []).map(y => ({ to: y, isParentGroup: true }))\n ])),\n x => x.to[idKey]?.toString()\n ))\n .map(xs => xs.find(x => x.isParentGroup) ?? xs.find(x => !x.isParentGroup))\n .filter((x): x is NonNullable<typeof x> => !!x);\n}"],"mappings":";;;AAKA,SAAgB,QAAS,KAAgC;AACvD,QAAO,MAAM,MAAM,KAAK;;AAG1B,SAAgB,qBACd,OACA,SAC2E;AAE3E,KAAI,QAAQ,0BAA0B,MAAM,oBAC1C,QAAO;EACL,oBAAyB,QAAQ,MAAM,oBAAoB,UAAU;EACrE,yBAAyB,QAAQ,MAAM,oBAAoB,UAAU;;AAKzE,KAAI,CAAC,QAAQ,uBACX,QAAO;EACL,GAAG,wBAA6B,SAAS,EAAE,oBAA4B,MAAM;EAC7E,GAAG,6BAA6B,SAAS,EAAE,yBAA4B,MAAM;;;;;;;AAanF,SAAgB,sBACd,YACA,SACiB;AACjB,KAAI,CAAC,WAAY,QAAO;CAExB,MAAM,QAAQ,QAAQ,SAAS;AAE/B,QAAO,OAAO,QACZ,WACG,SAAS,MAAqD,CAC7D,GAAG,IAAI,EAAE,GAAG,gBAAgB,IAAI,KAAI,OAAM;EAAE,IAAI;EAAG,eAAe;SAEtE,MAAK,EAAE,GAAG,QAAQ,aAEjB,KAAI,OAAM,GAAG,MAAK,MAAK,EAAE,kBAAkB,GAAG,MAAK,MAAK,CAAC,EAAE,gBAC3D,QAAQ,MAAkC,CAAC,CAAC"}
1
+ {"version":3,"file":"util.js","names":[],"sources":["../../../../src/RS/v3/to/util.ts"],"sourcesContent":["import { Types as CoreTypes, Deserialized } from '../../../core/types';\nimport { Group } from '../types/groups';\nimport { ParsedOutOptions as OutOptions } from '../types/out-options';\nimport { groupBy, values } from 'lodash-es';\n\nexport function min2hrs (min: number | undefined | null) {\n return min ? min / 60 : undefined;\n}\n\nexport function parseMaxWorkingHours (\n group: Deserialized<CoreTypes.group>,\n options: OutOptions\n): Pick<Group, 'maxNumWorkingHours' | 'maxNumDailyWorkingHours'> | undefined {\n // new format\n if (options.useMaximumScheduleSpan && group.maximumScheduleSpan) {\n return {\n maxNumWorkingHours: min2hrs(group.maximumScheduleSpan.daily) ?? false,\n maxNumDailyWorkingHours: min2hrs(group.maximumScheduleSpan.daily) ?? false,\n };\n }\n\n // old format, to become deprecated\n if (!options.useMaximumScheduleSpan) {\n return {\n ...'maxNumWorkingHours' in group && { maxNumWorkingHours: group.maxNumWorkingHours },\n ...'maxNumDailyWorkingHours' in group && { maxNumDailyWorkingHours: group.maxNumDailyWorkingHours },\n };\n }\n\n return;\n}\n\n\ntype GroupReferences = NonNullable<Deserialized<CoreTypes.event>['groups']>;\n/**\n * Merges group references with their parent groups while ensuring that a group is present at\n * most once while ensuring that parent groups are prioritized as they carry no member exclusions.\n */\nexport function mergeWithParentGroups (\n references: GroupReferences,\n options: OutOptions\n): GroupReferences {\n if (!references) return [];\n\n const idKey = options.idKey || 'id';\n\n return values(groupBy(\n references\n .flatMap((x): ((typeof x) & { isParentGroup?: boolean })[] => ([\n x, ...(x.to.parentGroups ?? []).map(y => ({ to: y, isParentGroup: true }))\n ])),\n x => x.to[idKey]?.toString()\n ))\n .map(xs => xs.find(x => x.isParentGroup) ?? xs.find(x => !x.isParentGroup))\n .filter((x): x is NonNullable<typeof x> => !!x);\n}"],"mappings":";;;AAKA,SAAgB,QAAS,KAAgC;AACvD,QAAO,MAAM,MAAM,KAAK;;AAG1B,SAAgB,qBACd,OACA,SAC2E;AAE3E,KAAI,QAAQ,0BAA0B,MAAM,oBAC1C,QAAO;EACL,oBAAyB,QAAQ,MAAM,oBAAoB,UAAU;EACrE,yBAAyB,QAAQ,MAAM,oBAAoB,UAAU;;AAKzE,KAAI,CAAC,QAAQ,uBACX,QAAO;EACL,GAAG,wBAA6B,SAAS,EAAE,oBAA4B,MAAM;EAC7E,GAAG,6BAA6B,SAAS,EAAE,yBAA4B,MAAM;;;;;;;AAanF,SAAgB,sBACd,YACA,SACiB;AACjB,KAAI,CAAC,WAAY,QAAO;CAExB,MAAM,QAAQ,QAAQ,SAAS;AAE/B,QAAO,OAAO,QACZ,WACG,SAAS,MAAqD,CAC7D,GAAG,IAAI,EAAE,GAAG,gBAAgB,IAAI,KAAI,OAAM;EAAE,IAAI;EAAG,eAAe;SAEtE,MAAK,EAAE,GAAG,QAAQ,aAEjB,KAAI,OAAM,GAAG,MAAK,MAAK,EAAE,kBAAkB,GAAG,MAAK,MAAK,CAAC,EAAE,gBAC3D,QAAQ,MAAkC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ //#region src/RS/v3/types/algorithm-parameters.d.ts
2
+ type ParameterName = 'overlap' | 'doubleBooking' | 'timeFrame' | 'breakLength' | 'clustering' | 'dailyOvertime' | 'position' | 'gap' | 'dependencyAlternation' | 'overtime' | 'dependencyRank' | 'dayRank' | 'groupRank';
3
+ type AlgorithmWeightParameters = Record<ParameterName, number | false>;
4
+ //#endregion
5
+ export { AlgorithmWeightParameters };
6
+ //# sourceMappingURL=algorithm-parameters.d.ts.map
@@ -1,5 +1,12 @@
1
+ import { AlgorithmWeightParameters } from "./algorithm-parameters.js";
2
+
1
3
  //#region src/RS/v3/types/out-options.d.ts
2
4
  type Id = 'id' | '_id';
5
+ type PartialScheduleOptions<IDs extends Array<string> | Set<string>> = {
6
+ includedEvents?: IDs;
7
+ includedLocations?: IDs;
8
+ omittedEventsHandling: 'ignore' | 'freeze';
9
+ };
3
10
  interface OutOptions {
4
11
  idKey?: Id;
5
12
  meta?: boolean;
@@ -7,11 +14,8 @@ interface OutOptions {
7
14
  isPublicId?: boolean;
8
15
  appendCoreData?: boolean;
9
16
  appendOutput?: boolean;
10
- partialScheduleOptions?: {
11
- includedEvents?: Set<string>;
12
- includedLocations?: Set<string>;
13
- omittedEventsHandling: 'ignore' | 'freeze';
14
- };
17
+ partialScheduleOptions?: PartialScheduleOptions<Array<string> | Set<string>>;
18
+ algorithmWeightParameters?: AlgorithmWeightParameters;
15
19
  useMaximumScheduleSpan?: boolean;
16
20
  }
17
21
  //#endregion
@@ -1,5 +1,6 @@
1
1
  import { Types } from "../../../core/v2/types/index.js";
2
2
  import { Serialized } from "../../../core/types/index.js";
3
+ import { AlgorithmWeightParameters } from "./algorithm-parameters.js";
3
4
  import { Configuration } from "./configurations.js";
4
5
  import { Constraint } from "./constraints.js";
5
6
 
@@ -14,6 +15,9 @@ interface Schedule {
14
15
  input?: Constraint;
15
16
  output?: Configuration[];
16
17
  coreData?: Serialized<Omit<Types.division, 'settings' | 'syllabuses'>> & Pick<Types.division, 'settings'>;
18
+ algorithmParameters?: {
19
+ weights?: AlgorithmWeightParameters;
20
+ };
17
21
  }
18
22
  //#endregion
19
23
  export { Schedule };
@@ -13,12 +13,12 @@ import { DivisionSettings } from "../types/division-settings.js";
13
13
  import { Division } from "../types/divisions.js";
14
14
  import { Types as Types$1 } from "../types/index.js";
15
15
  import { Deserialized, Serialized } from "../../types/index.js";
16
- import * as mongoose2 from "mongoose";
17
- import * as lodash0 from "lodash";
16
+ import * as mongoose5 from "mongoose";
17
+ import * as lodash1 from "lodash";
18
18
 
19
19
  //#region src/core/v2/to/schedules.d.ts
20
20
  declare function export_default(schedule: Deserialized<Types$1.schedule>): {
21
- syllabuses: lodash0.Omit<Deserialized<Syllabus>, "_id" | "belongsTo" | "createdAt" | "updatedAt" | "lastModifiedBy">[];
21
+ syllabuses: lodash1.Omit<Deserialized<Syllabus>, "_id" | "belongsTo" | "createdAt" | "updatedAt" | "lastModifiedBy">[];
22
22
  settings: DivisionSettings;
23
23
  rootIntervals: RootInterval[];
24
24
  overlapGroups: Serialized<Omit<OverlapGroup, "belongsTo" | "lastModifiedBy">>[];
@@ -46,7 +46,7 @@ declare function export_default(schedule: Deserialized<Types$1.schedule>): {
46
46
  to: string;
47
47
  }[] | undefined;
48
48
  course: string | undefined;
49
- _id?: mongoose2.Types.ObjectId | undefined;
49
+ _id?: mongoose5.Types.ObjectId | undefined;
50
50
  id?: string | undefined;
51
51
  belongsTo?: Deserialized<Division> | undefined;
52
52
  density?: number | undefined;
@@ -131,7 +131,7 @@ declare function export_default(schedule: Deserialized<Types$1.schedule>): {
131
131
  persons: {
132
132
  exceptions?: string[] | undefined;
133
133
  group: string | undefined;
134
- _id?: mongoose2.Types.ObjectId | undefined;
134
+ _id?: mongoose5.Types.ObjectId | undefined;
135
135
  id?: string | undefined;
136
136
  belongsTo?: Deserialized<Division> | undefined;
137
137
  ids?: string | undefined;
@@ -215,7 +215,7 @@ declare function export_default(schedule: Deserialized<Types$1.schedule>): {
215
215
  }[];
216
216
  locations: {
217
217
  exceptions?: string[] | Deserialized<Exception>[] | undefined;
218
- _id?: mongoose2.Types.ObjectId | undefined;
218
+ _id?: mongoose5.Types.ObjectId | undefined;
219
219
  id?: string | undefined;
220
220
  belongsTo?: Deserialized<Division> | undefined;
221
221
  ids?: string | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@royalschedule/maps",
3
3
  "description": "",
4
- "version": "3.3.13",
4
+ "version": "3.3.15",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",
@@ -1,10 +0,0 @@
1
- import { Types } from "../../../core/v2/types/index.js";
2
- import { Deserialized } from "../../../core/types/index.js";
3
- import { AvailableDependency } from "../types/available-dependencies.js";
4
- import { OutOptions } from "../types/out-options.js";
5
-
6
- //#region src/RS/v3/to/available-dependencies.d.ts
7
- declare function export_default(availableLocations: Deserialized<Types.availableLocation>[], options: OutOptions): AvailableDependency[][];
8
- //#endregion
9
- export { export_default };
10
- //# sourceMappingURL=available-dependencies.d.ts.map
@@ -1,13 +0,0 @@
1
- import { Types } from "../../../../core/v2/types/index.js";
2
- import { Deserialized } from "../../../../core/types/index.js";
3
- import { CourseEvent } from "../../types/course-events.js";
4
- import { Individual } from "../../types/individuals.js";
5
- import { OutOptions } from "../../types/out-options.js";
6
- import moment from "moment";
7
-
8
- //#region src/RS/v3/to/course-events/index.d.ts
9
-
10
- declare function export_default(courseEvents: Deserialized<Types.event>[] | Deserialized<Types.event>, overlapGroups: Deserialized<Types.overlapGroup>[] | undefined, settings: Types.divisionSettings, options: OutOptions, periodsMap: Map<string | undefined, number>, destructMap?: Map<string | null, Individual>): CourseEvent[];
11
- //#endregion
12
- export { export_default };
13
- //# sourceMappingURL=index.d.ts.map
@@ -1,10 +0,0 @@
1
- import { Types } from "../../../core/v2/types/index.js";
2
- import { Deserialized } from "../../../core/types/index.js";
3
- import { Dependency } from "../types/dependencies.js";
4
- import { OutOptions } from "../types/out-options.js";
5
-
6
- //#region src/RS/v3/to/dependencies.d.ts
7
- declare function export_default(locations: Deserialized<Types.location>[], settings: Types.divisionSettings, options: OutOptions): Dependency[];
8
- //#endregion
9
- export { export_default };
10
- //# sourceMappingURL=dependencies.d.ts.map
@@ -1,22 +0,0 @@
1
- //#region src/RS/v3/to/persons.ts
2
- var persons_default = (persons, settings, options) => {
3
- if (persons == null) return [];
4
- const idKey = options.idKey || "id";
5
- return (Array.isArray(persons) ? persons : [persons]).filter((x) => !x.group).map((person, index) => {
6
- if (person[idKey] == void 0) throw new Error(`(RS::V3::To::Persons) A person must have an id, index: ${index}`);
7
- const doc = {
8
- id: `persons.${person[idKey].toString()}`,
9
- group_type: "persons",
10
- minimizeDependencyAlternation: false
11
- };
12
- if (options.meta) Object.assign(doc, {
13
- ...person.ids && { ids: person.ids },
14
- ...person.firstName && { name: `${person.firstName} ${person.lastName}` }
15
- });
16
- return doc;
17
- }, []);
18
- };
19
-
20
- //#endregion
21
- export { persons_default as default };
22
- //# sourceMappingURL=persons.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"persons.js","names":["idKey: keyof CoreTypes.person","doc: Group"],"sources":["../../../../src/RS/v3/to/persons.ts"],"sourcesContent":["import { Group } from '../types/groups';\nimport { OutOptions } from '../types/out-options';\n\nimport { Types as CoreTypes } from '../../../core/types';\nimport { Deserialized } from '../../../core/types';\n\nexport default (persons: Deserialized<CoreTypes.person>[] | Deserialized<CoreTypes.person>,\n settings: CoreTypes.divisionSettings,\n options: OutOptions): Group[] => {\n if (persons == null)\n return [];\n\n const idKey: keyof CoreTypes.person = options.idKey || 'id';\n\n return (Array.isArray(persons) ? persons : [persons]).filter(x => !x.group).map((person, index) => {\n\n if (person[idKey] == undefined) throw new Error(`(RS::V3::To::Persons) A person must have an id, index: ${ index }`);\n\n const doc: Group = {\n id: `persons.${ person[idKey]!.toString() }`,\n group_type: 'persons',\n minimizeDependencyAlternation: false,\n };\n\n if (options.meta) {\n Object.assign(doc, {\n ...person.ids && { ids: person.ids },\n ...person.firstName && { name: `${ person.firstName } ${ person.lastName }` },\n });\n }\n\n return doc;\n }, []);\n};\n"],"mappings":";AAMA,uBAAgB,SACd,UACA,YAAkC;AAClC,KAAI,WAAW,KACb,QAAO;CAET,MAAMA,QAAgC,QAAQ,SAAS;AAEvD,SAAQ,MAAM,QAAQ,WAAW,UAAU,CAAC,UAAU,QAAO,MAAK,CAAC,EAAE,OAAO,KAAK,QAAQ,UAAU;AAEjG,MAAI,OAAO,UAAU,OAAW,OAAM,IAAI,MAAM,0DAA2D;EAE3G,MAAMC,MAAa;GACjB,IAA+B,WAAY,OAAO,OAAQ;GAC1D,YAA+B;GAC/B,+BAA+B;;AAGjC,MAAI,QAAQ,KACV,QAAO,OAAO,KAAK;GACjB,GAAG,OAAO,OAAiC,EAAE,KAA4B,OAAO;GAChF,GAAG,OAAO,aAAiC,EAAE,MAA4B,GAAI,OAAO,UAAW,GAAI,OAAO;;AAI9G,SAAO;IACN"}