zdu-student-api 1.1.5 → 1.1.7

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.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +242 -18
  3. package/dist/audience.d.ts +44 -44
  4. package/dist/audience.js +50 -48
  5. package/dist/cabinet/cabinet.d.ts +79 -0
  6. package/dist/cabinet/cabinet.js +162 -0
  7. package/dist/cabinet/data.d.ts +66 -0
  8. package/dist/cabinet/data.js +115 -0
  9. package/dist/cabinet/disciplines.d.ts +19 -0
  10. package/dist/cabinet/disciplines.js +87 -0
  11. package/dist/cabinet/index.d.ts +3 -2
  12. package/dist/cabinet/index.js +3 -2
  13. package/dist/cabinet/parsers.d.ts +37 -0
  14. package/dist/cabinet/parsers.js +284 -0
  15. package/dist/cabinet/scores.d.ts +12 -0
  16. package/dist/cabinet/scores.js +101 -0
  17. package/dist/cabinet/sesId.d.ts +10 -9
  18. package/dist/cabinet/sesId.js +40 -39
  19. package/dist/cabinet/session.d.ts +33 -0
  20. package/dist/cabinet/session.js +99 -0
  21. package/dist/cabinet/types.d.ts +2 -2
  22. package/dist/cabinet/utils.d.ts +8 -0
  23. package/dist/cabinet/utils.js +19 -0
  24. package/dist/cabinet/validSession.d.ts +8 -0
  25. package/dist/cabinet/validSession.js +29 -0
  26. package/dist/cabinetStudent/cabinetStudent.d.ts +87 -0
  27. package/dist/cabinetStudent/cabinetStudent.js +181 -0
  28. package/dist/cabinetStudent/disciplines.d.ts +19 -0
  29. package/dist/cabinetStudent/disciplines.js +86 -0
  30. package/dist/cabinetStudent/index.d.ts +4 -0
  31. package/dist/cabinetStudent/index.js +4 -0
  32. package/dist/cabinetStudent/scores.d.ts +12 -0
  33. package/dist/cabinetStudent/scores.js +101 -0
  34. package/dist/cabinetStudent/types.d.ts +137 -0
  35. package/dist/cabinetStudent/types.js +1 -0
  36. package/dist/cabinetTeacher/academicGroups.d.ts +10 -0
  37. package/dist/cabinetTeacher/academicGroups.js +36 -0
  38. package/dist/cabinetTeacher/cabinetTeacher.d.ts +71 -0
  39. package/dist/cabinetTeacher/cabinetTeacher.js +132 -0
  40. package/dist/cabinetTeacher/index.d.ts +3 -0
  41. package/dist/cabinetTeacher/index.js +3 -0
  42. package/dist/cabinetTeacher/types.d.ts +68 -0
  43. package/dist/cabinetTeacher/types.js +1 -0
  44. package/dist/constants.d.ts +49 -49
  45. package/dist/constants.js +55 -52
  46. package/dist/examples.d.ts +1 -1
  47. package/dist/examples.js +70 -15
  48. package/dist/index.d.ts +12 -10
  49. package/dist/index.js +12 -10
  50. package/dist/schedule.d.ts +62 -62
  51. package/dist/schedule.js +74 -68
  52. package/dist/types.d.ts +17 -16
  53. package/dist/types.js +0 -1
  54. package/package.json +35 -33
package/dist/schedule.js CHANGED
@@ -7,34 +7,34 @@ import { faculties } from './constants.js';
7
7
  */
