@hello.nrfcloud.com/proto-map 5.6.2 → 5.6.3

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.
Files changed (68) hide show
  1. package/api/Context.ts +1 -1
  2. package/api/{ResourceUpdate.spec.ts → ObjectUpdate.spec.ts} +5 -5
  3. package/api/{ResourceUpdate.ts → ObjectUpdate.ts} +4 -4
  4. package/dist/api/Context.js +1 -1
  5. package/dist/api/DeviceId.js +7 -7
  6. package/dist/api/Devices.js +11 -11
  7. package/dist/api/History.js +10 -10
  8. package/dist/api/History.spec.js +17 -17
  9. package/dist/api/LwM2M.js +11 -11
  10. package/dist/api/ObjectUpdate.js +17 -0
  11. package/dist/api/ObjectUpdate.spec.js +26 -0
  12. package/dist/api/ShareDeviceOwnershipConfirmed.js +4 -4
  13. package/dist/api/ShareDeviceRequest.js +4 -4
  14. package/dist/api/Timestamp.js +3 -3
  15. package/dist/api/Timestamp.spec.js +9 -9
  16. package/dist/api/index.js +8 -8
  17. package/dist/generator/addDocBlock.js +2 -2
  18. package/dist/generator/generateLwM2MDefinitions.js +27 -27
  19. package/dist/generator/generateLwM2MDefinitions.spec.js +32 -32
  20. package/dist/generator/generateLwm2mTimestampResources.js +7 -7
  21. package/dist/generator/generateModels.js +37 -37
  22. package/dist/generator/generateType.js +21 -21
  23. package/dist/generator/generateValidator.js +29 -29
  24. package/dist/generator/generateValidators.js +9 -9
  25. package/dist/generator/isDir.js +1 -1
  26. package/dist/generator/isDir.spec.js +13 -13
  27. package/dist/generator/lwm2m.js +23 -23
  28. package/dist/generator/models.js +23 -23
  29. package/dist/generator/printNode.js +2 -2
  30. package/dist/generator/tokenizeName.js +2 -2
  31. package/dist/generator/tokenizeName.spec.js +20 -20
  32. package/dist/generator/types.js +37 -37
  33. package/dist/lwm2m/LWM2MObjectDefinition.js +30 -30
  34. package/dist/lwm2m/check-lwm2m-rules.js +34 -34
  35. package/dist/lwm2m/definitions.js +4 -4
  36. package/dist/lwm2m/fromXML2JSON.js +4 -4
  37. package/dist/lwm2m/instanceTs.js +2 -2
  38. package/dist/lwm2m/instanceTs.spec.js +10 -10
  39. package/dist/lwm2m/isRegisteredLwM2MObject.js +2 -2
  40. package/dist/lwm2m/isRegisteredLwM2MObject.spec.js +12 -12
  41. package/dist/lwm2m/parseRangeEnumeration.js +1 -1
  42. package/dist/lwm2m/parseRangeEnumeration.spec.js +11 -11
  43. package/dist/lwm2m/unwrapNestedArray.js +2 -2
  44. package/dist/lwm2m/unwrapNestedArray.spec.js +155 -155
  45. package/dist/lwm2m/validate.js +1 -1
  46. package/dist/lwm2m/validation.js +16 -16
  47. package/dist/markdown/getCodeBlock.js +5 -5
  48. package/dist/markdown/getFrontMatter.js +6 -6
  49. package/dist/markdown/parseREADME.js +5 -5
  50. package/dist/models/asset_tracker_v2+AWS/examples/examples.spec.js +21 -21
  51. package/dist/models/check-model-rules.js +42 -42
  52. package/dist/models/models.js +20 -20
  53. package/dist/models/types.js +3 -3
  54. package/dist/senml/SenMLSchema.js +16 -16
  55. package/dist/senml/SenMLSchema.spec.js +11 -11
  56. package/dist/senml/hasValue.js +2 -2
  57. package/dist/senml/hasValue.spec.js +4 -4
  58. package/dist/senml/lwm2mToSenML.js +8 -8
  59. package/dist/senml/lwm2mToSenML.spec.js +42 -42
  60. package/dist/senml/parseResourceId.js +1 -1
  61. package/dist/senml/parseResourceId.spec.js +6 -6
  62. package/dist/senml/senMLtoLwM2M.js +14 -14
  63. package/dist/senml/senMLtoLwM2M.spec.js +53 -53
  64. package/dist/senml/validateSenML.js +2 -2
  65. package/dist/senml/validateSenML.spec.js +11 -11
  66. package/package.json +4 -8
  67. package/dist/api/ResourceUpdate.js +0 -17
  68. package/dist/api/ResourceUpdate.spec.js +0 -26
