@corvina/device-example 1.4.3 → 1.4.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.
- package/package.json +60 -60
- package/.env +0 -64
- package/ca.crt +0 -15
- package/dist/app.module.d.ts +0 -3
- package/dist/app.module.d.ts.map +0 -1
- package/dist/app.module.js +0 -42
- package/dist/app.module.js.map +0 -1
- package/dist/controllers/app.controller.d.ts +0 -6
- package/dist/controllers/app.controller.d.ts.map +0 -1
- package/dist/controllers/app.controller.js +0 -27
- package/dist/controllers/app.controller.js.map +0 -1
- package/dist/controllers/device/config.controller.d.ts +0 -12
- package/dist/controllers/device/config.controller.d.ts.map +0 -1
- package/dist/controllers/device/config.controller.js +0 -80
- package/dist/controllers/device/config.controller.js.map +0 -1
- package/dist/controllers/device/dice.controller.d.ts +0 -7
- package/dist/controllers/device/dice.controller.d.ts.map +0 -1
- package/dist/controllers/device/dice.controller.js +0 -65
- package/dist/controllers/device/dice.controller.js.map +0 -1
- package/dist/controllers/device/dto/datapoint.dto.d.ts +0 -7
- package/dist/controllers/device/dto/datapoint.dto.d.ts.map +0 -1
- package/dist/controllers/device/dto/datapoint.dto.js +0 -14
- package/dist/controllers/device/dto/datapoint.dto.js.map +0 -1
- package/dist/controllers/device/dto/deviceconfig.dto.d.ts +0 -55
- package/dist/controllers/device/dto/deviceconfig.dto.d.ts.map +0 -1
- package/dist/controllers/device/dto/deviceconfig.dto.js +0 -120
- package/dist/controllers/device/dto/deviceconfig.dto.js.map +0 -1
- package/dist/controllers/device/dto/licensedata.dto.d.ts +0 -9
- package/dist/controllers/device/dto/licensedata.dto.d.ts.map +0 -1
- package/dist/controllers/device/dto/licensedata.dto.js +0 -16
- package/dist/controllers/device/dto/licensedata.dto.js.map +0 -1
- package/dist/controllers/device/json.controller.d.ts +0 -7
- package/dist/controllers/device/json.controller.d.ts.map +0 -1
- package/dist/controllers/device/json.controller.js +0 -137
- package/dist/controllers/device/json.controller.js.map +0 -1
- package/dist/controllers/device/sine.controller.d.ts +0 -7
- package/dist/controllers/device/sine.controller.d.ts.map +0 -1
- package/dist/controllers/device/sine.controller.js +0 -81
- package/dist/controllers/device/sine.controller.js.map +0 -1
- package/dist/controllers/health.controller.d.ts +0 -9
- package/dist/controllers/health.controller.d.ts.map +0 -1
- package/dist/controllers/health.controller.js +0 -41
- package/dist/controllers/health.controller.js.map +0 -1
- package/dist/main.d.ts +0 -2
- package/dist/main.d.ts.map +0 -1
- package/dist/main.js +0 -64
- package/dist/main.js.map +0 -1
- package/dist/services/device.health.d.ts +0 -8
- package/dist/services/device.health.d.ts.map +0 -1
- package/dist/services/device.health.js +0 -36
- package/dist/services/device.health.js.map +0 -1
- package/ignore +0 -0
- package/main-linux +0 -0
- package/main-macos +0 -0
- package/main-win.exe +0 -0
- package/out +0 -6922
- package/src/.env +0 -130
- package/tags.json +0 -302
- package/tsconfig.app.tsbuildinfo +0 -1
|
@@ -1,120 +0,0 @@
|
|
|
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, enum: require("../../../../../../libs/device-client/dist/common/types").NoiseSimulationType }, 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, enum: require("../../../../../../libs/device-client/dist/common/types").SimulationType }, 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, enum: require("../../../../../../libs/device-client/dist/common/types").PacketFormatEnum } };
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
exports.DeviceConfigDTO = DeviceConfigDTO;
|
|
120
|
-
//# sourceMappingURL=deviceconfig.dto.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deviceconfig.dto.js","sourceRoot":"","sources":["../../../../src/controllers/device/dto/deviceconfig.dto.ts"],"names":[],"mappings":";;;;AAeA,MAAa,iCAAiC;IAC1C,UAAU,CAAU;IACpB,KAAK,CAAS;IACd,QAAQ,CAAS;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AAE,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,cAAc;QACV,OAAO;YACH,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC;YAClD,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC;YACtD,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,YAAY,EAAE,IAAI,CAAC,YAAY;SAClC,CAAC;IACN,CAAC;IAED,YAAY,YAA0B;QAClC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC,aAAa,CAAC;QAChD,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC;QACpD,IAAI,CAAC,iBAAiB,GAAG,YAAY,CAAC,iBAAiB,CAAC;QACxD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACjE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,YAAY,CAAC;QAC9C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;QACrE,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,cAAc,CAAC;QAClD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,YAAY,CAAC;IAClD,CAAC;;;;CACJ;AAjDD,0CAiDC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { LicenseData } from "@corvina/device-client";
|
|
2
|
-
export declare class LicenseDataDTO implements LicenseData {
|
|
3
|
-
realm: string;
|
|
4
|
-
logicalId: string;
|
|
5
|
-
apiKey: string;
|
|
6
|
-
platformPairingApiUrl: string;
|
|
7
|
-
brokerUrls: string[];
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=licensedata.dto.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"licensedata.dto.d.ts","sourceRoot":"","sources":["../../../../src/controllers/device/dto/licensedata.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,qBAAa,cAAe,YAAW,WAAW;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB,EAAE,MAAM,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;CACxB"}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DataPointDTO } from "./dto/datapoint.dto";
|
|
2
|
-
export declare class Json {
|
|
3
|
-
private readonly l;
|
|
4
|
-
private readonly deviceService;
|
|
5
|
-
post(tagName: any, timestamp: any, qos: any, postCallback: any, v: any): Promise<DataPointDTO[]>;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=json.controller.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/device/json.controller.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,qBAGa,IAAI;IACb,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAyB;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAwElD,IAAI,CACY,OAAO,KAAY,EACjB,SAAS,KAAY,EAC3B,GAAG,KAAY,EACV,YAAY,KAAY,EACnC,CAAC,EAAE,GAAG,GACf,OAAO,CAAC,YAAY,EAAE,CAAC;CAmB7B"}
|
|
@@ -1,137 +0,0 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
-
};
|
|
17
|
-
var Json_1;
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.Json = void 0;
|
|
20
|
-
const openapi = require("@nestjs/swagger");
|
|
21
|
-
const common_1 = require("@nestjs/common");
|
|
22
|
-
const device_client_1 = require("@corvina/device-client");
|
|
23
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
24
|
-
const axios_1 = __importDefault(require("axios"));
|
|
25
|
-
let Json = Json_1 = class Json {
|
|
26
|
-
l = new common_1.Logger(Json_1.name);
|
|
27
|
-
deviceService;
|
|
28
|
-
async post(tagName = undefined, timestamp = undefined, qos = undefined, postCallback = undefined, v) {
|
|
29
|
-
const t = timestamp || Date.now();
|
|
30
|
-
const dataPoints = new Array();
|
|
31
|
-
const dp = {
|
|
32
|
-
tagName,
|
|
33
|
-
value: v,
|
|
34
|
-
timestamp: t,
|
|
35
|
-
};
|
|
36
|
-
dataPoints.push(dp);
|
|
37
|
-
await this.deviceService.post(dataPoints, {
|
|
38
|
-
qos: qos || 0,
|
|
39
|
-
cb: postCallback
|
|
40
|
-
? (error, tagName, modelPath) => {
|
|
41
|
-
axios_1.default.post(postCallback, { error: { message: error.message }, tagName, modelPath });
|
|
42
|
-
}
|
|
43
|
-
: undefined,
|
|
44
|
-
});
|
|
45
|
-
return dataPoints;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
__decorate([
|
|
49
|
-
(0, common_1.Inject)(),
|
|
50
|
-
__metadata("design:type", device_client_1.DeviceService)
|
|
51
|
-
], Json.prototype, "deviceService", void 0);
|
|
52
|
-
__decorate([
|
|
53
|
-
(0, swagger_1.ApiOperation)({
|
|
54
|
-
summary: "Post a new JSON value",
|
|
55
|
-
callbacks: {
|
|
56
|
-
result: {
|
|
57
|
-
"{$request.query#/callback}": {
|
|
58
|
-
post: {
|
|
59
|
-
requestBody: {
|
|
60
|
-
required: true,
|
|
61
|
-
content: {
|
|
62
|
-
"application/json": {
|
|
63
|
-
schema: {
|
|
64
|
-
type: "object",
|
|
65
|
-
properties: {
|
|
66
|
-
error: {
|
|
67
|
-
type: "object",
|
|
68
|
-
properties: {
|
|
69
|
-
message: {
|
|
70
|
-
type: "string",
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
tagName: {
|
|
75
|
-
type: "string",
|
|
76
|
-
},
|
|
77
|
-
modelPath: {
|
|
78
|
-
type: "string",
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
responses: {
|
|
86
|
-
"200": { description: "The server acknowledged the request" },
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
}),
|
|
93
|
-
(0, swagger_1.ApiQuery)({
|
|
94
|
-
name: "tagName",
|
|
95
|
-
description: "Prefix of device identifier (name) of data source. The actual tag names advertised to the cloud are automatically generated as this prefix plus each property JSON path. The prefix can be undefined, so that only JSON paths are used",
|
|
96
|
-
schema: { default: undefined, example: "temperature" },
|
|
97
|
-
required: false,
|
|
98
|
-
}),
|
|
99
|
-
(0, swagger_1.ApiQuery)({
|
|
100
|
-
name: "timestamp",
|
|
101
|
-
description: "Specify a timestamp (if omitted the request timestamp is used) ",
|
|
102
|
-
required: false,
|
|
103
|
-
}),
|
|
104
|
-
(0, swagger_1.ApiQuery)({
|
|
105
|
-
name: "callback",
|
|
106
|
-
description: "Specify an optional callback to be invoked when the message has been delivered",
|
|
107
|
-
schema: { type: "string", format: "uri", example: "http://localhost:30001" },
|
|
108
|
-
required: false,
|
|
109
|
-
}),
|
|
110
|
-
(0, swagger_1.ApiQuery)({
|
|
111
|
-
name: "qos",
|
|
112
|
-
description: "Specify an optional qos (by default is zeo)",
|
|
113
|
-
schema: { type: "number", minimum: 0, maximum: 2, default: 0, example: 1 },
|
|
114
|
-
required: false,
|
|
115
|
-
}),
|
|
116
|
-
(0, swagger_1.ApiBody)({
|
|
117
|
-
description: "The json value to set. Each property in the json is assigned as full tag name advertised to the cloud as ```availableTags``` the corresponding json path prefixed by ```tagName```. For instance, if ```tagName=\"tag\"``` and value is ```{ a: {b : 1 } }``` the advertised list of available tags is ```['tag.a.b']```. If ```tagName``` is undefined the advertised list of available tags is simply ```['a.b']```",
|
|
118
|
-
schema: { default: "{}", example: { Tag1: 1 } },
|
|
119
|
-
}),
|
|
120
|
-
(0, common_1.Post)(),
|
|
121
|
-
openapi.ApiResponse({ status: 201, type: [require("./dto/datapoint.dto").DataPointDTO] }),
|
|
122
|
-
__param(0, (0, common_1.Query)("tagName")),
|
|
123
|
-
__param(1, (0, common_1.Query)("timestamp")),
|
|
124
|
-
__param(2, (0, common_1.Query)("qos")),
|
|
125
|
-
__param(3, (0, common_1.Query)("callback")),
|
|
126
|
-
__param(4, (0, common_1.Body)()),
|
|
127
|
-
__metadata("design:type", Function),
|
|
128
|
-
__metadata("design:paramtypes", [Object, Object, Object, Object, Object]),
|
|
129
|
-
__metadata("design:returntype", Promise)
|
|
130
|
-
], Json.prototype, "post", null);
|
|
131
|
-
Json = Json_1 = __decorate([
|
|
132
|
-
(0, swagger_1.ApiTags)("device"),
|
|
133
|
-
(0, common_1.Controller)("/device/json/"),
|
|
134
|
-
(0, common_1.Injectable)()
|
|
135
|
-
], Json);
|
|
136
|
-
exports.Json = Json;
|
|
137
|
-
//# sourceMappingURL=json.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.controller.js","sourceRoot":"","sources":["../../../src/controllers/device/json.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;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;IACD,IAAA,iBAAO,EAAC;QACL,WAAW,EACP,wZAAwZ;QAC5Z,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE;KAClD,CAAC;IACD,IAAA,aAAI,GAAE;;IAEF,WAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;IAChB,WAAA,IAAA,cAAK,EAAC,WAAW,CAAC,CAAA;IAClB,WAAA,IAAA,cAAK,EAAC,KAAK,CAAC,CAAA;IACZ,WAAA,IAAA,cAAK,EAAC,UAAU,CAAC,CAAA;IACjB,WAAA,IAAA,aAAI,GAAE,CAAA;;;;gCAmBV;AAlGQ,IAAI;IAHhB,IAAA,iBAAO,EAAC,QAAQ,CAAC;IACjB,IAAA,mBAAU,EAAC,eAAe,CAAC;IAC3B,IAAA,mBAAU,GAAE;GACA,IAAI,CAmGhB;AAnGY,oBAAI"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DataPointDTO } from "./dto/datapoint.dto";
|
|
2
|
-
export declare class Sine {
|
|
3
|
-
private readonly l;
|
|
4
|
-
private readonly deviceService;
|
|
5
|
-
post(tagName?: string, period?: number, amplitude?: number, phase?: number): Promise<DataPointDTO[]>;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=sine.controller.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sine.controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/device/sine.controller.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,qBAGa,IAAI;IACb,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAyB;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAyBlD,IAAI,CACY,OAAO,SAAQ,EAChB,MAAM,SAAO,EACV,SAAS,SAAO,EACpB,KAAK,SAAI,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;CAa7B"}
|
|
@@ -1,81 +0,0 @@
|
|
|
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 Sine_1;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.Sine = void 0;
|
|
17
|
-
const openapi = require("@nestjs/swagger");
|
|
18
|
-
const common_1 = require("@nestjs/common");
|
|
19
|
-
const device_client_1 = require("@corvina/device-client");
|
|
20
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
21
|
-
let Sine = Sine_1 = class Sine {
|
|
22
|
-
l = new common_1.Logger(Sine_1.name);
|
|
23
|
-
deviceService;
|
|
24
|
-
async post(tagName = "Tag", period = 1000, amplitude = 1000, phase = 0) {
|
|
25
|
-
const t = Date.now();
|
|
26
|
-
const v = amplitude * Math.sin(phase + (Date.now() / period) * 2 * Math.PI);
|
|
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", device_client_1.DeviceService)
|
|
41
|
-
], Sine.prototype, "deviceService", void 0);
|
|
42
|
-
__decorate([
|
|
43
|
-
(0, swagger_1.ApiOperation)({
|
|
44
|
-
summary: "Post a new value sampled from a sine wave with the given parameters, using wall clock as time base",
|
|
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, swagger_1.ApiQuery)({
|
|
53
|
-
name: "period",
|
|
54
|
-
description: "period in ms of the sine wave",
|
|
55
|
-
required: false,
|
|
56
|
-
schema: { default: 1000 },
|
|
57
|
-
}),
|
|
58
|
-
(0, swagger_1.ApiQuery)({
|
|
59
|
-
name: "amplitude",
|
|
60
|
-
description: "amplitude of the sine wave",
|
|
61
|
-
required: false,
|
|
62
|
-
schema: { default: 1000 },
|
|
63
|
-
}),
|
|
64
|
-
(0, swagger_1.ApiQuery)({ name: "phase", description: "phase of the sine wave", required: false, schema: { default: 0 } }),
|
|
65
|
-
(0, common_1.Post)(),
|
|
66
|
-
openapi.ApiResponse({ status: 201, type: [require("./dto/datapoint.dto").DataPointDTO] }),
|
|
67
|
-
__param(0, (0, common_1.Query)("tagName")),
|
|
68
|
-
__param(1, (0, common_1.Query)("period")),
|
|
69
|
-
__param(2, (0, common_1.Query)("amplitude")),
|
|
70
|
-
__param(3, (0, common_1.Query)("phase")),
|
|
71
|
-
__metadata("design:type", Function),
|
|
72
|
-
__metadata("design:paramtypes", [Object, Object, Object, Object]),
|
|
73
|
-
__metadata("design:returntype", Promise)
|
|
74
|
-
], Sine.prototype, "post", null);
|
|
75
|
-
Sine = Sine_1 = __decorate([
|
|
76
|
-
(0, swagger_1.ApiTags)("device"),
|
|
77
|
-
(0, common_1.Controller)("/device/sine"),
|
|
78
|
-
(0, common_1.Injectable)()
|
|
79
|
-
], Sine);
|
|
80
|
-
exports.Sine = Sine;
|
|
81
|
-
//# sourceMappingURL=sine.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sine.controller.js","sourceRoot":"","sources":["../../../src/controllers/device/sine.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAqF;AACrF,0DAAuD;AAEvD,6CAAkE;AAMlE,IAAa,IAAI,YAAjB,MAAa,IAAI;IACI,CAAC,GAAG,IAAI,eAAM,CAAC,MAAI,CAAC,IAAI,CAAC,CAAC;IAChB,aAAa,CAAgB;IAyBxD,KAAK,CAAC,IAAI,CACY,UAAU,KAAK,EAChB,SAAS,IAAI,EACV,YAAY,IAAI,EACpB,QAAQ,CAAC;QAEzB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5E,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;AA3Ca;IAAT,IAAA,eAAM,GAAE;8BAAiC,6BAAa;2CAAC;;IAEvD,IAAA,sBAAY,EAAC;QACV,OAAO,EAAE,oGAAoG;KAChH,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,kBAAQ,EAAC;QACN,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,+BAA+B;QAC5C,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;KAC5B,CAAC;IACD,IAAA,kBAAQ,EAAC;QACN,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,4BAA4B;QACzC,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;KAC5B,CAAC;IACD,IAAA,kBAAQ,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;IAC3G,IAAA,aAAI,GAAE;;IAEF,WAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;IAChB,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;IACf,WAAA,IAAA,cAAK,EAAC,WAAW,CAAC,CAAA;IAClB,WAAA,IAAA,cAAK,EAAC,OAAO,CAAC,CAAA;;;;gCAalB;AA5CQ,IAAI;IAHhB,IAAA,iBAAO,EAAC,QAAQ,CAAC;IACjB,IAAA,mBAAU,EAAC,cAAc,CAAC;IAC1B,IAAA,mBAAU,GAAE;GACA,IAAI,CA6ChB;AA7CY,oBAAI"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DeviceHealthIndicator } from "../services/device.health";
|
|
2
|
-
import { HealthCheckService } from "@nestjs/terminus";
|
|
3
|
-
export declare class HealthController {
|
|
4
|
-
private health;
|
|
5
|
-
private deviceHealthIndicator;
|
|
6
|
-
constructor(health: HealthCheckService, deviceHealthIndicator: DeviceHealthIndicator);
|
|
7
|
-
check(): Promise<import("@nestjs/terminus").HealthCheckResult>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=health.controller.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"health.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/health.controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAe,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEnE,qBACa,gBAAgB;IACb,OAAO,CAAC,MAAM;IAAsB,OAAO,CAAC,qBAAqB;gBAAzD,MAAM,EAAE,kBAAkB,EAAU,qBAAqB,EAAE,qBAAqB;IAIpG,KAAK;CAGR"}
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.HealthController = void 0;
|
|
13
|
-
const openapi = require("@nestjs/swagger");
|
|
14
|
-
const common_1 = require("@nestjs/common");
|
|
15
|
-
const device_health_1 = require("../services/device.health");
|
|
16
|
-
const terminus_1 = require("@nestjs/terminus");
|
|
17
|
-
let HealthController = class HealthController {
|
|
18
|
-
health;
|
|
19
|
-
deviceHealthIndicator;
|
|
20
|
-
constructor(health, deviceHealthIndicator) {
|
|
21
|
-
this.health = health;
|
|
22
|
-
this.deviceHealthIndicator = deviceHealthIndicator;
|
|
23
|
-
}
|
|
24
|
-
check() {
|
|
25
|
-
return this.health.check([async () => this.deviceHealthIndicator.isHealthy("device")]);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
__decorate([
|
|
29
|
-
(0, common_1.Get)(),
|
|
30
|
-
(0, terminus_1.HealthCheck)(),
|
|
31
|
-
openapi.ApiResponse({ status: 200, type: Object }),
|
|
32
|
-
__metadata("design:type", Function),
|
|
33
|
-
__metadata("design:paramtypes", []),
|
|
34
|
-
__metadata("design:returntype", void 0)
|
|
35
|
-
], HealthController.prototype, "check", null);
|
|
36
|
-
HealthController = __decorate([
|
|
37
|
-
(0, common_1.Controller)("health"),
|
|
38
|
-
__metadata("design:paramtypes", [terminus_1.HealthCheckService, device_health_1.DeviceHealthIndicator])
|
|
39
|
-
], HealthController);
|
|
40
|
-
exports.HealthController = HealthController;
|
|
41
|
-
//# sourceMappingURL=health.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"health.controller.js","sourceRoot":"","sources":["../../src/controllers/health.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAiD;AACjD,6DAAkE;AAClE,+CAAmE;AAGnE,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IACL;IAAoC;IAAxD,YAAoB,MAA0B,EAAU,qBAA4C;QAAhF,WAAM,GAAN,MAAM,CAAoB;QAAU,0BAAqB,GAArB,qBAAqB,CAAuB;IAAG,CAAC;IAIxG,KAAK;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC3F,CAAC;CACJ,CAAA;;IALI,IAAA,YAAG,GAAE;IACL,IAAA,sBAAW,GAAE;;;;;6CAGb;AAPQ,gBAAgB;IAD5B,IAAA,mBAAU,EAAC,QAAQ,CAAC;qCAEW,6BAAkB,EAAiC,qCAAqB;GAD3F,gBAAgB,CAQ5B;AARY,4CAAgB"}
|
package/dist/main.d.ts
DELETED
package/dist/main.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
|
package/dist/main.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const core_1 = require("@nestjs/core");
|
|
7
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
8
|
-
const axios_1 = __importDefault(require("axios"));
|
|
9
|
-
const app_module_1 = require("./app.module");
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const nestjs_pino_1 = require("nestjs-pino");
|
|
12
|
-
const device_client_1 = require("@corvina/device-client");
|
|
13
|
-
async function bootstrap() {
|
|
14
|
-
const app = await core_1.NestFactory.create(app_module_1.AppModule, {
|
|
15
|
-
bufferLogs: false,
|
|
16
|
-
});
|
|
17
|
-
const pinoLogger = app.get(nestjs_pino_1.Logger);
|
|
18
|
-
app.useLogger(pinoLogger);
|
|
19
|
-
const l = new common_1.Logger("example");
|
|
20
|
-
try {
|
|
21
|
-
const config = new swagger_1.DocumentBuilder()
|
|
22
|
-
.setTitle("Corvina NodeJS device API")
|
|
23
|
-
.setDescription("")
|
|
24
|
-
.setVersion("1.0")
|
|
25
|
-
.addTag("device")
|
|
26
|
-
.build();
|
|
27
|
-
const document = swagger_1.SwaggerModule.createDocument(app, config);
|
|
28
|
-
swagger_1.SwaggerModule.setup("swagger-ui", app, document);
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
l.error("Error caught: ");
|
|
32
|
-
l.error(e);
|
|
33
|
-
}
|
|
34
|
-
await app.listen(process.env.PORT || 3000);
|
|
35
|
-
app.get(device_client_1.DeviceRunnerService).run();
|
|
36
|
-
const device = app.get(device_client_1.DeviceService);
|
|
37
|
-
device.on("ready", (event) => {
|
|
38
|
-
l.log("Device is ready to transmit data");
|
|
39
|
-
});
|
|
40
|
-
device.on("not_ready", (event) => {
|
|
41
|
-
l.log("Device is not ready to transmit data");
|
|
42
|
-
});
|
|
43
|
-
device.on("write", (event) => {
|
|
44
|
-
l.log(`Write event received ${JSON.stringify(event)}`);
|
|
45
|
-
const t = Date.now();
|
|
46
|
-
const dataPoints = new Array();
|
|
47
|
-
const dp = {
|
|
48
|
-
tagName: event.tagName,
|
|
49
|
-
value: event.v,
|
|
50
|
-
timestamp: t,
|
|
51
|
-
};
|
|
52
|
-
dataPoints.push(dp);
|
|
53
|
-
device.post(dataPoints, {
|
|
54
|
-
qos: 0,
|
|
55
|
-
cb: process.env["WRITE_CALLBACK"]
|
|
56
|
-
? (error, tagName, modelPath) => {
|
|
57
|
-
axios_1.default.post(process.env["WRITE_CALLBACK"], event).catch((err) => "Error executing write callback");
|
|
58
|
-
}
|
|
59
|
-
: undefined,
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
bootstrap();
|
|
64
|
-
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;AAAA,uCAA2C;AAC3C,6CAAiE;AACjE,kDAA0B;AAC1B,6CAAyC;AACzC,2CAAuD;AACvD,6CAAuD;AACvD,0DAAuF;AAEvF,KAAK,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;QAC7B,CAAC,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QACzB,CAAC,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAEvD,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACrB,MAAM,UAAU,GAAG,IAAI,KAAK,EAAa,CAAC;QAC1C,MAAM,EAAE,GAAc;YAClB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,KAAK,EAAE,KAAK,CAAC,CAAC;YACd,SAAS,EAAE,CAAC;SACf,CAAC;QACF,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,GAAG,EAAE,CAAC;YACN,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;gBAC7B,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE;oBAC5B,eAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,gCAAgC,CAAC,CAAC;gBACtG,CAAC;gBACD,CAAC,CAAC,SAAS;SAClB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AACD,SAAS,EAAE,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { HealthIndicatorResult, HealthIndicator } from "@nestjs/terminus";
|
|
2
|
-
import { DeviceService } from "@corvina/device-client";
|
|
3
|
-
export declare class DeviceHealthIndicator extends HealthIndicator {
|
|
4
|
-
private readonly deviceService;
|
|
5
|
-
constructor(deviceService: DeviceService);
|
|
6
|
-
isHealthy(key: string): Promise<HealthIndicatorResult>;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=device.health.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"device.health.d.ts","sourceRoot":"","sources":["../../src/services/device.health.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAoB,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,qBACa,qBAAsB,SAAQ,eAAe;IAC1C,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAInD,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAS/D"}
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DeviceHealthIndicator = void 0;
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const terminus_1 = require("@nestjs/terminus");
|
|
15
|
-
const device_client_1 = require("@corvina/device-client");
|
|
16
|
-
let DeviceHealthIndicator = class DeviceHealthIndicator extends terminus_1.HealthIndicator {
|
|
17
|
-
deviceService;
|
|
18
|
-
constructor(deviceService) {
|
|
19
|
-
super();
|
|
20
|
-
this.deviceService = deviceService;
|
|
21
|
-
}
|
|
22
|
-
async isHealthy(key) {
|
|
23
|
-
const isHealthy = this.deviceService.status.ready == true;
|
|
24
|
-
const result = this.getStatus(key, isHealthy, this.deviceService.status);
|
|
25
|
-
if (this.deviceService.isReady) {
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
throw new terminus_1.HealthCheckError("Device not ready", result);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
DeviceHealthIndicator = __decorate([
|
|
32
|
-
(0, common_1.Injectable)(),
|
|
33
|
-
__metadata("design:paramtypes", [device_client_1.DeviceService])
|
|
34
|
-
], DeviceHealthIndicator);
|
|
35
|
-
exports.DeviceHealthIndicator = DeviceHealthIndicator;
|
|
36
|
-
//# sourceMappingURL=device.health.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"device.health.js","sourceRoot":"","sources":["../../src/services/device.health.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA4F;AAC5F,0DAAuD;AAGvD,IAAa,qBAAqB,GAAlC,MAAa,qBAAsB,SAAQ,0BAAe;IACzB;IAA7B,YAA6B,aAA4B;QACrD,KAAK,EAAE,CAAC;QADiB,kBAAa,GAAb,aAAa,CAAe;IAEzD,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,GAAW;QACvB,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC;QAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAEzE,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;YAC5B,OAAO,MAAM,CAAC;SACjB;QACD,MAAM,IAAI,2BAAgB,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;CACJ,CAAA;AAdY,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAEmC,6BAAa;GADhD,qBAAqB,CAcjC;AAdY,sDAAqB"}
|
package/ignore
DELETED
|
File without changes
|
package/main-linux
DELETED
|
Binary file
|
package/main-macos
DELETED
|
Binary file
|
package/main-win.exe
DELETED
|
Binary file
|