@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
package/api/Context.ts CHANGED
@@ -10,6 +10,6 @@ export const Context = {
10
10
  request: new URL(`${baseURL}/share-device-request`),
11
11
  ownershipConfirmed: new URL(`${baseURL}/share-device-ownership-confirmed`),
12
12
  },
13
- resourceUpdate: new URL(`${baseURL}/resource/update`),
13
+ objectUpdate: new URL(`${baseURL}/object/update`),
14
14
  named: (name: string): URL => new URL(`${baseURL}/${name}`),
15
15
  }
@@ -1,13 +1,13 @@
1
1
  import { describe, it } from 'node:test'
2
2
  import assert from 'node:assert/strict'
3
3
  import { validate } from '../validate.js'
4
- import { ResourceUpdate } from './ResourceUpdate.js'
4
+ import { ObjectUpdate } from './ObjectUpdate.js'
5
5
  import type { Static } from '@sinclair/typebox'
6
6
 
7
- void describe('ResourceUpdate', () => {
7
+ void describe('ObjectUpdate', () => {
8
8
  void it('should validate', () => {
9
- const input: Static<typeof ResourceUpdate> = {
10
- '@context': 'https://github.com/hello-nrfcloud/proto-map/resource/update',
9
+ const input: Static<typeof ObjectUpdate> = {
10
+ '@context': 'https://github.com/hello-nrfcloud/proto-map/object/update',
11
11
  ObjectID: 14201,
12
12
  ObjectVersion: '1.0',
13
13
  ObjectInstanceID: 0,
@@ -21,7 +21,7 @@ void describe('ResourceUpdate', () => {
21
21
  deviceId: 'bassetto-ennobler-toilless',
22
22
  ts: '2024-04-19T08:30:00.000Z',
23
23
  }
24
- const maybeValid = validate(ResourceUpdate)(input)
24
+ const maybeValid = validate(ObjectUpdate)(input)
25
25
  assert.equal('errors' in maybeValid, false)
26
26
  assert.deepEqual('value' in maybeValid && maybeValid.value, input)
27
27
  })
@@ -9,18 +9,18 @@ import {
9
9
  import { PublicDeviceId } from './DeviceId.js'
10
10
  import { Timestamp } from './Timestamp.js'
11
11
 
12
- export const ResourceUpdate = Type.Object(
12
+ export const ObjectUpdate = Type.Object(
13
13
  {
14
- '@context': Type.Literal(Context.resourceUpdate.toString()),
14
+ '@context': Type.Literal(Context.objectUpdate.toString()),
15
15
  ObjectID,
16
- ObjectInstanceID,
17
- ObjectVersion,
16
+ ObjectInstanceID: Type.Optional(ObjectInstanceID),
17
+ ObjectVersion: Type.Optional(ObjectVersion),
18
18
  Resources,
19
19
  ts: Timestamp,
20
20
  deviceId: PublicDeviceId,
21
21
  },
22
22
  {
23
- title: 'Resource update',
24
- description: 'Describes an update to a LwM2M resource for a device.',
23
+ title: 'Object update',
24
+ description: 'Describes an update to a LwM2M object for a device.',
25
25
  },
26
26
  )
@@ -9,7 +9,7 @@ export var Context = {
9
9
  request: new URL("".concat(baseURL, "/share-device-request")),
10
10
  ownershipConfirmed: new URL("".concat(baseURL, "/share-device-ownership-confirmed"))
11
11
  },
12
- resourceUpdate: new URL("".concat(baseURL, "/resource/update")),
12
+ objectUpdate: new URL("".concat(baseURL, "/object/update")),
13
13
  named: function(name) {
14
14
  return new URL("".concat(baseURL, "/").concat(name));
15
15
  }
@@ -1,15 +1,15 @@
1
- import { Type } from "@sinclair/typebox";
1
+ import { Type } from '@sinclair/typebox';
2
2
  export var DeviceId = Type.RegExp(/^[a-zA-Z0-9:_-]{1,128}$/, {
3
- title: "Device ID",
4
- description: "Must follow the AWS IoT limitations for Thing names.",
3
+ title: 'Device ID',
4
+ description: 'Must follow the AWS IoT limitations for Thing names.',
5
5
  examples: [
6
- "oob-352656166666905"
6
+ 'oob-352656166666905'
7
7
  ]
8
8
  });
9
9
  export var PublicDeviceId = Type.RegExp(/^[a-z]{8}-[a-z]{8}-[a-z]{8}$/, {
10
- title: "Public Device ID",
11
- description: "This is the format of @nordicsemiconductor/random-words which is used for public IDs.",
10
+ title: 'Public Device ID',
11
+ description: 'This is the format of @nordicsemiconductor/random-words which is used for public IDs.',
12
12
  examples: [
13
- "pentacid-coxalgia-backheel"
13
+ 'pentacid-coxalgia-backheel'
14
14
  ]
15
15
  });
@@ -1,8 +1,8 @@
1
- import { Type } from "@sinclair/typebox";
2
- import { Context } from "./Context.js";
3
- import { PublicDeviceId } from "./DeviceId.js";
4
- import { models } from "@hello.nrfcloud.com/proto-map";
5
- import { ObjectID, ObjectInstanceID, ObjectVersion, Resources } from "./LwM2M.js";
1
+ import { Type } from '@sinclair/typebox';
2
+ import { Context } from './Context.js';
3
+ import { PublicDeviceId } from './DeviceId.js';
4
+ import { models } from '@hello.nrfcloud.com/proto-map';
5
+ import { ObjectID, ObjectInstanceID, ObjectVersion, Resources } from './LwM2M.js';
6
6
  export var LwM2MObjectInstance = Type.Object({
7
7
  ObjectID: ObjectID,
8
8
  ObjectVersion: Type.Optional(ObjectVersion),
@@ -12,19 +12,19 @@ export var LwM2MObjectInstance = Type.Object({
12
12
  export var Model = Type.Union(Object.keys(models).map(function(s) {
13
13
  return Type.Literal(s);
14
14
  }), {
15
- title: "Model",
16
- description: "Must be one of the models defined in @hello.nrfcloud.com/proto-map"
15
+ title: 'Model',
16
+ description: 'Must be one of the models defined in @hello.nrfcloud.com/proto-map'
17
17
  });
18
18
  export var PublicDevice = Type.Object({
19
- "@context": Type.Literal(Context.device.toString()),
19
+ '@context': Type.Literal(Context.device.toString()),
20
20
  id: PublicDeviceId,
21
21
  model: Model,
22
22
  state: Type.Optional(Type.Array(LwM2MObjectInstance))
23
23
  }, {
24
- title: "Public device",
25
- description: "A device that is publicly visible."
24
+ title: 'Public device',
25
+ description: 'A device that is publicly visible.'
26
26
  });
27
27
  export var Devices = Type.Object({
28
- "@context": Type.Literal(Context.devices.toString()),
28
+ '@context': Type.Literal(Context.devices.toString()),
29
29
  devices: Type.Array(PublicDevice)
30
30
  });
@@ -1,17 +1,17 @@
1
- import { Type } from "@sinclair/typebox";
2
- import { Context } from "./Context.js";
3
- import { ObjectID, ObjectInstanceID, ObjectVersion, Resources } from "./LwM2M.js";
4
- import { PublicDeviceId } from "./DeviceId.js";
5
- import { Timestamp } from "./Timestamp.js";
1
+ import { Type } from '@sinclair/typebox';
2
+ import { Context } from './Context.js';
3
+ import { ObjectID, ObjectInstanceID, ObjectVersion, Resources } from './LwM2M.js';
4
+ import { PublicDeviceId } from './DeviceId.js';
5
+ import { Timestamp } from './Timestamp.js';
6
6
  export var ResourceHistory = Type.Object({
7
- "@context": Type.Literal(Context.history.resource.toString()),
7
+ '@context': Type.Literal(Context.history.resource.toString()),
8
8
  partialInstances: Type.Array(Type.Intersect([
9
9
  Resources,
10
10
  Type.Object({
11
11
  ts: Timestamp
12
12
  })
13
13
  ], {
14
- title: "The resources of the object instance and the timestamp the data was received."
14
+ title: 'The resources of the object instance and the timestamp the data was received.'
15
15
  })),
16
16
  query: Type.Object({
17
17
  ObjectID: ObjectID,
@@ -19,7 +19,7 @@ export var ResourceHistory = Type.Object({
19
19
  ObjectVersion: ObjectVersion,
20
20
  binIntervalMinutes: Type.Number({
21
21
  minimum: 1,
22
- title: "The number of minutes the results are binned to.",
22
+ title: 'The number of minutes the results are binned to.',
23
23
  examples: [
24
24
  15
25
25
  ]
@@ -29,6 +29,6 @@ export var ResourceHistory = Type.Object({
29
29
  title: "The query that was used"
30
30
  })
31
31
  }, {
32
- title: "Resource history",
33
- description: "Contains historical values of an LwM2M resource for a device."
32
+ title: 'Resource history',
33
+ description: 'Contains historical values of an LwM2M resource for a device.'
34
34
  });
@@ -1,33 +1,33 @@
1
- import { describe, it } from "node:test";
2
- import assert from "node:assert/strict";
3
- import { validate } from "../validate.js";
4
- import { ResourceHistory } from "./History.js";
5
- void describe("ResourceHistory", function() {
6
- void it("should validate", function() {
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { validate } from '../validate.js';
4
+ import { ResourceHistory } from './History.js';
5
+ void describe('ResourceHistory', function() {
6
+ void it('should validate', function() {
7
7
  var input = {
8
- "@context": "https://github.com/hello-nrfcloud/proto-map/history/resource",
8
+ '@context': 'https://github.com/hello-nrfcloud/proto-map/history/resource',
9
9
  query: {
10
10
  ObjectID: 14230,
11
- ObjectVersion: "1.0",
11
+ ObjectVersion: '1.0',
12
12
  ObjectInstanceID: 0,
13
- deviceId: "bassetto-ennobler-toilless",
13
+ deviceId: 'bassetto-ennobler-toilless',
14
14
  binIntervalMinutes: 15
15
15
  },
16
16
  partialInstances: [
17
17
  {
18
- "0": 92.2,
19
- "99": 1713510000000,
20
- ts: "2024-04-19T08:45:00.000Z"
18
+ '0': 92.2,
19
+ '99': 1713510000000,
20
+ ts: '2024-04-19T08:45:00.000Z'
21
21
  },
22
22
  {
23
- "0": 113.8,
24
- "99": 1713515400000,
25
- ts: "2024-04-19T08:30:00.000Z"
23
+ '0': 113.8,
24
+ '99': 1713515400000,
25
+ ts: '2024-04-19T08:30:00.000Z'
26
26
  }
27
27
  ]
28
28
  };
29
29
  var maybeValid = validate(ResourceHistory)(input);
30
- assert.equal("errors" in maybeValid, false);
31
- assert.deepEqual("value" in maybeValid && maybeValid.value, input);
30
+ assert.equal('errors' in maybeValid, false);
31
+ assert.deepEqual('value' in maybeValid && maybeValid.value, input);
32
32
  });
33
33
  });
package/dist/api/LwM2M.js CHANGED
@@ -1,21 +1,21 @@
1
- import { Type } from "@sinclair/typebox";
2
- import { LwM2MObjectID } from "../lwm2m/LwM2MObjectID.js";
1
+ import { Type } from '@sinclair/typebox';
2
+ import { LwM2MObjectID } from '../lwm2m/LwM2MObjectID.js';
3
3
  export var ObjectVersion = Type.String({
4
- pattern: "^[0-9]+.[0-9]+$",
5
- default: "1.0",
4
+ pattern: '^[0-9]+.[0-9]+$',
5
+ default: '1.0',
6
6
  examples: [
7
- "1.0",
8
- "1.1"
7
+ '1.0',
8
+ '1.1'
9
9
  ],
10
10
  description: "The Object Version of an Object is composed of 2 digits separated by a dot '.'.\nSee https://www.openmobilealliance.org/release/LightweightM2M/V1_1_1-20190617-A/OMA-TS-LightweightM2M_Core-V1_1_1-20190617-A.pdf Section 7.2.2"
11
11
  });
12
12
  export var ObjectID = Type.Enum(LwM2MObjectID, {
13
- description: "The LwM2M Object IDs defined in @hello.nrfcloud.com/proto-map"
13
+ description: 'The LwM2M Object IDs defined in @hello.nrfcloud.com/proto-map'
14
14
  });
15
15
  export var ObjectInstanceID = Type.Integer({
16
16
  minimum: 0,
17
17
  default: 0,
18
- description: "The LwM2M Object Instance ID",
18
+ description: 'The LwM2M Object Instance ID',
19
19
  examples: [
20
20
  0,
21
21
  1
@@ -26,12 +26,12 @@ export var Resources = Type.Record(Type.Integer({
26
26
  }), Type.Union([
27
27
  Type.String({
28
28
  minLength: 1,
29
- title: "LwM2M string value"
29
+ title: 'LwM2M string value'
30
30
  }),
31
31
  Type.Number({
32
- title: "LwM2M number value"
32
+ title: 'LwM2M number value'
33
33
  }),
34
34
  Type.Boolean({
35
- title: "LwM2M boolean value"
35
+ title: 'LwM2M boolean value'
36
36
  })
37
37
  ]));
@@ -0,0 +1,17 @@
1
+ import { Type } from '@sinclair/typebox';
2
+ import { Context } from './Context.js';
3
+ import { ObjectID, ObjectInstanceID, ObjectVersion, Resources } from './LwM2M.js';
4
+ import { PublicDeviceId } from './DeviceId.js';
5
+ import { Timestamp } from './Timestamp.js';
6
+ export var ObjectUpdate = Type.Object({
7
+ '@context': Type.Literal(Context.objectUpdate.toString()),
8
+ ObjectID: ObjectID,
9
+ ObjectInstanceID: Type.Optional(ObjectInstanceID),
10
+ ObjectVersion: Type.Optional(ObjectVersion),
11
+ Resources: Resources,
12
+ ts: Timestamp,
13
+ deviceId: PublicDeviceId
14
+ }, {
15
+ title: 'Object update',
16
+ description: 'Describes an update to a LwM2M object for a device.'
17
+ });
@@ -0,0 +1,26 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { validate } from '../validate.js';
4
+ import { ObjectUpdate } from './ObjectUpdate.js';
5
+ void describe('ObjectUpdate', function() {
6
+ void it('should validate', function() {
7
+ var input = {
8
+ '@context': 'https://github.com/hello-nrfcloud/proto-map/object/update',
9
+ ObjectID: 14201,
10
+ ObjectVersion: '1.0',
11
+ ObjectInstanceID: 0,
12
+ Resources: {
13
+ '0': 70.374978,
14
+ '1': 31.104015,
15
+ '3': 1,
16
+ '6': 'Fixed',
17
+ '99': '${tsISO}'
18
+ },
19
+ deviceId: 'bassetto-ennobler-toilless',
20
+ ts: '2024-04-19T08:30:00.000Z'
21
+ };
22
+ var maybeValid = validate(ObjectUpdate)(input);
23
+ assert.equal('errors' in maybeValid, false);
24
+ assert.deepEqual('value' in maybeValid && maybeValid.value, input);
25
+ });
26
+ });
@@ -1,7 +1,7 @@
1
- import { Type } from "@sinclair/typebox";
2
- import { Context } from "./Context.js";
3
- import { DeviceId } from "./DeviceId.js";
1
+ import { Type } from '@sinclair/typebox';
2
+ import { Context } from './Context.js';
3
+ import { DeviceId } from './DeviceId.js';
4
4
  export var ShareDeviceOwnershipConfirmed = Type.Object({
5
- "@context": Type.Literal(Context.shareDevice.ownershipConfirmed.toString()),
5
+ '@context': Type.Literal(Context.shareDevice.ownershipConfirmed.toString()),
6
6
  id: DeviceId
7
7
  });
@@ -1,8 +1,8 @@
1
- import { Type } from "@sinclair/typebox";
2
- import { Context } from "./Context.js";
3
- import { DeviceId, PublicDeviceId } from "./DeviceId.js";
1
+ import { Type } from '@sinclair/typebox';
2
+ import { Context } from './Context.js';
3
+ import { DeviceId, PublicDeviceId } from './DeviceId.js';
4
4
  export var ShareDeviceRequest = Type.Object({
5
- "@context": Type.Literal(Context.shareDevice.request.toString()),
5
+ '@context': Type.Literal(Context.shareDevice.request.toString()),
6
6
  id: PublicDeviceId,
7
7
  deviceId: DeviceId
8
8
  });
@@ -1,7 +1,7 @@
1
- import { Type } from "@sinclair/typebox";
1
+ import { Type } from '@sinclair/typebox';
2
2
  export var Timestamp = Type.RegExp(/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/, {
3
- title: "Time when the update was received, formatted as ISO 8601",
3
+ title: 'Time when the update was received, formatted as ISO 8601',
4
4
  examples: [
5
- "2024-04-19T08:45:00.000Z"
5
+ '2024-04-19T08:45:00.000Z'
6
6
  ]
7
7
  });
@@ -1,12 +1,12 @@
1
- import { describe, it } from "node:test";
2
- import assert from "node:assert/strict";
3
- import { validate } from "../validate.js";
4
- import { Timestamp } from "./Timestamp.js";
5
- void describe("Timestamp", function() {
6
- void it("should validate", function() {
7
- var input = "2024-04-19T08:30:00.000Z";
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { validate } from '../validate.js';
4
+ import { Timestamp } from './Timestamp.js';
5
+ void describe('Timestamp', function() {
6
+ void it('should validate', function() {
7
+ var input = '2024-04-19T08:30:00.000Z';
8
8
  var maybeValid = validate(Timestamp)(input);
9
- assert.equal("errors" in maybeValid, false);
10
- assert.deepEqual("value" in maybeValid && maybeValid.value, input);
9
+ assert.equal('errors' in maybeValid, false);
10
+ assert.deepEqual('value' in maybeValid && maybeValid.value, input);
11
11
  });
12
12
  });
package/dist/api/index.js CHANGED
@@ -1,8 +1,8 @@
1
- export * from "./Context.js";
2
- export * from "./DeviceId.js";
3
- export * from "./Devices.js";
4
- export * from "./ShareDeviceOwnershipConfirmed.js";
5
- export * from "./ShareDeviceRequest.js";
6
- export * from "./History.js";
7
- export * from "./LwM2M.js";
8
- export * from "./Timestamp.js";
1
+ export * from './Context.js';
2
+ export * from './DeviceId.js';
3
+ export * from './Devices.js';
4
+ export * from './ShareDeviceOwnershipConfirmed.js';
5
+ export * from './ShareDeviceRequest.js';
6
+ export * from './History.js';
7
+ export * from './LwM2M.js';
8
+ export * from './Timestamp.js';
@@ -1,5 +1,5 @@
1
- import ts from "typescript";
1
+ import ts from 'typescript';
2
2
  export var addDocBlock = function(comment, node) {
3
- ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, "*\n * ".concat(comment.join("\n * "), " \n "), true);
3
+ ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, "*\n * ".concat(comment.join('\n * '), " \n "), true);
4
4
  return node;
5
5
  };
@@ -1,52 +1,52 @@
1
- import ts from "typescript";
2
- import { addDocBlock } from "./addDocBlock.js";
3
- import { generateName } from "./generateType.js";
4
- import { parseRangeEnumeration } from "../lwm2m/parseRangeEnumeration.js";
1
+ import ts from 'typescript';
2
+ import { addDocBlock } from './addDocBlock.js';
3
+ import { generateName } from './generateType.js';
4
+ import { parseRangeEnumeration } from '../lwm2m/parseRangeEnumeration.js';
5
5
  export var generateLwM2MDefinitions = function(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"))
9
- ])), ts.factory.createStringLiteral("./LWM2MObjectInfo.js"));
9
+ ])), ts.factory.createStringLiteral('./LWM2MObjectInfo.js'));
10
10
  var importLwM2MObjectID = ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([
11
11
  ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier("LwM2MObjectID"))
12
- ])), ts.factory.createStringLiteral("./LwM2MObjectID.js"));
12
+ ])), ts.factory.createStringLiteral('./LwM2MObjectID.js'));
13
13
  var type = ts.factory.createVariableStatement([
14
14
  ts.factory.createToken(ts.SyntaxKind.ExportKeyword)
15
15
  ], ts.factory.createVariableDeclarationList([
16
- ts.factory.createVariableDeclaration(ts.factory.createIdentifier("definitions"), undefined, ts.factory.createTypeReferenceNode("Record", [
17
- ts.factory.createTypeReferenceNode("LwM2MObjectID"),
18
- ts.factory.createTypeReferenceNode("LWM2MObjectInfo")
16
+ ts.factory.createVariableDeclaration(ts.factory.createIdentifier("definitions"), undefined, ts.factory.createTypeReferenceNode('Record', [
17
+ ts.factory.createTypeReferenceNode('LwM2MObjectID'),
18
+ ts.factory.createTypeReferenceNode('LWM2MObjectInfo')
19
19
  ]), ts.factory.createObjectLiteralExpression(definitions.map(function(definition) {
20
20
  var _definition_ObjectVersion;
21
- var objectDef = ts.factory.createPropertyAssignment(ts.factory.createComputedPropertyName(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("LwM2MObjectID"), generateName(definition))), ts.factory.createObjectLiteralExpression([
22
- ts.factory.createPropertyAssignment("ObjectID", ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("LwM2MObjectID"), generateName(definition))),
23
- ts.factory.createPropertyAssignment("ObjectVersion", ts.factory.createStringLiteral((_definition_ObjectVersion = definition.ObjectVersion) !== null && _definition_ObjectVersion !== void 0 ? _definition_ObjectVersion : "1.0")),
24
- ts.factory.createPropertyAssignment("Name", ts.factory.createStringLiteral(definition.Name)),
25
- ts.factory.createPropertyAssignment("Description", ts.factory.createStringLiteral(definition.Description1)),
26
- ts.factory.createPropertyAssignment("Resources", ts.factory.createObjectLiteralExpression(definition.Resources.Item.map(function(Resource) {
21
+ var objectDef = ts.factory.createPropertyAssignment(ts.factory.createComputedPropertyName(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('LwM2MObjectID'), generateName(definition))), ts.factory.createObjectLiteralExpression([
22
+ ts.factory.createPropertyAssignment('ObjectID', ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('LwM2MObjectID'), generateName(definition))),
23
+ ts.factory.createPropertyAssignment('ObjectVersion', ts.factory.createStringLiteral((_definition_ObjectVersion = definition.ObjectVersion) !== null && _definition_ObjectVersion !== void 0 ? _definition_ObjectVersion : '1.0')),
24
+ ts.factory.createPropertyAssignment('Name', ts.factory.createStringLiteral(definition.Name)),
25
+ ts.factory.createPropertyAssignment('Description', ts.factory.createStringLiteral(definition.Description1)),
26
+ ts.factory.createPropertyAssignment('Resources', ts.factory.createObjectLiteralExpression(definition.Resources.Item.map(function(Resource) {
27
27
  var range = undefined;
28
28
  if (Resource.RangeEnumeration.length > 0) {
29
29
  var maybeRange = parseRangeEnumeration(Resource.RangeEnumeration);
30
- if ("error" in maybeRange) throw maybeRange.error;
30
+ if ('error' in maybeRange) throw maybeRange.error;
31
31
  range = maybeRange.range;
32
32
  }
33
33
  var props = [
34
- ts.factory.createPropertyAssignment("ResourceID", ts.factory.createNumericLiteral(Resource.$.ID)),
35
- ts.factory.createPropertyAssignment("Name", ts.factory.createStringLiteral(Resource.Name)),
36
- ts.factory.createPropertyAssignment("Mandatory", ts.factory.createIdentifier(Resource.Mandatory === "Mandatory" ? "true" : "false")),
37
- ts.factory.createPropertyAssignment("Type", ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("ResourceType"), Resource.Type)),
38
- ts.factory.createPropertyAssignment("Description", ts.factory.createStringLiteral(Resource.Description))
34
+ ts.factory.createPropertyAssignment('ResourceID', ts.factory.createNumericLiteral(Resource.$.ID)),
35
+ ts.factory.createPropertyAssignment('Name', ts.factory.createStringLiteral(Resource.Name)),
36
+ ts.factory.createPropertyAssignment('Mandatory', ts.factory.createIdentifier(Resource.Mandatory === 'Mandatory' ? 'true' : 'false')),
37
+ ts.factory.createPropertyAssignment('Type', ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('ResourceType'), Resource.Type)),
38
+ ts.factory.createPropertyAssignment('Description', ts.factory.createStringLiteral(Resource.Description))
39
39
  ];
40
40
  if (Resource.RangeEnumeration.length > 0) {
41
41
  var maybeRange1 = parseRangeEnumeration(Resource.RangeEnumeration);
42
- if ("error" in maybeRange1) throw maybeRange1.error;
42
+ if ('error' in maybeRange1) throw maybeRange1.error;
43
43
  var _maybeRange_range = maybeRange1.range, min = _maybeRange_range.min, max = _maybeRange_range.max;
44
- props.push(ts.factory.createPropertyAssignment("RangeEnumeration", ts.factory.createObjectLiteralExpression([
45
- ts.factory.createPropertyAssignment("min", createNumber(min)),
46
- ts.factory.createPropertyAssignment("max", createNumber(max))
44
+ props.push(ts.factory.createPropertyAssignment('RangeEnumeration', ts.factory.createObjectLiteralExpression([
45
+ ts.factory.createPropertyAssignment('min', createNumber(min)),
46
+ ts.factory.createPropertyAssignment('max', createNumber(max))
47
47
  ])));
48
48
  }
49
- if (Resource.Units.length > 0) props.push(ts.factory.createPropertyAssignment("Units", ts.factory.createStringLiteral(Resource.Units)));
49
+ if (Resource.Units.length > 0) props.push(ts.factory.createPropertyAssignment('Units', ts.factory.createStringLiteral(Resource.Units)));
50
50
  var resourceDef = ts.factory.createPropertyAssignment(ts.factory.createNumericLiteral(Resource.$.ID), ts.factory.createObjectLiteralExpression(props));
51
51
  var docStrings = [
52
52
  "".concat(Resource.Name, " (").concat(Resource.Type, ")"),
@@ -69,7 +69,7 @@ export var generateLwM2MDefinitions = function(definitions) {
69
69
  })))
70
70
  ], ts.NodeFlags.Const));
71
71
  addDocBlock([
72
- "Contains the ID of the resource that defines the timestamp for each LwM2M object definition"
72
+ 'Contains the ID of the resource that defines the timestamp for each LwM2M object definition'
73
73
  ], type);
74
74
  return [
75
75
  importLWM2MObjectInfo,