@hello.nrfcloud.com/proto-map 16.5.44 → 16.6.0
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/api/Email.spec.ts +1 -1
- package/dist/api/IsoDateType.js +1 -1
- package/dist/generator/addDocBlock.js +1 -1
- package/dist/generator/generateLwM2MDefinitions.js +3 -3
- package/dist/generator/generateLwm2mTimestampResources.js +1 -1
- package/dist/generator/generateModels.js +1 -1
- package/dist/generator/generateType.js +4 -4
- package/dist/generator/generateValidator.js +4 -4
- package/dist/generator/generateValidators.js +1 -1
- package/dist/generator/lwm2m.js +1 -1
- package/dist/generator/models.js +12 -4
- package/dist/generator/printNode.js +1 -1
- package/dist/generator/tokenizeName.js +1 -1
- package/dist/generator/types.js +2 -2
- package/dist/lwm2m/aws/instanceMeasuresToRecord.js +1 -1
- package/dist/lwm2m/aws/instanceToMeasures.js +1 -1
- package/dist/lwm2m/aws/objectsToShadow.js +2 -3
- package/dist/lwm2m/aws/shadowToObjects.js +1 -1
- package/dist/lwm2m/check-lwm2m-rules.js +33 -17
- package/dist/lwm2m/correctOffset.js +1 -1
- package/dist/lwm2m/fromXML2JSON.js +13 -5
- package/dist/lwm2m/instanceTs.js +2 -2
- package/dist/lwm2m/isLwM2MObjectID.js +1 -1
- package/dist/lwm2m/isNumber.js +1 -1
- package/dist/lwm2m/isNumeric.js +1 -1
- package/dist/lwm2m/isUnixTimeInSeconds.js +1 -1
- package/dist/lwm2m/object/validate14201.js +1 -1
- package/dist/lwm2m/object/validate14202.js +1 -1
- package/dist/lwm2m/object/validate14203.js +1 -1
- package/dist/lwm2m/object/validate14204.js +1 -1
- package/dist/lwm2m/object/validate14205.js +1 -1
- package/dist/lwm2m/object/validate14210.js +1 -1
- package/dist/lwm2m/object/validate14220.js +1 -1
- package/dist/lwm2m/object/validate14230.js +1 -1
- package/dist/lwm2m/object/validate14240.js +1 -1
- package/dist/lwm2m/object/validate14250.js +1 -1
- package/dist/lwm2m/object/validate14301.js +1 -1
- package/dist/lwm2m/object/validate14401.js +1 -1
- package/dist/lwm2m/object/validate14501.js +1 -1
- package/dist/lwm2m/object/validate14502.js +1 -1
- package/dist/lwm2m/object/validate14503.js +1 -1
- package/dist/lwm2m/parseRangeEnumeration.js +2 -2
- package/dist/lwm2m/unwrapNestedArray.js +1 -1
- package/dist/lwm2m/validate.js +1 -1
- package/dist/lwm2m/validation.js +15 -15
- package/dist/markdown/getCodeBlock.js +5 -5
- package/dist/markdown/parseREADME.js +3 -3
- package/dist/models/check-model-rules.js +1 -1
- package/dist/senml/fromCBOR.js +1 -1
- package/dist/senml/hasName.js +1 -1
- package/dist/senml/hasValue.js +3 -3
- package/dist/senml/index.js +1 -0
- package/dist/senml/lwm2mToSenML.js +2 -2
- package/dist/senml/parseResourceId.js +1 -1
- package/dist/senml/senMLtoLwM2M.js +23 -14
- package/dist/senml/senMLtoLwM2M.spec.js +11 -3
- package/dist/senml/toCBOR.js +174 -0
- package/dist/senml/toCBOR.spec.js +75 -0
- package/dist/senml/validateSenML.js +1 -1
- package/package.json +9 -9
- package/senml/index.ts +1 -0
- package/senml/toCBOR.spec.ts +38 -0
- package/senml/toCBOR.ts +39 -0
package/api/Email.spec.ts
CHANGED
|
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict'
|
|
|
2
2
|
import { describe, it } from 'node:test'
|
|
3
3
|
import { validate } from '../validate.js'
|
|
4
4
|
import { Email } from './Email.js'
|
|
5
|
-
import invalidEmails from './test/invalid-emails.json'
|
|
5
|
+
import invalidEmails from './test/invalid-emails.json' with { type: 'json' }
|
|
6
6
|
|
|
7
7
|
const v = validate(Email)
|
|
8
8
|
|
package/dist/api/IsoDateType.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Type } from '@sinclair/typebox';
|
|
2
|
-
export var IsoDateType = function(description) {
|
|
2
|
+
export var IsoDateType = function IsoDateType(description) {
|
|
3
3
|
return Type.String({
|
|
4
4
|
pattern: '^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2}(?:.[0-9]*)?)(([+-]([0-9]{2}):([0-9]{2})|Z)?)$',
|
|
5
5
|
description: description !== null && description !== void 0 ? description : 'A date formatted as an ISO 8601 string',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
export var addDocBlock = function(comment, node) {
|
|
2
|
+
export var addDocBlock = function addDocBlock(comment, node) {
|
|
3
3
|
ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, "*\n * ".concat(comment.join('\n * '), " \n "), true);
|
|
4
4
|
return node;
|
|
5
5
|
};
|
|
@@ -2,7 +2,7 @@ import ts from 'typescript';
|
|
|
2
2
|
import { parseRangeEnumeration } from '../lwm2m/parseRangeEnumeration.js';
|
|
3
3
|
import { addDocBlock } from './addDocBlock.js';
|
|
4
4
|
import { generateName } from './generateType.js';
|
|
5
|
-
export var generateLwM2MDefinitions = function(definitions) {
|
|
5
|
+
export var generateLwM2MDefinitions = function generateLwM2MDefinitions(definitions) {
|
|
6
6
|
var importLWM2MObjectInfo = ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([
|
|
7
7
|
ts.factory.createImportSpecifier(true, undefined, ts.factory.createIdentifier("LWM2MObjectInfo")),
|
|
8
8
|
ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier("ResourceType"))
|
|
@@ -44,10 +44,10 @@ export var generateLwM2MDefinitions = function(definitions) {
|
|
|
44
44
|
type
|
|
45
45
|
];
|
|
46
46
|
};
|
|
47
|
-
var createNumber = function(n) {
|
|
47
|
+
var createNumber = function createNumber(n) {
|
|
48
48
|
return n < 0 ? ts.factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, ts.factory.createNumericLiteral(-n)) : ts.factory.createNumericLiteral(n);
|
|
49
49
|
};
|
|
50
|
-
var createResource = function(Resource) {
|
|
50
|
+
var createResource = function createResource(Resource) {
|
|
51
51
|
var range = undefined;
|
|
52
52
|
if (Resource.RangeEnumeration.length > 0) {
|
|
53
53
|
var maybeRange = parseRangeEnumeration(Resource.RangeEnumeration);
|
|
@@ -46,7 +46,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
46
46
|
}
|
|
47
47
|
import ts from 'typescript';
|
|
48
48
|
import { addDocBlock } from './addDocBlock.js';
|
|
49
|
-
export var generateLwm2mTimestampResources = function(timestampResources) {
|
|
49
|
+
export var generateLwm2mTimestampResources = function generateLwm2mTimestampResources(timestampResources) {
|
|
50
50
|
var importLwM2MObjectID = ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([
|
|
51
51
|
ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier("LwM2MObjectID"))
|
|
52
52
|
])), ts.factory.createStringLiteral('./LwM2MObjectID.js'));
|
|
@@ -2,7 +2,7 @@ import { parseREADME } from 'markdown/parseREADME.js';
|
|
|
2
2
|
import ts from 'typescript';
|
|
3
3
|
import { addDocBlock } from './addDocBlock.js';
|
|
4
4
|
import { tokenizeName } from './tokenizeName.js';
|
|
5
|
-
export var generateModels = function(models) {
|
|
5
|
+
export var generateModels = function generateModels(models) {
|
|
6
6
|
var types = [];
|
|
7
7
|
types.push(addDocBlock([
|
|
8
8
|
'The Model IDs defined in this repo.'
|
|
@@ -3,7 +3,7 @@ import ts from 'typescript';
|
|
|
3
3
|
import { LwM2MType } from '../lwm2m/resourceType.js';
|
|
4
4
|
import { addDocBlock } from './addDocBlock.js';
|
|
5
5
|
import { tokenizeName } from './tokenizeName.js';
|
|
6
|
-
export var generateType = function(param) {
|
|
6
|
+
export var generateType = function generateType(param) {
|
|
7
7
|
var ObjectID = param.ObjectID, ObjectVersion = param.ObjectVersion, Name = param.Name, Description1 = param.Description1, Resources = param.Resources;
|
|
8
8
|
var name = generateName({
|
|
9
9
|
Name: Name,
|
|
@@ -58,11 +58,11 @@ export var generateType = function(param) {
|
|
|
58
58
|
exportType
|
|
59
59
|
];
|
|
60
60
|
};
|
|
61
|
-
export var generateName = function(param) {
|
|
61
|
+
export var generateName = function generateName(param) {
|
|
62
62
|
var Name = param.Name, ObjectID = param.ObjectID;
|
|
63
63
|
return "".concat(tokenizeName(Name), "_").concat(ObjectID);
|
|
64
64
|
};
|
|
65
|
-
var typeScriptResourceType = function(type) {
|
|
65
|
+
var typeScriptResourceType = function typeScriptResourceType(type) {
|
|
66
66
|
switch(type){
|
|
67
67
|
case LwM2MType.Float:
|
|
68
68
|
case LwM2MType.Integer:
|
|
@@ -80,7 +80,7 @@ var typeScriptResourceType = function(type) {
|
|
|
80
80
|
throw new Error("Unexpected resource type: ".concat(type));
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
|
-
var byImportance = function(resources) {
|
|
83
|
+
var byImportance = function byImportance(resources) {
|
|
84
84
|
return resources// sort by id
|
|
85
85
|
.sort(function(param, param1) {
|
|
86
86
|
var _param_$ = param.$, id1 = _param_$.ID, _param_$1 = param1.$, id2 = _param_$1.ID;
|
|
@@ -26,7 +26,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
26
26
|
import ts from 'typescript';
|
|
27
27
|
import { addDocBlock } from './addDocBlock.js';
|
|
28
28
|
import { generateName } from './generateType.js';
|
|
29
|
-
export var generateValidator = function(param) {
|
|
29
|
+
export var generateValidator = function generateValidator(param) {
|
|
30
30
|
var ObjectID = param.ObjectID, ObjectVersion = param.ObjectVersion, Name = param.Name, Resources = param.Resources;
|
|
31
31
|
// import type { LwM2MObject } from './LwM2MObject.js'
|
|
32
32
|
var importLwM2MObject = ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(true, undefined, ts.factory.createNamedImports([
|
|
@@ -102,7 +102,7 @@ export var generateValidator = function(param) {
|
|
|
102
102
|
validate
|
|
103
103
|
];
|
|
104
104
|
};
|
|
105
|
-
var toResourceValidator = function(Resource) {
|
|
105
|
+
var toResourceValidator = function toResourceValidator(Resource) {
|
|
106
106
|
var valueValidator = ts.factory.createIdentifier(typeToValidator(Resource.Type));
|
|
107
107
|
if (Resource.MultipleInstances === 'Multiple') {
|
|
108
108
|
valueValidator = ts.factory.createCallExpression(ts.factory.createIdentifier('MultipleInstanceResource'), undefined, [
|
|
@@ -114,7 +114,7 @@ var toResourceValidator = function(Resource) {
|
|
|
114
114
|
]);
|
|
115
115
|
return valueValidator;
|
|
116
116
|
};
|
|
117
|
-
var typeToValidator = function(Type) {
|
|
117
|
+
var typeToValidator = function typeToValidator(Type) {
|
|
118
118
|
switch(Type){
|
|
119
119
|
case 'String':
|
|
120
120
|
case 'Opaque':
|
|
@@ -130,7 +130,7 @@ var typeToValidator = function(Type) {
|
|
|
130
130
|
throw new Error("Unsupported Resource type ".concat(Type, "!"));
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
|
-
var getResourceValidators = function(param) {
|
|
133
|
+
var getResourceValidators = function getResourceValidators(param) {
|
|
134
134
|
var Resources = param.Resources;
|
|
135
135
|
return new Set((Array.isArray(Resources.Item) ? Resources.Item : [
|
|
136
136
|
Resources.Item
|
|
@@ -26,7 +26,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
26
26
|
import ts from 'typescript';
|
|
27
27
|
import { addDocBlock } from './addDocBlock.js';
|
|
28
28
|
import { generateName } from './generateType.js';
|
|
29
|
-
export var generateValidators = function(objects) {
|
|
29
|
+
export var generateValidators = function generateValidators(objects) {
|
|
30
30
|
// import { LwM2MObjectID } from './LwM2MObjectID.js'
|
|
31
31
|
var importLwM2MObjectID = ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([
|
|
32
32
|
ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier("LwM2MObjectID"))
|
package/dist/generator/lwm2m.js
CHANGED
|
@@ -35,7 +35,7 @@ import { generateLwm2mTimestampResources } from './generateLwm2mTimestampResourc
|
|
|
35
35
|
import { generateName } from './generateType.js';
|
|
36
36
|
import { printNode } from './printNode.js';
|
|
37
37
|
var baseDir = process.cwd();
|
|
38
|
-
var subDir = function() {
|
|
38
|
+
var subDir = function subDir() {
|
|
39
39
|
for(var _len = arguments.length, tree = new Array(_len), _key = 0; _key < _len; _key++){
|
|
40
40
|
tree[_key] = arguments[_key];
|
|
41
41
|
}
|
package/dist/generator/models.js
CHANGED
|
@@ -61,9 +61,17 @@ function _ts_generator(thisArg, body) {
|
|
|
61
61
|
},
|
|
62
62
|
trys: [],
|
|
63
63
|
ops: []
|
|
64
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
65
|
-
return
|
|
66
|
-
|
|
64
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
65
|
+
return d(g, "next", {
|
|
66
|
+
value: verb(0)
|
|
67
|
+
}), d(g, "throw", {
|
|
68
|
+
value: verb(1)
|
|
69
|
+
}), d(g, "return", {
|
|
70
|
+
value: verb(2)
|
|
71
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
72
|
+
value: function() {
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
67
75
|
}), g;
|
|
68
76
|
function verb(n) {
|
|
69
77
|
return function(v) {
|
|
@@ -153,7 +161,7 @@ import path from 'node:path';
|
|
|
153
161
|
import { generateModels } from './generateModels.js';
|
|
154
162
|
import { printNode } from './printNode.js';
|
|
155
163
|
var baseDir = process.cwd();
|
|
156
|
-
var subDir = function() {
|
|
164
|
+
var subDir = function subDir() {
|
|
157
165
|
for(var _len = arguments.length, tree = new Array(_len), _key = 0; _key < _len; _key++){
|
|
158
166
|
tree[_key] = arguments[_key];
|
|
159
167
|
}
|
|
@@ -3,6 +3,6 @@ var resultFile = ts.createSourceFile("stub.ts", '', ts.ScriptTarget.Latest, /*se
|
|
|
3
3
|
var printer = ts.createPrinter({
|
|
4
4
|
newLine: ts.NewLineKind.LineFeed
|
|
5
5
|
});
|
|
6
|
-
export var printNode = function(node) {
|
|
6
|
+
export var printNode = function printNode(node) {
|
|
7
7
|
return printer.printNode(ts.EmitHint.Unspecified, node, resultFile);
|
|
8
8
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export var tokenizeName = function(name) {
|
|
1
|
+
export var tokenizeName = function tokenizeName(name) {
|
|
2
2
|
return name.split(' ').map(function(s) {
|
|
3
3
|
return "".concat(s.slice(0, 1).toUpperCase()).concat(s.slice(1));
|
|
4
4
|
}).join(' ').replaceAll(' ', '').replaceAll('&', 'and').replace(/^(\d)(.+)/, 'n$1$2').replaceAll(/[^a-z0-9]/gi, '_').replaceAll(/_{2,}/g, '_').replaceAll(/_+$/g, '').trim();
|
package/dist/generator/types.js
CHANGED
|
@@ -37,7 +37,7 @@ import { generateValidator } from './generateValidator.js';
|
|
|
37
37
|
import { generateValidators } from './generateValidators.js';
|
|
38
38
|
import { printNode } from './printNode.js';
|
|
39
39
|
var baseDir = process.cwd();
|
|
40
|
-
var subDir = function() {
|
|
40
|
+
var subDir = function subDir() {
|
|
41
41
|
for(var _len = arguments.length, tree = new Array(_len), _key = 0; _key < _len; _key++){
|
|
42
42
|
tree[_key] = arguments[_key];
|
|
43
43
|
}
|
|
@@ -65,7 +65,7 @@ try {
|
|
|
65
65
|
idMembers.push(member);
|
|
66
66
|
try {
|
|
67
67
|
await mkdir(subDir('lwm2m', "object"));
|
|
68
|
-
} catch (
|
|
68
|
+
} catch (unused) {
|
|
69
69
|
// pass
|
|
70
70
|
}
|
|
71
71
|
// Type
|
|
@@ -2,7 +2,7 @@ import { MeasureValueType, TimeUnit } from '@aws-sdk/client-timestream-write';
|
|
|
2
2
|
import { instanceTs } from '../instanceTs.js';
|
|
3
3
|
import { instanceToMeasures } from './instanceToMeasures.js';
|
|
4
4
|
import { NoHistoryMeasuresError } from './NoHistoryMeasuresError.js';
|
|
5
|
-
export var instanceMeasuresToRecord = function(param) {
|
|
5
|
+
export var instanceMeasuresToRecord = function instanceMeasuresToRecord(param) {
|
|
6
6
|
var ObjectID = param.ObjectID, ObjectInstanceID = param.ObjectInstanceID, ObjectVersion = param.ObjectVersion, Resources = param.Resources;
|
|
7
7
|
var maybeMeasures = instanceToMeasures({
|
|
8
8
|
ObjectID: ObjectID,
|
|
@@ -52,7 +52,7 @@ import { isNumber } from '../isNumber.js';
|
|
|
52
52
|
import { isNumeric } from '../isNumeric.js';
|
|
53
53
|
import { isUnixTimeInSeconds } from '../isUnixTimeInSeconds.js';
|
|
54
54
|
import { timestampResources } from '../timestampResources.js';
|
|
55
|
-
export var instanceToMeasures = function(param) {
|
|
55
|
+
export var instanceToMeasures = function instanceToMeasures(param) {
|
|
56
56
|
var Resources = param.Resources, ObjectID = param.ObjectID, ObjectInstanceID = param.ObjectInstanceID, ObjectVersion = param.ObjectVersion;
|
|
57
57
|
var measures = [];
|
|
58
58
|
var tsResource = timestampResources.get(ObjectID);
|
|
@@ -51,15 +51,14 @@ function _object_spread_props(target, source) {
|
|
|
51
51
|
return target;
|
|
52
52
|
}
|
|
53
53
|
import { instanceTs } from '../instanceTs.js';
|
|
54
|
-
export var objectsToShadow = function(objects) {
|
|
54
|
+
export var objectsToShadow = function objectsToShadow(objects) {
|
|
55
55
|
return objects.sort(function(u1, u2) {
|
|
56
56
|
var d1 = instanceTs(u1);
|
|
57
57
|
var d2 = instanceTs(u2);
|
|
58
58
|
return d1 - d2 ? 1 : -1;
|
|
59
59
|
}).reduce(function(shadow, update) {
|
|
60
|
-
var _update_ObjectVersion;
|
|
60
|
+
var _update_ObjectVersion, _update_ObjectInstanceID;
|
|
61
61
|
var key = "".concat(update.ObjectID, ":").concat((_update_ObjectVersion = update.ObjectVersion) !== null && _update_ObjectVersion !== void 0 ? _update_ObjectVersion : '1.0');
|
|
62
|
-
var _update_ObjectInstanceID;
|
|
63
62
|
return _object_spread_props(_object_spread({}, shadow), _define_property({}, key, _define_property({}, (_update_ObjectInstanceID = update.ObjectInstanceID) !== null && _update_ObjectInstanceID !== void 0 ? _update_ObjectInstanceID : 0, update.Resources)));
|
|
64
63
|
}, {});
|
|
65
64
|
};
|
|
@@ -45,7 +45,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
45
45
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
46
46
|
}
|
|
47
47
|
import { timestampResources } from '../timestampResources.js';
|
|
48
|
-
export var shadowToObjects = function(shadow) {
|
|
48
|
+
export var shadowToObjects = function shadowToObjects(shadow) {
|
|
49
49
|
return Object.entries(shadow).map(function(param) {
|
|
50
50
|
var _param = _sliced_to_array(param, 2), ObjectIdAndVersion = _param[0], Instances = _param[1];
|
|
51
51
|
var _ObjectIdAndVersion_split = _sliced_to_array(ObjectIdAndVersion.split(':'), 2), ObjectIDString = _ObjectIdAndVersion_split[0], ObjectVersion = _ObjectIdAndVersion_split[1];
|
|
@@ -116,12 +116,22 @@ function _object_spread_props(target, source) {
|
|
|
116
116
|
}
|
|
117
117
|
function _object_without_properties(source, excluded) {
|
|
118
118
|
if (source == null) return {};
|
|
119
|
-
var target =
|
|
120
|
-
|
|
119
|
+
var target = {}, sourceKeys, key, i;
|
|
120
|
+
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
121
|
+
sourceKeys = Reflect.ownKeys(source);
|
|
122
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
123
|
+
key = sourceKeys[i];
|
|
124
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
125
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
126
|
+
target[key] = source[key];
|
|
127
|
+
}
|
|
128
|
+
return target;
|
|
129
|
+
}
|
|
130
|
+
target = _object_without_properties_loose(source, excluded);
|
|
121
131
|
if (Object.getOwnPropertySymbols) {
|
|
122
|
-
|
|
123
|
-
for(i = 0; i <
|
|
124
|
-
key =
|
|
132
|
+
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
133
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
134
|
+
key = sourceKeys[i];
|
|
125
135
|
if (excluded.indexOf(key) >= 0) continue;
|
|
126
136
|
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
127
137
|
target[key] = source[key];
|
|
@@ -131,12 +141,11 @@ function _object_without_properties(source, excluded) {
|
|
|
131
141
|
}
|
|
132
142
|
function _object_without_properties_loose(source, excluded) {
|
|
133
143
|
if (source == null) return {};
|
|
134
|
-
var target = {};
|
|
135
|
-
var sourceKeys = Object.keys(source);
|
|
136
|
-
var key, i;
|
|
144
|
+
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
137
145
|
for(i = 0; i < sourceKeys.length; i++){
|
|
138
146
|
key = sourceKeys[i];
|
|
139
147
|
if (excluded.indexOf(key) >= 0) continue;
|
|
148
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
140
149
|
target[key] = source[key];
|
|
141
150
|
}
|
|
142
151
|
return target;
|
|
@@ -161,9 +170,17 @@ function _ts_generator(thisArg, body) {
|
|
|
161
170
|
},
|
|
162
171
|
trys: [],
|
|
163
172
|
ops: []
|
|
164
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
165
|
-
return
|
|
166
|
-
|
|
173
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
174
|
+
return d(g, "next", {
|
|
175
|
+
value: verb(0)
|
|
176
|
+
}), d(g, "throw", {
|
|
177
|
+
value: verb(1)
|
|
178
|
+
}), d(g, "return", {
|
|
179
|
+
value: verb(2)
|
|
180
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
181
|
+
value: function() {
|
|
182
|
+
return this;
|
|
183
|
+
}
|
|
167
184
|
}), g;
|
|
168
185
|
function verb(n) {
|
|
169
186
|
return function(v) {
|
|
@@ -268,7 +285,7 @@ import { LWM2MObjectDefinition } from './LWM2MObjectDefinition.js';
|
|
|
268
285
|
import { parseRangeEnumeration } from './parseRangeEnumeration.js';
|
|
269
286
|
import { unwrapNestedArray } from './unwrapNestedArray.js';
|
|
270
287
|
var v = validate(LWM2MObjectDefinition);
|
|
271
|
-
var listLwm2mDefinitions = function(modelDir) {
|
|
288
|
+
var listLwm2mDefinitions = function listLwm2mDefinitions(modelDir) {
|
|
272
289
|
return _async_to_generator(function() {
|
|
273
290
|
var defs, files, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step, err;
|
|
274
291
|
return _ts_generator(this, function(_state) {
|
|
@@ -291,12 +308,11 @@ var listLwm2mDefinitions = function(modelDir) {
|
|
|
291
308
|
9
|
|
292
309
|
]);
|
|
293
310
|
_loop = function() {
|
|
294
|
-
var
|
|
311
|
+
var file, _TimeResources_, _TimeResources_1, objectDefinitionFile, schemaValidated, ObjectID, ObjectURN, definition, _, objectDef, Item, maybeValid, _maybeValid_value, Name, Resources, TimeResources, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step1, _step_value, id, resource, _resource_Units;
|
|
295
312
|
return _ts_generator(this, function(_state) {
|
|
296
313
|
switch(_state.label){
|
|
297
314
|
case 0:
|
|
298
|
-
|
|
299
|
-
file = _ref;
|
|
315
|
+
file = _step.value;
|
|
300
316
|
if (!file.endsWith('.xml')) return [
|
|
301
317
|
2,
|
|
302
318
|
"continue"
|
|
@@ -359,8 +375,8 @@ var listLwm2mDefinitions = function(modelDir) {
|
|
|
359
375
|
});
|
|
360
376
|
Item = definition.Resources.Item;
|
|
361
377
|
if (Array.isArray(Item)) {
|
|
362
|
-
objectDef.Resources = Item.reduce(function(resources,
|
|
363
|
-
var $ =
|
|
378
|
+
objectDef.Resources = Item.reduce(function(resources, _1) {
|
|
379
|
+
var $ = _1.$, item = _object_without_properties(_1, [
|
|
364
380
|
"$"
|
|
365
381
|
]);
|
|
366
382
|
if (resources[$.ID] !== undefined) throw new Error("Duplicate resource ID: ".concat($.ID));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Corrects an offset of up to 60 seconds in the future.
|
|
3
3
|
* This is needed because some devices clocks drift, and they report timestamps in the future.
|
|
4
|
-
*/ export var correctOffset = function(ts) {
|
|
4
|
+
*/ export var correctOffset = function correctOffset(ts) {
|
|
5
5
|
var maxOffsetSeconds = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 60;
|
|
6
6
|
var nowSeconds = Math.ceil(Date.now() / 1000);
|
|
7
7
|
var offset = ts * 1000 - nowSeconds;
|
|
@@ -61,9 +61,17 @@ function _ts_generator(thisArg, body) {
|
|
|
61
61
|
},
|
|
62
62
|
trys: [],
|
|
63
63
|
ops: []
|
|
64
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
65
|
-
return
|
|
66
|
-
|
|
64
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
65
|
+
return d(g, "next", {
|
|
66
|
+
value: verb(0)
|
|
67
|
+
}), d(g, "throw", {
|
|
68
|
+
value: verb(1)
|
|
69
|
+
}), d(g, "return", {
|
|
70
|
+
value: verb(2)
|
|
71
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
72
|
+
value: function() {
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
67
75
|
}), g;
|
|
68
76
|
function verb(n) {
|
|
69
77
|
return function(v) {
|
|
@@ -148,14 +156,14 @@ import path from 'node:path';
|
|
|
148
156
|
import xml2js from 'xml2js';
|
|
149
157
|
/**
|
|
150
158
|
* From XML to JSON
|
|
151
|
-
*/ export var fromXML2JSON = function(id) {
|
|
159
|
+
*/ export var fromXML2JSON = function fromXML2JSON(id) {
|
|
152
160
|
return _async_to_generator(function() {
|
|
153
161
|
var _path, baseDir, subDir, jsonObject, _;
|
|
154
162
|
return _ts_generator(this, function(_state) {
|
|
155
163
|
switch(_state.label){
|
|
156
164
|
case 0:
|
|
157
165
|
baseDir = process.cwd();
|
|
158
|
-
subDir = function() {
|
|
166
|
+
subDir = function subDir() {
|
|
159
167
|
for(var _len = arguments.length, tree = new Array(_len), _key = 0; _key < _len; _key++){
|
|
160
168
|
tree[_key] = arguments[_key];
|
|
161
169
|
}
|
package/dist/lwm2m/instanceTs.js
CHANGED
|
@@ -6,7 +6,7 @@ import { timestampResources } from './timestampResources.js';
|
|
|
6
6
|
* The timestamp is s signed integer representing
|
|
7
7
|
* the number of seconds since Jan 1, 1970 in the
|
|
8
8
|
* UTC time zone.
|
|
9
|
-
*/ export var instanceTs = function(instance) {
|
|
9
|
+
*/ export var instanceTs = function instanceTs(instance) {
|
|
10
10
|
var definition = definitions[instance.ObjectID];
|
|
11
11
|
var tsResourceId = timestampResources.get(definition.ObjectID)// All registered objects must have a timestamp resource
|
|
12
12
|
;
|
|
@@ -14,6 +14,6 @@ import { timestampResources } from './timestampResources.js';
|
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
16
|
* Returns the timestamp of the instance as a Date object
|
|
17
|
-
*/ export var instanceTsAsDate = function(instance) {
|
|
17
|
+
*/ export var instanceTsAsDate = function instanceTsAsDate(instance) {
|
|
18
18
|
return new Date(instanceTs(instance) * 1000);
|
|
19
19
|
};
|
package/dist/lwm2m/isNumber.js
CHANGED
package/dist/lwm2m/isNumeric.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ResourceType } from './LWM2MObjectInfo.js';
|
|
2
2
|
/**
|
|
3
3
|
* Only store numeric values, because you cannot create statistics about strings, or boolean
|
|
4
|
-
*/ export var isNumeric = function(def) {
|
|
4
|
+
*/ export var isNumeric = function isNumeric(def) {
|
|
5
5
|
switch(def.Type){
|
|
6
6
|
case ResourceType.Float:
|
|
7
7
|
case ResourceType.Integer:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNumber } from './isNumber.js';
|
|
2
|
-
export var isUnixTimeInSeconds = function(value) {
|
|
2
|
+
export var isUnixTimeInSeconds = function isUnixTimeInSeconds(value) {
|
|
3
3
|
if (!isNumber(value)) return false;
|
|
4
4
|
if (value < 1700000000) return false;
|
|
5
5
|
if (value * 1000 > Date.now()) return false;
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate Geolocation (14201)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14201.xml.
|
|
7
|
-
*/ export var validate14201 = function(o) {
|
|
7
|
+
*/ export var validate14201 = function validate14201(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.Geolocation_14201, "1.0", {
|
|
9
9
|
0: NumberResource,
|
|
10
10
|
1: NumberResource,
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate Battery and Power (14202)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14202.xml.
|
|
7
|
-
*/ export var validate14202 = function(o) {
|
|
7
|
+
*/ export var validate14202 = function validate14202(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.BatteryAndPower_14202, "1.0", {
|
|
9
9
|
99: TimeResource,
|
|
10
10
|
0: OptionalResource(NumberResource),
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate Connection information (14203)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14203.xml.
|
|
7
|
-
*/ export var validate14203 = function(o) {
|
|
7
|
+
*/ export var validate14203 = function validate14203(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.ConnectionInformation_14203, "1.0", {
|
|
9
9
|
99: TimeResource,
|
|
10
10
|
0: OptionalResource(StringResource),
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate Device information (14204)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14204.xml.
|
|
7
|
-
*/ export var validate14204 = function(o) {
|
|
7
|
+
*/ export var validate14204 = function validate14204(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.DeviceInformation_14204, "1.0", {
|
|
9
9
|
0: StringResource,
|
|
10
10
|
2: StringResource,
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate Environment (14205)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14205.xml.
|
|
7
|
-
*/ export var validate14205 = function(o) {
|
|
7
|
+
*/ export var validate14205 = function validate14205(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.Environment_14205, "1.0", {
|
|
9
9
|
99: TimeResource,
|
|
10
10
|
0: OptionalResource(NumberResource),
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate Solar charge (14210)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14210.xml.
|
|
7
|
-
*/ export var validate14210 = function(o) {
|
|
7
|
+
*/ export var validate14210 = function validate14210(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.SolarCharge_14210, "1.0", {
|
|
9
9
|
0: NumberResource,
|
|
10
10
|
99: TimeResource,
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate Button press (14220)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14220.xml.
|
|
7
|
-
*/ export var validate14220 = function(o) {
|
|
7
|
+
*/ export var validate14220 = function validate14220(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.ButtonPress_14220, "1.0", {
|
|
9
9
|
99: TimeResource
|
|
10
10
|
})(o);
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate Sea Water Level (14230)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14230.xml.
|
|
7
|
-
*/ export var validate14230 = function(o) {
|
|
7
|
+
*/ export var validate14230 = function validate14230(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.SeaWaterLevel_14230, "1.0", {
|
|
9
9
|
0: NumberResource,
|
|
10
10
|
1: StringResource,
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate RGB LED (14240)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14240.xml.
|
|
7
|
-
*/ export var validate14240 = function(o) {
|
|
7
|
+
*/ export var validate14240 = function validate14240(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.RGBLED_14240, "1.0", {
|
|
9
9
|
0: NumberResource,
|
|
10
10
|
1: NumberResource,
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate Reboot (14250)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14250.xml.
|
|
7
|
-
*/ export var validate14250 = function(o) {
|
|
7
|
+
*/ export var validate14250 = function validate14250(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.Reboot_14250, "1.0", {
|
|
9
9
|
99: TimeResource,
|
|
10
10
|
0: OptionalResource(NumberResource)
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate Application Configuration (14301)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14301.xml.
|
|
7
|
-
*/ export var validate14301 = function(o) {
|
|
7
|
+
*/ export var validate14301 = function validate14301(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.ApplicationConfiguration_14301, "1.0", {
|
|
9
9
|
0: NumberResource,
|
|
10
10
|
1: BooleanResource,
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate nRF Cloud Service Info (14401)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14401.xml.
|
|
7
|
-
*/ export var validate14401 = function(o) {
|
|
7
|
+
*/ export var validate14401 = function validate14401(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.NRFCloudServiceInfo_14401, "1.0", {
|
|
9
9
|
99: TimeResource,
|
|
10
10
|
0: OptionalResource(MultipleInstanceResource(StringResource))
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate Connection Quality (14501)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14501.xml.
|
|
7
|
-
*/ export var validate14501 = function(o) {
|
|
7
|
+
*/ export var validate14501 = function validate14501(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.ConnectionQuality_14501, "1.0", {
|
|
9
9
|
99: TimeResource,
|
|
10
10
|
0: OptionalResource(NumberResource),
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate Network Neighbor (14502)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14502.xml.
|
|
7
|
-
*/ export var validate14502 = function(o) {
|
|
7
|
+
*/ export var validate14502 = function validate14502(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.NetworkNeighbor_14502, "1.0", {
|
|
9
9
|
0: NumberResource,
|
|
10
10
|
99: TimeResource,
|
|
@@ -4,7 +4,7 @@ import { LwM2MObjectID } from "../LwM2MObjectID.js";
|
|
|
4
4
|
* Validate DECT NR+ Connection Profile (14503)
|
|
5
5
|
*
|
|
6
6
|
* Ensures the given object is an LwM2M object according to the schema 14503.xml.
|
|
7
|
-
*/ export var validate14503 = function(o) {
|
|
7
|
+
*/ export var validate14503 = function validate14503(o) {
|
|
8
8
|
return validateInstance(LwM2MObjectID.DECTNR_ConnectionProfile_14503, "1.0", {
|
|
9
9
|
0: NumberResource,
|
|
10
10
|
1: NumberResource,
|