@hahnpro/hpc-api 1.0.3 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/asset.interface.d.ts +27 -18
- package/dist/asset.service.d.ts +2 -1
- package/dist/asset.service.js +3 -0
- package/dist/endpoint.interface.d.ts +13 -3
- package/dist/endpoint.service.d.ts +2 -2
- package/dist/endpoint.service.js +2 -3
- package/dist/mock/api.mock.d.ts +3 -1
- package/dist/mock/api.mock.js +6 -5
- package/dist/mock/asset.mock.service.d.ts +4 -2
- package/dist/mock/asset.mock.service.js +12 -1
- package/dist/mock/endpoint.mock.service.d.ts +2 -2
- package/dist/mock/endpoint.mock.service.js +1 -1
- package/package.json +3 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Hahn PRO
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,34 +1,43 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface AssetType {
|
|
2
2
|
id?: string;
|
|
3
3
|
name: string;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
tags?: string[];
|
|
5
|
+
allowedParents?: string[];
|
|
6
|
+
allowedParent$name?: string;
|
|
6
7
|
readPermissions: string[];
|
|
7
8
|
readWritePermissions: string[];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
attachments?: string[];
|
|
13
|
-
image?: string;
|
|
9
|
+
supertype?: string;
|
|
10
|
+
supertype$name?: string;
|
|
11
|
+
typeSchema: any;
|
|
12
|
+
uiSchema: any;
|
|
14
13
|
actions?: string[];
|
|
15
|
-
notificationEndpoints?: string[];
|
|
16
14
|
createdAt?: string;
|
|
17
15
|
updatedAt?: string;
|
|
18
16
|
}
|
|
19
|
-
export interface
|
|
17
|
+
export interface AssetParent {
|
|
20
18
|
id?: string;
|
|
21
19
|
name: string;
|
|
22
|
-
|
|
23
|
-
allowedParent?: string;
|
|
24
|
-
allowedParent$name?: string;
|
|
20
|
+
type: string | AssetType;
|
|
25
21
|
readPermissions: string[];
|
|
26
22
|
readWritePermissions: string[];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
parent?: any | Asset;
|
|
24
|
+
ancestors?: string[];
|
|
25
|
+
tags?: string[];
|
|
26
|
+
relations?: any[];
|
|
27
|
+
data?: any;
|
|
28
|
+
image?: string;
|
|
29
|
+
author?: string;
|
|
30
|
+
revision?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface Asset extends AssetParent {
|
|
33
|
+
type$name?: string;
|
|
34
|
+
parent$name?: string;
|
|
35
|
+
attachments?: string[];
|
|
36
|
+
notificationEndpoints?: string[];
|
|
31
37
|
actions?: string[];
|
|
38
|
+
}
|
|
39
|
+
export interface AssetRevision extends AssetParent {
|
|
40
|
+
originalId?: string;
|
|
32
41
|
createdAt?: string;
|
|
33
42
|
updatedAt?: string;
|
|
34
43
|
}
|
package/dist/asset.service.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import FormData from 'form-data';
|
|
2
|
-
import { Asset } from './asset.interface';
|
|
2
|
+
import { Asset, AssetRevision } from './asset.interface';
|
|
3
3
|
import { Paginated, RequestParameter } from './data.interface';
|
|
4
4
|
import { DataService } from './data.service';
|
|
5
5
|
import { HttpClient } from './http.service';
|
|
@@ -7,4 +7,5 @@ export declare class AssetService extends DataService<Asset> {
|
|
|
7
7
|
constructor(httpClient: HttpClient);
|
|
8
8
|
addAttachment: (id: string, form: FormData) => Promise<Asset>;
|
|
9
9
|
getChildren(assetId: string, params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
10
|
+
findRevisions(assetId: string): Promise<Paginated<AssetRevision[]>>;
|
|
10
11
|
}
|
package/dist/asset.service.js
CHANGED
|
@@ -17,5 +17,8 @@ class AssetService extends data_service_1.DataService {
|
|
|
17
17
|
getChildren(assetId, params = {}) {
|
|
18
18
|
return this.getManyFiltered({ parent: assetId }, params);
|
|
19
19
|
}
|
|
20
|
+
findRevisions(assetId) {
|
|
21
|
+
return this.httpClient.get(`${this.basePath}/${assetId}/revisions`);
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
exports.AssetService = AssetService;
|
|
@@ -9,9 +9,9 @@ export interface Endpoint {
|
|
|
9
9
|
authToken: string;
|
|
10
10
|
recipients?: string[];
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
notificationCheckInterval: number;
|
|
13
|
+
notificationPauseInterval: number;
|
|
14
|
+
nbOfNotificationsBetweenPauseInterval: number;
|
|
15
15
|
readPermissions: string[];
|
|
16
16
|
readWritePermissions: string[];
|
|
17
17
|
}
|
|
@@ -23,3 +23,13 @@ export interface EndpointLog {
|
|
|
23
23
|
group?: string;
|
|
24
24
|
updatedAt?: string;
|
|
25
25
|
}
|
|
26
|
+
export interface NotificationPayload {
|
|
27
|
+
subject: string;
|
|
28
|
+
message: string;
|
|
29
|
+
group?: string;
|
|
30
|
+
level?: string;
|
|
31
|
+
eventLink?: string;
|
|
32
|
+
assetId?: string;
|
|
33
|
+
assetName?: string;
|
|
34
|
+
assetLink?: string;
|
|
35
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HttpClient } from './http.service';
|
|
2
2
|
import { DataService } from './data.service';
|
|
3
|
-
import { Endpoint, EndpointLog } from './endpoint.interface';
|
|
3
|
+
import { Endpoint, NotificationPayload, EndpointLog } from './endpoint.interface';
|
|
4
4
|
export declare class EndpointService extends DataService<Endpoint> {
|
|
5
5
|
constructor(httpClient: HttpClient);
|
|
6
|
-
sendNotification(endpointId: string,
|
|
6
|
+
sendNotification(endpointId: string, payload: NotificationPayload): Promise<void>;
|
|
7
7
|
readLastLogByGroup(endpointId: string, group: string): Promise<EndpointLog>;
|
|
8
8
|
}
|
package/dist/endpoint.service.js
CHANGED
|
@@ -6,9 +6,8 @@ class EndpointService extends data_service_1.DataService {
|
|
|
6
6
|
constructor(httpClient) {
|
|
7
7
|
super(httpClient, '/notification/endpoints');
|
|
8
8
|
}
|
|
9
|
-
sendNotification(endpointId,
|
|
10
|
-
|
|
11
|
-
return this.httpClient.post(`${this.basePath}/${endpointId}`, body);
|
|
9
|
+
sendNotification(endpointId, payload) {
|
|
10
|
+
return this.httpClient.post(`${this.basePath}/${endpointId}`, payload);
|
|
12
11
|
}
|
|
13
12
|
readLastLogByGroup(endpointId, group) {
|
|
14
13
|
return this.httpClient.get(`${this.basePath}/${endpointId}/logs/${group}/last`);
|
package/dist/mock/api.mock.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { API } from '../api';
|
|
2
|
-
import { Asset, AssetType } from '../asset.interface';
|
|
2
|
+
import { Asset, AssetRevision, AssetType } from '../asset.interface';
|
|
3
3
|
import { Content } from '../content.interface';
|
|
4
4
|
import { Secret } from '../secret.interface';
|
|
5
5
|
import { TimeSeries, TimeSeriesValue } from '../timeseries.interface';
|
|
@@ -38,6 +38,7 @@ export declare class MockAPI implements API {
|
|
|
38
38
|
userManager: UserMockService;
|
|
39
39
|
constructor(initData: {
|
|
40
40
|
assets?: AssetInit[];
|
|
41
|
+
revisions?: AssetRevisionInit[];
|
|
41
42
|
contents?: ContentInit[];
|
|
42
43
|
endpoints?: EndpointInit[];
|
|
43
44
|
secrets?: SecretInit[];
|
|
@@ -55,6 +56,7 @@ export declare type Replace<T, K extends keyof T, TReplace> = Identity<Pick<T, E
|
|
|
55
56
|
[P in K]: TReplace;
|
|
56
57
|
}>;
|
|
57
58
|
export declare type AssetInit = Replace<AtLeast<Asset, 'id' | 'name' | 'type'>, 'type', AssetTypeInit | string>;
|
|
59
|
+
export declare type AssetRevisionInit = Replace<AtLeast<AssetRevision, 'id' | 'name' | 'type'>, 'type', AssetTypeInit | string>;
|
|
58
60
|
export declare type AssetTypeInit = AtLeast<AssetType, 'id' | 'name'>;
|
|
59
61
|
export declare type ContentInit = Identity<AtLeast<Content, 'id' | 'filename'> & {
|
|
60
62
|
filePath?: string;
|
package/dist/mock/api.mock.js
CHANGED
|
@@ -16,7 +16,7 @@ class MockAPI {
|
|
|
16
16
|
this.httpClient = null;
|
|
17
17
|
this.proxy = null;
|
|
18
18
|
this.siDrive = null;
|
|
19
|
-
const { assets = [], contents = [], endpoints = [], secrets = [], timeSeries = [], tasks = [], events = [], users } = initData;
|
|
19
|
+
const { assets = [], revisions = [], contents = [], endpoints = [], secrets = [], timeSeries = [], tasks = [], events = [], users, } = initData;
|
|
20
20
|
const assetTypes = assets
|
|
21
21
|
.map((v) => v.type)
|
|
22
22
|
.map((v) => {
|
|
@@ -32,6 +32,7 @@ class MockAPI {
|
|
|
32
32
|
};
|
|
33
33
|
});
|
|
34
34
|
const assets1 = assets.map((v, index) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], type: assetTypes[index] })));
|
|
35
|
+
const revisions1 = revisions.map((v, index) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], type: assetTypes[index] })));
|
|
35
36
|
const contents1 = contents.map((v) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], size: 0, fileId: '', mimetype: v.mimetype || '' })));
|
|
36
37
|
const contentData = contents.map((v) => {
|
|
37
38
|
return v.data ? v.data : (0, fs_1.readFileSync)((0, path_1.join)(v.filePath, v.filename));
|
|
@@ -58,9 +59,9 @@ class MockAPI {
|
|
|
58
59
|
description: value.description,
|
|
59
60
|
status: value.status,
|
|
60
61
|
config: value.config,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
notificationCheckInterval: value.notificationCheckInterval,
|
|
63
|
+
notificationPauseInterval: value.notificationPauseInterval,
|
|
64
|
+
nbOfNotificationsBetweenPauseInterval: value.nbOfNotificationsBetweenPauseInterval,
|
|
64
65
|
readPermissions: [],
|
|
65
66
|
readWritePermissions: [],
|
|
66
67
|
}));
|
|
@@ -90,7 +91,7 @@ class MockAPI {
|
|
|
90
91
|
group: v.group,
|
|
91
92
|
}));
|
|
92
93
|
const timeseriesValues = timeSeries.map((v) => v.values);
|
|
93
|
-
this.assets = new asset_mock_service_1.AssetMockService(this, assets1);
|
|
94
|
+
this.assets = new asset_mock_service_1.AssetMockService(this, assets1, revisions1);
|
|
94
95
|
this.contents = new content_mock_service_1.ContentMockService(contents1, contentData);
|
|
95
96
|
this.endpoints = new endpoint_mock_service_1.EndpointMockService(endpoint1);
|
|
96
97
|
this.secrets = new secret_mock_service_1.SecretMockService(secrets1);
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import FormData from 'form-data';
|
|
2
|
-
import { Asset } from '../asset.interface';
|
|
2
|
+
import { Asset, AssetRevision } from '../asset.interface';
|
|
3
3
|
import { AssetService } from '../asset.service';
|
|
4
4
|
import { Paginated, RequestParameter } from '../data.interface';
|
|
5
5
|
import { MockAPI } from './api.mock';
|
|
6
6
|
import { DataMockService } from './data.mock.service';
|
|
7
7
|
export declare class AssetMockService extends DataMockService<Asset> implements AssetService {
|
|
8
8
|
private api;
|
|
9
|
-
|
|
9
|
+
private revisions;
|
|
10
|
+
constructor(api: MockAPI, assets: Asset[], revisions: AssetRevision[]);
|
|
10
11
|
addAttachment(id: string, form: FormData): Promise<Asset>;
|
|
11
12
|
getChildren(assetId: string, params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
13
|
+
findRevisions(assetId: string): Promise<Paginated<AssetRevision[]>>;
|
|
12
14
|
}
|
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AssetMockService = void 0;
|
|
4
4
|
const data_mock_service_1 = require("./data.mock.service");
|
|
5
5
|
class AssetMockService extends data_mock_service_1.DataMockService {
|
|
6
|
-
constructor(api, assets) {
|
|
6
|
+
constructor(api, assets, revisions) {
|
|
7
7
|
super();
|
|
8
8
|
this.api = api;
|
|
9
|
+
this.revisions = [];
|
|
9
10
|
this.data = assets;
|
|
11
|
+
this.revisions = revisions;
|
|
10
12
|
}
|
|
11
13
|
async addAttachment(id, form) {
|
|
12
14
|
const asset = this.data.find((v) => v.id === id);
|
|
@@ -17,5 +19,14 @@ class AssetMockService extends data_mock_service_1.DataMockService {
|
|
|
17
19
|
getChildren(assetId, params = {}) {
|
|
18
20
|
return this.getManyFiltered({ parent: assetId }, params);
|
|
19
21
|
}
|
|
22
|
+
findRevisions(assetId) {
|
|
23
|
+
const newData = this.revisions.filter((revision) => revision.originalId === assetId);
|
|
24
|
+
const page = {
|
|
25
|
+
docs: newData,
|
|
26
|
+
limit: Number.MAX_SAFE_INTEGER,
|
|
27
|
+
total: newData.length,
|
|
28
|
+
};
|
|
29
|
+
return Promise.resolve(page);
|
|
30
|
+
}
|
|
20
31
|
}
|
|
21
32
|
exports.AssetMockService = AssetMockService;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Endpoint } from '../endpoint.interface';
|
|
1
|
+
import { Endpoint, NotificationPayload } from '../endpoint.interface';
|
|
2
2
|
import { EndpointService } from '../endpoint.service';
|
|
3
3
|
import { DataMockService } from './data.mock.service';
|
|
4
4
|
export declare class EndpointMockService extends DataMockService<Endpoint> implements EndpointService {
|
|
5
5
|
constructor(endpoints: Endpoint[]);
|
|
6
|
-
sendNotification(endpointId: string,
|
|
6
|
+
sendNotification(endpointId: string, payload: NotificationPayload): Promise<void>;
|
|
7
7
|
readLastLogByGroup(endpointId: string, group: string): Promise<{
|
|
8
8
|
id: string;
|
|
9
9
|
endpoint: string;
|
|
@@ -7,7 +7,7 @@ class EndpointMockService extends data_mock_service_1.DataMockService {
|
|
|
7
7
|
super();
|
|
8
8
|
this.data = endpoints;
|
|
9
9
|
}
|
|
10
|
-
sendNotification(endpointId,
|
|
10
|
+
sendNotification(endpointId, payload) {
|
|
11
11
|
return Promise.resolve();
|
|
12
12
|
}
|
|
13
13
|
readLastLogByGroup(endpointId, group) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hahnpro/hpc-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Module for easy access to the HahnPRO API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "git@
|
|
12
|
+
"url": "git@github.com:hahnprojects/flow.git"
|
|
13
13
|
},
|
|
14
14
|
"directories": {
|
|
15
15
|
"lib": "lib",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"axios": "^0.
|
|
27
|
+
"axios": "^0.25.0",
|
|
28
28
|
"form-data": "^4.0.0",
|
|
29
29
|
"jwt-decode": "^3.1.2",
|
|
30
30
|
"p-queue": "^6.6.2"
|