8
8
  export class Schedule {
9
9
  /**
10
- * Тип розкладу.
11
- *
12
- * Типи: group, teacher, room.
13
- */
10
+ * Тип розкладу.
11
+ *
12
+ * Типи: group, teacher, room.
13
+ */
14
14
  type = 'group';
15
15
  /**
16
- * Група
17
- */
16
+ * Група
17
+ */
18
18
  group = '';
19
19
  /**
20
- * Id групи
21
- */
20
+ * Id групи
21
+ */
22
22
  groupId;
23
23
  /**
24
- * Викладач
25
- */
24
+ * Викладач
25
+ */
26
26
  teacher = '';
27
27
  /**
28
- * Id викладача
29
- */
28
+ * Id викладача
29
+ */
30
30
  teacherId;
31
31
  /**
32
- * Аудиторія
33
- */
32
+ * Аудиторія
33
+ */
34
34
  room = '';
35
35
  /**
36
- * Id аудиторії
37
- */
36
+ * Id аудиторії
37
+ */
38
38
  roomId;
39
39
  /**
40
40
  * Факультет.
@@ -49,22 +49,22 @@ export class Schedule {
49
49
  */
50
50
  faculty = faculties.none;
51
51
  /**
52
- * Курс
53
- *
54
- * `0` - не вибрано
55
- */
52
+ * Курс
53
+ *
54
+ * `0` - не вибрано
55
+ */
56
56
  course = 0;
57
57
  /**
58
- * Початкова дата розкладу
59
- */
58
+ * Початкова дата розкладу
59
+ */
60
60
  beginDate = new Date();
61
61
  /**
62
- * Кінцева дата розкладу (за промовчанням +7 днів)
63
- */
62
+ * Кінцева дата розкладу (за промовчанням +7 днів)
63
+ */
64
64
  endDate = new Date(this.beginDate.getTime() + 7 * 24 * 60 * 60 * 1000);
65
65
  /**
66
- * Показувати пусті дні - false
67
- */
66
+ * Показувати пусті дні - false
67
+ */
68
68
  showEmpty = false;
69
69
  /**
70
70
  * false - сформований текст (за промовчанням)
@@ -84,69 +84,75 @@ export class Schedule {
84
84
  return this._rosText;
85
85
  }
86
86
  /**
87
- * Повертає список пар (розклад)
88
- *
89
- * @throws {Error} Якщо виникають проблеми з запитом або дані некоректні.
90
- *
91
- * @example
92
- * ```ts
93
- * import { Schedule, scheduleErrors } from "./index.ts";
94
- * const schedule = new Schedule();
95
- * schedule.group = '23Бд-СОінф123' // встановлюєм неправильну назву групи
96
- * schedule.type = 'group' // встановлєм тип пошуку по групі
97
- * schedule.rosText = true; // встановлюєм окремі стовпчики
98
- * schedule.allStreamComponents = true; // встановлюєм повний склад потоку
99
- * try {
100
- * const mySchedule = await schedule.getSchedule();
101
- * console.log("Розклад:", mySchedule);
102
- * } catch (err: any) {
103
- * // Отримуєм помилку тому що ми неправильно вказали назву групи
104
- * console.error(err.message); // Поверне: "{"error_message":"Об‘єкт - 23Бд-СОінф123 - Об‘єкт не знайдено ","errorcode":"-90"}"
105
- * console.error(scheduleErrors[JSON.parse(err.message).errorcode]); // Поверне: "Об`єкт, для якого потрібно показати розклад, не знайдено"
106
- * }
107
- * ```
108
- *
109
- * @remarks
110
- * У `err.message` може повертатися простий текст помилки,
111
- * або об’єкт у форматі:
112
- * ```JSON
113
- * {
114
- * "error_message": "Текст помилки",
115
- * "errorcode": "Код помилки"
116
- * }
117
- * ```
118
- *
119
- * Де:
120
- * - `error_message` - текст помилки відповідно до {@link scheduleErrors}
121
- * - `errorcode` - код помилки відповідно до {@link scheduleErrors}
122
- */
87
+ * Повертає список пар (розклад)
88
+ *
89
+ * @throws {Error} Якщо виникають проблеми з запитом або дані некоректні.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * import { Schedule, scheduleErrors } from "./index.ts";
94
+ * const schedule = new Schedule();
95
+ * schedule.group = '23Бд-СОінф123' // встановлюєм неправильну назву групи
96
+ * schedule.type = 'group' // встановлєм тип пошуку по групі
97
+ * schedule.rosText = true; // встановлюєм окремі стовпчики
98
+ * schedule.allStreamComponents = true; // встановлюєм повний склад потоку
99
+ * try {
100
+ * const mySchedule = await schedule.getSchedule();
101
+ * console.log("Розклад:", mySchedule);
102
+ * } catch (err: any) {
103
+ * // Отримуєм помилку тому що ми неправильно вказали назву групи
104
+ * console.error(err.message); // Поверне: "{"error_message":"Об‘єкт - 23Бд-СОінф123 - Об‘єкт не знайдено ","errorcode":"-90"}"
105
+ * console.error(scheduleErrors[JSON.parse(err.message).errorcode]); // Поверне: "Об`єкт, для якого потрібно показати розклад, не знайдено"
106
+ * }
107
+ * ```
108
+ *
109
+ * @remarks
110
+ * У `err.message` може повертатися простий текст помилки,
111
+ * або об’єкт у форматі:
112
+ * ```JSON
113
+ * {
114
+ * "error_message": "Текст помилки",
115
+ * "errorcode": "Код помилки"
116
+ * }
117
+ * ```
118
+ *
119
+ * Де:
120
+ * - `error_message` - текст помилки відповідно до {@link scheduleErrors}
121
+ * - `errorcode` - код помилки відповідно до {@link scheduleErrors}
122
+ */
123
123
  async getSchedule() {
124
124
  const beginDate = this.beginDate.toLocaleDateString('uk-UA', {
125
125
  day: '2-digit',
126
126
  month: '2-digit',
127
- year: 'numeric'
127
+ year: 'numeric',
128
128
  });
129
129
  const endDate = this.endDate.toLocaleDateString('uk-UA', {
130
130
  day: '2-digit',
131
131
  month: '2-digit',
132
- year: 'numeric'
132
+ year: 'numeric',
133
133
  });
134
- let id = (this.type === 'group' ? this.groupId : this.type === 'teacher' ? this.teacherId : this.roomId);
134
+ let id = this.type === 'group'
135
+ ? this.groupId
136
+ : this.type === 'teacher'
137
+ ? this.teacherId
138
+ : this.roomId;
135
139
  if (!id)
136
140
  id = '';
137
- let name = (this.type === 'group' ? this.group : this.type === 'teacher' ? this.teacher : this.room);
141
+ let name = this.type === 'group' ? this.group : this.type === 'teacher' ? this.teacher : this.room;
138
142
  name = this.encodeCP1251(name);
139
143
  const response = await fetch(`https://dekanat.zu.edu.ua/cgi-bin/timetable_export.cgi?req_type=rozklad&req_mode=${this.type}&OBJ_ID=${id}&OBJ_name=${name}&dep_name=&begin_date=${beginDate}&end_date=${endDate}&ros_text=${this.rosText ? 'separated' : 'united'}${this.showEmpty ? '' : '&show_empty=yes'}${this.allStreamComponents ? '' : '&all_stream_components=yes'}&req_format=json&coding_mode=UTF8&bs=%D1%F4%EE%F0%EC%F3%E2%E0%F2%E8+%E7%E0%EF%E8%F2`);
140
144
  if (!response.ok)
141
145
  throw new Error(`HTTP error ${response.status}: ${response.statusText}`);
142
146
  const data = await response.json();
143
147
  if (data.psrozklad_export.code !== '0') {
144
- throw new Error(JSON.stringify(data.psrozklad_export.error) || "Unknown error");
148
+ throw new Error(JSON.stringify(data.psrozklad_export.error) || 'Unknown error');
145
149
  }
146
150
  return data.psrozklad_export.roz_items;
147
151
  }
