@corvina/device-example 1.0.8

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.
Files changed (43) hide show
  1. package/.env +96 -0
  2. package/README.md +56 -0
  3. package/bin/corvina-device-example.js +3 -0
  4. package/dist/app.module.js +31 -0
  5. package/dist/app.module.js.map +1 -0
  6. package/dist/controllers/app.controller.js +28 -0
  7. package/dist/controllers/app.controller.js.map +1 -0
  8. package/dist/controllers/device/config.controller.js +79 -0
  9. package/dist/controllers/device/config.controller.js.map +1 -0
  10. package/dist/controllers/device/dice.controller.js +65 -0
  11. package/dist/controllers/device/dice.controller.js.map +1 -0
  12. package/dist/controllers/device/dto/datapoint.dto.js +14 -0
  13. package/dist/controllers/device/dto/datapoint.dto.js.map +1 -0
  14. package/dist/controllers/device/dto/deviceconfig.dto.js +120 -0
  15. package/dist/controllers/device/dto/deviceconfig.dto.js.map +1 -0
  16. package/dist/controllers/device/dto/licensedata.dto.js +16 -0
  17. package/dist/controllers/device/dto/licensedata.dto.js.map +1 -0
  18. package/dist/controllers/device/json.controller.js +137 -0
  19. package/dist/controllers/device/json.controller.js.map +1 -0
  20. package/dist/controllers/device/sine.controller.js +81 -0
  21. package/dist/controllers/device/sine.controller.js.map +1 -0
  22. package/dist/controllers/health.controller.js +41 -0
  23. package/dist/controllers/health.controller.js.map +1 -0
  24. package/dist/main.js +36 -0
  25. package/dist/main.js.map +1 -0
  26. package/dist/services/device.health.js +37 -0
  27. package/dist/services/device.health.js.map +1 -0
  28. package/nest-cli.json +17 -0
  29. package/package.json +47 -0
  30. package/src/.env +130 -0
  31. package/src/app.module.ts +19 -0
  32. package/src/controllers/app.controller.ts +7 -0
  33. package/src/controllers/device/config.controller.ts +42 -0
  34. package/src/controllers/device/dice.controller.ts +38 -0
  35. package/src/controllers/device/dto/datapoint.dto.ts +7 -0
  36. package/src/controllers/device/dto/deviceconfig.dto.ts +110 -0
  37. package/src/controllers/device/dto/licensedata.dto.ts +9 -0
  38. package/src/controllers/device/json.controller.ts +111 -0
  39. package/src/controllers/device/sine.controller.ts +56 -0
  40. package/src/controllers/health.controller.ts +14 -0
  41. package/src/main.ts +33 -0
  42. package/src/services/device.health.ts +20 -0
  43. package/tsconfig.app.json +9 -0
