@hello.nrfcloud.com/proto-map 5.2.0 → 5.2.2

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 ADDED
@@ -0,0 +1,10 @@
1
+ const baseURL = `https://github.com/hello-nrfcloud/proto-map`
2
+
3
+ export const Context = {
4
+ device: new URL(`${baseURL}/device`),
5
+ devices: new URL(`${baseURL}/devices`),
6
+ shareDevice: {
7
+ request: new URL(`${baseURL}/share-device-request`),
8
+ ownershipConfirmed: new URL(`${baseURL}/share-device-ownership-confirmed`),
9
+ },
10
+ }
@@ -0,0 +1,12 @@
1
+ import { Type } from '@sinclair/typebox'
2
+
3
+ export const DeviceId = Type.RegExp(/^[a-zA-Z0-9:_-]{1,128}$/, {
4
+ title: 'Device ID',
5
+ description: 'Must follow the AWS IoT limitations for Thing names.',
6
+ })
7
+
8
+ export const PublicDeviceId = Type.RegExp(/^[a-z]{8}-[a-z]{8}-[a-z]{8}$/, {
9
+ title: 'Public Device ID',
10
+ description:
11
+ 'This is the format of @nordicsemiconductor/random-words which is used for public IDs.',
12
+ })
package/api/Devices.ts ADDED
@@ -0,0 +1,53 @@
1
+ import { Type } from '@sinclair/typebox'
2
+ import { Context } from './Context.js'
3
+ import { PublicDeviceId } from './DeviceId.js'
4
+ import { LwM2MObjectID, models } from '@hello.nrfcloud.com/proto-map'
5
+
6
+ export const LwM2MObjectInstance = Type.Object({
7
+ ObjectID: Type.Enum(LwM2MObjectID, {
8
+ description:
9
+ 'The LwM2M Object IDs defined in @hello.nrfcloud.com/proto-map',
10
+ }),
11
+ ObjectVersion: Type.Optional(
12
+ Type.String({
13
+ pattern: '^[0-9]+.[0-9]+$',
14
+ default: '1.0',
15
+ description:
16
+ "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",
17
+ }),
18
+ ),
19
+ ObjectInstanceID: Type.Optional(
20
+ Type.Integer({
21
+ minimum: 0,
22
+ default: 0,
23
+ }),
24
+ ),
25
+ Resources: Type.Record(
26
+ Type.Integer({ minimum: 0 }),
27
+ Type.Union([Type.String(), Type.Number(), Type.Boolean()]),
28
+ ),
29
+ })
30
+
31
+ export const Model = Type.Union(
32
+ Object.keys(models).map((s) => Type.Literal(s)),
33
+ {
34
+ title: 'Model',
35
+ description:
36
+ 'Must be one of the models defined in @hello.nrfcloud.com/proto-map',
37
+ },
38
+ )
39
+
40
+ export const PublicDevice = Type.Object(
41
+ {
42
+ '@context': Type.Literal(Context.device.toString()),
43
+ id: PublicDeviceId,
44
+ model: Model,
45
+ state: Type.Optional(Type.Array(LwM2MObjectInstance)),
46
+ },
47
+ { title: 'Public device', description: 'A device that is publicly visible.' },
48
+ )
49
+
50
+ export const Devices = Type.Object({
51
+ '@context': Type.Literal(Context.devices.toString()),
52
+ devices: Type.Array(PublicDevice),
53
+ })
@@ -0,0 +1,8 @@
1
+ import { Type } from '@sinclair/typebox'
2
+ import { Context } from './Context.js'
3
+ import { DeviceId } from './DeviceId.js'
4
+
5
+ export const ShareDeviceOwnershipConfirmed = Type.Object({
6
+ '@context': Type.Literal(Context.shareDevice.ownershipConfirmed.toString()),
7
+ id: DeviceId,
8
+ })
@@ -0,0 +1,8 @@
1
+ import { Type } from '@sinclair/typebox'
2
+ import { Context } from './Context.js'
3
+ import { PublicDeviceId } from './DeviceId.js'
4
+
5
+ export const ShareDeviceRequest = Type.Object({
6
+ '@context': Type.Literal(Context.shareDevice.request.toString()),
7
+ id: PublicDeviceId,
8
+ })
package/api/index.ts ADDED
@@ -0,0 +1,5 @@
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'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hello.nrfcloud.com/proto-map",
3
- "version": "5.2.0",
3
+ "version": "5.2.2",
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": {
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "./*": {
12
12
  "default": "./dist/*/index.js",
13
- "types": "./dist/*/index.d.ts"
13
+ "types": "./*/index.ts"
14
14
  }
15
15
  },
16
16
  "repository": {
@@ -103,6 +103,7 @@
103
103
  "dist",
104
104
  "export.js",
105
105
  "index.d.ts",
106
+ "api",
106
107
  "senml",
107
108
  "models",
108
109
  "lwm2m"