@ricado/api-client 1.2.5 → 1.4.1
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/Site/PointController.js +2 -0
- package/lib/Errors/BadRequestError.js +1 -1
- package/lib/Errors/ForbiddenError.js +1 -1
- package/lib/Errors/NetworkError.js +1 -1
- package/lib/Errors/NotAllowedError.js +1 -1
- package/lib/Errors/NotFoundError.js +1 -1
- package/lib/Errors/ServerError.js +1 -1
- package/lib/Errors/UnauthorizedError.js +1 -1
- package/lib/Models/AccountPolicyModel.js +1 -1
- package/lib/Models/ApiAccountModel.js +1 -1
- package/lib/Models/CompanyModel.js +1 -1
- package/lib/Models/FirebaseTokenModel.js +1 -1
- package/lib/Models/Packhouse/Site/BinTipWeightModel.js +1 -1
- package/lib/Models/Packhouse/Site/CompacSizerBatchModel.js +1 -1
- package/lib/Models/Packhouse/Site/CompacSizerModel.js +1 -1
- package/lib/Models/Packhouse/Site/CompacSizerOutletProductChangeModel.js +1 -1
- package/lib/Models/Packhouse/Site/CompacSizerOutletTypeChangeModel.js +1 -1
- package/lib/Models/Packhouse/Site/CompacSizerOutletTypeModel.js +1 -1
- package/lib/Models/Packhouse/Site/CompacSizerPackrunSummaryModel.js +1 -1
- package/lib/Models/Packhouse/Site/DowntimeEventModel.js +1 -1
- package/lib/Models/Packhouse/Site/FreshPackPackrunSummaryModel.js +1 -1
- package/lib/Models/Packhouse/Site/GrowingMethodModel.js +1 -1
- package/lib/Models/Packhouse/Site/PackTypeModel.js +1 -1
- package/lib/Models/Packhouse/Site/PackingLineModel.js +1 -1
- package/lib/Models/Packhouse/Site/PackrunModel.js +1 -1
- package/lib/Models/Packhouse/Site/RejectBinModel.js +1 -1
- package/lib/Models/Packhouse/Site/RejectBinScaleModel.js +1 -1
- package/lib/Models/Packhouse/Site/RejectBinWeightModel.js +1 -1
- package/lib/Models/Packhouse/Site/ShiftFocusMeetingModel.js +1 -1
- package/lib/Models/Packhouse/Site/ShiftHourlyEntryModel.js +1 -1
- package/lib/Models/Packhouse/Site/ShiftModel.js +1 -1
- package/lib/Models/Packhouse/Site/VarietyModel.js +1 -1
- package/lib/Models/RTUModel.js +1 -1
- package/lib/Models/RTUPluginModel.js +1 -1
- package/lib/Models/Site/AlarmGroupModel.js +1 -1
- package/lib/Models/Site/AlarmModel.js +1 -1
- package/lib/Models/Site/BaseSiteModel.js +1 -1
- package/lib/Models/Site/DefinitionModel.js +1 -1
- package/lib/Models/Site/PermanentObjectDataModel.js +1 -1
- package/lib/Models/Site/PermanentObjectModel.js +1 -1
- package/lib/Models/Site/PointModel.js +1 -1
- package/lib/Models/Site/TemporaryObjectModel.js +1 -1
- package/lib/Models/SiteModel.js +1 -1
- package/lib/Models/TokenModel.js +1 -1
- package/lib/Models/UserAccountActionTokenModel.js +1 -1
- package/lib/Models/UserAccountModel.js +1 -1
- package/lib/PackageVersion.js +1 -1
- package/lib/Points.js +9 -1
- package/lib/index.d.ts +9 -3
- package/lib/index.js +67 -38
- package/package.json +2 -2
- package/src/Controllers/Site/PointController.js +2 -0
- package/src/PackageVersion.js +1 -1
- package/src/Points.js +11 -1
- package/src/index.js +35 -3
package/lib/index.d.ts
CHANGED
|
@@ -486,9 +486,7 @@ declare module '@ricado/api-client/Points' {
|
|
|
486
486
|
/**
|
|
487
487
|
* The Read Points Callback
|
|
488
488
|
*/
|
|
489
|
-
export type readPointsCallback = (siteId: number, pointValues:
|
|
490
|
-
[x: number]: PointValueItem;
|
|
491
|
-
}) => void;
|
|
489
|
+
export type readPointsCallback = (siteId: number, pointValues: PointValueItem[]) => void;
|
|
492
490
|
/**
|
|
493
491
|
* A Point Value Item used in a Read Points Callback
|
|
494
492
|
*/
|
|
@@ -4462,6 +4460,14 @@ declare module '@ricado/api-client/Controllers/Site/PointController' {
|
|
|
4462
4460
|
* The End Timestamp of the Point History Results. Defaults to Now
|
|
4463
4461
|
*/
|
|
4464
4462
|
timestampEnd?: Date;
|
|
4463
|
+
/**
|
|
4464
|
+
* The Maximum Number of Values that should be returned for each Point ID. Defaults to an Unlimited Number of Values
|
|
4465
|
+
*/
|
|
4466
|
+
maximumValues?: number;
|
|
4467
|
+
/**
|
|
4468
|
+
* A Resolution (Interval) in Seconds for the History Results - NOTE: Use of the maximumValues Query Parameter may enforce a higher minimum resolution. Defaults to 30 Seconds
|
|
4469
|
+
*/
|
|
4470
|
+
resolution?: number;
|
|
4465
4471
|
};
|
|
4466
4472
|
/**
|
|
4467
4473
|
* The Optional Query Parameters for the getAllEvents Function
|
package/lib/index.js
CHANGED
|
@@ -3,44 +3,24 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports
|
|
8
|
-
exports.setToken = setToken;
|
|
9
|
-
exports.hasToken = hasToken;
|
|
10
|
-
exports.isInitialized = isInitialized;
|
|
11
|
-
exports.isDebugMode = isDebugMode;
|
|
12
|
-
exports.enableDebugMode = enableDebugMode;
|
|
13
|
-
exports.disableDebugMode = disableDebugMode;
|
|
14
|
-
exports.getBaseURL = getBaseURL;
|
|
15
|
-
exports.setBaseURL = setBaseURL;
|
|
16
|
-
exports.getWebSocketServer = getWebSocketServer;
|
|
17
|
-
exports.setWebSocketServer = setWebSocketServer;
|
|
18
|
-
exports.getWebSocketPort = getWebSocketPort;
|
|
19
|
-
exports.setWebSocketPort = setWebSocketPort;
|
|
20
|
-
exports.initialize = initialize;
|
|
21
|
-
exports.userAccountLogin = userAccountLogin;
|
|
22
|
-
exports.apiAccountLogin = apiAccountLogin;
|
|
23
|
-
exports.pinCodeUnlock = pinCodeUnlock;
|
|
24
|
-
exports.passwordUnlock = passwordUnlock;
|
|
25
|
-
exports.lock = lock;
|
|
26
|
-
exports.logout = logout;
|
|
27
|
-
exports.ping = ping;
|
|
28
|
-
Object.defineProperty(exports, "RequestHelper", {
|
|
6
|
+
exports.BaseURL = void 0;
|
|
7
|
+
Object.defineProperty(exports, "Controllers", {
|
|
29
8
|
enumerable: true,
|
|
30
9
|
get: function get() {
|
|
31
|
-
return
|
|
10
|
+
return _index.default;
|
|
32
11
|
}
|
|
33
12
|
});
|
|
34
|
-
Object.defineProperty(exports, "
|
|
13
|
+
Object.defineProperty(exports, "Errors", {
|
|
35
14
|
enumerable: true,
|
|
36
15
|
get: function get() {
|
|
37
|
-
return
|
|
16
|
+
return _index2.default;
|
|
38
17
|
}
|
|
39
18
|
});
|
|
40
|
-
|
|
19
|
+
exports.JWT = void 0;
|
|
20
|
+
Object.defineProperty(exports, "Models", {
|
|
41
21
|
enumerable: true,
|
|
42
22
|
get: function get() {
|
|
43
|
-
return
|
|
23
|
+
return _index3.default;
|
|
44
24
|
}
|
|
45
25
|
});
|
|
46
26
|
Object.defineProperty(exports, "NoAuthPaths", {
|
|
@@ -49,25 +29,48 @@ Object.defineProperty(exports, "NoAuthPaths", {
|
|
|
49
29
|
return _NoAuthPaths.default;
|
|
50
30
|
}
|
|
51
31
|
});
|
|
52
|
-
Object.defineProperty(exports, "
|
|
32
|
+
Object.defineProperty(exports, "Points", {
|
|
53
33
|
enumerable: true,
|
|
54
34
|
get: function get() {
|
|
55
|
-
return
|
|
35
|
+
return _Points.default;
|
|
56
36
|
}
|
|
57
37
|
});
|
|
58
|
-
Object.defineProperty(exports, "
|
|
38
|
+
Object.defineProperty(exports, "RequestHelper", {
|
|
59
39
|
enumerable: true,
|
|
60
40
|
get: function get() {
|
|
61
|
-
return
|
|
41
|
+
return _RequestHelper.default;
|
|
62
42
|
}
|
|
63
43
|
});
|
|
64
|
-
|
|
44
|
+
exports.Version = void 0;
|
|
45
|
+
Object.defineProperty(exports, "WebSocketHelper", {
|
|
65
46
|
enumerable: true,
|
|
66
47
|
get: function get() {
|
|
67
|
-
return
|
|
48
|
+
return _WebSocketHelper.default;
|
|
68
49
|
}
|
|
69
50
|
});
|
|
70
|
-
exports.
|
|
51
|
+
exports.WebSocketServer = exports.WebSocketPort = void 0;
|
|
52
|
+
exports.apiAccountLogin = apiAccountLogin;
|
|
53
|
+
exports.disableDebugMode = disableDebugMode;
|
|
54
|
+
exports.enableDebugMode = enableDebugMode;
|
|
55
|
+
exports.getBaseURL = getBaseURL;
|
|
56
|
+
exports.getToken = getToken;
|
|
57
|
+
exports.getWebSocketPort = getWebSocketPort;
|
|
58
|
+
exports.getWebSocketServer = getWebSocketServer;
|
|
59
|
+
exports.hasToken = hasToken;
|
|
60
|
+
exports.initialize = initialize;
|
|
61
|
+
exports.isDebugMode = isDebugMode;
|
|
62
|
+
exports.isDefined = isDefined;
|
|
63
|
+
exports.isInitialized = isInitialized;
|
|
64
|
+
exports.lock = lock;
|
|
65
|
+
exports.logout = logout;
|
|
66
|
+
exports.passwordUnlock = passwordUnlock;
|
|
67
|
+
exports.pinCodeUnlock = pinCodeUnlock;
|
|
68
|
+
exports.ping = ping;
|
|
69
|
+
exports.setBaseURL = setBaseURL;
|
|
70
|
+
exports.setToken = setToken;
|
|
71
|
+
exports.setWebSocketPort = setWebSocketPort;
|
|
72
|
+
exports.setWebSocketServer = setWebSocketServer;
|
|
73
|
+
exports.userAccountLogin = userAccountLogin;
|
|
71
74
|
|
|
72
75
|
var _RequestHelper = _interopRequireDefault(require("./RequestHelper"));
|
|
73
76
|
|
|
@@ -85,7 +88,7 @@ var _index2 = _interopRequireDefault(require("./Errors/index"));
|
|
|
85
88
|
|
|
86
89
|
var _index3 = _interopRequireDefault(require("./Models/index"));
|
|
87
90
|
|
|
88
|
-
var
|
|
91
|
+
var _jsBase = require("js-base64");
|
|
89
92
|
|
|
90
93
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
91
94
|
|
|
@@ -137,7 +140,7 @@ function getToken() {
|
|
|
137
140
|
|
|
138
141
|
|
|
139
142
|
function setToken(jwt) {
|
|
140
|
-
if ((
|
|
143
|
+
if (isJwtValid(jwt)) {
|
|
141
144
|
exports.JWT = JWT = jwt;
|
|
142
145
|
} else {
|
|
143
146
|
throw new Error("The JSON Web Token provided was not valid");
|
|
@@ -153,7 +156,7 @@ function setToken(jwt) {
|
|
|
153
156
|
|
|
154
157
|
|
|
155
158
|
function hasToken() {
|
|
156
|
-
return isDefined(JWT) && (
|
|
159
|
+
return isDefined(JWT) && isJwtValid(JWT);
|
|
157
160
|
}
|
|
158
161
|
/**
|
|
159
162
|
* Initialized Status
|
|
@@ -511,6 +514,32 @@ function ping() {
|
|
|
511
514
|
});
|
|
512
515
|
});
|
|
513
516
|
}
|
|
517
|
+
/**
|
|
518
|
+
*
|
|
519
|
+
* @param {string} jwt The JWT Token
|
|
520
|
+
* @return {boolean}
|
|
521
|
+
*/
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
function isJwtValid(jwt) {
|
|
525
|
+
if (jwt === null || typeof jwt !== 'string') {
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
var jwtSegments = jwt.split('.');
|
|
530
|
+
|
|
531
|
+
if (jwtSegments.length !== 3) {
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
try {
|
|
536
|
+
JSON.parse((0, _jsBase.decode)(jwtSegments[0]));
|
|
537
|
+
JSON.parse((0, _jsBase.decode)(jwtSegments[1]));
|
|
538
|
+
return true;
|
|
539
|
+
} catch (_unused) {
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
514
543
|
/**
|
|
515
544
|
* The Library Version
|
|
516
545
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ricado/api-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "RICADO Gen 4 API Client Library for NodeJS and Browsers",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ash Neilson"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"analyze-webpack": "npm run generate-version-file && npm run babel && cross-env NODE_ENV=production webpack --profile --json > stats.json && webpack-bundle-analyzer ./stats.json"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"
|
|
44
|
+
"js-base64": "^3.7.2",
|
|
45
45
|
"node-fetch": "^2.6.1",
|
|
46
46
|
"socket.io-client": "^2.4.0"
|
|
47
47
|
},
|
|
@@ -476,6 +476,8 @@ export default PointController;
|
|
|
476
476
|
* @typedef {Object} PointController.GetAllHistoryQueryParameters
|
|
477
477
|
* @property {Date} [timestampBegin] The Beginning Timestamp of the Point History Results. Defaults to 24 Hours ago
|
|
478
478
|
* @property {Date} [timestampEnd] The End Timestamp of the Point History Results. Defaults to Now
|
|
479
|
+
* @property {number} [maximumValues] The Maximum Number of Values that should be returned for each Point ID. Defaults to an Unlimited Number of Values
|
|
480
|
+
* @property {number} [resolution] A Resolution (Interval) in Seconds for the History Results - NOTE: Use of the maximumValues Query Parameter may enforce a higher minimum resolution. Defaults to 30 Seconds
|
|
479
481
|
* @memberof Controllers.Site
|
|
480
482
|
*/
|
|
481
483
|
|
package/src/PackageVersion.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '1.
|
|
2
|
+
export const version = '1.4.1';
|
package/src/Points.js
CHANGED
|
@@ -371,6 +371,11 @@ class Points
|
|
|
371
371
|
*/
|
|
372
372
|
static getDefinition(siteId, pointId)
|
|
373
373
|
{
|
|
374
|
+
if(Points.isInitialized() != true)
|
|
375
|
+
{
|
|
376
|
+
return undefined;
|
|
377
|
+
}
|
|
378
|
+
|
|
374
379
|
if(siteId in Points._definitions && pointId in Points._definitions[siteId])
|
|
375
380
|
{
|
|
376
381
|
return Points._definitions[siteId][pointId];
|
|
@@ -390,6 +395,11 @@ class Points
|
|
|
390
395
|
*/
|
|
391
396
|
static getValue(siteId, pointId)
|
|
392
397
|
{
|
|
398
|
+
if(Points.isInitialized() != true)
|
|
399
|
+
{
|
|
400
|
+
return undefined;
|
|
401
|
+
}
|
|
402
|
+
|
|
393
403
|
if(siteId in Points._values && pointId in Points._values[siteId])
|
|
394
404
|
{
|
|
395
405
|
return Points._values[siteId][pointId];
|
|
@@ -562,7 +572,7 @@ class Points
|
|
|
562
572
|
*
|
|
563
573
|
* @callback Points.readPointsCallback
|
|
564
574
|
* @param {number} siteId - The Site ID
|
|
565
|
-
* @param {
|
|
575
|
+
* @param {Points.PointValueItem[]} pointValues - An Object of Point Values
|
|
566
576
|
* @return {void}
|
|
567
577
|
*/
|
|
568
578
|
|
package/src/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import NoAuthPaths from './NoAuthPaths';
|
|
|
10
10
|
import Controllers from './Controllers/index';
|
|
11
11
|
import Errors from './Errors/index';
|
|
12
12
|
import Models from './Models/index';
|
|
13
|
-
import {
|
|
13
|
+
import { decode as base64Decode } from 'js-base64';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Determines if a Variable has been Defined
|
|
@@ -55,7 +55,7 @@ export function getToken()
|
|
|
55
55
|
*/
|
|
56
56
|
export function setToken(jwt)
|
|
57
57
|
{
|
|
58
|
-
if(
|
|
58
|
+
if(isJwtValid(jwt))
|
|
59
59
|
{
|
|
60
60
|
JWT = jwt;
|
|
61
61
|
}
|
|
@@ -74,7 +74,7 @@ export function setToken(jwt)
|
|
|
74
74
|
*/
|
|
75
75
|
export function hasToken()
|
|
76
76
|
{
|
|
77
|
-
return isDefined(JWT) &&
|
|
77
|
+
return isDefined(JWT) && isJwtValid(JWT);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
@@ -405,6 +405,38 @@ export function ping() {
|
|
|
405
405
|
});
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
+
/**
|
|
409
|
+
*
|
|
410
|
+
* @param {string} jwt The JWT Token
|
|
411
|
+
* @return {boolean}
|
|
412
|
+
*/
|
|
413
|
+
function isJwtValid(jwt)
|
|
414
|
+
{
|
|
415
|
+
if(jwt === null || typeof jwt !== 'string')
|
|
416
|
+
{
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
let jwtSegments = jwt.split('.');
|
|
421
|
+
|
|
422
|
+
if(jwtSegments.length !== 3)
|
|
423
|
+
{
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
try
|
|
428
|
+
{
|
|
429
|
+
JSON.parse(base64Decode(jwtSegments[0]));
|
|
430
|
+
JSON.parse(base64Decode(jwtSegments[1]));
|
|
431
|
+
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
catch
|
|
435
|
+
{
|
|
436
|
+
return false;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
408
440
|
/**
|
|
409
441
|
* The Library Version
|
|
410
442
|
*
|