bsuir-iis-api 0.7.0 → 0.9.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/CHANGELOG.md +45 -5
- package/README.md +16 -1
- package/dist/_tsup-dts-rollup.d.ts +437 -82
- package/dist/index.d.ts +10 -1
- package/dist/index.js +534 -134
- package/dist/index.js.map +1 -1
- package/package.json +15 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,52 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## [0.9.1] - 2026-05-10
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- `http.ts`: cache eviction now performs true LRU — entries are sorted by `accessedAt` timestamp before eviction instead of relying on Map insertion order (which produced FIFO behaviour, not LRU).
|
|
8
|
+
- `http.ts`: `setCache` now removes the key before re-inserting on a cache refresh, ensuring Map insertion order stays consistent with actual last-write time.
|
|
9
|
+
- `http.ts`: `canUseCaching` and `canUseDedup` now check `config.signal?.aborted` in addition to per-request `options.signal`; previously a globally aborted client signal did not suppress cache reads, which could return stale data after cancellation.
|
|
10
|
+
|
|
11
|
+
### Documentation
|
|
12
|
+
|
|
13
|
+
- `types.ts`: all `BsuirClientOptions` fields now have full JSDoc — description, `@defaultValue`, `@example`, and side-effect notes where applicable.
|
|
14
|
+
- `types.ts`: `validateResponses` JSDoc explicitly recommends `process.env.NODE_ENV !== "production"` as a sensible default pattern and clarifies the performance trade-off.
|
|
15
|
+
- `types.ts`: `signal` JSDoc clarifies that an aborted global signal suppresses both cache reads and in-flight deduplication.
|
|
16
|
+
|
|
17
|
+
## [0.9.0] - 2026-05-10
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- Public exports for schedule utilities: `normalizeSchedule` and `filterLessons`.
|
|
22
|
+
- Public re-export of `ScheduleFilterOptions` type from `src/index.ts`.
|
|
23
|
+
- Global cancellation support via `createBsuirClient({ signal })`.
|
|
24
|
+
- `src/modules/index.ts` barrel for module factory imports.
|
|
25
|
+
- In-memory GET cache via `createBsuirClient({ cache: { ttlMs, maxEntries } })`.
|
|
26
|
+
- In-flight GET request deduplication via `dedupeInFlight`.
|
|
27
|
+
- Opt-in runtime response-shape validation via `validateResponses` and `BsuirResponseValidationError`.
|
|
28
|
+
- Request lifecycle hooks via `createBsuirClient({ hooks })`: `onRequest`, `onRetry`, `onResponse`, `onError`.
|
|
29
|
+
- API Extractor configuration (`api-extractor.json`) and npm scripts for local/update and CI checks.
|
|
30
|
+
- `POST` method support in `requestJson` via `options.method` and `options.body`.
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- `schedule.getGroup/getEmployee` return typing now follows client-level `defaultRaw` when `raw` is omitted.
|
|
35
|
+
- `normalizeSchedule` no longer duplicates day-item flattening work and avoids repeated `auditories` normalization per lesson.
|
|
36
|
+
- Strict date parsing in `parseDdMmYyyy` now rejects non-existent calendar dates (for example `31.02.2026`).
|
|
37
|
+
- `BsuirNetworkError` now relies on standard `Error.cause` instead of duplicate `causeError` field.
|
|
38
|
+
- Client option validation now rejects invalid timeout/retry configuration values early.
|
|
39
|
+
- `week.ts`: passing an empty string now throws a clear `BsuirValidationError` ("is an empty string") instead of a misleading "must be a positive integer" message.
|
|
40
|
+
- `filterLessons`: `weekNumber: 0` is now rejected with `assertPositiveInt` instead of silently passing.
|
|
41
|
+
- `http.ts`: cache eviction now uses pseudo-LRU (oldest-inserted Map key, O(1)) instead of an O(n) scan; `inFlightPromise` is typed as `Promise<T>` to eliminate unsafe `as Promise<unknown>` cast.
|
|
42
|
+
- `http.ts`: restored file integrity after shell heredoc substitution corrupted ES module imports; fixed `@typescript-eslint/no-unsafe-call` error on `inFlight` read by shifting the `as T` cast to the Promise type before `await`.
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
8
45
|
|
|
9
|
-
|
|
46
|
+
- JSDoc for `defaultRaw` client option now clarifies that a per-call `raw` option takes priority and includes an `@example` for both cases.
|
|
47
|
+
- Dev tooling: bumped TypeScript to 6.0.3, ESLint to ^10.2.1, Vitest and `@vitest/coverage-v8` to ^4.1.4, `@types/node` to ^25.6.0, `@typescript-eslint/*` and `typescript-eslint` to ^8.58.2, `@changesets/cli` to ^2.31.0, `@microsoft/api-extractor` to ^7.58.5, Prettier to ^3.8.3, `globals` to ^17.5.0; regenerated `package-lock.json`.
|
|
48
|
+
- CI now validates API report compatibility via `npm run api:report:check` (Node 24 job in matrix).
|
|
49
|
+
- `vitest.config.ts`: added coverage thresholds (`lines: 80`, `functions: 80`) to enforce minimum test coverage on CI.
|
|
10
50
|
|
|
11
51
|
## [0.7.0] - 2026-04-19
|
|
12
52
|
|
package/README.md
CHANGED
|
@@ -38,11 +38,24 @@ const client = createBsuirClient({
|
|
|
38
38
|
retryDelayMs: 300,
|
|
39
39
|
retryMaxDelayMs: 3000,
|
|
40
40
|
retryJitter: true,
|
|
41
|
+
cache: { ttlMs: 60_000, maxEntries: 200 },
|
|
42
|
+
dedupeInFlight: true,
|
|
43
|
+
validateResponses: false,
|
|
44
|
+
hooks: {
|
|
45
|
+
onRetry: ({ endpoint, delayMs, reason }) => {
|
|
46
|
+
console.log("retry", endpoint, delayMs, reason);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
41
49
|
defaultRaw: false
|
|
42
50
|
});
|
|
43
51
|
```
|
|
44
52
|
|
|
45
53
|
- `fetch` can be passed for custom runtime/testing.
|
|
54
|
+
- `signal` in `createBsuirClient({ signal })` acts as a global cancellation signal for all requests made by that client.
|
|
55
|
+
- `cache` stores successful GET responses in-memory for the configured TTL.
|
|
56
|
+
- `dedupeInFlight` reuses the same in-flight GET request for concurrent callers (when no per-request signal is passed).
|
|
57
|
+
- `validateResponses` enables runtime payload-shape checks for key endpoints.
|
|
58
|
+
- `hooks` provides lifecycle callbacks (`onRequest`, `onRetry`, `onResponse`, `onError`) for observability.
|
|
46
59
|
- `AbortSignal` is supported by all read methods.
|
|
47
60
|
|
|
48
61
|
## API
|
|
@@ -84,7 +97,8 @@ When IIS responds with HTTP `404` or `400` (no list, missing resource, or endpoi
|
|
|
84
97
|
SDK throws typed errors:
|
|
85
98
|
|
|
86
99
|
- `BsuirApiError` for HTTP errors (contains `status`, `endpoint`, `body`). **Exception:** `client.announcements.byEmployee` / `byDepartment` resolve to `[]` on IIS HTTP `404` or `400` instead of throwing (see Announcements above).
|
|
87
|
-
- `BsuirNetworkError` for transport errors (contains `endpoint
|
|
100
|
+
- `BsuirNetworkError` for transport errors (contains `endpoint` and standard `cause`)
|
|
101
|
+
- `BsuirResponseValidationError` for invalid payload shapes when `validateResponses: true`
|
|
88
102
|
- `BsuirTimeoutError` for timeouts (contains `endpoint`, `timeoutMs`)
|
|
89
103
|
- `BsuirValidationError` for invalid input parameters
|
|
90
104
|
- `BsuirConfigurationError` when the runtime has no `fetch` and none was passed to `createBsuirClient({ fetch })`
|
|
@@ -151,6 +165,7 @@ npm run lint
|
|
|
151
165
|
npm run lint:fix
|
|
152
166
|
npm run check
|
|
153
167
|
npm run build
|
|
168
|
+
npm run api:report
|
|
154
169
|
```
|
|
155
170
|
|
|
156
171
|
`npm run build` uses [tsup](https://tsup.egoist.dev/) with [`experimentalDts`](https://tsup.egoist.dev/) so `.d.ts` output is produced via `@microsoft/api-extractor` rather than the legacy Rollup declaration path (which is awkward with TypeScript 6’s `baseUrl` deprecation). TypeScript’s handbook notes that [`paths` can be used without `baseUrl`](https://www.typescriptlang.org/docs/handbook/modules/reference.html) when you need path mapping.
|