@hello.nrfcloud.com/proto-map 7.1.2 → 8.0.1
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/README.md +3 -3
- package/api/Context.ts +0 -4
- package/api/index.ts +0 -2
- package/dist/api/Context.js +0 -4
- package/dist/api/index.js +0 -2
- package/package.json +3 -3
- package/api/History.spec.ts +0 -36
- package/api/History.ts +0 -49
- package/api/ObjectUpdate.spec.ts +0 -28
- package/api/ObjectUpdate.ts +0 -26
- package/api/Timestamp.spec.ts +0 -14
- package/api/Timestamp.ts +0 -9
- package/dist/api/History.js +0 -34
- package/dist/api/History.spec.js +0 -33
- package/dist/api/ObjectUpdate.js +0 -17
- package/dist/api/ObjectUpdate.spec.js +0 -26
- package/dist/api/Timestamp.js +0 -7
- package/dist/api/Timestamp.spec.js +0 -12
package/README.md
CHANGED
|
@@ -68,9 +68,9 @@ The conformity to the rules is checked using the script
|
|
|
68
68
|
### Model definition rules
|
|
69
69
|
|
|
70
70
|
- **device models** are identified using a model name, for example
|
|
71
|
-
`
|
|
72
|
-
- a [`README.md`](./models/
|
|
73
|
-
describes the model
|
|
71
|
+
`kartverket-vasstandsdata`
|
|
72
|
+
- a [`README.md`](./models/kartverket-vasstandsdata/README.md) must be provided
|
|
73
|
+
that describes the model
|
|
74
74
|
|
|
75
75
|
The conformity to the rules is checked using the script
|
|
76
76
|
[`./models/check-model-rules.ts`](./models/check-model-rules.ts).
|
package/api/Context.ts
CHANGED
|
@@ -3,13 +3,9 @@ const baseURL = `https://github.com/hello-nrfcloud/proto-map`
|
|
|
3
3
|
export const Context = {
|
|
4
4
|
device: new URL(`${baseURL}/device`),
|
|
5
5
|
devices: new URL(`${baseURL}/devices`),
|
|
6
|
-
history: {
|
|
7
|
-
resource: new URL(`${baseURL}/history/resource`),
|
|
8
|
-
},
|
|
9
6
|
shareDevice: {
|
|
10
7
|
request: new URL(`${baseURL}/share-device-request`),
|
|
11
8
|
ownershipConfirmed: new URL(`${baseURL}/share-device-ownership-confirmed`),
|
|
12
9
|
},
|
|
13
|
-
objectUpdate: new URL(`${baseURL}/object/update`),
|
|
14
10
|
named: (name: string): URL => new URL(`${baseURL}/${name}`),
|
|
15
11
|
}
|
package/api/index.ts
CHANGED
package/dist/api/Context.js
CHANGED
|
@@ -2,14 +2,10 @@ var baseURL = "https://github.com/hello-nrfcloud/proto-map";
|
|
|
2
2
|
export var Context = {
|
|
3
3
|
device: new URL("".concat(baseURL, "/device")),
|
|
4
4
|
devices: new URL("".concat(baseURL, "/devices")),
|
|
5
|
-
history: {
|
|
6
|
-
resource: new URL("".concat(baseURL, "/history/resource"))
|
|
7
|
-
},
|
|
8
5
|
shareDevice: {
|
|
9
6
|
request: new URL("".concat(baseURL, "/share-device-request")),
|
|
10
7
|
ownershipConfirmed: new URL("".concat(baseURL, "/share-device-ownership-confirmed"))
|
|
11
8
|
},
|
|
12
|
-
objectUpdate: new URL("".concat(baseURL, "/object/update")),
|
|
13
9
|
named: function(name) {
|
|
14
10
|
return new URL("".concat(baseURL, "/").concat(name));
|
|
15
11
|
}
|
package/dist/api/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hello.nrfcloud.com/proto-map",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.1",
|
|
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": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@bifravst/prettier-config": "1.0.0",
|
|
44
44
|
"@commitlint/config-conventional": "19.2.2",
|
|
45
45
|
"@swc/cli": "0.3.12",
|
|
46
|
-
"@swc/core": "1.5.
|
|
46
|
+
"@swc/core": "1.5.2",
|
|
47
47
|
"@types/node": "20.12.7",
|
|
48
48
|
"@types/xml2js": "0.4.14",
|
|
49
49
|
"chalk": "5.3.0",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"lwm2m"
|
|
105
105
|
],
|
|
106
106
|
"peerDependencies": {
|
|
107
|
-
"@sinclair/typebox": "^0.32.
|
|
107
|
+
"@sinclair/typebox": "^0.32.26",
|
|
108
108
|
"ajv": "^8.12.0"
|
|
109
109
|
}
|
|
110
110
|
}
|
package/api/History.spec.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
import type { Static } from '@sinclair/typebox'
|
|
6
|
-
|
|
7
|
-
void describe('ResourceHistory', () => {
|
|
8
|
-
void it('should validate', () => {
|
|
9
|
-
const input: Static<typeof ResourceHistory> = {
|
|
10
|
-
'@context':
|
|
11
|
-
'https://github.com/hello-nrfcloud/proto-map/history/resource',
|
|
12
|
-
query: {
|
|
13
|
-
ObjectID: 14230,
|
|
14
|
-
ObjectVersion: '1.0',
|
|
15
|
-
ObjectInstanceID: 0,
|
|
16
|
-
deviceId: 'bassetto-ennobler-toilless',
|
|
17
|
-
binIntervalMinutes: 15,
|
|
18
|
-
},
|
|
19
|
-
partialInstances: [
|
|
20
|
-
{
|
|
21
|
-
'0': 92.2,
|
|
22
|
-
'99': 1713510000000,
|
|
23
|
-
ts: '2024-04-19T08:45:00.000Z',
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
'0': 113.8,
|
|
27
|
-
'99': 1713515400000,
|
|
28
|
-
ts: '2024-04-19T08:30:00.000Z',
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
}
|
|
32
|
-
const maybeValid = validate(ResourceHistory)(input)
|
|
33
|
-
assert.equal('errors' in maybeValid, false)
|
|
34
|
-
assert.deepEqual('value' in maybeValid && maybeValid.value, input)
|
|
35
|
-
})
|
|
36
|
-
})
|
package/api/History.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
import { Timestamp } from './Timestamp.js'
|
|
11
|
-
|
|
12
|
-
export const ResourceHistory = Type.Object(
|
|
13
|
-
{
|
|
14
|
-
'@context': Type.Literal(Context.history.resource.toString()),
|
|
15
|
-
partialInstances: Type.Array(
|
|
16
|
-
Type.Intersect(
|
|
17
|
-
[
|
|
18
|
-
Resources,
|
|
19
|
-
Type.Object({
|
|
20
|
-
ts: Timestamp,
|
|
21
|
-
}),
|
|
22
|
-
],
|
|
23
|
-
{
|
|
24
|
-
title:
|
|
25
|
-
'The resources of the object instance and the timestamp the data was received.',
|
|
26
|
-
},
|
|
27
|
-
),
|
|
28
|
-
),
|
|
29
|
-
query: Type.Object(
|
|
30
|
-
{
|
|
31
|
-
ObjectID,
|
|
32
|
-
ObjectInstanceID,
|
|
33
|
-
ObjectVersion,
|
|
34
|
-
binIntervalMinutes: Type.Number({
|
|
35
|
-
minimum: 1,
|
|
36
|
-
title: 'The number of minutes the results are binned to.',
|
|
37
|
-
examples: [15],
|
|
38
|
-
}),
|
|
39
|
-
deviceId: PublicDeviceId,
|
|
40
|
-
},
|
|
41
|
-
{ title: `The query that was used` },
|
|
42
|
-
),
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
title: 'Resource history',
|
|
46
|
-
description:
|
|
47
|
-
'Contains historical values of an LwM2M resource for a device.',
|
|
48
|
-
},
|
|
49
|
-
)
|
package/api/ObjectUpdate.spec.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
import type { Static } from '@sinclair/typebox'
|
|
6
|
-
|
|
7
|
-
void describe('ObjectUpdate', () => {
|
|
8
|
-
void it('should validate', () => {
|
|
9
|
-
const input: Static<typeof ObjectUpdate> = {
|
|
10
|
-
'@context': 'https://github.com/hello-nrfcloud/proto-map/object/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(ObjectUpdate)(input)
|
|
25
|
-
assert.equal('errors' in maybeValid, false)
|
|
26
|
-
assert.deepEqual('value' in maybeValid && maybeValid.value, input)
|
|
27
|
-
})
|
|
28
|
-
})
|
package/api/ObjectUpdate.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
import { Timestamp } from './Timestamp.js'
|
|
11
|
-
|
|
12
|
-
export const ObjectUpdate = Type.Object(
|
|
13
|
-
{
|
|
14
|
-
'@context': Type.Literal(Context.objectUpdate.toString()),
|
|
15
|
-
ObjectID,
|
|
16
|
-
ObjectInstanceID: Type.Optional(ObjectInstanceID),
|
|
17
|
-
ObjectVersion: Type.Optional(ObjectVersion),
|
|
18
|
-
Resources,
|
|
19
|
-
ts: Timestamp,
|
|
20
|
-
deviceId: PublicDeviceId,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
title: 'Object update',
|
|
24
|
-
description: 'Describes an update to a LwM2M object for a device.',
|
|
25
|
-
},
|
|
26
|
-
)
|
package/api/Timestamp.spec.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
})
|
package/api/Timestamp.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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/dist/api/History.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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 ResourceHistory = Type.Object({
|
|
7
|
-
'@context': Type.Literal(Context.history.resource.toString()),
|
|
8
|
-
partialInstances: Type.Array(Type.Intersect([
|
|
9
|
-
Resources,
|
|
10
|
-
Type.Object({
|
|
11
|
-
ts: Timestamp
|
|
12
|
-
})
|
|
13
|
-
], {
|
|
14
|
-
title: 'The resources of the object instance and the timestamp the data was received.'
|
|
15
|
-
})),
|
|
16
|
-
query: Type.Object({
|
|
17
|
-
ObjectID: ObjectID,
|
|
18
|
-
ObjectInstanceID: ObjectInstanceID,
|
|
19
|
-
ObjectVersion: ObjectVersion,
|
|
20
|
-
binIntervalMinutes: Type.Number({
|
|
21
|
-
minimum: 1,
|
|
22
|
-
title: 'The number of minutes the results are binned to.',
|
|
23
|
-
examples: [
|
|
24
|
-
15
|
|
25
|
-
]
|
|
26
|
-
}),
|
|
27
|
-
deviceId: PublicDeviceId
|
|
28
|
-
}, {
|
|
29
|
-
title: "The query that was used"
|
|
30
|
-
})
|
|
31
|
-
}, {
|
|
32
|
-
title: 'Resource history',
|
|
33
|
-
description: 'Contains historical values of an LwM2M resource for a device.'
|
|
34
|
-
});
|
package/dist/api/History.spec.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
var input = {
|
|
8
|
-
'@context': 'https://github.com/hello-nrfcloud/proto-map/history/resource',
|
|
9
|
-
query: {
|
|
10
|
-
ObjectID: 14230,
|
|
11
|
-
ObjectVersion: '1.0',
|
|
12
|
-
ObjectInstanceID: 0,
|
|
13
|
-
deviceId: 'bassetto-ennobler-toilless',
|
|
14
|
-
binIntervalMinutes: 15
|
|
15
|
-
},
|
|
16
|
-
partialInstances: [
|
|
17
|
-
{
|
|
18
|
-
'0': 92.2,
|
|
19
|
-
'99': 1713510000000,
|
|
20
|
-
ts: '2024-04-19T08:45:00.000Z'
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
'0': 113.8,
|
|
24
|
-
'99': 1713515400000,
|
|
25
|
-
ts: '2024-04-19T08:30:00.000Z'
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
};
|
|
29
|
-
var maybeValid = validate(ResourceHistory)(input);
|
|
30
|
-
assert.equal('errors' in maybeValid, false);
|
|
31
|
-
assert.deepEqual('value' in maybeValid && maybeValid.value, input);
|
|
32
|
-
});
|
|
33
|
-
});
|
package/dist/api/ObjectUpdate.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
});
|
package/dist/api/Timestamp.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
});
|