@hello.nrfcloud.com/proto-map 5.6.2 → 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.
- package/api/Context.ts +1 -1
- package/api/{ResourceUpdate.spec.ts → ObjectUpdate.spec.ts} +5 -5
- package/api/{ResourceUpdate.ts → ObjectUpdate.ts} +4 -4
- package/dist/api/Context.js +1 -1
- package/dist/api/DeviceId.js +7 -7
- package/dist/api/Devices.js +11 -11
- package/dist/api/History.js +10 -10
- package/dist/api/History.spec.js +17 -17
- package/dist/api/LwM2M.js +11 -11
- package/dist/api/ObjectUpdate.js +17 -0
- package/dist/api/ObjectUpdate.spec.js +26 -0
- package/dist/api/ShareDeviceOwnershipConfirmed.js +4 -4
- package/dist/api/ShareDeviceRequest.js +4 -4
- package/dist/api/Timestamp.js +3 -3
- package/dist/api/Timestamp.spec.js +9 -9
- package/dist/api/index.js +8 -8
- package/dist/generator/addDocBlock.js +2 -2
- package/dist/generator/generateLwM2MDefinitions.js +27 -27
- package/dist/generator/generateLwM2MDefinitions.spec.js +32 -32
- package/dist/generator/generateLwm2mTimestampResources.js +7 -7
- package/dist/generator/generateModels.js +37 -37
- package/dist/generator/generateType.js +21 -21
- package/dist/generator/generateValidator.js +29 -29
- package/dist/generator/generateValidators.js +9 -9
- package/dist/generator/isDir.js +1 -1
- package/dist/generator/isDir.spec.js +13 -13
- package/dist/generator/lwm2m.js +23 -23
- package/dist/generator/models.js +23 -23
- package/dist/generator/printNode.js +2 -2
- package/dist/generator/tokenizeName.js +2 -2
- package/dist/generator/tokenizeName.spec.js +20 -20
- package/dist/generator/types.js +37 -37
- package/dist/lwm2m/LWM2MObjectDefinition.js +30 -30
- package/dist/lwm2m/check-lwm2m-rules.js +34 -34
- package/dist/lwm2m/definitions.js +4 -4
- package/dist/lwm2m/fromXML2JSON.js +4 -4
- package/dist/lwm2m/instanceTs.js +2 -2
- package/dist/lwm2m/instanceTs.spec.js +10 -10
- package/dist/lwm2m/isRegisteredLwM2MObject.js +2 -2
- package/dist/lwm2m/isRegisteredLwM2MObject.spec.js +12 -12
- package/dist/lwm2m/parseRangeEnumeration.js +1 -1
- package/dist/lwm2m/parseRangeEnumeration.spec.js +11 -11
- package/dist/lwm2m/unwrapNestedArray.js +2 -2
- package/dist/lwm2m/unwrapNestedArray.spec.js +155 -155
- package/dist/lwm2m/validate.js +1 -1
- package/dist/lwm2m/validation.js +16 -16
- package/dist/markdown/getCodeBlock.js +5 -5
- package/dist/markdown/getFrontMatter.js +6 -6
- package/dist/markdown/parseREADME.js +5 -5
- package/dist/models/asset_tracker_v2+AWS/examples/examples.spec.js +21 -21
- package/dist/models/check-model-rules.js +42 -42
- package/dist/models/models.js +20 -20
- package/dist/models/types.js +3 -3
- package/dist/senml/SenMLSchema.js +16 -16
- package/dist/senml/SenMLSchema.spec.js +11 -11
- package/dist/senml/hasValue.js +2 -2
- package/dist/senml/hasValue.spec.js +4 -4
- package/dist/senml/lwm2mToSenML.js +8 -8
- package/dist/senml/lwm2mToSenML.spec.js +42 -42
- package/dist/senml/parseResourceId.js +1 -1
- package/dist/senml/parseResourceId.spec.js +6 -6
- package/dist/senml/senMLtoLwM2M.js +14 -14
- package/dist/senml/senMLtoLwM2M.spec.js +53 -53
- package/dist/senml/validateSenML.js +2 -2
- package/dist/senml/validateSenML.spec.js +11 -11
- package/package.json +4 -8
- package/dist/api/ResourceUpdate.js +0 -17
- package/dist/api/ResourceUpdate.spec.js +0 -26
|
@@ -1,254 +1,254 @@
|
|
|
1
|
-
import { describe, it } from
|
|
2
|
-
import assert from
|
|
3
|
-
import { unwrapNestedArray } from
|
|
4
|
-
void describe(
|
|
5
|
-
void it(
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { unwrapNestedArray } from './unwrapNestedArray.js';
|
|
4
|
+
void describe('unwrapNestedArray()', function() {
|
|
5
|
+
void it('should unwrap an array', function() {
|
|
6
6
|
return assert.deepEqual(unwrapNestedArray({
|
|
7
7
|
LWM2M: {
|
|
8
8
|
$: {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
|
10
|
+
'xsi:noNamespaceSchemaLocation': 'http://www.openmobilealliance.org/tech/profiles/LWM2M-v1_1.xsd'
|
|
11
11
|
},
|
|
12
12
|
Object: [
|
|
13
13
|
{
|
|
14
14
|
$: {
|
|
15
|
-
ObjectType:
|
|
15
|
+
ObjectType: 'MODefinition'
|
|
16
16
|
},
|
|
17
17
|
Name: [
|
|
18
|
-
|
|
18
|
+
'Location'
|
|
19
19
|
],
|
|
20
20
|
Description1: [
|
|
21
|
-
|
|
21
|
+
'This LwM2M Object provides a range of location telemetry related information which can be queried by the LwM2M Server.'
|
|
22
22
|
],
|
|
23
23
|
ObjectID: [
|
|
24
|
-
|
|
24
|
+
'6'
|
|
25
25
|
],
|
|
26
26
|
ObjectURN: [
|
|
27
|
-
|
|
27
|
+
'urn:oma:lwm2m:oma:6'
|
|
28
28
|
],
|
|
29
29
|
LWM2MVersion: [
|
|
30
|
-
|
|
30
|
+
'1.0'
|
|
31
31
|
],
|
|
32
32
|
ObjectVersion: [
|
|
33
|
-
|
|
33
|
+
'1.0'
|
|
34
34
|
],
|
|
35
35
|
MultipleInstances: [
|
|
36
|
-
|
|
36
|
+
'Single'
|
|
37
37
|
],
|
|
38
38
|
Mandatory: [
|
|
39
|
-
|
|
39
|
+
'Optional'
|
|
40
40
|
],
|
|
41
41
|
Resources: [
|
|
42
42
|
{
|
|
43
43
|
Item: [
|
|
44
44
|
{
|
|
45
45
|
$: {
|
|
46
|
-
ID:
|
|
46
|
+
ID: '0'
|
|
47
47
|
},
|
|
48
48
|
Name: [
|
|
49
|
-
|
|
49
|
+
'Latitude'
|
|
50
50
|
],
|
|
51
51
|
Operations: [
|
|
52
|
-
|
|
52
|
+
'R'
|
|
53
53
|
],
|
|
54
54
|
MultipleInstances: [
|
|
55
|
-
|
|
55
|
+
'Single'
|
|
56
56
|
],
|
|
57
57
|
Mandatory: [
|
|
58
|
-
|
|
58
|
+
'Mandatory'
|
|
59
59
|
],
|
|
60
60
|
Type: [
|
|
61
|
-
|
|
61
|
+
'Float'
|
|
62
62
|
],
|
|
63
63
|
RangeEnumeration: [
|
|
64
|
-
|
|
64
|
+
''
|
|
65
65
|
],
|
|
66
66
|
Units: [
|
|
67
|
-
|
|
67
|
+
'lat'
|
|
68
68
|
],
|
|
69
69
|
Description: [
|
|
70
|
-
|
|
70
|
+
'The decimal notation of latitude, e.g. -43.5723 [World Geodetic System 1984].'
|
|
71
71
|
]
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
$: {
|
|
75
|
-
ID:
|
|
75
|
+
ID: '1'
|
|
76
76
|
},
|
|
77
77
|
Name: [
|
|
78
|
-
|
|
78
|
+
'Longitude'
|
|
79
79
|
],
|
|
80
80
|
Operations: [
|
|
81
|
-
|
|
81
|
+
'R'
|
|
82
82
|
],
|
|
83
83
|
MultipleInstances: [
|
|
84
|
-
|
|
84
|
+
'Single'
|
|
85
85
|
],
|
|
86
86
|
Mandatory: [
|
|
87
|
-
|
|
87
|
+
'Mandatory'
|
|
88
88
|
],
|
|
89
89
|
Type: [
|
|
90
|
-
|
|
90
|
+
'Float'
|
|
91
91
|
],
|
|
92
92
|
RangeEnumeration: [
|
|
93
|
-
|
|
93
|
+
''
|
|
94
94
|
],
|
|
95
95
|
Units: [
|
|
96
|
-
|
|
96
|
+
'lon'
|
|
97
97
|
],
|
|
98
98
|
Description: [
|
|
99
|
-
|
|
99
|
+
'The decimal notation of longitude, e.g. 153.21760 [World Geodetic System 1984].'
|
|
100
100
|
]
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
103
|
$: {
|
|
104
|
-
ID:
|
|
104
|
+
ID: '2'
|
|
105
105
|
},
|
|
106
106
|
Name: [
|
|
107
|
-
|
|
107
|
+
'Altitude'
|
|
108
108
|
],
|
|
109
109
|
Operations: [
|
|
110
|
-
|
|
110
|
+
'R'
|
|
111
111
|
],
|
|
112
112
|
MultipleInstances: [
|
|
113
|
-
|
|
113
|
+
'Single'
|
|
114
114
|
],
|
|
115
115
|
Mandatory: [
|
|
116
|
-
|
|
116
|
+
'Optional'
|
|
117
117
|
],
|
|
118
118
|
Type: [
|
|
119
|
-
|
|
119
|
+
'Float'
|
|
120
120
|
],
|
|
121
121
|
RangeEnumeration: [
|
|
122
|
-
|
|
122
|
+
''
|
|
123
123
|
],
|
|
124
124
|
Units: [
|
|
125
|
-
|
|
125
|
+
'm'
|
|
126
126
|
],
|
|
127
127
|
Description: [
|
|
128
|
-
|
|
128
|
+
'The decimal notation of altitude in meters above sea level.'
|
|
129
129
|
]
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
132
|
$: {
|
|
133
|
-
ID:
|
|
133
|
+
ID: '3'
|
|
134
134
|
},
|
|
135
135
|
Name: [
|
|
136
|
-
|
|
136
|
+
'Radius'
|
|
137
137
|
],
|
|
138
138
|
Operations: [
|
|
139
|
-
|
|
139
|
+
'R'
|
|
140
140
|
],
|
|
141
141
|
MultipleInstances: [
|
|
142
|
-
|
|
142
|
+
'Single'
|
|
143
143
|
],
|
|
144
144
|
Mandatory: [
|
|
145
|
-
|
|
145
|
+
'Optional'
|
|
146
146
|
],
|
|
147
147
|
Type: [
|
|
148
|
-
|
|
148
|
+
'Float'
|
|
149
149
|
],
|
|
150
150
|
RangeEnumeration: [
|
|
151
|
-
|
|
151
|
+
''
|
|
152
152
|
],
|
|
153
153
|
Units: [
|
|
154
|
-
|
|
154
|
+
'm'
|
|
155
155
|
],
|
|
156
156
|
Description: [
|
|
157
|
-
|
|
157
|
+
'The value in this resource indicates the radius of a circular area in meters. The circular area is used to describe uncertainty about a point for coordinates in a two-dimensional coordinate reference systems (CRS). The center point of a circular area is specified by using the Latitude and the Longitude Resources.'
|
|
158
158
|
]
|
|
159
159
|
},
|
|
160
160
|
{
|
|
161
161
|
$: {
|
|
162
|
-
ID:
|
|
162
|
+
ID: '4'
|
|
163
163
|
},
|
|
164
164
|
Name: [
|
|
165
|
-
|
|
165
|
+
'Velocity'
|
|
166
166
|
],
|
|
167
167
|
Operations: [
|
|
168
|
-
|
|
168
|
+
'R'
|
|
169
169
|
],
|
|
170
170
|
MultipleInstances: [
|
|
171
|
-
|
|
171
|
+
'Single'
|
|
172
172
|
],
|
|
173
173
|
Mandatory: [
|
|
174
|
-
|
|
174
|
+
'Optional'
|
|
175
175
|
],
|
|
176
176
|
Type: [
|
|
177
|
-
|
|
177
|
+
'Opaque'
|
|
178
178
|
],
|
|
179
179
|
RangeEnumeration: [
|
|
180
|
-
|
|
180
|
+
''
|
|
181
181
|
],
|
|
182
182
|
Units: [
|
|
183
|
-
|
|
183
|
+
''
|
|
184
184
|
],
|
|
185
185
|
Description: [
|
|
186
|
-
|
|
186
|
+
'The velocity of the LwM2M Client, as defined in [3GPP-TS_23.032].'
|
|
187
187
|
]
|
|
188
188
|
},
|
|
189
189
|
{
|
|
190
190
|
$: {
|
|
191
|
-
ID:
|
|
191
|
+
ID: '5'
|
|
192
192
|
},
|
|
193
193
|
Name: [
|
|
194
|
-
|
|
194
|
+
'Timestamp'
|
|
195
195
|
],
|
|
196
196
|
Operations: [
|
|
197
|
-
|
|
197
|
+
'R'
|
|
198
198
|
],
|
|
199
199
|
MultipleInstances: [
|
|
200
|
-
|
|
200
|
+
'Single'
|
|
201
201
|
],
|
|
202
202
|
Mandatory: [
|
|
203
|
-
|
|
203
|
+
'Mandatory'
|
|
204
204
|
],
|
|
205
205
|
Type: [
|
|
206
|
-
|
|
206
|
+
'Time'
|
|
207
207
|
],
|
|
208
208
|
RangeEnumeration: [
|
|
209
|
-
|
|
209
|
+
''
|
|
210
210
|
],
|
|
211
211
|
Units: [
|
|
212
|
-
|
|
212
|
+
''
|
|
213
213
|
],
|
|
214
214
|
Description: [
|
|
215
|
-
|
|
215
|
+
'The timestamp of when the location measurement was performed.'
|
|
216
216
|
]
|
|
217
217
|
},
|
|
218
218
|
{
|
|
219
219
|
$: {
|
|
220
|
-
ID:
|
|
220
|
+
ID: '6'
|
|
221
221
|
},
|
|
222
222
|
Name: [
|
|
223
|
-
|
|
223
|
+
'Speed'
|
|
224
224
|
],
|
|
225
225
|
Operations: [
|
|
226
|
-
|
|
226
|
+
'R'
|
|
227
227
|
],
|
|
228
228
|
MultipleInstances: [
|
|
229
|
-
|
|
229
|
+
'Single'
|
|
230
230
|
],
|
|
231
231
|
Mandatory: [
|
|
232
|
-
|
|
232
|
+
'Optional'
|
|
233
233
|
],
|
|
234
234
|
Type: [
|
|
235
|
-
|
|
235
|
+
'Float'
|
|
236
236
|
],
|
|
237
237
|
RangeEnumeration: [
|
|
238
|
-
|
|
238
|
+
''
|
|
239
239
|
],
|
|
240
240
|
Units: [
|
|
241
|
-
|
|
241
|
+
'm/s'
|
|
242
242
|
],
|
|
243
243
|
Description: [
|
|
244
|
-
|
|
244
|
+
'Speed is the time rate of change in position of a LwM2M Client without regard for direction: the scalar component of velocity.'
|
|
245
245
|
]
|
|
246
246
|
}
|
|
247
247
|
]
|
|
248
248
|
}
|
|
249
249
|
],
|
|
250
250
|
Description2: [
|
|
251
|
-
|
|
251
|
+
''
|
|
252
252
|
]
|
|
253
253
|
}
|
|
254
254
|
]
|
|
@@ -256,117 +256,117 @@ void describe("unwrapNestedArray()", function() {
|
|
|
256
256
|
}), {
|
|
257
257
|
LWM2M: {
|
|
258
258
|
$: {
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
|
260
|
+
'xsi:noNamespaceSchemaLocation': 'http://www.openmobilealliance.org/tech/profiles/LWM2M-v1_1.xsd'
|
|
261
261
|
},
|
|
262
262
|
Object: {
|
|
263
263
|
$: {
|
|
264
|
-
ObjectType:
|
|
264
|
+
ObjectType: 'MODefinition'
|
|
265
265
|
},
|
|
266
|
-
Name:
|
|
267
|
-
Description1:
|
|
268
|
-
ObjectID:
|
|
269
|
-
ObjectURN:
|
|
270
|
-
LWM2MVersion:
|
|
271
|
-
ObjectVersion:
|
|
272
|
-
MultipleInstances:
|
|
273
|
-
Mandatory:
|
|
266
|
+
Name: 'Location',
|
|
267
|
+
Description1: 'This LwM2M Object provides a range of location telemetry related information which can be queried by the LwM2M Server.',
|
|
268
|
+
ObjectID: '6',
|
|
269
|
+
ObjectURN: 'urn:oma:lwm2m:oma:6',
|
|
270
|
+
LWM2MVersion: '1.0',
|
|
271
|
+
ObjectVersion: '1.0',
|
|
272
|
+
MultipleInstances: 'Single',
|
|
273
|
+
Mandatory: 'Optional',
|
|
274
274
|
Resources: {
|
|
275
275
|
Item: [
|
|
276
276
|
{
|
|
277
277
|
$: {
|
|
278
|
-
ID:
|
|
278
|
+
ID: '0'
|
|
279
279
|
},
|
|
280
|
-
Name:
|
|
281
|
-
Operations:
|
|
282
|
-
MultipleInstances:
|
|
283
|
-
Mandatory:
|
|
284
|
-
Type:
|
|
285
|
-
RangeEnumeration:
|
|
286
|
-
Units:
|
|
287
|
-
Description:
|
|
280
|
+
Name: 'Latitude',
|
|
281
|
+
Operations: 'R',
|
|
282
|
+
MultipleInstances: 'Single',
|
|
283
|
+
Mandatory: 'Mandatory',
|
|
284
|
+
Type: 'Float',
|
|
285
|
+
RangeEnumeration: '',
|
|
286
|
+
Units: 'lat',
|
|
287
|
+
Description: 'The decimal notation of latitude, e.g. -43.5723 [World Geodetic System 1984].'
|
|
288
288
|
},
|
|
289
289
|
{
|
|
290
290
|
$: {
|
|
291
|
-
ID:
|
|
291
|
+
ID: '1'
|
|
292
292
|
},
|
|
293
|
-
Name:
|
|
294
|
-
Operations:
|
|
295
|
-
MultipleInstances:
|
|
296
|
-
Mandatory:
|
|
297
|
-
Type:
|
|
298
|
-
RangeEnumeration:
|
|
299
|
-
Units:
|
|
300
|
-
Description:
|
|
293
|
+
Name: 'Longitude',
|
|
294
|
+
Operations: 'R',
|
|
295
|
+
MultipleInstances: 'Single',
|
|
296
|
+
Mandatory: 'Mandatory',
|
|
297
|
+
Type: 'Float',
|
|
298
|
+
RangeEnumeration: '',
|
|
299
|
+
Units: 'lon',
|
|
300
|
+
Description: 'The decimal notation of longitude, e.g. 153.21760 [World Geodetic System 1984].'
|
|
301
301
|
},
|
|
302
302
|
{
|
|
303
303
|
$: {
|
|
304
|
-
ID:
|
|
304
|
+
ID: '2'
|
|
305
305
|
},
|
|
306
|
-
Name:
|
|
307
|
-
Operations:
|
|
308
|
-
MultipleInstances:
|
|
309
|
-
Mandatory:
|
|
310
|
-
Type:
|
|
311
|
-
RangeEnumeration:
|
|
312
|
-
Units:
|
|
313
|
-
Description:
|
|
306
|
+
Name: 'Altitude',
|
|
307
|
+
Operations: 'R',
|
|
308
|
+
MultipleInstances: 'Single',
|
|
309
|
+
Mandatory: 'Optional',
|
|
310
|
+
Type: 'Float',
|
|
311
|
+
RangeEnumeration: '',
|
|
312
|
+
Units: 'm',
|
|
313
|
+
Description: 'The decimal notation of altitude in meters above sea level.'
|
|
314
314
|
},
|
|
315
315
|
{
|
|
316
316
|
$: {
|
|
317
|
-
ID:
|
|
317
|
+
ID: '3'
|
|
318
318
|
},
|
|
319
|
-
Name:
|
|
320
|
-
Operations:
|
|
321
|
-
MultipleInstances:
|
|
322
|
-
Mandatory:
|
|
323
|
-
Type:
|
|
324
|
-
RangeEnumeration:
|
|
325
|
-
Units:
|
|
326
|
-
Description:
|
|
319
|
+
Name: 'Radius',
|
|
320
|
+
Operations: 'R',
|
|
321
|
+
MultipleInstances: 'Single',
|
|
322
|
+
Mandatory: 'Optional',
|
|
323
|
+
Type: 'Float',
|
|
324
|
+
RangeEnumeration: '',
|
|
325
|
+
Units: 'm',
|
|
326
|
+
Description: 'The value in this resource indicates the radius of a circular area in meters. The circular area is used to describe uncertainty about a point for coordinates in a two-dimensional coordinate reference systems (CRS). The center point of a circular area is specified by using the Latitude and the Longitude Resources.'
|
|
327
327
|
},
|
|
328
328
|
{
|
|
329
329
|
$: {
|
|
330
|
-
ID:
|
|
330
|
+
ID: '4'
|
|
331
331
|
},
|
|
332
|
-
Name:
|
|
333
|
-
Operations:
|
|
334
|
-
MultipleInstances:
|
|
335
|
-
Mandatory:
|
|
336
|
-
Type:
|
|
337
|
-
RangeEnumeration:
|
|
338
|
-
Units:
|
|
339
|
-
Description:
|
|
332
|
+
Name: 'Velocity',
|
|
333
|
+
Operations: 'R',
|
|
334
|
+
MultipleInstances: 'Single',
|
|
335
|
+
Mandatory: 'Optional',
|
|
336
|
+
Type: 'Opaque',
|
|
337
|
+
RangeEnumeration: '',
|
|
338
|
+
Units: '',
|
|
339
|
+
Description: 'The velocity of the LwM2M Client, as defined in [3GPP-TS_23.032].'
|
|
340
340
|
},
|
|
341
341
|
{
|
|
342
342
|
$: {
|
|
343
|
-
ID:
|
|
343
|
+
ID: '5'
|
|
344
344
|
},
|
|
345
|
-
Name:
|
|
346
|
-
Operations:
|
|
347
|
-
MultipleInstances:
|
|
348
|
-
Mandatory:
|
|
349
|
-
Type:
|
|
350
|
-
RangeEnumeration:
|
|
351
|
-
Units:
|
|
352
|
-
Description:
|
|
345
|
+
Name: 'Timestamp',
|
|
346
|
+
Operations: 'R',
|
|
347
|
+
MultipleInstances: 'Single',
|
|
348
|
+
Mandatory: 'Mandatory',
|
|
349
|
+
Type: 'Time',
|
|
350
|
+
RangeEnumeration: '',
|
|
351
|
+
Units: '',
|
|
352
|
+
Description: 'The timestamp of when the location measurement was performed.'
|
|
353
353
|
},
|
|
354
354
|
{
|
|
355
355
|
$: {
|
|
356
|
-
ID:
|
|
356
|
+
ID: '6'
|
|
357
357
|
},
|
|
358
|
-
Name:
|
|
359
|
-
Operations:
|
|
360
|
-
MultipleInstances:
|
|
361
|
-
Mandatory:
|
|
362
|
-
Type:
|
|
363
|
-
RangeEnumeration:
|
|
364
|
-
Units:
|
|
365
|
-
Description:
|
|
358
|
+
Name: 'Speed',
|
|
359
|
+
Operations: 'R',
|
|
360
|
+
MultipleInstances: 'Single',
|
|
361
|
+
Mandatory: 'Optional',
|
|
362
|
+
Type: 'Float',
|
|
363
|
+
RangeEnumeration: '',
|
|
364
|
+
Units: 'm/s',
|
|
365
|
+
Description: 'Speed is the time rate of change in position of a LwM2M Client without regard for direction: the scalar component of velocity.'
|
|
366
366
|
}
|
|
367
367
|
]
|
|
368
368
|
},
|
|
369
|
-
Description2:
|
|
369
|
+
Description2: ''
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
});
|
package/dist/lwm2m/validate.js
CHANGED
package/dist/lwm2m/validation.js
CHANGED
|
@@ -55,7 +55,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
55
55
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
56
56
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
57
57
|
}
|
|
58
|
-
import { LwM2MObjectIDs } from
|
|
58
|
+
import { LwM2MObjectIDs } from './LwM2MObjectID.js';
|
|
59
59
|
export var isLwM2MObject = function(object, onError) {
|
|
60
60
|
var _Object_keys_find;
|
|
61
61
|
var error = function(message) {
|
|
@@ -63,15 +63,15 @@ export var isLwM2MObject = function(object, onError) {
|
|
|
63
63
|
return false;
|
|
64
64
|
};
|
|
65
65
|
// Must be an object
|
|
66
|
-
if (typeof object !==
|
|
66
|
+
if (typeof object !== 'object' || object === null) return error("Not an object");
|
|
67
67
|
// Must have valid ObjectID
|
|
68
|
-
if (!(
|
|
68
|
+
if (!('ObjectID' in object) || typeof object.ObjectID !== 'number' || object.ObjectID < 14200 || object.ObjectID > 15000 || LwM2MObjectIDs.includes(object.ObjectID) === false) return error("Not an valid Object ID: ".concat(JSON.stringify(object.ObjectID)));
|
|
69
69
|
// ObjectVersion must be valid
|
|
70
|
-
if (
|
|
71
|
-
if (typeof object.ObjectVersion !==
|
|
70
|
+
if ('ObjectVersion' in object) {
|
|
71
|
+
if (typeof object.ObjectVersion !== 'string' || !/^\d+\.\d+$/.test(object.ObjectVersion)) return error("Invalid ObjectVersion");
|
|
72
72
|
}
|
|
73
73
|
// Must have valid resources
|
|
74
|
-
if (!(
|
|
74
|
+
if (!('Resources' in object) || typeof object.Resources !== 'object' || object.Resources === null) return error("Resources must be an object");
|
|
75
75
|
var _Object_keys_find_length;
|
|
76
76
|
// All keys must be numbers
|
|
77
77
|
if (((_Object_keys_find_length = (_Object_keys_find = Object.keys(object.Resources).find(function(k) {
|
|
@@ -82,10 +82,10 @@ export var isLwM2MObject = function(object, onError) {
|
|
|
82
82
|
// All values must be number, string, boolean, or Date
|
|
83
83
|
for(var _iterator = Object.values(object.Resources)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
84
84
|
var v = _step.value;
|
|
85
|
-
if (typeof v ===
|
|
86
|
-
if (typeof v ===
|
|
87
|
-
if (typeof v ===
|
|
88
|
-
if (typeof v ===
|
|
85
|
+
if (typeof v === 'string') continue;
|
|
86
|
+
if (typeof v === 'boolean') continue;
|
|
87
|
+
if (typeof v === 'number') continue;
|
|
88
|
+
if (typeof v === 'object' && _instanceof(v, Date)) continue;
|
|
89
89
|
return error("Invalid value type ".concat(typeof v === "undefined" ? "undefined" : _type_of(v)));
|
|
90
90
|
}
|
|
91
91
|
} catch (err) {
|
|
@@ -113,7 +113,7 @@ export var validate = function(ObjectID, ObjectVersion, Resources) {
|
|
|
113
113
|
if (!isLwM2MObject(o, onError)) return false;
|
|
114
114
|
if (o.ObjectID !== ObjectID) return error("Given Object ID ".concat(o.ObjectID, " does not match expected ").concat(ObjectID));
|
|
115
115
|
var _o_ObjectVersion;
|
|
116
|
-
if (((_o_ObjectVersion = o.ObjectVersion) !== null && _o_ObjectVersion !== void 0 ? _o_ObjectVersion :
|
|
116
|
+
if (((_o_ObjectVersion = o.ObjectVersion) !== null && _o_ObjectVersion !== void 0 ? _o_ObjectVersion : '1.0') !== ObjectVersion) return error("Given Object version ".concat(o.ObjectVersion, " does not match expected ").concat(ObjectVersion));
|
|
117
117
|
return Object.entries(Resources).reduce(function(allValid, param) {
|
|
118
118
|
var _param = _sliced_to_array(param, 2), ResourceID = _param[0], validator = _param[1];
|
|
119
119
|
if (!allValid) return false;
|
|
@@ -125,16 +125,16 @@ export var validate = function(ObjectID, ObjectVersion, Resources) {
|
|
|
125
125
|
};
|
|
126
126
|
};
|
|
127
127
|
export var NumberResource = function(r) {
|
|
128
|
-
return typeof r ===
|
|
128
|
+
return typeof r === 'number';
|
|
129
129
|
};
|
|
130
130
|
export var StringResource = function(r) {
|
|
131
|
-
return typeof r ===
|
|
131
|
+
return typeof r === 'string';
|
|
132
132
|
};
|
|
133
133
|
export var DateResource = function(r) {
|
|
134
|
-
return typeof r ===
|
|
134
|
+
return typeof r === 'object' && _instanceof(r, Date);
|
|
135
135
|
};
|
|
136
136
|
export var BooleanResource = function(r) {
|
|
137
|
-
return typeof r ===
|
|
137
|
+
return typeof r === 'boolean';
|
|
138
138
|
};
|
|
139
139
|
export var OptionalResource = function(validator) {
|
|
140
140
|
return function(r) {
|
|
@@ -142,5 +142,5 @@ export var OptionalResource = function(validator) {
|
|
|
142
142
|
};
|
|
143
143
|
};
|
|
144
144
|
export var isLwM2MObjectID = function(o) {
|
|
145
|
-
return typeof o ===
|
|
145
|
+
return typeof o === 'number' && LwM2MObjectIDs.includes(o);
|
|
146
146
|
};
|