@hahnpro/hpc-api 3.6.5 → 3.6.7
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.
|
@@ -21,10 +21,10 @@ export declare class TimeseriesMockService extends BaseService implements TimeSe
|
|
|
21
21
|
data: TimeSeriesValue[];
|
|
22
22
|
})[]>>;
|
|
23
23
|
addAssetTimeSeriesValues(assetId: string, name: string, readPermissions: string[], readWritePermissions: string[], values: {
|
|
24
|
-
[
|
|
24
|
+
[timestamp: string]: any;
|
|
25
25
|
}): Promise<TimeSeries>;
|
|
26
26
|
addValue(id: string, value: {
|
|
27
|
-
[
|
|
27
|
+
[timestamp: string]: any;
|
|
28
28
|
}): Promise<void>;
|
|
29
29
|
getManyByAsset(assetId: string, names?: string[]): Promise<Paginated<TimeSeries[]>>;
|
|
30
30
|
getMostRecentValue(id: string, before: Date): Promise<TimeSeriesValue>;
|
|
@@ -30,8 +30,15 @@ class TimeseriesMockService extends BaseService {
|
|
|
30
30
|
}
|
|
31
31
|
addAssetTimeSeriesValues(assetId, name, readPermissions, readWritePermissions, values) {
|
|
32
32
|
const ts = this.data.find((v) => v.assetRef === assetId);
|
|
33
|
+
const data = Object.entries(values).map(([timestamp, value]) => {
|
|
34
|
+
if (value !== null && typeof value === 'object') {
|
|
35
|
+
return Object.assign({ timestamp }, value);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return { timestamp, value };
|
|
39
|
+
}
|
|
40
|
+
});
|
|
33
41
|
if (!ts) {
|
|
34
|
-
const data = values.map((v) => (Object.assign({ timestamp: Date.now() }, v)));
|
|
35
42
|
const dto = {
|
|
36
43
|
autoDelBucket: undefined,
|
|
37
44
|
autoDelData: undefined,
|
|
@@ -46,12 +53,19 @@ class TimeseriesMockService extends BaseService {
|
|
|
46
53
|
};
|
|
47
54
|
return this.addOne(dto);
|
|
48
55
|
}
|
|
49
|
-
ts.data =
|
|
56
|
+
ts.data = [...ts.data, ...data];
|
|
50
57
|
return Promise.resolve(ts);
|
|
51
58
|
}
|
|
52
59
|
async addValue(id, value) {
|
|
53
60
|
const ts = await this.getOne(id, {});
|
|
54
|
-
|
|
61
|
+
for (const [timestamp, v] of Object.entries(value)) {
|
|
62
|
+
if (v !== null && typeof v === 'object') {
|
|
63
|
+
ts.data.push(Object.assign({ timestamp }, v));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
ts.data.push({ timestamp: parseInt(timestamp, 10), value: v });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
55
69
|
}
|
|
56
70
|
getManyByAsset(assetId, names) {
|
|
57
71
|
const page = { docs: [], limit: 10, total: 0 };
|
|
@@ -11,7 +11,7 @@ declare class BaseService extends APIBase {
|
|
|
11
11
|
export declare class TimeSeriesService extends BaseService {
|
|
12
12
|
constructor(httpClient: HttpClient);
|
|
13
13
|
addValue(id: string, value: {
|
|
14
|
-
[
|
|
14
|
+
[timestamp: string]: any;
|
|
15
15
|
}): Promise<void>;
|
|
16
16
|
addAssetTimeSeriesValues(assetId: string, name: string, readPermissions: string[], readWritePermissions: string[], values: {
|
|
17
17
|
[timestamp: string]: any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hahnpro/hpc-api",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.7",
|
|
4
4
|
"description": "Module for easy access to the HahnPRO API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -24,17 +24,17 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"axios": "~1.
|
|
27
|
+
"axios": "~1.3.3",
|
|
28
28
|
"eventsource": "^2.0.2",
|
|
29
29
|
"form-data": "^4.0.0",
|
|
30
|
-
"jose": "^4.11.
|
|
30
|
+
"jose": "^4.11.4",
|
|
31
31
|
"jwt-decode": "^3.1.2",
|
|
32
32
|
"p-queue": "^6.6.2",
|
|
33
|
-
"ts-mixer": "^6.0.
|
|
33
|
+
"ts-mixer": "^6.0.3",
|
|
34
34
|
"uuid": "^9.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/eventsource": "
|
|
37
|
+
"@types/eventsource": "1.1.10",
|
|
38
38
|
"axios-mock-adapter": "^1.21.2"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|