@royalschedule/maps 3.3.16 → 3.3.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/Additio/to/index.d.ts +2 -2
- 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/dist/SchoolSoft/file/to/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Types } from "../../core/v2/types/index.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Types as Types$1 } from "../types/index.js";
|
|
3
3
|
import * as xlsx0 from "xlsx";
|
|
4
4
|
|
|
5
5
|
//#region src/Additio/to/index.d.ts
|
|
@@ -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) => xlsx0.WorkBook;
|
|
18
18
|
}
|
|
19
19
|
//#endregion
|
|
20
20
|
export { export_default };
|
|
@@ -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":["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\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 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":";;;;AAqCA,MAAM,SAAS,QAA+E;AAC5F,KAAI,CAAC,IAAK,QAA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AAC,CAACA;EAEjB,MAAMC,MAAgB;GACpB,IAAW,EAAE,KAAK;GAClB,QAAY,MAAM,QAAQ,KAAK;GAC/B,WAAW,MAAM,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"}
|
|
@@ -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 xlsx1 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[]) => xlsx1.WorkBook;
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
9
|
export { export_default };
|
|
@@ -1,5 +1,5 @@
|
|
|
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/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
|
+
}) => xlsx2.WorkBook;
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
19
|
export { export_default };
|