@hahnpro/hpc-api 2.1.1 → 2.2.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 (43) hide show
  1. package/dist/Queue.js +1 -1
  2. package/dist/api.d.ts +8 -0
  3. package/dist/api.js +8 -0
  4. package/dist/content.interface.d.ts +1 -13
  5. package/dist/flow-deployment.interface.d.ts +76 -0
  6. package/dist/flow-deployment.interface.js +2 -0
  7. package/dist/flow-deployment.service.d.ts +26 -0
  8. package/dist/flow-deployment.service.js +58 -0
  9. package/dist/flow-function.interface.d.ts +47 -0
  10. package/dist/flow-function.interface.js +2 -0
  11. package/dist/flow-function.service.d.ts +9 -0
  12. package/dist/flow-function.service.js +20 -0
  13. package/dist/flow-module.interface.d.ts +13 -0
  14. package/dist/flow-module.interface.js +2 -0
  15. package/dist/flow-module.service.d.ts +13 -0
  16. package/dist/flow-module.service.js +40 -0
  17. package/dist/flow.interface.d.ts +25 -0
  18. package/dist/flow.interface.js +2 -0
  19. package/dist/flow.service.d.ts +11 -0
  20. package/dist/flow.service.js +25 -0
  21. package/dist/http.service.d.ts +6 -0
  22. package/dist/http.service.js +34 -1
  23. package/dist/index.d.ts +5 -0
  24. package/dist/index.js +18 -13
  25. package/dist/mock/api.mock.d.ts +28 -0
  26. package/dist/mock/api.mock.js +35 -1
  27. package/dist/mock/flow-deployment.mock.service.d.ts +27 -0
  28. package/dist/mock/flow-deployment.mock.service.js +117 -0
  29. package/dist/mock/flow-functions.mock.service.d.ts +14 -0
  30. package/dist/mock/flow-functions.mock.service.js +41 -0
  31. package/dist/mock/flow-modules.mock.service.d.ts +18 -0
  32. package/dist/mock/flow-modules.mock.service.js +34 -0
  33. package/dist/mock/flow.mock.service.d.ts +10 -0
  34. package/dist/mock/flow.mock.service.js +23 -0
  35. package/dist/mock/index.js +9 -9
  36. package/dist/resource.interface.d.ts +18 -0
  37. package/dist/resource.interface.js +2 -0
  38. package/dist/schema.interface.d.ts +18 -0
  39. package/dist/schema.interface.js +2 -0
  40. package/dist/storage.interface.d.ts +16 -0
  41. package/dist/storage.interface.js +2 -0
  42. package/dist/user.service.js +1 -1
  43. package/package.json +5 -3