148
152
  encodeCP1251(str) {
149
153
  const buf = iconv.encode(str, 'win1251');
150
- return Array.from(buf).map(b => '%' + b.toString(16).toUpperCase().padStart(2, '0')).join('');
154
+ return Array.from(buf)
155
+ .map((b) => '%' + b.toString(16).toUpperCase().padStart(2, '0'))
156
+ .join('');
151
157
  }
152
158
  }
package/dist/types.d.ts CHANGED
@@ -59,10 +59,10 @@ export interface Room {
59
59
  block: string;
60
60
  }
61
61
  /**
62
- * Типи для отримання розкладу.
63
- * @category Schedule
64
- *
65
- */
62
+ * Типи для отримання розкладу.
63
+ * @category Schedule
64
+ *
65
+ */
66
66
  export type ScheduleTypes = 'group' | 'teacher' | 'room';
67
67
  /**
68
68
  * Базова інформація про заняття
@@ -94,16 +94,17 @@ export interface BaseLesson {
94
94
  * @category Schedule
95
95
  *
96
96
  * @remarks
97
- * - `half` — Номер підгрупи
97
+ * - `half` — Половина пари (не використовується)
98
98
  * - `teacher` — Основний викладач
99
99
  * - `teachers_add` — Додаткові викладачі
100
100
  * - `room` — Аудиторія, наприклад "319/№1"
101
- * - `group` — Список груп, які відвідують заняття
101
+ * - `group` — Список груп, які відвідують заняття / підгрупа
102
102
  * - `title` — Повна назва предмету або його код
103
103
  * - `type` — Тип заняття
104
104
  * - `replacement` — Позначка про заміну пари
105
+ * - `reservation` — Зарезервована пара
105
106
  * - `online` — Чи є онлайн-посилання / онлайн-режим
106
- * - `comment4link` — Коментар до посилання (іноді використовується для Zoom/Meet)
107
+ * - `comment4link` — Коментар до посилання (іноді використовується для Zoom/Meet) / підгрупа / коментар
107
108
  * - `link` — Посилання на онлайн-заняття
108
109
  */
