@royalschedule/maps 3.3.14 → 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.
- package/dist/RS/v3/to/collections.js +1 -1
- package/dist/RS/v3/to/constraints.js +1 -17
- package/dist/RS/v3/to/constraints.js.map +1 -1
- package/dist/RS/v3/to/dynamic-locked-times.js +67 -58
- package/dist/RS/v3/to/dynamic-locked-times.js.map +1 -1
- package/dist/RS/v3/to/index.d.ts +10 -34
- package/dist/RS/v3/to/index.js +0 -26
- package/dist/RS/v3/to/index.js.map +1 -1
- package/dist/RS/v3/to/schedules.js +18 -2
- package/dist/RS/v3/to/schedules.js.map +1 -1
- package/dist/RS/v3/types/out-options.d.ts +1 -4
- package/dist/core/v2/to/schedules.d.ts +6 -6
- package/package.json +1 -1
- package/dist/RS/v3/to/available-dependencies.d.ts +0 -10
- package/dist/RS/v3/to/course-events/index.d.ts +0 -13
- package/dist/RS/v3/to/dependencies.d.ts +0 -10
- package/dist/RS/v3/to/persons.js +0 -22
- package/dist/RS/v3/to/persons.js.map +0 -1
|
@@ -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";
|
|
@@ -11,23 +11,7 @@ import { parsePeriods } from "./periods.js";
|
|
|
11
11
|
import { pick } from "lodash-es";
|
|
12
12
|
|
|
13
13
|
//#region src/RS/v3/to/constraints.ts
|
|
14
|
-
var constraints_default = (schedule,
|
|
15
|
-
const options = (() => {
|
|
16
|
-
const pso = _options.partialScheduleOptions;
|
|
17
|
-
const partialScheduleOptions = pso ? {
|
|
18
|
-
includedEvents: pso.includedEvents ? new Set(pso.includedEvents) : void 0,
|
|
19
|
-
includedLocations: pso.includedLocations ? new Set(pso.includedLocations) : void 0,
|
|
20
|
-
omittedEventsHandling: pso.omittedEventsHandling
|
|
21
|
-
} : void 0;
|
|
22
|
-
return {
|
|
23
|
-
..._options,
|
|
24
|
-
partialScheduleOptions
|
|
25
|
-
};
|
|
26
|
-
})();
|
|
27
|
-
if (options.partialScheduleOptions?.includedEvents?.size) options.partialScheduleOptions.includedEvents = new Set([...options.partialScheduleOptions.includedEvents].map((x) => {
|
|
28
|
-
if (x.startsWith("events.") || x.startsWith("lockedTimes.")) return x;
|
|
29
|
-
return `events.${x}`;
|
|
30
|
-
}));
|
|
14
|
+
var constraints_default = (schedule, options = {}) => {
|
|
31
15
|
schedule = structuredClone(schedule);
|
|
32
16
|
if (schedule == null) return {};
|
|
33
17
|
const idKey = options.idKey || "id";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constraints.js","names":["
|
|
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,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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
36
|
-
|
|
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'"
|
|
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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"}
|
package/dist/RS/v3/to/index.d.ts
CHANGED
|
@@ -15,40 +15,18 @@ import { Types as Types$1 } from "../../../core/v2/types/index.js";
|
|
|
15
15
|
import { Deserialized, Serialized } from "../../../core/types/index.js";
|
|
16
16
|
import { AlgorithmWeightParameters } from "../types/algorithm-parameters.js";
|
|
17
17
|
import { Configuration } from "../types/configurations.js";
|
|
18
|
-
import { Settings } from "../types/settings.js";
|
|
19
|
-
import { LockedTime as LockedTime$1 } from "../types/locked-times.js";
|
|
20
|
-
import { Interval as Interval$1 } from "../types/intervals.js";
|
|
21
|
-
import { Collection } from "../types/collections.js";
|
|
22
|
-
import { Group } from "../types/groups.js";
|
|
23
|
-
import { Individual } from "../types/individuals.js";
|
|
24
18
|
import { Constraint } from "../types/constraints.js";
|
|
25
|
-
import { OutOptions
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import { export_default as export_default$2 } from "./dependencies.js";
|
|
29
|
-
import * as mongoose5 from "mongoose";
|
|
30
|
-
import * as lodash1 from "lodash";
|
|
19
|
+
import { OutOptions } from "../types/out-options.js";
|
|
20
|
+
import * as mongoose2 from "mongoose";
|
|
21
|
+
import * as lodash0 from "lodash";
|
|
31
22
|
|
|
32
23
|
//#region src/RS/v3/to/index.d.ts
|
|
33
|
-
declare class export_default
|
|
34
|
-
static
|
|
35
|
-
static configuration: (events: Deserialized<Types$1.event>[], options: ParsedOutOptions) => Configuration[];
|
|
36
|
-
static constraints: (schedule: Partial<Deserialized<Types$1.schedule> & {
|
|
37
|
-
division: Deserialized<Types$1.division>;
|
|
38
|
-
}>, _options?: OutOptions) => Constraint;
|
|
39
|
-
static courseEvent: typeof export_default$1;
|
|
40
|
-
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: ParsedOutOptions, periodsMap: Map<string | undefined, number>, destructMap?: Map<string | null, Individual>) => (Collection[] | Collection)[];
|
|
41
|
-
static day: (days: Types$1.day[], numDays: number) => number[];
|
|
42
|
-
static dependency: typeof export_default$2;
|
|
43
|
-
static group: (groups: Deserialized<Types$1.group>[] | Deserialized<Types$1.group>, settings: Types$1.divisionSettings, options: ParsedOutOptions) => Group[];
|
|
44
|
-
static interval: (intervals: Types$1.interval[] | undefined, settings: Types$1.divisionSettings, rootInterval?: Types$1.rootInterval) => Interval$1[][];
|
|
45
|
-
static lockedTime: (lockedTimes: Types$1.lockedTime[] | Types$1.lockedTime, options: ParsedOutOptions) => LockedTime$1[] | never;
|
|
46
|
-
static persons: (persons: Deserialized<Types$1.person>[] | Deserialized<Types$1.person>, settings: Types$1.divisionSettings, options: ParsedOutOptions) => Group[];
|
|
47
|
-
static schedules: (schedule: Deserialized<Types$1.schedule>, options?: OutOptions) => {
|
|
24
|
+
declare class export_default {
|
|
25
|
+
static schedules: (schedule: Deserialized<Types$1.schedule>, _options?: OutOptions) => {
|
|
48
26
|
input: Constraint;
|
|
49
27
|
output?: Configuration[] | undefined;
|
|
50
28
|
coreData?: {
|
|
51
|
-
syllabuses:
|
|
29
|
+
syllabuses: lodash0.Omit<Deserialized<Syllabus>, "_id" | "belongsTo" | "createdAt" | "updatedAt" | "lastModifiedBy">[];
|
|
52
30
|
settings: DivisionSettings;
|
|
53
31
|
rootIntervals: RootInterval[];
|
|
54
32
|
overlapGroups: Serialized<Omit<OverlapGroup, "belongsTo" | "lastModifiedBy">>[];
|
|
@@ -76,7 +54,7 @@ declare class export_default$3 {
|
|
|
76
54
|
to: string;
|
|
77
55
|
}[] | undefined;
|
|
78
56
|
course: string | undefined;
|
|
79
|
-
_id?:
|
|
57
|
+
_id?: mongoose2.Types.ObjectId | undefined;
|
|
80
58
|
id?: string | undefined;
|
|
81
59
|
belongsTo?: Deserialized<Division> | undefined;
|
|
82
60
|
density?: number | undefined;
|
|
@@ -161,7 +139,7 @@ declare class export_default$3 {
|
|
|
161
139
|
persons: {
|
|
162
140
|
exceptions?: string[] | undefined;
|
|
163
141
|
group: string | undefined;
|
|
164
|
-
_id?:
|
|
142
|
+
_id?: mongoose2.Types.ObjectId | undefined;
|
|
165
143
|
id?: string | undefined;
|
|
166
144
|
belongsTo?: Deserialized<Division> | undefined;
|
|
167
145
|
ids?: string | undefined;
|
|
@@ -245,7 +223,7 @@ declare class export_default$3 {
|
|
|
245
223
|
}[];
|
|
246
224
|
locations: {
|
|
247
225
|
exceptions?: string[] | Deserialized<Exception>[] | undefined;
|
|
248
|
-
_id?:
|
|
226
|
+
_id?: mongoose2.Types.ObjectId | undefined;
|
|
249
227
|
id?: string | undefined;
|
|
250
228
|
belongsTo?: Deserialized<Division> | undefined;
|
|
251
229
|
ids?: string | undefined;
|
|
@@ -282,9 +260,7 @@ declare class export_default$3 {
|
|
|
282
260
|
weights: AlgorithmWeightParameters | undefined;
|
|
283
261
|
};
|
|
284
262
|
};
|
|
285
|
-
static setting: (settings: Types$1.divisionSettings) => Settings;
|
|
286
|
-
static teacher: (teachers: Deserialized<Types$1.teacher>[] | Deserialized<Types$1.teacher>, settings: Types$1.divisionSettings, options: ParsedOutOptions) => Group[];
|
|
287
263
|
}
|
|
288
264
|
//#endregion
|
|
289
|
-
export { export_default
|
|
265
|
+
export { export_default };
|
|
290
266
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/RS/v3/to/index.js
CHANGED
|
@@ -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":["
|
|
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,11 +1,27 @@
|
|
|
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,
|
|
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",
|
|
@@ -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
|
|
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"}
|
|
@@ -18,9 +18,6 @@ interface OutOptions {
|
|
|
18
18
|
algorithmWeightParameters?: AlgorithmWeightParameters;
|
|
19
19
|
useMaximumScheduleSpan?: boolean;
|
|
20
20
|
}
|
|
21
|
-
type ParsedOutOptions = Omit<OutOptions, 'partialScheduleOptions'> & {
|
|
22
|
-
partialScheduleOptions?: PartialScheduleOptions<Set<string>>;
|
|
23
|
-
};
|
|
24
21
|
//#endregion
|
|
25
|
-
export { OutOptions
|
|
22
|
+
export { OutOptions };
|
|
26
23
|
//# sourceMappingURL=out-options.d.ts.map
|
|
@@ -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;
|
|
@@ -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?:
|
|
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,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 { ParsedOutOptions } 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: ParsedOutOptions): 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 { ParsedOutOptions } 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: ParsedOutOptions, 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 { ParsedOutOptions } 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: ParsedOutOptions): Dependency[];
|
|
8
|
-
//#endregion
|
|
9
|
-
export { export_default };
|
|
10
|
-
//# sourceMappingURL=dependencies.d.ts.map
|
package/dist/RS/v3/to/persons.js
DELETED
|
@@ -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 { ParsedOutOptions as 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"}
|