@ricado/api-client 2.5.13 → 2.5.15
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/ricado.api.client.js +1 -1
- package/lib/Controllers/RTUController.js +229 -0
- package/lib/PackageVersion.js +1 -1
- package/lib/WebSocketHelper.js +2 -3
- package/lib/index.d.ts +5305 -5251
- package/package.json +2 -2
- package/src/Controllers/RTUController.js +271 -0
- package/src/PackageVersion.js +1 -1
- package/src/WebSocketHelper.js +0 -2
|
@@ -11,6 +11,8 @@ var _RTUModel = _interopRequireDefault(require("../Models/RTUModel"));
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
15
|
+
|
|
14
16
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
17
|
|
|
16
18
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -96,6 +98,104 @@ var RTUController = /*#__PURE__*/function () {
|
|
|
96
98
|
});
|
|
97
99
|
});
|
|
98
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Retrieve the Status of an RTU [GET /rtus/{id}/status]
|
|
103
|
+
*
|
|
104
|
+
* @static
|
|
105
|
+
* @public
|
|
106
|
+
* @param {number} id The RTU ID
|
|
107
|
+
* @return {Promise<RTUController.RTUStatusItem>}
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
}, {
|
|
111
|
+
key: "getOneStatus",
|
|
112
|
+
value: function getOneStatus(id) {
|
|
113
|
+
return new Promise(function (resolve, reject) {
|
|
114
|
+
_RequestHelper.default.getRequest("/rtus/".concat(id, "/status")).then(function (result) {
|
|
115
|
+
var resolveValue = function () {
|
|
116
|
+
var resultObject = {};
|
|
117
|
+
|
|
118
|
+
if (_typeof(result) === 'object' && 'id' in result) {
|
|
119
|
+
resultObject.id = function () {
|
|
120
|
+
if (typeof result.id !== 'number') {
|
|
121
|
+
return Number.isInteger(Number(result.id)) ? Number(result.id) : Math.floor(Number(result.id));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return Number.isInteger(result.id) ? result.id : Math.floor(result.id);
|
|
125
|
+
}();
|
|
126
|
+
} else {
|
|
127
|
+
resultObject.id = 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (_typeof(result) === 'object' && 'latency' in result) {
|
|
131
|
+
resultObject.latency = function () {
|
|
132
|
+
if (result.latency === null) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (typeof result.latency !== 'number') {
|
|
137
|
+
return Number(result.latency);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return result.latency;
|
|
141
|
+
}();
|
|
142
|
+
} else {
|
|
143
|
+
resultObject.latency = null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (_typeof(result) === 'object' && 'latencyTimestamp' in result) {
|
|
147
|
+
resultObject.latencyTimestamp = function () {
|
|
148
|
+
if (result.latencyTimestamp === null) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (typeof result.latencyTimestamp !== 'string') {
|
|
153
|
+
return new Date(String(result.latencyTimestamp));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return new Date(result.latencyTimestamp);
|
|
157
|
+
}();
|
|
158
|
+
} else {
|
|
159
|
+
resultObject.latencyTimestamp = null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (_typeof(result) === 'object' && 'lastSeenTimestamp' in result) {
|
|
163
|
+
resultObject.lastSeenTimestamp = function () {
|
|
164
|
+
if (result.lastSeenTimestamp === null) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (typeof result.lastSeenTimestamp !== 'string') {
|
|
169
|
+
return new Date(String(result.lastSeenTimestamp));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return new Date(result.lastSeenTimestamp);
|
|
173
|
+
}();
|
|
174
|
+
} else {
|
|
175
|
+
resultObject.lastSeenTimestamp = null;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (_typeof(result) === 'object' && 'onlineStatus' in result) {
|
|
179
|
+
resultObject.onlineStatus = function () {
|
|
180
|
+
if (typeof result.onlineStatus !== 'boolean') {
|
|
181
|
+
return Boolean(result.onlineStatus);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return result.onlineStatus;
|
|
185
|
+
}();
|
|
186
|
+
} else {
|
|
187
|
+
resultObject.onlineStatus = false;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return resultObject;
|
|
191
|
+
}();
|
|
192
|
+
|
|
193
|
+
resolve(resolveValue);
|
|
194
|
+
}).catch(function (error) {
|
|
195
|
+
return reject(error);
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
}
|
|
99
199
|
/**
|
|
100
200
|
* List all RTUs [GET /rtus]
|
|
101
201
|
*
|
|
@@ -147,6 +247,115 @@ var RTUController = /*#__PURE__*/function () {
|
|
|
147
247
|
return _RTUModel.default.fromJSON(result);
|
|
148
248
|
}();
|
|
149
249
|
|
|
250
|
+
resolve(resolveValue);
|
|
251
|
+
}).catch(function (error) {
|
|
252
|
+
return reject(error);
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Retrieve the Statuses of all RTUs [GET /rtus/statuses]
|
|
258
|
+
*
|
|
259
|
+
* An Array of Statuses for all RTUs
|
|
260
|
+
*
|
|
261
|
+
* @static
|
|
262
|
+
* @public
|
|
263
|
+
* @param {RTUController.GetAllStatusesQueryParameters} [queryParameters] The Optional Query Parameters
|
|
264
|
+
* @return {Promise<Array<RTUController.RTUStatusItem>>}
|
|
265
|
+
*/
|
|
266
|
+
|
|
267
|
+
}, {
|
|
268
|
+
key: "getAllStatuses",
|
|
269
|
+
value: function getAllStatuses() {
|
|
270
|
+
var queryParameters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
271
|
+
return new Promise(function (resolve, reject) {
|
|
272
|
+
_RequestHelper.default.getRequest("/rtus/statuses", queryParameters).then(function (result) {
|
|
273
|
+
var resolveValue = function () {
|
|
274
|
+
if (Array.isArray(result) !== true) {
|
|
275
|
+
return [];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return result.map(function (resultItem) {
|
|
279
|
+
return function () {
|
|
280
|
+
var resultItemObject = {};
|
|
281
|
+
|
|
282
|
+
if (_typeof(resultItem) === 'object' && 'id' in resultItem) {
|
|
283
|
+
resultItemObject.id = function () {
|
|
284
|
+
if (typeof resultItem.id !== 'number') {
|
|
285
|
+
return Number.isInteger(Number(resultItem.id)) ? Number(resultItem.id) : Math.floor(Number(resultItem.id));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return Number.isInteger(resultItem.id) ? resultItem.id : Math.floor(resultItem.id);
|
|
289
|
+
}();
|
|
290
|
+
} else {
|
|
291
|
+
resultItemObject.id = 0;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (_typeof(resultItem) === 'object' && 'latency' in resultItem) {
|
|
295
|
+
resultItemObject.latency = function () {
|
|
296
|
+
if (resultItem.latency === null) {
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (typeof resultItem.latency !== 'number') {
|
|
301
|
+
return Number(resultItem.latency);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return resultItem.latency;
|
|
305
|
+
}();
|
|
306
|
+
} else {
|
|
307
|
+
resultItemObject.latency = null;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (_typeof(resultItem) === 'object' && 'latencyTimestamp' in resultItem) {
|
|
311
|
+
resultItemObject.latencyTimestamp = function () {
|
|
312
|
+
if (resultItem.latencyTimestamp === null) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (typeof resultItem.latencyTimestamp !== 'string') {
|
|
317
|
+
return new Date(String(resultItem.latencyTimestamp));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return new Date(resultItem.latencyTimestamp);
|
|
321
|
+
}();
|
|
322
|
+
} else {
|
|
323
|
+
resultItemObject.latencyTimestamp = null;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (_typeof(resultItem) === 'object' && 'lastSeenTimestamp' in resultItem) {
|
|
327
|
+
resultItemObject.lastSeenTimestamp = function () {
|
|
328
|
+
if (resultItem.lastSeenTimestamp === null) {
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (typeof resultItem.lastSeenTimestamp !== 'string') {
|
|
333
|
+
return new Date(String(resultItem.lastSeenTimestamp));
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return new Date(resultItem.lastSeenTimestamp);
|
|
337
|
+
}();
|
|
338
|
+
} else {
|
|
339
|
+
resultItemObject.lastSeenTimestamp = null;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (_typeof(resultItem) === 'object' && 'onlineStatus' in resultItem) {
|
|
343
|
+
resultItemObject.onlineStatus = function () {
|
|
344
|
+
if (typeof resultItem.onlineStatus !== 'boolean') {
|
|
345
|
+
return Boolean(resultItem.onlineStatus);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return resultItem.onlineStatus;
|
|
349
|
+
}();
|
|
350
|
+
} else {
|
|
351
|
+
resultItemObject.onlineStatus = false;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return resultItemObject;
|
|
355
|
+
}();
|
|
356
|
+
});
|
|
357
|
+
}();
|
|
358
|
+
|
|
150
359
|
resolve(resolveValue);
|
|
151
360
|
}).catch(function (error) {
|
|
152
361
|
return reject(error);
|
|
@@ -169,6 +378,14 @@ var _default = RTUController;
|
|
|
169
378
|
* @memberof Controllers
|
|
170
379
|
*/
|
|
171
380
|
|
|
381
|
+
/**
|
|
382
|
+
* The Optional Query Parameters for the getAllStatuses Function
|
|
383
|
+
*
|
|
384
|
+
* @typedef {Object} RTUController.GetAllStatusesQueryParameters
|
|
385
|
+
* @property {number[]} [rtuIds] A List of RTU IDs to Filter by
|
|
386
|
+
* @memberof Controllers
|
|
387
|
+
*/
|
|
388
|
+
|
|
172
389
|
/**
|
|
173
390
|
* The Create Data for a RTU
|
|
174
391
|
*
|
|
@@ -188,4 +405,16 @@ var _default = RTUController;
|
|
|
188
405
|
* @memberof Controllers
|
|
189
406
|
*/
|
|
190
407
|
|
|
408
|
+
/**
|
|
409
|
+
* A **RTUStatusItem** Type
|
|
410
|
+
*
|
|
411
|
+
* @typedef {Object} RTUController.RTUStatusItem
|
|
412
|
+
* @property {number} id ID of the RTU
|
|
413
|
+
* @property {?number} latency Round-Trip Latency of the RTU represented in milliseconds
|
|
414
|
+
* @property {?Date} latencyTimestamp When the Latency was last Updated
|
|
415
|
+
* @property {?Date} lastSeenTimestamp When the Last Message was Received from the RTU
|
|
416
|
+
* @property {boolean} onlineStatus Whether the RTU is considered as Online
|
|
417
|
+
* @memberof Controllers
|
|
418
|
+
*/
|
|
419
|
+
|
|
191
420
|
exports.default = _default;
|
package/lib/PackageVersion.js
CHANGED
package/lib/WebSocketHelper.js
CHANGED
|
@@ -76,9 +76,8 @@ var WebSocketHelper = /*#__PURE__*/function () {
|
|
|
76
76
|
query: {
|
|
77
77
|
token: _index.JWT
|
|
78
78
|
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
var onEvent = WebSocketHelper._socket.onevent; // @ts-expect-error
|
|
79
|
+
});
|
|
80
|
+
var onEvent = WebSocketHelper._socket.onevent;
|
|
82
81
|
|
|
83
82
|
WebSocketHelper._socket.onevent = function (packet) {
|
|
84
83
|
var args = packet.data || [];
|