@hahnpro/hpc-api 2025.12.0 → 2025.12.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/package.json +1 -1
- package/src/lib/api.d.ts +3 -0
- package/src/lib/api.js +2 -1
- package/src/lib/mock/organizations-administration.mock.service.d.ts +2 -2
- package/src/lib/mock/organizations-administration.mock.service.js +2 -2
- package/src/lib/services/http-client.service.d.ts +3 -1
- package/src/lib/services/http-client.service.js +24 -14
- package/src/lib/services/organizations-administration.service.d.ts +4 -4
- package/src/lib/services/organizations-administration.service.js +5 -5
package/package.json
CHANGED
package/src/lib/api.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { QueueOptions } from './queue';
|
|
1
2
|
import { AiService, AlertService, AssetService, AssetTypesService, ContentService, EndpointService, EventService, FlowDeploymentService, FlowFunctionService, FlowModuleService, FlowService, HttpClientService, LabelService, NotificationRuleService, NotificationService, OrganizationsAdministrationService, OrganizationsResourcesService, OrganizationsService, ProxyService, SearchService, TaskService, TimeSeriesService, UserService, VaultService } from './services';
|
|
2
3
|
export declare class API {
|
|
3
4
|
readonly httpClient?: HttpClientService;
|
|
@@ -27,5 +28,7 @@ export declare class API {
|
|
|
27
28
|
constructor(httpClient?: HttpClientService, context?: {
|
|
28
29
|
tokenSubject?: string;
|
|
29
30
|
activeOrg?: string;
|
|
31
|
+
}, config?: {
|
|
32
|
+
queueOptions?: QueueOptions;
|
|
30
33
|
});
|
|
31
34
|
}
|
package/src/lib/api.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.API = void 0;
|
|
4
4
|
const services_1 = require("./services");
|
|
5
5
|
class API {
|
|
6
|
-
constructor(httpClient, context) {
|
|
6
|
+
constructor(httpClient, context, config) {
|
|
7
7
|
this.httpClient = httpClient;
|
|
8
8
|
if (!httpClient) {
|
|
9
9
|
// remove leading and trailing slashes
|
|
@@ -31,6 +31,7 @@ class API {
|
|
|
31
31
|
clientSecret: secret,
|
|
32
32
|
tokenSubject: context?.tokenSubject,
|
|
33
33
|
activeOrg: context?.activeOrg,
|
|
34
|
+
queueOptions: config?.queueOptions,
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
this.ai = new services_1.AiService(this.httpClient);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { APIBaseMock, OrganizationsMockService } from '.';
|
|
3
|
-
import { Filter, Organization, OrganizationCreateDto,
|
|
3
|
+
import { Filter, Organization, OrganizationCreateDto, OrganizationResourcesProgress, OrganizationSearchQuery, Paginated, RequestParameter, ServerSentEvent, SubscriptionType, UserWithOrgRoles } from '../interfaces';
|
|
4
4
|
import { OrganizationsAdministrationService } from '../services';
|
|
5
5
|
export declare class OrganizationsAdministrationMockService extends APIBaseMock<Organization> implements OrganizationsAdministrationService {
|
|
6
6
|
private readonly organizationMockService;
|
|
@@ -14,6 +14,6 @@ export declare class OrganizationsAdministrationMockService extends APIBaseMock<
|
|
|
14
14
|
getMany(params?: RequestParameter): Promise<Paginated<Organization>>;
|
|
15
15
|
getManyFiltered(filter: Filter, params?: RequestParameter): Promise<Paginated<Organization>>;
|
|
16
16
|
search(query: OrganizationSearchQuery): Promise<Organization[]>;
|
|
17
|
-
createOrganization(organizationCreateDto: OrganizationCreateDto,
|
|
17
|
+
createOrganization(organizationCreateDto: OrganizationCreateDto, emailsToInvite: string[], emailsToAdd: string[], createOrgAsOwner?: boolean): Promise<Organization>;
|
|
18
18
|
getOrganizationDeletionProgress(organizationId: string): Observable<ServerSentEvent<OrganizationResourcesProgress>>;
|
|
19
19
|
}
|
|
@@ -76,9 +76,9 @@ class OrganizationsAdministrationMockService extends _1.APIBaseMock {
|
|
|
76
76
|
async search(query) {
|
|
77
77
|
return Promise.resolve(this.data.filter((entry) => entry.name === query.name || entry.name.startsWith(query.name)));
|
|
78
78
|
}
|
|
79
|
-
createOrganization(organizationCreateDto,
|
|
79
|
+
createOrganization(organizationCreateDto, emailsToInvite, emailsToAdd, createOrgAsOwner = false) {
|
|
80
80
|
if (!organizationCreateDto?.name ||
|
|
81
|
-
!
|
|
81
|
+
([...emailsToInvite, ...emailsToAdd].length === 0 && !createOrgAsOwner) ||
|
|
82
82
|
this.data.some((org) => org.name === organizationCreateDto.name)) {
|
|
83
83
|
return Promise.reject('Bad Request');
|
|
84
84
|
}
|
|
@@ -2,7 +2,7 @@ import { AxiosInstance, Method } from 'axios';
|
|
|
2
2
|
import { EventSource } from 'eventsource';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
import { Config, Issuer, ServerSentEvent, TokenOption } from '../interfaces';
|
|
5
|
-
import { Queue } from '../queue';
|
|
5
|
+
import { Queue, QueueOptions } from '../queue';
|
|
6
6
|
import { TokenSet } from '../token-set';
|
|
7
7
|
export interface HttpClientConfig {
|
|
8
8
|
baseURL: string;
|
|
@@ -12,6 +12,7 @@ export interface HttpClientConfig {
|
|
|
12
12
|
clientSecret?: string;
|
|
13
13
|
tokenSubject?: string;
|
|
14
14
|
activeOrg?: string;
|
|
15
|
+
queueOptions?: QueueOptions;
|
|
15
16
|
}
|
|
16
17
|
export declare class HttpClientService {
|
|
17
18
|
protected readonly baseURL: string;
|
|
@@ -55,4 +56,5 @@ export declare class HttpClientService {
|
|
|
55
56
|
protected requestAccessToken(additionalOpts?: {}): Promise<TokenSet>;
|
|
56
57
|
protected exchangeAccessToken(accessToken: string): Promise<TokenSet>;
|
|
57
58
|
provideExternalToken(token: string): Promise<void>;
|
|
59
|
+
private requestPromise;
|
|
58
60
|
}
|
|
@@ -21,19 +21,12 @@ class HttpClientService {
|
|
|
21
21
|
this.put = (url, data, config) => this.request('PUT', url, config, data);
|
|
22
22
|
this.patch = (url, data, config) => this.request('PATCH', url, config, data);
|
|
23
23
|
this.request = (method, url, config = {}, data) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
headers[constants_1.ACTIVE_ORG_ID_HEADER] = this.activeOrg;
|
|
31
|
-
}
|
|
32
|
-
return this.axiosInstance.request({ ...config, headers, method, url, data });
|
|
33
|
-
})
|
|
34
|
-
.then((response) => resolve(response.data))
|
|
35
|
-
.catch(reject);
|
|
36
|
-
}));
|
|
24
|
+
if (this.requestQueue) {
|
|
25
|
+
return this.requestQueue.add(() => this.requestPromise(method, url, config, data));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return this.requestPromise(method, url, config, data);
|
|
29
|
+
}
|
|
37
30
|
};
|
|
38
31
|
this.getAccessToken = async (forceRefresh = false) => {
|
|
39
32
|
let accessToken;
|
|
@@ -57,6 +50,21 @@ class HttpClientService {
|
|
|
57
50
|
return accessToken;
|
|
58
51
|
}
|
|
59
52
|
};
|
|
53
|
+
this.requestPromise = (method, url, config = {}, data) => {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
const tokenP = config.token ? Promise.resolve(config.token) : this.getAccessToken();
|
|
56
|
+
tokenP
|
|
57
|
+
.then((token) => {
|
|
58
|
+
const headers = { Authorization: `Bearer ${token}`, ...config.headers };
|
|
59
|
+
if (this.activeOrg) {
|
|
60
|
+
headers[constants_1.ACTIVE_ORG_ID_HEADER] = this.activeOrg;
|
|
61
|
+
}
|
|
62
|
+
return this.axiosInstance.request({ ...config, headers, method, url, data });
|
|
63
|
+
})
|
|
64
|
+
.then((response) => resolve(response.data))
|
|
65
|
+
.catch(reject);
|
|
66
|
+
});
|
|
67
|
+
};
|
|
60
68
|
this.baseURL = config.baseURL;
|
|
61
69
|
this.authBaseURL = config.authBaseURL || config.baseURL;
|
|
62
70
|
this.realm = config.realm;
|
|
@@ -66,7 +74,9 @@ class HttpClientService {
|
|
|
66
74
|
this.activeOrg = config.activeOrg;
|
|
67
75
|
this.axiosInstance = axios_1.default.create({ baseURL: this.baseURL, timeout: 60000 });
|
|
68
76
|
this.authAxiosInstance = axios_1.default.create({ baseURL: this.authBaseURL, timeout: 10000 });
|
|
69
|
-
|
|
77
|
+
if (config.queueOptions) {
|
|
78
|
+
this.requestQueue = new queue_1.Queue(config.queueOptions);
|
|
79
|
+
}
|
|
70
80
|
}
|
|
71
81
|
getSseObservable(path) {
|
|
72
82
|
return new rxjs_1.Observable((subscriber) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { APIBase } from '../api-base';
|
|
3
|
-
import { Filter, Organization, OrganizationCreateDto,
|
|
3
|
+
import { Filter, Organization, OrganizationCreateDto, OrganizationResourcesProgress, OrganizationSearchQuery, Paginated, RequestParameter, ServerSentEvent, SubscriptionType, UserWithOrgRoles } from '../interfaces';
|
|
4
4
|
import { HttpClientService } from './';
|
|
5
5
|
/**
|
|
6
6
|
* Service for managing organizations with administrative privileges (superuser role required).
|
|
@@ -42,12 +42,12 @@ export declare class OrganizationsAdministrationService extends APIBase {
|
|
|
42
42
|
* The owner of the organization can be either the user or the service account 'organization-client', depending on the 'createOrgAsOwner' flag in the OrganizationCreateFlowDto.
|
|
43
43
|
*
|
|
44
44
|
* @param {OrganizationCreateDto} organizationCreateDto - The data transfer object containing the organization details for creation
|
|
45
|
-
* @param {string}
|
|
46
|
-
* @param {
|
|
45
|
+
* @param {string[]} emailsToInvite - The email addresses of the users to be invited to the organization
|
|
46
|
+
* @param {string[]} emailsToAdd - The email addresses of the users to be added without an invitation to the organization
|
|
47
47
|
* @param {boolean} createOrgAsOwner - Whether to create the organization with the user as the owner
|
|
48
48
|
* @returns {Promise<Organization>} - An promise of the created organization
|
|
49
49
|
*/
|
|
50
|
-
createOrganization(organizationCreateDto: OrganizationCreateDto,
|
|
50
|
+
createOrganization(organizationCreateDto: OrganizationCreateDto, emailsToInvite: string[], emailsToAdd: string[], createOrgAsOwner?: boolean): Promise<Organization>;
|
|
51
51
|
addOrganizationMembers(id: string, usersWithOrgRoles: UserWithOrgRoles[]): Promise<void>;
|
|
52
52
|
addSubscriptionToOrganization(id: string, type: SubscriptionType): Promise<Organization>;
|
|
53
53
|
/**
|
|
@@ -57,16 +57,16 @@ class OrganizationsAdministrationService extends api_base_1.APIBase {
|
|
|
57
57
|
* The owner of the organization can be either the user or the service account 'organization-client', depending on the 'createOrgAsOwner' flag in the OrganizationCreateFlowDto.
|
|
58
58
|
*
|
|
59
59
|
* @param {OrganizationCreateDto} organizationCreateDto - The data transfer object containing the organization details for creation
|
|
60
|
-
* @param {string}
|
|
61
|
-
* @param {
|
|
60
|
+
* @param {string[]} emailsToInvite - The email addresses of the users to be invited to the organization
|
|
61
|
+
* @param {string[]} emailsToAdd - The email addresses of the users to be added without an invitation to the organization
|
|
62
62
|
* @param {boolean} createOrgAsOwner - Whether to create the organization with the user as the owner
|
|
63
63
|
* @returns {Promise<Organization>} - An promise of the created organization
|
|
64
64
|
*/
|
|
65
|
-
createOrganization(organizationCreateDto,
|
|
65
|
+
createOrganization(organizationCreateDto, emailsToInvite, emailsToAdd, createOrgAsOwner = false) {
|
|
66
66
|
return this.httpClient.post(`${this.basePath}/create-org`, {
|
|
67
67
|
organizationDto: organizationCreateDto,
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
emailsToInvite,
|
|
69
|
+
emailsToAdd,
|
|
70
70
|
createOrgAsOwner,
|
|
71
71
|
});
|
|
72
72
|
}
|