@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ricado/api-client",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.15",
|
|
4
4
|
"description": "RICADO Gen 4 API Client Library for NodeJS and Browsers",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ash Neilson"
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"jsdoc-memberof-namespace": "^2.2.0",
|
|
61
61
|
"rimraf": "^3.0.2",
|
|
62
62
|
"tidy-jsdoc": "^1.4.0",
|
|
63
|
-
"typescript": "
|
|
63
|
+
"typescript": "4.0",
|
|
64
64
|
"webpack": "^5.43.0",
|
|
65
65
|
"webpack-bundle-analyzer": "^4.4.2",
|
|
66
66
|
"webpack-cli": "^4.7.2"
|
|
@@ -80,6 +80,126 @@ class RTUController
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Retrieve the Status of an RTU [GET /rtus/{id}/status]
|
|
85
|
+
*
|
|
86
|
+
* @static
|
|
87
|
+
* @public
|
|
88
|
+
* @param {number} id The RTU ID
|
|
89
|
+
* @return {Promise<RTUController.RTUStatusItem>}
|
|
90
|
+
*/
|
|
91
|
+
static getOneStatus(id)
|
|
92
|
+
{
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
RequestHelper.getRequest(`/rtus/${id}/status`)
|
|
95
|
+
.then((result) => {
|
|
96
|
+
let resolveValue = (function(){
|
|
97
|
+
let resultObject = {};
|
|
98
|
+
|
|
99
|
+
if(typeof result === 'object' && 'id' in result)
|
|
100
|
+
{
|
|
101
|
+
resultObject.id = (function(){
|
|
102
|
+
if(typeof result.id !== 'number')
|
|
103
|
+
{
|
|
104
|
+
return Number.isInteger(Number(result.id)) ? Number(result.id) : Math.floor(Number(result.id));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return Number.isInteger(result.id) ? result.id : Math.floor(result.id);
|
|
108
|
+
}());
|
|
109
|
+
}
|
|
110
|
+
else
|
|
111
|
+
{
|
|
112
|
+
resultObject.id = 0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if(typeof result === 'object' && 'latency' in result)
|
|
116
|
+
{
|
|
117
|
+
resultObject.latency = (function(){
|
|
118
|
+
if(result.latency === null)
|
|
119
|
+
{
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if(typeof result.latency !== 'number')
|
|
124
|
+
{
|
|
125
|
+
return Number(result.latency);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return result.latency;
|
|
129
|
+
}());
|
|
130
|
+
}
|
|
131
|
+
else
|
|
132
|
+
{
|
|
133
|
+
resultObject.latency = null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if(typeof result === 'object' && 'latencyTimestamp' in result)
|
|
137
|
+
{
|
|
138
|
+
resultObject.latencyTimestamp = (function(){
|
|
139
|
+
if(result.latencyTimestamp === null)
|
|
140
|
+
{
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if(typeof result.latencyTimestamp !== 'string')
|
|
145
|
+
{
|
|
146
|
+
return new Date(String(result.latencyTimestamp));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return new Date(result.latencyTimestamp);
|
|
150
|
+
}());
|
|
151
|
+
}
|
|
152
|
+
else
|
|
153
|
+
{
|
|
154
|
+
resultObject.latencyTimestamp = null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if(typeof result === 'object' && 'lastSeenTimestamp' in result)
|
|
158
|
+
{
|
|
159
|
+
resultObject.lastSeenTimestamp = (function(){
|
|
160
|
+
if(result.lastSeenTimestamp === null)
|
|
161
|
+
{
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if(typeof result.lastSeenTimestamp !== 'string')
|
|
166
|
+
{
|
|
167
|
+
return new Date(String(result.lastSeenTimestamp));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return new Date(result.lastSeenTimestamp);
|
|
171
|
+
}());
|
|
172
|
+
}
|
|
173
|
+
else
|
|
174
|
+
{
|
|
175
|
+
resultObject.lastSeenTimestamp = null;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if(typeof result === 'object' && 'onlineStatus' in result)
|
|
179
|
+
{
|
|
180
|
+
resultObject.onlineStatus = (function(){
|
|
181
|
+
if(typeof result.onlineStatus !== 'boolean')
|
|
182
|
+
{
|
|
183
|
+
return Boolean(result.onlineStatus);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return result.onlineStatus;
|
|
187
|
+
}());
|
|
188
|
+
}
|
|
189
|
+
else
|
|
190
|
+
{
|
|
191
|
+
resultObject.onlineStatus = false;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return resultObject;
|
|
195
|
+
}());
|
|
196
|
+
|
|
197
|
+
resolve(resolveValue);
|
|
198
|
+
})
|
|
199
|
+
.catch(error => reject(error));
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
83
203
|
/**
|
|
84
204
|
* List all RTUs [GET /rtus]
|
|
85
205
|
*
|
|
@@ -134,6 +254,137 @@ class RTUController
|
|
|
134
254
|
.catch(error => reject(error));
|
|
135
255
|
});
|
|
136
256
|
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Retrieve the Statuses of all RTUs [GET /rtus/statuses]
|
|
260
|
+
*
|
|
261
|
+
* An Array of Statuses for all RTUs
|
|
262
|
+
*
|
|
263
|
+
* @static
|
|
264
|
+
* @public
|
|
265
|
+
* @param {RTUController.GetAllStatusesQueryParameters} [queryParameters] The Optional Query Parameters
|
|
266
|
+
* @return {Promise<Array<RTUController.RTUStatusItem>>}
|
|
267
|
+
*/
|
|
268
|
+
static getAllStatuses(queryParameters = {})
|
|
269
|
+
{
|
|
270
|
+
return new Promise((resolve, reject) => {
|
|
271
|
+
RequestHelper.getRequest(`/rtus/statuses`, queryParameters)
|
|
272
|
+
.then((result) => {
|
|
273
|
+
let resolveValue = (function(){
|
|
274
|
+
if(Array.isArray(result) !== true)
|
|
275
|
+
{
|
|
276
|
+
return [];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return result.map((resultItem) => {
|
|
280
|
+
return (function(){
|
|
281
|
+
let resultItemObject = {};
|
|
282
|
+
|
|
283
|
+
if(typeof resultItem === 'object' && 'id' in resultItem)
|
|
284
|
+
{
|
|
285
|
+
resultItemObject.id = (function(){
|
|
286
|
+
if(typeof resultItem.id !== 'number')
|
|
287
|
+
{
|
|
288
|
+
return Number.isInteger(Number(resultItem.id)) ? Number(resultItem.id) : Math.floor(Number(resultItem.id));
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return Number.isInteger(resultItem.id) ? resultItem.id : Math.floor(resultItem.id);
|
|
292
|
+
}());
|
|
293
|
+
}
|
|
294
|
+
else
|
|
295
|
+
{
|
|
296
|
+
resultItemObject.id = 0;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if(typeof resultItem === 'object' && 'latency' in resultItem)
|
|
300
|
+
{
|
|
301
|
+
resultItemObject.latency = (function(){
|
|
302
|
+
if(resultItem.latency === null)
|
|
303
|
+
{
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if(typeof resultItem.latency !== 'number')
|
|
308
|
+
{
|
|
309
|
+
return Number(resultItem.latency);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return resultItem.latency;
|
|
313
|
+
}());
|
|
314
|
+
}
|
|
315
|
+
else
|
|
316
|
+
{
|
|
317
|
+
resultItemObject.latency = null;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if(typeof resultItem === 'object' && 'latencyTimestamp' in resultItem)
|
|
321
|
+
{
|
|
322
|
+
resultItemObject.latencyTimestamp = (function(){
|
|
323
|
+
if(resultItem.latencyTimestamp === null)
|
|
324
|
+
{
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
if(typeof resultItem.latencyTimestamp !== 'string')
|
|
329
|
+
{
|
|
330
|
+
return new Date(String(resultItem.latencyTimestamp));
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return new Date(resultItem.latencyTimestamp);
|
|
334
|
+
}());
|
|
335
|
+
}
|
|
336
|
+
else
|
|
337
|
+
{
|
|
338
|
+
resultItemObject.latencyTimestamp = null;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if(typeof resultItem === 'object' && 'lastSeenTimestamp' in resultItem)
|
|
342
|
+
{
|
|
343
|
+
resultItemObject.lastSeenTimestamp = (function(){
|
|
344
|
+
if(resultItem.lastSeenTimestamp === null)
|
|
345
|
+
{
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if(typeof resultItem.lastSeenTimestamp !== 'string')
|
|
350
|
+
{
|
|
351
|
+
return new Date(String(resultItem.lastSeenTimestamp));
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return new Date(resultItem.lastSeenTimestamp);
|
|
355
|
+
}());
|
|
356
|
+
}
|
|
357
|
+
else
|
|
358
|
+
{
|
|
359
|
+
resultItemObject.lastSeenTimestamp = null;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if(typeof resultItem === 'object' && 'onlineStatus' in resultItem)
|
|
363
|
+
{
|
|
364
|
+
resultItemObject.onlineStatus = (function(){
|
|
365
|
+
if(typeof resultItem.onlineStatus !== 'boolean')
|
|
366
|
+
{
|
|
367
|
+
return Boolean(resultItem.onlineStatus);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return resultItem.onlineStatus;
|
|
371
|
+
}());
|
|
372
|
+
}
|
|
373
|
+
else
|
|
374
|
+
{
|
|
375
|
+
resultItemObject.onlineStatus = false;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return resultItemObject;
|
|
379
|
+
}());
|
|
380
|
+
});
|
|
381
|
+
}());
|
|
382
|
+
|
|
383
|
+
resolve(resolveValue);
|
|
384
|
+
})
|
|
385
|
+
.catch(error => reject(error));
|
|
386
|
+
});
|
|
387
|
+
}
|
|
137
388
|
}
|
|
138
389
|
|
|
139
390
|
export default RTUController;
|
|
@@ -148,6 +399,14 @@ export default RTUController;
|
|
|
148
399
|
* @memberof Controllers
|
|
149
400
|
*/
|
|
150
401
|
|
|
402
|
+
/**
|
|
403
|
+
* The Optional Query Parameters for the getAllStatuses Function
|
|
404
|
+
*
|
|
405
|
+
* @typedef {Object} RTUController.GetAllStatusesQueryParameters
|
|
406
|
+
* @property {number[]} [rtuIds] A List of RTU IDs to Filter by
|
|
407
|
+
* @memberof Controllers
|
|
408
|
+
*/
|
|
409
|
+
|
|
151
410
|
/**
|
|
152
411
|
* The Create Data for a RTU
|
|
153
412
|
*
|
|
@@ -165,4 +424,16 @@ export default RTUController;
|
|
|
165
424
|
* @property {string} [name] The RTU Name
|
|
166
425
|
* @property {boolean} [enabled] Whether the RTU is Enabled
|
|
167
426
|
* @memberof Controllers
|
|
427
|
+
*/
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* A **RTUStatusItem** Type
|
|
431
|
+
*
|
|
432
|
+
* @typedef {Object} RTUController.RTUStatusItem
|
|
433
|
+
* @property {number} id ID of the RTU
|
|
434
|
+
* @property {?number} latency Round-Trip Latency of the RTU represented in milliseconds
|
|
435
|
+
* @property {?Date} latencyTimestamp When the Latency was last Updated
|
|
436
|
+
* @property {?Date} lastSeenTimestamp When the Last Message was Received from the RTU
|
|
437
|
+
* @property {boolean} onlineStatus Whether the RTU is considered as Online
|
|
438
|
+
* @memberof Controllers
|
|
168
439
|
*/
|
package/src/PackageVersion.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '2.5.
|
|
2
|
+
export const version = '2.5.15';
|
package/src/WebSocketHelper.js
CHANGED
|
@@ -59,10 +59,8 @@ class WebSocketHelper
|
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
// @ts-expect-error
|
|
63
62
|
var onEvent = WebSocketHelper._socket.onevent;
|
|
64
63
|
|
|
65
|
-
// @ts-expect-error
|
|
66
64
|
WebSocketHelper._socket.onevent = function (packet) {
|
|
67
65
|
var args = packet.data || [];
|
|
68
66
|
onEvent.call (this, packet); // original call
|