@ignos/api-client 20260914.275.1 → 20260914.277.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/lib/AuthorizedApiBase.js +28 -27
- package/lib/ignosportal-api.js +325 -125
- package/package.json +2 -2
- package/tsconfig.json +3 -2
package/lib/AuthorizedApiBase.js
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
export class AuthorizedApiBase {
|
|
2
|
+
config;
|
|
2
3
|
constructor(config) {
|
|
3
|
-
this.transformOptions = async (options) => {
|
|
4
|
-
options.headers = {
|
|
5
|
-
...options.headers,
|
|
6
|
-
Authorization: "Bearer " + (await this.config.accessTokenProvider.getAccessToken()),
|
|
7
|
-
};
|
|
8
|
-
const tenantId = this.config.tenantIdProvider.getTenantId();
|
|
9
|
-
if (tenantId)
|
|
10
|
-
options.headers["x-tenantid"] = tenantId;
|
|
11
|
-
return options;
|
|
12
|
-
};
|
|
13
|
-
this.jsonParseReviver = (_, value) => {
|
|
14
|
-
if (typeof value !== "string")
|
|
15
|
-
return value;
|
|
16
|
-
// Matches starts with "2025-12-09T13:19:39"
|
|
17
|
-
// Will also match "2025-12-09T13:19:39.4576289+00:00"
|
|
18
|
-
const regex = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/;
|
|
19
|
-
if (!regex.test(value))
|
|
20
|
-
return value;
|
|
21
|
-
// JS Date only supports millisecond precision (3 fractional digits).
|
|
22
|
-
// Timestamps with microseconds or higher (e.g. ".4576289") produce Invalid Date.
|
|
23
|
-
// Truncate any excess fractional digits before parsing.
|
|
24
|
-
const normalized = value.replace(/(\.\d{3})\d+/, "$1");
|
|
25
|
-
const date = new Date(normalized);
|
|
26
|
-
// Prevent values like "2025-12-09T13:19:39.4576289+00:00 bla bla bla" from being parsed as Date
|
|
27
|
-
// (values not starting with an ISO date-time are already filtered out by the regex above)
|
|
28
|
-
return isNaN(date.getTime()) ? value : date;
|
|
29
|
-
};
|
|
30
4
|
this.config = config;
|
|
31
5
|
}
|
|
6
|
+
transformOptions = async (options) => {
|
|
7
|
+
options.headers = {
|
|
8
|
+
...options.headers,
|
|
9
|
+
Authorization: "Bearer " + (await this.config.accessTokenProvider.getAccessToken()),
|
|
10
|
+
};
|
|
11
|
+
const tenantId = this.config.tenantIdProvider.getTenantId();
|
|
12
|
+
if (tenantId)
|
|
13
|
+
options.headers["x-tenantid"] = tenantId;
|
|
14
|
+
return options;
|
|
15
|
+
};
|
|
16
|
+
jsonParseReviver = (_, value) => {
|
|
17
|
+
if (typeof value !== "string")
|
|
18
|
+
return value;
|
|
19
|
+
// Matches starts with "2025-12-09T13:19:39"
|
|
20
|
+
// Will also match "2025-12-09T13:19:39.4576289+00:00"
|
|
21
|
+
const regex = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/;
|
|
22
|
+
if (!regex.test(value))
|
|
23
|
+
return value;
|
|
24
|
+
// JS Date only supports millisecond precision (3 fractional digits).
|
|
25
|
+
// Timestamps with microseconds or higher (e.g. ".4576289") produce Invalid Date.
|
|
26
|
+
// Truncate any excess fractional digits before parsing.
|
|
27
|
+
const normalized = value.replace(/(\.\d{3})\d+/, "$1");
|
|
28
|
+
const date = new Date(normalized);
|
|
29
|
+
// Prevent values like "2025-12-09T13:19:39.4576289+00:00 bla bla bla" from being parsed as Date
|
|
30
|
+
// (values not starting with an ISO date-time are already filtered out by the regex above)
|
|
31
|
+
return isNaN(date.getTime()) ? value : date;
|
|
32
|
+
};
|
|
32
33
|
}
|