package/dist/Queue.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Queue = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const p_queue_1 = (0, tslib_1.__importDefault)(require("p-queue"));
5
+ const p_queue_1 = tslib_1.__importDefault(require("p-queue"));
6
6
  class Queue extends p_queue_1.default {
7
7
  constructor(options) {
8
8
  super(options);
package/dist/api.d.ts CHANGED
@@ -10,6 +10,10 @@ import { SiDriveIqService } from './sidriveiq.service';
10
10
  import { TaskService } from './task.service';
11
11
  import { TimeSeriesService } from './timeseries.service';
12
12
  import { UserService } from './user.service';
13
+ import { FlowService } from './flow.service';
14
+ import { FlowFunctionService } from './flow-function.service';
15
+ import { FlowModuleService } from './flow-module.service';
16
+ import { FlowDeploymentService } from './flow-deployment.service';
13
17
  export declare class API {
14
18
  httpClient: HttpClient;
15
19
  assets: AssetService;
@@ -17,6 +21,10 @@ export declare class API {
17
21
  contents: ContentService;
18
22
  endpoints: EndpointService;
19
23
  events: EventsService;
24
+ flows: FlowService;
25
+ flowDeployments: FlowDeploymentService;
26
+ flowFunctions: FlowFunctionService;
27
+ flowModules: FlowModuleService;
20
28
  proxy: ProxyService;
21
29
  secrets: SecretService;
22
30
  tasks: TaskService;
package/dist/api.js CHANGED
@@ -13,6 +13,10 @@ const sidriveiq_service_1 = require("./sidriveiq.service");
13
13
  const task_service_1 = require("./task.service");
14
14
  const timeseries_service_1 = require("./timeseries.service");
15
15
  const user_service_1 = require("./user.service");
16
+ const flow_service_1 = require("./flow.service");
17
+ const flow_function_service_1 = require("./flow-function.service");
18
+ const flow_module_service_1 = require("./flow-module.service");
19
+ const flow_deployment_service_1 = require("./flow-deployment.service");
16
20
  class API {
17
21
  constructor() {
18
22
  const normalizePath = (value = '', defaultValue = '') => value.replace(/^\/+|\/+$/g, '') || defaultValue;
@@ -36,6 +40,10 @@ class API {
36
40
  this.contents = new content_service_1.ContentService(this.httpClient);
37
41
  this.endpoints = new endpoint_service_1.EndpointService(this.httpClient);
38
42
  this.events = new events_service_1.EventsService(this.httpClient);
43
+ this.flows = new flow_service_1.FlowService(this.httpClient);
44
+ this.flowDeployments = new flow_deployment_service_1.FlowDeploymentService(this.httpClient);
45
+ this.flowFunctions = new flow_function_service_1.FlowFunctionService(this.httpClient);
46
+ this.flowModules = new flow_module_service_1.FlowModuleService(this.httpClient);
39
47
  this.proxy = new proxy_service_1.ProxyService(this.httpClient);
40
48
  this.secrets = new secret_service_1.SecretService(this.httpClient);
41
49
  this.tasks = new task_service_1.TaskService(this.httpClient);
@@ -1,15 +1,4 @@
1
- declare type FileType = 'original' | 'preview-sm' | 'preview-md' | 'preview-lg';
2
- declare type StorageProvider = 's3' | 'mongo';
3
- export interface Storage {
4
- id: string;
5
- filename: string;
6
- mimetype: string;
7
- size: number;
8
- createdAt: string;
9
- provider?: StorageProvider;
10
- type?: FileType;
11
- md5?: string;
12
- }
1
+ import { Storage } from './storage.interface';
13
2
  export interface Content {
14
3
  id?: string;
15
4
  fileId: string;
@@ -32,4 +21,3 @@ export declare enum ReturnType {
32
21
  ARRAYBUFFER = 4,
33
22
  NODESTREAM = 5
34
23
  }
35
- export {};
@@ -0,0 +1,76 @@
1
+ import { Resource } from './resource.interface';
2
+ import { FlowDiagram, FlowDto } from './flow.interface';
3
+ import { Storage } from './storage.interface';
4
+ export interface FlowDeployment extends Resource {
5
+ flow: string | FlowDto;
6
+ diagram: string | FlowDiagram;
7
+ artifact: Storage;
8
+ flowModel: FlowModel;
9
+ desiredStatus: string;
10
+ actualStatus: string;
11
+ target: string;
12
+ statistic?: FlowDeploymentStatistic;
13
+ }
14
+ export interface FlowDeploymentStatistic {
15
+ totalErrorCount: number;
16
+ errorCountWeek: number;
17
+ eventCountWeek: number;
18
+ errorCounts: {
19
+ timestamp: number;
20
+ error: number;
21
+ }[];
22
+ metrics?: Record<string, any>;
23
+ }
24
+ export interface FlowModel {
25
+ elements: FlowModelElement[];
26
+ connections: FlowConnection[];
27
+ modules?: string[];
28
+ properties?: Record<string, any>;
29
+ }
30
+ export interface FlowModelElement {
31
+ id: string;
32
+ name?: string;
33
+ properties?: Record<string, any>;
34
+ module: string;
35
+ functionFqn: string;
36
+ }
37
+ export interface FlowConnection {
38
+ id: string;
39
+ name?: string;
40
+ source: string;
41
+ target: string;
42
+ sourceStream?: string;
43
+ targetStream?: string;
44
+ }
45
+ export interface FlowDeploymentMetrics {
46
+ metrics: Metrics[];
47
+ stats?: Stats;
48
+ }
49
+ export interface Metrics {
50
+ timestamp: number;
51
+ cpu: number;
52
+ memory: number;
53
+ }
54
+ export interface Stats {
55
+ cpu: StatsValues;
56
+ memory: StatsValues;
57
+ }
58
+ export interface StatsValues {
59
+ count: number;
60
+ min: number;
61
+ max: number;
62
+ avg: number;
63
+ sum: number;
64
+ }
65
+ export interface FlowLog {
66
+ data?: any;
67
+ datacontenttype?: string;
68
+ deploymentId?: string;
69
+ elementId?: string;
70
+ eventId?: string;
71
+ flowId?: string;
72
+ subject: string;
73
+ source?: string;
74
+ time: string;
75
+ type: string;
76
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,26 @@
1
+ import { DataService } from './data.service';
2
+ import { FlowDeployment, FlowDeploymentMetrics, FlowDeploymentStatistic, FlowLog } from './flow-deployment.interface';
3
+ import { HttpClient } from './http.service';
4
+ import { ResourceReference } from './resource.interface';
5
+ export declare class FlowDeploymentService extends DataService<FlowDeployment> {
6
+ constructor(httpClient: HttpClient);
7
+ addMany(dto: any[]): Promise<FlowDeployment[]>;
8
+ updateOne(id: string, dto: any, force?: boolean): Promise<FlowDeployment>;
9
+ getDeploymentStatistics(id: string): Promise<FlowDeploymentStatistic>;
10
+ getDeploymentMetrics(id: string, range?: string, interval?: string): Promise<FlowDeploymentMetrics>;
11
+ getDeploymentLogs(id: string): Promise<FlowLog[]>;
12
+ resolveReferences(id: string, recursive?: boolean, types?: string[]): Promise<ResourceReference[]>;
13
+ updateStatus(id: string, desiredStatus: 'running' | 'stopped' | 'deleted'): Promise<FlowDeployment>;
14
+ deleteOne(id: string): Promise<FlowDeployment>;
15
+ waitForRunningStatus(id: string): Promise<void>;
16
+ addOne(dto: {
17
+ diagramId: string;
18
+ name: string;
19
+ properties?: Record<string, any>;
20
+ readPermissions?: string[];
21
+ readWritePermissions?: string[];
22
+ tags?: string[];
23
+ }): Promise<FlowDeployment>;
24
+ subscribeToStatus(id: string, listener: (event: MessageEvent<any>) => void, errorListener?: (event: MessageEvent) => void): Promise<string>;
25
+ subscribeToLogs(id: string, listener: (event: MessageEvent<any>) => void, errorListener?: (event: MessageEvent) => void): Promise<string>;
26
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowDeploymentService = void 0;
4
+ const data_service_1 = require("./data.service");
5
+ class FlowDeploymentService extends data_service_1.DataService {
6
+ constructor(httpClient) {
7
+ super(httpClient, '/flow/deployments');
8
+ }
9
+ addMany(dto) {
10
+ const reqs = dto.map((v) => this.addOne(v));
11
+ return Promise.all(reqs);
12
+ }
13
+ updateOne(id, dto, force = false) {
14
+ return this.httpClient.put(`${this.basePath}/${id}`, dto, { params: { force } });
15
+ }
16
+ getDeploymentStatistics(id) {
17
+ return this.httpClient.get(`${this.basePath}/${id}/statistics`);
18
+ }
19
+ getDeploymentMetrics(id, range = '12h', interval = '5m') {
20
+ const params = { range, interval };
21
+ return this.httpClient.get(`${this.basePath}/${id}/metrics`, { params });
22
+ }
23
+ getDeploymentLogs(id) {
24
+ return this.httpClient.get(`${this.basePath}/${id}/logs`);
25
+ }
26
+ resolveReferences(id, recursive = true, types) {
27
+ var _a;
28
+ const params = { recursive, types: (_a = types === null || types === void 0 ? void 0 : types.join(',')) !== null && _a !== void 0 ? _a : undefined };
29
+ return this.httpClient.get(`${this.basePath}/${id}/references`, { params });
30
+ }
31
+ updateStatus(id, desiredStatus) {
32
+ return this.httpClient.put(`${this.basePath}/${id}/status`, { desiredStatus });
33
+ }
34
+ deleteOne(id) {
35
+ return this.updateStatus(id, 'deleted');
36
+ }
37
+ async waitForRunningStatus(id) {
38
+ return new Promise(async (resolve, reject) => {
39
+ const esId = await this.subscribeToStatus(id, (event) => {
40
+ if (event.type === 'message' &&
41
+ ['running', 'deployment failed', 'deleted', 'generating failed', 'updating failed', 'upgrading failed'].includes(event.data)) {
42
+ this.httpClient.destroyEventSource(esId);
43
+ event.data === 'running' ? resolve() : reject(`Deployment in failed status: ${event.data}`);
44
+ }
45
+ });
46
+ });
47
+ }
48
+ addOne(dto) {
49
+ return super.addOne(dto);
50
+ }
51
+ subscribeToStatus(id, listener, errorListener) {
52
+ return this.httpClient.addEventSource(`${this.basePath}/${id}/status`, listener, errorListener);
53
+ }
54
+ subscribeToLogs(id, listener, errorListener) {
55
+ return this.httpClient.addEventSource(`${this.basePath}/${id}/logs/subscribe`, listener, errorListener);
56
+ }
57
+ }
58
+ exports.FlowDeploymentService = FlowDeploymentService;
@@ -0,0 +1,47 @@
1
+ export interface FlowFunctionDto {
2
+ fqn: string;
3
+ category: string;
4
+ readPermissions: string[];
5
+ readWritePermissions: string[];
6
+ author: string;
7
+ current: string;
8
+ history: string[] | HistoryEntry[];
9
+ name?: string;
10
+ description?: string;
11
+ icon?: string;
12
+ isAbstract?: boolean;
13
+ supertype?: string;
14
+ propertiesSchema?: Schema;
15
+ inputStreams?: Stream[];
16
+ outputStreams?: Stream[];
17
+ tags?: string[];
18
+ createdAt?: string;
19
+ updatedAt?: string;
20
+ }
21
+ export interface HistoryEntry {
22
+ author: string;
23
+ createdAt: string;
24
+ id: string;
25
+ }
26
+ interface Stream {
27
+ name: string;
28
+ }
29
+ interface Schema {
30
+ schema: {
31
+ type: string;
32
+ properties?: {
33
+ [key: string]: SchemaProperty;
34
+ };
35
+ };
36
+ layout?: any[];
37
+ data?: any;
38
+ }
39
+ declare type SchemaPropertyType = 'array' | 'boolean' | 'number' | 'string';
40
+ interface SchemaProperty {
41
+ type: SchemaPropertyType;
42
+ title?: string;
43
+ description?: string;
44
+ default?: any;
45
+ [key: string]: any;
46
+ }
47
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ import { DataService } from './data.service';
2
+ import { FlowFunctionDto } from './flow-function.interface';
3
+ import { HttpClient } from './http.service';
4
+ export declare class FlowFunctionService extends DataService<FlowFunctionDto> {
5
+ constructor(httpClient: HttpClient);
6
+ addMany(dto: any[]): Promise<FlowFunctionDto[]>;
7
+ getOneWithHistory(fqn: string): Promise<FlowFunctionDto>;
8
+ rollback(fqn: string, historyId: string): Promise<FlowFunctionDto>;
9
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowFunctionService = void 0;
4
+ const data_service_1 = require("./data.service");
5
+ class FlowFunctionService extends data_service_1.DataService {
6
+ constructor(httpClient) {
7
+ super(httpClient, '/flow/functions');
8
+ }
9
+ addMany(dto) {
10
+ const reqs = dto.map((v) => this.addOne(v));
11
+ return Promise.all(reqs);
12
+ }
13
+ getOneWithHistory(fqn) {
14
+ return this.httpClient.get(`${this.basePath}/${fqn}/history`);
15
+ }
16
+ rollback(fqn, historyId) {
17
+ return this.httpClient.put(`${this.basePath}/${fqn}/rollback/${historyId}`, {});
18
+ }
19
+ }
20
+ exports.FlowFunctionService = FlowFunctionService;
@@ -0,0 +1,13 @@
1
+ import { Artifact } from './storage.interface';
2
+ export interface FlowModule {
3
+ name: string;
4
+ description?: string;
5
+ artifacts: Artifact[];
6
+ author: string;
7
+ tags?: string[];
8
+ functions: string[];
9
+ readPermissions: string[];
10
+ readWritePermissions: string[];
11
+ createdAt?: string;
12
+ updatedAt?: string;
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ /// <reference types="node" />
2
+ import { DataService } from './data.service';
3
+ import { FlowModule } from './flow-module.interface';
4
+ import { HttpClient } from './http.service';
5
+ import { ReadStream } from 'fs';
6
+ export declare class FlowModuleService extends DataService<FlowModule> {
7
+ constructor(httpClient: HttpClient);
8
+ deleteArtifact(name: string, version: string): Promise<FlowModule>;
9
+ download(name: string, filePath: string, version?: string): Promise<void>;
10
+ publish(file: ReadStream): Promise<unknown>;
11
+ addOne(dto: any): Promise<FlowModule>;
12
+ addMany(dto: any[]): Promise<FlowModule[]>;
13
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowModuleService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const data_service_1 = require("./data.service");
6
+ const fs_1 = require("fs");
7
+ const form_data_1 = tslib_1.__importDefault(require("form-data"));
8
+ const promises_1 = require("stream/promises");
9
+ class FlowModuleService extends data_service_1.DataService {
10
+ constructor(httpClient) {
11
+ super(httpClient, '/flow/modules');
12
+ }
13
+ deleteArtifact(name, version) {
14
+ return this.httpClient.delete(`${this.basePath}/${name}/${version}`);
15
+ }
16
+ async download(name, filePath, version = 'latest') {
17
+ const writer = (0, fs_1.createWriteStream)(filePath);
18
+ return this.httpClient.get(`${this.basePath}/${name}/${version}`, { responseType: 'stream' }).then(async (response) => {
19
+ response.pipe(writer);
20
+ return (0, promises_1.finished)(writer);
21
+ });
22
+ }
23
+ publish(file) {
24
+ const form = new form_data_1.default();
25
+ form.append('file', file);
26
+ const config = {
27
+ headers: Object.assign({}, form.getHeaders()),
28
+ maxBodyLength: Infinity,
29
+ maxContentLength: Infinity,
30
+ };
31
+ return this.httpClient.post(`${this.basePath}`, form, config);
32
+ }
33
+ addOne(dto) {
34
+ throw new Error('not allowed: use publish instead');
35
+ }
36
+ addMany(dto) {
37
+ throw new Error('not allowed: use publish instead');
38
+ }
39
+ }
40
+ exports.FlowModuleService = FlowModuleService;
@@ -0,0 +1,25 @@
1
+ import { Resource } from './resource.interface';
2
+ import { JsonSchemaForm } from './schema.interface';
3
+ import { FlowDeployment } from './flow-deployment.interface';
4
+ export interface FlowDto extends Resource {
5
+ diagram: string | FlowDiagram;
6
+ deployments?: string[] | FlowDeployment[];
7
+ dashboard?: DashboardItem[];
8
+ propertiesSchema?: JsonSchemaForm;
9
+ }
10
+ export interface DashboardItem {
11
+ id: string;
12
+ cols: number;
13
+ rows: number;
14
+ x: number;
15
+ y: number;
16
+ }
17
+ export interface FlowDiagram {
18
+ id: string;
19
+ flow: string | FlowDto;
20
+ json: string;
21
+ author: string;
22
+ createdAt?: Date | string;
23
+ updatedAt?: Date | string;
24
+ deleteddAt?: Date | string;
25
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ import { DataService } from './data.service';
2
+ import { FlowDto } from './flow.interface';
3
+ import { HttpClient } from './http.service';
4
+ import { Paginated, RequestParameter } from './data.interface';
5
+ export declare class FlowService extends DataService<FlowDto> {
6
+ constructor(httpClient: HttpClient);
7
+ addMany(dto: any[]): Promise<FlowDto[]>;
8
+ getMany(params?: RequestParameter): Promise<Paginated<FlowDto[]>>;
9
+ getOne(id: string, options?: any): Promise<FlowDto>;
10
+ getFlowWithDiagram(diagramId: string): Promise<FlowDto>;
11
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowService = void 0;
4
+ const data_service_1 = require("./data.service");
5
+ class FlowService extends data_service_1.DataService {
6
+ constructor(httpClient) {
7
+ super(httpClient, '/flows');
8
+ }
9
+ addMany(dto) {
10
+ const reqs = dto.map((v) => this.addOne(v));
11
+ return Promise.all(reqs);
12
+ }
13
+ getMany(params = {}) {
14
+ params.populate = params.populate ? params.populate : 'none';
15
+ return super.getMany(params);
16
+ }
17
+ getOne(id, options = {}) {
18
+ options.populate = options.populate ? options.populate : 'none';
19
+ return super.getOne(id, options);
20
+ }
21
+ getFlowWithDiagram(diagramId) {
22
+ return this.httpClient.get(`${this.basePath}/diagram/${diagramId}`);
23
+ }
24
+ }
25
+ exports.FlowService = FlowService;
@@ -1,5 +1,7 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
+ import EventSource from 'eventsource';
2
3
  export declare class HttpClient {
4
+ private baseURL;
3
5
  private readonly realm;
4
6
  private readonly client;
5
7
  private readonly secret;
@@ -8,6 +10,7 @@ export declare class HttpClient {
8
10
  private readonly requestQueue;
9
11
  private accessToken;
10
12
  private accessTokenExpiration;
13
+ eventSourcesMap: Map<string, EventSource>;
11
14
  constructor(baseURL: string, authbaseURL: string, realm: string, client: string, secret: string);
12
15
  getQueueStats: () => {
13
16
  peak: number;
@@ -20,6 +23,9 @@ export declare class HttpClient {
20
23
  post: <T>(url: string, data: any, config?: AxiosRequestConfig) => Promise<T>;
21
24
  put: <T>(url: string, data: any, config?: AxiosRequestConfig) => Promise<T>;
22
25
  private request;
26
+ addEventSource(url: string, listener: (event: MessageEvent) => void, errorListener?: (event: MessageEvent) => void): Promise<string>;
27
+ destroyEventSource(id: string): void;
28
+ destroyAllEventSources(): void;
23
29
  getAccessToken: () => Promise<string>;
24
30
  private isTokenValid;
25
31
  private getToken;
@@ -2,15 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HttpClient = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const axios_1 = (0, tslib_1.__importDefault)(require("axios"));
5
+ const axios_1 = tslib_1.__importDefault(require("axios"));
6
+ const eventsource_1 = tslib_1.__importDefault(require("eventsource"));
6
7
  const Queue_1 = require("./Queue");
8
+ const crypto_1 = require("crypto");
7
9
  const EXPIRATION_BUFFER = 30 * 1000;
8
10
  class HttpClient {
9
11
  constructor(baseURL, authbaseURL, realm, client, secret) {
12
+ this.baseURL = baseURL;
10
13
  this.realm = realm;
11
14
  this.client = client;
12
15
  this.secret = secret;
13
16
  this.accessTokenExpiration = 0;
17
+ this.eventSourcesMap = new Map();
14
18
  this.getQueueStats = () => { var _a; return (_a = this.requestQueue) === null || _a === void 0 ? void 0 : _a.getStats(); };
15
19
  this.delete = (url, config) => this.request('DELETE', url, config);
16
20
  this.get = (url, config) => this.request('GET', url, config);
@@ -69,5 +73,34 @@ class HttpClient {
69
73
  this.authAxiosInstance = axios_1.default.create({ baseURL: authbaseURL || baseURL, timeout: 10000 });
70
74
  this.requestQueue = new Queue_1.Queue({ concurrency: 1, timeout: 70000, throwOnTimeout: true });
71
75
  }
76
+ async addEventSource(url, listener, errorListener) {
77
+ const id = (0, crypto_1.randomUUID)();
78
+ const es = new eventsource_1.default(`${this.baseURL}${url}`, {
79
+ headers: { authorization: 'Bearer ' + (await this.getAccessToken()) },
80
+ });
81
+ es.addEventListener('message', listener);
82
+ es.addEventListener('error', errorListener
83
+ ? errorListener
84
+ : (event) => {
85
+ throw new Error(JSON.stringify(event, null, 2));
86
+ });
87
+ this.eventSourcesMap.set(id, es);
88
+ return id;
89
+ }
90
+ destroyEventSource(id) {
91
+ if (!this.eventSourcesMap.has(id)) {
92
+ return;
93
+ }
94
+ const es = this.eventSourcesMap.get(id);
95
+ es.close();
96
+ es.removeEventListener('message', () => { });
97
+ es.removeEventListener('error', () => { });
98
+ this.eventSourcesMap.delete(id);
99
+ }
100
+ destroyAllEventSources() {
101
+ for (const key of this.eventSourcesMap.keys()) {
102
+ this.destroyEventSource(key);
103
+ }
104
+ }
72
105
  }
73
106
  exports.HttpClient = HttpClient;
package/dist/index.d.ts CHANGED
@@ -10,4 +10,9 @@ export * from './timeseries.interface';
10
10
  export * from './task.interface';
11
11
  export * from './events.interface';
12
12
  export * from './mock';
13
+ export * from './flow-deployment.interface';
14
+ export * from './flow-function.interface';
15
+ export * from './flow.interface';
16
+ export * from './resource.interface';
17
+ export * from './schema.interface';
13
18
  export * as SiDrive from './sidriveiq.interface';
package/dist/index.js CHANGED
@@ -2,16 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SiDrive = void 0;
4
4
  const tslib_1 = require("tslib");
5
- (0, tslib_1.__exportStar)(require("./api"), exports);
6
- (0, tslib_1.__exportStar)(require("./asset.interface"), exports);
7
- (0, tslib_1.__exportStar)(require("./content.interface"), exports);
8
- (0, tslib_1.__exportStar)(require("./data.interface"), exports);
9
- (0, tslib_1.__exportStar)(require("./data.service"), exports);
10
- (0, tslib_1.__exportStar)(require("./endpoint.interface"), exports);
11
- (0, tslib_1.__exportStar)(require("./http.service"), exports);
12
- (0, tslib_1.__exportStar)(require("./secret.interface"), exports);
13
- (0, tslib_1.__exportStar)(require("./timeseries.interface"), exports);
14
- (0, tslib_1.__exportStar)(require("./task.interface"), exports);
15
- (0, tslib_1.__exportStar)(require("./events.interface"), exports);
16
- (0, tslib_1.__exportStar)(require("./mock"), exports);
17
- exports.SiDrive = (0, tslib_1.__importStar)(require("./sidriveiq.interface"));
5
+ tslib_1.__exportStar(require("./api"), exports);
6
+ tslib_1.__exportStar(require("./asset.interface"), exports);
7
+ tslib_1.__exportStar(require("./content.interface"), exports);
8
+ tslib_1.__exportStar(require("./data.interface"), exports);
9
+ tslib_1.__exportStar(require("./data.service"), exports);
10
+ tslib_1.__exportStar(require("./endpoint.interface"), exports);
11
+ tslib_1.__exportStar(require("./http.service"), exports);
12
+ tslib_1.__exportStar(require("./secret.interface"), exports);
13
+ tslib_1.__exportStar(require("./timeseries.interface"), exports);
14
+ tslib_1.__exportStar(require("./task.interface"), exports);
15
+ tslib_1.__exportStar(require("./events.interface"), exports);
16
+ tslib_1.__exportStar(require("./mock"), exports);
17
+ tslib_1.__exportStar(require("./flow-deployment.interface"), exports);
18
+ tslib_1.__exportStar(require("./flow-function.interface"), exports);
19
+ tslib_1.__exportStar(require("./flow.interface"), exports);
20
+ tslib_1.__exportStar(require("./resource.interface"), exports);
21
+ tslib_1.__exportStar(require("./schema.interface"), exports);
22
+ exports.SiDrive = tslib_1.__importStar(require("./sidriveiq.interface"));
@@ -15,6 +15,15 @@ import { Task } from '../task.interface';
15
15
  import { TimeseriesMockService } from './timeseries.mock.service';
16
16
  import { TaskMockService } from './task.mock.service';
17
17
  import { UserMockService } from './user.mock.service';
18
+ import { FlowDeploymentService } from '../flow-deployment.service';
19
+ import { FlowFunctionService } from '../flow-function.service';
20
+ import { FlowModuleService } from '../flow-module.service';
21
+ import { FlowService } from '../flow.service';
22
+ import { FlowDiagram, FlowDto } from '../flow.interface';
23
+ import { FlowDeployment } from '../flow-deployment.interface';
24
+ import { FlowFunctionDto } from '../flow-function.interface';
25
+ import { FlowModule } from '../flow-module.interface';
26
+ import { Artifact } from '../storage.interface';
18
27
  export declare class MockAPI implements API {
19
28
  httpClient: any;
20
29
  assets: AssetMockService;
@@ -22,6 +31,10 @@ export declare class MockAPI implements API {
22
31
  contents: ContentMockService;
23
32
  endpoints: EndpointMockService;
24
33
  events: EventsMockService;
34
+ flows: FlowService;
35
+ flowDeployments: FlowDeploymentService;
36
+ flowFunctions: FlowFunctionService;
37
+ flowModules: FlowModuleService;
25
38
  proxy: any;
26
39
  secrets: SecretMockService;
27
40
  tasks: TaskMockService;
@@ -46,6 +59,11 @@ export declare class MockAPI implements API {
46
59
  tasks?: TaskInit[];
47
60
  events?: EventInit[];
48
61
  users?: UserInit;
62
+ flows?: FlowInit[];
63
+ deployments?: FlowDeploymentInit[];
64
+ functions?: FlowFunctionInit[];
65
+ modules?: FlowModuleInit[];
66
+ diagrams?: FlowDiagramInit[];
49
67
  });
50
68
  }
51
69
  export declare type Identity<T> = {
@@ -69,6 +87,16 @@ export declare type TimeSeriesInit = Identity<AtLeast<TimeSeries, 'id' | 'name'>
69
87
  }>;
70
88
  export declare type TaskInit = AtLeast<Task, 'name' | 'assignedTo'>;
71
89
  export declare type EventInit = AtLeast<Event, 'name'>;
90
+ export declare type FlowInit = AtLeast<FlowDto, 'id'>;
91
+ export declare type FlowDeploymentInit = AtLeast<FlowDeployment, 'id' | 'flow'>;
92
+ export declare type FlowFunctionInit = AtLeast<Identity<FlowFunctionDto & {
93
+ id: string;
94
+ }>, 'fqn' | 'id'>;
95
+ export declare type FlowModuleInit = Replace<AtLeast<FlowModule, 'name'>, 'artifacts', ArtifactInit[]>;
96
+ export declare type ArtifactInit = AtLeast<Artifact & {
97
+ path: string;
98
+ }, 'filename' | 'path'>;
99
+ export declare type FlowDiagramInit = AtLeast<FlowDiagram, 'id' | 'flow'>;
72
100
  export interface UserInit {
73
101
  roles: string[];
74
102
  }
@@ -11,12 +11,17 @@ const secret_mock_service_1 = require("./secret.mock.service");
11
11
  const timeseries_mock_service_1 = require("./timeseries.mock.service");
12
12
  const task_mock_service_1 = require("./task.mock.service");
13
13
  const user_mock_service_1 = require("./user.mock.service");
14
+ const flow_mock_service_1 = require("./flow.mock.service");
15
+ const flow_deployment_mock_service_1 = require("./flow-deployment.mock.service");
16
+ const flow_functions_mock_service_1 = require("./flow-functions.mock.service");
17
+ const flow_modules_mock_service_1 = require("./flow-modules.mock.service");
18
+ const crypto_1 = require("crypto");
14
19
  class MockAPI {
15
20
  constructor(initData) {
16
21
  this.httpClient = null;
17
22
  this.proxy = null;
18
23
  this.siDrive = null;
19
- const { assets = [], revisions = [], contents = [], endpoints = [], secrets = [], timeSeries = [], tasks = [], events = [], users, } = initData;
24
+ const { assets = [], revisions = [], contents = [], endpoints = [], secrets = [], timeSeries = [], tasks = [], events = [], users, flows = [], deployments = [], functions = [], modules = [], diagrams = [], } = initData;
20
25
  const assetTypes = assets
21
26
  .map((v) => v.type)
22
27
  .map((v) => {
@@ -91,6 +96,31 @@ class MockAPI {
91
96
  group: v.group,
92
97
  }));
93
98
  const timeseriesValues = timeSeries.map((v) => v.values);
99
+ const diagrams1 = diagrams.map((v) => (Object.assign(Object.assign({}, v), { json: '', author: 'nobody' })));
100
+ const flows1 = flows.map((v) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], diagram: diagrams.find((v1) => v1.flow === v.id).id, name: `flow-${v.id}`, deployments: [] })));
101
+ const deployments1 = deployments.map((v) => {
102
+ var _a;
103
+ return (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], diagram: (_a = v.diagram) !== null && _a !== void 0 ? _a : '', artifact: null, flowModel: { connections: [], elements: [] }, desiredStatus: 'running', actualStatus: 'generating queued', target: 'executor', name: `deployment-${v.id}` }));
104
+ });
105
+ const functions1 = functions.map((v) => {
106
+ var _a;
107
+ return (Object.assign(Object.assign({}, v), { category: 'task', readPermissions: [], readWritePermissions: [], author: 'nobody', current: v.id, history: [v.id, ...((_a = v === null || v === void 0 ? void 0 : v.history) !== null && _a !== void 0 ? _a : [])] }));
108
+ });
109
+ const historyMap = new Map();
110
+ functions1.forEach((func) => {
111
+ func.history.forEach((hist) => {
112
+ if (historyMap.has(func.fqn)) {
113
+ historyMap.get(func.fqn).push(functions1.find((v) => v.id === hist));
114
+ }
115
+ else {
116
+ historyMap.set(func.fqn, [functions1.find((v) => v.id === hist)]);
117
+ }
118
+ });
119
+ });
120
+ const modules1 = modules.map((v, index) => {
121
+ var _a;
122
+ return (Object.assign(Object.assign({}, v), { artifacts: (_a = modules[index].artifacts.map((art) => (Object.assign(Object.assign({}, art), { version: '0.0.0', id: (0, crypto_1.randomUUID)(), mimetype: '', size: 0, createdAt: '' + Date.now() })))) !== null && _a !== void 0 ? _a : [], author: 'nobody', functions: [], readPermissions: [], readWritePermissions: [] }));
123
+ });
94
124
  this.assets = new asset_mock_service_1.AssetMockService(this, assets1, revisions1);
95
125
  this.contents = new content_mock_service_1.ContentMockService(contents1, contentData);
96
126
  this.endpoints = new endpoint_mock_service_1.EndpointMockService(endpoint1);
@@ -99,6 +129,10 @@ class MockAPI {
99
129
  this.tasks = new task_mock_service_1.TaskMockService(tasks1);
100
130
  this.events = new events_mock_service_1.EventsMockService(events1);
101
131
  this.users = new user_mock_service_1.UserMockService(users);
132
+ this.flows = new flow_mock_service_1.FlowMockService(flows1, diagrams1);
133
+ this.flowDeployments = new flow_deployment_mock_service_1.FlowDeploymentMockService(deployments1, this);
134
+ this.flowFunctions = new flow_functions_mock_service_1.FlowFunctionsMockService(functions1, historyMap);
135
+ this.flowModules = new flow_modules_mock_service_1.FlowModulesMockService(modules1);
102
136
  this.assetManager = this.assets;
103
137
  this.contentManager = this.contents;
104
138
  this.endpointManager = this.endpoints;
@@ -0,0 +1,27 @@
1
+ import { DataMockService } from './data.mock.service';
2
+ import { FlowDeployment, FlowDeploymentMetrics, FlowDeploymentStatistic, FlowLog } from '../flow-deployment.interface';
3
+ import { FlowDeploymentService } from '../flow-deployment.service';
4
+ import { ResourceReference } from '../resource.interface';
5
+ import { MockAPI } from './api.mock';
6
+ export declare class FlowDeploymentMockService extends DataMockService<FlowDeployment> implements FlowDeploymentService {
7
+ private api;
8
+ constructor(deployments: FlowDeployment[], api: MockAPI);
9
+ subscribeToStatus(id: string, listener: (event: MessageEvent<any>) => void, errorListener?: (event: MessageEvent<any>) => void): Promise<string>;
10
+ subscribeToLogs(id: string, listener: (event: MessageEvent<any>) => void, errorListener?: (event: MessageEvent) => void): Promise<string>;
11
+ waitForRunningStatus(id: string): Promise<void>;
12
+ updateStatus(id: string, desiredStatus: 'running' | 'stopped' | 'deleted'): Promise<FlowDeployment>;
13
+ resolveReferences(id: string, recursive?: boolean, types?: string[]): Promise<ResourceReference[]>;
14
+ getDeploymentStatistics(id: string): Promise<FlowDeploymentStatistic>;
15
+ getDeploymentMetrics(id: string, range?: string, interval?: string): Promise<FlowDeploymentMetrics>;
16
+ getDeploymentLogs(id: string): Promise<FlowLog[]>;
17
+ addOne(dto: {
18
+ diagramId: string;
19
+ name: string;
20
+ properties?: Record<string, any>;
21
+ readPermissions?: string[];
22
+ readWritePermissions?: string[];
23
+ tags?: string[];
24
+ }): Promise<FlowDeployment>;
25
+ deleteOne(id: string): Promise<FlowDeployment>;
26
+ private getReferences;
27
+ }
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowDeploymentMockService = void 0;
4
+ const data_mock_service_1 = require("./data.mock.service");
5
+ const crypto_1 = require("crypto");
6
+ class FlowDeploymentMockService extends data_mock_service_1.DataMockService {
7
+ constructor(deployments, api) {
8
+ super();
9
+ this.api = api;
10
+ this.data = deployments;
11
+ }
12
+ subscribeToStatus(id, listener, errorListener) {
13
+ listener(new MessageEvent('message', { data: 'running' }));
14
+ return Promise.resolve((0, crypto_1.randomUUID)());
15
+ }
16
+ subscribeToLogs(id, listener, errorListener) {
17
+ listener(new MessageEvent('message', { data: 'foo' }));
18
+ return Promise.resolve((0, crypto_1.randomUUID)());
19
+ }
20
+ async waitForRunningStatus(id) {
21
+ const flowDeployment = this.data.find((v) => v.id === id);
22
+ flowDeployment.actualStatus = 'running';
23
+ }
24
+ async updateStatus(id, desiredStatus) {
25
+ const deployment = await this.getOne(id);
26
+ deployment.desiredStatus = desiredStatus;
27
+ deployment.actualStatus = desiredStatus;
28
+ return Promise.resolve(deployment);
29
+ }
30
+ async resolveReferences(id, recursive, types) {
31
+ var _a;
32
+ const depl = await this.getOne(id);
33
+ return (_a = depl.refs) !== null && _a !== void 0 ? _a : [];
34
+ }
35
+ getDeploymentStatistics(id) {
36
+ return Promise.resolve({
37
+ totalErrorCount: 0,
38
+ errorCountWeek: 0,
39
+ eventCountWeek: 0,
40
+ errorCounts: [],
41
+ metrics: {
42
+ cpu: 0,
43
+ memory: 97931264,
44
+ ctime: 16770,
45
+ elapsed: 172850950,
46
+ timestamp: 1648199692625,
47
+ deploymentId: id,
48
+ },
49
+ });
50
+ }
51
+ getDeploymentMetrics(id, range, interval) {
52
+ return Promise.resolve({
53
+ metrics: [{ timestamp: Date.now(), cpu: 0, memory: Math.random() * 1000000 }],
54
+ stats: {
55
+ cpu: { count: 123, avg: 0, max: 0, min: 0, sum: 0 },
56
+ memory: { count: 123, avg: 0, max: 0, min: 0, sum: 0 },
57
+ },
58
+ });
59
+ }
60
+ async getDeploymentLogs(id) {
61
+ const depl = await this.getOne(id);
62
+ return Promise.resolve([
63
+ {
64
+ type: 'flow.log.info',
65
+ deploymentId: id,
66
+ subject: 'FlowApplication',
67
+ data: 'Flow Deployment is running',
68
+ '@timestamp': '2022-03-23T09:14:03.129Z',
69
+ eventId: 'c68b7674-b8da-46c5-85f0-8e4279d74a78',
70
+ datacontenttype: 'text/plain',
71
+ elementId: 'none',
72
+ time: '2022-03-23T09:14:03.129Z',
73
+ flowId: depl.flow,
74
+ },
75
+ ]);
76
+ }
77
+ async addOne(dto) {
78
+ const flow = await this.api.flows.getFlowWithDiagram(dto.diagramId);
79
+ const refs = await this.getReferences(dto.properties);
80
+ const id = (0, crypto_1.randomUUID)();
81
+ const newDepl = {
82
+ actualStatus: 'generating queued',
83
+ artifact: undefined,
84
+ desiredStatus: 'running',
85
+ diagram: dto.diagramId,
86
+ flow: flow.id,
87
+ flowModel: { elements: [], connections: [], properties: dto.properties },
88
+ id,
89
+ name: dto.name,
90
+ readPermissions: [],
91
+ readWritePermissions: [],
92
+ target: 'executor',
93
+ refs,
94
+ };
95
+ await this.api.flows.updateOne(flow.id, Object.assign(Object.assign({}, flow), { deployments: [...flow.deployments, id] }));
96
+ return super.addOne(newDepl);
97
+ }
98
+ async deleteOne(id) {
99
+ const depl = await this.getOne(id);
100
+ const flow = await this.api.flows.getOne(depl.flow);
101
+ const index = flow.deployments.findIndex((v) => v === id);
102
+ flow.deployments.splice(index, 1);
103
+ await this.api.flows.updateOne(flow.id, flow);
104
+ return super.deleteOne(id);
105
+ }
106
+ async getReferences(properties) {
107
+ return Promise.all(Object.keys(properties).map(async (prop) => {
108
+ switch (prop) {
109
+ case 'assetId':
110
+ return { id: (await this.api.assets.getOne(properties[prop])).id, resourceType: 'asset' };
111
+ default:
112
+ throw new Error('not implemented');
113
+ }
114
+ }));
115
+ }
116
+ }
117
+ exports.FlowDeploymentMockService = FlowDeploymentMockService;
@@ -0,0 +1,14 @@
1
+ import { DataMockService } from './data.mock.service';
2
+ import { FlowFunctionDto } from '../flow-function.interface';
3
+ import { FlowFunctionService } from '../flow-function.service';
4
+ export declare class FlowFunctionsMockService extends DataMockService<FlowFunctionDto> implements FlowFunctionService {
5
+ private history;
6
+ constructor(functions: FlowFunctionDto[], history: Map<string, Array<FlowFunctionDto & {
7
+ id: string;
8
+ }>>);
9
+ getOneWithHistory(fqn: string): Promise<FlowFunctionDto>;
10
+ rollback(fqn: string, historyId: string): Promise<FlowFunctionDto>;
11
+ getOne(fqn: string, options?: any): Promise<FlowFunctionDto>;
12
+ private getOneById;
13
+ updateOne(fqn: string, dto: FlowFunctionDto): Promise<FlowFunctionDto>;
14
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowFunctionsMockService = void 0;
4
+ const data_mock_service_1 = require("./data.mock.service");
5
+ const crypto_1 = require("crypto");
6
+ class FlowFunctionsMockService extends data_mock_service_1.DataMockService {
7
+ constructor(functions, history) {
8
+ super();
9
+ this.history = history;
10
+ this.data = functions;
11
+ }
12
+ async getOneWithHistory(fqn) {
13
+ const func = await this.getOne(fqn);
14
+ return Promise.resolve(Object.assign(Object.assign({}, func), { history: await Promise.all(func.history.map(async (v) => {
15
+ const func1 = (await this.getOneById(v));
16
+ return { author: func1.author, createdAt: '', id: func1.id };
17
+ })) }));
18
+ }
19
+ rollback(fqn, historyId) {
20
+ const hist = this.history.get(fqn).find((v) => v.id === historyId);
21
+ const index = this.data.findIndex((v) => v.fqn === fqn);
22
+ hist.current = hist.id;
23
+ this.data[index] = hist;
24
+ return Promise.resolve(hist);
25
+ }
26
+ getOne(fqn, options) {
27
+ const t = this.data.find((v) => v.fqn === fqn);
28
+ return Promise.resolve(t);
29
+ }
30
+ async getOneById(id) {
31
+ return this.data.find((v) => v.id === id);
32
+ }
33
+ async updateOne(fqn, dto) {
34
+ const id = (0, crypto_1.randomUUID)();
35
+ const exDto = Object.assign(Object.assign({}, dto), { id, current: id });
36
+ exDto.history.push(id);
37
+ this.history.get(fqn).push(exDto);
38
+ return exDto;
39
+ }
40
+ }
41
+ exports.FlowFunctionsMockService = FlowFunctionsMockService;
@@ -0,0 +1,18 @@
1
+ /// <reference types="node" />
2
+ import { DataMockService } from './data.mock.service';
3
+ import { FlowModule } from '../flow-module.interface';
4
+ import { FlowModuleService } from '../flow-module.service';
5
+ import { ReadStream } from 'fs';
6
+ import { Artifact } from '../storage.interface';
7
+ import { Replace } from './api.mock';
8
+ declare type ExtendedFlowModule = Replace<FlowModule, 'artifacts', Array<Artifact & {
9
+ path: string;
10
+ }>>;
11
+ export declare class FlowModulesMockService extends DataMockService<ExtendedFlowModule> implements FlowModuleService {
12
+ constructor(modules: ExtendedFlowModule[]);
13
+ deleteArtifact(name: string, version: string): Promise<FlowModule>;
14
+ download(name: string, filePath: string, version?: string): Promise<void>;
15
+ publish(file: ReadStream): Promise<unknown>;
16
+ getOne(name: string, options?: any): Promise<ExtendedFlowModule>;
17
+ }
18
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowModulesMockService = void 0;
4
+ const data_mock_service_1 = require("./data.mock.service");
5
+ const fs_1 = require("fs");
6
+ const promises_1 = require("stream/promises");
7
+ class FlowModulesMockService extends data_mock_service_1.DataMockService {
8
+ constructor(modules) {
9
+ super();
10
+ this.data = modules;
11
+ }
12
+ async deleteArtifact(name, version) {
13
+ const module = await this.getOne(name);
14
+ const index = module.artifacts.findIndex((art) => art.version === version);
15
+ module.artifacts.splice(index, 1);
16
+ return Promise.resolve(module);
17
+ }
18
+ async download(name, filePath, version = 'latest') {
19
+ var _a, _b;
20
+ const module = await this.getOne(name);
21
+ const reader = (0, fs_1.createReadStream)((_b = (_a = module.artifacts.find((art) => art.version === version)) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : module.artifacts[0].path);
22
+ const writer = (0, fs_1.createWriteStream)(filePath);
23
+ reader.pipe(writer);
24
+ return (0, promises_1.finished)(writer);
25
+ }
26
+ publish(file) {
27
+ return Promise.resolve(undefined);
28
+ }
29
+ getOne(name, options = {}) {
30
+ const t = this.data.find((v) => v.name === name);
31
+ return Promise.resolve(t);
32
+ }
33
+ }
34
+ exports.FlowModulesMockService = FlowModulesMockService;
@@ -0,0 +1,10 @@
1
+ import { DataMockService } from './data.mock.service';
2
+ import { FlowDiagram, FlowDto } from '../flow.interface';
3
+ import { FlowService } from '../flow.service';
4
+ import { Paginated, RequestParameter } from '../data.interface';
5
+ export declare class FlowMockService extends DataMockService<FlowDto> implements FlowService {
6
+ private diagrams;
7
+ constructor(flows: FlowDto[], diagrams: FlowDiagram[]);
8
+ getFlowWithDiagram(diagramId: string): Promise<FlowDto>;
9
+ getMany(params?: RequestParameter): Promise<Paginated<FlowDto[]>>;
10
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowMockService = void 0;
4
+ const data_mock_service_1 = require("./data.mock.service");
5
+ class FlowMockService extends data_mock_service_1.DataMockService {
6
+ constructor(flows, diagrams) {
7
+ super();
8
+ this.diagrams = diagrams;
9
+ this.data = flows;
10
+ }
11
+ getFlowWithDiagram(diagramId) {
12
+ return Promise.resolve(this.data.find((v1) => v1.id === this.diagrams.find((v) => v.id === diagramId).flow));
13
+ }
14
+ async getMany(params) {
15
+ const flows = await super.getMany(params);
16
+ return {
17
+ docs: flows.docs.map((v) => (Object.assign(Object.assign({}, v), { diagram: this.diagrams.find((v1) => v1.id === v.diagram) }))),
18
+ total: 0,
19
+ limit: 0,
20
+ };
21
+ }
22
+ }
23
+ exports.FlowMockService = FlowMockService;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./api.mock"), exports);
5
- (0, tslib_1.__exportStar)(require("./asset.mock.service"), exports);
6
- (0, tslib_1.__exportStar)(require("./assetTypes.mock.service"), exports);
7
- (0, tslib_1.__exportStar)(require("./content.mock.service"), exports);
8
- (0, tslib_1.__exportStar)(require("./data.mock.service"), exports);
9
- (0, tslib_1.__exportStar)(require("./secret.mock.service"), exports);
10
- (0, tslib_1.__exportStar)(require("./timeseries.mock.service"), exports);
11
- (0, tslib_1.__exportStar)(require("./task.mock.service"), exports);
12
- (0, tslib_1.__exportStar)(require("./events.mock.service"), exports);
4
+ tslib_1.__exportStar(require("./api.mock"), exports);
5
+ tslib_1.__exportStar(require("./asset.mock.service"), exports);
6
+ tslib_1.__exportStar(require("./assetTypes.mock.service"), exports);
7
+ tslib_1.__exportStar(require("./content.mock.service"), exports);
8
+ tslib_1.__exportStar(require("./data.mock.service"), exports);
9
+ tslib_1.__exportStar(require("./secret.mock.service"), exports);
10
+ tslib_1.__exportStar(require("./timeseries.mock.service"), exports);
11
+ tslib_1.__exportStar(require("./task.mock.service"), exports);
12
+ tslib_1.__exportStar(require("./events.mock.service"), exports);
@@ -0,0 +1,18 @@
1
+ export interface ResourceReference {
2
+ id: string;
3
+ resourceType: string;
4
+ dependent?: boolean;
5
+ }
6
+ export interface Resource {
7
+ id: string;
8
+ name: string;
9
+ readPermissions: string[];
10
+ readWritePermissions: string[];
11
+ description?: string;
12
+ author?: string;
13
+ tags?: string[];
14
+ refs?: ResourceReference[];
15
+ createdAt?: string | Date;
16
+ updatedAt?: string | Date;
17
+ deleteddAt?: string | Date;
18
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,18 @@
1
+ export interface JsonSchemaForm {
2
+ schema: JsonSchema;
3
+ layout: Record<string, any> | Record<string, any>[];
4
+ }
5
+ export declare type JsonSchemaTypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
6
+ export declare type JsonSchemaType = string | number | boolean | {
7
+ [key: string]: JsonSchemaType;
8
+ } | JsonSchemaArray | null;
9
+ export declare type JsonSchemaArray = Array<JsonSchemaType>;
10
+ export interface JsonSchema {
11
+ default?: JsonSchemaType;
12
+ description?: string;
13
+ items?: JsonSchema | JsonSchema[];
14
+ properties?: Record<string, JsonSchema>;
15
+ required?: boolean | string[];
16
+ title?: string;
17
+ type?: JsonSchemaTypeName | JsonSchemaTypeName[];
18
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ export declare type FileType = 'original' | 'preview-sm' | 'preview-md' | 'preview-lg' | 'preview-xl';
2
+ export declare type StorageProvider = 's3' | 'mongo';
3
+ export interface Storage {
4
+ id: string;
5
+ filename: string;
6
+ mimetype: string;
7
+ size: number;
8
+ createdAt: string;
9
+ provider?: StorageProvider;
10
+ type?: FileType;
11
+ md5?: string;
12
+ }
13
+ export interface Artifact extends Storage {
14
+ version: string;
15
+ functions?: string[];
16
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserService = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const jwt_decode_1 = (0, tslib_1.__importDefault)(require("jwt-decode"));
5
+ const jwt_decode_1 = tslib_1.__importDefault(require("jwt-decode"));
6
6
  class UserService {
7
7
  constructor(httpClient) {
8
8
  this.httpClient = httpClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hahnpro/hpc-api",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "Module for easy access to the HahnPRO API",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -24,13 +24,15 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "axios": "^0.25.0",
27
+ "axios": "^0.26.1",
28
+ "eventsource": "^2.0.0",
28
29
  "form-data": "^4.0.0",
29
30
  "jwt-decode": "^3.1.2",
30
31
  "p-queue": "^6.6.2"
31
32
  },
32
33
  "devDependencies": {
33
- "axios-mock-adapter": "^1.20.0"
34
+ "axios-mock-adapter": "^1.20.0",
35
+ "@types/eventsource": "^1.1.8"
34
36
  },
35
37
  "engines": {
36
38
  "node": ">=v14.13"