@royalschedule/maps 3.3.16 → 3.3.18
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 -3
- package/dist/Additio/to/schedules.js +26 -1
- package/dist/Additio/to/schedules.js.map +1 -1
- package/dist/Additio/types/index.d.ts +2 -0
- package/dist/Additio/types/options.d.ts +8 -0
- package/dist/Additio/types/schedules.d.ts +1 -5
- package/dist/PlanDigital/to/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Types } from "../../core/v2/types/index.js";
|
|
2
|
-
import {
|
|
3
|
-
import * as
|
|
2
|
+
import { Types as Types$1 } from "../types/index.js";
|
|
3
|
+
import * as xlsx2 from "xlsx";
|
|
4
4
|
|
|
5
5
|
//#region src/Additio/to/index.d.ts
|
|
6
6
|
declare class export_default {
|
|
@@ -14,7 +14,7 @@ declare class export_default {
|
|
|
14
14
|
courses: Types.course[];
|
|
15
15
|
events: Types.event[];
|
|
16
16
|
lockedTimes: Types.lockedTime[];
|
|
17
|
-
}, options?:
|
|
17
|
+
}, options?: Types$1.options) => xlsx2.WorkBook;
|
|
18
18
|
}
|
|
19
19
|
//#endregion
|
|
20
20
|
export { export_default };
|
|
@@ -2,6 +2,26 @@ import moment from "moment";
|
|
|
2
2
|
import * as XLSX$1 from "xlsx";
|
|
3
3
|
|
|
4
4
|
//#region src/Additio/to/schedules.ts
|
|
5
|
+
/**
|
|
6
|
+
* Specifies the header and the order of the columns in the exported Excel file.
|
|
7
|
+
*/
|
|
8
|
+
const header = [
|
|
9
|
+
"id",
|
|
10
|
+
"externalid",
|
|
11
|
+
"groupid",
|
|
12
|
+
"group",
|
|
13
|
+
"dayid",
|
|
14
|
+
"startTime",
|
|
15
|
+
"length",
|
|
16
|
+
"subject",
|
|
17
|
+
"roomid",
|
|
18
|
+
"room",
|
|
19
|
+
"teacherid",
|
|
20
|
+
"teacher",
|
|
21
|
+
"classid",
|
|
22
|
+
"class",
|
|
23
|
+
"inweek"
|
|
24
|
+
];
|
|
5
25
|
const getId = (ref) => {
|
|
6
26
|
if (!ref) return "";
|
|
7
27
|
if (typeof ref == "string") return ref;
|
|
@@ -66,11 +86,15 @@ var schedules_default = (schedule, options = {}) => {
|
|
|
66
86
|
const start = moment.utc(x.start);
|
|
67
87
|
const end = moment.utc(x.end);
|
|
68
88
|
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);
|
|
89
|
+
const subject = x.tags?.find((x$1) => x$1.type == "COMPLEMENTARY_TIME")?.value;
|
|
90
|
+
const inweek = inWeeksMap.get("");
|
|
69
91
|
const out = {
|
|
70
92
|
id: x._id?.toString(),
|
|
71
93
|
dayid: (start.day() + 6) % 7,
|
|
72
94
|
startTime: start.format("HHmm"),
|
|
73
95
|
length: end.diff(start, "minutes"),
|
|
96
|
+
subject,
|
|
97
|
+
inweek,
|
|
74
98
|
teacherid: teachers.map((x$1) => x$1.ids).join(", "),
|
|
75
99
|
teacher: teachers.map((x$1) => x$1.displayName).join(", ")
|
|
76
100
|
};
|
|
@@ -80,7 +104,8 @@ var schedules_default = (schedule, options = {}) => {
|
|
|
80
104
|
};
|
|
81
105
|
function toXlsx(events) {
|
|
82
106
|
const wb = XLSX$1.utils.book_new();
|
|
83
|
-
|
|
107
|
+
const sheet = XLSX$1.utils.json_to_sheet(events, { header });
|
|
108
|
+
XLSX$1.utils.book_append_sheet(wb, sheet, "royal schedule export");
|
|
84
109
|
return wb;
|
|
85
110
|
}
|
|
86
111
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedules.js","names":["weeks","x","out: OutEvent","XLSX"],"sources":["../../../src/Additio/to/schedules.ts"],"sourcesContent":["import * as XLSX
|
|
1
|
+
{"version":3,"file":"schedules.js","names":["header: (keyof Required<OutEvent>)[]","weeks","x","out: OutEvent","XLSX"],"sources":["../../../src/Additio/to/schedules.ts"],"sourcesContent":["import * as XLSX from 'xlsx';\nimport moment from 'moment';\nimport type { Types as MongooseTypes } from 'mongoose';\nimport type { Types as CoreTypes } from '../../core/types';\nimport type { Types } from '../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\n/**\n * Specifies the header and the order of the columns in the exported Excel file.\n */\nconst header: (keyof Required<OutEvent>)[] = [\n 'id',\n 'externalid',\n 'groupid',\n 'group',\n 'dayid',\n 'startTime',\n 'length',\n 'subject',\n 'roomid',\n 'room',\n 'teacherid',\n 'teacher',\n 'classid',\n 'class',\n 'inweek'\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 } | MongooseTypes.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: Types.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 subject = x.tags?.find(x => x.type == 'COMPLEMENTARY_TIME')?.value;\n\n // the full schedule range\n const inweek = inWeeksMap.get('');\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 subject: subject,\n inweek: inweek,\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 const sheet = XLSX.utils.json_to_sheet(events, { header });\n XLSX.utils.book_append_sheet(wb, sheet, 'royal schedule export');\n\n return wb;\n}"],"mappings":";;;;;;;AA2BA,MAAMA,SAAuC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AAgBF,MAAM,SAAS,QAA+E;AAC5F,KAAI,CAAC,IAAK,QAAO;AACjB,KAAI,OAAO,OAAO,SAAU,QAAO;AACnC,QAAO,IAAI,GAAI;;AAGjB,yBACE,UACA,UAA0B,OACR;CAGlB,MAAM,aAAa,IAAI,IAAI,SAAS,QAAQ,KAAI,MAAK,CAAC,MAAM,IAAI;AAChE,YAAW,IAAI,IAAI,EAAE,QAAQ,CAAC;EAAE,OAAO,SAAS,SAAS;EAAO,KAAK,SAAS,SAAS;;CAGvF,MAAM,6BAAa,IAAI;AACvB,YAAW,SAAS,QAAQ,OAAO;EACjC,MAAM,QAAQ,OAAO,OAClB,KAAI,MAAK;GAER,MAAM,QAAQ,OAAO,IAAI,EAAE;GAC3B,MAAM,MAAQ,OAAO,IAAI,EAAE;GAC3B,MAAMC,UAAQ,IAAI;AAClB,UAAO,MAAM,SAAS,MAAM;AAC1B,YAAM,KAAK,MAAM;AACjB,U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M,cAAc,QAAQ,EAAE;AACjD,QAAK,MAAM,kBAAkB,IAAI,OAAO;AAExC,QAAO"}
|
|
@@ -7,9 +7,11 @@ import { ScheduleGroup } from "./schedule-groups.js";
|
|
|
7
7
|
import { Lesson } from "./lessons.js";
|
|
8
8
|
import { Schedule } from "./schedules.js";
|
|
9
9
|
import { CourseSection } from "./course-sections.js";
|
|
10
|
+
import { Options } from "./options.js";
|
|
10
11
|
|
|
11
12
|
//#region src/Additio/types/index.d.ts
|
|
12
13
|
declare namespace Types {
|
|
14
|
+
type options = Options;
|
|
13
15
|
type courseSection = CourseSection;
|
|
14
16
|
type course = Course;
|
|
15
17
|
type lesson = Lesson;
|
|
@@ -6,10 +6,6 @@ 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
|
-
};
|
|
13
9
|
type Schedule = {
|
|
14
10
|
start_date: Date;
|
|
15
11
|
end_date: Date;
|
|
@@ -27,5 +23,5 @@ type Schedule = {
|
|
|
27
23
|
lessons: Lesson[];
|
|
28
24
|
};
|
|
29
25
|
//#endregion
|
|
30
|
-
export {
|
|
26
|
+
export { Schedule };
|
|
31
27
|
//# 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 xlsx0 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[]) => xlsx0.WorkBook;
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
9
|
export { export_default };
|