@hahnpro/hpc-api 5.3.4 → 2024.4.0-0

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.
Files changed (196) hide show
  1. package/package.json +8 -24
  2. package/src/index.d.ts +20 -0
  3. package/src/index.js +20 -0
  4. package/{dist → src/lib}/Queue.js +2 -7
  5. package/src/lib/api-base.js +6 -0
  6. package/src/lib/api.js +60 -0
  7. package/src/lib/asset.interface.js +1 -0
  8. package/src/lib/asset.service.d.ts +24 -0
  9. package/src/lib/asset.service.js +51 -0
  10. package/{dist → src/lib}/assettypes.service.d.ts +4 -4
  11. package/src/lib/assettypes.service.js +24 -0
  12. package/{dist → src/lib}/content.interface.js +2 -5
  13. package/src/lib/content.service.d.ts +23 -0
  14. package/src/lib/content.service.js +49 -0
  15. package/src/lib/data.interface.d.ts +38 -0
  16. package/src/lib/data.interface.js +3 -0
  17. package/src/lib/data.service.d.ts +27 -0
  18. package/src/lib/data.service.js +57 -0
  19. package/src/lib/endpoint.interface.js +1 -0
  20. package/src/lib/endpoint.service.d.ts +8 -0
  21. package/src/lib/endpoint.service.js +12 -0
  22. package/src/lib/events.interface.js +1 -0
  23. package/{dist → src/lib}/events.service.d.ts +2 -2
  24. package/src/lib/events.service.js +9 -0
  25. package/src/lib/flow-deployment.interface.js +1 -0
  26. package/{dist → src/lib}/flow-deployment.service.d.ts +15 -13
  27. package/src/lib/flow-deployment.service.js +68 -0
  28. package/src/lib/flow-function.interface.js +1 -0
  29. package/src/lib/flow-function.service.d.ts +11 -0
  30. package/src/lib/flow-function.service.js +20 -0
  31. package/src/lib/flow-module.interface.js +1 -0
  32. package/src/lib/flow-module.service.d.ts +11 -0
  33. package/{dist → src/lib}/flow-module.service.js +9 -12
  34. package/src/lib/flow.interface.js +1 -0
  35. package/src/lib/flow.service.d.ts +26 -0
  36. package/src/lib/flow.service.js +49 -0
  37. package/{dist → src/lib}/http.service.d.ts +12 -6
  38. package/src/lib/http.service.js +179 -0
  39. package/src/lib/label.interface.js +1 -0
  40. package/src/lib/label.service.d.ts +9 -0
  41. package/src/lib/label.service.js +15 -0
  42. package/src/lib/mock/api-base.mock.js +7 -0
  43. package/src/lib/mock/api.mock.js +199 -0
  44. package/{dist → src/lib}/mock/asset.mock.service.js +30 -41
  45. package/{dist → src/lib}/mock/assetTypes.mock.service.js +19 -27
  46. package/{dist → src/lib}/mock/content.mock.service.js +21 -24
  47. package/src/lib/mock/data.mock.service.js +93 -0
  48. package/{dist → src/lib}/mock/endpoint.mock.service.js +2 -6
  49. package/src/lib/mock/events.mock.service.js +10 -0
  50. package/src/lib/mock/flow-deployment.mock.service.js +118 -0
  51. package/{dist → src/lib}/mock/flow-functions.mock.service.js +12 -21
  52. package/src/lib/mock/flow-modules.mock.service.js +20 -0
  53. package/src/lib/mock/flow.mock.service.js +81 -0
  54. package/src/lib/mock/index.js +11 -0
  55. package/src/lib/mock/label.mock.service.js +13 -0
  56. package/src/lib/mock/notification.mock.service.js +7 -0
  57. package/src/lib/mock/secret.mock.service.js +28 -0
  58. package/src/lib/mock/task.mock.service.js +32 -0
  59. package/{dist → src/lib}/mock/timeseries.mock.service.js +40 -49
  60. package/{dist → src/lib}/mock/trash.mock.service.js +8 -15
  61. package/src/lib/mock/user.mock.service.js +10 -0
  62. package/{dist → src/lib}/mock/vault.mock.service.js +2 -6
  63. package/src/lib/notification.interface.js +1 -0
  64. package/src/lib/notification.service.js +6 -0
  65. package/src/lib/proxy.service.d.ts +11 -0
  66. package/{dist → src/lib}/proxy.service.js +1 -5
  67. package/src/lib/resource.interface.js +1 -0
  68. package/src/lib/schema.interface.js +1 -0
  69. package/src/lib/secret.interface.js +1 -0
  70. package/src/lib/secret.service.js +15 -0
  71. package/src/lib/storage.interface.js +1 -0
  72. package/src/lib/task.interface.js +1 -0
  73. package/{dist → src/lib}/task.service.d.ts +2 -2
  74. package/src/lib/task.service.js +19 -0
  75. package/src/lib/timeseries.interface.js +1 -0
  76. package/{dist → src/lib}/timeseries.service.d.ts +10 -8
  77. package/src/lib/timeseries.service.js +92 -0
  78. package/{dist → src/lib}/token-set.d.ts +3 -1
  79. package/src/lib/token-set.js +23 -0
  80. package/{dist → src/lib}/trash.service.js +2 -6
  81. package/src/lib/user-settings.interface.js +1 -0
  82. package/src/lib/user.service.d.ts +11 -0
  83. package/src/lib/user.service.js +26 -0
  84. package/src/lib/vault.interface.js +1 -0
  85. package/{dist → src/lib}/vault.service.d.ts +2 -2
  86. package/src/lib/vault.service.js +10 -0
  87. package/LICENSE +0 -21
  88. package/dist/api-base.js +0 -10
  89. package/dist/api.js +0 -62
  90. package/dist/asset.interface.js +0 -2
  91. package/dist/asset.service.d.ts +0 -24
  92. package/dist/asset.service.js +0 -53
  93. package/dist/assettypes.service.js +0 -28
  94. package/dist/content.service.d.ts +0 -23
  95. package/dist/content.service.js +0 -50
  96. package/dist/data.interface.d.ts +0 -31
  97. package/dist/data.interface.js +0 -6
  98. package/dist/data.service.d.ts +0 -21
  99. package/dist/data.service.js +0 -50
  100. package/dist/endpoint.interface.js +0 -2
  101. package/dist/endpoint.service.d.ts +0 -8
  102. package/dist/endpoint.service.js +0 -16
  103. package/dist/events.interface.js +0 -2
  104. package/dist/events.service.js +0 -13
  105. package/dist/flow-deployment.interface.js +0 -2
  106. package/dist/flow-deployment.service.js +0 -74
  107. package/dist/flow-function.interface.js +0 -2
  108. package/dist/flow-function.service.d.ts +0 -11
  109. package/dist/flow-function.service.js +0 -23
  110. package/dist/flow-module.interface.js +0 -2
  111. package/dist/flow-module.service.d.ts +0 -11
  112. package/dist/flow.interface.js +0 -2
  113. package/dist/flow.service.d.ts +0 -24
  114. package/dist/flow.service.js +0 -54
  115. package/dist/http.service.js +0 -161
  116. package/dist/index.d.ts +0 -20
  117. package/dist/index.js +0 -23
  118. package/dist/label.interface.js +0 -2
  119. package/dist/label.service.d.ts +0 -9
  120. package/dist/label.service.js +0 -19
  121. package/dist/mock/api-base.mock.js +0 -11
  122. package/dist/mock/api.mock.js +0 -128
  123. package/dist/mock/data.mock.service.js +0 -96
  124. package/dist/mock/events.mock.service.js +0 -14
  125. package/dist/mock/flow-deployment.mock.service.js +0 -142
  126. package/dist/mock/flow-modules.mock.service.js +0 -27
  127. package/dist/mock/flow.mock.service.js +0 -93
  128. package/dist/mock/index.js +0 -14
  129. package/dist/mock/label.mock.service.js +0 -17
  130. package/dist/mock/notification.mock.service.js +0 -11
  131. package/dist/mock/secret.mock.service.js +0 -31
  132. package/dist/mock/task.mock.service.js +0 -37
  133. package/dist/mock/user.mock.service.js +0 -14
  134. package/dist/notification.interface.js +0 -2
  135. package/dist/notification.service.js +0 -10
  136. package/dist/proxy.service.d.ts +0 -11
  137. package/dist/resource.interface.js +0 -2
  138. package/dist/schema.interface.js +0 -2
  139. package/dist/secret.interface.js +0 -2
  140. package/dist/secret.service.js +0 -19
  141. package/dist/storage.interface.js +0 -2
  142. package/dist/task.interface.js +0 -2
  143. package/dist/task.service.js +0 -22
  144. package/dist/timeseries.interface.js +0 -2
  145. package/dist/timeseries.service.js +0 -56
  146. package/dist/token-set.js +0 -23
  147. package/dist/user-settings.interface.js +0 -2
  148. package/dist/user.service.d.ts +0 -11
  149. package/dist/user.service.js +0 -33
  150. package/dist/vault.interface.js +0 -2
  151. package/dist/vault.service.js +0 -14
  152. package/{dist → src/lib}/Queue.d.ts +0 -0
  153. package/{dist → src/lib}/api-base.d.ts +0 -0
  154. package/{dist → src/lib}/api.d.ts +6 -6
  155. package/{dist → src/lib}/asset.interface.d.ts +0 -0
  156. package/{dist → src/lib}/content.interface.d.ts +0 -0
  157. package/{dist → src/lib}/endpoint.interface.d.ts +0 -0
  158. package/{dist → src/lib}/events.interface.d.ts +0 -0
  159. package/{dist → src/lib}/flow-deployment.interface.d.ts +1 -1
  160. package/{dist → src/lib}/flow-function.interface.d.ts +0 -0
  161. package/{dist → src/lib}/flow-module.interface.d.ts +0 -0
  162. package/{dist → src/lib}/flow.interface.d.ts +1 -1
  163. package/{dist → src/lib}/label.interface.d.ts +0 -0
  164. package/{dist → src/lib}/mock/api-base.mock.d.ts +0 -0
  165. package/{dist → src/lib}/mock/api.mock.d.ts +18 -18
  166. package/{dist → src/lib}/mock/asset.mock.service.d.ts +1 -1
  167. package/{dist → src/lib}/mock/assetTypes.mock.service.d.ts +0 -0
  168. package/{dist → src/lib}/mock/content.mock.service.d.ts +1 -1
  169. package/{dist → src/lib}/mock/data.mock.service.d.ts +0 -0
  170. package/{dist → src/lib}/mock/endpoint.mock.service.d.ts +0 -0
  171. package/{dist → src/lib}/mock/events.mock.service.d.ts +0 -0
  172. package/{dist → src/lib}/mock/flow-deployment.mock.service.d.ts +2 -2
  173. package/{dist → src/lib}/mock/flow-functions.mock.service.d.ts +1 -1
  174. package/{dist → src/lib}/mock/flow-modules.mock.service.d.ts +2 -2
  175. package/{dist → src/lib}/mock/flow.mock.service.d.ts +1 -1
  176. package/{dist → src/lib}/mock/index.d.ts +0 -0
  177. package/{dist → src/lib}/mock/label.mock.service.d.ts +1 -1
  178. package/{dist → src/lib}/mock/notification.mock.service.d.ts +1 -1
  179. package/{dist → src/lib}/mock/secret.mock.service.d.ts +1 -1
  180. package/{dist → src/lib}/mock/task.mock.service.d.ts +0 -0
  181. package/{dist → src/lib}/mock/timeseries.mock.service.d.ts +0 -0
  182. package/{dist → src/lib}/mock/trash.mock.service.d.ts +1 -1
  183. package/{dist → src/lib}/mock/user.mock.service.d.ts +0 -0
  184. package/{dist → src/lib}/mock/vault.mock.service.d.ts +1 -1
  185. package/{dist → src/lib}/notification.interface.d.ts +0 -0
  186. package/{dist → src/lib}/notification.service.d.ts +1 -1
  187. /package/{dist → src/lib}/resource.interface.d.ts +0 -0
  188. /package/{dist → src/lib}/schema.interface.d.ts +0 -0
  189. /package/{dist → src/lib}/secret.interface.d.ts +0 -0
  190. /package/{dist → src/lib}/secret.service.d.ts +0 -0
  191. /package/{dist → src/lib}/storage.interface.d.ts +0 -0
  192. /package/{dist → src/lib}/task.interface.d.ts +0 -0
  193. /package/{dist → src/lib}/timeseries.interface.d.ts +0 -0
  194. /package/{dist → src/lib}/trash.service.d.ts +0 -0
  195. /package/{dist → src/lib}/user-settings.interface.d.ts +0 -0
  196. /package/{dist → src/lib}/vault.interface.d.ts +0 -0
