@royalschedule/maps 4.0.16 → 4.0.17
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/Excel/v2/from/index.js +52 -39
- package/dist/Excel/v2/from/index.js.map +1 -1
- package/dist/RS/types/to.d.ts +3 -2
- package/dist/RS/types/to.js.map +1 -1
- package/dist/core/interfaces/vertices/vertex-query.d.ts +1 -1
- package/dist/core/interfaces/vertices/vertex-query.js +1 -1
- package/dist/core/interfaces/vertices/vertex-query.js.map +1 -1
- package/package.json +1 -1
|
@@ -23,15 +23,23 @@ function toPositiveInteger(val) {
|
|
|
23
23
|
if (num <= 0) throw new Error(`toInteger: te result ${num} is not positive`);
|
|
24
24
|
return num;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Converts a string/number to a trimmed string
|
|
28
|
+
*/
|
|
26
29
|
function toString(x) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
return isNumber(x) ? x.toString() : x.trim();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Converts a possible nullish string/number to a trimmed string or undefined
|
|
34
|
+
*/
|
|
35
|
+
function toStringIfExists(x) {
|
|
36
|
+
if (x == null) return void 0;
|
|
37
|
+
return toString(x);
|
|
31
38
|
}
|
|
32
39
|
function extractLocations(course, locationsNameMap, warnings) {
|
|
40
|
+
if (course.locations == null) return;
|
|
33
41
|
const locationsStr = toString(course.locations);
|
|
34
|
-
if (!locationsStr) return
|
|
42
|
+
if (!locationsStr) return;
|
|
35
43
|
const locationReferences = [];
|
|
36
44
|
locationsStr.split("+").flatMap((x, i) => x.split(",").map((x$1) => [i, x$1.trim()])).forEach(([i, x]) => {
|
|
37
45
|
const key = x.toLowerCase();
|
|
@@ -58,8 +66,9 @@ function extractLocations(course, locationsNameMap, warnings) {
|
|
|
58
66
|
return locationReferences;
|
|
59
67
|
}
|
|
60
68
|
function extractGroups(course, groupsNameMap, warnings) {
|
|
69
|
+
if (course.groups == null) return;
|
|
61
70
|
const groupsStr = toString(course.groups);
|
|
62
|
-
if (!groupsStr) return
|
|
71
|
+
if (!groupsStr) return;
|
|
63
72
|
const groupReferences = [];
|
|
64
73
|
groupsStr.split(",").map((x) => x.trim()).forEach((x) => {
|
|
65
74
|
const key = x.toLowerCase();
|
|
@@ -83,6 +92,7 @@ function extractGroups(course, groupsNameMap, warnings) {
|
|
|
83
92
|
return groupReferences;
|
|
84
93
|
}
|
|
85
94
|
function extractTeachers(course, teachersNameMap, warnings) {
|
|
95
|
+
if (course.teachers == null) return;
|
|
86
96
|
const teachersStr = toString(course.teachers);
|
|
87
97
|
if (!teachersStr) return void 0;
|
|
88
98
|
const teacherReferences = [];
|
|
@@ -108,6 +118,7 @@ function extractTeachers(course, teachersNameMap, warnings) {
|
|
|
108
118
|
return teacherReferences;
|
|
109
119
|
}
|
|
110
120
|
function extractSyllabus(course, syllabusesCodeMap, syllabusesNameMap, warnings) {
|
|
121
|
+
if (course.syllabus == null) return void 0;
|
|
111
122
|
const syllabusValue = toString(course.syllabus);
|
|
112
123
|
if (!syllabusValue) return void 0;
|
|
113
124
|
const syllabus = syllabusesCodeMap.get(syllabusValue) || syllabusesNameMap.get(syllabusValue.toLowerCase());
|
|
@@ -122,12 +133,12 @@ function extractSyllabus(course, syllabusesCodeMap, syllabusesNameMap, warnings)
|
|
|
122
133
|
}
|
|
123
134
|
function _schedules(source) {
|
|
124
135
|
const warnings = [];
|
|
125
|
-
source.settings = source.settings?.filter((x) => Object.values(x).some((y) =>
|
|
126
|
-
source.locations = source.locations?.filter((x) => Object.values(x).some((y) =>
|
|
127
|
-
source.teachers = source.teachers?.filter((x) => Object.values(x).some((y) =>
|
|
128
|
-
source.groups = source.groups?.filter((x) => Object.values(x).some((y) =>
|
|
129
|
-
source.persons = source.persons?.filter((x) => Object.values(x).some((y) =>
|
|
130
|
-
source.courses = source.courses?.filter((x) => Object.values(x).some((y) =>
|
|
136
|
+
source.settings = source.settings?.filter((x) => Object.values(x).some((y) => toString(y).length > 0));
|
|
137
|
+
source.locations = source.locations?.filter((x) => Object.values(x).some((y) => toString(y).length > 0));
|
|
138
|
+
source.teachers = source.teachers?.filter((x) => Object.values(x).some((y) => toString(y).length > 0));
|
|
139
|
+
source.groups = source.groups?.filter((x) => Object.values(x).some((y) => toString(y).length > 0));
|
|
140
|
+
source.persons = source.persons?.filter((x) => Object.values(x).some((y) => toString(y).length > 0));
|
|
141
|
+
source.courses = source.courses?.filter((x) => Object.values(x).some((y) => toString(y).length > 0));
|
|
131
142
|
const settings = {
|
|
132
143
|
discretization: 5,
|
|
133
144
|
numDays: 5,
|
|
@@ -158,13 +169,13 @@ function _schedules(source) {
|
|
|
158
169
|
const syllabusesCodeMap = /* @__PURE__ */ new Map();
|
|
159
170
|
if (!source.syllabuses) {}
|
|
160
171
|
source.syllabuses?.forEach((x) => {
|
|
161
|
-
const ids =
|
|
162
|
-
const subjectCode =
|
|
163
|
-
const subjectName =
|
|
164
|
-
const courseCode =
|
|
165
|
-
const courseName =
|
|
166
|
-
const schoolType =
|
|
167
|
-
const id = x.ID
|
|
172
|
+
const ids = toStringIfExists(x.foreign_ID);
|
|
173
|
+
const subjectCode = toStringIfExists(x.subject_code);
|
|
174
|
+
const subjectName = toStringIfExists(x.subject_name);
|
|
175
|
+
const courseCode = toStringIfExists(x.course_code);
|
|
176
|
+
const courseName = toStringIfExists(x.course_name);
|
|
177
|
+
const schoolType = toStringIfExists(x.school_type);
|
|
178
|
+
const id = toStringIfExists(x.ID) ?? generateId(syllabusesIdMap);
|
|
168
179
|
if (syllabusesIdMap.has(id)) {
|
|
169
180
|
warnings.push({
|
|
170
181
|
code: "ignoring_duplicate_syllabus",
|
|
@@ -226,9 +237,9 @@ function _schedules(source) {
|
|
|
226
237
|
}].forEach(({ name, data, idMap, nameMap }) => {
|
|
227
238
|
if (!data) warnings.push({ code: `missing_${name.plural}_sheet` });
|
|
228
239
|
data?.forEach((x) => {
|
|
229
|
-
const ids =
|
|
230
|
-
const displayName =
|
|
231
|
-
const id = x.ID
|
|
240
|
+
const ids = toStringIfExists(x.foreign_ID);
|
|
241
|
+
const displayName = toStringIfExists(x.name);
|
|
242
|
+
const id = toStringIfExists(x.ID) ?? generateId(idMap);
|
|
232
243
|
if (idMap.has(id)) {
|
|
233
244
|
warnings.push({
|
|
234
245
|
code: `ignoring_duplicate_${name.singular}`,
|
|
@@ -250,9 +261,9 @@ function _schedules(source) {
|
|
|
250
261
|
const groupsNameMap = /* @__PURE__ */ new Map();
|
|
251
262
|
if (!source.groups) warnings.push({ code: "missing_groups_sheet" });
|
|
252
263
|
source.groups?.forEach((x) => {
|
|
253
|
-
const ids =
|
|
254
|
-
const displayName =
|
|
255
|
-
const id = x.ID
|
|
264
|
+
const ids = toStringIfExists(x.foreign_ID);
|
|
265
|
+
const displayName = toStringIfExists(x.name);
|
|
266
|
+
const id = toStringIfExists(x.ID) ?? generateId(groupsIdMap);
|
|
256
267
|
if (groupsIdMap.has(id)) {
|
|
257
268
|
warnings.push({
|
|
258
269
|
code: "ignoring_duplicate_group",
|
|
@@ -260,7 +271,7 @@ function _schedules(source) {
|
|
|
260
271
|
});
|
|
261
272
|
return;
|
|
262
273
|
}
|
|
263
|
-
const species =
|
|
274
|
+
const species = toStringIfExists(x.is_class) == "1" ? "class" : void 0;
|
|
264
275
|
const y = {
|
|
265
276
|
id,
|
|
266
277
|
...ids && { ids },
|
|
@@ -275,11 +286,11 @@ function _schedules(source) {
|
|
|
275
286
|
const personsSsnMap = /* @__PURE__ */ new Map();
|
|
276
287
|
if (!source.persons) warnings.push({ code: "missing_persons_sheet" });
|
|
277
288
|
source.persons?.forEach((x) => {
|
|
278
|
-
const ids =
|
|
279
|
-
const firstName =
|
|
280
|
-
const lastName =
|
|
281
|
-
const SSN =
|
|
282
|
-
const id = x.ID
|
|
289
|
+
const ids = toStringIfExists(x.foreign_ID);
|
|
290
|
+
const firstName = toStringIfExists(x.first_name);
|
|
291
|
+
const lastName = toStringIfExists(x.last_name);
|
|
292
|
+
const SSN = toStringIfExists(x.SSN);
|
|
293
|
+
const id = toStringIfExists(x.ID) ?? generateId(personsIdMap);
|
|
283
294
|
if (personsIdMap.has(id)) {
|
|
284
295
|
warnings.push({
|
|
285
296
|
code: "ignoring_duplicate_person",
|
|
@@ -323,7 +334,9 @@ function _schedules(source) {
|
|
|
323
334
|
});
|
|
324
335
|
groupsNameMap.forEach((x) => {
|
|
325
336
|
let duplicateReported = false;
|
|
326
|
-
|
|
337
|
+
if (!x.__raw.members) return;
|
|
338
|
+
x.members = makeChainable(x.__raw.members).chain((x$1) => toString(x$1).split(",").map((x$2) => x$2.trim()).filter((x$2) => x$2 != null)).chain((x$1) => countBy(x$1)).chain((y) => Object.entries(y).map(([ssn, count]) => {
|
|
339
|
+
if (!ssn) return;
|
|
327
340
|
if (!duplicateReported && count > 1) {
|
|
328
341
|
warnings.push({
|
|
329
342
|
code: "duplicate_group_member",
|
|
@@ -357,11 +370,11 @@ function _schedules(source) {
|
|
|
357
370
|
const overlapGroupsKeyMap = /* @__PURE__ */ new Map();
|
|
358
371
|
if (!source.courses) warnings.push({ code: "missing_courses_sheet" });
|
|
359
372
|
source.courses?.forEach((x) => {
|
|
360
|
-
if (
|
|
361
|
-
const ids =
|
|
362
|
-
const displayName =
|
|
363
|
-
const subject =
|
|
364
|
-
const courseId = x.ID
|
|
373
|
+
if (toStringIfExists(x.merge_with)) return;
|
|
374
|
+
const ids = toStringIfExists(x.foreign_ID);
|
|
375
|
+
const displayName = toStringIfExists(x.name);
|
|
376
|
+
const subject = toStringIfExists(x.subject);
|
|
377
|
+
const courseId = toStringIfExists(x.ID) ?? generateId(coursesIdMap);
|
|
365
378
|
if (coursesIdMap.has(courseId)) {
|
|
366
379
|
warnings.push({
|
|
367
380
|
code: "ignoring_duplicate_course",
|
|
@@ -454,7 +467,7 @@ function _schedules(source) {
|
|
|
454
467
|
coursesIdMap.set(courseId, course);
|
|
455
468
|
});
|
|
456
469
|
source.courses?.forEach((x) => {
|
|
457
|
-
const mergeWith =
|
|
470
|
+
const mergeWith = toStringIfExists(x.merge_with);
|
|
458
471
|
if (!mergeWith) return;
|
|
459
472
|
if (!coursesIdMap.has(mergeWith)) {
|
|
460
473
|
warnings.push({
|
|
@@ -463,7 +476,7 @@ function _schedules(source) {
|
|
|
463
476
|
});
|
|
464
477
|
return;
|
|
465
478
|
}
|
|
466
|
-
const displayName =
|
|
479
|
+
const displayName = toStringIfExists(x.name);
|
|
467
480
|
const locations = extractLocations(x, locationsNameMap, warnings)?.map((x$1) => ({
|
|
468
481
|
groupIndex: x$1.groupIndex,
|
|
469
482
|
locations: [x$1.to]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["id: string","map","locationReferences: { groupIndex: number; to: string }[]","x","groupReferences: { to: string }[]","teacherReferences: { to: string }[]","warnings: { code: Types.ErrorCode, context?: unknown }[]","settings: C_Settings","y: C_Syllabus","group: string | undefined","sex: C_Person['sex']","person: C_Person","expectedTotalHours: number | undefined","minutesPerWeek: number | undefined","event: C_Event","course: C_Course"],"sources":["../../../../src/Excel/v2/from/index.ts"],"sourcesContent":["import { isString, isNumber, countBy } from 'lodash-es';\nimport { nanoid } from 'nanoid';\nimport type { CoreTypes } from '../../../core';\nimport type { Types } from '../types';\nimport type { FromInterface } from '../../../common/types';\nimport { makeChainable } from '../../../common/make-chainable';\n\ntype C_Settings = Pick<CoreTypes.Serialized.Settings, 'discretization' | 'numDays' | 'dayStart' | 'dayEnd'>;\ntype C_Location = Omit<CoreTypes.Serialized.Location, '_id'> & { __raw: Types.Location };\ntype C_Group = Omit<CoreTypes.Serialized.Group, '_id'> & { __raw: Types.Group };\ntype C_Teacher = Omit<CoreTypes.Serialized.Teacher, '_id'> & { __raw: Types.Teacher };\ntype C_Course = Omit<CoreTypes.Serialized.Course, '_id'> & { __raw: Types.Course };\ntype C_Person = Omit<CoreTypes.Serialized.Person, '_id'> & { __raw: Types.Person };\ntype C_Event = Omit<CoreTypes.Serialized.Event, '_id'> & { __raw?: Types.Course };\ntype C_OverlapGroup = Omit<CoreTypes.Serialized.OverlapGroup, '_id'> & { /* raw: Types.OverlapGroup */ };\ntype C_Syllabus = Omit<CoreTypes.Serialized.Syllabus, '_id'> & { __raw?: Types.Syllabus };\n\ntype Out = {\n settings: C_Settings;\n locations: C_Location[];\n teachers: C_Teacher[];\n persons: C_Person[];\n groups: C_Group[];\n courses: C_Course[];\n events: C_Event[];\n overlapGroups: C_OverlapGroup[];\n syllabuses: C_Syllabus[];\n meta: {\n // errors?: string[];\n warnings?: { code: Types.ErrorCode, context?: unknown }[];\n };\n};\n\n\nfunction generateId (map: Map<string, unknown>) {\n // generate a unique id\n let id: string;\n do {\n id = nanoid(8);\n } while (map.has(id));\n\n return id;\n}\n\nfunction toPositiveMultipleOf5 (val: number | string) {\n const num = isString(val) ? parseInt(val) : val;\n\n // throw error if nan\n if (isNaN(num)) throw new Error(`toMultipleOf5: ${val} is not a number`);\n\n const res = Math.floor(num / 5) * 5;\n\n if (res <= 0) throw new Error(`toMultipleOf5: the result ${res} is not positive`);\n\n return res;\n}\n\nfunction toPositiveInteger (val: number | string) {\n const num = isString(val) ? parseInt(val) : val;\n\n // throw error if nan\n if (isNaN(num)) throw new Error(`toInteger: ${val} is not a number`);\n if (num <= 0) throw new Error(`toInteger: te result ${num} is not positive`);\n\n return num;\n}\n\nfunction toString<T extends string | number | undefined, R = T extends undefined ? (string | undefined) : string> (x: T): R {\n if (x == undefined ) return undefined as R;\n if (typeof x == 'string' && !x.length) return undefined as R;\n if (isNumber(x) ) return x.toString() as R;\n return x.trim() as R;\n}\n\nfunction extractLocations (\n course: Types.Course,\n locationsNameMap: Map<string, C_Location>,\n warnings: { code: Types.ErrorCode, context?: unknown }[],\n) {\n const locationsStr = toString(course.locations);\n if (!locationsStr) return undefined;\n\n const locationReferences: { groupIndex: number; to: string }[] = [];\n\n locationsStr.split('+')\n .flatMap((x, i) => x.split(',').map(x => [i, x.trim()] as [number, string]))\n .forEach(([i, x]) => {\n const key = x.toLowerCase();\n const ref = locationsNameMap.get(key);\n if (!ref) {\n warnings.push({ code: 'invalid_location_reference', context: x });\n return;\n }\n\n if (locationReferences.some(y => y.to == ref.id)) {\n warnings.push({ code: 'location_referenced_multiple_times', context: x });\n return;\n }\n\n locationReferences.push({ groupIndex: i, to: ref.id });\n });\n\n return locationReferences;\n}\n\nfunction extractGroups (\n course: Types.Course,\n groupsNameMap: Map<string, C_Group>,\n warnings: { code: Types.ErrorCode, context?: unknown }[],\n) {\n const groupsStr = toString(course.groups);\n if (!groupsStr) return undefined;\n\n const groupReferences: { to: string }[] = [];\n groupsStr.split(',').map(x => x.trim())\n .forEach(x => {\n const key = x.toLowerCase();\n const ref = groupsNameMap.get(key);\n if (!ref) {\n warnings.push({ code: 'invalid_group_reference', context: x });\n return;\n }\n\n if (groupReferences.some(y => y.to == ref.id)) {\n warnings.push({ code: 'group_referenced_multiple_times', context: x });\n return;\n }\n\n groupReferences.push({ to: ref.id });\n });\n\n return groupReferences;\n}\n\nfunction extractTeachers (\n course: Types.Course,\n teachersNameMap: Map<string, C_Teacher>,\n warnings: { code: Types.ErrorCode, context?: unknown }[],\n) {\n const teachersStr = toString(course.teachers);\n if (!teachersStr) return undefined;\n\n const teacherReferences: { to: string }[] = [];\n teachersStr.split(',').map(x => x.trim())\n .forEach(x => {\n const key = x.toLowerCase();\n const ref = teachersNameMap.get(key);\n if (!ref) {\n warnings.push({ code: 'invalid_teacher_reference', context: x });\n return;\n }\n\n if (teacherReferences.some(y => y.to == ref.id)) {\n warnings.push({ code: 'teacher_referenced_multiple_times', context: x });\n return;\n }\n\n teacherReferences.push({ to: ref.id });\n });\n\n return teacherReferences;\n}\n\nfunction extractSyllabus (\n course: Types.Course,\n syllabusesCodeMap: Map<string, C_Syllabus>,\n syllabusesNameMap: Map<string, C_Syllabus>,\n warnings: { code: Types.ErrorCode, context?: unknown }[],\n): string | undefined {\n const syllabusValue = toString(course.syllabus);\n if (!syllabusValue) return undefined;\n\n const syllabus = syllabusesCodeMap.get(syllabusValue) || syllabusesNameMap.get(syllabusValue.toLowerCase());\n\n if (!syllabus) {\n warnings.push({ code: 'invalid_syllabus_reference', context: syllabusValue });\n return undefined;\n }\n\n return syllabus.id;\n}\n\n\nfunction _schedules (\n source: Types.Source\n): Out {\n // gather all import related warnings/errors\n const warnings: { code: Types.ErrorCode, context?: unknown }[] = [];\n // let errors: string[] = [];\n\n source.settings = source.settings ?.filter(x => Object.values(x).some(y => y.toString().trim().length > 0));\n source.locations = source.locations?.filter(x => Object.values(x).some(y => y.toString().trim().length > 0));\n source.teachers = source.teachers ?.filter(x => Object.values(x).some(y => y.toString().trim().length > 0));\n source.groups = source.groups ?.filter(x => Object.values(x).some(y => y.toString().trim().length > 0));\n source.persons = source.persons ?.filter(x => Object.values(x).some(y => y.toString().trim().length > 0));\n source.courses = source.courses ?.filter(x => Object.values(x).some(y => y.toString().trim().length > 0));\n\n\n ////\n //// settings\n ////\n const settings: C_Settings = {\n discretization: 5,\n numDays: 5,\n dayStart: '08:00',\n dayEnd: '17:00',\n };\n if (!source.settings) {\n warnings.push({ code: 'missing_settings_sheet' });\n }\n if (source.settings?.[0]?.number_of_days) {\n const numDays = source.settings?.[0]?.number_of_days;\n try {\n settings.numDays = toPositiveInteger(numDays);\n\n // must be 5 or 7\n if (settings.numDays !== 5 && settings.numDays !== 7) {\n warnings.push({ code: 'invalid_number_of_days', context: numDays });\n settings.numDays = 5;\n }\n } catch {\n warnings.push({ code: 'invalid_number_of_days', context: numDays });\n }\n }\n\n ////\n //// syllabuses\n ////\n const syllabusesIdMap = new Map<string, C_Syllabus>();\n const syllabusesNameMap = new Map<string, C_Syllabus>();\n const syllabusesCodeMap = new Map<string, C_Syllabus>();\n if (!source.syllabuses) {\n // warnings.push({ code: 'missing_syllabus_sheet' });\n }\n source.syllabuses?.forEach(x => {\n const ids = toString(x.foreign_ID);\n const subjectCode = toString(x.subject_code);\n const subjectName = toString(x.subject_name);\n const courseCode = toString(x.course_code );\n const courseName = toString(x.course_name );\n const schoolType = toString(x.school_type);\n\n const id = x.ID?.toString() ?? generateId(syllabusesIdMap);\n if (syllabusesIdMap.has(id)) {\n warnings.push({ code: 'ignoring_duplicate_syllabus', context: `${subjectName} (${courseName})` });\n return;\n }\n\n if (!subjectName) {\n warnings.push({ code: 'missing_subject_name', context: x });\n return;\n }\n\n if (!schoolType) {\n warnings.push({ code: 'missing_school_type', context: x });\n return;\n }\n\n // create the syllabus object\n const y: C_Syllabus = {\n id,\n ...ids && { ids },\n ...subjectCode && { subjectCode },\n subjectName,\n ...courseCode && { courseCode },\n ...courseName && { courseName },\n schoolType,\n official: true, // always true for imported syllabuses\n __raw: x\n };\n syllabusesIdMap.set(id, y);\n const code = courseCode || subjectCode;\n const name = courseName || subjectName;\n if (code) syllabusesCodeMap.set(code, y);\n if (name) syllabusesNameMap.set(name.toLowerCase(), y);\n });\n\n\n ////\n //// locations, teachers\n ////\n const locationsIdMap = new Map<string, C_Location>();\n const locationsNameMap = new Map<string, C_Location>();\n const teachersIdMap = new Map<string, C_Teacher>();\n const teachersNameMap = new Map<string, C_Teacher>();\n [\n {\n name: { singular: 'location', plural: 'locations' } as const,\n data: source.locations,\n idMap: locationsIdMap,\n nameMap: locationsNameMap,\n },\n {\n name: { singular: 'teacher', plural: 'teachers' } as const,\n data: source.teachers,\n idMap: teachersIdMap,\n nameMap: teachersNameMap,\n }\n ].forEach(({ name, data, idMap, nameMap }) => {\n if (!data) {\n warnings.push({ code: `missing_${name.plural}_sheet` });\n }\n data?.forEach(x => {\n const ids = toString(x.foreign_ID);\n const displayName = toString(x.name);\n\n const id = x.ID?.toString() ?? generateId(idMap);\n if (idMap.has(id)) {\n warnings.push({ code: `ignoring_duplicate_${name.singular}`, context: displayName });\n return;\n }\n\n const y = {\n id,\n ...ids && { ids },\n ...displayName && { displayName },\n __raw: x\n };\n idMap.set(id, y);\n if (displayName) nameMap.set(displayName.toLowerCase(), y);\n });\n });\n\n\n ////\n //// groups\n ////\n const groupsIdMap = new Map<string, C_Group>();\n const groupsNameMap = new Map<string, C_Group>();\n if (!source.groups) {\n warnings.push({ code: 'missing_groups_sheet' });\n }\n source.groups?.forEach(x => {\n const ids = toString(x.foreign_ID);\n const displayName = toString(x.name);\n\n const id = x.ID?.toString() ?? generateId(groupsIdMap);\n if (groupsIdMap.has(id)) {\n warnings.push({ code: 'ignoring_duplicate_group', context: displayName });\n return;\n }\n\n // parent groups determine the species of the group\n const species = toString(x.is_class) == '1' ? 'class' as const : undefined;\n\n const y = {\n id,\n ...ids && { ids },\n ...displayName && { displayName },\n ...species && { species },\n __raw: x\n } as C_Group;\n groupsIdMap.set(id, y);\n if (displayName) groupsNameMap.set(displayName.toLowerCase(), y);\n });\n\n\n ////\n //// persons\n ////\n const personsIdMap = new Map<string, C_Person>();\n const personsSsnMap = new Map<string, C_Person>();\n if (!source.persons) {\n warnings.push({ code: 'missing_persons_sheet' });\n }\n source.persons?.forEach(x => {\n const ids = toString(x.foreign_ID);\n const firstName = toString(x.first_name);\n const lastName = toString(x.last_name );\n const SSN = toString(x.SSN );\n\n const id = x.ID?.toString() ?? generateId(personsIdMap);\n if (personsIdMap.has(id)) {\n warnings.push({ code: 'ignoring_duplicate_person', context: `${firstName} ${lastName}` });\n return;\n }\n\n let group: string | undefined = undefined;\n if (x.group) {\n const key = toString(x.group).toLowerCase();\n const ref = groupsNameMap.get(key);\n if (!ref) {\n warnings.push({ code: 'invalid_group_reference', context: x.group });\n } else if (ref.species !== 'class') {\n warnings.push({ code: 'forbidden_group_reference', context: x.group });\n } else {\n group = ref.id;\n }\n }\n\n let sex: C_Person['sex'];\n if (x.sex) {\n if (isString(x.sex) && x.sex.toLowerCase() == 'man') sex = 'Man';\n else if (isString(x.sex) && x.sex.toLowerCase() == 'woman') sex = 'Woman';\n else {\n warnings.push({ code: 'invalid_sex', context: x.sex });\n }\n }\n\n const person: C_Person = {\n id,\n ...ids && { ids },\n ...firstName && { firstName },\n ...lastName && { lastName },\n ...sex && { sex },\n ...group && { group },\n ...SSN && { SSN: { value: SSN } },\n __raw: x\n };\n personsIdMap.set(id, person);\n if (SSN) personsSsnMap.set(SSN, person);\n });\n\n\n ////\n //// group.members (need to wait for persons to be parsed)\n ////\n groupsNameMap.forEach(x => {\n let duplicateReported = false;\n\n // parse and replace SSN by person id\n x.members = makeChainable(x.__raw.members)\n .chain(x => toString(x ?? '')\n .split(',')\n .map(x => x.trim())\n .filter(x => x != null)\n )\n .chain(x => countBy(x))\n .chain(y => Object.entries(y)\n .map(([ssn, count]) => {\n // warn if duplicate member\n if (!duplicateReported && count > 1) {\n warnings.push({ code: 'duplicate_group_member', context: x.displayName });\n duplicateReported = true;\n }\n\n // fetch person and warn if not found\n const person = personsSsnMap.get(ssn);\n if (!person) {\n warnings.push({ code: 'invalid_person_reference', context: ssn });\n return;\n }\n\n // warn if the group is a class and the person is already in a different class\n // (we also need to set the group of the person if it is empty)\n if (x.species == 'class') {\n if (!person.group) {\n person.group = x.id;\n }\n else if (person.group != x.id) {\n warnings.push({ code: 'person_in_multiple_classes', context: ssn });\n return;\n }\n }\n\n return person.id;\n })\n .filter(x => x != null)\n )\n .value;\n });\n\n\n ////\n //// courses\n ////\n const coursesIdMap = new Map<string, C_Course >();\n const eventsIdMap = new Map<string, C_Event >();\n const overlapGroupsKeyMap = new Map<string, C_OverlapGroup>();\n if (!source.courses) {\n warnings.push({ code: 'missing_courses_sheet' });\n }\n source.courses?.forEach(x => {\n // await loading events until courses are created\n const mergeWith = toString(x.merge_with);\n if (mergeWith) return;\n\n const ids = toString(x.foreign_ID);\n const displayName = toString(x.name)?.trim();\n const subject = toString(x.subject);\n\n const courseId = x.ID?.toString() ?? generateId(coursesIdMap);\n if (coursesIdMap.has(courseId)) {\n warnings.push({ code: 'ignoring_duplicate_course', context: displayName + (subject ? ` (${subject})` : '') });\n return;\n }\n\n // try to parse the total hours as an integer\n let expectedTotalHours: number | undefined = undefined;\n if (x.total_hours) {\n try {\n expectedTotalHours = toPositiveInteger(x.total_hours);\n } catch {\n warnings.push({ code: 'invalid_total_hours', context: x.total_hours });\n }\n }\n\n // try to parse the minutes per week as an multiple of 5\n let minutesPerWeek: number | undefined = undefined;\n if (x.minutes_per_week) {\n try {\n minutesPerWeek = toPositiveMultipleOf5(x.minutes_per_week);\n } catch {\n warnings.push({ code: 'invalid_minutes_per_week', context: x.minutes_per_week });\n }\n }\n\n // only one of minutes_per_week or total_hours should be defined\n if (minutesPerWeek != null && expectedTotalHours != null) {\n warnings.push({ code: 'ambiguous_planned_duration', context: `${minutesPerWeek} min/week OR ${expectedTotalHours} hrs` });\n }\n const plannedDuration =\n expectedTotalHours\n ? `${expectedTotalHours} hrs` :\n minutesPerWeek\n ? `${minutesPerWeek} min/week` :\n undefined;\n\n\n // try to parse the lesson durations as an array of integers from which we will generate events\n if (x.lesson_durations) {\n const _durations = typeof x.lesson_durations === 'string'\n ? x.lesson_durations.split(',').map(x => x.trim())\n : [x.lesson_durations];\n\n // truncate to multiple of 5 and filter out zero duration events\n const durations = _durations\n .map(e => {\n try {\n return toPositiveMultipleOf5(e);\n } catch {\n warnings.push({ code: 'invalid_lesson_durations', context: x.lesson_durations });\n return undefined;\n }\n })\n .filter((x): x is number => x !== undefined);\n\n durations.forEach(x => {\n const id = generateId(eventsIdMap);\n const event: C_Event = { id, course: courseId, preferredDuration: x };\n eventsIdMap.set(id, event);\n });\n }\n\n // overlap group\n if (x.overlap_group && toString(x.overlap_group)) {\n const key = toString(x.overlap_group).toLowerCase();\n\n const og = overlapGroupsKeyMap.get(key);\n if (og) og.coalesced?.push({ toModel: 'courses', to: courseId });\n else {\n const id = generateId(overlapGroupsKeyMap);\n const coalesced = [{ toModel: 'courses' as const, to: courseId }];\n overlapGroupsKeyMap.set(key, { id, coalesced });\n }\n }\n\n const locations = extractLocations(x, locationsNameMap, warnings)?.map(x => ({ groupIndex: x.groupIndex, locations: [x.to] as [string] }));\n const groups = extractGroups (x, groupsNameMap, warnings);\n const teachers = extractTeachers (x, teachersNameMap, warnings);\n const syllabus = extractSyllabus(x, syllabusesCodeMap, syllabusesNameMap, warnings);\n\n const course: C_Course = {\n id: courseId,\n ...ids && { ids },\n ...displayName && { displayName },\n ...subject && { subject },\n /* TO BE DEPRECATED */ ...expectedTotalHours && { expectedTotalHours },\n /* TO BE DEPRECATED */ ...minutesPerWeek && { minutesPerWeek },\n ...plannedDuration && { plannedDuration },\n ...groups && { groups },\n ...teachers && { teachers },\n ...locations && { locations },\n ...syllabus && { syllabus },\n __raw: x\n };\n coursesIdMap.set(courseId, course);\n });\n\n\n ////\n //// events\n ////\n source.courses?.forEach(x => {\n // load courses\n const mergeWith = toString(x.merge_with);\n if (!mergeWith) return;\n\n // ensure that the course to merge with exists\n if (!coursesIdMap.has(mergeWith)) {\n warnings.push({ code: 'invalid_course_reference', context: mergeWith });\n return;\n }\n\n const displayName = toString(x.name)?.trim();\n const locations = extractLocations(x, locationsNameMap, warnings)?.map(x => ({ groupIndex: x.groupIndex, locations: [x.to] as [string] }));\n const groups = extractGroups (x, groupsNameMap, warnings);\n const teachers = extractTeachers (x, teachersNameMap, warnings);\n\n // try to parse the lesson durations as an array of integers from which we will generate events\n if (x.lesson_durations) {\n const _durations = typeof x.lesson_durations === 'string'\n ? x.lesson_durations.split(',').map(x => x.trim())\n : [x.lesson_durations];\n\n // truncate to multiple of 5 and filter out zero duration events\n const durations = _durations\n .map(e => {\n try {\n return toPositiveMultipleOf5(e);\n } catch {\n warnings.push({ code: 'invalid_lesson_durations', context: x.lesson_durations });\n return undefined;\n }\n })\n .filter((x): x is number => x !== undefined);\n\n durations.forEach(preferredDuration => {\n const id = generateId(eventsIdMap);\n const event: C_Event = {\n id,\n course: mergeWith,\n preferredDuration: preferredDuration,\n ...displayName && { displayName },\n ...groups && { groups },\n ...teachers && { teachers },\n ...locations && { locations },\n __raw: x\n };\n eventsIdMap.set(id, event);\n });\n }\n });\n\n\n ////\n //// return\n ////\n return {\n settings,\n locations: [...locationsIdMap .values()],\n teachers: [...teachersIdMap .values()],\n persons: [...personsIdMap .values()],\n groups: [...groupsIdMap .values()],\n courses: [...coursesIdMap .values()],\n events: [...eventsIdMap .values()],\n overlapGroups: [...overlapGroupsKeyMap.values()],\n syllabuses: [...syllabusesIdMap .values()],\n meta: {\n // ...errors .length && { errors: errors },\n ...warnings.length && { warnings: warnings }\n }\n };\n}\n\n\nexport default {\n schedules: _schedules\n} satisfies FromInterface;"],"mappings":";;;;;AAkCA,SAAS,WAAY,OAA2B;CAE9C,IAAIA;AACJ;AACE,OAAK,OAAO,EAAE;QACPC,MAAI,IAAI,GAAG;AAEpB,QAAO;;AAGT,SAAS,sBAAuB,KAAsB;CACpD,MAAM,MAAM,SAAS,IAAI,GAAG,SAAS,IAAI,GAAG;AAG5C,KAAI,MAAM,IAAI,CAAE,OAAM,IAAI,MAAM,kBAAkB,IAAI,kBAAkB;CAExE,MAAM,MAAM,KAAK,MAAM,MAAM,EAAE,GAAG;AAElC,KAAI,OAAO,EAAG,OAAM,IAAI,MAAM,6BAA6B,IAAI,kBAAkB;AAEjF,QAAO;;AAGT,SAAS,kBAAmB,KAAsB;CAChD,MAAM,MAAM,SAAS,IAAI,GAAG,SAAS,IAAI,GAAG;AAG5C,KAAI,MAAM,IAAI,CAAE,OAAM,IAAI,MAAM,cAAc,IAAI,kBAAkB;AACpE,KAAI,OAAO,EAAG,OAAM,IAAI,MAAM,wBAAwB,IAAI,kBAAkB;AAE5E,QAAO;;AAGT,SAAS,SAA0G,GAAS;AAC1H,KAAI,KAAK,OAA8B,QAAO;AAC9C,KAAI,OAAO,KAAK,YAAY,CAAC,EAAE,OAAQ,QAAO;AAC9C,KAAI,SAAS,EAAE,CAAwB,QAAO,EAAE,UAAU;AAC1D,QAAO,EAAE,MAAM;;AAGjB,SAAS,iBACP,QACA,kBACA,UACA;CACA,MAAM,eAAe,SAAS,OAAO,UAAU;AAC/C,KAAI,CAAC,aAAc,QAAO;CAE1B,MAAMC,qB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AG,eAAkB,SAAS;EACnE,MAAM,WAAc,gBAAiB,GAAG,iBAAkB,SAAS;AAGnE,MAAI,EAAE,iBAiBJ,EAhBmB,OAAO,EAAE,qBAAqB,WAC7C,EAAE,iBAAiB,MAAM,IAAI,CAAC,KAAI,QAAKA,IAAE,MAAM,CAAC,GAChD,CAAC,EAAE,iBAAiB,EAIrB,KAAI,MAAK;AACR,OAAI;AACF,WAAO,sBAAsB,EAAE;WACzB;AACN,aAAS,KAAK;KAAE,MAAM;KAA4B,SAAS,EAAE;KAAkB,CAAC;AAChF;;IAEF,CACD,QAAQ,QAAmBA,QAAM,OAAU,CAEpC,SAAQ,sBAAqB;GACrC,MAAM,KAAK,WAAW,YAAY;GAClC,MAAMW,QAAiB;IACrB;IACA,QAAmB;IACA;IACnB,GAAG,eAAgB,EAAE,aAAa;IAClC,GAAG,UAAgB,EAAE,QAAa;IAClC,GAAG,YAAgB,EAAE,UAAa;IAClC,GAAG,aAAgB,EAAE,WAAa;IAClC,OAAmB;IACpB;AACD,eAAY,IAAI,IAAI,MAAM;IAC1B;GAEJ;AAMF,QAAO;EACL;EACA,WAAe,CAAC,GAAG,eAAoB,QAAQ,CAAC;EAChD,UAAe,CAAC,GAAG,cAAoB,QAAQ,CAAC;EAChD,SAAe,CAAC,GAAG,aAAoB,QAAQ,CAAC;EAChD,QAAe,CAAC,GAAG,YAAoB,QAAQ,CAAC;EAChD,SAAe,CAAC,GAAG,aAAoB,QAAQ,CAAC;EAChD,QAAe,CAAC,GAAG,YAAoB,QAAQ,CAAC;EAChD,eAAe,CAAC,GAAG,oBAAoB,QAAQ,CAAC;EAChD,YAAe,CAAC,GAAG,gBAAoB,QAAQ,CAAC;EAChD,MAAe,EAEb,GAAG,SAAS,UAAU,EAAY,UAAU,EAC7C;EACF;;AAIH,mBAAe,EACb,WAAW,YACZ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["id: string","map","locationReferences: { groupIndex: number; to: string }[]","x","groupReferences: { to: string }[]","teacherReferences: { to: string }[]","warnings: { code: Types.ErrorCode, context?: unknown }[]","settings: C_Settings","y: C_Syllabus","group: string | undefined","sex: C_Person['sex']","person: C_Person","expectedTotalHours: number | undefined","minutesPerWeek: number | undefined","event: C_Event","course: C_Course"],"sources":["../../../../src/Excel/v2/from/index.ts"],"sourcesContent":["import { isString, isNumber, countBy } from 'lodash-es';\nimport { nanoid } from 'nanoid';\nimport type { CoreTypes } from '../../../core';\nimport type { Types } from '../types';\nimport type { FromInterface } from '../../../common/types';\nimport { makeChainable } from '../../../common/make-chainable';\n\ntype C_Settings = Pick<CoreTypes.Serialized.Settings, 'discretization' | 'numDays' | 'dayStart' | 'dayEnd'>;\ntype C_Location = Omit<CoreTypes.Serialized.Location, '_id'> & { __raw: Types.Location };\ntype C_Group = Omit<CoreTypes.Serialized.Group, '_id'> & { __raw: Types.Group };\ntype C_Teacher = Omit<CoreTypes.Serialized.Teacher, '_id'> & { __raw: Types.Teacher };\ntype C_Course = Omit<CoreTypes.Serialized.Course, '_id'> & { __raw: Types.Course };\ntype C_Person = Omit<CoreTypes.Serialized.Person, '_id'> & { __raw: Types.Person };\ntype C_Event = Omit<CoreTypes.Serialized.Event, '_id'> & { __raw?: Types.Course };\ntype C_OverlapGroup = Omit<CoreTypes.Serialized.OverlapGroup, '_id'> & { /* raw: Types.OverlapGroup */ };\ntype C_Syllabus = Omit<CoreTypes.Serialized.Syllabus, '_id'> & { __raw?: Types.Syllabus };\n\ntype Out = {\n settings: C_Settings;\n locations: C_Location[];\n teachers: C_Teacher[];\n persons: C_Person[];\n groups: C_Group[];\n courses: C_Course[];\n events: C_Event[];\n overlapGroups: C_OverlapGroup[];\n syllabuses: C_Syllabus[];\n meta: {\n // errors?: string[];\n warnings?: { code: Types.ErrorCode, context?: unknown }[];\n };\n};\n\n\nfunction generateId (map: Map<string, unknown>) {\n // generate a unique id\n let id: string;\n do {\n id = nanoid(8);\n } while (map.has(id));\n\n return id;\n}\n\nfunction toPositiveMultipleOf5 (val: number | string) {\n const num = isString(val) ? parseInt(val) : val;\n\n // throw error if nan\n if (isNaN(num)) throw new Error(`toMultipleOf5: ${val} is not a number`);\n\n const res = Math.floor(num / 5) * 5;\n\n if (res <= 0) throw new Error(`toMultipleOf5: the result ${res} is not positive`);\n\n return res;\n}\n\nfunction toPositiveInteger (val: number | string) {\n const num = isString(val) ? parseInt(val) : val;\n\n // throw error if nan\n if (isNaN(num)) throw new Error(`toInteger: ${val} is not a number`);\n if (num <= 0) throw new Error(`toInteger: te result ${num} is not positive`);\n\n return num;\n}\n\n/**\n * Converts a string/number to a trimmed string\n */\nfunction toString (x: string | number): string {\n return isNumber(x)\n ? x.toString()\n : x.trim();\n}\n\n/**\n * Converts a possible nullish string/number to a trimmed string or undefined\n */\nfunction toStringIfExists (x: string | number | undefined | null): string | undefined {\n if (x == null) return undefined;\n return toString(x);\n}\n\nfunction extractLocations (\n course: Types.Course,\n locationsNameMap: Map<string, C_Location>,\n warnings: { code: Types.ErrorCode, context?: unknown }[],\n) {\n if (course.locations == null) return;\n const locationsStr = toString(course.locations);\n if (!locationsStr) return;\n\n const locationReferences: { groupIndex: number; to: string }[] = [];\n\n locationsStr.split('+')\n .flatMap((x, i) => x.split(',').map(x => [i, x.trim()] as [number, string]))\n .forEach(([i, x]) => {\n const key = x.toLowerCase();\n const ref = locationsNameMap.get(key);\n if (!ref) {\n warnings.push({ code: 'invalid_location_reference', context: x });\n return;\n }\n\n if (locationReferences.some(y => y.to == ref.id)) {\n warnings.push({ code: 'location_referenced_multiple_times', context: x });\n return;\n }\n\n locationReferences.push({ groupIndex: i, to: ref.id });\n });\n\n return locationReferences;\n}\n\nfunction extractGroups (\n course: Types.Course,\n groupsNameMap: Map<string, C_Group>,\n warnings: { code: Types.ErrorCode, context?: unknown }[],\n) {\n if (course.groups == null) return;\n const groupsStr = toString(course.groups);\n if (!groupsStr) return;\n\n const groupReferences: { to: string }[] = [];\n groupsStr.split(',').map(x => x.trim())\n .forEach(x => {\n const key = x.toLowerCase();\n const ref = groupsNameMap.get(key);\n if (!ref) {\n warnings.push({ code: 'invalid_group_reference', context: x });\n return;\n }\n\n if (groupReferences.some(y => y.to == ref.id)) {\n warnings.push({ code: 'group_referenced_multiple_times', context: x });\n return;\n }\n\n groupReferences.push({ to: ref.id });\n });\n\n return groupReferences;\n}\n\nfunction extractTeachers (\n course: Types.Course,\n teachersNameMap: Map<string, C_Teacher>,\n warnings: { code: Types.ErrorCode, context?: unknown }[],\n) {\n if (course.teachers == null) return;\n const teachersStr = toString(course.teachers);\n if (!teachersStr) return undefined;\n\n const teacherReferences: { to: string }[] = [];\n teachersStr.split(',').map(x => x.trim())\n .forEach(x => {\n const key = x.toLowerCase();\n const ref = teachersNameMap.get(key);\n if (!ref) {\n warnings.push({ code: 'invalid_teacher_reference', context: x });\n return;\n }\n\n if (teacherReferences.some(y => y.to == ref.id)) {\n warnings.push({ code: 'teacher_referenced_multiple_times', context: x });\n return;\n }\n\n teacherReferences.push({ to: ref.id });\n });\n\n return teacherReferences;\n}\n\nfunction extractSyllabus (\n course: Types.Course,\n syllabusesCodeMap: Map<string, C_Syllabus>,\n syllabusesNameMap: Map<string, C_Syllabus>,\n warnings: { code: Types.ErrorCode, context?: unknown }[],\n): string | undefined {\n if (course.syllabus == null) return undefined;\n const syllabusValue = toString(course.syllabus);\n if (!syllabusValue) return undefined;\n\n const syllabus = syllabusesCodeMap.get(syllabusValue) || syllabusesNameMap.get(syllabusValue.toLowerCase());\n\n if (!syllabus) {\n warnings.push({ code: 'invalid_syllabus_reference', context: syllabusValue });\n return undefined;\n }\n\n return syllabus.id;\n}\n\n\nfunction _schedules (\n source: Types.Source\n): Out {\n // gather all import related warnings/errors\n const warnings: { code: Types.ErrorCode, context?: unknown }[] = [];\n // let errors: string[] = [];\n\n source.settings = source.settings ?.filter(x => Object.values(x).some(y => toString(y).length > 0));\n source.locations = source.locations?.filter(x => Object.values(x).some(y => toString(y).length > 0));\n source.teachers = source.teachers ?.filter(x => Object.values(x).some(y => toString(y).length > 0));\n source.groups = source.groups ?.filter(x => Object.values(x).some(y => toString(y).length > 0));\n source.persons = source.persons ?.filter(x => Object.values(x).some(y => toString(y).length > 0));\n source.courses = source.courses ?.filter(x => Object.values(x).some(y => toString(y).length > 0));\n\n\n ////\n //// settings\n ////\n const settings: C_Settings = {\n discretization: 5,\n numDays: 5,\n dayStart: '08:00',\n dayEnd: '17:00',\n };\n if (!source.settings) {\n warnings.push({ code: 'missing_settings_sheet' });\n }\n if (source.settings?.[0]?.number_of_days) {\n const numDays = source.settings?.[0]?.number_of_days;\n try {\n settings.numDays = toPositiveInteger(numDays);\n\n // must be 5 or 7\n if (settings.numDays !== 5 && settings.numDays !== 7) {\n warnings.push({ code: 'invalid_number_of_days', context: numDays });\n settings.numDays = 5;\n }\n } catch {\n warnings.push({ code: 'invalid_number_of_days', context: numDays });\n }\n }\n\n ////\n //// syllabuses\n ////\n const syllabusesIdMap = new Map<string, C_Syllabus>();\n const syllabusesNameMap = new Map<string, C_Syllabus>();\n const syllabusesCodeMap = new Map<string, C_Syllabus>();\n if (!source.syllabuses) {\n // warnings.push({ code: 'missing_syllabus_sheet' });\n }\n source.syllabuses?.forEach(x => {\n const ids = toStringIfExists(x.foreign_ID );\n const subjectCode = toStringIfExists(x.subject_code);\n const subjectName = toStringIfExists(x.subject_name);\n const courseCode = toStringIfExists(x.course_code );\n const courseName = toStringIfExists(x.course_name );\n const schoolType = toStringIfExists(x.school_type );\n\n const id = toStringIfExists(x.ID) ?? generateId(syllabusesIdMap);\n if (syllabusesIdMap.has(id)) {\n warnings.push({ code: 'ignoring_duplicate_syllabus', context: `${subjectName} (${courseName})` });\n return;\n }\n\n if (!subjectName) {\n warnings.push({ code: 'missing_subject_name', context: x });\n return;\n }\n\n if (!schoolType) {\n warnings.push({ code: 'missing_school_type', context: x });\n return;\n }\n\n // create the syllabus object\n const y: C_Syllabus = {\n id,\n ...ids && { ids },\n ...subjectCode && { subjectCode },\n subjectName,\n ...courseCode && { courseCode },\n ...courseName && { courseName },\n schoolType,\n official: true, // always true for imported syllabuses\n __raw: x\n };\n syllabusesIdMap.set(id, y);\n const code = courseCode || subjectCode;\n const name = courseName || subjectName;\n if (code) syllabusesCodeMap.set(code, y);\n if (name) syllabusesNameMap.set(name.toLowerCase(), y);\n });\n\n\n ////\n //// locations, teachers\n ////\n const locationsIdMap = new Map<string, C_Location>();\n const locationsNameMap = new Map<string, C_Location>();\n const teachersIdMap = new Map<string, C_Teacher>();\n const teachersNameMap = new Map<string, C_Teacher>();\n [\n {\n name: { singular: 'location', plural: 'locations' } as const,\n data: source.locations,\n idMap: locationsIdMap,\n nameMap: locationsNameMap,\n },\n {\n name: { singular: 'teacher', plural: 'teachers' } as const,\n data: source.teachers,\n idMap: teachersIdMap,\n nameMap: teachersNameMap,\n }\n ].forEach(({ name, data, idMap, nameMap }) => {\n if (!data) {\n warnings.push({ code: `missing_${name.plural}_sheet` });\n }\n data?.forEach(x => {\n const ids = toStringIfExists(x.foreign_ID);\n const displayName = toStringIfExists(x.name );\n\n const id = toStringIfExists(x.ID) ?? generateId(idMap);\n if (idMap.has(id)) {\n warnings.push({ code: `ignoring_duplicate_${name.singular}`, context: displayName });\n return;\n }\n\n const y = {\n id,\n ...ids && { ids },\n ...displayName && { displayName },\n __raw: x\n };\n idMap.set(id, y);\n if (displayName) nameMap.set(displayName.toLowerCase(), y);\n });\n });\n\n\n ////\n //// groups\n ////\n const groupsIdMap = new Map<string, C_Group>();\n const groupsNameMap = new Map<string, C_Group>();\n if (!source.groups) {\n warnings.push({ code: 'missing_groups_sheet' });\n }\n source.groups?.forEach(x => {\n const ids = toStringIfExists(x.foreign_ID);\n const displayName = toStringIfExists(x.name );\n\n const id = toStringIfExists(x.ID) ?? generateId(groupsIdMap);\n if (groupsIdMap.has(id)) {\n warnings.push({ code: 'ignoring_duplicate_group', context: displayName });\n return;\n }\n\n // parent groups determine the species of the group\n const species = toStringIfExists(x.is_class) == '1' ? 'class' as const : undefined;\n\n const y = {\n id,\n ...ids && { ids },\n ...displayName && { displayName },\n ...species && { species },\n __raw: x\n } as C_Group;\n groupsIdMap.set(id, y);\n if (displayName) groupsNameMap.set(displayName.toLowerCase(), y);\n });\n\n\n ////\n //// persons\n ////\n const personsIdMap = new Map<string, C_Person>();\n const personsSsnMap = new Map<string, C_Person>();\n if (!source.persons) {\n warnings.push({ code: 'missing_persons_sheet' });\n }\n source.persons?.forEach(x => {\n const ids = toStringIfExists(x.foreign_ID);\n const firstName = toStringIfExists(x.first_name);\n const lastName = toStringIfExists(x.last_name );\n const SSN = toStringIfExists(x.SSN );\n\n const id = toStringIfExists(x.ID) ?? generateId(personsIdMap);\n if (personsIdMap.has(id)) {\n warnings.push({ code: 'ignoring_duplicate_person', context: `${firstName} ${lastName}` });\n return;\n }\n\n let group: string | undefined = undefined;\n if (x.group) {\n const key = toString(x.group).toLowerCase();\n const ref = groupsNameMap.get(key);\n if (!ref) {\n warnings.push({ code: 'invalid_group_reference', context: x.group });\n } else if (ref.species !== 'class') {\n warnings.push({ code: 'forbidden_group_reference', context: x.group });\n } else {\n group = ref.id;\n }\n }\n\n let sex: C_Person['sex'];\n if (x.sex) {\n if (isString(x.sex) && x.sex.toLowerCase() == 'man') sex = 'Man';\n else if (isString(x.sex) && x.sex.toLowerCase() == 'woman') sex = 'Woman';\n else {\n warnings.push({ code: 'invalid_sex', context: x.sex });\n }\n }\n\n const person: C_Person = {\n id,\n ...ids && { ids },\n ...firstName && { firstName },\n ...lastName && { lastName },\n ...sex && { sex },\n ...group && { group },\n ...SSN && { SSN: { value: SSN } },\n __raw: x\n };\n personsIdMap.set(id, person);\n if (SSN) personsSsnMap.set(SSN, person);\n });\n\n ////\n //// group.members (need to wait for persons to be parsed)\n ////\n groupsNameMap.forEach(x => {\n let duplicateReported = false;\n\n // ignore if no members\n if (!x.__raw.members) return;\n\n // parse and replace SSN by person id\n x.members = makeChainable(x.__raw.members)\n .chain(x => toString(x)\n .split(',')\n .map(x => x.trim())\n .filter(x => x != null)\n )\n .chain(x => countBy(x))\n .chain(y => Object.entries(y)\n .map(([ssn, count]) => {\n // ignore empty ssn\n if (!ssn) return;\n\n // warn if duplicate member\n if (!duplicateReported && count > 1) {\n warnings.push({ code: 'duplicate_group_member', context: x.displayName });\n duplicateReported = true;\n }\n\n // fetch person and warn if not found\n const person = personsSsnMap.get(ssn);\n if (!person) {\n warnings.push({ code: 'invalid_person_reference', context: ssn });\n return;\n }\n\n // warn if the group is a class and the person is already in a different class\n // (we also need to set the group of the person if it is empty)\n if (x.species == 'class') {\n if (!person.group) {\n person.group = x.id;\n }\n else if (person.group != x.id) {\n warnings.push({ code: 'person_in_multiple_classes', context: ssn });\n return;\n }\n }\n\n return person.id;\n })\n .filter(x => x != null)\n )\n .value;\n });\n\n\n ////\n //// courses\n ////\n const coursesIdMap = new Map<string, C_Course >();\n const eventsIdMap = new Map<string, C_Event >();\n const overlapGroupsKeyMap = new Map<string, C_OverlapGroup>();\n if (!source.courses) {\n warnings.push({ code: 'missing_courses_sheet' });\n }\n source.courses?.forEach(x => {\n // await loading events until courses are created\n const mergeWith = toStringIfExists(x.merge_with);\n if (mergeWith) return;\n\n const ids = toStringIfExists(x.foreign_ID);\n const displayName = toStringIfExists(x.name );\n const subject = toStringIfExists(x.subject );\n\n const courseId = toStringIfExists(x.ID) ?? generateId(coursesIdMap);\n if (coursesIdMap.has(courseId)) {\n warnings.push({ code: 'ignoring_duplicate_course', context: displayName + (subject ? ` (${subject})` : '') });\n return;\n }\n\n // try to parse the total hours as an integer\n let expectedTotalHours: number | undefined = undefined;\n if (x.total_hours) {\n try {\n expectedTotalHours = toPositiveInteger(x.total_hours);\n } catch {\n warnings.push({ code: 'invalid_total_hours', context: x.total_hours });\n }\n }\n\n // try to parse the minutes per week as an multiple of 5\n let minutesPerWeek: number | undefined = undefined;\n if (x.minutes_per_week) {\n try {\n minutesPerWeek = toPositiveMultipleOf5(x.minutes_per_week);\n } catch {\n warnings.push({ code: 'invalid_minutes_per_week', context: x.minutes_per_week });\n }\n }\n\n // only one of minutes_per_week or total_hours should be defined\n if (minutesPerWeek != null && expectedTotalHours != null) {\n warnings.push({ code: 'ambiguous_planned_duration', context: `${minutesPerWeek} min/week OR ${expectedTotalHours} hrs` });\n }\n const plannedDuration =\n expectedTotalHours\n ? `${expectedTotalHours} hrs` :\n minutesPerWeek\n ? `${minutesPerWeek} min/week` :\n undefined;\n\n\n // try to parse the lesson durations as an array of integers from which we will generate events\n if (x.lesson_durations) {\n const _durations = typeof x.lesson_durations === 'string'\n ? x.lesson_durations.split(',').map(x => x.trim())\n : [x.lesson_durations];\n\n // truncate to multiple of 5 and filter out zero duration events\n const durations = _durations\n .map(e => {\n try {\n return toPositiveMultipleOf5(e);\n } catch {\n warnings.push({ code: 'invalid_lesson_durations', context: x.lesson_durations });\n return undefined;\n }\n })\n .filter((x): x is number => x !== undefined);\n\n durations.forEach(x => {\n const id = generateId(eventsIdMap);\n const event: C_Event = { id, course: courseId, preferredDuration: x };\n eventsIdMap.set(id, event);\n });\n }\n\n // overlap group\n if (x.overlap_group && toString(x.overlap_group)) {\n const key = toString(x.overlap_group).toLowerCase();\n\n const og = overlapGroupsKeyMap.get(key);\n if (og) og.coalesced?.push({ toModel: 'courses', to: courseId });\n else {\n const id = generateId(overlapGroupsKeyMap);\n const coalesced = [{ toModel: 'courses' as const, to: courseId }];\n overlapGroupsKeyMap.set(key, { id, coalesced });\n }\n }\n\n const locations = extractLocations(x, locationsNameMap, warnings)?.map(x => ({ groupIndex: x.groupIndex, locations: [x.to] as [string] }));\n const groups = extractGroups (x, groupsNameMap, warnings);\n const teachers = extractTeachers (x, teachersNameMap, warnings);\n const syllabus = extractSyllabus(x, syllabusesCodeMap, syllabusesNameMap, warnings);\n\n const course: C_Course = {\n id: courseId,\n ...ids && { ids },\n ...displayName && { displayName },\n ...subject && { subject },\n /* TO BE DEPRECATED */ ...expectedTotalHours && { expectedTotalHours },\n /* TO BE DEPRECATED */ ...minutesPerWeek && { minutesPerWeek },\n ...plannedDuration && { plannedDuration },\n ...groups && { groups },\n ...teachers && { teachers },\n ...locations && { locations },\n ...syllabus && { syllabus },\n __raw: x\n };\n coursesIdMap.set(courseId, course);\n });\n\n\n ////\n //// events\n ////\n source.courses?.forEach(x => {\n // load courses\n const mergeWith = toStringIfExists(x.merge_with);\n if (!mergeWith) return;\n\n // ensure that the course to merge with exists\n if (!coursesIdMap.has(mergeWith)) {\n warnings.push({ code: 'invalid_course_reference', context: mergeWith });\n return;\n }\n\n const displayName = toStringIfExists(x.name);\n const locations = extractLocations(x, locationsNameMap, warnings)?.map(x => ({ groupIndex: x.groupIndex, locations: [x.to] as [string] }));\n const groups = extractGroups (x, groupsNameMap, warnings);\n const teachers = extractTeachers (x, teachersNameMap, warnings);\n\n // try to parse the lesson durations as an array of integers from which we will generate events\n if (x.lesson_durations) {\n const _durations = typeof x.lesson_durations === 'string'\n ? x.lesson_durations.split(',').map(x => x.trim())\n : [x.lesson_durations];\n\n // truncate to multiple of 5 and filter out zero duration events\n const durations = _durations\n .map(e => {\n try {\n return toPositiveMultipleOf5(e);\n } catch {\n warnings.push({ code: 'invalid_lesson_durations', context: x.lesson_durations });\n return undefined;\n }\n })\n .filter((x): x is number => x !== undefined);\n\n durations.forEach(preferredDuration => {\n const id = generateId(eventsIdMap);\n const event: C_Event = {\n id,\n course: mergeWith,\n preferredDuration: preferredDuration,\n ...displayName && { displayName },\n ...groups && { groups },\n ...teachers && { teachers },\n ...locations && { locations },\n __raw: x\n };\n eventsIdMap.set(id, event);\n });\n }\n });\n\n\n ////\n //// return\n ////\n return {\n settings,\n locations: [...locationsIdMap .values()],\n teachers: [...teachersIdMap .values()],\n persons: [...personsIdMap .values()],\n groups: [...groupsIdMap .values()],\n courses: [...coursesIdMap .values()],\n events: [...eventsIdMap .values()],\n overlapGroups: [...overlapGroupsKeyMap.values()],\n syllabuses: [...syllabusesIdMap .values()],\n meta: {\n // ...errors .length && { errors: errors },\n ...warnings.length && { warnings: warnings }\n }\n };\n}\n\n\nexport default {\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AC,KAAI,QAAKA,IAAE,MAAM,CAAC,GAChD,CAAC,EAAE,iBAAiB,EAIrB,KAAI,MAAK;AACR,OAAI;AACF,WAAO,sBAAsB,EAAE;WACzB;AACN,aAAS,KAAK;KAAE,MAAM;KAA4B,SAAS,EAAE;KAAkB,CAAC;AAChF;;IAEF,CACD,QAAQ,QAAmBA,QAAM,OAAU,CAEpC,SAAQ,sBAAqB;GACrC,MAAM,KAAK,WAAW,YAAY;GAClC,MAAMW,QAAiB;IACrB;IACA,QAAmB;IACA;IACnB,GAAG,eAAgB,EAAE,aAAa;IAClC,GAAG,UAAgB,EAAE,QAAa;IAClC,GAAG,YAAgB,EAAE,UAAa;IAClC,GAAG,aAAgB,EAAE,WAAa;IAClC,OAAmB;IACpB;AACD,eAAY,IAAI,IAAI,MAAM;IAC1B;GAEJ;AAMF,QAAO;EACL;EACA,WAAe,CAAC,GAAG,eAAoB,QAAQ,CAAC;EAChD,UAAe,CAAC,GAAG,cAAoB,QAAQ,CAAC;EAChD,SAAe,CAAC,GAAG,aAAoB,QAAQ,CAAC;EAChD,QAAe,CAAC,GAAG,YAAoB,QAAQ,CAAC;EAChD,SAAe,CAAC,GAAG,aAAoB,QAAQ,CAAC;EAChD,QAAe,CAAC,GAAG,YAAoB,QAAQ,CAAC;EAChD,eAAe,CAAC,GAAG,oBAAoB,QAAQ,CAAC;EAChD,YAAe,CAAC,GAAG,gBAAoB,QAAQ,CAAC;EAChD,MAAe,EAEb,GAAG,SAAS,UAAU,EAAY,UAAU,EAC7C;EACF;;AAIH,mBAAe,EACb,WAAW,YACZ"}
|
package/dist/RS/types/to.d.ts
CHANGED
|
@@ -29,8 +29,9 @@ interface ToOptions extends BaseOptions {
|
|
|
29
29
|
*/
|
|
30
30
|
appendOutput?: boolean;
|
|
31
31
|
/**
|
|
32
|
-
* @deprecated
|
|
33
|
-
*
|
|
32
|
+
* @deprecated the only purpose of this backwards compatibility is to support the input-analyzer module
|
|
33
|
+
*
|
|
34
|
+
* If not set to true, these new features are taken into account:
|
|
34
35
|
*
|
|
35
36
|
* - New root level entries: `intervals` and `individuals`
|
|
36
37
|
* - As the there is now a root level `intervals` the former may be references from `Collection.intervals`, `Group.intervals` etc.
|
package/dist/RS/types/to.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to.js","names":[],"sources":["../../../src/RS/types/to.ts"],"sourcesContent":["import type { BaseOptions } from '../../common/types';\nimport type { CoreTypes } from '../../core';\nimport type { MixedScheduleData } from '../make-connected';\nimport type { Types } from './';\nimport type { AlgorithmWeightParameters } from './algorithm-parameters';\n\n\nexport type ToInput = MixedScheduleData;\n\ntype PartialScheduleOptions<IDs extends Array<string> | Set<string>> = {\n /** @description undefined means all included */\n includedEvents?: IDs;\n /** @description undefined means all included */\n includedLocations?: IDs;\n omittedEventsHandling: 'ignore' | 'freeze';\n};\n\nexport interface ToOptions extends BaseOptions {\n meta?: boolean;\n isPrivateId?: boolean;\n isPublicId?: boolean;\n /**\n * If true, the output will include the full core data. This enables the resulting output file to be uploaded as a new schedule.\n * @default false\n */\n appendCoreData?: boolean;\n /**\n * If true, the output will include current configuration of events and locked times as `output` entry.\n * @default false\n */\n appendOutput?: boolean;\n\n /**\n * @deprecated\n * If
|
|
1
|
+
{"version":3,"file":"to.js","names":[],"sources":["../../../src/RS/types/to.ts"],"sourcesContent":["import type { BaseOptions } from '../../common/types';\nimport type { CoreTypes } from '../../core';\nimport type { MixedScheduleData } from '../make-connected';\nimport type { Types } from './';\nimport type { AlgorithmWeightParameters } from './algorithm-parameters';\n\n\nexport type ToInput = MixedScheduleData;\n\ntype PartialScheduleOptions<IDs extends Array<string> | Set<string>> = {\n /** @description undefined means all included */\n includedEvents?: IDs;\n /** @description undefined means all included */\n includedLocations?: IDs;\n omittedEventsHandling: 'ignore' | 'freeze';\n};\n\nexport interface ToOptions extends BaseOptions {\n meta?: boolean;\n isPrivateId?: boolean;\n isPublicId?: boolean;\n /**\n * If true, the output will include the full core data. This enables the resulting output file to be uploaded as a new schedule.\n * @default false\n */\n appendCoreData?: boolean;\n /**\n * If true, the output will include current configuration of events and locked times as `output` entry.\n * @default false\n */\n appendOutput?: boolean;\n\n /**\n * @deprecated the only purpose of this backwards compatibility is to support the input-analyzer module\n *\n * If not set to true, these new features are taken into account:\n *\n * - New root level entries: `intervals` and `individuals`\n * - As the there is now a root level `intervals` the former may be references from `Collection.intervals`, `Group.intervals` etc.\n * - The `Collection.groups` and `Event.groups` supports referencing `individuals` (and `individuals sets`) in addition to `groups`\n * - The `Group.forbidOverlappingEvents` has been removed.\n * - The `Group.disableDayLengthPunishment` has been replaced by `Group.minimizeGaps`\n */\n oldFormat?: boolean;\n\n partialScheduleOptions?: PartialScheduleOptions<Array<string> | Set<string>>\n\n algorithmWeightParameters?: AlgorithmWeightParameters;\n\n /**\n * to be used before whe have migrated from \"maxNumWorkingHours\" and \"maxNumDailyWorkingHours\" to \"maximumScheduleSpan\"\n */\n useMaximumScheduleSpan?: boolean;\n}\n\nexport interface ParsedToOptions extends Omit<ToOptions, 'partialScheduleOptions'> {\n partialScheduleOptions?: PartialScheduleOptions<Set<string>>\n}\n\nexport const structure = 'RS/algorithm-5.0.2';\nexport type Structure = typeof structure;\nexport interface ToOutput {\n meta: {\n structure?: Structure;\n division: Pick<CoreTypes.Deep.Division, 'displayName' | 'start' | 'end'>;\n };\n algorithmParameters?: {\n weights?: AlgorithmWeightParameters;\n };\n score?: [number, number, number, number];\n input: Types.scheduleData;\n output?: Types.configuration[];\n coreData?: Partial<CoreTypes.SerializedWithOptionalId.Schedule>;\n}"],"mappings":";AA2DA,MAAa,YAAY"}
|
|
@@ -80,7 +80,7 @@ type Infer<T extends VertexQuery$1<any, any>> = T extends VertexQuery$1<infer C,
|
|
|
80
80
|
*/
|
|
81
81
|
declare namespace createVertexQuery {
|
|
82
82
|
function division<Q$1 extends VertexQuery<DivisionVertex>>(query: Q$1): VertexQuery$1<"divisions", Q$1>;
|
|
83
|
-
function settings<Q$1 extends VertexQuery<DivisionSettingsVertex>>(query: Q$1): VertexQuery$1<"
|
|
83
|
+
function settings<Q$1 extends VertexQuery<DivisionSettingsVertex>>(query: Q$1): VertexQuery$1<"settings", Q$1>;
|
|
84
84
|
function exception<Q$1 extends VertexQuery<ExceptionVertex>>(query: Q$1): VertexQuery$1<"exceptions", Q$1>;
|
|
85
85
|
function event<Q$1 extends VertexQuery<EventVertex>>(query: Q$1): VertexQuery$1<"events", Q$1>;
|
|
86
86
|
function scheduleEvent<Q$1 extends VertexQuery<ScheduleEventVertex>>(query: Q$1): VertexQuery$1<"scheduleEvents", Q$1>;
|
|
@@ -24,7 +24,7 @@ let createVertexQuery;
|
|
|
24
24
|
}
|
|
25
25
|
_createVertexQuery.division = division;
|
|
26
26
|
function settings(query) {
|
|
27
|
-
return new VertexQuery("
|
|
27
|
+
return new VertexQuery("settings", query);
|
|
28
28
|
}
|
|
29
29
|
_createVertexQuery.settings = settings;
|
|
30
30
|
function exception(query) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vertex-query.js","names":["_collection: C","_query: Q"],"sources":["../../../../src/core/interfaces/vertices/vertex-query.ts"],"sourcesContent":["import type { Collection, CustomVertexExport } from './util';\nimport type { TeacherVertex } from './teachers';\nimport type { ExceptionVertex } from './exceptions';\nimport type { EventVertex, ScheduleEventVertex, CalendarEventVertex } from './events';\nimport type { CourseVertex } from './courses';\nimport type { DivisionSettingsVertex } from './division-settings';\nimport type { DivisionVertex } from './divisions';\nimport type { GenerationVertex } from './generations';\nimport type { GroupVertex } from './groups';\nimport type { LocationVertex } from './locations';\nimport type { LockedTimeVertex } from './locked-times';\nimport type { OverlapGroupVertex } from './overlap-groups';\nimport type { PeriodVertex } from './periods';\nimport type { PersonVertex } from './persons';\nimport type { RootIntervalVertex } from './root-intervals';\nimport type { SyllabusVertex } from './syllabuses';\nimport type { ConfigurationVertex } from './configurations';\nimport type { CompanyVertex } from './companies';\nimport type { UserVertex } from './users';\nimport type { VertexQuery as Query } from './util/vertex-query';\nimport type { TypeEqual } from 'ts-expect';\nimport { expectType } from 'ts-expect';\n\n\ntype VertexRecord = {\n divisions: DivisionVertex;\n divisionSettings: DivisionSettingsVertex;\n settings: DivisionSettingsVertex;\n teachers: TeacherVertex;\n exceptions: ExceptionVertex;\n events: EventVertex;\n scheduleEvents: ScheduleEventVertex;\n calendarEvents: CalendarEventVertex;\n courses: CourseVertex;\n generations: GenerationVertex;\n groups: GroupVertex;\n locations: LocationVertex;\n lockedTimes: LockedTimeVertex;\n overlapGroups: OverlapGroupVertex;\n periods: PeriodVertex;\n persons: PersonVertex;\n students: PersonVertex;\n rootIntervals: RootIntervalVertex;\n syllabuses: SyllabusVertex;\n configurations: ConfigurationVertex;\n companies: CompanyVertex;\n users: UserVertex;\n};\nexport type BaseQueryRecord<C extends keyof VertexRecord> = Query<VertexRecord[C]>;\n{\n // the keys must all be a collection\n type Mismatches = keyof {\n [K in keyof VertexRecord as K extends Collection ? never : K]: true\n };\n expectType<TypeEqual<Mismatches, never>>(true);\n}\n\n/**\n * See {@link createVertexQuery}\n */\nexport class VertexQuery <\n C extends keyof VertexRecord,\n Q extends BaseQueryRecord<C>\n> {\n constructor (\n private readonly _collection: C,\n private readonly _query: Q\n ) {}\n\n get collection () { return this._collection }\n get query () { return this._query }\n}\n\n\n/**\n * Infers the result type for a query created via createVertexQuery.\n *\n * @example\n * const personQuery = createVertexQuery('persons', { select: ['id', 'firstName'] });\n * type PersonType = Infer<typeof personQuery>;\n */\nexport type Infer<T extends VertexQuery<any, any>> =\n T extends VertexQuery<infer C, infer Q>\n ? CustomVertexExport<VertexRecord[C], Q>\n : never;\n\n\n/**\n * Builds a typed vertex query for a given vertex type using a select/expand shape.\n *\n * Use together with Infer<T> to obtain the serialized result type.\n *\n * @typeParam Q - The select/expand query shape for that vertex.\n *\n * @example\n * const groupQuery = createVertexQuery.group({\n * select: ['id', 'displayName'],\n * expand: { members: { select: ['id'] } }\n * });\n * type GroupType = Infer<typeof groupQuery>;\n */\nexport namespace createVertexQuery {\n //\n // The following did not work: it seems we need to define Q as an completely independent type parameter (?)\n //\n // export function createVertexQuery <\n // C extends keyof VertexRecord,\n // const Q extends Query<VertexRecord[C]>\n // > (\n // collection: C,\n // query: Q\n // ) {\n // return new VertexQuery(collection, query);\n // }\n\n export function division <Q extends Query<DivisionVertex >> (query: Q) { return new VertexQuery('divisions', query) }\n export function settings <Q extends Query<DivisionSettingsVertex>> (query: Q) { return new VertexQuery('
|
|
1
|
+
{"version":3,"file":"vertex-query.js","names":["_collection: C","_query: Q"],"sources":["../../../../src/core/interfaces/vertices/vertex-query.ts"],"sourcesContent":["import type { Collection, CustomVertexExport } from './util';\nimport type { TeacherVertex } from './teachers';\nimport type { ExceptionVertex } from './exceptions';\nimport type { EventVertex, ScheduleEventVertex, CalendarEventVertex } from './events';\nimport type { CourseVertex } from './courses';\nimport type { DivisionSettingsVertex } from './division-settings';\nimport type { DivisionVertex } from './divisions';\nimport type { GenerationVertex } from './generations';\nimport type { GroupVertex } from './groups';\nimport type { LocationVertex } from './locations';\nimport type { LockedTimeVertex } from './locked-times';\nimport type { OverlapGroupVertex } from './overlap-groups';\nimport type { PeriodVertex } from './periods';\nimport type { PersonVertex } from './persons';\nimport type { RootIntervalVertex } from './root-intervals';\nimport type { SyllabusVertex } from './syllabuses';\nimport type { ConfigurationVertex } from './configurations';\nimport type { CompanyVertex } from './companies';\nimport type { UserVertex } from './users';\nimport type { VertexQuery as Query } from './util/vertex-query';\nimport type { TypeEqual } from 'ts-expect';\nimport { expectType } from 'ts-expect';\n\n\ntype VertexRecord = {\n divisions: DivisionVertex;\n divisionSettings: DivisionSettingsVertex;\n settings: DivisionSettingsVertex;\n teachers: TeacherVertex;\n exceptions: ExceptionVertex;\n events: EventVertex;\n scheduleEvents: ScheduleEventVertex;\n calendarEvents: CalendarEventVertex;\n courses: CourseVertex;\n generations: GenerationVertex;\n groups: GroupVertex;\n locations: LocationVertex;\n lockedTimes: LockedTimeVertex;\n overlapGroups: OverlapGroupVertex;\n periods: PeriodVertex;\n persons: PersonVertex;\n students: PersonVertex;\n rootIntervals: RootIntervalVertex;\n syllabuses: SyllabusVertex;\n configurations: ConfigurationVertex;\n companies: CompanyVertex;\n users: UserVertex;\n};\nexport type BaseQueryRecord<C extends keyof VertexRecord> = Query<VertexRecord[C]>;\n{\n // the keys must all be a collection\n type Mismatches = keyof {\n [K in keyof VertexRecord as K extends Collection ? never : K]: true\n };\n expectType<TypeEqual<Mismatches, never>>(true);\n}\n\n/**\n * See {@link createVertexQuery}\n */\nexport class VertexQuery <\n C extends keyof VertexRecord,\n Q extends BaseQueryRecord<C>\n> {\n constructor (\n private readonly _collection: C,\n private readonly _query: Q\n ) {}\n\n get collection () { return this._collection }\n get query () { return this._query }\n}\n\n\n/**\n * Infers the result type for a query created via createVertexQuery.\n *\n * @example\n * const personQuery = createVertexQuery('persons', { select: ['id', 'firstName'] });\n * type PersonType = Infer<typeof personQuery>;\n */\nexport type Infer<T extends VertexQuery<any, any>> =\n T extends VertexQuery<infer C, infer Q>\n ? CustomVertexExport<VertexRecord[C], Q>\n : never;\n\n\n/**\n * Builds a typed vertex query for a given vertex type using a select/expand shape.\n *\n * Use together with Infer<T> to obtain the serialized result type.\n *\n * @typeParam Q - The select/expand query shape for that vertex.\n *\n * @example\n * const groupQuery = createVertexQuery.group({\n * select: ['id', 'displayName'],\n * expand: { members: { select: ['id'] } }\n * });\n * type GroupType = Infer<typeof groupQuery>;\n */\nexport namespace createVertexQuery {\n //\n // The following did not work: it seems we need to define Q as an completely independent type parameter (?)\n //\n // export function createVertexQuery <\n // C extends keyof VertexRecord,\n // const Q extends Query<VertexRecord[C]>\n // > (\n // collection: C,\n // query: Q\n // ) {\n // return new VertexQuery(collection, query);\n // }\n\n export function division <Q extends Query<DivisionVertex >> (query: Q) { return new VertexQuery('divisions', query) }\n export function settings <Q extends Query<DivisionSettingsVertex>> (query: Q) { return new VertexQuery('settings', query) }\n export function exception <Q extends Query<ExceptionVertex >> (query: Q) { return new VertexQuery('exceptions', query) }\n export function event <Q extends Query<EventVertex >> (query: Q) { return new VertexQuery('events', query) }\n export function scheduleEvent<Q extends Query<ScheduleEventVertex >> (query: Q) { return new VertexQuery('scheduleEvents', query) }\n export function calendarEvent<Q extends Query<CalendarEventVertex >> (query: Q) { return new VertexQuery('calendarEvents', query) }\n export function course <Q extends Query<CourseVertex >> (query: Q) { return new VertexQuery('courses', query) }\n export function generation <Q extends Query<GenerationVertex >> (query: Q) { return new VertexQuery('generations', query) }\n export function location <Q extends Query<LocationVertex >> (query: Q) { return new VertexQuery('locations', query) }\n export function lockedTime <Q extends Query<LockedTimeVertex >> (query: Q) { return new VertexQuery('lockedTimes', query) }\n export function overlapGroup <Q extends Query<OverlapGroupVertex >> (query: Q) { return new VertexQuery('overlapGroups', query) }\n export function period <Q extends Query<PeriodVertex >> (query: Q) { return new VertexQuery('periods', query) }\n export function person <Q extends Query<PersonVertex >> (query: Q) { return new VertexQuery('persons', query) }\n export function rootInterval <Q extends Query<RootIntervalVertex >> (query: Q) { return new VertexQuery('rootIntervals', query) }\n export function syllabus <Q extends Query<SyllabusVertex >> (query: Q) { return new VertexQuery('syllabuses', query) }\n export function group <Q extends Query<GroupVertex >> (query: Q) { return new VertexQuery('groups', query) }\n export function teacher <Q extends Query<TeacherVertex >> (query: Q) { return new VertexQuery('teachers', query) }\n}"],"mappings":";;;AAsDE,WAAyC,KAAK;;;;AAMhD,IAAa,cAAb,MAGE;CACA,YACE,AAAiBA,aACjB,AAAiBC,QACjB;EAFiB;EACA;;CAGnB,IAAI,aAAc;AAAE,SAAO,KAAK;;CAChC,IAAI,QAAc;AAAE,SAAO,KAAK;;;;;CA6CzB,SAAS,SAAwD,OAAU;AAAE,SAAO,IAAI,YAAY,aAAoB,MAAM;;;CAC9H,SAAS,SAAwD,OAAU;AAAE,SAAO,IAAI,YAAY,YAAoB,MAAM;;;CAC9H,SAAS,UAAwD,OAAU;AAAE,SAAO,IAAI,YAAY,cAAoB,M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