milesight-powermeter-api 2024.9.24-1 → 2025.7.3
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/npm-shrinkwrap.json +8 -8
- package/package.json +2 -2
- package/src/controller/three-phase-milesight.controller.spec.ts +38 -26
- package/src/controller/three-phase-milesight.controller.ts +3 -1
- package/src/modules/milesight-powermeter.module.ts +1 -1
- package/src/service/three-phase-milesight.service.spec.ts +13 -9
- package/src/service/three-phase-milesight.service.ts +6 -2
- package/timestamp.sh +1 -1
package/npm-shrinkwrap.json
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"name": "milesight-powermeter-api",
|
3
|
-
"version": "
|
3
|
+
"version": "2025.7.3",
|
4
4
|
"lockfileVersion": 3,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "milesight-powermeter-api",
|
9
|
-
"version": "
|
9
|
+
"version": "2025.7.3",
|
10
10
|
"license": "UNLICENSED",
|
11
11
|
"dependencies": {
|
12
|
-
"@coinspect/therma-action-rule-decoder": "
|
12
|
+
"@coinspect/therma-action-rule-decoder": "2025.6.28",
|
13
13
|
"@nestjs/common": "^10.0.0",
|
14
14
|
"@nestjs/core": "^10.0.0",
|
15
15
|
"@nestjs/platform-express": "^10.0.0",
|
@@ -769,9 +769,9 @@
|
|
769
769
|
"dev": true
|
770
770
|
},
|
771
771
|
"node_modules/@coinspect/therma-action-rule-decoder": {
|
772
|
-
"version": "2025.6.
|
773
|
-
"resolved": "https://registry.npmjs.org/@coinspect/therma-action-rule-decoder/-/therma-action-rule-decoder-2025.6.
|
774
|
-
"integrity": "sha512
|
772
|
+
"version": "2025.6.28",
|
773
|
+
"resolved": "https://registry.npmjs.org/@coinspect/therma-action-rule-decoder/-/therma-action-rule-decoder-2025.6.28.tgz",
|
774
|
+
"integrity": "sha512-v4vkug4GBxPhgUhi3CUhxOwvobJvEqUdqllAQu1RnncxoOoyZPu/2Q0vgl6qXrKJLlwTsBEyjjOVD61JVQaEGQ==",
|
775
775
|
"hasShrinkwrap": true,
|
776
776
|
"dependencies": {
|
777
777
|
"@aws-sdk/client-iot": "^3.428.0",
|
@@ -11556,7 +11556,6 @@
|
|
11556
11556
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
|
11557
11557
|
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
|
11558
11558
|
"extraneous": true,
|
11559
|
-
"hasInstallScript": true,
|
11560
11559
|
"dependencies": {
|
11561
11560
|
"bindings": "^1.5.0",
|
11562
11561
|
"nan": "^2.12.1"
|
@@ -19650,7 +19649,8 @@
|
|
19650
19649
|
"hasInstallScript": true,
|
19651
19650
|
"optional": true,
|
19652
19651
|
"os": [
|
19653
|
-
"darwin"
|
19652
|
+
"darwin",
|
19653
|
+
"linux"
|
19654
19654
|
],
|
19655
19655
|
"engines": {
|
19656
19656
|
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "milesight-powermeter-api",
|
3
|
-
"version": "
|
3
|
+
"version": "2025.7.3",
|
4
4
|
"description": "Milesight Powermeter API is an internal tool accessible on backend. The API allows detail retrieval and command sending to its powermeters.",
|
5
5
|
"author": "Lester Vitor",
|
6
6
|
"license": "UNLICENSED",
|
@@ -22,7 +22,7 @@
|
|
22
22
|
"build:kube:ci": "scripts/build-app.sh mewe/lorawan-milesight-powermeter-api-service"
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@coinspect/therma-action-rule-decoder": "
|
25
|
+
"@coinspect/therma-action-rule-decoder": "2025.6.28",
|
26
26
|
"@nestjs/common": "^10.0.0",
|
27
27
|
"@nestjs/core": "^10.0.0",
|
28
28
|
"@nestjs/platform-express": "^10.0.0",
|
@@ -15,8 +15,12 @@ describe('ThreePhaseMilesightController', () => {
|
|
15
15
|
controllers: [ThreePhaseMilesightController],
|
16
16
|
providers: [DownlinkService, ThreePhaseMilesightService],
|
17
17
|
}).compile();
|
18
|
-
threePhaseMilesightService = app.get<ThreePhaseMilesightService>(
|
19
|
-
|
18
|
+
threePhaseMilesightService = app.get<ThreePhaseMilesightService>(
|
19
|
+
ThreePhaseMilesightService,
|
20
|
+
);
|
21
|
+
threePhaseMilesightController = app.get<ThreePhaseMilesightController>(
|
22
|
+
ThreePhaseMilesightController,
|
23
|
+
);
|
20
24
|
});
|
21
25
|
|
22
26
|
afterEach(() => {
|
@@ -53,21 +57,23 @@ describe('ThreePhaseMilesightController', () => {
|
|
53
57
|
],
|
54
58
|
};
|
55
59
|
const controllerResult = {
|
56
|
-
message:
|
57
|
-
'Retrieved three-phase powermeter device list details',
|
60
|
+
message: 'Retrieved three-phase powermeter device list details',
|
58
61
|
result: expectedResult,
|
59
62
|
};
|
60
|
-
jest.spyOn(
|
61
|
-
|
62
|
-
|
63
|
-
|
63
|
+
jest.spyOn(
|
64
|
+
threePhaseMilesightService,
|
65
|
+
'getDeviceList',
|
66
|
+
).mockResolvedValue(expectedResult);
|
67
|
+
const result =
|
68
|
+
await threePhaseMilesightController.getDeviceList(queryParams);
|
64
69
|
expect(result).toEqual(controllerResult);
|
65
70
|
});
|
66
71
|
it('should handle error if device is not retrieved', async () => {
|
67
72
|
const queryParams = { maxResult: 1 };
|
68
|
-
jest.spyOn(
|
69
|
-
|
70
|
-
|
73
|
+
jest.spyOn(
|
74
|
+
threePhaseMilesightService,
|
75
|
+
'getDeviceList',
|
76
|
+
).mockResolvedValue(null);
|
71
77
|
let errorResult = null;
|
72
78
|
try {
|
73
79
|
await threePhaseMilesightController.getDeviceList(queryParams);
|
@@ -87,16 +93,19 @@ describe('ThreePhaseMilesightController', () => {
|
|
87
93
|
message: `Successfully sent reboot command for three-phase device sampleDeviceEui.`,
|
88
94
|
result: true,
|
89
95
|
};
|
90
|
-
jest.spyOn(
|
91
|
-
|
92
|
-
|
93
|
-
|
96
|
+
jest.spyOn(
|
97
|
+
threePhaseMilesightService,
|
98
|
+
'rebootDevice',
|
99
|
+
).mockResolvedValue(true);
|
100
|
+
const result =
|
101
|
+
await threePhaseMilesightController.rebootDevice(data);
|
94
102
|
expect(result).toEqual(controllerResult);
|
95
103
|
});
|
96
104
|
it('should handle error properly', async () => {
|
97
|
-
jest.spyOn(
|
98
|
-
|
99
|
-
|
105
|
+
jest.spyOn(
|
106
|
+
threePhaseMilesightService,
|
107
|
+
'rebootDevice',
|
108
|
+
).mockResolvedValue(null);
|
100
109
|
let errorResult = null;
|
101
110
|
try {
|
102
111
|
await threePhaseMilesightController.rebootDevice(data);
|
@@ -117,16 +126,19 @@ describe('ThreePhaseMilesightController', () => {
|
|
117
126
|
message: `Successfully sent set device interval command for three-phase device sampleDeviceEui.`,
|
118
127
|
result: true,
|
119
128
|
};
|
120
|
-
jest.spyOn(
|
121
|
-
|
122
|
-
|
123
|
-
|
129
|
+
jest.spyOn(
|
130
|
+
threePhaseMilesightService,
|
131
|
+
'setDeviceInterval',
|
132
|
+
).mockResolvedValue(true);
|
133
|
+
const result =
|
134
|
+
await threePhaseMilesightController.setDeviceInterval(data);
|
124
135
|
expect(result).toEqual(controllerResult);
|
125
136
|
});
|
126
137
|
it('should handle error properly', async () => {
|
127
|
-
jest.spyOn(
|
128
|
-
|
129
|
-
|
138
|
+
jest.spyOn(
|
139
|
+
threePhaseMilesightService,
|
140
|
+
'setDeviceInterval',
|
141
|
+
).mockResolvedValue(null);
|
130
142
|
let errorResult = null;
|
131
143
|
try {
|
132
144
|
await threePhaseMilesightController.setDeviceInterval(data);
|
@@ -136,4 +148,4 @@ describe('ThreePhaseMilesightController', () => {
|
|
136
148
|
expect(errorResult).toBeInstanceOf(HttpException);
|
137
149
|
});
|
138
150
|
});
|
139
|
-
});
|
151
|
+
});
|
@@ -19,7 +19,9 @@ import { AWSListThings } from '@coinspect/therma-action-rule-decoder';
|
|
19
19
|
|
20
20
|
@Controller('powermeter/three-phase/milesight')
|
21
21
|
export class ThreePhaseMilesightController {
|
22
|
-
constructor(
|
22
|
+
constructor(
|
23
|
+
private readonly threePhaseMilesightService: ThreePhaseMilesightService,
|
24
|
+
) {}
|
23
25
|
@Get()
|
24
26
|
async getDeviceList(
|
25
27
|
@Query() queryParams: DeviceListParamsDto,
|
@@ -10,4 +10,4 @@ import { DownlinkModule } from './downlink.module';
|
|
10
10
|
controllers: [MilesightController, ThreePhaseMilesightController],
|
11
11
|
providers: [MilesightService, ThreePhaseMilesightService],
|
12
12
|
})
|
13
|
-
export class MilesightPowermeterModule {}
|
13
|
+
export class MilesightPowermeterModule {}
|
@@ -2,7 +2,7 @@ import { Test, TestingModule } from '@nestjs/testing';
|
|
2
2
|
import { Logger } from '@nestjs/common';
|
3
3
|
import { DownlinkService } from './downlink.service';
|
4
4
|
import { ThreePhaseMilesightService } from './three-phase-milesight.service';
|
5
|
-
|
5
|
+
|
6
6
|
const mockGetListDevices = jest.fn();
|
7
7
|
const mockGetDeviceWithTags = jest.fn();
|
8
8
|
jest.mock('@coinspect/therma-action-rule-decoder', () => {
|
@@ -50,7 +50,9 @@ describe('ThreePhaseMilesightService', () => {
|
|
50
50
|
],
|
51
51
|
}).compile();
|
52
52
|
|
53
|
-
threePhaseMilesightService = module.get<ThreePhaseMilesightService>(
|
53
|
+
threePhaseMilesightService = module.get<ThreePhaseMilesightService>(
|
54
|
+
ThreePhaseMilesightService,
|
55
|
+
);
|
54
56
|
downlinkService = module.get<DownlinkService>(DownlinkService);
|
55
57
|
});
|
56
58
|
|
@@ -91,12 +93,13 @@ describe('ThreePhaseMilesightService', () => {
|
|
91
93
|
};
|
92
94
|
mockGetListDevices.mockResolvedValue(expectedResult);
|
93
95
|
|
94
|
-
const result =
|
96
|
+
const result =
|
97
|
+
await threePhaseMilesightService.getDeviceList(MaxResult);
|
95
98
|
|
96
99
|
expect(mockGetListDevices).toHaveBeenCalledWith(
|
97
100
|
'three-phase-powermeter-milesight',
|
98
101
|
MaxResult,
|
99
|
-
undefined
|
102
|
+
undefined,
|
100
103
|
);
|
101
104
|
expect(result).toEqual(expectedResult);
|
102
105
|
});
|
@@ -105,7 +108,8 @@ describe('ThreePhaseMilesightService', () => {
|
|
105
108
|
const MaxResult = 1;
|
106
109
|
mockGetListDevices.mockRejectedValue(new Error('Test error'));
|
107
110
|
|
108
|
-
const response =
|
111
|
+
const response =
|
112
|
+
await threePhaseMilesightService.getDeviceList(MaxResult);
|
109
113
|
expect(response).toBeNull();
|
110
114
|
mockGetListDevices.mockClear();
|
111
115
|
});
|
@@ -122,7 +126,7 @@ describe('ThreePhaseMilesightService', () => {
|
|
122
126
|
const sendDownlinkSpy = jest
|
123
127
|
.spyOn(downlinkService, 'sendDownlink')
|
124
128
|
.mockResolvedValue(true);
|
125
|
-
|
129
|
+
|
126
130
|
const result = await threePhaseMilesightService.rebootDevice(
|
127
131
|
data.deviceEui,
|
128
132
|
data.serialNumber,
|
@@ -144,7 +148,7 @@ describe('ThreePhaseMilesightService', () => {
|
|
144
148
|
const sendDownlinkSpy = jest
|
145
149
|
.spyOn(downlinkService, 'sendDownlink')
|
146
150
|
.mockRejectedValue(new Error('Downlink error'));
|
147
|
-
|
151
|
+
|
148
152
|
const result = await threePhaseMilesightService.rebootDevice(
|
149
153
|
data.deviceEui,
|
150
154
|
data.serialNumber,
|
@@ -167,7 +171,7 @@ describe('ThreePhaseMilesightService', () => {
|
|
167
171
|
const sendDownlinkSpy = jest
|
168
172
|
.spyOn(downlinkService, 'sendDownlink')
|
169
173
|
.mockResolvedValue(true);
|
170
|
-
|
174
|
+
|
171
175
|
const result = await threePhaseMilesightService.setDeviceInterval(
|
172
176
|
data.deviceEui,
|
173
177
|
data.serialNumber,
|
@@ -190,7 +194,7 @@ describe('ThreePhaseMilesightService', () => {
|
|
190
194
|
const sendDownlinkSpy = jest
|
191
195
|
.spyOn(downlinkService, 'sendDownlink')
|
192
196
|
.mockRejectedValue(new Error('Downlink error'));
|
193
|
-
|
197
|
+
|
194
198
|
const result = await threePhaseMilesightService.setDeviceInterval(
|
195
199
|
data.deviceEui,
|
196
200
|
data.serialNumber,
|
@@ -56,10 +56,14 @@ export class ThreePhaseMilesightService {
|
|
56
56
|
fPort,
|
57
57
|
true,
|
58
58
|
);
|
59
|
-
this.logger.log(
|
59
|
+
this.logger.log(
|
60
|
+
`Successfully rebooted three-phase device ${deviceEui}`,
|
61
|
+
);
|
60
62
|
return response;
|
61
63
|
} catch (error) {
|
62
|
-
this.logger.error(
|
64
|
+
this.logger.error(
|
65
|
+
`Error rebooting three-phase device ${deviceEui}: ${error}`,
|
66
|
+
);
|
63
67
|
return null;
|
64
68
|
}
|
65
69
|
}
|
package/timestamp.sh
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export DT=
|
1
|
+
export DT=20250706184520
|