package/package.json CHANGED
@@ -1,28 +1,12 @@
1
1
  {
2
2
  "name": "@hahnpro/hpc-api",
3
- "version": "5.3.4",
4
- "description": "Module for easy access to the HahnPRO API",
3
+ "version": "2024.4.0-0",
4
+ "description": "Module for easy access to the HahnPRO Cloud API",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Hahn Projects GmbH",
8
8
  "url": "https://hahnpro.com"
9
9
  },
10
- "repository": {
11
- "type": "git",
12
- "url": "git@github.com:hahnprojects/flow.git"
13
- },
14
- "directories": {
15
- "lib": "lib",
16
- "test": "test"
17
- },
18
- "files": [
19
- "dist"
20
- ],
21
- "main": "./dist/index.js",
22
- "types": "./dist/index.d.ts",
23
- "publishConfig": {
24
- "access": "public"
25
- },
26
10
  "dependencies": {
27
11
  "axios": "1.7.9",
28
12
  "eventsource": "2.0.2",
@@ -31,17 +15,17 @@
31
15
  "jwt-decode": "4.0.0",
32
16
  "p-queue": "6.6.2",
33
17
  "ts-mixer": "6.0.4",
34
- "uuid": "11.0.5"
18
+ "tslib": "2.8.1"
35
19
  },