@@ -44,16 +44,16 @@ function _unsupported_iterable_to_array(o, minLen) {
44
44
  if (n === "Map" || n === "Set") return Array.from(n);
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
- import ts from "typescript";
48
- import { addDocBlock } from "./addDocBlock.js";
47
+ import ts from 'typescript';
48
+ import { addDocBlock } from './addDocBlock.js';
49
49
  export var generateLwm2mTimestampResources = function(timestampResources) {
50
50
  var type = ts.factory.createVariableStatement([
51
51
  ts.factory.createToken(ts.SyntaxKind.ExportKeyword)
52
52
  ], ts.factory.createVariableDeclarationList([
53
- ts.factory.createVariableDeclaration(ts.factory.createIdentifier("timestampResources"), undefined, ts.factory.createTypeReferenceNode("Readonly", [
54
- ts.factory.createTypeReferenceNode("Record", [
55
- ts.factory.createTypeReferenceNode("number"),
56
- ts.factory.createTypeReferenceNode("number")
53
+ ts.factory.createVariableDeclaration(ts.factory.createIdentifier("timestampResources"), undefined, ts.factory.createTypeReferenceNode('Readonly', [
54
+ ts.factory.createTypeReferenceNode('Record', [
55
+ ts.factory.createTypeReferenceNode('number'),
56
+ ts.factory.createTypeReferenceNode('number')
57
57
  ])
58
58
  ]), ts.factory.createObjectLiteralExpression(Object.entries(timestampResources).map(function(param) {
59
59
  var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
@@ -61,7 +61,7 @@ export var generateLwm2mTimestampResources = function(timestampResources) {
61
61
  })))
62
62
  ], ts.NodeFlags.Const));
63
63
  addDocBlock([
64
- "Contains the ID of the resource that defines the timestamp for each LwM2M object definition"
64
+ 'Contains the ID of the resource that defines the timestamp for each LwM2M object definition'
65
65
  ], type);
66
66
  return [
67
67
  type
@@ -44,86 +44,86 @@ function _unsupported_iterable_to_array(o, minLen) {
44
44
  if (n === "Map" || n === "Set") return Array.from(n);
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
- import ts from "typescript";
48
- import { addDocBlock } from "./addDocBlock.js";
49
- import { tokenizeName } from "./tokenizeName.js";
50
- import { parseREADME } from "markdown/parseREADME.js";
47
+ import ts from 'typescript';
48
+ import { addDocBlock } from './addDocBlock.js';
49
+ import { tokenizeName } from './tokenizeName.js';
50
+ import { parseREADME } from 'markdown/parseREADME.js';
51
51
  export var generateModels = function(models) {
52
52
  var types = [];
53
53
  types.push(ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([
54
- ts.factory.createImportSpecifier(true, undefined, ts.factory.createIdentifier("Transform")),
55
- ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier("TransformType"))
54
+ ts.factory.createImportSpecifier(true, undefined, ts.factory.createIdentifier('Transform')),
55
+ ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier('TransformType'))
56
56
  ])), ts.factory.createStringLiteral("./types.js")));
57
57
  types.push(addDocBlock([
58
- "The Model IDs defined in this repo."
58
+ 'The Model IDs defined in this repo.'
59
59
  ], ts.factory.createEnumDeclaration([
60
60
  ts.factory.createToken(ts.SyntaxKind.ExportKeyword)
61
- ], ts.factory.createIdentifier("ModelID"), models.map(function(param) {
61
+ ], ts.factory.createIdentifier('ModelID'), models.map(function(param) {
62
62
  var id = param.id;
63
63
  return ts.factory.createEnumMember(tokenizeName(id), ts.factory.createStringLiteral(id));
64
64
  }))));
65
65
  types.push(ts.factory.createTypeAliasDeclaration([
66
66
  ts.factory.createToken(ts.SyntaxKind.ExportKeyword)
67
- ], ts.factory.createIdentifier("Model"), undefined, ts.factory.createTypeLiteralNode([
67
+ ], ts.factory.createIdentifier('Model'), undefined, ts.factory.createTypeLiteralNode([
68
68
  addDocBlock([
69
- "The Model ID"
70
- ], ts.factory.createPropertySignature(undefined, ts.factory.createStringLiteral("id"), undefined, ts.factory.createTypeReferenceNode("ModelID"))),
69
+ 'The Model ID'
70
+ ], ts.factory.createPropertySignature(undefined, ts.factory.createStringLiteral('id'), undefined, ts.factory.createTypeReferenceNode('ModelID'))),
71
71
  addDocBlock([
72
- "The transforms defined for this model."
73
- ], ts.factory.createPropertySignature(undefined, ts.factory.createStringLiteral("transforms"), undefined, ts.factory.createTypeReferenceNode("Array", [
74
- ts.factory.createTypeReferenceNode("Transform")
72
+ 'The transforms defined for this model.'
73
+ ], ts.factory.createPropertySignature(undefined, ts.factory.createStringLiteral('transforms'), undefined, ts.factory.createTypeReferenceNode('Array', [
74
+ ts.factory.createTypeReferenceNode('Transform')
75
75
  ]))),
76
76
  addDocBlock([
77
- "Description of the Model from the README.md"
78
- ], ts.factory.createPropertySignature(undefined, ts.factory.createStringLiteral("about"), undefined, ts.factory.createTypeLiteralNode([
77
+ 'Description of the Model from the README.md'
78
+ ], ts.factory.createPropertySignature(undefined, ts.factory.createStringLiteral('about'), undefined, ts.factory.createTypeLiteralNode([
79
79
  addDocBlock([
80
- "The text of the H1 headline"
81
- ], ts.factory.createPropertySignature(undefined, ts.factory.createStringLiteral("title"), undefined, ts.factory.createTypeReferenceNode("string"))),
80
+ 'The text of the H1 headline'
81
+ ], ts.factory.createPropertySignature(undefined, ts.factory.createStringLiteral('title'), undefined, ts.factory.createTypeReferenceNode('string'))),
82
82
  addDocBlock([
83
- "The text of the paragraphs following the H1 headline"
84
- ], ts.factory.createPropertySignature(undefined, ts.factory.createStringLiteral("description"), undefined, ts.factory.createTypeReferenceNode("string")))
83
+ 'The text of the paragraphs following the H1 headline'
84
+ ], ts.factory.createPropertySignature(undefined, ts.factory.createStringLiteral('description'), undefined, ts.factory.createTypeReferenceNode('string')))
85
85
  ])))
86
86
  ])));
87
87
  types.push(addDocBlock([
88
- "The models defined for hello.nrfcloud.com"
88
+ 'The models defined for hello.nrfcloud.com'
89
89
  ], ts.factory.createVariableStatement([
90
90
  ts.factory.createToken(ts.SyntaxKind.ExportKeyword)
91
91
  ], ts.factory.createVariableDeclarationList([
92
- ts.factory.createVariableDeclaration(ts.factory.createIdentifier("models"), undefined, ts.factory.createTypeReferenceNode("Readonly", [
93
- ts.factory.createTypeReferenceNode("Record", [
94
- ts.factory.createTypeReferenceNode("ModelID", []),
95
- ts.factory.createTypeReferenceNode("Model", [])
92
+ ts.factory.createVariableDeclaration(ts.factory.createIdentifier("models"), undefined, ts.factory.createTypeReferenceNode('Readonly', [
93
+ ts.factory.createTypeReferenceNode('Record', [
94
+ ts.factory.createTypeReferenceNode('ModelID', []),
95
+ ts.factory.createTypeReferenceNode('Model', [])
96
96
  ])
97
97
  ]), ts.factory.createAsExpression(ts.factory.createObjectLiteralExpression(models.map(function(model) {
98
98
  var readme = parseREADME(model.readmeMarkdown);
99
- return ts.factory.createPropertyAssignment(ts.factory.createComputedPropertyName(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("ModelID"), ts.factory.createIdentifier(tokenizeName(model.id)))), // The model object
99
+ return ts.factory.createPropertyAssignment(ts.factory.createComputedPropertyName(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('ModelID'), ts.factory.createIdentifier(tokenizeName(model.id)))), // The model object
100
100
  ts.factory.createObjectLiteralExpression([
101
101
  // id
102
- ts.factory.createPropertyAssignment(ts.factory.createStringLiteral("id"), ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("ModelID"), ts.factory.createIdentifier(tokenizeName(model.id)))),
102
+ ts.factory.createPropertyAssignment(ts.factory.createStringLiteral('id'), ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('ModelID'), ts.factory.createIdentifier(tokenizeName(model.id)))),
103
103
  // transforms
104
- ts.factory.createPropertyAssignment(ts.factory.createStringLiteral("transforms"), ts.factory.createArrayLiteralExpression(model.transforms.map(function(transform) {
104
+ ts.factory.createPropertyAssignment(ts.factory.createStringLiteral('transforms'), ts.factory.createArrayLiteralExpression(model.transforms.map(function(transform) {
105
105
  return ts.factory.createObjectLiteralExpression([
106
106
  // type
107
- ts.factory.createPropertyAssignment(ts.factory.createStringLiteral("type"), transform.type === "messages" ? ts.factory.createIdentifier("TransformType.Messages") : ts.factory.createIdentifier("TransformType.Shadow")),
107
+ ts.factory.createPropertyAssignment(ts.factory.createStringLiteral('type'), transform.type === 'messages' ? ts.factory.createIdentifier('TransformType.Messages') : ts.factory.createIdentifier('TransformType.Shadow')),
108
108
  // match
109
- ts.factory.createPropertyAssignment(ts.factory.createStringLiteral("match"), createAssignment(transform.match)),
109
+ ts.factory.createPropertyAssignment(ts.factory.createStringLiteral('match'), createAssignment(transform.match)),
110
110
  // transform
111
- ts.factory.createPropertyAssignment(ts.factory.createStringLiteral("transform"), createAssignment(transform.transform))
111
+ ts.factory.createPropertyAssignment(ts.factory.createStringLiteral('transform'), createAssignment(transform.transform))
112
112
  ]);
113
113
  }))),
114
114
  // About
115
- ts.factory.createPropertyAssignment(ts.factory.createStringLiteral("about"), ts.factory.createObjectLiteralExpression([
116
- ts.factory.createPropertyAssignment(ts.factory.createStringLiteral("title"), ts.factory.createStringLiteral(readme.heading)),
117
- ts.factory.createPropertyAssignment(ts.factory.createStringLiteral("description"), ts.factory.createStringLiteral(readme.description.join("\n")))
115
+ ts.factory.createPropertyAssignment(ts.factory.createStringLiteral('about'), ts.factory.createObjectLiteralExpression([
116
+ ts.factory.createPropertyAssignment(ts.factory.createStringLiteral('title'), ts.factory.createStringLiteral(readme.heading)),
117
+ ts.factory.createPropertyAssignment(ts.factory.createStringLiteral('description'), ts.factory.createStringLiteral(readme.description.join('\n')))
118
118
  ]))
119
119
  ]));
120
- })), ts.factory.createTypeReferenceNode("const")))
120
+ })), ts.factory.createTypeReferenceNode('const')))
121
121
  ], ts.NodeFlags.Const))));
122
122
  return types;
123
123
  };
124
124
  var createAssignment = function(v) {
125
125
  if (v === null) return ts.factory.createNull();
126
- if (typeof v === "string") {
126
+ if (typeof v === 'string') {
127
127
  return ts.factory.createStringLiteral(v);
128
128
  }
129
129
  if (Array.isArray(v)) {
@@ -131,7 +131,7 @@ var createAssignment = function(v) {
131
131
  return createAssignment(el);
132
132
  }));
133
133
  }
134
- if (typeof v === "object") return ts.factory.createObjectLiteralExpression(Object.entries(v).map(function(param) {
134
+ if (typeof v === 'object') return ts.factory.createObjectLiteralExpression(Object.entries(v).map(function(param) {
135
135
  var _param = _sliced_to_array(param, 2), k = _param[0], _$v = _param[1];
136
136
  return ts.factory.createPropertyAssignment(ts.factory.createStringLiteral(k), createAssignment(_$v));
137
137
  }));
@@ -1,8 +1,8 @@
1
- import ts from "typescript";
2
- import { addDocBlock } from "./addDocBlock.js";
3
- import { LwM2MType } from "../lwm2m/resourceType.js";
4
- import { tokenizeName } from "./tokenizeName.js";
5
- import { parseRangeEnumeration } from "lwm2m/parseRangeEnumeration.js";
1
+ import ts from 'typescript';
2
+ import { addDocBlock } from './addDocBlock.js';
3
+ import { LwM2MType } from '../lwm2m/resourceType.js';
4
+ import { tokenizeName } from './tokenizeName.js';
5
+ import { parseRangeEnumeration } from 'lwm2m/parseRangeEnumeration.js';
6
6
  export var generateType = function(param) {
7
7
  var ObjectID = param.ObjectID, ObjectVersion = param.ObjectVersion, Name = param.Name, Description1 = param.Description1, Resources = param.Resources;
8
8
  var name = generateName({
@@ -11,27 +11,27 @@ export var generateType = function(param) {
11
11
  });
12
12
  var importLwM2MObject = ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(true, undefined, ts.factory.createNamedImports([
13
13
  ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier("LwM2MObject"))
14
- ])), ts.factory.createStringLiteral("../LwM2MObject.js"));
14
+ ])), ts.factory.createStringLiteral('../LwM2MObject.js'));
15
15
  var importLwM2MObjectID = ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([
16
16
  ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier("LwM2MObjectID"))
17
- ])), ts.factory.createStringLiteral("../LwM2MObjectID.js"));
17
+ ])), ts.factory.createStringLiteral('../LwM2MObjectID.js'));
18
18
  // Generate the type
19
19
  var exportType = ts.factory.createTypeAliasDeclaration([
20
20
  ts.factory.createToken(ts.SyntaxKind.ExportKeyword)
21
- ], ts.factory.createIdentifier(name), undefined, ts.factory.createTypeReferenceNode("LwM2MObject", [
21
+ ], ts.factory.createIdentifier(name), undefined, ts.factory.createTypeReferenceNode('LwM2MObject', [
22
22
  ts.factory.createTypeLiteralNode([
23
- ts.factory.createPropertySignature(undefined, ts.factory.createIdentifier("ObjectID"), undefined, ts.factory.createTypeReferenceNode("LwM2MObjectID.".concat(name), undefined)),
24
- ts.factory.createPropertySignature(undefined, ts.factory.createIdentifier("ObjectVersion"), undefined, ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(ObjectVersion !== null && ObjectVersion !== void 0 ? ObjectVersion : "1.0"))),
25
- ts.factory.createPropertySignature(undefined, ts.factory.createIdentifier("Resources"), undefined, ts.factory.createTypeLiteralNode(byImportance(Resources.Item).map(function(resource) {
26
- var res = ts.factory.createPropertySignature(undefined, ts.factory.createIdentifier("".concat(resource.$.ID)), resource.Mandatory === "Mandatory" ? undefined : ts.factory.createToken(ts.SyntaxKind.QuestionToken), typeScriptResourceType(resource.Type));
23
+ ts.factory.createPropertySignature(undefined, ts.factory.createIdentifier('ObjectID'), undefined, ts.factory.createTypeReferenceNode("LwM2MObjectID.".concat(name), undefined)),
24
+ ts.factory.createPropertySignature(undefined, ts.factory.createIdentifier('ObjectVersion'), undefined, ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(ObjectVersion !== null && ObjectVersion !== void 0 ? ObjectVersion : '1.0'))),
25
+ ts.factory.createPropertySignature(undefined, ts.factory.createIdentifier('Resources'), undefined, ts.factory.createTypeLiteralNode(byImportance(Resources.Item).map(function(resource) {
26
+ var res = ts.factory.createPropertySignature(undefined, ts.factory.createIdentifier("".concat(resource.$.ID)), resource.Mandatory === 'Mandatory' ? undefined : ts.factory.createToken(ts.SyntaxKind.QuestionToken), typeScriptResourceType(resource.Type));
27
27
  addDocBlock([
28
- "".concat(resource.Name).concat(resource.Units.length > 0 ? " (".concat(resource.Units, ")") : ""),
28
+ "".concat(resource.Name).concat(resource.Units.length > 0 ? " (".concat(resource.Units, ")") : ''),
29
29
  "",
30
30
  resource.Description
31
31
  ], res);
32
32
  if (resource.RangeEnumeration.length > 0) {
33
33
  var maybeRange = parseRangeEnumeration(resource.RangeEnumeration);
34
- if ("error" in maybeRange) throw maybeRange.error;
34
+ if ('error' in maybeRange) throw maybeRange.error;
35
35
  addDocBlock([
36
36
  "Minimum: ".concat(maybeRange.range.min),
37
37
  "Maximum: ".concat(maybeRange.range.max)
@@ -43,7 +43,7 @@ export var generateType = function(param) {
43
43
  ]));
44
44
  addDocBlock([
45
45
  "".concat(Name, " (").concat(ObjectID, ")"),
46
- "",
46
+ '',
47
47
  Description1
48
48
  ], exportType);
49
49
  return [
@@ -61,16 +61,16 @@ var typeScriptResourceType = function(type) {
61
61
  case LwM2MType.Float:
62
62
  case LwM2MType.Integer:
63
63
  case LwM2MType.UnsignedInteger:
64
- return ts.factory.createTypeReferenceNode("number");
64
+ return ts.factory.createTypeReferenceNode('number');
65
65
  case LwM2MType.Boolean:
66
- return ts.factory.createTypeReferenceNode("boolean");
66
+ return ts.factory.createTypeReferenceNode('boolean');
67
67
  case LwM2MType.String:
68
68
  case LwM2MType.Opaque:
69
69
  case LwM2MType.Corelnk:
70
70
  case LwM2MType.Objlnk:
71
- return ts.factory.createTypeReferenceNode("string");
71
+ return ts.factory.createTypeReferenceNode('string');
72
72
  case LwM2MType.Time:
73
- return ts.factory.createTypeReferenceNode("Date");
73
+ return ts.factory.createTypeReferenceNode('Date');
74
74
  default:
75
75
  throw new Error("Unexpected resource type: ".concat(type));
76
76
  }
@@ -83,8 +83,8 @@ var byImportance = function(resources) {
83
83
  })// sort mandatory up
84
84
  .sort(function(param, param1) {
85
85
  var m1 = param.Mandatory, m2 = param1.Mandatory;
86
- if (m1 === "Mandatory" && m2 === "Mandatory") return 0;
87
- if (m1 === "Mandatory") return -1;
86
+ if (m1 === 'Mandatory' && m2 === 'Mandatory') return 0;
87
+ if (m1 === 'Mandatory') return -1;
88
88
  return 1;
89
89
  });
90
90
  };
@@ -23,15 +23,15 @@ function _unsupported_iterable_to_array(o, minLen) {
23
23
  if (n === "Map" || n === "Set") return Array.from(n);
24
24
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
25
25
  }
26
- import ts from "typescript";
27
- import { generateName } from "./generateType.js";
28
- import { addDocBlock } from "./addDocBlock.js";
26
+ import ts from 'typescript';
27
+ import { generateName } from './generateType.js';
28
+ import { addDocBlock } from './addDocBlock.js';
29
29
  export var generateValidator = function(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([
33
33
  ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier("LwM2MObject"))
34
- ])), ts.factory.createStringLiteral("../LwM2MObject.js"));
34
+ ])), ts.factory.createStringLiteral('../LwM2MObject.js'));
35
35
  /*
36
36
  import {
37
37
  DateResource,
@@ -43,10 +43,10 @@ export var generateValidator = function(param) {
43
43
  */ var importValidation = ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports(_to_consumable_array(getResourceValidators({
44
44
  Resources: Resources
45
45
  })).concat([
46
- "validate"
46
+ 'validate'
47
47
  ]).map(function(res) {
48
48
  return ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier(res));
49
- }))), ts.factory.createStringLiteral("../validation.js"));
49
+ }))), ts.factory.createStringLiteral('../validation.js'));
50
50
  // import type { Geolocation_14201 } from './objects.js'
