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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api/History.ts CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  Resources,
8
8
  } from './LwM2M.js'
9
9
  import { PublicDeviceId } from './DeviceId.js'
10
+ import { Timestamp } from './Timestamp.js'
10
11
 
11
12
  export const ResourceHistory = Type.Object(
12
13
  {
@@ -16,14 +17,7 @@ export const ResourceHistory = Type.Object(
16
17
  [
17
18
  Resources,
18
19
  Type.Object({
19
- ts: Type.RegExp(
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
- {
22
- title:
23
- 'Time when the update was received, formatted as ISO 8601',
24
- examples: ['2024-04-19T08:45:00.000Z'],
25
- },
26
- ),
20
+ ts: Timestamp,
27
21
  }),
28
22
  ],
29
23
  {
@@ -7,6 +7,7 @@ import {
7
7
  Resources,
8
8
  } from './LwM2M.js'
9
9
  import { PublicDeviceId } from './DeviceId.js'
10
+ import { Timestamp } from './Timestamp.js'
10
11
 
11
12
  export const ResourceUpdate = Type.Object(
12
13
  {
@@ -15,13 +16,7 @@ export const ResourceUpdate = Type.Object(
15
16
  ObjectInstanceID,
16
17
  ObjectVersion,
17
18
  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
- ),
19
+ ts: Timestamp,
25
20
  deviceId: PublicDeviceId,
26
21
  },
27
22
  {
@@ -0,0 +1,14 @@
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
+ import type { Static } from '@sinclair/typebox'
6
+
7
+ void describe('Timestamp', () => {
8
+ void it('should validate', () => {
9
+ const input: Static<typeof Timestamp> = '2024-04-19T08:30:00.000Z'
10
+ const maybeValid = validate(Timestamp)(input)
11
+ assert.equal('errors' in maybeValid, false)
12
+ assert.deepEqual('value' in maybeValid && maybeValid.value, input)
13
+ })
14
+ })
@@ -0,0 +1,9 @@
1
+ import { Type } from '@sinclair/typebox'
2
+
3
+ export const Timestamp = Type.RegExp(
4
+ /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/,
5
+ {
6
+ title: 'Time when the update was received, formatted as ISO 8601',
7
+ examples: ['2024-04-19T08:45:00.000Z'],
8
+ },
9
+ )
package/api/index.ts CHANGED
@@ -5,3 +5,4 @@ export * from './ShareDeviceOwnershipConfirmed.js'
5
5
  export * from './ShareDeviceRequest.js'
6
6
  export * from './History.js'
7
7
  export * from './LwM2M.js'
8
+ export * from './Timestamp.js'
@@ -2,17 +2,13 @@ import { Type } from "@sinclair/typebox";
2
2
  import { Context } from "./Context.js";
3
3
  import { ObjectID, ObjectInstanceID, ObjectVersion, Resources } from "./LwM2M.js";
4
4
  import { PublicDeviceId } from "./DeviceId.js";
5
+ import { Timestamp } from "./Timestamp.js";
5
6
  export var ResourceHistory = Type.Object({
6
7
  "@context": Type.Literal(Context.history.resource.toString()),
7
8
  partialInstances: Type.Array(Type.Intersect([
8
9
  Resources,
9
10
  Type.Object({
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: "Time when the update was received, formatted as ISO 8601",
12
- examples: [
13
- "2024-04-19T08:45:00.000Z"
14
- ]
15
- })
11
+ ts: Timestamp
16
12
  })
17
13
  ], {
18
14
  title: "The resources of the object instance and the timestamp the data was received."
@@ -2,18 +2,14 @@ import { Type } from "@sinclair/typebox";
2
2
  import { Context } from "./Context.js";
3
3
  import { ObjectID, ObjectInstanceID, ObjectVersion, Resources } from "./LwM2M.js";
4
4
  import { PublicDeviceId } from "./DeviceId.js";
5
+ import { Timestamp } from "./Timestamp.js";
5
6
  export var ResourceUpdate = Type.Object({
6
7
  "@context": Type.Literal(Context.resourceUpdate.toString()),
7
8
  ObjectID: ObjectID,
8
9
  ObjectInstanceID: ObjectInstanceID,
9
10
  ObjectVersion: ObjectVersion,
10
11
  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
- }),
12
+ ts: Timestamp,
17
13
  deviceId: PublicDeviceId
18
14
  }, {
19
15
  title: "Resource history",
@@ -0,0 +1,7 @@
1
+ import { Type } from "@sinclair/typebox";
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",
4
+ examples: [
5
+ "2024-04-19T08:45:00.000Z"
6
+ ]
7
+ });
@@ -0,0 +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";
8
+ var maybeValid = validate(Timestamp)(input);
9
+ assert.equal("errors" in maybeValid, false);
10
+ assert.deepEqual("value" in maybeValid && maybeValid.value, input);
11
+ });
12
+ });
package/dist/api/index.js CHANGED
@@ -5,3 +5,4 @@ export * from "./ShareDeviceOwnershipConfirmed.js";
5
5
  export * from "./ShareDeviceRequest.js";
6
6
  export * from "./History.js";
7
7
  export * from "./LwM2M.js";
8
+ export * from "./Timestamp.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hello.nrfcloud.com/proto-map",
3
- "version": "5.5.0",
3
+ "version": "5.6.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": {