chuvsu-js 5.5.1 → 5.5.3
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/README.md +6 -9
- package/dist/common/http.js +2 -4
- package/dist/common/lesson-type.js +6 -1
- package/dist/common/parse.js +3 -1
- package/dist/core.d.ts +2 -1
- package/dist/core.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/lk/client.js +10 -4
- package/dist/lk/parse/grade-value.js +5 -1
- package/dist/lk/parse/portfolio-content.js +58 -16
- package/dist/lk/parse/portfolio-grades.js +37 -9
- package/dist/lk/parse/portfolio-performance.js +26 -8
- package/dist/lk/parse/portfolio.js +31 -13
- package/dist/lk/parse/webinar-lesson.js +4 -2
- package/dist/lk/parse/webinars.js +7 -3
- package/dist/lk/webinars.js +3 -1
- package/dist/tt/client.js +15 -7
- package/dist/tt/domain/directory.js +2 -4
- package/dist/tt/domain/index.d.ts +2 -2
- package/dist/tt/domain/index.js +2 -2
- package/dist/tt/domain/repository.js +67 -35
- package/dist/tt/domain/schedule-snapshot.js +51 -24
- package/dist/tt/domain/schedule.js +7 -3
- package/dist/tt/observations.js +7 -2
- package/dist/tt/parse/audience.js +3 -1
- package/dist/tt/parse/entry-parts.js +2 -3
- package/dist/tt/parse/full-schedule.js +1 -1
- package/dist/tt/parse/groups.js +1 -3
- package/dist/tt/parse/index.d.ts +2 -2
- package/dist/tt/parse/index.js +2 -2
- package/dist/tt/parse/lists.js +3 -3
- package/dist/tt/parse/overlays.js +7 -2
- package/dist/tt/utils/date.js +2 -2
- package/dist/tt/utils/period.js +2 -1
- package/dist/tt/utils/semester.js +2 -2
- package/dist/tt/utils/time-slots.js +81 -15
- package/dist/webinar/chat-subscription.d.ts +5 -0
- package/dist/webinar/chat-subscription.js +20 -0
- package/dist/webinar/client.d.ts +16 -1
- package/dist/webinar/client.js +152 -35
- package/dist/webinar/ddp.js +44 -13
- package/dist/webinar/events.js +7 -2
- package/dist/webinar/gateway.d.ts +3 -1
- package/dist/webinar/gateway.js +63 -16
- package/dist/webinar/media-protocol.d.ts +3 -2
- package/dist/webinar/media-protocol.js +28 -6
- package/dist/webinar/media.js +11 -5
- package/dist/webinar/parse.js +59 -17
- package/dist/webinar/playback.d.ts +1 -0
- package/dist/webinar/playback.js +49 -13
- package/dist/webinar/socket.js +4 -1
- package/dist/webinar/state.js +73 -26
- package/dist/webinar/types.d.ts +14 -1
- package/dist/webinar/types.js +3 -1
- package/dist/webinar/typing.d.ts +8 -0
- package/dist/webinar/typing.js +36 -0
- package/docs/fixture-review.md +44 -44
- package/docs/student-portal.md +11 -2
- package/docs/v5-migration.md +85 -88
- package/docs/webinar.md +38 -6
- package/package.json +1 -1
package/dist/tt/client.js
CHANGED
|
@@ -71,7 +71,8 @@ export class TimetableClient {
|
|
|
71
71
|
loginMode = null;
|
|
72
72
|
timetableContexts = new Map();
|
|
73
73
|
constructor(opts) {
|
|
74
|
-
this.educationLevel =
|
|
74
|
+
this.educationLevel =
|
|
75
|
+
opts?.educationLevel ?? EducationLevel.HigherEducation;
|
|
75
76
|
if (this.educationLevel !== EducationLevel.HigherEducation &&
|
|
76
77
|
this.educationLevel !== EducationLevel.VocationalEducation) {
|
|
77
78
|
throw new RangeError("Invalid education level");
|
|
@@ -302,7 +303,7 @@ export class TimetableClient {
|
|
|
302
303
|
const ownerName = owner.type === "group"
|
|
303
304
|
? parseGroupName(html)
|
|
304
305
|
: owner.type === "teacher"
|
|
305
|
-
? parseTeacherInfo(html)?.name ?? null
|
|
306
|
+
? (parseTeacherInfo(html)?.name ?? null)
|
|
306
307
|
: parseRoomName(html);
|
|
307
308
|
if (!ownerName) {
|
|
308
309
|
throw new ParseError(`TT ${owner.type} schedule response has no owner name`);
|
|
@@ -355,7 +356,9 @@ export class TimetableClient {
|
|
|
355
356
|
}
|
|
356
357
|
async getSchedule(owner, options) {
|
|
357
358
|
const ownerUrl = this.ownerUrl(owner);
|
|
358
|
-
const requestedPeriods = options?.periods
|
|
359
|
+
const requestedPeriods = options?.periods
|
|
360
|
+
? normalizePeriods(options.periods)
|
|
361
|
+
: null;
|
|
359
362
|
await this.ensureRepository();
|
|
360
363
|
if (owner.type === "group" && owner.group.name.trim()) {
|
|
361
364
|
await this.rememberGroups([owner.group]);
|
|
@@ -390,7 +393,10 @@ export class TimetableClient {
|
|
|
390
393
|
async getGroupSchedule(groupId, options) {
|
|
391
394
|
return this.getSchedule({
|
|
392
395
|
type: "group",
|
|
393
|
-
group: this._repository.directory.resolveGroup({
|
|
396
|
+
group: this._repository.directory.resolveGroup({
|
|
397
|
+
id: groupId,
|
|
398
|
+
name: "",
|
|
399
|
+
}),
|
|
394
400
|
}, options);
|
|
395
401
|
}
|
|
396
402
|
// --- Search / Discovery ---
|
|
@@ -623,7 +629,7 @@ export class TimetableClient {
|
|
|
623
629
|
}
|
|
624
630
|
async getCachedRoomImage(cacheKey, fetchUrl) {
|
|
625
631
|
const cached = this.cache?.getLocal("roomImages", cacheKey) ??
|
|
626
|
-
await this.cache?.get("roomImages", cacheKey);
|
|
632
|
+
(await this.cache?.get("roomImages", cacheKey));
|
|
627
633
|
if (cached !== null && cached !== undefined) {
|
|
628
634
|
const entry = cached;
|
|
629
635
|
if (entry.data !== undefined) {
|
|
@@ -786,7 +792,7 @@ export class TimetableClient {
|
|
|
786
792
|
requirePositiveId(teacherId, "Teacher ID");
|
|
787
793
|
const photoCacheKey = String(teacherId);
|
|
788
794
|
const cachedPhoto = this.cache?.getLocal("teacherPhotos", photoCacheKey) ??
|
|
789
|
-
await this.cache?.get("teacherPhotos", photoCacheKey);
|
|
795
|
+
(await this.cache?.get("teacherPhotos", photoCacheKey));
|
|
790
796
|
if (cachedPhoto !== null && cachedPhoto !== undefined) {
|
|
791
797
|
const entry = cachedPhoto;
|
|
792
798
|
if (entry.data !== undefined) {
|
|
@@ -816,7 +822,9 @@ export class TimetableClient {
|
|
|
816
822
|
await this.blobAdapter.put(blobKey, photoBuffer, {
|
|
817
823
|
ttl: this.cache?.ttl("teacherPhotos"),
|
|
818
824
|
});
|
|
819
|
-
await this.cache?.setExternal("teacherPhotos", photoCacheKey, {
|
|
825
|
+
await this.cache?.setExternal("teacherPhotos", photoCacheKey, {
|
|
826
|
+
blobKey,
|
|
827
|
+
});
|
|
820
828
|
}
|
|
821
829
|
else {
|
|
822
830
|
await this.cache?.set("teacherPhotos", photoCacheKey, {
|
|
@@ -65,8 +65,7 @@ class EntityIndex {
|
|
|
65
65
|
let record = value.id == null ? undefined : this.byId.get(value.id);
|
|
66
66
|
record ??= this.byName.get(name);
|
|
67
67
|
if (!record && this.teacherIdentity) {
|
|
68
|
-
const identified = [...(this.byPerson.get(person) ?? [])]
|
|
69
|
-
.filter((candidate) => candidate.value.id != null);
|
|
68
|
+
const identified = [...(this.byPerson.get(person) ?? [])].filter((candidate) => candidate.value.id != null);
|
|
70
69
|
const ids = new Set(identified.map((candidate) => candidate.value.id));
|
|
71
70
|
if (ids.size === 1)
|
|
72
71
|
record = identified[0];
|
|
@@ -109,8 +108,7 @@ class EntityIndex {
|
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
110
|
mergeTeacherAliases(target, person) {
|
|
112
|
-
const aliases = [...(this.byPerson.get(person) ?? [])]
|
|
113
|
-
.filter((candidate) => candidate !== target && candidate.value.id == null);
|
|
111
|
+
const aliases = [...(this.byPerson.get(person) ?? [])].filter((candidate) => candidate !== target && candidate.value.id == null);
|
|
114
112
|
for (const alias of aliases)
|
|
115
113
|
this.mergeRecords(target, alias);
|
|
116
114
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { RandomLessonIdGenerator, occurrenceIdForSeries, migrateLegacyLessonId } from "./ids.js";
|
|
2
|
-
export { ScheduleSnapshot, createScheduleSnapshot, SCHEDULE_SNAPSHOT_SCHEMA_VERSION } from "./schedule-snapshot.js";
|
|
1
|
+
export { RandomLessonIdGenerator, occurrenceIdForSeries, migrateLegacyLessonId, } from "./ids.js";
|
|
2
|
+
export { ScheduleSnapshot, createScheduleSnapshot, SCHEDULE_SNAPSHOT_SCHEMA_VERSION, } from "./schedule-snapshot.js";
|
|
3
3
|
export type { SerializedScheduleSnapshot } from "./schedule-snapshot.js";
|
|
4
4
|
export { TimetableDirectory } from "./directory.js";
|
|
5
5
|
export { entityKey, mergeEntityRefs, mergeGroups, mergeRooms, mergeTeachers, normalizeScheduleText, } from "./normalize.js";
|
package/dist/tt/domain/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { RandomLessonIdGenerator, occurrenceIdForSeries, migrateLegacyLessonId } from "./ids.js";
|
|
2
|
-
export { ScheduleSnapshot, createScheduleSnapshot, SCHEDULE_SNAPSHOT_SCHEMA_VERSION } from "./schedule-snapshot.js";
|
|
1
|
+
export { RandomLessonIdGenerator, occurrenceIdForSeries, migrateLegacyLessonId, } from "./ids.js";
|
|
2
|
+
export { ScheduleSnapshot, createScheduleSnapshot, SCHEDULE_SNAPSHOT_SCHEMA_VERSION, } from "./schedule-snapshot.js";
|
|
3
3
|
export { TimetableDirectory } from "./directory.js";
|
|
4
4
|
export { entityKey, mergeEntityRefs, mergeGroups, mergeRooms, mergeTeachers, normalizeScheduleText, } from "./normalize.js";
|
|
5
5
|
export { MemoryTimetableRepositoryAdapter, TimetableRepository, } from "./repository.js";
|
|
@@ -39,10 +39,10 @@ function recurrenceWeeks(observation) {
|
|
|
39
39
|
return weeks.join(",");
|
|
40
40
|
}
|
|
41
41
|
function sameTimeRange(left, right) {
|
|
42
|
-
return left.start.hours === right.start.hours &&
|
|
42
|
+
return (left.start.hours === right.start.hours &&
|
|
43
43
|
left.start.minutes === right.start.minutes &&
|
|
44
44
|
left.end.hours === right.end.hours &&
|
|
45
|
-
left.end.minutes === right.end.minutes;
|
|
45
|
+
left.end.minutes === right.end.minutes);
|
|
46
46
|
}
|
|
47
47
|
function valuesOverlap(left, right) {
|
|
48
48
|
if (!left?.length || !right?.length)
|
|
@@ -99,9 +99,7 @@ function observationScore(left, right, sameSource, directory) {
|
|
|
99
99
|
right.slotNumber != null &&
|
|
100
100
|
left.slotNumber === right.slotNumber)
|
|
101
101
|
score += 12;
|
|
102
|
-
if (left.time &&
|
|
103
|
-
right.time &&
|
|
104
|
-
sameTimeRange(left.time, right.time)) {
|
|
102
|
+
if (left.time && right.time && sameTimeRange(left.time, right.time)) {
|
|
105
103
|
score += 12;
|
|
106
104
|
}
|
|
107
105
|
if (left.kind === "series" && right.kind === "series") {
|
|
@@ -152,11 +150,11 @@ function deserializeSource(source) {
|
|
|
152
150
|
};
|
|
153
151
|
}
|
|
154
152
|
function sameSourceContent(left, right) {
|
|
155
|
-
return left.sourceKey === right.sourceKey &&
|
|
153
|
+
return (left.sourceKey === right.sourceKey &&
|
|
156
154
|
left.academicYearStartYear === right.academicYearStartYear &&
|
|
157
155
|
left.period === right.period &&
|
|
158
156
|
JSON.stringify(left.owner) === JSON.stringify(right.owner) &&
|
|
159
|
-
JSON.stringify(left.observations) === JSON.stringify(right.observations);
|
|
157
|
+
JSON.stringify(left.observations) === JSON.stringify(right.observations));
|
|
160
158
|
}
|
|
161
159
|
function sourceRef(claim) {
|
|
162
160
|
return {
|
|
@@ -418,7 +416,8 @@ export class TimetableRepository {
|
|
|
418
416
|
lessonIds,
|
|
419
417
|
created,
|
|
420
418
|
updated,
|
|
421
|
-
removedObservations: Math.max(0, prior?.observations.filter((value) => !currentKeys.has(value.key))
|
|
419
|
+
removedObservations: Math.max(0, prior?.observations.filter((value) => !currentKeys.has(value.key))
|
|
420
|
+
.length ?? 0),
|
|
422
421
|
};
|
|
423
422
|
}
|
|
424
423
|
getSeries(opts) {
|
|
@@ -460,7 +459,8 @@ export class TimetableRepository {
|
|
|
460
459
|
values.push(value);
|
|
461
460
|
}
|
|
462
461
|
return values.sort((a, b) => a.scheduledDate.localeCompare(b.scheduledDate) ||
|
|
463
|
-
(
|
|
462
|
+
(a.time?.start.hours ?? 24) * 60 +
|
|
463
|
+
(a.time?.start.minutes ?? 0) -
|
|
464
464
|
((b.time?.start.hours ?? 24) * 60 + (b.time?.start.minutes ?? 0)) ||
|
|
465
465
|
a.id.localeCompare(b.id));
|
|
466
466
|
}
|
|
@@ -494,11 +494,14 @@ export class TimetableRepository {
|
|
|
494
494
|
teachers: mergeTeachers(tracker.teachers),
|
|
495
495
|
rooms: mergeRooms(tracker.rooms),
|
|
496
496
|
},
|
|
497
|
-
sourceReplacements: [...tracker.sourceKeys]
|
|
497
|
+
sourceReplacements: [...tracker.sourceKeys]
|
|
498
|
+
.sort()
|
|
499
|
+
.flatMap((sourceKey) => {
|
|
498
500
|
const source = this.sources.get(sourceKey);
|
|
499
501
|
if (!source)
|
|
500
502
|
return [];
|
|
501
|
-
return [
|
|
503
|
+
return [
|
|
504
|
+
{
|
|
502
505
|
source: serializeSource(source),
|
|
503
506
|
links: source.observations.map((observation) => {
|
|
504
507
|
const link = this.links.get(sourceObservationKey(sourceKey, observation.key));
|
|
@@ -507,7 +510,8 @@ export class TimetableRepository {
|
|
|
507
510
|
}
|
|
508
511
|
return { observationKey: observation.key, ...link };
|
|
509
512
|
}),
|
|
510
|
-
}
|
|
513
|
+
},
|
|
514
|
+
];
|
|
511
515
|
}),
|
|
512
516
|
};
|
|
513
517
|
}
|
|
@@ -571,10 +575,12 @@ export class TimetableRepository {
|
|
|
571
575
|
if (!Number.isInteger(source.academicYearStartYear)) {
|
|
572
576
|
throw new Error(`Invalid academic year for source ${source.sourceKey}`);
|
|
573
577
|
}
|
|
574
|
-
if (!Number.isInteger(source.period) ||
|
|
578
|
+
if (!Number.isInteger(source.period) ||
|
|
579
|
+
!Object.values(AcademicPeriod).includes(source.period)) {
|
|
575
580
|
throw new Error(`Invalid academic period for source ${source.sourceKey}`);
|
|
576
581
|
}
|
|
577
|
-
if (!(source.observedAt instanceof Date) ||
|
|
582
|
+
if (!(source.observedAt instanceof Date) ||
|
|
583
|
+
!Number.isFinite(source.observedAt.getTime())) {
|
|
578
584
|
throw new Error(`Invalid observation time for source ${source.sourceKey}`);
|
|
579
585
|
}
|
|
580
586
|
const validateRef = (value, label) => {
|
|
@@ -599,7 +605,11 @@ export class TimetableRepository {
|
|
|
599
605
|
throw new Error(`Empty lesson subject in ${source.sourceKey}/${observation.key}`);
|
|
600
606
|
}
|
|
601
607
|
const relations = [
|
|
602
|
-
[
|
|
608
|
+
[
|
|
609
|
+
"group",
|
|
610
|
+
observation.groups,
|
|
611
|
+
observation.groups.values.map((value) => value.group),
|
|
612
|
+
],
|
|
603
613
|
["teacher", observation.teachers, observation.teachers.values],
|
|
604
614
|
["room", observation.rooms, observation.rooms.values],
|
|
605
615
|
];
|
|
@@ -614,15 +624,22 @@ export class TimetableRepository {
|
|
|
614
624
|
validateRef(value, label);
|
|
615
625
|
}
|
|
616
626
|
if (observation.slotNumber != null &&
|
|
617
|
-
(!Number.isInteger(observation.slotNumber) ||
|
|
627
|
+
(!Number.isInteger(observation.slotNumber) ||
|
|
628
|
+
observation.slotNumber < 1)) {
|
|
618
629
|
throw new Error(`Invalid slot number in ${source.sourceKey}/${observation.key}`);
|
|
619
630
|
}
|
|
620
631
|
if (observation.time) {
|
|
621
632
|
const start = observation.time.start.hours * 60 + observation.time.start.minutes;
|
|
622
633
|
const end = observation.time.end.hours * 60 + observation.time.end.minutes;
|
|
623
|
-
const validPart = (value) => Number.isInteger(value.hours) &&
|
|
624
|
-
|
|
625
|
-
|
|
634
|
+
const validPart = (value) => Number.isInteger(value.hours) &&
|
|
635
|
+
value.hours >= 0 &&
|
|
636
|
+
value.hours <= 23 &&
|
|
637
|
+
Number.isInteger(value.minutes) &&
|
|
638
|
+
value.minutes >= 0 &&
|
|
639
|
+
value.minutes <= 59;
|
|
640
|
+
if (!validPart(observation.time.start) ||
|
|
641
|
+
!validPart(observation.time.end) ||
|
|
642
|
+
end <= start) {
|
|
626
643
|
throw new Error(`Invalid lesson time in ${source.sourceKey}/${observation.key}`);
|
|
627
644
|
}
|
|
628
645
|
}
|
|
@@ -640,8 +657,11 @@ export class TimetableRepository {
|
|
|
640
657
|
if (!Number.isInteger(weekday) || weekday < 0 || weekday > 6) {
|
|
641
658
|
throw new Error(`Invalid recurrence weekday in ${source.sourceKey}/${observation.key}`);
|
|
642
659
|
}
|
|
643
|
-
if (weeks &&
|
|
644
|
-
|
|
660
|
+
if (weeks &&
|
|
661
|
+
(!Number.isInteger(weeks.from) ||
|
|
662
|
+
!Number.isInteger(weeks.to) ||
|
|
663
|
+
weeks.from < 1 ||
|
|
664
|
+
weeks.to < weeks.from)) {
|
|
645
665
|
throw new Error(`Invalid recurrence weeks in ${source.sourceKey}/${observation.key}`);
|
|
646
666
|
}
|
|
647
667
|
}
|
|
@@ -649,10 +669,11 @@ export class TimetableRepository {
|
|
|
649
669
|
if (!isLocalDate(observation.date)) {
|
|
650
670
|
throw new Error(`Invalid lesson date in ${source.sourceKey}/${observation.key}`);
|
|
651
671
|
}
|
|
652
|
-
if (observation.transfer &&
|
|
653
|
-
!isLocalDate(observation.transfer.
|
|
654
|
-
|
|
655
|
-
|
|
672
|
+
if (observation.transfer &&
|
|
673
|
+
(!isLocalDate(observation.transfer.fromDate) ||
|
|
674
|
+
!isLocalDate(observation.transfer.targetDate) ||
|
|
675
|
+
!Number.isInteger(observation.transfer.fromSlot) ||
|
|
676
|
+
observation.transfer.fromSlot < 1)) {
|
|
656
677
|
throw new Error(`Invalid lesson transfer in ${source.sourceKey}/${observation.key}`);
|
|
657
678
|
}
|
|
658
679
|
}
|
|
@@ -715,7 +736,12 @@ export class TimetableRepository {
|
|
|
715
736
|
if (link.kind === "series" && observation.kind === "series") {
|
|
716
737
|
let record = this.seriesRecords.get(link.id);
|
|
717
738
|
if (!record) {
|
|
718
|
-
record = {
|
|
739
|
+
record = {
|
|
740
|
+
id: link.id,
|
|
741
|
+
claims: new Map(),
|
|
742
|
+
bucketKey,
|
|
743
|
+
ownerKeys: new Set(),
|
|
744
|
+
};
|
|
719
745
|
this.seriesRecords.set(link.id, record);
|
|
720
746
|
this.addRecordToBucket(record);
|
|
721
747
|
}
|
|
@@ -728,7 +754,12 @@ export class TimetableRepository {
|
|
|
728
754
|
if (link.kind === "occurrence" && observation.kind === "occurrence") {
|
|
729
755
|
let record = this.occurrenceRecords.get(link.id);
|
|
730
756
|
if (!record) {
|
|
731
|
-
record = {
|
|
757
|
+
record = {
|
|
758
|
+
id: link.id,
|
|
759
|
+
claims: new Map(),
|
|
760
|
+
bucketKey,
|
|
761
|
+
ownerKeys: new Set(),
|
|
762
|
+
};
|
|
732
763
|
this.occurrenceRecords.set(link.id, record);
|
|
733
764
|
this.addRecordToBucket(record);
|
|
734
765
|
}
|
|
@@ -775,8 +806,7 @@ export class TimetableRepository {
|
|
|
775
806
|
continue;
|
|
776
807
|
let recordScore = Number.NEGATIVE_INFINITY;
|
|
777
808
|
for (const claim of record.claims.values()) {
|
|
778
|
-
if (claim.source.academicYearStartYear !==
|
|
779
|
-
source.academicYearStartYear ||
|
|
809
|
+
if (claim.source.academicYearStartYear !== source.academicYearStartYear ||
|
|
780
810
|
claim.source.period !== source.period) {
|
|
781
811
|
continue;
|
|
782
812
|
}
|
|
@@ -902,7 +932,7 @@ export class TimetableRepository {
|
|
|
902
932
|
teachers: teachers.length > 0 ? teachers : undefined,
|
|
903
933
|
isDistance: current?.isDistance === true || substitution.isDistance === true
|
|
904
934
|
? true
|
|
905
|
-
: current?.isDistance ?? substitution.isDistance,
|
|
935
|
+
: (current?.isDistance ?? substitution.isDistance),
|
|
906
936
|
});
|
|
907
937
|
}
|
|
908
938
|
return [...byDate.values()].sort((a, b) => a.date.localeCompare(b.date));
|
|
@@ -940,7 +970,9 @@ export class TimetableRepository {
|
|
|
940
970
|
...relations,
|
|
941
971
|
isDistance: claims.some((value) => value.observation.isDistance === true),
|
|
942
972
|
possibleChanges: claims.some((value) => value.observation.possibleChanges === true),
|
|
943
|
-
...(preferred.observation.retakeAttempt
|
|
973
|
+
...(preferred.observation.retakeAttempt
|
|
974
|
+
? { retakeAttempt: preferred.observation.retakeAttempt }
|
|
975
|
+
: {}),
|
|
944
976
|
substitutions: this.aggregateSubstitutions(claims),
|
|
945
977
|
sources: claims.map(sourceRef),
|
|
946
978
|
};
|
|
@@ -982,7 +1014,9 @@ export class TimetableRepository {
|
|
|
982
1014
|
...relations,
|
|
983
1015
|
isDistance: claims.some((value) => value.observation.isDistance === true),
|
|
984
1016
|
possibleChanges: claims.some((value) => value.observation.possibleChanges === true),
|
|
985
|
-
...(preferred.observation.retakeAttempt
|
|
1017
|
+
...(preferred.observation.retakeAttempt
|
|
1018
|
+
? { retakeAttempt: preferred.observation.retakeAttempt }
|
|
1019
|
+
: {}),
|
|
986
1020
|
status: transfer ? "moved" : "scheduled",
|
|
987
1021
|
movedFrom: transfer
|
|
988
1022
|
? { date: transfer.fromDate, slotNumber: transfer.fromSlot }
|
|
@@ -994,9 +1028,7 @@ export class TimetableRepository {
|
|
|
994
1028
|
export class MemoryTimetableRepositoryAdapter {
|
|
995
1029
|
snapshot = null;
|
|
996
1030
|
async load() {
|
|
997
|
-
return this.snapshot == null
|
|
998
|
-
? null
|
|
999
|
-
: structuredClone(this.snapshot);
|
|
1031
|
+
return this.snapshot == null ? null : structuredClone(this.snapshot);
|
|
1000
1032
|
}
|
|
1001
1033
|
async compareAndSet(expectedRevision, snapshot) {
|
|
1002
1034
|
const currentRevision = this.snapshot?.revision ?? 0;
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
import { formatLocalDate, parseLocalDate, RUSSIAN_HOLIDAYS } from "../utils/index.js";
|
|
2
|
-
import { Schedule } from "./schedule.js";
|
|
1
|
+
import { formatLocalDate, parseLocalDate, RUSSIAN_HOLIDAYS, } from "../utils/index.js";
|
|
2
|
+
import { Schedule, } from "./schedule.js";
|
|
3
3
|
export const SCHEDULE_SNAPSHOT_SCHEMA_VERSION = 3;
|
|
4
4
|
function serializeSources(sources, include) {
|
|
5
5
|
return include
|
|
6
|
-
? sources.map((source) => ({
|
|
6
|
+
? sources.map((source) => ({
|
|
7
|
+
...structuredClone(source),
|
|
8
|
+
observedAt: source.observedAt.toISOString(),
|
|
9
|
+
}))
|
|
7
10
|
: [];
|
|
8
11
|
}
|
|
9
12
|
function deserializeSources(sources) {
|
|
10
|
-
return sources.map((source) => ({
|
|
13
|
+
return sources.map((source) => ({
|
|
14
|
+
...structuredClone(source),
|
|
15
|
+
observedAt: new Date(source.observedAt),
|
|
16
|
+
}));
|
|
11
17
|
}
|
|
12
18
|
function usesDefaultHolidays(holidays) {
|
|
13
|
-
return holidays.length === RUSSIAN_HOLIDAYS.length &&
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
return (holidays.length === RUSSIAN_HOLIDAYS.length &&
|
|
20
|
+
holidays.every((holiday, index) => {
|
|
21
|
+
const standard = RUSSIAN_HOLIDAYS[index];
|
|
22
|
+
return (holiday.month === standard.month &&
|
|
23
|
+
holiday.day === standard.day &&
|
|
24
|
+
holiday.name === standard.name);
|
|
25
|
+
}));
|
|
17
26
|
}
|
|
18
27
|
/** Browser-ready schedule backed by recurring rules and dated exceptions. */
|
|
19
28
|
export class ScheduleSnapshot extends Schedule {
|
|
@@ -26,10 +35,12 @@ export class ScheduleSnapshot extends Schedule {
|
|
|
26
35
|
throw new Error(`Unsupported schedule snapshot schema: ${snapshot.schemaVersion}`);
|
|
27
36
|
}
|
|
28
37
|
const series = snapshot.series.map((value) => ({
|
|
29
|
-
...structuredClone(value),
|
|
38
|
+
...structuredClone(value),
|
|
39
|
+
sources: deserializeSources(value.sources),
|
|
30
40
|
}));
|
|
31
41
|
const direct = snapshot.direct.map((value) => ({
|
|
32
|
-
...structuredClone(value),
|
|
42
|
+
...structuredClone(value),
|
|
43
|
+
sources: deserializeSources(value.sources),
|
|
33
44
|
}));
|
|
34
45
|
const options = {
|
|
35
46
|
period: snapshot.period,
|
|
@@ -44,14 +55,20 @@ export class ScheduleSnapshot extends Schedule {
|
|
|
44
55
|
this.snapshotDirect = direct;
|
|
45
56
|
this.snapshot = structuredClone(snapshot);
|
|
46
57
|
}
|
|
47
|
-
get revision() {
|
|
58
|
+
get revision() {
|
|
59
|
+
return this.snapshot.repositoryRevision;
|
|
60
|
+
}
|
|
48
61
|
queryData() {
|
|
49
62
|
return { series: this.snapshotSeries, direct: this.snapshotDirect };
|
|
50
63
|
}
|
|
51
|
-
export() {
|
|
64
|
+
export() {
|
|
65
|
+
return structuredClone(this.snapshot);
|
|
66
|
+
}
|
|
52
67
|
on(date, options) {
|
|
53
68
|
const key = formatLocalDate(date);
|
|
54
|
-
return key < this.snapshot.start || key > this.snapshot.end
|
|
69
|
+
return key < this.snapshot.start || key > this.snapshot.end
|
|
70
|
+
? []
|
|
71
|
+
: super.on(date, options);
|
|
55
72
|
}
|
|
56
73
|
dateKeys(options) {
|
|
57
74
|
const subgroup = options?.subgroup;
|
|
@@ -69,8 +86,12 @@ export class ScheduleSnapshot extends Schedule {
|
|
|
69
86
|
}
|
|
70
87
|
}
|
|
71
88
|
export function createScheduleSnapshot(schedule, options) {
|
|
72
|
-
const start = options?.start == null
|
|
73
|
-
|
|
89
|
+
const start = options?.start == null
|
|
90
|
+
? new Date(schedule.academicYearStartYear, 8, 1)
|
|
91
|
+
: new Date(options.start);
|
|
92
|
+
const end = options?.end == null
|
|
93
|
+
? new Date(schedule.academicYearStartYear + 1, 7, 31)
|
|
94
|
+
: new Date(options.end);
|
|
74
95
|
if (!Number.isFinite(start.getTime()) || !Number.isFinite(end.getTime())) {
|
|
75
96
|
throw new RangeError("Schedule snapshot range contains an invalid date");
|
|
76
97
|
}
|
|
@@ -78,10 +99,12 @@ export function createScheduleSnapshot(schedule, options) {
|
|
|
78
99
|
throw new RangeError("Schedule snapshot start must not exceed end");
|
|
79
100
|
const includeSources = options?.includeSources !== false;
|
|
80
101
|
const series = schedule.series().map((value) => ({
|
|
81
|
-
...value,
|
|
102
|
+
...value,
|
|
103
|
+
sources: serializeSources(value.sources, includeSources),
|
|
82
104
|
}));
|
|
83
105
|
const direct = schedule.directOccurrences().map((value) => ({
|
|
84
|
-
...value,
|
|
106
|
+
...value,
|
|
107
|
+
sources: serializeSources(value.sources, includeSources),
|
|
85
108
|
}));
|
|
86
109
|
return {
|
|
87
110
|
schemaVersion: SCHEDULE_SNAPSHOT_SCHEMA_VERSION,
|
|
@@ -93,12 +116,16 @@ export function createScheduleSnapshot(schedule, options) {
|
|
|
93
116
|
end: formatLocalDate(end),
|
|
94
117
|
series,
|
|
95
118
|
direct,
|
|
96
|
-
...(!usesDefaultHolidays(schedule.holidays)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
119
|
+
...(!usesDefaultHolidays(schedule.holidays)
|
|
120
|
+
? { holidays: structuredClone(schedule.holidays) }
|
|
121
|
+
: {}),
|
|
122
|
+
...(schedule.holidayTransfers.length
|
|
123
|
+
? {
|
|
124
|
+
holidayTransfers: schedule.holidayTransfers.map((value) => ({
|
|
125
|
+
dayOff: value.dayOff.toISOString(),
|
|
126
|
+
workDay: value.workDay?.toISOString() ?? null,
|
|
127
|
+
})),
|
|
128
|
+
}
|
|
129
|
+
: {}),
|
|
103
130
|
};
|
|
104
131
|
}
|
|
@@ -63,8 +63,10 @@ function attendanceOverlaps(left, right) {
|
|
|
63
63
|
}
|
|
64
64
|
function sortOccurrences(left, right) {
|
|
65
65
|
return (left.scheduledDate.localeCompare(right.scheduledDate) ||
|
|
66
|
-
(
|
|
67
|
-
(
|
|
66
|
+
(left.time?.start.hours ?? 24) * 60 +
|
|
67
|
+
(left.time?.start.minutes ?? 0) -
|
|
68
|
+
((right.time?.start.hours ?? 24) * 60 +
|
|
69
|
+
(right.time?.start.minutes ?? 0)) ||
|
|
68
70
|
(left.slotNumber ?? Number.MAX_SAFE_INTEGER) -
|
|
69
71
|
(right.slotNumber ?? Number.MAX_SAFE_INTEGER) ||
|
|
70
72
|
left.subject.localeCompare(right.subject) ||
|
|
@@ -182,7 +184,9 @@ export class Schedule {
|
|
|
182
184
|
rooms,
|
|
183
185
|
isDistance,
|
|
184
186
|
possibleChanges: series.possibleChanges,
|
|
185
|
-
...(series.retakeAttempt
|
|
187
|
+
...(series.retakeAttempt
|
|
188
|
+
? { retakeAttempt: series.retakeAttempt }
|
|
189
|
+
: {}),
|
|
186
190
|
status: "scheduled",
|
|
187
191
|
originalRooms,
|
|
188
192
|
originalTeachers,
|
package/dist/tt/observations.js
CHANGED
|
@@ -17,7 +17,11 @@ function teacherRef(value) {
|
|
|
17
17
|
function relationSet(values, explicitlyEmpty = false) {
|
|
18
18
|
return {
|
|
19
19
|
values: values ?? [],
|
|
20
|
-
completeness: explicitlyEmpty
|
|
20
|
+
completeness: explicitlyEmpty
|
|
21
|
+
? "complete"
|
|
22
|
+
: values?.length
|
|
23
|
+
? "partial"
|
|
24
|
+
: "unknown",
|
|
21
25
|
};
|
|
22
26
|
}
|
|
23
27
|
function groupsFor(entry, owner) {
|
|
@@ -25,7 +29,8 @@ function groupsFor(entry, owner) {
|
|
|
25
29
|
group: { name },
|
|
26
30
|
subgroup: entry.subgroup,
|
|
27
31
|
})) ?? [];
|
|
28
|
-
const groups = relationSet(visible, entry.groups === null ||
|
|
32
|
+
const groups = relationSet(visible, entry.groups === null ||
|
|
33
|
+
(Array.isArray(entry.groups) && entry.groups.length === 0));
|
|
29
34
|
if (owner.type === "group") {
|
|
30
35
|
groups.values.unshift({ group: owner.group, subgroup: entry.subgroup });
|
|
31
36
|
if (groups.completeness === "unknown")
|
|
@@ -168,7 +168,9 @@ function parseRoomSessionEntry(td) {
|
|
|
168
168
|
lesson: {
|
|
169
169
|
subject,
|
|
170
170
|
type: parseLessonTypeAfterSubject(subjectEl).toLowerCase(),
|
|
171
|
-
teacher: teacherLine
|
|
171
|
+
teacher: teacherLine
|
|
172
|
+
? parseTeacher(stripDistanceMarker(teacherLine))
|
|
173
|
+
: undefined,
|
|
172
174
|
groups: groups.length > 0 ? groups : undefined,
|
|
173
175
|
subgroup: subgroupMatch ? parseInt(subgroupMatch[1]) : undefined,
|
|
174
176
|
isDistance: hasDistanceMarker(plainText),
|
|
@@ -69,9 +69,8 @@ export function parseLessonTypeAfterSubject(subjectElement) {
|
|
|
69
69
|
break;
|
|
70
70
|
suffix += sibling.textContent ?? "";
|
|
71
71
|
}
|
|
72
|
-
const candidate = suffix.match(LEADING_PARENTHESIZED_RE)?.[1]
|
|
73
|
-
|
|
74
|
-
.replace(/\.$/, "") ?? "";
|
|
72
|
+
const candidate = suffix.match(LEADING_PARENTHESIZED_RE)?.[1]?.trim().replace(/\.$/, "") ??
|
|
73
|
+
"";
|
|
75
74
|
if (!candidate ||
|
|
76
75
|
WEEK_METADATA_RE.test(candidate) ||
|
|
77
76
|
SUBGROUP_METADATA_RE.test(candidate) ||
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseHtml, parseTeacher, parseTime, parseWeekParity, parseWeeks, text, } from "../../common/parse.js";
|
|
2
|
-
import { parseSubstitutionDiv, parseTransferDiv
|
|
2
|
+
import { parseSubstitutionDiv, parseTransferDiv } from "./overlays.js";
|
|
3
3
|
import { SUBGROUP_RE, WEEKS_RE } from "./patterns.js";
|
|
4
4
|
import { hasDistanceMarker, containsGroupCode, linesAfterSubject, parseLessonTypeAfterSubject, parseEntryRoom, parseRetakeAttempt, stripDistanceMarker, stripHtml, } from "./entry-parts.js";
|
|
5
5
|
export function parseGroupSchedule(html) {
|
package/dist/tt/parse/groups.js
CHANGED
|
@@ -16,9 +16,7 @@ import { SUBGROUP_ANNOTATION_RE_I } from "./patterns.js";
|
|
|
16
16
|
export function parseGroupsString(raw) {
|
|
17
17
|
if (!raw)
|
|
18
18
|
return [];
|
|
19
|
-
const cleaned = raw
|
|
20
|
-
.replace(SUBGROUP_ANNOTATION_RE_I, " ")
|
|
21
|
-
.trim();
|
|
19
|
+
const cleaned = raw.replace(SUBGROUP_ANNOTATION_RE_I, " ").trim();
|
|
22
20
|
if (!cleaned)
|
|
23
21
|
return [];
|
|
24
22
|
const out = [];
|
package/dist/tt/parse/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { parseGroupsString } from "./groups.js";
|
|
2
2
|
export { parseAcademicYearFromPage, parseAvailablePeriodsFromPage, parseRoomButtons, parseRoomName, parseFacultyButtons, parseGroupButtons, parseGroupName, parsePeriodFromPage, parseTeacherButtons, } from "./lists.js";
|
|
3
3
|
export { parseGroupSchedule } from "./full-schedule.js";
|
|
4
|
-
export { parseRoomSchedule, parseRoomInfo
|
|
5
|
-
export { parseTeacherSchedule, parseTeacherInfo
|
|
4
|
+
export { parseRoomSchedule, parseRoomInfo } from "./audience.js";
|
|
5
|
+
export { parseTeacherSchedule, parseTeacherInfo } from "./teacher.js";
|
package/dist/tt/parse/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { parseGroupsString } from "./groups.js";
|
|
2
2
|
export { parseAcademicYearFromPage, parseAvailablePeriodsFromPage, parseRoomButtons, parseRoomName, parseFacultyButtons, parseGroupButtons, parseGroupName, parsePeriodFromPage, parseTeacherButtons, } from "./lists.js";
|
|
3
3
|
export { parseGroupSchedule } from "./full-schedule.js";
|
|
4
|
-
export { parseRoomSchedule, parseRoomInfo
|
|
5
|
-
export { parseTeacherSchedule, parseTeacherInfo
|
|
4
|
+
export { parseRoomSchedule, parseRoomInfo } from "./audience.js";
|
|
5
|
+
export { parseTeacherSchedule, parseTeacherInfo } from "./teacher.js";
|
package/dist/tt/parse/lists.js
CHANGED
|
@@ -5,8 +5,8 @@ const PERIOD_LABELS = {
|
|
|
5
5
|
"зимняя сессия": 2,
|
|
6
6
|
"весенний семестр": 3,
|
|
7
7
|
"летняя сессия": 4,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
гиа: AcademicPeriod.StateFinalAssessment,
|
|
9
|
+
ппа: AcademicPeriod.Retake,
|
|
10
10
|
};
|
|
11
11
|
const KNOWN_PERIODS = new Set(Object.values(AcademicPeriod).filter((value) => typeof value === "number"));
|
|
12
12
|
/** Period tabs exposed by this timetable page, in portal order. */
|
|
@@ -29,7 +29,7 @@ export function parsePeriodFromPage(html) {
|
|
|
29
29
|
return checkedValue;
|
|
30
30
|
}
|
|
31
31
|
// Some pages keep the selected period only in the hidden form field.
|
|
32
|
-
const hiddenValue = Number(doc.querySelector(
|
|
32
|
+
const hiddenValue = Number(doc.querySelector("#htype")?.getAttribute("value"));
|
|
33
33
|
if (KNOWN_PERIODS.has(hiddenValue)) {
|
|
34
34
|
return hiddenValue;
|
|
35
35
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseTeacher, text } from "../../common/parse.js";
|
|
2
2
|
import { parseGroupsString } from "./groups.js";
|
|
3
3
|
import { containsGroupCode, hasDistanceMarker, linesAfterSubject, stripDistanceMarker, } from "./entry-parts.js";
|
|
4
|
-
import { LESSON_TYPE_RE, LESSON_TYPE_RE_I, SUBGROUP_RE
|
|
4
|
+
import { LESSON_TYPE_RE, LESSON_TYPE_RE_I, SUBGROUP_RE } from "./patterns.js";
|
|
5
5
|
const GROUP_CODE_RE = /[A-ZА-ЯЁ]{1,}(?:-[A-ZА-ЯЁa-zа-яё0-9]+)+/u;
|
|
6
6
|
const ROOM_CODE_RE = /^[А-Яа-яA-Za-z]-\d+$/u;
|
|
7
7
|
const BLUE_SPAN_RE = /<span\b(?=[^>]*(?:style=["'][^"']*color:\s*blue|class=["'][^"']*\bblue\b))[^>]*>([^<]+)<\/span>/i;
|
|
@@ -84,7 +84,12 @@ export function parseSubstitutionDiv(div) {
|
|
|
84
84
|
const teacherMatch = divHtml.match(/Преподаватель:\s*<span[^>]*>([^<]+)<\/span>/);
|
|
85
85
|
if (teacherMatch)
|
|
86
86
|
teacher = parseTeacher(teacherMatch[1].trim());
|
|
87
|
-
return {
|
|
87
|
+
return {
|
|
88
|
+
date,
|
|
89
|
+
room,
|
|
90
|
+
teacher,
|
|
91
|
+
isDistance: hasDistanceMarker(room ?? divText),
|
|
92
|
+
};
|
|
88
93
|
}
|
|
89
94
|
export function parseSubstituteForDiv(div) {
|
|
90
95
|
const divText = text(div);
|
package/dist/tt/utils/date.js
CHANGED
|
@@ -44,9 +44,9 @@ export function isLocalDate(value) {
|
|
|
44
44
|
const month = Number(match[2]);
|
|
45
45
|
const day = Number(match[3]);
|
|
46
46
|
const date = new Date(year, month - 1, day);
|
|
47
|
-
return date.getFullYear() === year &&
|
|
47
|
+
return (date.getFullYear() === year &&
|
|
48
48
|
date.getMonth() === month - 1 &&
|
|
49
|
-
date.getDate() === day;
|
|
49
|
+
date.getDate() === day);
|
|
50
50
|
}
|
|
51
51
|
export function parseLocalDate(value) {
|
|
52
52
|
if (!isLocalDate(value))
|