51
51
  var name = generateName({
52
52
  Name: Name,
@@ -54,32 +54,32 @@ export var generateValidator = function(param) {
54
54
  });
55
55
  var importObjectType = ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(true, undefined, ts.factory.createNamedImports([
56
56
  ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier(name))
57
- ])), ts.factory.createStringLiteral("../objects.js"));
57
+ ])), ts.factory.createStringLiteral('../objects.js'));
58
58
  // import { LwM2MObjectID } from './LwM2MObjectID.js'
59
59
  var importLwM2MObjectID = ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([
60
60
  ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier("LwM2MObjectID"))
61
- ])), ts.factory.createStringLiteral("../LwM2MObjectID.js"));
61
+ ])), ts.factory.createStringLiteral('../LwM2MObjectID.js'));
62
62
  // validate ...
63
63
  var validate = ts.factory.createVariableStatement([
64
64
  ts.factory.createToken(ts.SyntaxKind.ExportKeyword)
65
65
  ], ts.factory.createVariableDeclarationList([
66
66
  ts.factory.createVariableDeclaration(ts.factory.createIdentifier("validate".concat(ObjectID)), undefined, undefined, ts.factory.createArrowFunction(undefined, undefined, [
67
- ts.factory.createParameterDeclaration(undefined, undefined, ts.factory.createIdentifier("o"), undefined, ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword)),
68
- ts.factory.createParameterDeclaration(undefined, undefined, ts.factory.createIdentifier("onError"), ts.factory.createToken(ts.SyntaxKind.QuestionToken), ts.factory.createFunctionTypeNode(undefined, [
69
- ts.factory.createParameterDeclaration(undefined, undefined, ts.factory.createIdentifier("error"), undefined, ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("Error")))
67
+ ts.factory.createParameterDeclaration(undefined, undefined, ts.factory.createIdentifier('o'), undefined, ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword)),
68
+ ts.factory.createParameterDeclaration(undefined, undefined, ts.factory.createIdentifier('onError'), ts.factory.createToken(ts.SyntaxKind.QuestionToken), ts.factory.createFunctionTypeNode(undefined, [
69
+ ts.factory.createParameterDeclaration(undefined, undefined, ts.factory.createIdentifier('error'), undefined, ts.factory.createTypeReferenceNode(ts.factory.createIdentifier('Error')))
70
70
  ], ts.factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword)))
71
- ], ts.factory.createTypePredicateNode(undefined, ts.factory.createIdentifier("o"), ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("LwM2MObject"), [
71
+ ], ts.factory.createTypePredicateNode(undefined, ts.factory.createIdentifier('o'), ts.factory.createTypeReferenceNode(ts.factory.createIdentifier('LwM2MObject'), [
72
72
  ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name))
73
- ])), undefined, ts.factory.createCallExpression(ts.factory.createCallExpression(ts.factory.createIdentifier("validate"), undefined, [
74
- ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("LwM2MObjectID"), ts.factory.createIdentifier(name)),
75
- ts.factory.createStringLiteral(ObjectVersion !== null && ObjectVersion !== void 0 ? ObjectVersion : "1.0"),
73
+ ])), undefined, ts.factory.createCallExpression(ts.factory.createCallExpression(ts.factory.createIdentifier('validate'), undefined, [
74
+ ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('LwM2MObjectID'), ts.factory.createIdentifier(name)),
75
+ ts.factory.createStringLiteral(ObjectVersion !== null && ObjectVersion !== void 0 ? ObjectVersion : '1.0'),
76
76
  ts.factory.createObjectLiteralExpression(Resources.Item.map(function(Resource) {
77
77
  var validator = ts.factory.createPropertyAssignment(ts.factory.createNumericLiteral(Resource.$.ID), toResourceValidator(Resource));
78
78
  return validator;
79
79
  }))
80
80
  ]), undefined, [
81
- ts.factory.createIdentifier("o"),
82
- ts.factory.createIdentifier("onError")
81
+ ts.factory.createIdentifier('o'),
82
+ ts.factory.createIdentifier('onError')
83
83
  ])))
