@xube/kit-aws-hooks 0.0.56 → 0.0.58
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/dist/transform.js +2 -2
- package/package.json +8 -8
- package/src/transform.test.ts +17 -13
- package/src/transform.ts +2 -2
package/dist/transform.js
CHANGED
|
@@ -36,7 +36,7 @@ const getTimeSeriesDataFromData = (items, log = kit_log_1.XubeLog.getInstance())
|
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
38
|
const timeSeriesEntry = timeSeriesEntriesById[item.id];
|
|
39
|
-
const timeDifference = Math.
|
|
39
|
+
const timeDifference = Math.round((microsSinceEpoch - previousMicroSecondsSinceEpochById?.[item.id]) /
|
|
40
40
|
getDivisorByTimeUnit(timeSeriesEntry.dtt));
|
|
41
41
|
timeSeriesEntry.data.push(item.data);
|
|
42
42
|
if (timeSeriesEntry.dt === 0) {
|
|
@@ -86,7 +86,7 @@ function microsecondsSinceEpoch(s, us) {
|
|
|
86
86
|
return s * 1000000 + us;
|
|
87
87
|
}
|
|
88
88
|
function isoDateTimeWithMicroseconds(microsecondsSinceEpoch) {
|
|
89
|
-
const milliseconds = Math.
|
|
89
|
+
const milliseconds = Math.round(microsecondsSinceEpoch / 1000);
|
|
90
90
|
const microseconds = microsecondsSinceEpoch % 1000;
|
|
91
91
|
const date = new Date(milliseconds);
|
|
92
92
|
const year = date.getUTCFullYear();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xube/kit-aws-hooks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.58",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
},
|
|
18
18
|
"homepage": "https://github.com/XubeLtd/dev-kit#readme",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@xube/kit-build": "^0.0.
|
|
20
|
+
"@xube/kit-build": "^0.0.58"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@xube/kit-aws": "^0.0.
|
|
24
|
-
"@xube/kit-aws-schema": "^0.0.
|
|
25
|
-
"@xube/kit-data-schema": "^0.0.
|
|
26
|
-
"@xube/kit-log": "^0.0.
|
|
27
|
-
"@xube/kit-request": "^0.0.
|
|
28
|
-
"@xube/kit-schema": "^0.0.
|
|
23
|
+
"@xube/kit-aws": "^0.0.58",
|
|
24
|
+
"@xube/kit-aws-schema": "^0.0.58",
|
|
25
|
+
"@xube/kit-data-schema": "^0.0.58",
|
|
26
|
+
"@xube/kit-log": "^0.0.58",
|
|
27
|
+
"@xube/kit-request": "^0.0.58",
|
|
28
|
+
"@xube/kit-schema": "^0.0.58",
|
|
29
29
|
"zod": "^3.22.4"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/transform.test.ts
CHANGED
|
@@ -10,8 +10,8 @@ describe("getTimeSeriesDataFromData", () => {
|
|
|
10
10
|
PK: "",
|
|
11
11
|
SK: "",
|
|
12
12
|
data: "S,+000.30,+001.74,M,00,33",
|
|
13
|
-
s:
|
|
14
|
-
us:
|
|
13
|
+
s: 1697578841,
|
|
14
|
+
us: 213581,
|
|
15
15
|
type: DATA_TYPE,
|
|
16
16
|
id: "12345678",
|
|
17
17
|
},
|
|
@@ -19,8 +19,8 @@ describe("getTimeSeriesDataFromData", () => {
|
|
|
19
19
|
PK: "",
|
|
20
20
|
SK: "",
|
|
21
21
|
data: "S,+000.35,+001.84,M,00,39",
|
|
22
|
-
s:
|
|
23
|
-
us:
|
|
22
|
+
s: 1697578841,
|
|
23
|
+
us: 413572,
|
|
24
24
|
type: DATA_TYPE,
|
|
25
25
|
id: "12345678",
|
|
26
26
|
},
|
|
@@ -28,8 +28,8 @@ describe("getTimeSeriesDataFromData", () => {
|
|
|
28
28
|
PK: "",
|
|
29
29
|
SK: "",
|
|
30
30
|
data: "S,+000.26,+002.00,M,00,34",
|
|
31
|
-
s:
|
|
32
|
-
us:
|
|
31
|
+
s: 1697578841,
|
|
32
|
+
us: 612976,
|
|
33
33
|
type: DATA_TYPE,
|
|
34
34
|
id: "12345678",
|
|
35
35
|
},
|
|
@@ -37,8 +37,8 @@ describe("getTimeSeriesDataFromData", () => {
|
|
|
37
37
|
PK: "",
|
|
38
38
|
SK: "",
|
|
39
39
|
data: "S,+000.34,+001.88,M,00,34",
|
|
40
|
-
s:
|
|
41
|
-
us:
|
|
40
|
+
s: 1697578841,
|
|
41
|
+
us: 813754,
|
|
42
42
|
type: DATA_TYPE,
|
|
43
43
|
id: "12345678",
|
|
44
44
|
},
|
|
@@ -46,8 +46,8 @@ describe("getTimeSeriesDataFromData", () => {
|
|
|
46
46
|
PK: "",
|
|
47
47
|
SK: "",
|
|
48
48
|
data: "S,+000.35,+001.82,M,00,3F",
|
|
49
|
-
s:
|
|
50
|
-
us:
|
|
49
|
+
s: 1697578842,
|
|
50
|
+
us: 13019,
|
|
51
51
|
type: DATA_TYPE,
|
|
52
52
|
id: "12345678",
|
|
53
53
|
},
|
|
@@ -63,18 +63,22 @@ describe("getTimeSeriesDataFromData", () => {
|
|
|
63
63
|
trigger: DATA_TYPE,
|
|
64
64
|
source: "device",
|
|
65
65
|
},
|
|
66
|
-
t0: "2023-10-
|
|
66
|
+
t0: "2023-10-17T21:40:41.214581Z",
|
|
67
67
|
dtt: "ms",
|
|
68
68
|
dt: 200,
|
|
69
69
|
dataT: [
|
|
70
70
|
{
|
|
71
|
-
dt:
|
|
71
|
+
dt: 199,
|
|
72
72
|
i: 2,
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
|
-
dt:
|
|
75
|
+
dt: 201,
|
|
76
76
|
i: 3,
|
|
77
77
|
},
|
|
78
|
+
{
|
|
79
|
+
dt: 199,
|
|
80
|
+
i: 4,
|
|
81
|
+
},
|
|
78
82
|
],
|
|
79
83
|
data: [
|
|
80
84
|
"S,+000.30,+001.74,M,00,33",
|
package/src/transform.ts
CHANGED
|
@@ -43,7 +43,7 @@ export const getTimeSeriesDataFromData = (
|
|
|
43
43
|
} else {
|
|
44
44
|
const timeSeriesEntry = timeSeriesEntriesById[item.id];
|
|
45
45
|
|
|
46
|
-
const timeDifference = Math.
|
|
46
|
+
const timeDifference = Math.round(
|
|
47
47
|
(microsSinceEpoch - previousMicroSecondsSinceEpochById?.[item.id]) /
|
|
48
48
|
getDivisorByTimeUnit(timeSeriesEntry.dtt)
|
|
49
49
|
);
|
|
@@ -99,7 +99,7 @@ function microsecondsSinceEpoch(s: number, us: number): number {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
function isoDateTimeWithMicroseconds(microsecondsSinceEpoch: number): string {
|
|
102
|
-
const milliseconds = Math.
|
|
102
|
+
const milliseconds = Math.round(microsecondsSinceEpoch / 1000);
|
|
103
103
|
const microseconds = microsecondsSinceEpoch % 1000;
|
|
104
104
|
|
|
105
105
|
const date = new Date(milliseconds);
|