@hahnpro/hpc-api 2025.2.2 → 2025.2.4

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/README.md CHANGED
@@ -61,6 +61,8 @@ defaults to `https://testing.hahnpro.com`), `AUTH_BASE_URL` (defaults to `API_BA
61
61
 
62
62
  ```typescript
63
63
  import { API } from '@hahnpro/flow-sdk';
64
+ // or by using dotenv
65
+ import * as dotenv from 'dotenv';
64
66
 
65
67
  // explicitly set the envs
66
68
  process.env.API_BASE_URL = '*your API URL*';
@@ -69,9 +71,6 @@ process.env.AUTH_REALM = '*the Keycloak Realm*';
69
71
  process.env.API_USER = '*your username*';
70
72
  process.env.AUTH_SECRET = '*your secret*';
71
73
 
72
- // or by using dotenv
73
- import * as dotenv from 'dotenv';
74
-
75
74
  dotenv.config();
76
75
 
77
76
  const api = new API();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hahnpro/hpc-api",
3
- "version": "2025.2.2",
3
+ "version": "2025.2.4",
4
4
  "description": "Module for easy access to the HahnPRO Cloud API",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -8,10 +8,10 @@
8
8
  "url": "https://hahnpro.com"
9
9
  },
10
10
  "dependencies": {
11
- "axios": "1.7.9",
11
+ "axios": "1.8.2",
12
12
  "eventsource": "3.0.5",
13
13
  "form-data": "4.0.2",
14
- "jose": "5.9.6",
14
+ "jose": "5.10.0",
15
15
  "jwt-decode": "4.0.0",
16
16
  "p-queue": "6.6.2",
17
17
  "ts-mixer": "6.0.4",
package/src/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './lib/api';
2
+ export type * from './lib/interfaces';
2
3
  export * from './lib/asset.interface';
3
4
  export * from './lib/content.interface';
4
5
  export * from './lib/data.interface';
package/src/lib/api.d.ts CHANGED
@@ -10,14 +10,17 @@ import { FlowService } from './flow.service';
10
10
  import { HttpClient } from './http.service';
11
11
  import { LabelService } from './label.service';
12
12
  import { NotificationService } from './notification.service';
13
+ import { OrganizationService } from './organization.service';
13
14
  import { ProxyService } from './proxy.service';
14
15
  import { SecretService } from './secret.service';
16
+ import { AiService } from './services';
15
17
  import { TaskService } from './task.service';
16
18
  import { TimeSeriesService } from './timeseries.service';
17
19
  import { UserService } from './user.service';
18
20
  import { VaultService } from './vault.service';
19
21
  export declare class API {
20
22
  readonly httpClient?: HttpClient;
23
+ ai: AiService;
21
24
  assets: AssetService;
22
25
  assetTypes: AssetTypesService;
23
26
  contents: ContentService;
@@ -28,6 +31,7 @@ export declare class API {
28
31
  flowFunctions: FlowFunctionService;
29
32
  flowModules: FlowModuleService;
30
33
  labels: LabelService;
34
+ organizations: OrganizationService;
31
35
  proxy: ProxyService;
32
36
  secrets: SecretService;
33
37
  tasks: TaskService;
package/src/lib/api.js CHANGED
@@ -13,8 +13,10 @@ const flow_service_1 = require("./flow.service");
13
13
  const http_service_1 = require("./http.service");
14
14
  const label_service_1 = require("./label.service");
15
15
  const notification_service_1 = require("./notification.service");
16
+ const organization_service_1 = require("./organization.service");
16
17
  const proxy_service_1 = require("./proxy.service");
17
18
  const secret_service_1 = require("./secret.service");
19
+ const services_1 = require("./services");
18
20
  const task_service_1 = require("./task.service");
19
21
  const timeseries_service_1 = require("./timeseries.service");
20
22
  const user_service_1 = require("./user.service");
@@ -42,6 +44,7 @@ class API {
42
44
  }
43
45
  this.httpClient = new http_service_1.HttpClient(apiUrl, authUrl, realm, client, secret, context?.tokenSubject);
44
46
  }
47
+ this.ai = new services_1.AiService(this.httpClient);
45
48
  this.assets = new asset_service_1.AssetService(this.httpClient);
46
49
  this.assetTypes = new assettypes_service_1.AssetTypesService(this.httpClient);
47
50
  this.contents = new content_service_1.ContentService(this.httpClient);
@@ -52,6 +55,7 @@ class API {
52
55
  this.flowFunctions = new flow_function_service_1.FlowFunctionService(this.httpClient);
53
56
  this.flowModules = new flow_module_service_1.FlowModuleService(this.httpClient);
54
57
  this.labels = new label_service_1.LabelService(this.httpClient);
58
+ this.organizations = new organization_service_1.OrganizationService(this.httpClient);
55
59
  this.proxy = new proxy_service_1.ProxyService(this.httpClient);
56
60
  this.secrets = new secret_service_1.SecretService(this.httpClient);
57
61
  this.tasks = new task_service_1.TaskService(this.httpClient);
@@ -0,0 +1,4 @@
1
+ export interface SpeechToken {
2
+ token: string;
3
+ region: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export type { SpeechToken } from './ai.interface';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ import { APIBase } from '../api-base';
2
+ import { HttpClient } from '../http.service';
3
+ import { SpeechToken } from '../interfaces';
4
+ import { AiService } from '../services';
5
+ export declare class AiMockService extends APIBase implements AiService {
6
+ httpClient: HttpClient;
7
+ basePath: string;
8
+ getSpeechToken(): Promise<SpeechToken>;
9
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AiMockService = void 0;
4
+ const api_base_1 = require("../api-base");
5
+ class AiMockService extends api_base_1.APIBase {
6
+ async getSpeechToken() {
7
+ throw new Error('Method not implemented.');
8
+ }
9
+ }
10
+ exports.AiMockService = AiMockService;
@@ -13,7 +13,9 @@ import { FlowDiagram, FlowDto, FlowRevision } from '../flow.interface';
13
13
  import { FlowService } from '../flow.service';
14
14
  import { Label } from '../label.interface';
15
15
  import { Notification } from '../notification.interface';
16
+ import { Organization } from '../organization.interface';
16
17
  import { Secret } from '../secret.interface';
18
+ import { AiService } from '../services';
17
19
  import { Artifact } from '../storage.interface';
18
20
  import { Task } from '../task.interface';
19
21
  import { TimeSeries, TimeSeriesValue } from '../timeseries.interface';
@@ -26,6 +28,7 @@ import { EventsMockService } from './events.mock.service';
26
28
  import { HttpMockService } from './http.mock.service';
27
29
  import { LabelMockService } from './label.mock.service';
28
30
  import { NotificationMockService } from './notification.mock.service';
31
+ import { OrganizationMockService } from './organization.mock.service';
29
32
  import { SecretMockService } from './secret.mock.service';
30
33
  import { TaskMockService } from './task.mock.service';
31
34
  import { TimeseriesMockService } from './timeseries.mock.service';
@@ -51,8 +54,10 @@ export interface MockAPIInitData {
51
54
  labels?: LabelInit[];
52
55
  vault?: VaultSecretInit[];
53
56
  notifications?: NotificationInit[];
57
+ organizations?: OrganizationInit[];
54
58
  }
55
59
  export declare class MockAPI implements API {
60
+ ai: AiService;
56
61
  httpClient: HttpMockService;
57
62
  assets: AssetMockService;
58
63
  assetTypes: AssetTypesMockService;
@@ -71,6 +76,7 @@ export declare class MockAPI implements API {
71
76
  users: UserMockService;
72
77
  vault: VaultMockService;
73
78
  notifications: NotificationMockService;
79
+ organizations: OrganizationMockService;
74
80
  constructor(initData: MockAPIInitData);
75
81
  }
76
82
  export type Identity<T> = {
@@ -107,6 +113,7 @@ export type FlowDiagramInit = AtLeast<FlowDiagram, 'id' | 'flow'>;
107
113
  export type LabelInit = AtLeast<Label, 'id' | 'name'>;
108
114
  export type VaultSecretInit = AtLeast<VaultSecret, 'name' | 'secret'>;
109
115
  export type NotificationInit = AtLeast<Notification, 'id' | 'name' | 'userId' | 'notificationType'>;
116
+ export type OrganizationInit = AtLeast<Organization, 'id' | 'name'>;
110
117
  export interface UserInit {
111
118
  roles: string[];
112
119
  }
@@ -16,6 +16,7 @@ const flow_mock_service_1 = require("./flow.mock.service");
16
16
  const http_mock_service_1 = require("./http.mock.service");
17
17
  const label_mock_service_1 = require("./label.mock.service");
18
18
  const notification_mock_service_1 = require("./notification.mock.service");
19
+ const organization_mock_service_1 = require("./organization.mock.service");
19
20
  const secret_mock_service_1 = require("./secret.mock.service");
20
21
  const task_mock_service_1 = require("./task.mock.service");
21
22
  const timeseries_mock_service_1 = require("./timeseries.mock.service");
@@ -24,7 +25,7 @@ const vault_mock_service_1 = require("./vault.mock.service");
24
25
  class MockAPI {
25
26
  constructor(initData) {
26
27
  this.proxy = null;
27
- const { assets = [], assetRevisions = [], contents = [], endpoints = [], secrets = [], timeSeries = [], tasks = [], events = [], users, flows = [], flowRevisions = [], deployments = [], functions = [], functionRevisions = [], modules = [], diagrams = [], labels = [], vault = [], notifications = [], } = initData;
28
+ const { assets = [], assetRevisions = [], contents = [], endpoints = [], secrets = [], timeSeries = [], tasks = [], events = [], users, flows = [], flowRevisions = [], deployments = [], functions = [], functionRevisions = [], modules = [], diagrams = [], labels = [], vault = [], notifications = [], organizations = [], } = initData;
28
29
  // convert init data to normal data that the services usually use
29
30
  const assetTypes = assets
30
31
  .map((v) => v.type)
@@ -182,6 +183,10 @@ class MockAPI {
182
183
  description: v.description ?? '',
183
184
  read: v.read ?? false,
184
185
  }));
186
+ const organizations1 = organizations.map((v) => ({
187
+ ...v,
188
+ domains: v.domains ?? [],
189
+ }));
185
190
  this.assets = new asset_mock_service_1.AssetMockService(this, assets1, assetRevisions1);
186
191
  this.assetTypes = new assetTypes_mock_service_1.AssetTypesMockService(assetTypes, []);
187
192
  this.contents = new content_mock_service_1.ContentMockService(contents1, contentData);
@@ -198,6 +203,7 @@ class MockAPI {
198
203
  this.labels = new label_mock_service_1.LabelMockService(labels1);
199
204
  this.vault = new vault_mock_service_1.VaultMockService(vaultSecrets1);
200
205
  this.notifications = new notification_mock_service_1.NotificationMockService(notifications1);
206
+ this.organizations = new organization_mock_service_1.OrganizationMockService(organizations1);
201
207
  this.httpClient = new http_mock_service_1.HttpMockService();
202
208
  }
203
209
  }
@@ -10,3 +10,4 @@ export * from './task.mock.service';
10
10
  export * from './events.mock.service';
11
11
  export * from './vault.mock.service';
12
12
  export * from './notification.mock.service';
13
+ export * from './organization.mock.service';
@@ -13,3 +13,4 @@ tslib_1.__exportStar(require("./task.mock.service"), exports);
13
13
  tslib_1.__exportStar(require("./events.mock.service"), exports);
14
14
  tslib_1.__exportStar(require("./vault.mock.service"), exports);
15
15
  tslib_1.__exportStar(require("./notification.mock.service"), exports);
16
+ tslib_1.__exportStar(require("./organization.mock.service"), exports);
@@ -0,0 +1,7 @@
1
+ import { Organization } from '../organization.interface';
2
+ import { OrganizationService } from '../organization.service';
3
+ import { DataMockService } from './data.mock.service';
4
+ export declare class OrganizationMockService extends DataMockService<Organization> implements OrganizationService {
5
+ constructor(organizations: Organization[]);
6
+ addOrganizationInvitation(id: string, email: string, roles: string[]): Promise<void>;
7
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrganizationMockService = void 0;
4
+ const data_mock_service_1 = require("./data.mock.service");
5
+ class OrganizationMockService extends data_mock_service_1.DataMockService {
6
+ constructor(organizations) {
7
+ super();
8
+ this.data = organizations;
9
+ }
10
+ addOrganizationInvitation(id, email, roles) {
11
+ if (!id || !email || !roles?.length) {
12
+ return Promise.reject();
13
+ }
14
+ return Promise.resolve();
15
+ }
16
+ }
17
+ exports.OrganizationMockService = OrganizationMockService;
@@ -0,0 +1,25 @@
1
+ import { Author } from './resource.interface';
2
+ export interface Organization {
3
+ id?: string;
4
+ name: string;
5
+ description?: string;
6
+ realm?: string;
7
+ domains?: string[];
8
+ logo?: string;
9
+ addressLine?: string;
10
+ zipCode?: string;
11
+ city?: string;
12
+ phoneNumber?: string;
13
+ website?: string;
14
+ vat?: string;
15
+ certificates?: string[];
16
+ services?: string[];
17
+ subscriptionId?: string;
18
+ previousSubscriptions?: string[];
19
+ assetId?: string;
20
+ verified?: boolean;
21
+ createdAt?: Date | string;
22
+ updatedAt?: Date | string;
23
+ createdBy?: Author;
24
+ updatedBy?: Author;
25
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { DataService } from './data.service';
2
+ import { HttpClient } from './http.service';
3
+ import { Organization } from './organization.interface';
4
+ export declare class OrganizationService extends DataService<Organization> {
5
+ constructor(httpClient: HttpClient);
6
+ addOrganizationInvitation(id: string, email: string, roles: string[]): Promise<void>;
7
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrganizationService = void 0;
4
+ const data_service_1 = require("./data.service");
5
+ class OrganizationService extends data_service_1.DataService {
6
+ constructor(httpClient) {
7
+ super(httpClient, '/organizations');
8
+ }
9
+ addOrganizationInvitation(id, email, roles) {
10
+ return this.httpClient.post(`${this.basePath}/${id}/data/invitations`, { roles, email });
11
+ }
12
+ }
13
+ exports.OrganizationService = OrganizationService;
@@ -0,0 +1,7 @@
1
+ import { APIBase } from '../api-base';
2
+ import { HttpClient } from '../http.service';
3
+ import { SpeechToken } from '../interfaces';
4
+ export declare class AiService extends APIBase {
5
+ constructor(httpClient: HttpClient);
6
+ getSpeechToken(): Promise<SpeechToken>;
7
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AiService = void 0;
4
+ const api_base_1 = require("../api-base");
5
+ class AiService extends api_base_1.APIBase {
6
+ constructor(httpClient) {
7
+ super(httpClient, '/assistants');
8
+ }
9
+ async getSpeechToken() {
10
+ return this.httpClient.get(`${this.basePath}/speech/token`);
11
+ }
12
+ }
13
+ exports.AiService = AiService;
@@ -0,0 +1 @@
1
+ export { AiService } from './ai.service';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AiService = void 0;
4
+ var ai_service_1 = require("./ai.service");
5
+ Object.defineProperty(exports, "AiService", { enumerable: true, get: function () { return ai_service_1.AiService; } });
@@ -1,7 +1,6 @@
1
1
  export interface UserSettings {
2
2
  userId: string;
3
3
  language: string;
4
- activeRoles: Permission[];
5
4
  creationReadRoles: Permission[];
6
5
  creationWriteRoles: Permission[];
7
6
  activeTags: string[];