@royalschedule/maps 3.3.14 → 3.3.16
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/Additio/to/index.d.ts +3 -1
- package/dist/Additio/to/schedules.js +37 -22
- package/dist/Additio/to/schedules.js.map +1 -1
- package/dist/Additio/types/schedules.d.ts +5 -1
- package/dist/PlanDigital/to/index.d.ts +2 -2
- 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 +4 -28
- 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/SchoolSoft/file/to/index.d.ts +2 -2
- 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,4 +1,5 @@
|
|
|
1
1
|
import { Types } from "../../core/v2/types/index.js";
|
|
2
|
+
import { Options } from "../types/schedules.js";
|
|
2
3
|
import * as xlsx0 from "xlsx";
|
|
3
4
|
|
|
4
5
|
//#region src/Additio/to/index.d.ts
|
|
@@ -12,7 +13,8 @@ declare class export_default {
|
|
|
12
13
|
teachers: Types.teacher[];
|
|
13
14
|
courses: Types.course[];
|
|
14
15
|
events: Types.event[];
|
|
15
|
-
|
|
16
|
+
lockedTimes: Types.lockedTime[];
|
|
17
|
+
}, options?: Options) => xlsx0.WorkBook;
|
|
16
18
|
}
|
|
17
19
|
//#endregion
|
|
18
20
|
export { export_default };
|
|
@@ -7,7 +7,7 @@ const getId = (ref) => {
|
|
|
7
7
|
if (typeof ref == "string") return ref;
|
|
8
8
|
return ref.id.toString();
|
|
9
9
|
};
|
|
10
|
-
var schedules_default = (schedule) => {
|
|
10
|
+
var schedules_default = (schedule, options = {}) => {
|
|
11
11
|
const periodsMap = new Map(schedule.periods.map((x) => [getId(x), x]));
|
|
12
12
|
periodsMap.set("", { ranges: [{
|
|
13
13
|
start: schedule.division.start,
|
|
@@ -31,20 +31,20 @@ var schedules_default = (schedule) => {
|
|
|
31
31
|
const groupsMap = new Map(schedule.groups.map((x) => [getId(x), x]));
|
|
32
32
|
const teachersMap = new Map(schedule.teachers.map((x) => [getId(x), x]));
|
|
33
33
|
const coursesMap = new Map(schedule.courses.map((x) => [getId(x), x]));
|
|
34
|
-
const events = schedule.events.
|
|
35
|
-
if (
|
|
36
|
-
const course = coursesMap.get(getId(
|
|
37
|
-
if (!course) return
|
|
38
|
-
const start = moment.utc(
|
|
39
|
-
const end = moment.utc(
|
|
40
|
-
const periodId = getId(
|
|
34
|
+
const events = (options.includeEvents ?? true ? schedule.events : []).map((x) => {
|
|
35
|
+
if (x.parked) return;
|
|
36
|
+
const course = coursesMap.get(getId(x.course));
|
|
37
|
+
if (!course) return;
|
|
38
|
+
const start = moment.utc(x.start);
|
|
39
|
+
const end = moment.utc(x.end);
|
|
40
|
+
const periodId = getId(x.period ?? course.period ?? schedule.settings.period);
|
|
41
41
|
const inWeeks = inWeeksMap.get(periodId);
|
|
42
|
-
const locations = (
|
|
43
|
-
const teachers = (
|
|
44
|
-
const groups = (
|
|
42
|
+
const locations = (x.inLocations ?? []).map((x$1) => x$1 ? locationsMap.get(getId(x$1)) : null).filter((x$1) => !!x$1);
|
|
43
|
+
const teachers = (x.teachers ?? course.teachers ?? []).map((x$1) => teachersMap.get(getId(x$1.to))).filter((x$1) => !!x$1);
|
|
44
|
+
const groups = (x.groups ?? course.groups ?? []).map((x$1) => groupsMap.get(getId(x$1.to))).filter((x$1) => !!x$1);
|
|
45
45
|
const out = {
|
|
46
|
-
id:
|
|
47
|
-
externalid:
|
|
46
|
+
id: x._id?.toString(),
|
|
47
|
+
externalid: x.ids?.toString(),
|
|
48
48
|
groupid: course.ids,
|
|
49
49
|
group: course.displayName,
|
|
50
50
|
dayid: (start.day() + 6) % 7,
|
|
@@ -52,16 +52,31 @@ var schedules_default = (schedule) => {
|
|
|
52
52
|
length: end.diff(start, "minutes"),
|
|
53
53
|
subject: course.subject,
|
|
54
54
|
inweek: inWeeks,
|
|
55
|
-
roomid: locations.map((x) => x.ids).join(", "),
|
|
56
|
-
room: locations.map((x) => x.displayName).join(", "),
|
|
57
|
-
teacherid: teachers.map((x) => x.ids).join(", "),
|
|
58
|
-
teacher: teachers.map((x) => x.displayName).join(", "),
|
|
59
|
-
classid: groups.map((x) => x.ids).join(", "),
|
|
60
|
-
class: groups.map((x) => x.displayName).join(", ")
|
|
55
|
+
roomid: locations.map((x$1) => x$1.ids).join(", "),
|
|
56
|
+
room: locations.map((x$1) => x$1.displayName).join(", "),
|
|
57
|
+
teacherid: teachers.map((x$1) => x$1.ids).join(", "),
|
|
58
|
+
teacher: teachers.map((x$1) => x$1.displayName).join(", "),
|
|
59
|
+
classid: groups.map((x$1) => x$1.ids).join(", "),
|
|
60
|
+
class: groups.map((x$1) => x$1.displayName).join(", ")
|
|
61
61
|
};
|
|
62
|
-
return
|
|
63
|
-
}
|
|
64
|
-
|
|
62
|
+
return out;
|
|
63
|
+
}).filter((x) => !!x);
|
|
64
|
+
const complementaryTimes = (options.includeComplementaryTimes ?? true ? schedule.lockedTimes : []).filter((x) => x.type == "COMPLEMENTARY_TIME").map((x) => {
|
|
65
|
+
if (x.parked) return;
|
|
66
|
+
const start = moment.utc(x.start);
|
|
67
|
+
const end = moment.utc(x.end);
|
|
68
|
+
const teachers = (x.coalesced ?? []).filter((x$1) => x$1.toModel == "teachers").map((x$1) => teachersMap.get(getId(x$1.to))).filter((x$1) => !!x$1);
|
|
69
|
+
const out = {
|
|
70
|
+
id: x._id?.toString(),
|
|
71
|
+
dayid: (start.day() + 6) % 7,
|
|
72
|
+
startTime: start.format("HHmm"),
|
|
73
|
+
length: end.diff(start, "minutes"),
|
|
74
|
+
teacherid: teachers.map((x$1) => x$1.ids).join(", "),
|
|
75
|
+
teacher: teachers.map((x$1) => x$1.displayName).join(", ")
|
|
76
|
+
};
|
|
77
|
+
return out;
|
|
78
|
+
}).filter((x) => !!x);
|
|
79
|
+
return toXlsx([...events, ...complementaryTimes]);
|
|
65
80
|
};
|
|
66
81
|
function toXlsx(events) {
|
|
67
82
|
const wb = XLSX$1.utils.book_new();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedules.js","names":["weeks","out: OutEvent","XLSX"],"sources":["../../../src/Additio/to/schedules.ts"],"sourcesContent":["import * as XLSX from 'xlsx';\nimport moment from 'moment';\nimport { Types } from 'mongoose';\n\nimport { Types as CoreTypes } from '../../core/types';\n\ntype OutEvent = {\n id?: string;\n externalid?: string;\n groupid?: string;\n group?: string;\n dayid?: number;\n startTime?: string;\n length?: number;\n subject?: string;\n roomid?: string;\n room?: string;\n teacherid?: string;\n teacher?: string;\n classid?: string;\n class?: string;\n inweek?: string;\n};\n\ntype Schedule = {\n division:
|
|
1
|
+
{"version":3,"file":"schedules.js","names":["weeks","x","out: OutEvent","XLSX"],"sources":["../../../src/Additio/to/schedules.ts"],"sourcesContent":["import * as XLSX from 'xlsx';\nimport moment from 'moment';\nimport { Types } from 'mongoose';\n\nimport { Types as CoreTypes } from '../../core/types';\nimport { Options } from '../types/schedules';\n\ntype OutEvent = {\n id?: string;\n externalid?: string;\n groupid?: string;\n group?: string;\n dayid?: number;\n startTime?: string;\n length?: number;\n subject?: string;\n roomid?: string;\n room?: string;\n teacherid?: string;\n teacher?: string;\n classid?: string;\n class?: string;\n inweek?: string;\n};\n\ntype Schedule = {\n division: CoreTypes.division;\n settings: CoreTypes.divisionSettings;\n periods: CoreTypes.period[];\n locations: CoreTypes.location[];\n groups: CoreTypes.group[];\n teachers: CoreTypes.teacher[];\n courses: CoreTypes.course[];\n events: CoreTypes.event[];\n lockedTimes: CoreTypes.lockedTime[];\n};\n\n\nconst getId = (ref: { id?: string } | Types.ObjectId | string | undefined): string => {\n if (!ref) return '';\n if (typeof ref == 'string') return ref;\n return ref.id!.toString();\n};\n\nexport default (\n schedule: Schedule,\n options: Options = { }\n): XLSX.WorkBook => {\n\n // a map of period.id -> period\n const periodsMap = new Map(schedule.periods.map(x => [getId(x), x]));\n periodsMap.set('', { ranges: [{ start: schedule.division.start, end: schedule.division.end }] });\n\n // a map of period.id -> inWeeks\n const inWeeksMap = new Map<string, string>();\n periodsMap.forEach((period, id) => {\n const weeks = period.ranges\n .map(x => {\n // fetch all weeks between start and end\n const start = moment.utc(x.start);\n const end = moment.utc(x.end);\n const weeks = new Array<number>();\n while (start.isBefore(end)) {\n weeks.push(start.week());\n start.add(1, 'week');\n }\n return weeks;\n })\n .flat()\n .join(', ');\n\n inWeeksMap.set(id, weeks);\n });\n\n // a map of location.id -> location\n const locationsMap = new Map(schedule.locations.map(x => [getId(x), x]));\n\n // a map of group.id -> group\n const groupsMap = new Map(schedule.groups.map(x => [getId(x), x]));\n\n // a map of teacher.id -> teacher\n const teachersMap = new Map(schedule.teachers.map(x => [getId(x), x]));\n\n // a map of course.id -> course\n const coursesMap = new Map(schedule.courses.map(x => [getId(x), x]));\n\n const events = (options.includeEvents ?? true ? schedule.events : [])\n .map(x => {\n // ignore parked events\n if (x.parked) return;\n\n // must have a course\n const course = coursesMap.get(getId(x.course));\n if (!course) return;\n\n const start = moment.utc(x.start);\n const end = moment.utc(x.end);\n\n const periodId = getId(x.period ?? course.period ?? schedule.settings.period);\n const inWeeks = inWeeksMap.get(periodId);\n\n const locations = (x.inLocations ?? []).map(x => x ? locationsMap.get(getId(x )) : null).filter(x => !!x);\n const teachers = (x.teachers ?? course.teachers ?? []).map(x => teachersMap .get(getId(x.to)) ).filter(x => !!x);\n const groups = (x.groups ?? course.groups ?? []).map(x => groupsMap .get(getId(x.to)) ).filter(x => !!x);\n\n const out: OutEvent = {\n id: x._id?.toString(),\n externalid: x.ids?.toString(),\n groupid: course.ids,\n group: course.displayName,\n dayid: (start.day() + 6) % 7,\n startTime: start.format('HHmm'),\n length: end.diff(start, 'minutes'),\n subject: course.subject,\n inweek: inWeeks,\n roomid: locations.map(x => x.ids ).join(', '),\n room: locations.map(x => x.displayName).join(', '),\n teacherid: teachers .map(x => x.ids ).join(', '),\n teacher: teachers .map(x => x.displayName).join(', '),\n classid: groups .map(x => x.ids ).join(', '),\n class: groups .map(x => x.displayName).join(', ')\n };\n return out;\n })\n .filter(x => !!x);\n\n const complementaryTimes = (options.includeComplementaryTimes ?? true ? schedule.lockedTimes : [])\n .filter(x => x.type == 'COMPLEMENTARY_TIME')\n .map(x => {\n // ignore parked events\n if (x.parked) return;\n\n const start = moment.utc(x.start);\n const end = moment.utc(x.end);\n\n const teachers = (x.coalesced ?? [])\n .filter(x => x.toModel == 'teachers')\n .map(x => teachersMap.get(getId(x.to)))\n .filter(x => !!x);\n\n const out: OutEvent = {\n id: x._id?.toString(),\n dayid: (start.day() + 6) % 7,\n startTime: start.format('HHmm'),\n length: end.diff(start, 'minutes'),\n teacherid: teachers .map(x => x.ids ).join(', '),\n teacher: teachers .map(x => x.displayName).join(', '),\n };\n return out;\n })\n .filter(x => !!x);\n\n return toXlsx([...events, ...complementaryTimes]);\n};\n\nfunction toXlsx (events: OutEvent[]): XLSX.WorkBook {\n const wb = XLSX.utils.book_new();\n\n XLSX.utils.book_append_sheet(wb, XLSX.utils.json_to_sheet(events), 'royal schedule export');\n\n return wb;\n}"],"mappings":";;;;AAsCA,MAAM,SAAS,QAAuE;AACpF,KAAI,CAAC,IAAK,QAAO;AACjB,KAAI,OAAO,OAAO,SAAU,QAAO;AACnC,QAAO,IAAI,GAAI;;AAGjB,yBACE,UACA,UAAoB,OACF;CAGlB,MAAM,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OAAO;GACxB,QAAW,IAAI,KAAK,OAAO;GAC3B,WAAW,SAAU,KAAI,QAAKD,IAAE,KAAa,KAAK;GAClD,SAAW,SAAU,KAAI,QAAKA,IAAE,aAAa,KAAK;;AAEpD,SAAO;IAER,QAAO,MAAK,CAAC,CAAC;AAEjB,QAAO,OAAO,CAAC,GAAG,QAAQ,GAAG;;AAG/B,SAAS,OAAQ,QAAmC;CAClD,MAAM,KAAKE,OAAK,MAAM;AAEtB,QAAK,MAAM,kBAAkB,IAAIA,OAAK,MAAM,cAAc,SAAS;AAEnE,QAAO"}
|
|
@@ -6,6 +6,10 @@ import { ScheduleGroup } from "./schedule-groups.js";
|
|
|
6
6
|
import { Lesson } from "./lessons.js";
|
|
7
7
|
|
|
8
8
|
//#region src/Additio/types/schedules.d.ts
|
|
9
|
+
type Options = {
|
|
10
|
+
includeEvents?: boolean;
|
|
11
|
+
includeComplementaryTimes?: boolean;
|
|
12
|
+
};
|
|
9
13
|
type Schedule = {
|
|
10
14
|
start_date: Date;
|
|
11
15
|
end_date: Date;
|
|
@@ -23,5 +27,5 @@ type Schedule = {
|
|
|
23
27
|
lessons: Lesson[];
|
|
24
28
|
};
|
|
25
29
|
//#endregion
|
|
26
|
-
export { Schedule };
|
|
30
|
+
export { Options, Schedule };
|
|
27
31
|
//# sourceMappingURL=schedules.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Types } from "../../core/v2/types/index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as xlsx2 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[]) =>
|
|
6
|
+
static schedules: (courseEvents: Types.course[]) => xlsx2.WorkBook;
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
9
|
export { export_default };
|
|
@@ -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;AAG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C,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":";;;;;;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,QAA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O,UAAU,SAAS,KAAK;MAEjF,QAAO,MAAK,KAAK;KAErB,OAEA,QAAuC,KAAK,MAAM;GACjD,MAAM,MAAM,CAAC,EAAE,mBAAmB,uBAAuB,OAAO,WAAW,KAAK;AAChF,OAAI,IAAI,KAAM,KAAI,KAAK,KAAK;OACd,KAAI,OAAO,CAAC;AAC1B,UAAO;KACN;AAGL,SAAO,OAAO,QAAQ,SAAS,KAAK,CAAC,IAAI,aAAyB;GAAE;GAAI;;;AAG1E,QAAQ,CAAC,GAAG,SAAS,GAAG"}
|
package/dist/RS/v3/to/index.d.ts
CHANGED
|
@@ -15,36 +15,14 @@ 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 { export_default } from "./available-dependencies.js";
|
|
27
|
-
import { export_default as export_default$1 } from "./course-events/index.js";
|
|
28
|
-
import { export_default as export_default$2 } from "./dependencies.js";
|
|
19
|
+
import { OutOptions } from "../types/out-options.js";
|
|
29
20
|
import * as mongoose5 from "mongoose";
|
|
30
21
|
import * as lodash1 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?: {
|
|
@@ -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
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Types } from "../../../core/v2/types/index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as xlsx1 from "xlsx";
|
|
3
3
|
|
|
4
4
|
//#region src/SchoolSoft/file/to/index.d.ts
|
|
5
5
|
declare class export_default {
|
|
@@ -13,7 +13,7 @@ declare class export_default {
|
|
|
13
13
|
events: Types.event[];
|
|
14
14
|
periods: Types.period[];
|
|
15
15
|
persons: Types.person[];
|
|
16
|
-
}) =>
|
|
16
|
+
}) => xlsx1.WorkBook;
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
19
|
export { export_default };
|
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"}
|