@hello.nrfcloud.com/proto-map 5.4.2 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api/Context.ts CHANGED
@@ -10,5 +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
14
  named: (name: string): URL => new URL(`${baseURL}/${name}`),
14
15
  }
package/api/History.ts CHANGED
@@ -19,7 +19,8 @@ export const ResourceHistory = Type.Object(
19
19
  ts: Type.RegExp(
20
20
  /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/,
21
21
  {
22
- title: 'Date formatted as ISO 8601',
22
+ title:
23
+ 'Time when the update was received, formatted as ISO 8601',
23
24
  examples: ['2024-04-19T08:45:00.000Z'],
24
25
  },
25
26
  ),
@@ -0,0 +1,28 @@
1
+ import { describe, it } from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+ import { validate } from '../validate.js'
4
+ import { ResourceUpdate } from './ResourceUpdate.js'
5
+ import type { Static } from '@sinclair/typebox'
6
+
7
+ void describe('ResourceUpdate', () => {
8
+ void it('should validate', () => {
9
+ const input: Static<typeof ResourceUpdate> = {
10
+ '@context': 'https://github.com/hello-nrfcloud/proto-map/resource/update',
11
+ ObjectID: 14201,
12
+ ObjectVersion: '1.0',
13
+ ObjectInstanceID: 0,
14
+ Resources: {
15
+ '0': 70.374978,
16
+ '1': 31.104015,
17
+ '3': 1,
18
+ '6': 'Fixed',
19
+ '99': '${tsISO}',
20
+ },
21
+ deviceId: 'bassetto-ennobler-toilless',
22
+ ts: '2024-04-19T08:30:00.000Z',
23
+ }
24
+ const maybeValid = validate(ResourceUpdate)(input)
25
+ assert.equal('errors' in maybeValid, false)
26
+ assert.deepEqual('value' in maybeValid && maybeValid.value, input)
27
+ })
28
+ })
@@ -0,0 +1,31 @@
1
+ import { Type } from '@sinclair/typebox'
2
+ import { Context } from './Context.js'
3
+ import {
4
+ ObjectID,
5
+ ObjectInstanceID,
6
+ ObjectVersion,
7
+ Resources,
8
+ } from './LwM2M.js'
9
+ import { PublicDeviceId } from './DeviceId.js'
10
+
11
+ export const ResourceUpdate = Type.Object(
12
+ {
13
+ '@context': Type.Literal(Context.resourceUpdate.toString()),
14
+ ObjectID,
15
+ ObjectInstanceID,
16
+ ObjectVersion,
17
+ Resources,
18
+ ts: Type.RegExp(
19
+ /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/,
20
+ {
21
+ title: 'Time when the update was received, formatted as ISO 8601',
22
+ examples: ['2024-04-19T08:45:00.000Z'],
23
+ },
24
+ ),
25
+ deviceId: PublicDeviceId,
26
+ },
27
+ {
28
+ title: 'Resource history',
29
+ description: 'Describes an update to a LwM2M resource for a device.',
30
+ },
31
+ )
@@ -9,6 +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
13
  named: function(name) {
13
14
  return new URL("".concat(baseURL, "/").concat(name));
14
15
  }
@@ -8,7 +8,7 @@ export var ResourceHistory = Type.Object({
8
8
  Resources,
9
9
  Type.Object({
10
10
  ts: 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)/, {
11
- title: "Date formatted as ISO 8601",
11
+ title: "Time when the update was received, formatted as ISO 8601",
12
12
  examples: [
13
13
  "2024-04-19T08:45:00.000Z"
14
14
  ]
@@ -0,0 +1,21 @@
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
+ export var ResourceUpdate = Type.Object({
6
+ "@context": Type.Literal(Context.resourceUpdate.toString()),
7
+ ObjectID: ObjectID,
8
+ ObjectInstanceID: ObjectInstanceID,
9
+ ObjectVersion: ObjectVersion,
10
+ Resources: Resources,
11
+ ts: 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)/, {
12
+ title: "Time when the update was received, formatted as ISO 8601",
13
+ examples: [
14
+ "2024-04-19T08:45:00.000Z"
15
+ ]
16
+ }),
17
+ deviceId: PublicDeviceId
18
+ }, {
19
+ title: "Resource history",
20
+ description: "Describes an update to a LwM2M resource for a device."
21
+ });
@@ -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 { ResourceUpdate } from "./ResourceUpdate.js";
5
+ void describe("ResourceUpdate", function() {
6
+ void it("should validate", function() {
7
+ var input = {
8
+ "@context": "https://github.com/hello-nrfcloud/proto-map/resource/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(ResourceUpdate)(input);
23
+ assert.equal("errors" in maybeValid, false);
24
+ assert.deepEqual("value" in maybeValid && maybeValid.value, input);
25
+ });
26
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hello.nrfcloud.com/proto-map",
3
- "version": "5.4.2",
3
+ "version": "5.5.0",
4
4
  "description": "Documents the communication protocol between devices, the hello.nrfcloud.com/map backend and web application",
5
5
  "type": "module",
6
6
  "exports": {
@@ -108,7 +108,7 @@
108
108
  "lwm2m"
109
109
  ],
110
110
  "peerDependencies": {
111
- "@sinclair/typebox": "^0.32.21",
111
+ "@sinclair/typebox": "^0.32.22",
112
112
  "ajv": "^8.12.0",
113
113
  "jsonata": "^2.0.4"
114
114
  }