84
84
  ], ts.NodeFlags.Const));
85
85
  addDocBlock([
@@ -97,23 +97,23 @@ export var generateValidator = function(param) {
97
97
  };
98
98
  var toResourceValidator = function(Resource) {
99
99
  var valueValidator = ts.factory.createIdentifier(typeToValidator(Resource.Type));
100
- if (Resource.Mandatory === "Optional") return ts.factory.createCallExpression(ts.factory.createIdentifier("OptionalResource"), undefined, [
100
+ if (Resource.Mandatory === 'Optional') return ts.factory.createCallExpression(ts.factory.createIdentifier('OptionalResource'), undefined, [
101
101
  valueValidator
102
102
  ]);
103
103
  return valueValidator;
104
104
  };
105
105
  var typeToValidator = function(Type) {
106
106
  switch(Type){
107
- case "String":
108
- case "Opaque":
109
- return "StringResource";
110
- case "Float":
111
- case "Integer":
112
- return "NumberResource";
113
- case "Boolean":
114
- return "BooleanResource";
115
- case "Time":
116
- return "DateResource";
107
+ case 'String':
108
+ case 'Opaque':
109
+ return 'StringResource';
110
+ case 'Float':
111
+ case 'Integer':
112
+ return 'NumberResource';
113
+ case 'Boolean':
114
+ return 'BooleanResource';
115
+ case 'Time':
116
+ return 'DateResource';
117
117
  default:
118
118
  throw new Error("Unsupported Resource type ".concat(Type, "!"));
119
119
  }
@@ -124,7 +124,7 @@ var getResourceValidators = function(param) {
124
124
  var Type = param.Type, Mandatory = param.Mandatory;
125
125
  return [
126
126
  typeToValidator(Type),
127
- Mandatory === "Optional" ? "OptionalResource" : undefined
127
+ Mandatory === 'Optional' ? 'OptionalResource' : undefined
128
128
  ];
129
129
  }).flat().filter(function(d) {
130
130
  return d !== undefined;
@@ -23,14 +23,14 @@ function _unsupported_iterable_to_array(o, minLen) {
23
23
  if (n === "Map" || n === "Set") return Array.from(n);
24
24
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
25
25
  }
26
- import ts from "typescript";
27
- import { generateName } from "./generateType.js";
28
- import { addDocBlock } from "./addDocBlock.js";
26
+ import ts from 'typescript';
27
+ import { generateName } from './generateType.js';
28
+ import { addDocBlock } from './addDocBlock.js';
29
29
  export var generateValidators = function(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"))
33
- ])), ts.factory.createStringLiteral("./LwM2MObjectID.js"));
33
+ ])), ts.factory.createStringLiteral('./LwM2MObjectID.js'));
34
34
  var validatorImports = objects.map(function(object) {
35
35
  return ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([
36
36
  ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier("validate".concat(object.ObjectID)))
@@ -39,10 +39,10 @@ export var generateValidators = function(objects) {
39
39
  var validators = ts.factory.createVariableStatement([
40
40
  ts.factory.createToken(ts.SyntaxKind.ExportKeyword)
41
41
  ], ts.factory.createVariableDeclarationList([
42
- ts.factory.createVariableDeclaration(ts.factory.createIdentifier("validators"), undefined, undefined, ts.factory.createNewExpression(ts.factory.createIdentifier("Map"), [
43
- ts.factory.createTypeReferenceNode("LwM2MObjectID"),
42
+ ts.factory.createVariableDeclaration(ts.factory.createIdentifier("validators"), undefined, undefined, ts.factory.createNewExpression(ts.factory.createIdentifier('Map'), [
43
+ ts.factory.createTypeReferenceNode('LwM2MObjectID'),
44
44
  ts.factory.createFunctionTypeNode(undefined, [
45
- ts.factory.createParameterDeclaration(undefined, undefined, ts.factory.createIdentifier("o"), undefined, ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword))
45
+ ts.factory.createParameterDeclaration(undefined, undefined, ts.factory.createIdentifier('o'), undefined, ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword))
46
46
  ], ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword))
47
47
  ], []))
48
48
  ], ts.NodeFlags.Const));
@@ -50,8 +50,8 @@ export var generateValidators = function(objects) {
50
50
  "Contains the validators for all registered LwM2M objects."
51
51
  ], validators);
52
52
  var validatorRegistrations = objects.map(function(object) {
53
- return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("validators"), ts.factory.createIdentifier("set")), undefined, [
54
- ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("LwM2MObjectID"), ts.factory.createIdentifier(generateName(object))),
53
+ return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('validators'), ts.factory.createIdentifier('set')), undefined, [
54
+ ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('LwM2MObjectID'), ts.factory.createIdentifier(generateName(object))),
55
55
  ts.factory.createIdentifier("validate".concat(object.ObjectID))
56
56
  ]);
57
57
  });
