zdu-student-api 1.1.10 → 1.1.12

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/audience.js CHANGED
@@ -74,6 +74,7 @@ export class Audience {
74
74
  this.dops.forEach((dop) => {
75
75
  dops += `&dop_${dop}=yes`;
76
76
  });
77
+ // TODO FIX MIN AND MAX. IF MIN = true & !MAX, MAX=999999999
77
78
  const response = await fetch(`https://dekanat.zu.edu.ua/cgi-bin/timetable_export.cgi?req_type=free_rooms_list&&block_name=${this.blockName !== undefined ? this.encodeCP1251(this.blockName) : ''}&size_min=${this.size_min !== undefined ? this.size_min : ''}&size_max=${this.size_max !== undefined ? this.size_max : ''}&room_type=${this.roomType !== undefined ? this.encodeCP1251(this.roomType) : ''}&begin_date=${date}&lesson=${this.lesson}${dops}&req_format=json&coding_mode=UTF8&bs=%D1%F4%EE%F0%EC%F3%E2%E0%F2%E8+%E7%E0%EF%E8%F2`);
78
79
  if (!response.ok)
79
80
  throw new Error(`HTTP error ${response.status}: ${response.statusText}`);
@@ -2,6 +2,7 @@ import fetch from 'cross-fetch';
2
2
  import iconv from 'iconv-lite';
3
3
  import { generateCookieString, isLoginPage } from './session.js';
4
4
  import { parseDataPageN3, parseDataPageN31, parseTeacherData } from './parsers.js';
5
+ import { Buffer } from 'buffer';
5
6
  /**
6
7
  * Отримати анкетні дані студента
7
8
  * @category CabinetTeacher
@@ -1,5 +1,6 @@
1
1
  import fetch from 'cross-fetch';
2
2
  import iconv from 'iconv-lite';
3
+ import { Buffer } from 'buffer';
3
4
  /**
4
5
  * Отримати sesID та sessGUID користувача
5
6
  * @category Cabinet
@@ -2,6 +2,7 @@ import fetch from 'cross-fetch';
2
2
  import iconv from 'iconv-lite';
3
3
  import { parseDisciplinesPageN6, parseDisciplinesPageN7 } from '../cabinet/parsers.js';
4
4
  import { generateCookieString, isLoginPage } from '../cabinet/session.js';
5
+ import { Buffer } from 'buffer';
5
6
  /**
6
7
  * Отримати всі дисципліни студента
7
8
  * @category CabinetStudent
@@ -1,6 +1,7 @@
1
1
  import fetch from 'cross-fetch';
2
2
  import iconv from 'iconv-lite';
3
3
  import { generateCookieString, isLoginPage } from '../cabinet/session.js';
4
+ import { Buffer } from 'buffer';
4
5
  /**
5
6
  * Отримати оцінки вибраного предмета студента
6
7
  * @category CabinetStudent
@@ -70,6 +71,13 @@ function parseSchedule(html) {
70
71
  if (thirdTrStart === -1 || thirdTrEnd === -1)
71
72
  return [];
72
73
  let thirdRow = theadContent.slice(thirdTrStart, thirdTrEnd);
74
+ // Збираємо всі data-ind з thead в порядку появи (вони у другому рядку)
75
+ const allInds = [];
76
+ const indRegex = /data-ind="([^"]+)"/g;
77
+ let indMatch;
78
+ while ((indMatch = indRegex.exec(theadContent)) !== null) {
79
+ allInds.push(indMatch[1]);
80
+ }
73
81
  const result = [];
74
82
  const thStartRegex = /<th\b/g;
75
83
  const positions = [];
@@ -84,6 +92,7 @@ function parseSchedule(html) {
84
92
  thirdPositions.push(match.index);
85
93
  }
86
94
  thirdPositions.push(thirdRow.length);
95
+ let indIdx = 0;
87
96
  for (let i = 0; i < positions.length - 1; i++) {
88
97
  const start = positions[i];
89
98
  const end = positions[i + 1];
@@ -117,10 +126,17 @@ function parseSchedule(html) {
117
126
  if (!dataHthMatch)
118
127
  continue;
119
128
  const dataHth = dataHthMatch[1];
129
+ let index;
120
130
  const aMatch = thContent.match(/data-ind="([^"]+)"/);
121
- if (!aMatch)
122
- continue;
123
- const index = aMatch[1];
131
+ if (aMatch) {
132
+ index = aMatch[1];
133
+ }
134
+ else {
135
+ if (indIdx >= allInds.length)
136
+ continue;
137
+ index = allInds[indIdx];
138
+ }
139
+ indIdx++;
124
140
  const dateMatch = thContent.match(/>(\d{2}\.\d{2}\.\d{4})</);
125
141
  const date = dateMatch ? dateMatch[1] : '';
126
142
  const timeMatch = thContent.match(/<br[^>]*>\s*(\d{2}:\d{2}-\d{2}:\d{2})/);
@@ -2,6 +2,7 @@ import fetch from 'cross-fetch';
2
2
  import iconv from 'iconv-lite';
3
3
  import { generateCookieString, isLoginPage } from '../cabinet/session.js';
4
4
  import { parseGroupsPage } from '../cabinet/parsers.js';
5
+ import { Buffer } from 'buffer';
5
6
  /**
6
7
  * Отримати всі академічні групи
7
8
  * @category CabinetTeacher
package/dist/examples.js CHANGED
@@ -27,10 +27,16 @@ import 'dotenv/config';
27
27
  // console.log(await getTeachers('Кривонос Олександр'));
28
28
  // console.log(await getRooms('319'));
29
29
  // const audience = new Audience();
30
- // audience.blockName = "гуртож №3"
30
+ // // audience.blockName = 'гуртож №3';
31
31
  // try {
32
+ // audience.roomType = 'Комп. клас';
33
+ // audience.blockName = '№1';
34
+ // const [day, month, year] = '09.02.2026'.split('.');
35
+ // audience.roomsDate = new Date(+year, +month - 1, +day + 1);
36
+ // console.log(audience.roomsDate);
37
+ // audience.lesson = 5;
32
38
  // const audiences = await audience.getAudience();
33
- // console.log("Аудиторії:", audiences);
39
+ // console.log('Аудиторії:', audiences);
34
40
  // } catch (err: any) {
35
41
  // console.error(err.message);
36
42
  // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zdu-student-api",
3
- "version": "1.1.10",
3
+ "version": "1.1.12",
4
4
  "description": "API client for ZDU student services",
5
5
  "author": "Nicita3 <ni596157@gmail.com> (https://github.com/Nicita-3)",
6
6
  "main": "dist/index.js",
@@ -13,7 +13,7 @@
13
13
  "build": "tsc",
14
14
  "docs": "typedoc --out docs src",
15
15
  "test": "node --loader ts-node/esm src/examples.ts",
16
- "publish:all": "npm run build && npm run docs && npm publish"
16
+ "publish:all": "npm run build && npm publish"
17
17
  },
18
18
  "license": "MIT",
19
19
  "repository": {
@@ -22,16 +22,16 @@
22
22
  },
23
23
  "homepage": "https://nicita-3.github.io/zdu-student-api",
24
24
  "devDependencies": {
25
- "@types/node": "^24.10.1",
26
- "prettier": "^3.7.4",
25
+ "@types/node": "^24.12.2",
26
+ "prettier": "^3.8.1",
27
27
  "ts-node": "^10.9.2",
28
- "typedoc": "^0.28.14",
28
+ "typedoc": "^0.28.18",
29
29
  "typescript": "^5.9.3"
30
30
  },
31
31
  "dependencies": {
32
32
  "buffer": "^6.0.3",
33
33
  "cross-fetch": "^4.1.0",
34
- "dotenv": "^17.2.3",
35
- "iconv-lite": "^0.7.0"
34
+ "dotenv": "^17.4.1",
35
+ "iconv-lite": "^0.7.2"
36
36
  }
37
37
  }