attlaz-client 1.48.1 → 1.48.3
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/Helper/LoadAllHelper.js +8 -3
- package/dist/Http/ClientError.js +1 -0
- package/dist/Http/Transport/DirectTransport.d.ts +13 -4
- package/dist/Http/Transport/DirectTransport.js +15 -8
- package/dist/Service/Endpoint.js +6 -0
- package/dist/Service/HealthAlertEndpoint.d.ts +3 -3
- package/dist/Service/HealthAlertEndpoint.js +4 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
|
@@ -9,9 +9,14 @@ export class LoadAllHelper {
|
|
|
9
9
|
firstPagination.limit = limit;
|
|
10
10
|
firstPagination.startingAfter = lastRef;
|
|
11
11
|
const data = await call(firstPagination);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const records = data.getData();
|
|
13
|
+
// Spread is faster than a per-element loop but can exceed the call stack for very large collections (50k+)
|
|
14
|
+
if (totalResult.length + records.length > 50_000) {
|
|
15
|
+
throw new Error('loadAll exceeded 50,000 records (' + (totalResult.length + records.length) + '). This method is not intended for large datasets.');
|
|
16
|
+
}
|
|
17
|
+
totalResult.push(...records);
|
|
18
|
+
if (records.length > 0) {
|
|
19
|
+
lastRef = records[records.length - 1].id.toString();
|
|
15
20
|
}
|
|
16
21
|
hasMore = data.hasMore;
|
|
17
22
|
}
|
package/dist/Http/ClientError.js
CHANGED
|
@@ -14,6 +14,7 @@ export class ClientError extends Error {
|
|
|
14
14
|
if (error instanceof AxiosError) {
|
|
15
15
|
if (error.code === 'ECONNREFUSED' || error.code === 'ERR_NETWORK') {
|
|
16
16
|
clientError.httpStatus = HttpStatus.HTTP_UNAVAILABLE;
|
|
17
|
+
// clientError.code = 'Service not available';
|
|
17
18
|
clientError.message = 'Service not available';
|
|
18
19
|
return clientError;
|
|
19
20
|
}
|
|
@@ -8,13 +8,18 @@ export interface DirectTransportRoute {
|
|
|
8
8
|
* Transport for internal service-to-service calls that bypasses Gateway OAuth.
|
|
9
9
|
* Authenticates via HMAC-signed session headers instead of an OAuth token.
|
|
10
10
|
*
|
|
11
|
+
* The caller is responsible for computing the HMAC signature (since this requires
|
|
12
|
+
* node:crypto which is not available in browser environments).
|
|
13
|
+
*
|
|
11
14
|
* Usage:
|
|
12
|
-
*
|
|
15
|
+
* import {createHmac} from 'node:crypto';
|
|
16
|
+
* const sessionPayload = DirectTransport.createSessionPayload();
|
|
17
|
+
* const sessionSignature = createHmac('sha256', apiSecret).update(sessionPayload).digest('hex');
|
|
18
|
+
* const transport = new DirectTransport('http://core-api:5728', sessionPayload, sessionSignature);
|
|
13
19
|
* const client = Client.withTransport(transport);
|
|
14
|
-
* client.getFlowEndpoint().getById(id);
|
|
15
20
|
*
|
|
16
21
|
* With multiple backends:
|
|
17
|
-
* const transport = new DirectTransport('http://core-api:5728',
|
|
22
|
+
* const transport = new DirectTransport('http://core-api:5728', sessionPayload, sessionSignature, [
|
|
18
23
|
* { prefix: '/products', baseUrl: 'http://products-api:5730' },
|
|
19
24
|
* { prefix: '/services', baseUrl: 'http://services-api:5731' },
|
|
20
25
|
* ]);
|
|
@@ -22,7 +27,11 @@ export interface DirectTransportRoute {
|
|
|
22
27
|
export declare class DirectTransport implements ITransport {
|
|
23
28
|
private readonly clients;
|
|
24
29
|
private readonly sortedRoutes;
|
|
25
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Creates the default session payload for internal service-to-service calls.
|
|
32
|
+
*/
|
|
33
|
+
static createSessionPayload(): string;
|
|
34
|
+
constructor(defaultBaseUrl: string, sessionPayload: string, sessionSignature: string, routes?: DirectTransportRoute[]);
|
|
26
35
|
request<T>(action: string, parameters?: Parameters, method?: string, _signWithOauthToken?: boolean): Promise<T>;
|
|
27
36
|
private resolveClient;
|
|
28
37
|
isDebugEnabled(): boolean;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { createHmac } from 'node:crypto';
|
|
2
1
|
import { OAuthClientOptions } from '../OAuthClientOptions.js';
|
|
3
2
|
import { OAuthClient } from './OAuthClient.js';
|
|
4
3
|
/**
|
|
5
4
|
* Transport for internal service-to-service calls that bypasses Gateway OAuth.
|
|
6
5
|
* Authenticates via HMAC-signed session headers instead of an OAuth token.
|
|
7
6
|
*
|
|
7
|
+
* The caller is responsible for computing the HMAC signature (since this requires
|
|
8
|
+
* node:crypto which is not available in browser environments).
|
|
9
|
+
*
|
|
8
10
|
* Usage:
|
|
9
|
-
*
|
|
11
|
+
* import {createHmac} from 'node:crypto';
|
|
12
|
+
* const sessionPayload = DirectTransport.createSessionPayload();
|
|
13
|
+
* const sessionSignature = createHmac('sha256', apiSecret).update(sessionPayload).digest('hex');
|
|
14
|
+
* const transport = new DirectTransport('http://core-api:5728', sessionPayload, sessionSignature);
|
|
10
15
|
* const client = Client.withTransport(transport);
|
|
11
|
-
* client.getFlowEndpoint().getById(id);
|
|
12
16
|
*
|
|
13
17
|
* With multiple backends:
|
|
14
|
-
* const transport = new DirectTransport('http://core-api:5728',
|
|
18
|
+
* const transport = new DirectTransport('http://core-api:5728', sessionPayload, sessionSignature, [
|
|
15
19
|
* { prefix: '/products', baseUrl: 'http://products-api:5730' },
|
|
16
20
|
* { prefix: '/services', baseUrl: 'http://services-api:5731' },
|
|
17
21
|
* ]);
|
|
@@ -19,9 +23,11 @@ import { OAuthClient } from './OAuthClient.js';
|
|
|
19
23
|
export class DirectTransport {
|
|
20
24
|
clients = new Map();
|
|
21
25
|
sortedRoutes;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Creates the default session payload for internal service-to-service calls.
|
|
28
|
+
*/
|
|
29
|
+
static createSessionPayload() {
|
|
30
|
+
return JSON.stringify({
|
|
25
31
|
api_version: 'latest',
|
|
26
32
|
user: null,
|
|
27
33
|
client: null,
|
|
@@ -30,7 +36,8 @@ export class DirectTransport {
|
|
|
30
36
|
scopes: [],
|
|
31
37
|
access_token: null,
|
|
32
38
|
});
|
|
33
|
-
|
|
39
|
+
}
|
|
40
|
+
constructor(defaultBaseUrl, sessionPayload, sessionSignature, routes = []) {
|
|
34
41
|
// All routes plus the catch-all default, sorted by prefix length descending (most specific first)
|
|
35
42
|
this.sortedRoutes = [...routes, { prefix: '', baseUrl: defaultBaseUrl }]
|
|
36
43
|
.sort((a, b) => b.prefix.length - a.prefix.length);
|
package/dist/Service/Endpoint.js
CHANGED
|
@@ -114,6 +114,11 @@ export class Endpoint {
|
|
|
114
114
|
}
|
|
115
115
|
throw this.toApiError(error);
|
|
116
116
|
}
|
|
117
|
+
// TODO: add errors
|
|
118
|
+
/**
|
|
119
|
+
* Parse errors
|
|
120
|
+
*/
|
|
121
|
+
// TODO: temporary check until we know the API is fully upgraded
|
|
117
122
|
if (requestResponse === null || requestResponse === undefined) {
|
|
118
123
|
throw new ApiError('Unable to parse object: response is empty for action `[' + method + '] ' + action + '`', HttpStatus.HTTP_INTERNAL_SERVER_ERROR);
|
|
119
124
|
}
|
|
@@ -165,6 +170,7 @@ export class Endpoint {
|
|
|
165
170
|
return data;
|
|
166
171
|
}
|
|
167
172
|
parseObject(rawObject, parser) {
|
|
173
|
+
// TODO: is it interesting to keep this wrapper, or only in develop mode?
|
|
168
174
|
const wrappedData = ObjectWrapper.wrap(rawObject);
|
|
169
175
|
try {
|
|
170
176
|
return parser(wrappedData);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EntityType } from '../Model/EntityType.js';
|
|
2
2
|
import { HealthAlert } from '../Model/HealthAlert/HealthAlert.js';
|
|
3
3
|
import { CollectionResult } from '../Model/Result/CollectionResult.js';
|
|
4
|
-
import {
|
|
4
|
+
import { Endpoint } from './Endpoint.js';
|
|
5
5
|
export declare class HealthAlertEndpoint extends Endpoint {
|
|
6
|
-
|
|
6
|
+
getCurrentAlertsByScope(scopeType: EntityType, scopeId: string, parentScopeId: string | null): Promise<CollectionResult<HealthAlert>>;
|
|
7
7
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Endpoint } from './Endpoint.js';
|
|
2
|
-
import { HealthAlert } from '../Model/HealthAlert/HealthAlert.js';
|
|
3
1
|
import { QueryString } from '../Http/Data/QueryString.js';
|
|
2
|
+
import { HealthAlert } from '../Model/HealthAlert/HealthAlert.js';
|
|
3
|
+
import { Endpoint } from './Endpoint.js';
|
|
4
4
|
export class HealthAlertEndpoint extends Endpoint {
|
|
5
|
-
async
|
|
5
|
+
async getCurrentAlertsByScope(scopeType, scopeId, parentScopeId) {
|
|
6
6
|
try {
|
|
7
|
-
const q = new QueryString('/health/' + scopeType + '/' + scopeId
|
|
7
|
+
const q = new QueryString('/health/' + scopeType + '/' + scopeId);
|
|
8
8
|
if (parentScopeId !== null) {
|
|
9
9
|
q.set('parentScopeId', parentScopeId);
|
|
10
10
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.48.
|
|
1
|
+
export declare const VERSION = "1.48.3";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.48.
|
|
1
|
+
export const VERSION = "1.48.3";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "attlaz-client",
|
|
3
|
-
"version": "1.48.
|
|
3
|
+
"version": "1.48.3",
|
|
4
4
|
"description": "Javascript Client to access Attlaz API",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -54,18 +54,18 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/jest": "^30.0.0",
|
|
57
|
-
"@types/node": "^24.
|
|
57
|
+
"@types/node": "^24.12.0",
|
|
58
58
|
"@typescript-eslint/eslint-plugin": "^8.1.0",
|
|
59
59
|
"@typescript-eslint/parser": "^8.1.0",
|
|
60
60
|
"dotenv": "^17.3.1",
|
|
61
|
-
"eslint": "^9.39.
|
|
61
|
+
"eslint": "^9.39.4",
|
|
62
62
|
"eslint-config-attlaz-base": "^1.5.2",
|
|
63
63
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
64
64
|
"eslint-plugin-import": "^2.32.0",
|
|
65
65
|
"eslint-plugin-jsdoc": "^51.4.1",
|
|
66
66
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
67
67
|
"eslint-plugin-promise": "^7.2.1",
|
|
68
|
-
"jest": "^30.
|
|
68
|
+
"jest": "^30.3.0",
|
|
69
69
|
"rimraf": "^6.1.3",
|
|
70
70
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
71
71
|
"rollup-plugin-node-resolve": "^5.2.0",
|