@hahnpro/hpc-api 4.1.0 → 4.1.2

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.
@@ -15,7 +15,7 @@ class AssetService extends BaseService {
15
15
  constructor(httpClient) {
16
16
  super(httpClient, '/assets');
17
17
  this.addAttachment = (id, form) => {
18
- const headers = { ...form.getHeaders() };
18
+ const headers = Object.assign({}, form.getHeaders());
19
19
  return this.httpClient.post(`${this.basePath}/${id}/attachment`, form, {
20
20
  headers,
21
21
  maxBodyLength: Infinity,
@@ -16,33 +16,35 @@ class ContentService extends BaseService {
16
16
  constructor(httpClient) {
17
17
  super(httpClient, '/contents');
18
18
  this.upload = (form) => {
19
- const headers = { ...form.getHeaders() };
19
+ const headers = Object.assign({}, form.getHeaders());
20
20
  return this.httpClient.post(`${this.basePath}`, form, { headers, maxBodyLength: Infinity, maxContentLength: Infinity });
21
21
  };
22
22
  }
23
- async download(id, second) {
24
- let returnType;
25
- if (typeof second === 'boolean' || second == null) {
26
- returnType = second ? content_interface_1.ReturnType.ARRAYBUFFER : content_interface_1.ReturnType.BLOB;
27
- }
28
- else {
29
- returnType = second;
30
- }
31
- const url = `${this.basePath}/${id}/download`;
32
- switch (returnType) {
33
- case content_interface_1.ReturnType.TEXT:
34
- return this.httpClient.get(url, { responseType: 'text' });
35
- case content_interface_1.ReturnType.JSON:
36
- return this.httpClient.get(url, { responseType: 'json' });
37
- case content_interface_1.ReturnType.NODEBUFFER:
38
- return Buffer.from(new Uint8Array(await this.httpClient.get(url, { responseType: 'arraybuffer' })));
39
- case content_interface_1.ReturnType.BLOB:
40
- return this.httpClient.get(url, { responseType: 'blob' });
41
- case content_interface_1.ReturnType.ARRAYBUFFER:
42
- return this.httpClient.get(url, { responseType: 'arraybuffer' });
43
- case content_interface_1.ReturnType.NODESTREAM:
44
- return this.httpClient.get(url, { responseType: 'stream' });
45
- }
23
+ download(id, second) {
24
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
25
+ let returnType;
26
+ if (typeof second === 'boolean' || second == null) {
27
+ returnType = second ? content_interface_1.ReturnType.ARRAYBUFFER : content_interface_1.ReturnType.BLOB;
28
+ }
29
+ else {
30
+ returnType = second;
31
+ }
32
+ const url = `${this.basePath}/${id}/download`;
33
+ switch (returnType) {
34
+ case content_interface_1.ReturnType.TEXT:
35
+ return this.httpClient.get(url, { responseType: 'text' });
36
+ case content_interface_1.ReturnType.JSON:
37
+ return this.httpClient.get(url, { responseType: 'json' });
38
+ case content_interface_1.ReturnType.NODEBUFFER:
39
+ return Buffer.from(new Uint8Array(yield this.httpClient.get(url, { responseType: 'arraybuffer' })));
40
+ case content_interface_1.ReturnType.BLOB:
41
+ return this.httpClient.get(url, { responseType: 'blob' });
42
+ case content_interface_1.ReturnType.ARRAYBUFFER:
43
+ return this.httpClient.get(url, { responseType: 'arraybuffer' });
44
+ case content_interface_1.ReturnType.NODESTREAM:
45
+ return this.httpClient.get(url, { responseType: 'stream' });
46
+ }
47
+ });
46
48
  }
47
49
  }
48
50
  exports.ContentService = ContentService;
@@ -33,7 +33,8 @@ class FlowDeploymentService extends BaseService {
33
33
  return this.httpClient.get(`${this.basePath}/${id}/logs`);
34
34
  }
35
35
  resolveReferences(id, recursive = true, types) {
36
- const params = { recursive, types: types?.join(',') ?? undefined };
36
+ var _a;
37
+ const params = { recursive, types: (_a = types === null || types === void 0 ? void 0 : types.join(',')) !== null && _a !== void 0 ? _a : undefined };
37
38
  return this.httpClient.get(`${this.basePath}/${id}/references`, { params });
38
39
  }
39
40
  updateStatus(id, desiredStatus) {
@@ -42,15 +43,17 @@ class FlowDeploymentService extends BaseService {
42
43
  deleteOne(id) {
43
44
  return this.updateStatus(id, 'deleted');
44
45
  }
45
- async waitForRunningStatus(id) {
46
- return new Promise(async (resolve, reject) => {
47
- const esId = await this.subscribeToStatus(id, (event) => {
48
- if (event.type === 'message' &&
49
- ['running', 'deployment failed', 'deleted', 'generating failed', 'updating failed', 'upgrading failed'].includes(event.data)) {
50
- this.httpClient.destroyEventSource(esId);
51
- event.data === 'running' ? resolve() : reject(`Deployment in failed status: ${event.data}`);
52
- }
53
- });
46
+ waitForRunningStatus(id) {
47
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
48
+ return new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
49
+ const esId = yield this.subscribeToStatus(id, (event) => {
50
+ if (event.type === 'message' &&
51
+ ['running', 'deployment failed', 'deleted', 'generating failed', 'updating failed', 'upgrading failed'].includes(event.data)) {
52
+ this.httpClient.destroyEventSource(esId);
53
+ event.data === 'running' ? resolve() : reject(`Deployment in failed status: ${event.data}`);
54
+ }
55
+ });
56
+ }));
54
57
  });
55
58
  }
56
59
  addOne(dto) {
@@ -11,7 +11,7 @@ class FlowModuleService extends data_service_1.DataService {
11
11
  }
12
12
  publish(form) {
13
13
  const config = {
14
- headers: { ...form.getHeaders() },
14
+ headers: Object.assign({}, form.getHeaders()),
15
15
  maxBodyLength: Infinity,
16
16
  maxContentLength: Infinity,
17
17
  };
@@ -33,11 +33,13 @@ class FlowService extends BaseService {
33
33
  getDiagramRevisions(id) {
34
34
  return this.httpClient.get(`${this.basePath}/${id}/diagram/revisions`);
35
35
  }
36
- async isDeploymentOnLatestDiagramVersion(depl) {
37
- const flowId = typeof depl.flow === 'string' ? depl.flow : depl.flow.id;
38
- const diagramId = typeof depl.diagram === 'string' ? depl.diagram : depl.diagram.id;
39
- const revisions = await this.getDiagramRevisions(flowId);
40
- return revisions[revisions.length - 1].id === diagramId;
36
+ isDeploymentOnLatestDiagramVersion(depl) {
37
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
38
+ const flowId = typeof depl.flow === 'string' ? depl.flow : depl.flow.id;
39
+ const diagramId = typeof depl.diagram === 'string' ? depl.diagram : depl.diagram.id;
40
+ const revisions = yield this.getDiagramRevisions(flowId);
41
+ return revisions[revisions.length - 1].id === diagramId;
42
+ });
41
43
  }
42
44
  getRevisions(id) {
43
45
  return this.httpClient.get(`${this.basePath}/${id}/revisions`);
@@ -17,7 +17,7 @@ class HttpClient {
17
17
  this.clientId = clientId;
18
18
  this.clientSecret = clientSecret;
19
19
  this.eventSourcesMap = new Map();
20
- this.getQueueStats = () => this.requestQueue?.getStats();
20
+ this.getQueueStats = () => { var _a; return (_a = this.requestQueue) === null || _a === void 0 ? void 0 : _a.getStats(); };
21
21
  this.delete = (url, config) => this.request('DELETE', url, config);
22
22
  this.get = (url, config) => this.request('GET', url, config);
23
23
  this.post = (url, data, config) => this.request('POST', url, config, data);
@@ -26,37 +26,39 @@ class HttpClient {
26
26
  return this.requestQueue.add(() => new Promise((resolve, reject) => {
27
27
  this.getAccessToken()
28
28
  .then((token) => {
29
- const headers = { Authorization: `Bearer ${token}`, ...config.headers };
30
- return this.axiosInstance.request({ ...config, headers, method, url, data });
29
+ const headers = Object.assign({ Authorization: `Bearer ${token}` }, config.headers);
30
+ return this.axiosInstance.request(Object.assign(Object.assign({}, config), { headers, method, url, data }));
31
31
  })
32
32
  .then((response) => resolve(response.data))
33
33
  .catch(reject);
34
34
  }));
35
35
  };
36
- this.getAccessToken = async (forceRefresh = false) => {
36
+ this.getAccessToken = (forceRefresh = false) => tslib_1.__awaiter(this, void 0, void 0, function* () {
37
37
  if (forceRefresh || !this.tokenSet || this.tokenSet.isExpired()) {
38
38
  return this.requestAccessToken();
39
39
  }
40
40
  return this.tokenSet.accessToken;
41
- };
41
+ });
42
42
  this.axiosInstance = axios_1.default.create({ baseURL, timeout: 60000 });
43
43
  this.authAxiosInstance = axios_1.default.create({ baseURL: authBaseURL || baseURL, timeout: 10000 });
44
44
  this.requestQueue = new Queue_1.Queue({ concurrency: 1, timeout: 70000, throwOnTimeout: true });
45
45
  }
46
- async addEventSource(url, listener, errorListener) {
47
- const id = (0, uuid_1.v4)();
48
- const errListener = errorListener
49
- ? errorListener
50
- : (event) => {
51
- throw new Error(JSON.stringify(event, null, 2));
52
- };
53
- const es = new eventsource_1.default(`${this.baseURL}${url}`, {
54
- headers: { authorization: 'Bearer ' + (await this.getAccessToken()) },
46
+ addEventSource(url, listener, errorListener) {
47
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
48
+ const id = (0, uuid_1.v4)();
49
+ const errListener = errorListener
50
+ ? errorListener
51
+ : (event) => {
52
+ throw new Error(JSON.stringify(event, null, 2));
53
+ };
54
+ const es = new eventsource_1.default(`${this.baseURL}${url}`, {
55
+ headers: { authorization: 'Bearer ' + (yield this.getAccessToken()) },
56
+ });
57
+ es.addEventListener('message', listener);
58
+ es.addEventListener('error', errListener);
59
+ this.eventSourcesMap.set(id, { eventSource: es, listener, errListener });
60
+ return id;
55
61
  });
56
- es.addEventListener('message', listener);
57
- es.addEventListener('error', errListener);
58
- this.eventSourcesMap.set(id, { eventSource: es, listener, errListener });
59
- return id;
60
62
  }
61
63
  destroyEventSource(id) {
62
64
  if (!this.eventSourcesMap.has(id)) {
@@ -74,58 +76,63 @@ class HttpClient {
74
76
  }
75
77
  }
76
78
  validateIssuer(issuer) {
79
+ var _a, _b;
77
80
  if (!issuer.issuer ||
78
- !issuer.grant_types_supported?.includes('client_credentials') ||
79
- !issuer.token_endpoint_auth_methods_supported?.includes('client_secret_jwt')) {
81
+ !((_a = issuer.grant_types_supported) === null || _a === void 0 ? void 0 : _a.includes('client_credentials')) ||
82
+ !((_b = issuer.token_endpoint_auth_methods_supported) === null || _b === void 0 ? void 0 : _b.includes('client_secret_jwt'))) {
80
83
  throw new Error('Issuer does not support client_secret_jwt');
81
84
  }
82
85
  return issuer;
83
86
  }
84
- async discoverIssuer(uri) {
85
- const wellKnownUri = `${uri}/.well-known/openid-configuration`;
86
- const issuerResponse = await this.authAxiosInstance.get(wellKnownUri, {
87
- responseType: 'json',
88
- headers: { Accept: 'application/json' },
87
+ discoverIssuer(uri) {
88
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
89
+ const wellKnownUri = `${uri}/.well-known/openid-configuration`;
90
+ const issuerResponse = yield this.authAxiosInstance.get(wellKnownUri, {
91
+ responseType: 'json',
92
+ headers: { Accept: 'application/json' },
93
+ });
94
+ return this.validateIssuer(issuerResponse.data);
89
95
  });
90
- return this.validateIssuer(issuerResponse.data);
91
96
  }
92
- async requestAccessToken() {
93
- const issuer = await this.discoverIssuer(`${this.authBaseURL}/realms/${this.realm}`);
94
- const timestamp = Date.now() / 1000;
95
- const audience = [...new Set([issuer.issuer, issuer.token_endpoint].filter(Boolean))];
96
- const assertionPayload = {
97
- iat: timestamp,
98
- exp: timestamp + 60,
99
- jti: (0, uuid_1.v4)(),
100
- iss: this.clientId,
101
- sub: this.clientId,
102
- aud: audience,
103
- };
104
- const supportedAlgos = issuer.token_endpoint_auth_signing_alg_values_supported;
105
- const alg = issuer.token_endpoint_auth_signing_alg ??
106
- (Array.isArray(supportedAlgos) && supportedAlgos.find((signAlg) => /^HS(?:256|384|512)/.test(signAlg)));
107
- if (!alg) {
108
- throw new Error('Issuer has to support HS256, HS384 or HS512');
109
- }
110
- const assertion = await new jose_1.CompactSign(Buffer.from(JSON.stringify(assertionPayload)))
111
- .setProtectedHeader({ alg })
112
- .sign(new TextEncoder().encode(this.clientSecret));
113
- const opts = {
114
- client_id: this.clientId,
115
- client_assertion: assertion,
116
- client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
117
- grant_type: 'client_credentials',
118
- };
119
- const authResponse = await this.authAxiosInstance.post(issuer.token_endpoint, (0, querystring_1.stringify)(opts), {
120
- headers: { Accept: 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' },
97
+ requestAccessToken() {
98
+ var _a, _b;
99
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
100
+ const issuer = yield this.discoverIssuer(`${this.authBaseURL}/realms/${this.realm}`);
101
+ const timestamp = Date.now() / 1000;
102
+ const audience = [...new Set([issuer.issuer, issuer.token_endpoint].filter(Boolean))];
103
+ const assertionPayload = {
104
+ iat: timestamp,
105
+ exp: timestamp + 60,
106
+ jti: (0, uuid_1.v4)(),
107
+ iss: this.clientId,
108
+ sub: this.clientId,
109
+ aud: audience,
110
+ };
111
+ const supportedAlgos = issuer.token_endpoint_auth_signing_alg_values_supported;
112
+ const alg = (_a = issuer.token_endpoint_auth_signing_alg) !== null && _a !== void 0 ? _a : (Array.isArray(supportedAlgos) && supportedAlgos.find((signAlg) => /^HS(?:256|384|512)/.test(signAlg)));
113
+ if (!alg) {
114
+ throw new Error('Issuer has to support HS256, HS384 or HS512');
115
+ }
116
+ const assertion = yield new jose_1.CompactSign(Buffer.from(JSON.stringify(assertionPayload)))
117
+ .setProtectedHeader({ alg })
118
+ .sign(new TextEncoder().encode(this.clientSecret));
119
+ const opts = {
120
+ client_id: this.clientId,
121
+ client_assertion: assertion,
122
+ client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
123
+ grant_type: 'client_credentials',
124
+ };
125
+ const authResponse = yield this.authAxiosInstance.post(issuer.token_endpoint, (0, querystring_1.stringify)(opts), {
126
+ headers: { Accept: 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' },
127
+ });
128
+ if (((_b = authResponse === null || authResponse === void 0 ? void 0 : authResponse.data) === null || _b === void 0 ? void 0 : _b.access_token) && authResponse.data.expires_in) {
129
+ this.tokenSet = new token_set_1.TokenSet(authResponse.data.access_token, authResponse.data.expires_in);
130
+ return authResponse.data.access_token;
131
+ }
132
+ else {
133
+ throw new Error('Invalid access token received');
134
+ }
121
135
  });
122
- if (authResponse?.data?.access_token && authResponse.data.expires_in) {
123
- this.tokenSet = new token_set_1.TokenSet(authResponse.data.access_token, authResponse.data.expires_in);
124
- return authResponse.data.access_token;
125
- }
126
- else {
127
- throw new Error('Invalid access token received');
128
- }
129
136
  }
130
137
  }
131
138
  exports.HttpClient = HttpClient;
@@ -38,30 +38,16 @@ class MockAPI {
38
38
  uiSchema: {},
39
39
  };
40
40
  });
41
- const assets1 = assets.map((v, index) => ({
42
- ...v,
43
- readPermissions: [],
44
- readWritePermissions: [],
45
- type: assetTypes[index],
46
- }));
47
- const assetRevisions1 = assetRevisions.map((v, index) => ({
48
- ...v,
49
- readPermissions: [],
50
- readWritePermissions: [],
51
- type: assetTypes[index],
52
- }));
53
- const contents1 = contents.map((v) => ({
54
- ...v,
55
- readPermissions: [],
56
- readWritePermissions: [],
57
- size: 0,
58
- fileId: '',
59
- mimetype: v.mimetype || '',
60
- }));
41
+ const assets1 = assets.map((v, index) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], type: assetTypes[index] })));
42
+ const assetRevisions1 = assetRevisions.map((v, index) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], type: assetTypes[index] })));
43
+ const contents1 = contents.map((v) => {
44
+ var _a;
45
+ return (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], size: 0, fileId: '', mimetype: (_a = v.mimetype) !== null && _a !== void 0 ? _a : '' }));
46
+ });
61
47
  const contentData = contents.map((v) => {
62
48
  return v.data ? v.data : (0, fs_1.readFileSync)((0, path_1.join)(v.filePath, v.filename));
63
49
  });
