@royalschedule/maps 3.3.9 → 3.3.10
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.
- package/dist/RS/v3/to/constraints.js +1 -1
- package/dist/RS/v3/to/constraints.js.map +1 -1
- package/dist/RS/v3/to/dynamic-locked-times.js +2 -2
- package/dist/RS/v3/to/dynamic-locked-times.js.map +1 -1
- package/dist/RS/v3/to/index.d.ts +7 -7
- package/dist/core/v2/from/schedules.d.ts +1 -1
- package/dist/core/v2/to/schedules.d.ts +7 -7
- package/dist/core/v2/types/locked-times.d.ts +1 -1
- package/dist/core/v2/types/teachers.d.ts +1 -1
- package/package.json +1 -1
|
@@ -72,7 +72,7 @@ var constraints_default = (schedule, options = {}) => {
|
|
|
72
72
|
* Only add lunch if the group is a class
|
|
73
73
|
*/
|
|
74
74
|
if (groups?.some((group) => "lunch" in group)) data.events = (data.events ?? []).concat(dynamic_locked_times_default(groups.filter((x) => x.species == "class"), settings, options, lunchSet, destructMap));
|
|
75
|
-
if (teachers?.some((teacher) => "lunch" in teacher || "
|
|
75
|
+
if (teachers?.some((teacher) => "lunch" in teacher || "complementaryTimes" in teacher)) data.events = (data.events ?? []).concat(dynamic_locked_times_default(teachers, settings, options, lunchSet));
|
|
76
76
|
return data;
|
|
77
77
|
};
|
|
78
78
|
|
|
@@ -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 || '
|
|
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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|
|
32
32
|
toModel: ""
|
|
33
33
|
}]
|
|
34
34
|
}));
|
|
35
|
-
if ("
|
|
35
|
+
if ("complementaryTimes" in group) lunch = lunch?.concat(group.complementaryTimes ?? []);
|
|
36
36
|
if (lunch == null) return acc;
|
|
37
37
|
return acc.concat(lunch.reduce((acc$1, lockedTime) => {
|
|
38
38
|
const { _id, intervals, duration, durationVariance, coalesced } = lockedTime;
|
|
@@ -46,7 +46,7 @@ var dynamic_locked_times_default = (docs, settings, options, set, destructMap) =
|
|
|
46
46
|
if (days) days = [...new Set(days)];
|
|
47
47
|
const day = days?.length == 1 ? days[0] : void 0;
|
|
48
48
|
const groups = mapCoalescedReferences(coalesced, options, destructMap);
|
|
49
|
-
const distributionKey = lockedTime.type == "
|
|
49
|
+
const distributionKey = lockedTime.type == "COMPLEMENTARY_TIME" ? "COMPLEMENTARY_TIME." + lockedTime.tags?.at(0)?.value : void 0;
|
|
50
50
|
const doc = {
|
|
51
51
|
id: `${group.lunch == null ? "virtual" : "lockedTimes"}.${id}`,
|
|
52
52
|
groups: [...new Set(groups.filter(Boolean))],
|
|
@@ -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 ('
|
|
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 find the day(s) the events should be placed on\n */\n\n let days = intervals?.length\n ? intervals.map(({ start }) => (moment(start).day() + 6) % 7)\n : undefined;\n if (days)\n days = [...new Set(days)];\n const day = days?.length == 1 ? days[0] : undefined;\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":";;;;;;;AAcA,SAAS,uBACP,WACA,SACA,aACA;CACA,MAAM,QAAQ,QAAQ,SAAS;AAE/B,KAAI,CAAC,UAAW,QAAO;CAEvB,MAAM,WAAe,UAAU,QAAO,MAAK,EAAE,WAAW;CACxD,MAAM,SAAe,UAAU,QAAO,MAAK,EAAE,WAAW;CACxD,MAAM,eAAe,UAAU,QAAO,MAAK,EAAE,WAAW;CAExD,MAAM,aAAiB,SAAa,KAAK,EAAE,SAAS,GAAG,QAAQ,QAAQ,MAAkC,CAAC,CAAC,GACxG,KAAI,OAAM,EAAE,aAAa,CAAC,0BAA0B,EAAE;CACzD,MAAM,WAAiB,OAAa,KAAK,EAAE,SAAS,GAAG,QAAQ,QAAQ,MAAkC,CAAC,CAAC,GACxG,KAAI,MAAK,YAAY,EAAE;CAC1B,MAAM,iBAAiB,aAAa,KAAK,EAAE,SAAS,GAAG,QAAQ,QAAQ,MAAkC,CAAC,CAAC,GACxG,KAAI,OAAM,EAAE,aAAa,CAAC,aAAc,EAAE;CAG7C,MAAM,MAAM;EAAC,GAAG,IAAI,IAAI;EAAa,GAAG,IAAI,IAAI;EAAW,GAAG,IAAI,IAAI;GAAiB,KAAI,MAAK,CAAC;AACjG,QAAO;;AAGT,oCACE,MACA,UACA,SACA,KACA,gBACG;CAEH,MAAMA,QAA+B,QAAQ,SAAS;AAEtD,QAAO,KACJ,QAAO,MAAK,CAAC,CAAC,GACd,QAAQ,KAAoB,UAAyB;EACpD,IAAI,QAAQ,MAAM;AAClB,MAAI,SAAS,KACX,SAAQ,SAAS,cAAc,KAAI,aAAU;GAAE,GAAGC;GAAO,WAAW,CAAC;IAAE,IAAI,KAAK,OAA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,gBAAgB,0BAA0B,QAAQ;AAC1D,QAAI,kBAAkB,CAAC,eAAe,IAAI,IAAI,KAAK;AAEjD,SAAI,yBAAyB,SAAU,QAAOF;AAE9C,SAAI,yBAAyB,UAAU;AAErC,UAAI,WAAW,UAAU,CAAC,WAAW,SAAS,CAAC,WAAW,SAAU,QAAOA;AAG3E,aAAO,OAAO,KAAK,cAAc,WAAW;AAC5C,UAAI,SAAS,WAAW;AACxB,UAAI,oBAAoB;MAGxB,MAAM,UAAU,SAAS,WAAW;AACpC,UAAI,OAAY,MAAM,KAAK,EAAE,QAAQ,YAAY,GAAG,MAAM;AAC1D,UAAI,YAAY,MAAM,KAAK,EAAE,QAAQ,iBAAiB,CAAC;OAAE,KAAK;OAAG,KAAK;;;;;AAQ5E,UAAOA,MAAI,OAAO;KACjB;IAEJ,IACF,OACA,OAAO"}
|
package/dist/RS/v3/to/index.d.ts
CHANGED
|
@@ -25,8 +25,8 @@ import { OutOptions } from "../types/out-options.js";
|
|
|
25
25
|
import { export_default } from "./available-dependencies.js";
|
|
26
26
|
import { export_default as export_default$1 } from "./course-events/index.js";
|
|
27
27
|
import { export_default as export_default$2 } from "./dependencies.js";
|
|
28
|
-
import * as
|
|
29
|
-
import * as
|
|
28
|
+
import * as mongoose2 from "mongoose";
|
|
29
|
+
import * as lodash0 from "lodash";
|
|
30
30
|
|
|
31
31
|
//#region src/RS/v3/to/index.d.ts
|
|
32
32
|
declare class export_default$3 {
|
|
@@ -47,7 +47,7 @@ declare class export_default$3 {
|
|
|
47
47
|
input: Constraint;
|
|
48
48
|
output?: Configuration[] | undefined;
|
|
49
49
|
coreData?: {
|
|
50
|
-
syllabuses:
|
|
50
|
+
syllabuses: lodash0.Omit<Deserialized<Syllabus>, "_id" | "belongsTo" | "createdAt" | "updatedAt" | "lastModifiedBy">[];
|
|
51
51
|
settings: DivisionSettings;
|
|
52
52
|
rootIntervals: RootInterval[];
|
|
53
53
|
overlapGroups: Serialized<Omit<OverlapGroup, "belongsTo" | "lastModifiedBy">>[];
|
|
@@ -75,7 +75,7 @@ declare class export_default$3 {
|
|
|
75
75
|
to: string;
|
|
76
76
|
}[] | undefined;
|
|
77
77
|
course: string | undefined;
|
|
78
|
-
_id?:
|
|
78
|
+
_id?: mongoose2.Types.ObjectId | undefined;
|
|
79
79
|
id?: string | undefined;
|
|
80
80
|
belongsTo?: Deserialized<Division> | undefined;
|
|
81
81
|
density?: number | undefined;
|
|
@@ -160,7 +160,7 @@ declare class export_default$3 {
|
|
|
160
160
|
persons: {
|
|
161
161
|
exceptions?: string[] | undefined;
|
|
162
162
|
group: string | undefined;
|
|
163
|
-
_id?:
|
|
163
|
+
_id?: mongoose2.Types.ObjectId | undefined;
|
|
164
164
|
id?: string | undefined;
|
|
165
165
|
belongsTo?: Deserialized<Division> | undefined;
|
|
166
166
|
ids?: string | undefined;
|
|
@@ -239,12 +239,12 @@ declare class export_default$3 {
|
|
|
239
239
|
maximumScheduleSpan?: MaximumScheduleSpan | undefined;
|
|
240
240
|
rootInterval?: Deserialized<RootInterval> | undefined;
|
|
241
241
|
plannedScheduledDuration?: PlannedScheduledDuration | undefined;
|
|
242
|
-
|
|
242
|
+
complementaryTimes?: Deserialized<LockedTime>[] | undefined;
|
|
243
243
|
signature?: string | undefined;
|
|
244
244
|
}[];
|
|
245
245
|
locations: {
|
|
246
246
|
exceptions?: string[] | Deserialized<Exception>[] | undefined;
|
|
247
|
-
_id?:
|
|
247
|
+
_id?: mongoose2.Types.ObjectId | undefined;
|
|
248
248
|
id?: string | undefined;
|
|
249
249
|
belongsTo?: Deserialized<Division> | undefined;
|
|
250
250
|
ids?: string | undefined;
|
|
@@ -209,7 +209,7 @@ declare function export_default$1(schedule: ReturnType<typeof export_default>):
|
|
|
209
209
|
maximumScheduleSpan?: MaximumScheduleSpan | undefined;
|
|
210
210
|
rootInterval?: Deserialized<RootInterval> | undefined;
|
|
211
211
|
plannedScheduledDuration?: PlannedScheduledDuration | undefined;
|
|
212
|
-
|
|
212
|
+
complementaryTimes?: Deserialized<LockedTime>[] | undefined;
|
|
213
213
|
signature?: string | undefined;
|
|
214
214
|
}[];
|
|
215
215
|
locations: {
|
|
@@ -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
|
|
17
|
-
import * as
|
|
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:
|
|
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?:
|
|
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?:
|
|
134
|
+
_id?: mongoose5.Types.ObjectId | undefined;
|
|
135
135
|
id?: string | undefined;
|
|
136
136
|
belongsTo?: Deserialized<Division> | undefined;
|
|
137
137
|
ids?: string | undefined;
|
|
@@ -210,12 +210,12 @@ declare function export_default(schedule: Deserialized<Types$1.schedule>): {
|
|
|
210
210
|
maximumScheduleSpan?: MaximumScheduleSpan | undefined;
|
|
211
211
|
rootInterval?: Deserialized<RootInterval> | undefined;
|
|
212
212
|
plannedScheduledDuration?: PlannedScheduledDuration | undefined;
|
|
213
|
-
|
|
213
|
+
complementaryTimes?: Deserialized<LockedTime>[] | undefined;
|
|
214
214
|
signature?: string | undefined;
|
|
215
215
|
}[];
|
|
216
216
|
locations: {
|
|
217
217
|
exceptions?: string[] | Deserialized<Exception>[] | undefined;
|
|
218
|
-
_id?:
|
|
218
|
+
_id?: mongoose5.Types.ObjectId | undefined;
|
|
219
219
|
id?: string | undefined;
|
|
220
220
|
belongsTo?: Deserialized<Division> | undefined;
|
|
221
221
|
ids?: string | undefined;
|
|
@@ -12,7 +12,7 @@ import moment from "moment";
|
|
|
12
12
|
import { Types } from "mongoose";
|
|
13
13
|
|
|
14
14
|
//#region src/core/v2/types/locked-times.d.ts
|
|
15
|
-
type Type = 'ANY' | 'LUNCH' | '
|
|
15
|
+
type Type = 'ANY' | 'LUNCH' | 'COMPLEMENTARY_TIME';
|
|
16
16
|
interface LockedTimeBare {
|
|
17
17
|
belongsTo?: Edge<Division>;
|
|
18
18
|
displayName?: string;
|
|
@@ -28,7 +28,7 @@ interface TeacherBare {
|
|
|
28
28
|
exceptions?: Edge<Exception[]>;
|
|
29
29
|
lockedTimes?: Edge<LockedTime[]>;
|
|
30
30
|
lunch?: Edge<LockedTime[]>;
|
|
31
|
-
|
|
31
|
+
complementaryTimes?: Edge<LockedTime[]>;
|
|
32
32
|
intervals?: Interval[];
|
|
33
33
|
rootInterval?: Edge<RootInterval>;
|
|
34
34
|
days?: Day[];
|