109
110
  export interface DetailedLesson extends BaseLesson {
@@ -139,22 +140,22 @@ export interface AudienceRoom {
139
140
  comment: string;
140
141
  }
141
142
  /**
142
- * Блоки
143
- * @category Audience
144
- */
143
+ * Блоки
144
+ * @category Audience
145
+ */
145
146
  export type Blocks = '' | '№1' | '№2' | '№3' | '№4' | '№5' | 'гуртож №1' | 'гуртож №2' | 'гуртож №3' | 'гуртож №4' | 'гуртож №5';
146
147
  /**
147
- * Тип аудиторії
148
- * @category Audience
149
- */
148
+ * Тип аудиторії
149
+ * @category Audience
150
+ */
150
151
  export interface TypeAudience {
151
152
  full: string;
152
153
  short: string;
153
154
  }
154
155
  /**
155
- * Доп. обладнання
156
- * @category Audience
157
- */
156
+ * Доп. обладнання
157
+ * @category Audience
158
+ */
158
159
  export interface Dop {
159
160
  name: string;
160
161
  }
package/dist/types.js CHANGED
@@ -1,2 +1 @@
1
- ;
2
1
  export {};
package/package.json CHANGED
@@ -1,35 +1,37 @@
1
1
  {
2
- "name": "zdu-student-api",
3
- "version": "1.1.5",
4
- "description": "API client for ZDU student services",
5
- "author": "Nicita3 <ni596157@gmail.com> (https://github.com/Nicita-3)",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "type": "module",
9
- "files": [
10
- "dist"
11
- ],
12
- "scripts": {
13
- "build": "tsc",
14
- "docs": "typedoc --out docs src",
15
- "test": "node --loader ts-node/esm src/examples.ts",
16
- "publish:all": "npm run build && npm run docs && npm publish"
17
- },
18
- "license": "MIT",
19
- "repository": {
20
- "type": "git",
21
- "url": "https://github.com/Nicita-3/zdu-student-api"
22
- },
23
- "homepage": "https://nicita-3.github.io/zdu-student-api",
24
- "devDependencies": {
25
- "@types/node": "^24.10.1",
26
- "ts-node": "^10.9.2",
27
- "typedoc": "^0.28.14",
28
- "typescript": "^5.9.3"
29
- },
30
- "dependencies": {
31
- "buffer": "^6.0.3",
32
- "cross-fetch": "^4.1.0",
33
- "iconv-lite": "^0.7.0"
34
- }
2
+ "name": "zdu-student-api",
3
+ "version": "1.1.7",
4
+ "description": "API client for ZDU student services",
5
+ "author": "Nicita3 <ni596157@gmail.com> (https://github.com/Nicita-3)",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "type": "module",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "docs": "typedoc --out docs src",
15
+ "test": "node --loader ts-node/esm src/examples.ts",
16
+ "publish:all": "npm run build && npm run docs && npm publish"
17
+ },
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/Nicita-3/zdu-student-api"
22
+ },
23
+ "homepage": "https://nicita-3.github.io/zdu-student-api",
24
+ "devDependencies": {
25
+ "@types/node": "^24.10.1",
26
+ "prettier": "^3.7.4",
27
+ "ts-node": "^10.9.2",
28
+ "typedoc": "^0.28.14",
29
+ "typescript": "^5.9.3"
30
+ },
31
+ "dependencies": {
32
+ "buffer": "^6.0.3",
33
+ "cross-fetch": "^4.1.0",
34
+ "dotenv": "^17.2.3",
35
+ "iconv-lite": "^0.7.0"
36
+ }
35
37
  }