package/.env ADDED
@@ -0,0 +1,96 @@
1
+ APP_ID=app
2
+ PORT=3000
3
+ LOG_LEVEL=trace
4
+ REQUEST_LIMIT=100kb
5
+ SESSION_SECRET=mySecret
6
+
7
+ # fog
8
+ # ACTIVATION_KEY=B3ED-48CF-A9DD-6971
9
+ # PAIRING_ENDPOINT=https://pairing.corvina.fog:10443/api/v1/
10
+
11
+ # my pc
12
+ ACTIVATION_KEY=4D05-4037-974E-9482
13
+ PAIRING_ENDPOINT=https://pairing.corvina.fog:10443/api/v1/
14
+
15
+ # abb ac500
16
+ # ACTIVATION_KEY=B2A0-45AC-ABFE-D25F
17
+ # PAIRING_ENDPOINT=https://pairing.dev.corvina.cloud/api/v1/
18
+
19
+ AVAILABLE_TAGS=[{"name":"Tag1","type":"integer"},{"name":"Tag2","type":"integer"},{"name":"Tag3","type":"integer"}]
20
+ AVAILABLE_ALARMS=[{"name": "Alarm1", "severity" : 1, "source" : "Tag1", "desc" : { "en" : "Tag above normal : [Tag1]"} , "ack_required": true, "reset_required" : true, "simulation" : { "f" : "{ console.log('current tag value is ', $('Tag1')); return $('Tag1') > 100 }" } }, {"name" : "Alarm2"} ]
21
+ SIMULATE_TAGS=1
22
+ SIMULATE_ALARMS=0
23
+ SIMULATION_MS=1000
24
+ PACKET_FORMAT=bson
25
+ WRITE_CALLBACK=http://localhost:3001
26
+
27
+ # don't bother about certificates
28
+ NODE_TLS_REJECT_UNAUTHORIZED=0
29
+
30
+ #Swagger
31
+ SWAGGER_API_SPEC=/spec
32
+
33
+
34
+
35
+ # AVAILABLE_TAGS=[{"name":"struct.a","type":"integer"},{"name":"struct.b","type":"integer"},{"name":"Tag1","type":"integer"},{"name":"Tag2","type":"integer"},{"name":"Tag3","type":"integer"},{"name":"PositionNow","type":"integer"}]
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+ ### LAST-ENV ###
88
+ # don't write below this line!!
89
+ ACTIVATION_KEY=BZUOL-GMV5Q-2MPOF-72V0L
90
+ PAIRING_ENDPOINT=https://pairing.corvina.fog:10443/api/v1/
91
+ AVAILABLE_TAGS_FILE=
92
+ AVAILABLE_TAGS=[{"name":"Tag1","type":"integer"},{"name":"Tag2","type":"integer"},{"name":"Tag3","type":"integer"},{"name":"PositionNow","type":"integer"},{"name":"InputTag","type":"integer"}]
93
+ SIMULATE_TAGS=1
94
+ AVAILABLE_ALARMS=[{"name":"Alarm10","severity":1,"source":"Tag1","desc":{"en":"Tag above normal : [Tag1]"},"ack_required":true,"reset_required":true,"simulation":{"f":"{ console.log('current tag value is ', $('Tag1')); $('Tag1') > 0; return Math.random() > 0.5 }"}},{"name":"Alarm2"}]
95
+ SIMULATE_ALARMS=1
96
+ PACKET_FORMAT=bson
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Corvina simulated device example
2
+
3
+ This is an example of the usage of `@corvina/device-client`.
4
+
5
+ The device client can be configured with environment variables (or `.env` file).
6
+
7
+ In addition, this example exposes a web interface to post arbitrary JSON data or to simulate device data.
8
+
9
+ ## Quick Start
10
+
11
+ At least the following environment variables must be configured:
12
+
13
+ ```shell
14
+ ACTIVATION_KEY=<your_device_activation_key>
15
+ PAIRING_ENDPOINT=https://pairing.corvina.io/api/v1/
16
+ ```
17
+
18
+
19
+ The device can be started:
20
+
21
+ * via package manager:
22
+
23
+ ```
24
+ npm install @corvina/device-example
25
+
26
+ npm @corvina/device-example
27
+ ```
28
+
29
+ * via `npx`
30
+
31
+ ```shell
32
+ npx @corvina/device-example
33
+ ```
34
+
35
+ * from sources:
36
+
37
+ ```shell
38
+ yarn install
39
+
40
+ yarn start:dev
41
+ ```
42
+
43
+ A web interface will be available at `http://localhost:3000/swagger-ui`.
44
+
45
+ ## Environment variables
46
+
47
+ This example device provides the environment variable `WRITE_CALLBACK` to configure a webhook for written data:
48
+
49
+
50
+ In addition, the full list of environment variables used by `@corvina/device-client` can be used.
51
+
52
+ ### Using the example rest interface
53
+
54
+ It is possible to send generic JSON posting to the `/device/json` endpoint.
55
+
56
+ Each of the JSON properties posted will be advertised to the cloud with the corresponding JSON paths.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ const device = require('..');
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.AppModule = void 0;
10
+ const terminus_1 = require("@nestjs/terminus");
11
+ const health_controller_1 = require("./controllers/health.controller");
12
+ const common_1 = require("@nestjs/common");
13
+ const config_1 = require("@nestjs/config");
14
+ const device_module_1 = require("@corvina/corvina-device-sdk/device.module");
15
+ const device_health_1 = require("./services/device.health");
16
+ const config_controller_1 = require("./controllers/device/config.controller");
17
+ const dice_controller_1 = require("./controllers/device/dice.controller");
18
+ const sine_controller_1 = require("./controllers/device/sine.controller");
19
+ const json_controller_1 = require("./controllers/device/json.controller");
20
+ let AppModule = class AppModule {
21
+ };
22
+ AppModule = __decorate([
23
+ (0, common_1.Module)({
24
+ imports: [terminus_1.TerminusModule, config_1.ConfigModule.forRoot(), device_module_1.DeviceClientModule],
25
+ controllers: [config_controller_1.Config, dice_controller_1.Dice, sine_controller_1.Sine, json_controller_1.Json, health_controller_1.HealthController],
26
+ providers: [device_health_1.DeviceHealthIndicator],
27
+ exports: [],
28
+ })
29
+ ], AppModule);
30
+ exports.AppModule = AppModule;
31
+ //# sourceMappingURL=app.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAkD;AAClD,uEAAmE;AACnE,2CAAwC;AACxC,2CAA8C;AAC9C,6EAA+E;AAC/E,4DAAiE;AACjE,8EAAgE;AAChE,0EAA4D;AAC5D,0EAA4D;AAC5D,0EAA4D;AAS5D,IAAa,SAAS,GAAtB,MAAa,SAAS;CAAG,CAAA;AAAZ,SAAS;IANrB,IAAA,eAAM,EAAC;QACJ,OAAO,EAAE,CAAC,yBAAc,EAAE,qBAAY,CAAC,OAAO,EAAE,EAAE,kCAAkB,CAAC;QACrE,WAAW,EAAE,CAAC,0BAAM,EAAE,sBAAI,EAAE,sBAAI,EAAE,sBAAI,EAAE,oCAAgB,CAAC;QACzD,SAAS,EAAE,CAAC,qCAAqB,CAAC;QAClC,OAAO,EAAE,EAAE;KACd,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var _a;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.AppController = void 0;
14
+ const openapi = require("@nestjs/swagger");
15
+ const common_1 = require("@nestjs/common");
16
+ const corvina_device_sdk_1 = require("@corvina/corvina-device-sdk");
17
+ let AppController = class AppController {
18
+ appService;
19
+ constructor(appService) {
20
+ this.appService = appService;
21
+ }
22
+ };
23
+ AppController = __decorate([
24
+ (0, common_1.Controller)(),
25
+ __metadata("design:paramtypes", [typeof (_a = typeof corvina_device_sdk_1.DeviceRunnerService !== "undefined" && corvina_device_sdk_1.DeviceRunnerService) === "function" ? _a : Object])
26
+ ], AppController);
27
+ exports.AppController = AppController;
28
+ //# sourceMappingURL=app.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../../src/controllers/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,oEAAkE;AAGlE,IAAa,aAAa,GAA1B,MAAa,aAAa;IACO;IAA7B,YAA6B,UAA+B;QAA/B,eAAU,GAAV,UAAU,CAAqB;IAAG,CAAC;CACnE,CAAA;AAFY,aAAa;IADzB,IAAA,mBAAU,GAAE;yDAEgC,wCAAmB,oBAAnB,wCAAmB;GADnD,aAAa,CAEzB;AAFY,sCAAa"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var Config_1, _a, _b;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.Config = void 0;
17
+ const openapi = require("@nestjs/swagger");
18
+ const common_1 = require("@nestjs/common");
19
+ const corvina_device_sdk_1 = require("@corvina/corvina-device-sdk");
20
+ const swagger_1 = require("@nestjs/swagger");
21
+ const deviceconfig_dto_1 = require("./dto/deviceconfig.dto");
22
+ const licensedata_dto_1 = require("./dto/licensedata.dto");
23
+ let Config = Config_1 = class Config {
24
+ deviceService;
25
+ l = new common_1.Logger(Config_1.name);
26
+ constructor(deviceService) {
27
+ this.deviceService = deviceService;
28
+ }
29
+ config(newConfig) {
30
+ this.l.log("apply new config");
31
+ return new deviceconfig_dto_1.DeviceConfigDTO(this.deviceService.getDeviceConfig());
32
+ }
33
+ get() {
34
+ const config = this.deviceService.getAppliedConfig();
35
+ return config;
36
+ }
37
+ getLicenseData() {
38
+ return this.deviceService.getLicenseData();
39
+ }
40
+ };
41
+ __decorate([
42
+ (0, swagger_1.ApiOperation)({
43
+ summary: "Applied a new device configuration",
44
+ }),
45
+ (0, common_1.Post)("/config"),
46
+ openapi.ApiResponse({ status: 201, type: require("./dto/deviceconfig.dto").DeviceConfigDTO }),
47
+ __param(0, (0, common_1.Body)("newConfig")),
48
+ __metadata("design:type", Function),
49
+ __metadata("design:paramtypes", [deviceconfig_dto_1.DeviceConfigDTO]),
50
+ __metadata("design:returntype", deviceconfig_dto_1.DeviceConfigDTO)
51
+ ], Config.prototype, "config", null);
52
+ __decorate([
53
+ (0, swagger_1.ApiOperation)({
54
+ summary: "Get current applied device configuration",
55
+ }),
56
+ (0, common_1.Get)("/config"),
57
+ openapi.ApiResponse({ status: 200, type: Object }),
58
+ __metadata("design:type", Function),
59
+ __metadata("design:paramtypes", []),
60
+ __metadata("design:returntype", typeof (_a = typeof corvina_device_sdk_1.DeviceConfig !== "undefined" && corvina_device_sdk_1.DeviceConfig) === "function" ? _a : Object)
61
+ ], Config.prototype, "get", null);
62
+ __decorate([
63
+ (0, swagger_1.ApiOperation)({
64
+ summary: "Get current device license data",
65
+ }),
66
+ (0, common_1.Get)("/licenseData"),
67
+ openapi.ApiResponse({ status: 200, type: require("./dto/licensedata.dto").LicenseDataDTO }),
68
+ __metadata("design:type", Function),
69
+ __metadata("design:paramtypes", []),
70
+ __metadata("design:returntype", licensedata_dto_1.LicenseDataDTO)
71
+ ], Config.prototype, "getLicenseData", null);
72
+ Config = Config_1 = __decorate([
73
+ (0, swagger_1.ApiTags)("device"),
74
+ (0, common_1.Controller)("/device"),
75
+ (0, common_1.Injectable)(),
76
+ __metadata("design:paramtypes", [typeof (_b = typeof corvina_device_sdk_1.DeviceService !== "undefined" && corvina_device_sdk_1.DeviceService) === "function" ? _b : Object])
77
+ ], Config);
78
+ exports.Config = Config;
79
+ //# sourceMappingURL=config.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.controller.js","sourceRoot":"","sources":["../../../src/controllers/device/config.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAiF;AACjF,oEAA0E;AAC1E,6CAAwD;AACxD,6DAAyD;AACzD,2DAAuD;AAMvD,IAAa,MAAM,cAAnB,MAAa,MAAM;IAGc;IAFZ,CAAC,GAAG,IAAI,eAAM,CAAC,QAAM,CAAC,IAAI,CAAC,CAAC;IAE7C,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAM7D,MAAM,CAAoB,SAA0B;QAChD,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QAE/B,OAAO,IAAI,kCAAe,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC,CAAC;IACrE,CAAC;IAMD,GAAG;QACC,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACrD,OAAO,MAAM,CAAC;IAClB,CAAC;IAMD,cAAc;QACV,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;IAC/C,CAAC;CACJ,CAAA;;IA1BI,IAAA,sBAAY,EAAC;QACV,OAAO,EAAE,oCAAoC;KAChD,CAAC;IACD,IAAA,aAAI,EAAC,SAAS,CAAC;;IACR,WAAA,IAAA,aAAI,EAAC,WAAW,CAAC,CAAA;;qCAAY,kCAAe;oCAAG,kCAAe;oCAIrE;;IAEA,IAAA,sBAAY,EAAC;QACV,OAAO,EAAE,0CAA0C;KACtD,CAAC;IACD,IAAA,YAAG,EAAC,SAAS,CAAC;;;;wDACR,iCAAY,oBAAZ,iCAAY;iCAGlB;;IAEA,IAAA,sBAAY,EAAC;QACV,OAAO,EAAE,iCAAiC;KAC7C,CAAC;IACD,IAAA,YAAG,EAAC,cAAc,CAAC;;;;oCACF,gCAAc;4CAE/B;AA9BQ,MAAM;IAHlB,IAAA,iBAAO,EAAC,QAAQ,CAAC;IACjB,IAAA,mBAAU,EAAC,SAAS,CAAC;IACrB,IAAA,mBAAU,GAAE;yDAImC,kCAAa,oBAAb,kCAAa;GAHhD,MAAM,CA+BlB;AA/BY,wBAAM"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var Dice_1, _a;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.Dice = void 0;
17
+ const openapi = require("@nestjs/swagger");
18
+ const common_1 = require("@nestjs/common");
19
+ const corvina_device_sdk_1 = require("@corvina/corvina-device-sdk");
20
+ const swagger_1 = require("@nestjs/swagger");
21
+ let Dice = Dice_1 = class Dice {
22
+ l = new common_1.Logger(Dice_1.name);
23
+ deviceService;
24
+ async post(tagName) {
25
+ const t = Date.now();
26
+ const v = Math.random() > 0.5;
27
+ const dataPoints = new Array();
28
+ const dp = {
29
+ tagName,
30
+ value: v,
31
+ timestamp: t,
32
+ };
33
+ dataPoints.push(dp);
34
+ await this.deviceService.post(dataPoints);
35
+ return dataPoints;
36
+ }
37
+ };
38
+ __decorate([
39
+ (0, common_1.Inject)(),
40
+ __metadata("design:type", typeof (_a = typeof corvina_device_sdk_1.DeviceService !== "undefined" && corvina_device_sdk_1.DeviceService) === "function" ? _a : Object)
41
+ ], Dice.prototype, "deviceService", void 0);
42
+ __decorate([
43
+ (0, swagger_1.ApiOperation)({
44
+ summary: "Post binary (0/1) values sampled from a uniform random number distribution",
45
+ }),
46
+ (0, swagger_1.ApiQuery)({
47
+ name: "tagName",
48
+ description: "device identifier (name) of data source",
49
+ schema: { default: "Tag" },
50
+ required: false,
51
+ }),
52
+ (0, common_1.Post)(),
53
+ openapi.ApiResponse({ status: 201, type: [require("./dto/datapoint.dto").DataPointDTO] }),
54
+ __param(0, (0, common_1.Query)("tagName")),
55
+ __metadata("design:type", Function),
56
+ __metadata("design:paramtypes", [String]),
57
+ __metadata("design:returntype", Promise)
58
+ ], Dice.prototype, "post", null);
59
+ Dice = Dice_1 = __decorate([
60
+ (0, swagger_1.ApiTags)("device"),
61
+ (0, common_1.Controller)("/device/dice"),
62
+ (0, common_1.Injectable)()
63
+ ], Dice);
64
+ exports.Dice = Dice;
65
+ //# sourceMappingURL=dice.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dice.controller.js","sourceRoot":"","sources":["../../../src/controllers/device/dice.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAqF;AACrF,oEAA4D;AAE5D,6CAAkE;AAOlE,IAAa,IAAI,YAAjB,MAAa,IAAI;IACI,CAAC,GAAG,IAAI,eAAM,CAAC,MAAI,CAAC,IAAI,CAAC,CAAC;IAChB,aAAa,CAAgB;IAYxD,KAAK,CAAC,IAAI,CAAmB,OAAe;QACxC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;QAC9B,MAAM,UAAU,GAAG,IAAI,KAAK,EAAa,CAAC;QAC1C,MAAM,EAAE,GAAc;YAClB,OAAO;YACP,KAAK,EAAE,CAAC;YACR,SAAS,EAAE,CAAC;SACf,CAAC;QACF,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpB,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1C,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ,CAAA;AAzBa;IAAT,IAAA,eAAM,GAAE;kDAAiC,kCAAa,oBAAb,kCAAa;2CAAC;;IAEvD,IAAA,sBAAY,EAAC;QACV,OAAO,EAAE,4EAA4E;KACxF,CAAC;IACD,IAAA,kBAAQ,EAAC;QACN,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,yCAAyC;QACtD,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;QAC1B,QAAQ,EAAE,KAAK;KAClB,CAAC;IACD,IAAA,aAAI,GAAE;;IACK,WAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;;;;gCAY3B;AA1BQ,IAAI;IAHhB,IAAA,iBAAO,EAAC,QAAQ,CAAC;IACjB,IAAA,mBAAU,EAAC,cAAc,CAAC;IAC1B,IAAA,mBAAU,GAAE;GACA,IAAI,CA2BhB;AA3BY,oBAAI"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataPointDTO = void 0;
4
+ const openapi = require("@nestjs/swagger");
5
+ class DataPointDTO {
6
+ tagName;
7
+ value;
8
+ timestamp;
9
+ static _OPENAPI_METADATA_FACTORY() {
10
+ return { tagName: { required: true, type: () => String }, value: { required: true, type: () => Object }, timestamp: { required: true, type: () => Number } };
11
+ }
12
+ }
13
+ exports.DataPointDTO = DataPointDTO;
14
+ //# sourceMappingURL=datapoint.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datapoint.dto.js","sourceRoot":"","sources":["../../../../src/controllers/device/dto/datapoint.dto.ts"],"names":[],"mappings":";;;;AAEA,MAAa,YAAY;IACrB,OAAO,CAAS;IAChB,KAAK,CAAM;IACX,SAAS,CAAS;;;;CACrB;AAJD,oCAIC"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeviceConfigDTO = exports.AlarmDescDTO = exports.MultiLangStringDTO = exports.TagDescDTO = exports.SimulationDescDTO = exports.NoiseSimulationPropertiesDTO = exports.NullableSimulationPropertiesDTO = exports.NullableSimulationStateMachineDTO = void 0;
4
+ const openapi = require("@nestjs/swagger");
5
+ class NullableSimulationStateMachineDTO {
6
+ nullifying;
7
+ start;
8
+ duration;
9
+ static _OPENAPI_METADATA_FACTORY() {
10
+ return { nullifying: { required: true, type: () => Boolean }, start: { required: true, type: () => Number }, duration: { required: true, type: () => Number } };
11
+ }
12
+ }
13
+ exports.NullableSimulationStateMachineDTO = NullableSimulationStateMachineDTO;
14
+ class NullableSimulationPropertiesDTO {
15
+ probability;
16
+ dt_min;
17
+ dt_max;
18
+ state;
19
+ static _OPENAPI_METADATA_FACTORY() {
20
+ return { probability: { required: true, type: () => Number }, dt_min: { required: true, type: () => Number }, dt_max: { required: true, type: () => Number }, state: { required: false, type: () => require("./deviceconfig.dto").NullableSimulationStateMachineDTO } };
21
+ }
22
+ }
23
+ exports.NullableSimulationPropertiesDTO = NullableSimulationPropertiesDTO;
24
+ class NoiseSimulationPropertiesDTO {
25
+ type;
26
+ amplitude;
27
+ static _OPENAPI_METADATA_FACTORY() {
28
+ return { type: { required: true, type: () => Object }, amplitude: { required: true, type: () => Number } };
29
+ }
30
+ }
31
+ exports.NoiseSimulationPropertiesDTO = NoiseSimulationPropertiesDTO;
32
+ class SimulationDescDTO {
33
+ type;
34
+ noise;
35
+ nullable;
36
+ static _OPENAPI_METADATA_FACTORY() {
37
+ return { type: { required: true, type: () => Object }, noise: { required: true, type: () => require("./deviceconfig.dto").NoiseSimulationPropertiesDTO }, nullable: { required: true, type: () => require("./deviceconfig.dto").NullableSimulationPropertiesDTO } };
38
+ }
39
+ }
40
+ exports.SimulationDescDTO = SimulationDescDTO;
41
+ class TagDescDTO {
42
+ name;
43
+ type;
44
+ simulation;
45
+ static _OPENAPI_METADATA_FACTORY() {
46
+ return { name: { required: true, type: () => String }, type: { required: true, type: () => String }, simulation: { required: false, type: () => require("./deviceconfig.dto").SimulationDescDTO } };
47
+ }
48
+ }
49
+ exports.TagDescDTO = TagDescDTO;
50
+ class MultiLangStringDTO {
51
+ static _OPENAPI_METADATA_FACTORY() {
52
+ return {};
53
+ }
54
+ }
55
+ exports.MultiLangStringDTO = MultiLangStringDTO;
56
+ class AlarmDescDTO {
57
+ name;
58
+ desc;
59
+ source;
60
+ severity;
61
+ ack_required;
62
+ reset_required;
63
+ enabled;
64
+ simulation;
65
+ static _OPENAPI_METADATA_FACTORY() {
66
+ return { name: { required: true, type: () => String }, desc: { required: true, type: () => require("./deviceconfig.dto").MultiLangStringDTO }, source: { required: true, type: () => String }, severity: { required: true, type: () => Number }, ack_required: { required: true, type: () => Boolean }, reset_required: { required: true, type: () => Boolean }, enabled: { required: true, type: () => Boolean }, simulation: { required: true, type: () => require("./deviceconfig.dto").SimulationDescDTO } };
67
+ }
68
+ }
69
+ exports.AlarmDescDTO = AlarmDescDTO;
70
+ class DeviceConfigDTO {
71
+ activationKey;
72
+ pairingEndpoint;
73
+ availableTagsFile;
74
+ availableTags;
75
+ simulateTags;
76
+ availableAlarms;
77
+ simulateAlarms;
78
+ packetFormat;
79
+ arrayToMap(input) {
80
+ const map = new Map();
81
+ for (const item of input) {
82
+ map.set(item.name, item);
83
+ }
84
+ return map;
85
+ }
86
+ mapToArray(input) {
87
+ const array = [];
88
+ input.forEach((value, key) => {
89
+ array.push({ name: key, value });
90
+ });
91
+ return array;
92
+ }
93
+ toDeviceConfig() {
94
+ return {
95
+ activationKey: this.activationKey,
96
+ pairingEndpoint: this.pairingEndpoint,
97
+ availableTagsFile: this.availableTagsFile,
98
+ availableTags: this.arrayToMap(this.availableTags),
99
+ simulateTags: this.simulateTags,
100
+ availableAlarms: this.arrayToMap(this.availableAlarms),
101
+ simulateAlarms: this.simulateAlarms,
102
+ packetFormat: this.packetFormat,
103
+ };
104
+ }
105
+ constructor(deviceConfig) {
106
+ this.activationKey = deviceConfig.activationKey;
107
+ this.pairingEndpoint = deviceConfig.pairingEndpoint;
108
+ this.availableTagsFile = deviceConfig.availableTagsFile;
109
+ this.availableTags = this.mapToArray(deviceConfig.availableTags);
110
+ this.simulateTags = deviceConfig.simulateTags;
111
+ this.availableAlarms = this.mapToArray(deviceConfig.availableAlarms);
112
+ this.simulateAlarms = deviceConfig.simulateAlarms;
113
+ this.packetFormat = deviceConfig.packetFormat;
114
+ }
115
+ static _OPENAPI_METADATA_FACTORY() {
116
+ return { activationKey: { required: false, type: () => String }, pairingEndpoint: { required: false, type: () => String }, availableTagsFile: { required: false, type: () => String }, availableTags: { required: false, type: () => [require("./deviceconfig.dto").TagDescDTO] }, simulateTags: { required: false, type: () => Boolean }, availableAlarms: { required: false, type: () => [require("./deviceconfig.dto").AlarmDescDTO] }, simulateAlarms: { required: false, type: () => Boolean }, packetFormat: { required: false, type: () => Object } };
117
+ }
118
+ }
119
+ exports.DeviceConfigDTO = DeviceConfigDTO;
120
+ //# sourceMappingURL=deviceconfig.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deviceconfig.dto.js","sourceRoot":"","sources":["../../../../src/controllers/device/dto/deviceconfig.dto.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LicenseDataDTO = void 0;
4
+ const openapi = require("@nestjs/swagger");
5
+ class LicenseDataDTO {
6
+ realm;
7
+ logicalId;
8
+ apiKey;
9
+ platformPairingApiUrl;
10
+ brokerUrls;
11
+ static _OPENAPI_METADATA_FACTORY() {
12
+ return { realm: { required: true, type: () => String }, logicalId: { required: true, type: () => String }, apiKey: { required: true, type: () => String }, platformPairingApiUrl: { required: true, type: () => String }, brokerUrls: { required: true, type: () => [String] } };
13
+ }
14
+ }
15
+ exports.LicenseDataDTO = LicenseDataDTO;
16
+ //# sourceMappingURL=licensedata.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"licensedata.dto.js","sourceRoot":"","sources":["../../../../src/controllers/device/dto/licensedata.dto.ts"],"names":[],"mappings":";;;;AAEA,MAAa,cAAc;IACvB,KAAK,CAAS;IACd,SAAS,CAAS;IAClB,MAAM,CAAS;IACf,qBAAqB,CAAS;IAC9B,UAAU,CAAW;;;;CACxB;AAND,wCAMC"}