64
- const secrets1 = secrets.map((v) => ({ ...v, readPermissions: [], readWritePermissions: [] }));
50
+ const secrets1 = secrets.map((v) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [] })));
65
51
  const timeSeries1 = timeSeries.map((value) => ({
66
52
  id: value.id,
67
53
  name: value.name,
@@ -116,77 +102,22 @@ class MockAPI {
116
102
  createdAt: v.createdAt,
117
103
  }));
118
104
  const timeseriesValues = timeSeries.map((v) => v.values);
119
- const diagrams1 = diagrams.map((v) => ({
120
- ...v,
121
- json: '',
122
- author: 'nobody',
123
- }));
124
- const flows1 = flows.map((v) => ({
125
- ...v,
126
- readPermissions: [],
127
- readWritePermissions: [],
128
- diagram: diagrams.find((v1) => v1.flow === v.id).id,
129
- name: `flow-${v.id}`,
130
- deployments: [],
131
- }));
132
- const flowRevisions1 = flowRevisions.map((v) => ({
133
- ...v,
134
- readPermissions: [],
135
- readWritePermissions: [],
136
- diagram: diagrams.find((v1) => v1.flow === v.originalId).id,
137
- name: `flow-${v.id}`,
138
- deployments: [],
139
- }));
140
- const deployments1 = deployments.map((v) => ({
141
- ...v,
142
- readPermissions: [],
143
- readWritePermissions: [],
144
- diagram: v.diagram ?? '',
145
- artifact: null,
146
- flowModel: { connections: [], elements: [] },
147
- desiredStatus: 'running',
148
- actualStatus: 'generating queued',
149
- target: 'executor',
150
- name: `deployment-${v.id}`,
151
- }));
152
- const functions1 = functions.map((v) => ({
153
- ...v,
154
- category: 'task',
155
- readPermissions: [],
156
- readWritePermissions: [],
157
- author: 'nobody',
158
- }));
159
- const functionRevisions1 = functionRevisions.map((v) => ({
160
- ...v,
161
- category: 'task',
162
- readPermissions: [],
163
- readWritePermissions: [],
164
- author: 'nobody',
165
- }));
166
- const modules1 = modules.map((v, index) => ({
167
- ...v,
168
- artifacts: modules[index].artifacts.map((art) => ({
169
- ...art,
170
- version: '0.0.0',
171
- id: (0, crypto_1.randomUUID)(),
172
- mimetype: '',
173
- size: 0,
174
- createdAt: '' + Date.now(),
175
- })) ?? [],
176
- author: 'nobody',
177
- functions: [],
178
- readPermissions: [],
179
- readWritePermissions: [],
180
- }));
181
- const labels1 = labels.map((label) => ({
182
- ...label,
183
- color: '',
184
- description: '',
185
- readPermissions: [],
186
- readWritePermissions: [],
187
- }));
188
- const vaultSecrets1 = vault.map((v) => ({ ...v, readPermissions: [], readWritePermissions: [] }));
189
- const notifications1 = notifications.map((n) => ({ ...n, link: '', description: '', read: false }));
105
+ const diagrams1 = diagrams.map((v) => (Object.assign(Object.assign({}, v), { json: '', author: 'nobody' })));
106
+ 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: [] })));
107
+ const flowRevisions1 = flowRevisions.map((v) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], diagram: diagrams.find((v1) => v1.flow === v.originalId).id, name: `flow-${v.id}`, deployments: [] })));
108
+ const deployments1 = deployments.map((v) => {
109
+ var _a;
110
+ 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}` }));
111
+ });
112
+ const functions1 = functions.map((v) => (Object.assign(Object.assign({}, v), { category: 'task', readPermissions: [], readWritePermissions: [], author: 'nobody' })));
113
+ const functionRevisions1 = functionRevisions.map((v) => (Object.assign(Object.assign({}, v), { category: 'task', readPermissions: [], readWritePermissions: [], author: 'nobody' })));
114
+ const modules1 = modules.map((v, index) => {
115
+ var _a;
116
+ 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: [] }));
117
+ });
118
+ const labels1 = labels.map((label) => (Object.assign(Object.assign({}, label), { color: '', description: '', readPermissions: [], readWritePermissions: [] })));
119
+ const vaultSecrets1 = vault.map((v) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [] })));
120
+ const notifications1 = notifications.map((n) => (Object.assign(Object.assign({}, n), { link: '', description: '', read: false })));
190
121
  this.assets = new asset_mock_service_1.AssetMockService(this, assets1, assetRevisions1);
191
122
  this.contents = new content_mock_service_1.ContentMockService(contents1, contentData);
192
123
  this.endpoints = new endpoint_mock_service_1.EndpointMockService(endpoint1);
@@ -27,12 +27,12 @@ class AssetMockService extends BaseService {
27
27
  return page;
28
28
  }
29
29
  addOne(dto) {
30
- this.revisions.push({ ...dto, originalId: dto.id });
30
+ this.revisions.push(Object.assign(Object.assign({}, dto), { originalId: dto.id }));
31
31
  return super.addOne(dto);
32
32
  }
33
33
  deleteOne(assetId, force = false) {
34
34
  const asset = this.data.find((v) => v.id === assetId);
35
- if (!asset?.deletedAt && !force) {
35
+ if (!(asset === null || asset === void 0 ? void 0 : asset.deletedAt) && !force) {
36
36
  asset.deletedAt = new Date().toISOString();
37
37
  return Promise.resolve(asset);
38
38
  }
@@ -48,31 +48,40 @@ class AssetMockService extends BaseService {
48
48
  const page = this.getAssets(params, false);
49
49
  return Promise.resolve(page);
50
50
  }
51
- async updateOne(assetId, dto) {
52
- await super.deleteOne(assetId);
53
- const asset = await this.addOne(dto);
54
- return Promise.resolve(asset);
51
+ updateOne(assetId, dto) {
52
+ const _super = Object.create(null, {
53
+ deleteOne: { get: () => super.deleteOne }
54
+ });
55
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
56
+ yield _super.deleteOne.call(this, assetId);
57
+ const asset = yield this.addOne(dto);
58
+ return Promise.resolve(asset);
59
+ });
55
60
  }
56
- async addAttachment(id, form) {
57
- const asset = this.data.find((v) => v.id === id);
58
- const content = await this.api.contents.upload(form);
59
- asset.attachments.push(content.id);
60
- return Promise.resolve(asset);
61
+ addAttachment(id, form) {
62
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
63
+ const asset = this.data.find((v) => v.id === id);
64
+ const content = yield this.api.contents.upload(form);
65
+ asset.attachments.push(content.id);
66
+ return Promise.resolve(asset);
67
+ });
61
68
  }
62
- async getAttachments(assetId) {
63
- const contents = await this.api.contents.getMany();
64
- const docs = contents.docs.filter((c) => c.assets?.includes?.(assetId));
65
- return { docs, total: docs.length, limit: 0 };
69
+ getAttachments(assetId) {
70
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
71
+ const contents = yield this.api.contents.getMany();
72
+ const docs = contents.docs.filter((c) => { var _a, _b; return (_b = (_a = c.assets) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, assetId); });
73
+ return { docs, total: docs.length, limit: 0 };
74
+ });
66
75
  }
67
76
  getChildren(assetId, params = {}) {
68
77
  return this.getManyFiltered({ parent: assetId }, params);
69
78
  }
70
79
  getEventLevelOverride(ids, causes) {
71
80
  const eventCausesAssets = this.data.filter((v) => v.name.startsWith('hpc-event-causes-'));
72
- return Promise.resolve(ids.reduce((acc, id) => ({
73
- ...acc,
74
- [id]: eventCausesAssets.find((v) => v.name.includes(id))?.data ?? {},
75
- }), {}));
81
+ return Promise.resolve(ids.reduce((acc, id) => {
82
+ var _a, _b;
83
+ return (Object.assign(Object.assign({}, acc), { [id]: (_b = (_a = eventCausesAssets.find((v) => v.name.includes(id))) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : {} }));
84
+ }, {}));
76
85
  }
77
86
  updateEventCausesAsset(id, dto) {
78
87
  const asset = this.data.find((v) => v.id === id);
@@ -23,12 +23,12 @@ class AssetTypesMockService extends BaseService {
23
23
  }
24
24
  addOne(dto) {
25
25
  const id = (0, crypto_1.randomUUID)();
26
- this.revisions.push({ ...dto, id, originalId: dto.id });
26
+ this.revisions.push(Object.assign(Object.assign({}, dto), { id, originalId: dto.id }));
27
27
  return super.addOne(dto);
28
28
  }
29
29
  deleteOne(id, force = false) {
30
30
  const assettype = this.data.find((v) => v.id === id);
31
- if (!assettype?.deletedAt && !force) {
31
+ if (!(assettype === null || assettype === void 0 ? void 0 : assettype.deletedAt) && !force) {
32
32
  assettype.deletedAt = new Date().toISOString();
33
33
  return Promise.resolve(assettype);
34
34
  }
@@ -40,10 +40,15 @@ class AssetTypesMockService extends BaseService {
40
40
  });
41
41
  return super.deleteOne(id);
42
42
  }
43
- async updateOne(id, dto) {
44
- await super.deleteOne(id);
45
- const assetType = await this.addOne(dto);
46
- return Promise.resolve(assetType);
43
+ updateOne(id, dto) {
44
+ const _super = Object.create(null, {
45
+ deleteOne: { get: () => super.deleteOne }
46
+ });
47
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
48
+ yield _super.deleteOne.call(this, id);
49
+ const assetType = yield this.addOne(dto);
50
+ return Promise.resolve(assetType);
51
+ });
47
52
  }
48
53
  getRevisions(id) {
49
54
  const revisions = this.revisions.filter((revision) => revision.originalId === id);
@@ -67,7 +67,7 @@ class ContentMockService extends BaseService {
67
67
  }
68
68
  deleteOne(contentId, force = false) {
69
69
  const content = this.data.find((v) => v.id === contentId);
70
- if (!content?.deletedAt && !force) {
70
+ if (!(content === null || content === void 0 ? void 0 : content.deletedAt) && !force) {
71
71
  content.deletedAt = new Date().toISOString();
72
72
  return Promise.resolve(content);
73
73
  }
@@ -1,15 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataMockService = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const data_service_1 = require("../data.service");
5
6
  class DataMockService extends data_service_1.DataService {
6
7
  constructor() {
7
8
  super(null, null);
8
9
  this.data = [];
9
10
  }
10
- async addMany(dto) {
11
- const map = dto.map((v) => this.addOne(v));
12
- return Promise.all(map);
11
+ addMany(dto) {
12
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
+ const map = dto.map((v) => this.addOne(v));
14
+ return Promise.all(map);
15
+ });
13
16
  }
14
17
  addOne(dto) {
15
18
  this.data.push(dto);
@@ -30,25 +33,29 @@ class DataMockService extends data_service_1.DataService {
30
33
  };
31
34
  return Promise.resolve(page);
32
35
  }
33
- async getManyFiltered(filter, params = {}) {
34
- const paginated = await this.getMany(params);
35
- const newData = paginated.docs.filter((v) => filter.parent === v.parent || filter.tags?.some((tag) => v.tags?.contains(tag)) || filter.type === v.tag);
36
- const page = {
37
- docs: newData,
38
- limit: paginated.limit || Number.MAX_SAFE_INTEGER,
39
- total: newData.length,
40
- };
41
- return Promise.resolve(page);
36
+ getManyFiltered(filter, params = {}) {
37
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
38
+ const paginated = yield this.getMany(params);
39
+ const newData = paginated.docs.filter((v) => { var _a; return filter.parent === v.parent || ((_a = filter.tags) === null || _a === void 0 ? void 0 : _a.some((tag) => { var _a; return (_a = v.tags) === null || _a === void 0 ? void 0 : _a.contains(tag); })) || filter.type === v.tag; });
40
+ const page = {
41
+ docs: newData,
42
+ limit: paginated.limit || Number.MAX_SAFE_INTEGER,
43
+ total: newData.length,
44
+ };
45
+ return Promise.resolve(page);
46
+ });
42
47
  }
43
48
  getOne(id, options = {}) {
44
49
  const idKey = options.idKey || 'id';
45
50
  const t = this.data.find((v) => v[idKey] === id);
46
51
  return Promise.resolve(t);
47
52
  }
48
- async updateOne(id, dto) {
49
- await this.deleteOne(id);
50
- const t = await this.addOne(dto);
51
- return Promise.resolve(t);
53
+ updateOne(id, dto) {
54
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
55
+ yield this.deleteOne(id);
56
+ const t = yield this.addOne(dto);
57
+ return Promise.resolve(t);
58
+ });
52
59
  }
53
60
  }
54
61
  exports.DataMockService = DataMockService;
@@ -25,19 +25,26 @@ class FlowDeploymentMockService extends BaseService {
25
25
  listener(new MessageEvent('message', { data: 'foo' }));
26
26
  return Promise.resolve((0, crypto_1.randomUUID)());
27
27
  }
28
- async waitForRunningStatus(id) {
29
- const flowDeployment = this.data.find((v) => v.id === id);
30
- flowDeployment.actualStatus = 'running';
28
+ waitForRunningStatus(id) {
29
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
30
+ const flowDeployment = this.data.find((v) => v.id === id);
31
+ flowDeployment.actualStatus = 'running';
32
+ });
31
33
  }
32
- async updateStatus(id, desiredStatus) {
33
- const deployment = await this.getOne(id);
34
- deployment.desiredStatus = desiredStatus;
35
- deployment.actualStatus = desiredStatus;
36
- return Promise.resolve(deployment);
34
+ updateStatus(id, desiredStatus) {
35
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
36
+ const deployment = yield this.getOne(id);
37
+ deployment.desiredStatus = desiredStatus;
38
+ deployment.actualStatus = desiredStatus;
39
+ return Promise.resolve(deployment);
40
+ });
37
41
  }
38
- async resolveReferences(id, recursive, types) {
39
- const depl = await this.getOne(id);
40
- return depl.refs ?? [];
42
+ resolveReferences(id, recursive, types) {
43
+ var _a;
44
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
45
+ const depl = yield this.getOne(id);
46
+ return (_a = depl.refs) !== null && _a !== void 0 ? _a : [];
47
+ });
41
48
  }
42
49
  getDeploymentStatistics(id) {
43
50
  return Promise.resolve({
@@ -64,58 +71,72 @@ class FlowDeploymentMockService extends BaseService {
64
71
  },
65
72
  });
66
73
  }
67
- async getDeploymentLogs(id) {
68
- const depl = await this.getOne(id);
69
- return Promise.resolve([
70
- {
71
- type: 'flow.log.info',
72
- deploymentId: id,
73
- subject: 'FlowApplication',
74
- data: 'Flow Deployment is running',
75
- '@timestamp': '2022-03-23T09:14:03.129Z',
76
- eventId: 'c68b7674-b8da-46c5-85f0-8e4279d74a78',
77
- datacontenttype: 'text/plain',
78
- elementId: 'none',
79
- time: '2022-03-23T09:14:03.129Z',
80
- flowId: depl.flow,
81
- },
82
- ]);
74
+ getDeploymentLogs(id) {
75
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
76
+ const depl = yield this.getOne(id);
77
+ return Promise.resolve([
78
+ {
79
+ type: 'flow.log.info',
80
+ deploymentId: id,
81
+ subject: 'FlowApplication',
82
+ data: 'Flow Deployment is running',
83
+ '@timestamp': '2022-03-23T09:14:03.129Z',
84
+ eventId: 'c68b7674-b8da-46c5-85f0-8e4279d74a78',
85
+ datacontenttype: 'text/plain',
86
+ elementId: 'none',
87
+ time: '2022-03-23T09:14:03.129Z',
88
+ flowId: depl.flow,
89
+ },
90
+ ]);
91
+ });
83
92
  }
84
- async addOne(dto) {
85
- const flow = await this.api.flows.getFlowWithDiagram(dto.diagramId);
86
- const refs = await this.getReferences(dto.properties);
87
- const id = (0, crypto_1.randomUUID)();
88
- const newDepl = {
89
- actualStatus: 'generating queued',
90
- artifact: undefined,
91
- desiredStatus: 'running',
92
- diagram: dto.diagramId,
93
- flow: flow.id,
94
- flowModel: { elements: [], connections: [], properties: dto.properties },
95
- id,
96
- name: dto.name,
97
- readPermissions: [],
98
- readWritePermissions: [],
99
- target: 'executor',
100
- refs,
101
- };
102
- await this.api.flows.updateOne(flow.id, { ...flow, deployments: [...flow.deployments, id] });
103
- return super.addOne(newDepl);
93
+ addOne(dto) {
94
+ const _super = Object.create(null, {
95
+ addOne: { get: () => super.addOne }
96
+ });
97
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
98
+ const flow = yield this.api.flows.getFlowWithDiagram(dto.diagramId);
99
+ const refs = yield this.getReferences(dto.properties);
100
+ const id = (0, crypto_1.randomUUID)();
101
+ const newDepl = {
102
+ actualStatus: 'generating queued',
103
+ artifact: undefined,
104
+ desiredStatus: 'running',
105
+ diagram: dto.diagramId,
106
+ flow: flow.id,
107
+ flowModel: { elements: [], connections: [], properties: dto.properties },
108
+ id,
109
+ name: dto.name,
110
+ readPermissions: [],
111
+ readWritePermissions: [],
112
+ target: 'executor',
113
+ refs,
114
+ };
115
+ yield this.api.flows.updateOne(flow.id, Object.assign(Object.assign({}, flow), { deployments: [...flow.deployments, id] }));
116
+ return _super.addOne.call(this, newDepl);
117
+ });
104
118
  }
105
- async deleteOne(id) {
106
- const depl = await this.getOne(id);
107
- const flow = await this.api.flows.getOne(depl.flow);
108
- const index = flow.deployments.findIndex((v) => v === id);
109
- flow.deployments.splice(index, 1);
110
- await this.api.flows.updateOne(flow.id, flow);
111
- return super.deleteOne(id);
119
+ deleteOne(id) {
120
+ const _super = Object.create(null, {
121
+ deleteOne: { get: () => super.deleteOne }
122
+ });
123
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
124
+ const depl = yield this.getOne(id);
125
+ const flow = yield this.api.flows.getOne(depl.flow);
126
+ const index = flow.deployments.findIndex((v) => v === id);
127
+ flow.deployments.splice(index, 1);
128
+ yield this.api.flows.updateOne(flow.id, flow);
129
+ return _super.deleteOne.call(this, id);
130
+ });
112
131
  }
113
- async getReferences(properties) {
114
- return Promise.all(Object.keys(properties).map(async (prop) => {
115
- if (prop !== 'assetId')
116
- throw new Error('not implemented');
117
- return { id: (await this.api.assets.getOne(properties[prop])).id, resourceType: 'asset' };
118
- }));
132
+ getReferences(properties) {
133
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
134
+ return Promise.all(Object.keys(properties).map((prop) => tslib_1.__awaiter(this, void 0, void 0, function* () {
135
+ if (prop !== 'assetId')
136
+ throw new Error('not implemented');
137
+ return { id: (yield this.api.assets.getOne(properties[prop])).id, resourceType: 'asset' };
138
+ })));
139
+ });
119
140
  }
120
141
  }
121
142
  exports.FlowDeploymentMockService = FlowDeploymentMockService;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlowFunctionsMockService = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const crypto_1 = require("crypto");
5
6
  const data_mock_service_1 = require("./data.mock.service");
6
7
  class FlowFunctionsMockService extends data_mock_service_1.DataMockService {
@@ -11,7 +12,7 @@ class FlowFunctionsMockService extends data_mock_service_1.DataMockService {
11
12
  }
12
13
  addOne(dto) {
13
14
  const id = (0, crypto_1.randomUUID)();
14
- this.revisions.push({ ...dto, id, originalId: dto.fqn });
15
+ this.revisions.push(Object.assign(Object.assign({}, dto), { id, originalId: dto.fqn }));
15
16
  return super.addOne(dto);
16
17
  }
17
18
  deleteOne(fqn) {
@@ -25,18 +26,22 @@ class FlowFunctionsMockService extends data_mock_service_1.DataMockService {
25
26
  });
26
27
  return Promise.resolve(undefined);
27
28
  }
28
- async updateOne(fqn, dto) {
29
- const index = this.data.findIndex((v) => v.fqn === fqn);
30
- this.data.splice(index, 1);
31
- const flowFunction = await this.addOne(dto);
32
- return Promise.resolve(flowFunction);
29
+ updateOne(fqn, dto) {
30
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
31
+ const index = this.data.findIndex((v) => v.fqn === fqn);
32
+ this.data.splice(index, 1);
33
+ const flowFunction = yield this.addOne(dto);
34
+ return Promise.resolve(flowFunction);
35
+ });
33
36
  }
34
37
  getOne(fqn, options) {
35
38
  const t = this.data.find((v) => v.fqn === fqn);
36
39
  return Promise.resolve(t);
37
40
  }
38
- async getOneById(id) {
39
- return this.data.find((v) => v.id === id);
41
+ getOneById(id) {
42
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
43
+ return this.data.find((v) => v.id === id);
44
+ });
40
45
  }
41
46
  getRevisions(fqn) {
42
47
  const revisions = this.revisions.filter((revision) => revision.originalId === fqn);
@@ -1,17 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlowModulesMockService = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const data_mock_service_1 = require("./data.mock.service");
5
6
  class FlowModulesMockService extends data_mock_service_1.DataMockService {
6
7
  constructor(modules) {
7
8
  super();
8
9
  this.data = modules;
9
10
  }
10
- async deleteArtifact(name, version) {
11
- const module = await this.getOne(name);
12
- const index = module.artifacts.findIndex((art) => art.version === version);
13
- module.artifacts.splice(index, 1);
14
- return Promise.resolve(module);
11
+ deleteArtifact(name, version) {
12
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
+ const module = yield 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
+ });
15
18
  }
16
19
  publish(form) {
17
20
  return Promise.resolve(undefined);
@@ -20,7 +20,7 @@ class FlowMockService extends BaseService {
20
20
  }
21
21
  deleteOne(id, force = false) {
22
22
  const flow = this.data.find((v) => v.id === id);
23
- if (!flow?.deletedAt && !force) {
23
+ if (!(flow === null || flow === void 0 ? void 0 : flow.deletedAt) && !force) {
24
24
  flow.deletedAt = new Date().toISOString();
25
25
  return Promise.resolve(flow);
26
26
  }
@@ -34,19 +34,26 @@ class FlowMockService extends BaseService {
34
34
  }
35
35
  addOne(dto) {
36
36
  const id = (0, crypto_1.randomUUID)();
37
- this.revisions.push({ ...dto, id, originalId: dto.id });
37
+ this.revisions.push(Object.assign(Object.assign({}, dto), { id, originalId: dto.id }));
38
38
  return super.addOne(dto);
39
39
  }
40
- async updateOne(id, dto) {
41
- await super.deleteOne(id);
42
- const flow = await this.addOne(dto);
43
- return Promise.resolve(flow);
40
+ updateOne(id, dto) {
41
+ const _super = Object.create(null, {
42
+ deleteOne: { get: () => super.deleteOne }
43
+ });
44
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
45
+ yield _super.deleteOne.call(this, id);
46
+ const flow = yield this.addOne(dto);
47
+ return Promise.resolve(flow);
48
+ });
44
49
  }
45
- async isDeploymentOnLatestDiagramVersion(depl) {
46
- const flowId = typeof depl.flow === 'string' ? depl.flow : depl.flow.id;
47
- const diagramId = typeof depl.diagram === 'string' ? depl.diagram : depl.diagram.id;
48
- const revisions = await this.getDiagramRevisions(flowId);
49
- return revisions[revisions.length - 1].id === diagramId;
50
+ isDeploymentOnLatestDiagramVersion(depl) {
51
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
52
+ const flowId = typeof depl.flow === 'string' ? depl.flow : depl.flow.id;
53
+ const diagramId = typeof depl.diagram === 'string' ? depl.diagram : depl.diagram.id;
54
+ const revisions = yield this.getDiagramRevisions(flowId);
55
+ return revisions[revisions.length - 1].id === diagramId;
56
+ });
50
57
  }
51
58
  getDiagramRevisions(id) {
52
59
  return Promise.resolve(this.diagrams.filter((v) => v.flow === id));
@@ -54,13 +61,15 @@ class FlowMockService extends BaseService {
54
61
  getFlowWithDiagram(diagramId) {
55
62
  return Promise.resolve(this.data.find((v1) => v1.id === this.diagrams.find((v) => v.id === diagramId).flow));
56
63
  }
57
- async getMany(params) {
58
- const flows = this.getItems(params, false);
59
- return {
60
- docs: flows.docs.map((v) => ({ ...v, diagram: this.diagrams.find((v1) => v1.id === v.diagram) })),
61
- total: 0,
62
- limit: 0,
63
- };
64
+ getMany(params) {
65
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
66
+ const flows = this.getItems(params, false);
67
+ return {
68
+ docs: flows.docs.map((v) => (Object.assign(Object.assign({}, v), { diagram: this.diagrams.find((v1) => v1.id === v.diagram) }))),
69
+ total: 0,
70
+ limit: 0,
71
+ };
72
+ });
64
73
  }
65
74
  getRevisions(id) {
66
75
  const revisions = this.revisions.filter((revision) => revision.originalId === id);
@@ -17,7 +17,7 @@ class SecretMockService extends BaseService {
17
17
  }
18
18
  deleteOne(contentId, force = false) {
19
19
  const content = this.data.find((v) => v.id === contentId);
20
- if (!content?.deletedAt && !force) {
20
+ if (!(content === null || content === void 0 ? void 0 : content.deletedAt) && !force) {
21
21
  content.deletedAt = new Date().toISOString();
22
22
  return Promise.resolve(content);
23
23
  }
@@ -15,13 +15,15 @@ class TaskMockService extends BaseService {
15
15
  constructor(tasks) {
16
16
  super(tasks);
17
17
  }
18
- async createTaskAttachedToAsset(dto) {
19
- this.data.push(dto);
20
- return Promise.resolve(dto);
18
+ createTaskAttachedToAsset(dto) {
19
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
+ this.data.push(dto);
21
+ return Promise.resolve(dto);
22
+ });
21
23
  }
22
24
  deleteOne(taskId, force = false) {
23
25
  const task = this.data.find((v) => v.id === taskId);
24
- if (!task?.deletedAt && !force) {
26
+ if (!(task === null || task === void 0 ? void 0 : task.deletedAt) && !force) {
25
27
  task.deletedAt = new Date().toISOString();
26
28
  return Promise.resolve(task);
27
29
  }
@@ -13,12 +13,12 @@ BaseService = tslib_1.__decorate([
13
13
  ], BaseService);
14
14
  class TimeseriesMockService extends BaseService {
15
15
  constructor(timeseries, timeseriesValues) {
16
- const data = timeseries.map((value, index) => ({ ...value, data: timeseriesValues[index] }));
16
+ const data = timeseries.map((value, index) => (Object.assign(Object.assign({}, value), { data: timeseriesValues[index] })));
17
17
  super(data);
18
18
  }
19
19
  deleteOne(tsmId, force = false) {
20
20
  const tsm = this.data.find((v) => v.id === tsmId);
21
- if (!tsm?.deletedAt && !force) {
21
+ if (!(tsm === null || tsm === void 0 ? void 0 : tsm.deletedAt) && !force) {
22
22
  tsm.deletedAt = new Date().toISOString();
23
23
  return Promise.resolve(tsm);
24
24
  }
@@ -32,7 +32,7 @@ class TimeseriesMockService extends BaseService {
32
32
  const ts = this.data.find((v) => v.assetRef === assetId);
33
33
  const data = Object.entries(values).map(([timestamp, value]) => {
34
34
  if (value !== null && typeof value === 'object') {
35
- return { timestamp, ...value };
35
+ return Object.assign({ timestamp }, value);
36
36
  }
37
37
  else {
38
38
  return { timestamp, value };
@@ -56,16 +56,18 @@ class TimeseriesMockService extends BaseService {
56
56
  ts.data = ts.data ? [...ts.data, ...data] : data;
57
57
  return Promise.resolve(ts);
58
58
  }
59
- async addValue(id, value) {
60
- const ts = await this.getOne(id, {});
61
- for (const [timestamp, v] of Object.entries(value)) {
62
- if (v !== null && typeof v === 'object') {
63
- ts.data.push({ timestamp, ...v });
59
+ addValue(id, value) {
60
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
61
+ const ts = yield this.getOne(id, {});
62
+ for (const [timestamp, v] of Object.entries(value)) {
63
+ if (v !== null && typeof v === 'object') {
64
+ ts.data.push(Object.assign({ timestamp }, v));
65
+ }
66
+ else {
67
+ ts.data.push({ timestamp: parseInt(timestamp, 10), value: v });
68
+ }
64
69
  }
65
- else {
66
- ts.data.push({ timestamp: parseInt(timestamp, 10), value: v });
67
- }
68
- }
70
+ });
69
71
  }
70
72
  getManyByAsset(assetId, names) {
71
73
  const page = { docs: [], limit: 10, total: 0 };
@@ -80,24 +82,30 @@ class TimeseriesMockService extends BaseService {
80
82
  page.total = page.docs.length;
81
83
  return Promise.resolve(page);
82
84
  }
83
- async getMostRecentValue(id, before) {
84
- const ts = await this.getOne(id, {});
85
- for (const datum of ts.data) {
86
- if (datum.timestamp < before.valueOf()) {
87
- return datum;
85
+ getMostRecentValue(id, before) {
86
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
87
+ const ts = yield this.getOne(id, {});
88
+ for (const datum of ts.data) {
89
+ if (datum.timestamp < before.valueOf()) {
90
+ return datum;
91
+ }
88
92
  }
89
- }
93
+ });
90
94
  }
91
- async getValues(id, from, limit, group) {
92
- let timeSeriesValues = await this.getValuesOfPeriod(id, from, new Date().valueOf(), group);
93
- if (limit) {
94
- timeSeriesValues = timeSeriesValues.slice(0, limit);
95
- }
96
- return timeSeriesValues;
95
+ getValues(id, from, limit, group) {
96
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
97
+ let timeSeriesValues = yield this.getValuesOfPeriod(id, from, new Date().valueOf(), group);
98
+ if (limit) {
99
+ timeSeriesValues = timeSeriesValues.slice(0, limit);
100
+ }
101
+ return timeSeriesValues;
102
+ });
97
103
  }
98
- async getValuesOfPeriod(id, from, to, group) {
99
- const ts = await this.getOne(id, {});
100
- return ts.data.filter((v) => v.timestamp < to && v.timestamp > from);
104
+ getValuesOfPeriod(id, from, to, group) {
105
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
106
+ const ts = yield this.getOne(id, {});
107
+ return ts.data.filter((v) => v.timestamp < to && v.timestamp > from);
108
+ });
101
109
  }
102
110
  }
103
111
  exports.TimeseriesMockService = TimeseriesMockService;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TrashMockService = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const trash_service_1 = require("../trash.service");
5
6
  class TrashMockService extends trash_service_1.TrashService {
6
7
  constructor() {
@@ -19,12 +20,14 @@ class TrashMockService extends trash_service_1.TrashService {
19
20
  delete deleted['deletedAt'];
20
21
  return Promise.resolve(deleted);
21
22
  }
22
- async emptyTrash(offset) {
23
- const dateOffsSeconds = Math.round(new Date().getTime() / 1000) - offset;
24
- const date = new Date(dateOffsSeconds * 1000);
25
- const trashIds = this.data.filter((v) => new Date(v['deletedAt']) < date).map((v) => v.id);
26
- this.data = this.data.filter((item) => !trashIds.includes(item.id));
27
- return Promise.resolve({ acknowledged: true, deletedCount: trashIds.length });
23
+ emptyTrash(offset) {
24
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
25
+ const dateOffsSeconds = Math.round(new Date().getTime() / 1000) - offset;
26
+ const date = new Date(dateOffsSeconds * 1000);
27
+ const trashIds = this.data.filter((v) => new Date(v['deletedAt']) < date).map((v) => v.id);
28
+ this.data = this.data.filter((item) => !trashIds.includes(item.id));
29
+ return Promise.resolve({ acknowledged: true, deletedCount: trashIds.length });
30
+ });
28
31
  }
29
32
  getTrash(params) {
30
33
  const page = this.getItems(params, true);
@@ -16,7 +16,7 @@ export declare class TimeSeriesService extends BaseService {
16
16
  addAssetTimeSeriesValues(assetId: string, name: string, readPermissions: string[], readWritePermissions: string[], values: {
17
17
  [timestamp: string]: any;
18
18
  }): Promise<TimeSeries>;
19
- getMostRecentValue(id: string, before: Date): Promise<TimeSeriesValue>;
19
+ getMostRecentValue(id: string, before?: Date): Promise<TimeSeriesValue>;
20
20
  getValues(id: string, from: number, limit?: number, group?: TS_GROUPS): Promise<TimeSeriesValue[]>;
21
21
  getValuesOfPeriod(id: string, from: number, to: number, group?: TS_GROUPS): Promise<TimeSeriesValue[]>;
22
22
  getManyByAsset(assetId: string, names?: string[]): Promise<Paginated<TimeSeries[]>>;
@@ -8,15 +8,17 @@ class UserService {
8
8
  this.httpClient = httpClient;
9
9
  this.basePath = '/user';
10
10
  }
11
- async getCurrentUserRoles() {
12
- try {
13
- const token = await this.httpClient.getAccessToken();
14
- const decode = (0, jwt_decode_1.default)(token);
15
- return decode.realm_access.roles;
16
- }
17
- catch (err) {
18
- return null;
19
- }
11
+ getCurrentUserRoles() {
12
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
+ try {
14
+ const token = yield this.httpClient.getAccessToken();
15
+ const decode = (0, jwt_decode_1.default)(token);
16
+ return decode.realm_access.roles;
17
+ }
18
+ catch (err) {
19
+ return null;
20
+ }
21
+ });
20
22
  }
21
23
  getUserSettings() {
22
24
  return this.httpClient.get(this.basePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hahnpro/hpc-api",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "description": "Module for easy access to the HahnPRO API",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -24,7 +24,7 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "axios": "~1.4.0",
27
+ "axios": "~1.5.0",
28
28
  "eventsource": "^2.0.2",
29
29
  "form-data": "^4.0.0",
30
30
  "jose": "^4.14.4",