chuvsu-js 2.1.1 → 2.2.1
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/LICENSE +20 -20
- package/dist/common/http.d.ts +1 -0
- package/dist/common/http.js +9 -0
- package/dist/lk/client.d.ts +1 -0
- package/dist/lk/client.js +3 -0
- package/dist/tt/schedule.js +7 -7
- package/dist/tt/utils.d.ts +1 -0
- package/dist/tt/utils.js +78 -15
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Artemy Egorov
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Artemy Egorov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/dist/common/http.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ export declare class HttpClient {
|
|
|
8
8
|
private cookieHeader;
|
|
9
9
|
private saveCookies;
|
|
10
10
|
get(url: string, followRedirects?: boolean): Promise<HttpResponse>;
|
|
11
|
+
getBuffer(url: string): Promise<Buffer>;
|
|
11
12
|
post(url: string, data: Record<string, string>, followRedirects?: boolean): Promise<HttpResponse>;
|
|
12
13
|
}
|
package/dist/common/http.js
CHANGED
|
@@ -32,6 +32,15 @@ export class HttpClient {
|
|
|
32
32
|
location: res.headers.get("location") ?? undefined,
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
+
async getBuffer(url) {
|
|
36
|
+
const res = await fetch(url, {
|
|
37
|
+
method: "GET",
|
|
38
|
+
headers: { Cookie: this.cookieHeader() },
|
|
39
|
+
dispatcher: agent,
|
|
40
|
+
});
|
|
41
|
+
this.saveCookies(res.headers);
|
|
42
|
+
return Buffer.from(await res.arrayBuffer());
|
|
43
|
+
}
|
|
35
44
|
async post(url, data, followRedirects = true) {
|
|
36
45
|
const body = new URLSearchParams(data).toString();
|
|
37
46
|
const res = await fetch(url, {
|
package/dist/lk/client.d.ts
CHANGED
package/dist/lk/client.js
CHANGED
|
@@ -44,6 +44,9 @@ export class LkClient {
|
|
|
44
44
|
phone: vals.phone ?? "",
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
+
async getPhoto() {
|
|
48
|
+
return this.http.getBuffer(`${STUDENT_BASE}/face.php`);
|
|
49
|
+
}
|
|
47
50
|
async getGroupId() {
|
|
48
51
|
const { body } = await this.authGet(`${STUDENT_BASE}/tt.php`);
|
|
49
52
|
const match = body.match(/tt\.chuvsu\.ru\/index\/grouptt\/gr\/(\d+)/);
|
package/dist/tt/schedule.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCurrentPeriod, isSessionPeriod, getWeekdayName, getMonday, getSemesterStart, getSemesterWeeks, getWeekNumber, getAdjacentSemester, filterSlots, slotsToLessons, } from "./utils.js";
|
|
1
|
+
import { getCurrentPeriod, isSessionPeriod, getWeekdayName, getMonday, getSemesterStart, getSemesterWeeks, getWeekNumber, getAdjacentSemester, filterSlots, slotsToLessons, sortLessons, } from "./utils.js";
|
|
2
2
|
export class Schedule {
|
|
3
3
|
groupId;
|
|
4
4
|
scheduleMap;
|
|
@@ -70,7 +70,7 @@ export class Schedule {
|
|
|
70
70
|
lessons.push(...slotsToLessons(d.slots, d.date));
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
return lessons;
|
|
73
|
+
return lessons.sort(sortLessons);
|
|
74
74
|
}
|
|
75
75
|
const slots = this.getSlotsForWeekday(weekday, days, opts);
|
|
76
76
|
const date = this.getDateForWeekday(weekday, period, opts?.week);
|
|
@@ -103,7 +103,7 @@ export class Schedule {
|
|
|
103
103
|
lessons.push(...slotsToLessons(slots, date));
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
return lessons;
|
|
106
|
+
return lessons.sort(sortLessons);
|
|
107
107
|
}
|
|
108
108
|
forWeek(week, opts) {
|
|
109
109
|
const period = this.period;
|
|
@@ -127,18 +127,18 @@ export class Schedule {
|
|
|
127
127
|
date.setHours(0, 0, 0, 0);
|
|
128
128
|
lessons.push(...this.forDate(date, opts));
|
|
129
129
|
}
|
|
130
|
-
return lessons;
|
|
130
|
+
return lessons.sort(sortLessons);
|
|
131
131
|
}
|
|
132
132
|
today(opts) {
|
|
133
|
-
return this.forDate(new Date(), opts);
|
|
133
|
+
return this.forDate(new Date(), opts).sort(sortLessons);
|
|
134
134
|
}
|
|
135
135
|
tomorrow(opts) {
|
|
136
136
|
const date = new Date();
|
|
137
137
|
date.setDate(date.getDate() + 1);
|
|
138
|
-
return this.forDate(date, opts);
|
|
138
|
+
return this.forDate(date, opts).sort(sortLessons);
|
|
139
139
|
}
|
|
140
140
|
thisWeek(opts) {
|
|
141
|
-
return this.forWeek(undefined, opts);
|
|
141
|
+
return this.forWeek(undefined, opts).sort(sortLessons);
|
|
142
142
|
}
|
|
143
143
|
currentLesson(opts) {
|
|
144
144
|
const now = new Date();
|
package/dist/tt/utils.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare function getCurrentPeriod(opts?: {
|
|
|
5
5
|
date?: Date;
|
|
6
6
|
}): Period;
|
|
7
7
|
export declare function isSessionPeriod(period: Period): boolean;
|
|
8
|
+
export declare function sortLessons(a: Lesson, b: Lesson): number;
|
|
8
9
|
export declare function getWeekdayName(weekday: number): string;
|
|
9
10
|
export declare function getMonday(date: Date): Date;
|
|
10
11
|
/**
|
package/dist/tt/utils.js
CHANGED
|
@@ -17,6 +17,9 @@ export function getCurrentPeriod(opts) {
|
|
|
17
17
|
export function isSessionPeriod(period) {
|
|
18
18
|
return period === 2 /* Period.WinterSession */ || period === 4 /* Period.SummerSession */;
|
|
19
19
|
}
|
|
20
|
+
export function sortLessons(a, b) {
|
|
21
|
+
return a.start.date.getTime() - b.start.date.getTime();
|
|
22
|
+
}
|
|
20
23
|
const WEEKDAY_NAMES = [
|
|
21
24
|
"Воскресенье",
|
|
22
25
|
"Понедельник",
|
|
@@ -143,23 +146,83 @@ export function slotsToLessons(slots, date) {
|
|
|
143
146
|
}
|
|
144
147
|
// --- Lesson time slots ---
|
|
145
148
|
const VO_TIME_SLOTS = [
|
|
146
|
-
{
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
{
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
{
|
|
150
|
+
number: 1,
|
|
151
|
+
start: { hours: 8, minutes: 20 },
|
|
152
|
+
end: { hours: 9, minutes: 40 },
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
number: 2,
|
|
156
|
+
start: { hours: 9, minutes: 50 },
|
|
157
|
+
end: { hours: 11, minutes: 10 },
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
number: 3,
|
|
161
|
+
start: { hours: 11, minutes: 40 },
|
|
162
|
+
end: { hours: 13, minutes: 0 },
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
number: 4,
|
|
166
|
+
start: { hours: 13, minutes: 30 },
|
|
167
|
+
end: { hours: 14, minutes: 50 },
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
number: 5,
|
|
171
|
+
start: { hours: 15, minutes: 0 },
|
|
172
|
+
end: { hours: 16, minutes: 20 },
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
number: 6,
|
|
176
|
+
start: { hours: 16, minutes: 40 },
|
|
177
|
+
end: { hours: 18, minutes: 0 },
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
number: 7,
|
|
181
|
+
start: { hours: 18, minutes: 10 },
|
|
182
|
+
end: { hours: 19, minutes: 30 },
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
number: 8,
|
|
186
|
+
start: { hours: 19, minutes: 40 },
|
|
187
|
+
end: { hours: 21, minutes: 0 },
|
|
188
|
+
},
|
|
154
189
|
];
|
|
155
190
|
const SPO_TIME_SLOTS = [
|
|
156
|
-
{
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
{
|
|
162
|
-
|
|
191
|
+
{
|
|
192
|
+
number: 1,
|
|
193
|
+
start: { hours: 8, minutes: 10 },
|
|
194
|
+
end: { hours: 9, minutes: 40 },
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
number: 2,
|
|
198
|
+
start: { hours: 9, minutes: 55 },
|
|
199
|
+
end: { hours: 11, minutes: 25 },
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
number: 3,
|
|
203
|
+
start: { hours: 11, minutes: 55 },
|
|
204
|
+
end: { hours: 13, minutes: 25 },
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
number: 4,
|
|
208
|
+
start: { hours: 13, minutes: 40 },
|
|
209
|
+
end: { hours: 15, minutes: 10 },
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
number: 5,
|
|
213
|
+
start: { hours: 15, minutes: 25 },
|
|
214
|
+
end: { hours: 16, minutes: 55 },
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
number: 6,
|
|
218
|
+
start: { hours: 17, minutes: 10 },
|
|
219
|
+
end: { hours: 18, minutes: 40 },
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
number: 7,
|
|
223
|
+
start: { hours: 18, minutes: 55 },
|
|
224
|
+
end: { hours: 20, minutes: 25 },
|
|
225
|
+
},
|
|
163
226
|
];
|
|
164
227
|
export function getTimeSlots(educationType) {
|
|
165
228
|
return educationType === 2 /* EducationType.VocationalEducation */
|