@@ -122,7 +122,7 @@ function _ts_generator(thisArg, body) {
122
122
  };
123
123
  }
124
124
  }
125
- import { stat } from "node:fs/promises";
125
+ import { stat } from 'node:fs/promises';
126
126
  export var isDir = function() {
127
127
  var _ref = _async_to_generator(function(path) {
128
128
  var e;
@@ -122,13 +122,13 @@ function _ts_generator(thisArg, body) {
122
122
  };
123
123
  }
124
124
  }
125
- import { isDir } from "./isDir.js";
126
- import { describe, it, before } from "node:test";
127
- import assert from "node:assert/strict";
128
- import os from "node:os";
129
- import { mkdtemp } from "node:fs/promises";
130
- import path from "node:path";
131
- void describe("isDir()", function() {
125
+ import { isDir } from './isDir.js';
126
+ import { describe, it, before } from 'node:test';
127
+ import assert from 'node:assert/strict';
128
+ import os from 'node:os';
129
+ import { mkdtemp } from 'node:fs/promises';
130
+ import path from 'node:path';
131
+ void describe('isDir()', function() {
132
132
  var dir;
133
133
  void before(/*#__PURE__*/ _async_to_generator(function() {
134
134
  return _ts_generator(this, function(_state) {
@@ -136,7 +136,7 @@ void describe("isDir()", function() {
136
136
  case 0:
137
137
  return [
138
138
  4,
139
- mkdtemp(path.join(os.tmpdir(), "isdir-"))
139
+ mkdtemp(path.join(os.tmpdir(), 'isdir-'))
140
140
  ];
141
141
  case 1:
142
142
  dir = _state.sent();
@@ -146,7 +146,7 @@ void describe("isDir()", function() {
146
146
  }
147
147
  });
148
148
  }));
149
- void it("should return true if the path is a directory", /*#__PURE__*/ _async_to_generator(function() {
149
+ void it('should return true if the path is a directory', /*#__PURE__*/ _async_to_generator(function() {
150
150
  var _;
151
151
  return _ts_generator(this, function(_state) {
152
152
  switch(_state.label){
@@ -167,7 +167,7 @@ void describe("isDir()", function() {
167
167
  }
168
168
  });
169
169
  }));
170
- void it("should return false if the path is not a directory", /*#__PURE__*/ _async_to_generator(function() {
170
+ void it('should return false if the path is not a directory', /*#__PURE__*/ _async_to_generator(function() {
171
171
  var _;
172
172
  return _ts_generator(this, function(_state) {
173
173
  switch(_state.label){
@@ -175,7 +175,7 @@ void describe("isDir()", function() {
175
175
  _ = assert.strictEqual;
176
176
  return [
177
177
  4,
178
- isDir(path.join(dir, "foo.txt"))
178
+ isDir(path.join(dir, 'foo.txt'))
179
179
  ];
180
180
  case 1:
181
181
  return [
@@ -188,7 +188,7 @@ void describe("isDir()", function() {
188
188
  }
189
189
  });
190
190
  }));
191
- void it("should return false if an error occurs", /*#__PURE__*/ _async_to_generator(function() {
191
+ void it('should return false if an error occurs', /*#__PURE__*/ _async_to_generator(function() {
192
192
  var _;
193
193
  return _ts_generator(this, function(_state) {
194
194
  switch(_state.label){
@@ -196,7 +196,7 @@ void describe("isDir()", function() {
196
196
  _ = assert.strictEqual;
197
197
  return [
198
198
  4,
199
- isDir(path.join(dir, "foo"))
199
+ isDir(path.join(dir, 'foo'))
200
200
  ];
201
201
  case 1:
202
202
  return [
@@ -24,15 +24,15 @@ function _unsupported_iterable_to_array(o, minLen) {
24
24
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
25
25
  }
26
26
  var _path;
27
- import chalk from "chalk";
28
- import { readFile, readdir, writeFile } from "node:fs/promises";
29
- import path from "node:path";
30
- import { unwrapNestedArray } from "../lwm2m/unwrapNestedArray.js";
31
- import xml2js from "xml2js";
32
- import { generateLwm2mTimestampResources } from "./generateLwm2mTimestampResources.js";
33
- import { printNode } from "./printNode.js";
34
- import os from "node:os";
35
- import { generateLwM2MDefinitions } from "./generateLwM2MDefinitions.js";
27
+ import chalk from 'chalk';
28
+ import { readFile, readdir, writeFile } from 'node:fs/promises';
29
+ import path from 'node:path';
30
+ import { unwrapNestedArray } from '../lwm2m/unwrapNestedArray.js';
31
+ import xml2js from 'xml2js';
32
+ import { generateLwm2mTimestampResources } from './generateLwm2mTimestampResources.js';
33
+ import { printNode } from './printNode.js';
34
+ import os from 'node:os';
35
+ import { generateLwM2MDefinitions } from './generateLwM2MDefinitions.js';
36
36
  var baseDir = process.cwd();
37
37
  var subDir = function() {
38
38
  for(var _len = arguments.length, tree = new Array(_len), _key = 0; _key < _len; _key++){
@@ -42,16 +42,16 @@ var subDir = function() {
42
42
  baseDir
43
43
  ].concat(_to_consumable_array(tree)));
44
44
  };
45
- console.log(chalk.gray("LwM2M"));
45
+ console.log(chalk.gray('LwM2M'));
46
46
  // Load definitions
47
47
  var definitions = [];
48
48
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
49
49
  try {
50
- for(var _iterator = (await readdir(subDir("lwm2m"))).filter(function(s) {
51
- return s.endsWith(".xml");
50
+ for(var _iterator = (await readdir(subDir('lwm2m'))).filter(function(s) {
51
+ return s.endsWith('.xml');
52
52
  })[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
53
53
  var objectDefinitionFile = _step.value;
54
- var definition = unwrapNestedArray(await xml2js.parseStringPromise(await readFile(subDir("lwm2m", objectDefinitionFile), "utf-8"))).LWM2M.Object;
54
+ var definition = unwrapNestedArray(await xml2js.parseStringPromise(await readFile(subDir('lwm2m', objectDefinitionFile), 'utf-8'))).LWM2M.Object;
55
55
  definitions.push(definition);
56
56
  }
57
57
  } catch (err) {
@@ -68,7 +68,7 @@ try {
68
68
  }
69
69
  }
70
70
  }
71
- console.log(chalk.gray("", "\xb7"), chalk.gray("timestamp resources map"));
71
+ console.log(chalk.gray('', '·'), chalk.gray('timestamp resources map'));
72
72
  var timestampResources = {};
73
73
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
74
74
  try {
@@ -78,10 +78,10 @@ try {
78
78
  var ObjectID = parseInt(definition1.ObjectID, 10);
79
79
  var ResourceId = parseInt((_definition_Resources_Item_find = definition1.Resources.Item.find(function(param) {
80
80
  var Type = param.Type;
81
- return Type === "Time";
81
+ return Type === 'Time';
82
82
  })) === null || _definition_Resources_Item_find === void 0 ? void 0 : _definition_Resources_Item_find.$.ID, 10);
83
83
  timestampResources[ObjectID] = ResourceId;
84
- console.log(" ", chalk.gray("\xb7"), "".concat(chalk.white(ObjectID)).concat(chalk.gray(".")).concat(chalk.white(ResourceId)));
84
+ console.log(' ', chalk.gray('·'), "".concat(chalk.white(ObjectID)).concat(chalk.gray('.')).concat(chalk.white(ResourceId)));
85
85
  }
86
86
  } catch (err) {
87
87
  _didIteratorError1 = true;
@@ -97,10 +97,10 @@ try {
97
97
  }
98
98
  }
99
99
  }
100
- var timestampResourcesFile = subDir("lwm2m", "timestampResources.ts");
101
- console.log(chalk.green("Writing"), chalk.blue(timestampResourcesFile.replace(baseDir, "")));
102
- await writeFile(timestampResourcesFile, generateLwm2mTimestampResources(timestampResources).map(printNode).join(os.EOL), "utf-8");
103
- console.log(chalk.gray("", "\xb7"), chalk.gray("static object information"));
104
- var definitionsFile = subDir("lwm2m", "definitions.ts");
105
- console.log(chalk.green("Writing"), chalk.blue(definitionsFile.replace(baseDir, "")));
106
- await writeFile(definitionsFile, generateLwM2MDefinitions(definitions).map(printNode).join(os.EOL), "utf-8");
100
+ var timestampResourcesFile = subDir('lwm2m', 'timestampResources.ts');
101
+ console.log(chalk.green('Writing'), chalk.blue(timestampResourcesFile.replace(baseDir, '')));
102
+ await writeFile(timestampResourcesFile, generateLwm2mTimestampResources(timestampResources).map(printNode).join(os.EOL), 'utf-8');
103
+ console.log(chalk.gray('', '·'), chalk.gray('static object information'));
104
+ var definitionsFile = subDir('lwm2m', 'definitions.ts');
105
+ console.log(chalk.green('Writing'), chalk.blue(definitionsFile.replace(baseDir, '')));
106
+ await writeFile(definitionsFile, generateLwM2MDefinitions(definitions).map(printNode).join(os.EOL), 'utf-8');