36
20
  "devDependencies": {
37
21
  "@types/eventsource": "1.1.15",
38
22
  "axios-mock-adapter": "2.1.0"
39
23
  },
40
24
  "engines": {
41
- "node": ">=v18"
25
+ "node": ">=v20"
42
26
  },
43
- "scripts": {
44
- "build": "../../node_modules/.bin/tsc -p tsconfig.lib.json",
45
- "build:nocomments": "../../node_modules/.bin/tsc -p tsconfig.nocomments.json"
46
- }
27
+ "main": "./src/index.js",
28
+ "types": "./src/index.d.ts",
29
+ "module": "./lib/hpc-api/src/index.js",
30
+ "type": "module"
47
31
  }
package/src/index.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ export * from './lib/api';
2
+ export * from './lib/asset.interface';
3
+ export * from './lib/content.interface';
4
+ export * from './lib/data.interface';
5
+ export * from './lib/data.service';
6
+ export * from './lib/endpoint.interface';
7
+ export * from './lib/events.interface';
8
+ export * from './lib/flow.interface';
9
+ export * from './lib/flow-deployment.interface';
10
+ export * from './lib/flow-function.interface';
11
+ export * from './lib/http.service';
12
+ export * from './lib/label.interface';
13
+ export * from './lib/mock';
14
+ export * from './lib/notification.interface';
15
+ export * from './lib/resource.interface';
16
+ export * from './lib/schema.interface';
17
+ export * from './lib/secret.interface';
18
+ export * from './lib/task.interface';
19
+ export * from './lib/timeseries.interface';
20
+ export * from './lib/vault.interface';
package/src/index.js ADDED
@@ -0,0 +1,20 @@
1
+ export * from './lib/api';
2
+ export * from './lib/asset.interface';
3
+ export * from './lib/content.interface';
4
+ export * from './lib/data.interface';
5
+ export * from './lib/data.service';
6
+ export * from './lib/endpoint.interface';
7
+ export * from './lib/events.interface';
8
+ export * from './lib/flow.interface';
9
+ export * from './lib/flow-deployment.interface';
10
+ export * from './lib/flow-function.interface';
11
+ export * from './lib/http.service';
12
+ export * from './lib/label.interface';
13
+ export * from './lib/mock';
14
+ export * from './lib/notification.interface';
15
+ export * from './lib/resource.interface';
16
+ export * from './lib/schema.interface';
17
+ export * from './lib/secret.interface';
18
+ export * from './lib/task.interface';
19
+ export * from './lib/timeseries.interface';
20
+ export * from './lib/vault.interface';
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Queue = void 0;
4
- const tslib_1 = require("tslib");
5
- const p_queue_1 = tslib_1.__importDefault(require("p-queue"));
6
- class Queue extends p_queue_1.default {
1
+ import PQueue from 'p-queue';
2
+ export class Queue extends PQueue {
7
3
  constructor(options) {
8
4
  super(options);
9
5
  this.peak = 0;
@@ -24,4 +20,3 @@ class Queue extends p_queue_1.default {
24
20
  };
25
21
  }
26
22
  }
27
- exports.Queue = Queue;
@@ -0,0 +1,6 @@
1
+ export class APIBase {
2
+ constructor(httpClient, basePath) {
3
+ this.httpClient = httpClient;
4
+ this.basePath = basePath;
5
+ }
6
+ }
package/src/lib/api.js ADDED
@@ -0,0 +1,60 @@
1
+ import { AssetService } from './asset.service';
2
+ import { AssetTypesService } from './assettypes.service';
3
+ import { ContentService } from './content.service';
4
+ import { EndpointService } from './endpoint.service';
5
+ import { EventsService } from './events.service';
6
+ import { FlowDeploymentService } from './flow-deployment.service';
7
+ import { FlowFunctionService } from './flow-function.service';
8
+ import { FlowModuleService } from './flow-module.service';
9
+ import { FlowService } from './flow.service';
10
+ import { HttpClient } from './http.service';
11
+ import { LabelService } from './label.service';
12
+ import { NotificationService } from './notification.service';
13
+ import { ProxyService } from './proxy.service';
14
+ import { SecretService } from './secret.service';
15
+ import { TaskService } from './task.service';
16
+ import { TimeSeriesService } from './timeseries.service';
17
+ import { UserService } from './user.service';
18
+ import { VaultService } from './vault.service';
19
+ export class API {
20
+ constructor(httpClient, context) {
21
+ this.httpClient = httpClient;
22
+ if (!httpClient) {
23
+ // remove leading and trailing slashes
24
+ const normalizePath = (value = '', defaultValue = '') => value.replace(/(?:^\/+)|(?:\/+$)/g, '') || defaultValue;
25
+ let apiBaseUrl = process.env.API_BASE_URL || 'https://testing.hahnpro.com';
26
+ if (!apiBaseUrl.startsWith('https') && !apiBaseUrl.startsWith('http')) {
27
+ /* eslint-disable-next-line no-console */
28
+ console.info('no protocol specified - using HTTPS');
29
+ apiBaseUrl = `https://${apiBaseUrl}`;
30
+ }
31
+ const apiUrl = apiBaseUrl + '/' + normalizePath(process.env.API_BASE_PATH, 'api');
32
+ const authBaseUrl = process.env.AUTH_BASE_URL || apiBaseUrl;
33
+ const authUrl = authBaseUrl + '/' + normalizePath(process.env.AUTH_BASE_PATH, 'auth');
34
+ const realm = process.env.AUTH_REALM || 'hpc';
35
+ const client = process.env.API_USER || 'flow-executor-service';
36
+ const secret = process.env.AUTH_SECRET;
37
+ if (!secret) {
38
+ throw new Error('"API_BASE_URL", "API_USER", "AUTH_REALM" and "AUTH_SECRET" environment variables must be set');
39
+ }
40
+ this.httpClient = new HttpClient(apiUrl, authUrl, realm, client, secret, context?.tokenSubject);
41
+ }
42
+ this.assets = new AssetService(this.httpClient);
43
+ this.assetTypes = new AssetTypesService(this.httpClient);
44
+ this.contents = new ContentService(this.httpClient);
45
+ this.endpoints = new EndpointService(this.httpClient);
46
+ this.events = new EventsService(this.httpClient);
47
+ this.flows = new FlowService(this.httpClient);
48
+ this.flowDeployments = new FlowDeploymentService(this.httpClient);
49
+ this.flowFunctions = new FlowFunctionService(this.httpClient);
50
+ this.flowModules = new FlowModuleService(this.httpClient);
51
+ this.labels = new LabelService(this.httpClient);
52
+ this.proxy = new ProxyService(this.httpClient);
53
+ this.secrets = new SecretService(this.httpClient);
54
+ this.tasks = new TaskService(this.httpClient);
55
+ this.timeSeries = new TimeSeriesService(this.httpClient);
56
+ this.users = new UserService(this.httpClient);
57
+ this.vault = new VaultService(this.httpClient);
58
+ this.notifications = new NotificationService(this.httpClient);
59
+ }
60
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import FormData from 'form-data';
2
+ import { APIBase } from './api-base';
3
+ import { Asset, AssetRevision, Attachment, EventCause, EventLevelOverride } from './asset.interface';
4
+ import { Paginated, RequestParameter } from './data.interface';
5
+ import { DataService } from './data.service';
6
+ import { HttpClient, TokenOption } from './http.service';
7
+ import { TrashService } from './trash.service';
8
+ interface BaseService extends DataService<Asset>, TrashService<Asset> {
9
+ }
10
+ declare class BaseService extends APIBase {
11
+ }
12
+ export declare class AssetService extends BaseService {
13
+ constructor(httpClient: HttpClient);
14
+ deleteOne(id: string, force?: boolean, options?: TokenOption): Promise<any>;
15
+ addAttachment: (id: string, form: FormData, options?: TokenOption) => Promise<Asset>;
16
+ getChildren(assetId: string, params?: RequestParameter, options?: TokenOption): Promise<Paginated<Asset[]>>;
17
+ getAttachments(assetId: string, options?: TokenOption): Promise<Paginated<Attachment[]>>;
18
+ getEventLevelOverride(ids: string[], causes: string[], options?: TokenOption): Promise<EventLevelOverride>;
19
+ updateEventCausesAsset(id: string, dto: EventCause, options?: TokenOption): Promise<Asset>;
20
+ getRevisions(assetId: string, options?: TokenOption): Promise<Paginated<AssetRevision[]>>;
21
+ rollback(assetId: string, revisionId: string, options?: TokenOption): Promise<Asset>;
22
+ deleteRevision(assetId: string, revisionId: string, options?: TokenOption): Promise<any>;
23
+ }
24
+ export {};
@@ -0,0 +1,51 @@
1
+ import { __decorate } from "tslib";
2
+ import { mix } from 'ts-mixer';
3
+ import { APIBase } from './api-base';
4
+ import { DataService } from './data.service';
5
+ import { TrashService } from './trash.service';
6
+ let BaseService = class BaseService extends APIBase {
7
+ };
8
+ BaseService = __decorate([
9
+ mix(DataService, TrashService)
10
+ ], BaseService);
11
+ export class AssetService extends BaseService {
12
+ constructor(httpClient) {
13
+ super(httpClient, '/assets');
14
+ this.addAttachment = (id, form, options = {}) => {
15
+ const headers = { ...form.getHeaders() };
16
+ return this.httpClient.post(`${this.basePath}/${id}/attachment`, form, {
17
+ headers,
18
+ maxBodyLength: Infinity,
19
+ maxContentLength: Infinity,
20
+ ...options,
21
+ });
22
+ };
23
+ }
24
+ deleteOne(id, force = false, options = {}) {
25
+ return this.httpClient.delete(`${this.basePath}/${id}`, { params: { force }, ...options });
26
+ }
27
+ getChildren(assetId, params = {}, options = {}) {
28
+ return this.getManyFiltered({ parent: assetId }, params, options);
29
+ }
30
+ getAttachments(assetId, options = {}) {
31
+ return this.httpClient.get(`${this.basePath}/${assetId}/attachments`, options);
32
+ }
33
+ getEventLevelOverride(ids, causes, options = {}) {
34
+ return this.httpClient.get(`${this.basePath}/eventcauses`, {
35
+ params: { ids: ids.join(','), causes: causes.join(',') },
36
+ ...options,
37
+ });
38
+ }
39
+ updateEventCausesAsset(id, dto, options = {}) {
40
+ return this.httpClient.put(`${this.basePath}/${id}/eventcauses`, dto, options);
41
+ }
42
+ getRevisions(assetId, options = {}) {
43
+ return this.httpClient.get(`${this.basePath}/${assetId}/revisions`, options);
44
+ }
45
+ rollback(assetId, revisionId, options = {}) {
46
+ return this.httpClient.put(`${this.basePath}/${assetId}/rollback`, { revisionId }, options);
47
+ }
48
+ deleteRevision(assetId, revisionId, options = {}) {
49
+ return this.httpClient.delete(`${this.basePath}/${assetId}/revisions/${revisionId}`, options);
50
+ }
51
+ }
@@ -2,7 +2,7 @@ import { APIBase } from './api-base';
2
2
  import { AssetType } from './asset.interface';
3
3
  import { Paginated } from './data.interface';
4
4
  import { DataService } from './data.service';
5
- import { HttpClient } from './http.service';
5
+ import { HttpClient, TokenOption } from './http.service';
6
6
  import { TrashService } from './trash.service';
7
7
  interface BaseService extends DataService<AssetType>, TrashService<AssetType> {
8
8
  }
@@ -10,8 +10,8 @@ declare class BaseService extends APIBase {
10
10
  }
11
11
  export declare class AssetTypesService extends BaseService {
12
12
  constructor(httpClient: HttpClient);
13
- getRevisions(id: string): Promise<Paginated<AssetType[]>>;
14
- rollback(id: string, revisionId: string): Promise<AssetType>;
15
- deleteRevision(id: string, revisionId: string): Promise<any>;
13
+ getRevisions(id: string, options?: TokenOption): Promise<Paginated<AssetType[]>>;
14
+ rollback(id: string, revisionId: string, options?: TokenOption): Promise<AssetType>;
15
+ deleteRevision(id: string, revisionId: string, options?: TokenOption): Promise<any>;
16
16
  }
17
17
  export {};
@@ -0,0 +1,24 @@
1
+ import { __decorate } from "tslib";
2
+ import { mix } from 'ts-mixer';
3
+ import { APIBase } from './api-base';
4
+ import { DataService } from './data.service';
5
+ import { TrashService } from './trash.service';
6
+ let BaseService = class BaseService extends APIBase {
7
+ };
8
+ BaseService = __decorate([
9
+ mix(DataService, TrashService)
10
+ ], BaseService);
11
+ export class AssetTypesService extends BaseService {
12
+ constructor(httpClient) {
13
+ super(httpClient, '/assettypes');
14
+ }
15
+ getRevisions(id, options = {}) {
16
+ return this.httpClient.get(`${this.basePath}/${id}/revisions`, options);
17
+ }
18
+ rollback(id, revisionId, options = {}) {
19
+ return this.httpClient.put(`${this.basePath}/${id}/rollback`, { revisionId }, options);
20
+ }
21
+ deleteRevision(id, revisionId, options = {}) {
22
+ return this.httpClient.delete(`${this.basePath}/${id}/revisions/${revisionId}`, options);
23
+ }
24
+ }
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReturnType = void 0;
4
- var ReturnType;
1
+ export var ReturnType;
5
2
  (function (ReturnType) {
6
3
  ReturnType[ReturnType["TEXT"] = 0] = "TEXT";
7
4
  ReturnType[ReturnType["JSON"] = 1] = "JSON";
@@ -9,4 +6,4 @@ var ReturnType;
9
6
  ReturnType[ReturnType["BLOB"] = 3] = "BLOB";
10
7
  ReturnType[ReturnType["ARRAYBUFFER"] = 4] = "ARRAYBUFFER";
11
8
  ReturnType[ReturnType["NODESTREAM"] = 5] = "NODESTREAM";
12
- })(ReturnType || (exports.ReturnType = ReturnType = {}));
9
+ })(ReturnType || (ReturnType = {}));
@@ -0,0 +1,23 @@
1
+ import { Readable } from 'stream';
2
+ import FormData from 'form-data';
3
+ import { APIBase } from './api-base';
4
+ import { Content, ReturnType } from './content.interface';
5
+ import { DataService } from './data.service';
6
+ import { HttpClient, TokenOption } from './http.service';
7
+ import { TrashService } from './trash.service';
8
+ interface BaseService extends DataService<Content>, TrashService<Content> {
9
+ }
10
+ declare class BaseService extends APIBase {
11
+ }
12
+ export declare class ContentService extends BaseService {
13
+ constructor(httpClient: HttpClient);
14
+ upload: (form: FormData, options?: TokenOption) => Promise<Content>;
15
+ download(id: string, raw?: boolean, options?: TokenOption): Promise<Blob | ArrayBuffer>;
16
+ download(id: string, returnType: ReturnType.TEXT, options?: TokenOption): Promise<string>;
17
+ download(id: string, returnType: ReturnType.JSON, options?: TokenOption): Promise<Record<string, unknown>>;
18
+ download(id: string, returnType: ReturnType.NODEBUFFER, options?: TokenOption): Promise<Buffer>;
19
+ download(id: string, returnType: ReturnType.BLOB, options?: TokenOption): Promise<Blob>;
20
+ download(id: string, returnType: ReturnType.ARRAYBUFFER, options?: TokenOption): Promise<ArrayBuffer>;
21
+ download(id: string, returnType: ReturnType.NODESTREAM, options?: TokenOption): Promise<Readable>;
22
+ }
23
+ export {};
@@ -0,0 +1,49 @@
1
+ import { __decorate } from "tslib";
2
+ import { mix } from 'ts-mixer';
3
+ import { APIBase } from './api-base';
4
+ import { ReturnType } from './content.interface';
5
+ import { DataService } from './data.service';
6
+ import { TrashService } from './trash.service';
7
+ let BaseService = class BaseService extends APIBase {
8
+ };
9
+ BaseService = __decorate([
10
+ mix(DataService, TrashService)
11
+ ], BaseService);
12
+ export class ContentService extends BaseService {
13
+ constructor(httpClient) {
14
+ super(httpClient, '/contents');
15
+ this.upload = (form, options = {}) => {
16
+ const headers = { ...form.getHeaders() };
17
+ return this.httpClient.post(`${this.basePath}`, form, {
18
+ headers,
19
+ maxBodyLength: Infinity,
20
+ maxContentLength: Infinity,
21
+ ...options,
22
+ });
23
+ };
24
+ }
25
+ async download(id, second, options = {}) {
26
+ let returnType;
27
+ if (typeof second === 'boolean' || second == null) {
28
+ returnType = second ? ReturnType.ARRAYBUFFER : ReturnType.BLOB;
29
+ }
30
+ else {
31
+ returnType = second;
32
+ }
33
+ const url = `${this.basePath}/${id}/download`;
34
+ switch (returnType) {
35
+ case ReturnType.TEXT:
36
+ return this.httpClient.get(url, { responseType: 'text', ...options });
37
+ case ReturnType.JSON:
38
+ return this.httpClient.get(url, { responseType: 'json', ...options });
39
+ case ReturnType.NODEBUFFER:
40
+ return Buffer.from(new Uint8Array(await this.httpClient.get(url, { responseType: 'arraybuffer', ...options })));
41
+ case ReturnType.BLOB:
42
+ return this.httpClient.get(url, { responseType: 'blob', ...options });
43
+ case ReturnType.ARRAYBUFFER:
44
+ return this.httpClient.get(url, { responseType: 'arraybuffer', ...options });
45
+ case ReturnType.NODESTREAM:
46
+ return this.httpClient.get(url, { responseType: 'stream', ...options });
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,38 @@
1
+ import { TokenOption } from './http.service';
2
+ export interface Paginated<T> {
3
+ docs: T;
4
+ total: number;
5
+ limit: number;
6
+ page?: number;
7
+ pages?: number;
8
+ offset?: number;
9
+ }
10
+ export interface RequestParameter {
11
+ filter?: string;
12
+ limit?: number;
13
+ page?: number;
14
+ populate?: string;
15
+ sort?: string;
16
+ }
17
+ interface TimePeriod {
18
+ from: Date;
19
+ to: Date;
20
+ }
21
+ export declare function instanceOfTimePeriod(object: any): object is TimePeriod;
22
+ export type Filter = Record<string, string | string[] | TimePeriod>;
23
+ export interface DataInterface<T> {
24
+ addOne(dto: any, options?: TokenOption): Promise<T>;
25
+ addMany(dto: any[], options?: TokenOption & {
26
+ [key: string]: any;
27
+ }): Promise<T[]>;
28
+ getOne(id: string, options?: TokenOption & {
29
+ [key: string]: any;
30
+ }): Promise<T>;
31
+ getMany(params?: RequestParameter, options?: TokenOption): Promise<Paginated<T[]>>;
32
+ getManyFiltered(filter: Filter, params?: RequestParameter, options?: TokenOption): Promise<Paginated<T[]>>;
33
+ updateOne(id: string, dto: any, options?: TokenOption & {
34
+ [key: string]: any;
35
+ }): Promise<T>;
36
+ deleteOne(id: string, force: boolean, options?: TokenOption): Promise<any>;
37
+ }
38
+ export {};
@@ -0,0 +1,3 @@
1
+ export function instanceOfTimePeriod(object) {
2
+ return 'from' in object && 'to' in object;
3
+ }
@@ -0,0 +1,27 @@
1
+ import { APIBase } from './api-base';
2
+ import { DataInterface, Filter, Paginated, RequestParameter } from './data.interface';
3
+ import { TokenOption } from './http.service';
4
+ export declare class DataService<T> extends APIBase implements DataInterface<T> {
5
+ addOne(dto: any, options?: TokenOption): Promise<T>;
6
+ addMany(dto: any[], options?: TokenOption): Promise<T[]>;
7
+ getOne(id: string, options?: TokenOption & {
8
+ [key: string]: any;
9
+ }): Promise<T>;
10
+ getMany(params?: RequestParameter, options?: TokenOption): Promise<Paginated<T[]>>;
11
+ /**
12
+ * Filters the elements by the passed properties. The object with these properties has to be of the form:
13
+ * {
14
+ * propertyName: string | string[] | { from: Date, to: Date },
15
+ * ...
16
+ * }.
17
+ * @param filter The Object with the properties to filter by.
18
+ * @param params Other request parameters.
19
+ * @param options Parameters for authentication
20
+ */
21
+ getManyFiltered(filter: Filter, params?: RequestParameter, options?: TokenOption): Promise<Paginated<T[]>>;
22
+ updateOne(id: string, dto: any, options?: TokenOption & {
23
+ [key: string]: any;
24
+ }): Promise<T>;
25
+ deleteOne(id: string, force?: boolean, options?: TokenOption): Promise<any>;
26
+ private getFilterString;
27
+ }
@@ -0,0 +1,57 @@
1
+ import { APIBase } from './api-base';
2
+ import { instanceOfTimePeriod } from './data.interface';
3
+ export class DataService extends APIBase {
4
+ addOne(dto, options = {}) {
5
+ return this.httpClient.post(this.basePath, dto, options);
6
+ }
7
+ addMany(dto, options = {}) {
8
+ return this.httpClient.post(`${this.basePath}/many`, dto, options);
9
+ }
10
+ getOne(id, options = {}) {
11
+ const params = options.populate ? { populate: options.populate } : {};
12
+ return this.httpClient.get(`${this.basePath}/${id}`, { params });
13
+ }
14
+ getMany(params = {}, options = {}) {
15
+ params.limit = params.limit || 0;
16
+ params.page = params.page || 1;
17
+ return this.httpClient.get(`${this.basePath}`, { params, ...options });
18
+ }
19
+ /**
20
+ * Filters the elements by the passed properties. The object with these properties has to be of the form:
21
+ * {
22
+ * propertyName: string | string[] | { from: Date, to: Date },
23
+ * ...
24
+ * }.
25
+ * @param filter The Object with the properties to filter by.
26
+ * @param params Other request parameters.
27
+ * @param options Parameters for authentication
28
+ */
29
+ getManyFiltered(filter, params = {}, options = {}) {
30
+ params.filter = this.getFilterString(filter);
31
+ return this.getMany(params, options);
32
+ }
33
+ updateOne(id, dto, options = {}) {
34
+ return this.httpClient.put(`${this.basePath}/${id}`, dto, options);
35
+ }
36
+ deleteOne(id, force = false, options = {}) {
37
+ return this.httpClient.delete(`${this.basePath}/${id}`, { params: { force }, ...options });
38
+ }
39
+ getFilterString(filter) {
40
+ const filters = [];
41
+ for (const [key, value] of Object.entries(filter)) {
42
+ if (value != null && value !== '') {
43
+ // filter out null and undefined values and empty strings
44
+ if (typeof value === 'object' && instanceOfTimePeriod(value)) {
45
+ filters.push(`${key}>=${value.from.toISOString()};${key}<=${value.to.toISOString()}`);
46
+ }
47
+ else if (Array.isArray(value)) {
48
+ filters.push(`${key}=@${value.join(',')}`);
49
+ }
50
+ else {
51
+ filters.push(`${key}==${value}`);
52
+ }
53
+ }
54
+ }
55
+ return filters.join(';');
56
+ }
57
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { DataService } from './data.service';
2
+ import { Endpoint, EndpointLog, NotificationPayload } from './endpoint.interface';
3
+ import { HttpClient, TokenOption } from './http.service';
4
+ export declare class EndpointService extends DataService<Endpoint> {
5
+ constructor(httpClient: HttpClient);
6
+ sendNotification(endpointId: string, payload: NotificationPayload, options?: TokenOption): Promise<void>;
7
+ readLastLogByGroup(endpointId: string, group: string, options?: TokenOption): Promise<EndpointLog>;
8
+ }
@@ -0,0 +1,12 @@
1
+ import { DataService } from './data.service';
2
+ export class EndpointService extends DataService {
3
+ constructor(httpClient) {
4
+ super(httpClient, '/notification/endpoints');
5
+ }
6
+ sendNotification(endpointId, payload, options = {}) {
7
+ return this.httpClient.post(`${this.basePath}/${endpointId}`, payload, options);
8
+ }
9
+ readLastLogByGroup(endpointId, group, options = {}) {
10
+ return this.httpClient.get(`${this.basePath}/${endpointId}/logs/${group}/last`, options);
11
+ }
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { DataService } from './data.service';
2
2
  import { Event } from './events.interface';
3
- import { HttpClient } from './http.service';
3
+ import { HttpClient, TokenOption } from './http.service';
4
4
  export declare class EventsService extends DataService<Event> {
5
5
  constructor(httpClient: HttpClient);
6
- getLastEventByAssetAndGroup(assetId: string, group: string): Promise<Event>;
6
+ getLastEventByAssetAndGroup(assetId: string, group: string, options?: TokenOption): Promise<Event>;
7
7
  }
@@ -0,0 +1,9 @@
1
+ import { DataService } from './data.service';
2
+ export class EventsService extends DataService {
3
+ constructor(httpClient) {
4
+ super(httpClient, '/events');
5
+ }
6
+ getLastEventByAssetAndGroup(assetId, group, options = {}) {
7
+ return this.httpClient.get(`${this.basePath}/last/${assetId}/${group}`, options);
8
+ }
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { APIBase } from './api-base';
2
2
  import { DataService } from './data.service';
3
3
  import { FlowDeployment, FlowDeploymentMetrics, FlowDeploymentStatistic, FlowLog } from './flow-deployment.interface';
4
- import { HttpClient } from './http.service';
4
+ import { HttpClient, TokenOption } from './http.service';
5
5
  import { ResourceReference } from './resource.interface';
6
6
  import { TrashService } from './trash.service';
7
7
  interface BaseService extends DataService<FlowDeployment>, TrashService<FlowDeployment> {
@@ -10,15 +10,17 @@ declare class BaseService extends APIBase {
10
10
  }
11
11
  export declare class FlowDeploymentService extends BaseService {
12
12
  constructor(httpClient: HttpClient);
13
- addMany(dto: any[]): Promise<FlowDeployment[]>;
14
- updateOne(id: string, dto: any, force?: boolean): Promise<FlowDeployment>;
15
- getDeploymentStatistics(id: string): Promise<FlowDeploymentStatistic>;
16
- getDeploymentMetrics(id: string, range?: string, interval?: string): Promise<FlowDeploymentMetrics>;
17
- getDeploymentLogs(id: string): Promise<FlowLog[]>;
18
- resolveReferences(id: string, recursive?: boolean, types?: string[]): Promise<ResourceReference[]>;
19
- updateStatus(id: string, desiredStatus: 'running' | 'stopped' | 'deleted' | 'paused'): Promise<FlowDeployment>;
20
- deleteOne(id: string): Promise<FlowDeployment>;
21
- waitForRunningStatus(id: string): Promise<void>;
13
+ addMany(dto: any[], options?: TokenOption): Promise<FlowDeployment[]>;
14
+ updateOne(id: string, dto: any, options?: TokenOption & {
15
+ force: boolean;
16
+ }): Promise<FlowDeployment>;
17
+ getDeploymentStatistics(id: string, options?: TokenOption): Promise<FlowDeploymentStatistic>;
18
+ getDeploymentMetrics(id: string, range?: string, interval?: string, options?: TokenOption): Promise<FlowDeploymentMetrics>;
19
+ getDeploymentLogs(id: string, options?: TokenOption): Promise<FlowLog[]>;
20
+ resolveReferences(id: string, recursive?: boolean, types?: string[], options?: TokenOption): Promise<ResourceReference[]>;
21
+ updateStatus(id: string, desiredStatus: 'running' | 'stopped' | 'deleted' | 'paused', options?: TokenOption): Promise<FlowDeployment>;
22
+ deleteOne(id: string, _force?: boolean, options?: TokenOption): Promise<FlowDeployment>;
23
+ waitForRunningStatus(id: string, options?: TokenOption): Promise<void>;
22
24
  addOne(dto: {
23
25
  diagramId: string;
24
26
  name: string;
@@ -26,8 +28,8 @@ export declare class FlowDeploymentService extends BaseService {
26
28
  readPermissions?: string[];
27
29
  readWritePermissions?: string[];
28
30
  tags?: string[];
29
- }): Promise<FlowDeployment>;
30
- subscribeToStatus(id: string, listener: (event: MessageEvent<any>) => void, errorListener?: (event: MessageEvent) => void): Promise<string>;
31
- subscribeToLogs(id: string, listener: (event: MessageEvent<any>) => void, errorListener?: (event: MessageEvent) => void): Promise<string>;
31
+ }, options?: TokenOption): Promise<FlowDeployment>;
32
+ subscribeToStatus(id: string, listener: (event: MessageEvent<any>) => void, errorListener?: (event: MessageEvent) => void, options?: TokenOption): Promise<string>;
33
+ subscribeToLogs(id: string, listener: (event: MessageEvent<any>) => void, errorListener?: (event: MessageEvent) => void, options?: TokenOption): Promise<string>;
32
34
  }
33
35
  export {};