@hello.nrfcloud.com/proto-map 5.6.1 → 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} +6 -6
  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
@@ -1,23 +1,23 @@
1
- import { describe, it } from "node:test";
2
- import assert from "node:assert/strict";
3
- import { definitions } from "../lwm2m/definitions.js";
4
- import { LwM2MObjectID } from "../lwm2m/LwM2MObjectID.js";
5
- import { ResourceType } from "../lwm2m/LWM2MObjectInfo.js";
6
- void describe("generateLwM2MDefinitions()", function() {
7
- void it("should have generated definitions from the XML files", function() {
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { definitions } from '../lwm2m/definitions.js';
4
+ import { LwM2MObjectID } from '../lwm2m/LwM2MObjectID.js';
5
+ import { ResourceType } from '../lwm2m/LWM2MObjectInfo.js';
6
+ void describe('generateLwM2MDefinitions()', function() {
7
+ void it('should have generated definitions from the XML files', function() {
8
8
  assert.deepEqual(definitions[LwM2MObjectID.Geolocation_14201], {
9
9
  ObjectID: 14201,
10
- ObjectVersion: "1.0",
11
- Name: "Geolocation",
12
- Description: "Describes the geo location of a device",
10
+ ObjectVersion: '1.0',
11
+ Name: 'Geolocation',
12
+ Description: 'Describes the geo location of a device',
13
13
  Resources: {
14
14
  0: {
15
15
  ResourceID: 0,
16
- Name: "Latitude",
16
+ Name: 'Latitude',
17
17
  Mandatory: true,
18
18
  Type: ResourceType.Float,
19
- Description: "The decimal notation of latitude in degrees, e.g. -43.5723 [World Geodetic System 1984].",
20
- Units: "\xb0",
19
+ Description: 'The decimal notation of latitude in degrees, e.g. -43.5723 [World Geodetic System 1984].',
20
+ Units: '°',
21
21
  RangeEnumeration: {
22
22
  max: 90,
23
23
  min: -90
@@ -25,11 +25,11 @@ void describe("generateLwM2MDefinitions()", function() {
25
25
  },
26
26
  1: {
27
27
  ResourceID: 1,
28
- Name: "Longitude",
28
+ Name: 'Longitude',
29
29
  Mandatory: true,
30
30
  Type: ResourceType.Float,
31
- Description: "The decimal notation of longitude in degrees, e.g. 153.21760 [World Geodetic System 1984].",
32
- Units: "\xb0",
31
+ Description: 'The decimal notation of longitude in degrees, e.g. 153.21760 [World Geodetic System 1984].',
32
+ Units: '°',
33
33
  RangeEnumeration: {
34
34
  max: 180,
35
35
  min: -180
@@ -37,35 +37,35 @@ void describe("generateLwM2MDefinitions()", function() {
37
37
  },
38
38
  2: {
39
39
  ResourceID: 2,
40
- Name: "Altitude",
40
+ Name: 'Altitude',
41
41
  Mandatory: false,
42
42
  Type: ResourceType.Float,
43
- Description: "The decimal notation of altitude in meters above sea level.",
44
- Units: "m"
43
+ Description: 'The decimal notation of altitude in meters above sea level.',
44
+ Units: 'm'
45
45
  },
46
46
  3: {
47
47
  ResourceID: 3,
48
- Name: "Radius",
48
+ Name: 'Radius',
49
49
  Mandatory: false,
50
50
  Type: ResourceType.Float,
51
- Description: "The value in this resource indicates the radius of a circular area in meters. The circular area is used to describe uncertainty about a point for coordinates in a two-dimensional coordinate reference systems (CRS). The center point of a circular area is specified by using the Latitude and the Longitude Resources.",
52
- Units: "m"
51
+ Description: 'The value in this resource indicates the radius of a circular area in meters. The circular area is used to describe uncertainty about a point for coordinates in a two-dimensional coordinate reference systems (CRS). The center point of a circular area is specified by using the Latitude and the Longitude Resources.',
52
+ Units: 'm'
53
53
  },
54
54
  4: {
55
55
  ResourceID: 4,
56
- Name: "Speed",
56
+ Name: 'Speed',
57
57
  Mandatory: false,
58
58
  Type: ResourceType.Float,
59
- Description: "Speed is the time rate of change in position.",
60
- Units: "m/s"
59
+ Description: 'Speed is the time rate of change in position.',
60
+ Units: 'm/s'
61
61
  },
62
62
  5: {
63
63
  ResourceID: 5,
64
- Name: "Heading",
64
+ Name: 'Heading',
65
65
  Mandatory: false,
66
66
  Type: ResourceType.Float,
67
- Description: "The angle of movement in degrees.",
68
- Units: "\xb0",
67
+ Description: 'The angle of movement in degrees.',
68
+ Units: '°',
69
69
  RangeEnumeration: {
70
70
  min: 0,
71
71
  max: 360
@@ -73,17 +73,17 @@ void describe("generateLwM2MDefinitions()", function() {
73
73
  },
74
74
  6: {
75
75
  ResourceID: 6,
76
- Name: "Source",
76
+ Name: 'Source',
77
77
  Mandatory: true,
78
78
  Type: ResourceType.String,
79
- Description: "The source of the geo location, e.g. GNSS, SCELL, MCELL, WIFI."
79
+ Description: 'The source of the geo location, e.g. GNSS, SCELL, MCELL, WIFI.'
80
80
  },
81
81
  99: {
82
82
  ResourceID: 99,
83
- Name: "Timestamp",
83
+ Name: 'Timestamp',
84
84
  Mandatory: true,
85
85
  Type: ResourceType.Time,
86
- Description: "The timestamp of when the location measurement was performed."
86
+ Description: 'The timestamp of when the location measurement was performed.'
87
87
  }
88
88
  }
89
89
  });
@@ -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;