@hello.nrfcloud.com/proto-map 5.6.1 → 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.
Files changed (68) hide show
  1. package/api/Context.ts +1 -1
  2. package/api/{ResourceUpdate.spec.ts → ObjectUpdate.spec.ts} +5 -5
  3. package/api/{ResourceUpdate.ts → ObjectUpdate.ts} +6 -6
  4. package/dist/api/Context.js +1 -1
  5. package/dist/api/DeviceId.js +7 -7
  6. package/dist/api/Devices.js +11 -11
  7. package/dist/api/History.js +10 -10
  8. package/dist/api/History.spec.js +17 -17
  9. package/dist/api/LwM2M.js +11 -11
  10. package/dist/api/ObjectUpdate.js +17 -0
  11. package/dist/api/ObjectUpdate.spec.js +26 -0
  12. package/dist/api/ShareDeviceOwnershipConfirmed.js +4 -4
  13. package/dist/api/ShareDeviceRequest.js +4 -4
  14. package/dist/api/Timestamp.js +3 -3
  15. package/dist/api/Timestamp.spec.js +9 -9
  16. package/dist/api/index.js +8 -8
  17. package/dist/generator/addDocBlock.js +2 -2
  18. package/dist/generator/generateLwM2MDefinitions.js +27 -27
  19. package/dist/generator/generateLwM2MDefinitions.spec.js +32 -32
  20. package/dist/generator/generateLwm2mTimestampResources.js +7 -7
  21. package/dist/generator/generateModels.js +37 -37
  22. package/dist/generator/generateType.js +21 -21
  23. package/dist/generator/generateValidator.js +29 -29
  24. package/dist/generator/generateValidators.js +9 -9
  25. package/dist/generator/isDir.js +1 -1
  26. package/dist/generator/isDir.spec.js +13 -13
  27. package/dist/generator/lwm2m.js +23 -23
  28. package/dist/generator/models.js +23 -23
  29. package/dist/generator/printNode.js +2 -2
  30. package/dist/generator/tokenizeName.js +2 -2
  31. package/dist/generator/tokenizeName.spec.js +20 -20
  32. package/dist/generator/types.js +37 -37
  33. package/dist/lwm2m/LWM2MObjectDefinition.js +30 -30
  34. package/dist/lwm2m/check-lwm2m-rules.js +34 -34
  35. package/dist/lwm2m/definitions.js +4 -4
  36. package/dist/lwm2m/fromXML2JSON.js +4 -4
  37. package/dist/lwm2m/instanceTs.js +2 -2
  38. package/dist/lwm2m/instanceTs.spec.js +10 -10
  39. package/dist/lwm2m/isRegisteredLwM2MObject.js +2 -2
  40. package/dist/lwm2m/isRegisteredLwM2MObject.spec.js +12 -12
  41. package/dist/lwm2m/parseRangeEnumeration.js +1 -1
  42. package/dist/lwm2m/parseRangeEnumeration.spec.js +11 -11
  43. package/dist/lwm2m/unwrapNestedArray.js +2 -2
  44. package/dist/lwm2m/unwrapNestedArray.spec.js +155 -155
  45. package/dist/lwm2m/validate.js +1 -1
  46. package/dist/lwm2m/validation.js +16 -16
  47. package/dist/markdown/getCodeBlock.js +5 -5
  48. package/dist/markdown/getFrontMatter.js +6 -6
  49. package/dist/markdown/parseREADME.js +5 -5
  50. package/dist/models/asset_tracker_v2+AWS/examples/examples.spec.js +21 -21
  51. package/dist/models/check-model-rules.js +42 -42
  52. package/dist/models/models.js +20 -20
  53. package/dist/models/types.js +3 -3
  54. package/dist/senml/SenMLSchema.js +16 -16
  55. package/dist/senml/SenMLSchema.spec.js +11 -11
  56. package/dist/senml/hasValue.js +2 -2
  57. package/dist/senml/hasValue.spec.js +4 -4
  58. package/dist/senml/lwm2mToSenML.js +8 -8
  59. package/dist/senml/lwm2mToSenML.spec.js +42 -42
  60. package/dist/senml/parseResourceId.js +1 -1
  61. package/dist/senml/parseResourceId.spec.js +6 -6
  62. package/dist/senml/senMLtoLwM2M.js +14 -14
  63. package/dist/senml/senMLtoLwM2M.spec.js +53 -53
  64. package/dist/senml/validateSenML.js +2 -2
  65. package/dist/senml/validateSenML.spec.js +11 -11
  66. package/package.json +4 -8
  67. package/dist/api/ResourceUpdate.js +0 -17
  68. package/dist/api/ResourceUpdate.spec.js +0 -26
@@ -1,21 +1,21 @@
1
- import { remark } from "remark";
1
+ import { remark } from 'remark';
2
2
  export var parseMarkdown2 = remark();
3
3
  var isCodeBlock = function(lang) {
4
4
  return function(child) {
5
- return child.type === "code" && child.lang === lang;
5
+ return child.type === 'code' && child.lang === lang;
6
6
  };
7
7
  };
8
8
  var isHeadingWithTitle = function(title) {
9
9
  return function(child) {
10
10
  var _child_children_;
11
- return child.type === "heading" && ((_child_children_ = child.children[0]) === null || _child_children_ === void 0 ? void 0 : _child_children_.type) === "text" && child.children[0].value === title;
11
+ return child.type === 'heading' && ((_child_children_ = child.children[0]) === null || _child_children_ === void 0 ? void 0 : _child_children_.type) === 'text' && child.children[0].value === title;
12
12
  };
13
13
  };
14
14
  var isHeading = function(child) {
15
- return child.type === "heading";
15
+ return child.type === 'heading';
16
16
  };
17
17
  var isParagraph = function(child) {
18
- return child.type === "paragraph";
18
+ return child.type === 'paragraph';
19
19
  };
20
20
  var codeBlockWithHeading = function(children) {
21
21
  return function(lang, title) {
@@ -1,13 +1,13 @@
1
- import { remark } from "remark";
2
- import frontmatter from "remark-frontmatter";
3
- import { validate } from "../validate.js";
4
- import yaml from "yaml";
1
+ import { remark } from 'remark';
2
+ import frontmatter from 'remark-frontmatter';
3
+ import { validate } from '../validate.js';
4
+ import yaml from 'yaml';
5
5
  export var getFrontMatter = function(markdown, schema) {
6
6
  var data = yaml.parse(remark().use(frontmatter, [
7
- "yaml"
7
+ 'yaml'
8
8
  ]).parse(markdown).children[0].value);
9
9
  var maybeValid = validate(schema)(data);
10
- if ("errors" in maybeValid) {
10
+ if ('errors' in maybeValid) {
11
11
  console.error(maybeValid.errors);
12
12
  throw new Error("Frontmatter is not valid!");
13
13
  }
@@ -1,4 +1,4 @@
1
- import { getHeading, getParagraphsAfterHeading } from "./getCodeBlock.js";
1
+ import { getHeading, getParagraphsAfterHeading } from './getCodeBlock.js';
2
2
  export var parseREADME = function(markdown) {
3
3
  var h1 = getHeading(markdown, 1);
4
4
  if (h1 === undefined) throw new Error("No H1 defined!");
@@ -10,10 +10,10 @@ export var parseREADME = function(markdown) {
10
10
  };
11
11
  };
12
12
  var nodeToString = function(node) {
13
- if ("value" in node) return node.value;
14
- if ("children" in node) return node.children.map(nodeToString).join("");
15
- return "";
13
+ if ('value' in node) return node.value;
14
+ if ('children' in node) return node.children.map(nodeToString).join('');
15
+ return '';
16
16
  };
17
17
  var toOneLine = function(s) {
18
- return s.trim().replaceAll("\n", " ");
18
+ return s.trim().replaceAll('\n', ' ');
19
19
  };
@@ -168,13 +168,13 @@ function _ts_generator(thisArg, body) {
168
168
  };
169
169
  }
170
170
  }
171
- import { describe, it } from "node:test";
172
- import { senMLtoLwM2M } from "../../../senml/senMLtoLwM2M.js";
173
- import { TransformType } from "../../types.js";
174
- import jsonata from "jsonata";
175
- import { arrayContaining, check } from "tsmatchers";
176
- import { models } from "../../../models/models.js";
177
- void describe("asset_tracker_v2+AWS examples", function() {
171
+ import { describe, it } from 'node:test';
172
+ import { senMLtoLwM2M } from '../../../senml/senMLtoLwM2M.js';
173
+ import { TransformType } from '../../types.js';
174
+ import jsonata from 'jsonata';
175
+ import { arrayContaining, check } from 'tsmatchers';
176
+ import { models } from '../../../models/models.js';
177
+ void describe('asset_tracker_v2+AWS examples', function() {
178
178
  var _loop = function(_i, _iter) {
179
179
  var _iter__i = _sliced_to_array(_iter[_i], 2), input = _iter__i[0], expected = _iter__i[1];
180
180
  void it(input, /*#__PURE__*/ _async_to_generator(function() {
@@ -182,7 +182,7 @@ void describe("asset_tracker_v2+AWS examples", function() {
182
182
  return _ts_generator(this, function(_state) {
183
183
  switch(_state.label){
184
184
  case 0:
185
- _ = transformShadowUpdateToLwM2M(((_models_asset_tracker_v2AWS_transforms = (_models_asset_tracker_v2AWS = models["asset_tracker_v2+AWS"]) === null || _models_asset_tracker_v2AWS === void 0 ? void 0 : _models_asset_tracker_v2AWS.transforms) !== null && _models_asset_tracker_v2AWS_transforms !== void 0 ? _models_asset_tracker_v2AWS_transforms : []).filter(function(param) {
185
+ _ = transformShadowUpdateToLwM2M(((_models_asset_tracker_v2AWS_transforms = (_models_asset_tracker_v2AWS = models['asset_tracker_v2+AWS']) === null || _models_asset_tracker_v2AWS === void 0 ? void 0 : _models_asset_tracker_v2AWS.transforms) !== null && _models_asset_tracker_v2AWS_transforms !== void 0 ? _models_asset_tracker_v2AWS_transforms : []).filter(function(param) {
186
186
  var type = param.type;
187
187
  return type === TransformType.Shadow;
188
188
  }));
@@ -190,7 +190,7 @@ void describe("asset_tracker_v2+AWS examples", function() {
190
190
  4,
191
191
  import(input, {
192
192
  assert: {
193
- type: "json"
193
+ type: 'json'
194
194
  }
195
195
  })
196
196
  ];
@@ -232,7 +232,7 @@ void describe("asset_tracker_v2+AWS examples", function() {
232
232
  };
233
233
  for(var _i = 0, _iter = [
234
234
  [
235
- "./shadow/example-1.json",
235
+ './shadow/example-1.json',
236
236
  [
237
237
  {
238
238
  ObjectID: 14202,
@@ -260,7 +260,7 @@ void describe("asset_tracker_v2+AWS examples", function() {
260
260
  ]
261
261
  ],
262
262
  [
263
- "./shadow/example-2.json",
263
+ './shadow/example-2.json',
264
264
  [
265
265
  {
266
266
  ObjectID: 14201,
@@ -271,7 +271,7 @@ void describe("asset_tracker_v2+AWS examples", function() {
271
271
  3: 11.317643165588379,
272
272
  4: 0.03478508070111275,
273
273
  5: 90.31222534179688,
274
- 6: "GNSS",
274
+ 6: 'GNSS',
275
275
  99: new Date(1699049744000)
276
276
  }
277
277
  },
@@ -295,7 +295,7 @@ void describe("asset_tracker_v2+AWS examples", function() {
295
295
  ]
296
296
  ],
297
297
  [
298
- "./shadow/example-3.json",
298
+ './shadow/example-3.json',
299
299
  [
300
300
  {
301
301
  ObjectID: 14203,
@@ -308,16 +308,16 @@ void describe("asset_tracker_v2+AWS examples", function() {
308
308
  ]
309
309
  ],
310
310
  [
311
- "./shadow/example-4.json",
311
+ './shadow/example-4.json',
312
312
  [
313
313
  {
314
314
  ObjectID: 14204,
315
315
  Resources: {
316
- 0: "358299840016535",
317
- 1: "89450421180216254864",
318
- 2: "mfw_nrf91x1_2.0.0-77.beta",
319
- 3: "0.0.0-development",
320
- 4: "thingy91x_nrf9161",
316
+ 0: '358299840016535',
317
+ 1: '89450421180216254864',
318
+ 2: 'mfw_nrf91x1_2.0.0-77.beta',
319
+ 3: '0.0.0-development',
320
+ 4: 'thingy91x_nrf9161',
321
321
  99: new Date(1699284007851)
322
322
  }
323
323
  },
@@ -334,7 +334,7 @@ void describe("asset_tracker_v2+AWS examples", function() {
334
334
  ]
335
335
  ],
336
336
  [
337
- "./shadow/example-5.json",
337
+ './shadow/example-5.json',
338
338
  [
339
339
  {
340
340
  ObjectID: 14202,
@@ -416,7 +416,7 @@ void describe("asset_tracker_v2+AWS examples", function() {
416
416
  ];
417
417
  case 2:
418
418
  matched = _state.sent();
419
- if (typeof matched !== "boolean") return [
419
+ if (typeof matched !== 'boolean') return [
420
420
  2,
421
421
  null
422
422
  ];
@@ -1,94 +1,94 @@
1
- import chalk from "chalk";
2
- import jsonata from "jsonata";
3
- import assert from "node:assert/strict";
4
- import { readFile, readdir, stat } from "node:fs/promises";
5
- import path from "node:path";
6
- import { FrontMatter, ModelIDRegExp } from "./types.js";
7
- import { senMLtoLwM2M } from "../senml/senMLtoLwM2M.js";
8
- import { getCodeBlock } from "../markdown/getCodeBlock.js";
9
- import { getFrontMatter } from "../markdown/getFrontMatter.js";
10
- import { validateSenML } from "../senml/validateSenML.js";
11
- import { isRegisteredLwM2MObject } from "../lwm2m/isRegisteredLwM2MObject.js";
12
- import { hasValue } from "../senml/hasValue.js";
13
- import { parseREADME } from "markdown/parseREADME.js";
14
- console.log(chalk.gray("Models rules check"));
15
- console.log("");
16
- var modelsDir = path.join(process.cwd(), "models");
1
+ import chalk from 'chalk';
2
+ import jsonata from 'jsonata';
3
+ import assert from 'node:assert/strict';
4
+ import { readFile, readdir, stat } from 'node:fs/promises';
5
+ import path from 'node:path';
6
+ import { FrontMatter, ModelIDRegExp } from './types.js';
7
+ import { senMLtoLwM2M } from '../senml/senMLtoLwM2M.js';
8
+ import { getCodeBlock } from '../markdown/getCodeBlock.js';
9
+ import { getFrontMatter } from '../markdown/getFrontMatter.js';
10
+ import { validateSenML } from '../senml/validateSenML.js';
11
+ import { isRegisteredLwM2MObject } from '../lwm2m/isRegisteredLwM2MObject.js';
12
+ import { hasValue } from '../senml/hasValue.js';
13
+ import { parseREADME } from 'markdown/parseREADME.js';
14
+ console.log(chalk.gray('Models rules check'));
15
+ console.log('');
16
+ var modelsDir = path.join(process.cwd(), 'models');
17
17
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
18
18
  try {
19
19
  for(var _iterator = (await readdir(modelsDir))[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
20
20
  var model = _step.value;
21
21
  var modelDir = path.join(modelsDir, model);
22
22
  if (!(await stat(modelDir)).isDirectory()) continue;
23
- console.log(chalk.white("\xb7"), chalk.white.bold(model));
24
- assert.match(model, ModelIDRegExp, "Model identifiers must consist of numbers, letters, dash, plus, and underscore only");
25
- console.log(chalk.green(""), chalk.gray("Model name is correct"));
23
+ console.log(chalk.white('·'), chalk.white.bold(model));
24
+ assert.match(model, ModelIDRegExp, 'Model identifiers must consist of numbers, letters, dash, plus, and underscore only');
25
+ console.log(chalk.green(''), chalk.gray('Model name is correct'));
26
26
  // A README.md should exist
27
27
  try {
28
- await stat(path.join(modelDir, "README.md"));
28
+ await stat(path.join(modelDir, 'README.md'));
29
29
  } catch (e) {
30
30
  throw new Error("No README.md defined for model ".concat(model, "!"));
31
31
  }
32
- console.log(chalk.green(""), chalk.gray("README.md exists"));
32
+ console.log(chalk.green(''), chalk.gray("README.md exists"));
33
33
  try {
34
- parseREADME(await readFile(path.join(modelDir, "README.md"), "utf-8"));
34
+ parseREADME(await readFile(path.join(modelDir, 'README.md'), 'utf-8'));
35
35
  } catch (err) {
36
36
  console.error(err);
37
37
  throw new Error("README is not valid for ".concat(model, "!"));
38
38
  }
39
- console.log(chalk.green(""), chalk.gray("README.md is valid"));
39
+ console.log(chalk.green(''), chalk.gray("README.md is valid"));
40
40
  // Validate jsonata expressions
41
41
  var hasTransforms = false;
42
- var transformsFolder = path.join(modelDir, "transforms");
42
+ var transformsFolder = path.join(modelDir, 'transforms');
43
43
  try {
44
44
  await stat(transformsFolder);
45
45
  hasTransforms = true;
46
- console.log(" ", chalk.gray("Transforms:"));
46
+ console.log(' ', chalk.gray('Transforms:'));
47
47
  } catch (e) {
48
- console.log(" ", chalk.gray("No transforms found."));
48
+ console.log(' ', chalk.gray('No transforms found.'));
49
49
  }
50
50
  if (hasTransforms) {
51
51
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
52
52
  try {
53
53
  for(var _iterator1 = (await readdir(transformsFolder)).filter(function(f) {
54
- return f.endsWith(".md");
54
+ return f.endsWith('.md');
55
55
  })[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
56
56
  var transform = _step1.value;
57
- console.log(" ", chalk.white("\xb7"), chalk.white.bold(transform));
58
- var markdown = await readFile(path.join(modelDir, "transforms", transform), "utf-8");
57
+ console.log(' ', chalk.white('·'), chalk.white.bold(transform));
58
+ var markdown = await readFile(path.join(modelDir, 'transforms', transform), 'utf-8');
59
59
  // Validate front-matter
60
60
  var type = getFrontMatter(markdown, FrontMatter).type;
61
- console.log(" ", chalk.green(""), chalk.gray("Type ".concat(type, " is valid")));
61
+ console.log(' ', chalk.green(''), chalk.gray("Type ".concat(type, " is valid")));
62
62
  var findBlock = getCodeBlock(markdown);
63
- var matchExpression = findBlock("jsonata", "Match Expression");
64
- var transformExpression = findBlock("jsonata", "Transform Expression");
65
- var inputExample = JSON.parse(findBlock("json", "Input Example"));
66
- var resultExample = JSON.parse(findBlock("json", "Result Example"));
63
+ var matchExpression = findBlock('jsonata', 'Match Expression');
64
+ var transformExpression = findBlock('jsonata', 'Transform Expression');
65
+ var inputExample = JSON.parse(findBlock('json', 'Input Example'));
66
+ var resultExample = JSON.parse(findBlock('json', 'Result Example'));
67
67
  var selectResult = await jsonata(matchExpression).evaluate(inputExample);
68
68
  if (selectResult !== true) {
69
69
  throw new Error("The select expression did not evaluate to true with the given example.");
70
70
  }
71
- console.log(" ", chalk.green(""), chalk.gray("Select expression evaluated to true for the example input"));
71
+ console.log(' ', chalk.green(''), chalk.gray('Select expression evaluated to true for the example input'));
72
72
  var transformResult = await jsonata(// For testing purposes this function call result is hardcoded
73
- transformExpression.replace("$millis()", "1699999999999")).evaluate(inputExample);
73
+ transformExpression.replace('$millis()', '1699999999999')).evaluate(inputExample);
74
74
  var maybeValidSenML = validateSenML(transformResult.filter(hasValue));
75
- if ("errors" in maybeValidSenML) {
75
+ if ('errors' in maybeValidSenML) {
76
76
  console.error(maybeValidSenML.errors);
77
- throw new Error("The JSONata expression must produce valid SenML");
77
+ throw new Error('The JSONata expression must produce valid SenML');
78
78
  }
79
79
  assert.deepEqual(maybeValidSenML.value, resultExample);
80
- console.log(" ", chalk.green(""), chalk.gray("Transformation result is valid SenML"));
80
+ console.log(' ', chalk.green(''), chalk.gray('Transformation result is valid SenML'));
81
81
  assert.deepEqual(maybeValidSenML.value, resultExample);
82
- console.log(" ", chalk.green(""), chalk.gray("The transformation result matches the example"));
82
+ console.log(' ', chalk.green(''), chalk.gray('The transformation result matches the example'));
83
83
  var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
84
84
  try {
85
85
  // Validate
86
86
  for(var _iterator2 = senMLtoLwM2M(maybeValidSenML.value)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
87
87
  var object = _step2.value;
88
88
  if (!isRegisteredLwM2MObject(object, console.error)) {
89
- throw new Error("The LwM2M object must follow LwM2M schema definition");
89
+ throw new Error('The LwM2M object must follow LwM2M schema definition');
90
90
  }
91
- console.log(" ", chalk.green(""), chalk.gray("SenML object is valid LwM2M"));
91
+ console.log(' ', chalk.green(''), chalk.gray('SenML object is valid LwM2M'));
92
92
  }
93
93
  } catch (err) {
94
94
  _didIteratorError2 = true;
@@ -27,62 +27,62 @@ var _obj;
27
27
  {
28
28
  "type": TransformType.Messages,
29
29
  "match": "appId = 'AIR_QUAL'",
30
- "transform": '[\n {"bn": "14205/0/", "n": "10", "v": $number(data), "bt": ts }\n]'
30
+ "transform": "[\n {\"bn\": \"14205/0/\", \"n\": \"10\", \"v\": $number(data), \"bt\": ts }\n]"
31
31
  },
32
32
  {
33
33
  "type": TransformType.Messages,
34
34
  "match": "appId = 'BATTERY'",
35
- "transform": '[\n {"bn": "14202/0/", "n": "0", "v": $number(data), "bt": ts }\n]'
35
+ "transform": "[\n {\"bn\": \"14202/0/\", \"n\": \"0\", \"v\": $number(data), \"bt\": ts }\n]"
36
36
  },
37
37
  {
38
38
  "type": TransformType.Messages,
39
39
  "match": "appId = 'BUTTON'",
40
- "transform": '[\n {"bn": "14220/0/", "n": "0", "v": $number(data), "bt": ts }\n]'
40
+ "transform": "[\n {\"bn\": \"14220/0/\", \"n\": \"0\", \"v\": $number(data), \"bt\": ts }\n]"
41
41
  },
42
42
  {
43
43
  "type": TransformType.Messages,
44
44
  "match": "appId = 'DEVICE' and $exists(data.deviceInfo)",
45
- "transform": '[\n {"bn": "14204/0/", "n": "0", "vs": data.deviceInfo.imei, "bt": ts },\n {"n": "1", "vs": data.deviceInfo.iccid },\n {"n": "2", "vs": data.deviceInfo.modemFirmware },\n {"n": "3", "vs": data.deviceInfo.appVersion },\n {"n": "4", "vs": data.deviceInfo.board },\n {"n": "5", "vs": data.deviceInfo.bat }\n]'
45
+ "transform": "[\n {\"bn\": \"14204/0/\", \"n\": \"0\", \"vs\": data.deviceInfo.imei, \"bt\": ts },\n {\"n\": \"1\", \"vs\": data.deviceInfo.iccid },\n {\"n\": \"2\", \"vs\": data.deviceInfo.modemFirmware },\n {\"n\": \"3\", \"vs\": data.deviceInfo.appVersion },\n {\"n\": \"4\", \"vs\": data.deviceInfo.board },\n {\"n\": \"5\", \"vs\": data.deviceInfo.bat }\n]"
46
46
  },
47
47
  {
48
48
  "type": TransformType.Messages,
49
49
  "match": "appId = 'SOLAR'",
50
- "transform": '[\n {"bn": "14210/0/", "n": "0", "v": $number(data), "bt": ts }\n]'
50
+ "transform": "[\n {\"bn\": \"14210/0/\", \"n\": \"0\", \"v\": $number(data), \"bt\": ts }\n]"
51
51
  },
52
52
  {
53
53
  "type": TransformType.Messages,
54
54
  "match": "appId = 'GROUND_FIX' and $exists(data.lat) and $exists(data.lon) and $exists(data.uncertainty) and $exists(data.fulfilledWith)",
55
- "transform": '[\n {"bn": "14201/1/", "n": "0", "v": data.lat, "bt": $millis() },\n {"n": "1", "v": data.lon },\n {"n": "3", "v": data.uncertainty },\n {"n": "6", "vs": data.fulfilledWith }\n]'
55
+ "transform": "[\n {\"bn\": \"14201/1/\", \"n\": \"0\", \"v\": data.lat, \"bt\": $millis() },\n {\"n\": \"1\", \"v\": data.lon },\n {\"n\": \"3\", \"v\": data.uncertainty },\n {\"n\": \"6\", \"vs\": data.fulfilledWith }\n]"
56
56
  },
57
57
  {
58
58
  "type": TransformType.Messages,
59
59
  "match": "appId = 'GNSS'",
60
- "transform": '[\n {"bn": "14201/0/", "n": "0", "v": data.lat, "bt": ts },\n {"n": "1", "v": data.lng },\n {"n": "2", "v": data.alt },\n {"n": "3", "v": data.acc },\n {"n": "4", "v": data.spd },\n {"n": "5", "v": data.hdg },\n {"n": "6", "vs": "GNSS" }\n]'
60
+ "transform": "[\n {\"bn\": \"14201/0/\", \"n\": \"0\", \"v\": data.lat, \"bt\": ts },\n {\"n\": \"1\", \"v\": data.lng },\n {\"n\": \"2\", \"v\": data.alt },\n {\"n\": \"3\", \"v\": data.acc },\n {\"n\": \"4\", \"v\": data.spd },\n {\"n\": \"5\", \"v\": data.hdg },\n {\"n\": \"6\", \"vs\": \"GNSS\" }\n]"
61
61
  },
62
62
  {
63
63
  "type": TransformType.Messages,
64
64
  "match": "appId = 'HUMID'",
65
- "transform": '[\n {"bn": "14205/0/", "n": "1", "v": $number(data), "bt": ts }\n]'
65
+ "transform": "[\n {\"bn\": \"14205/0/\", \"n\": \"1\", \"v\": $number(data), \"bt\": ts }\n]"
66
66
  },
67
67
  {
68
68
  "type": TransformType.Messages,
69
69
  "match": "appId = 'DEVICE' and $exists(data.networkInfo)",
70
- "transform": '[\n {"bn": "14203/0/", "n": "0", "vs": data.networkInfo.networkMode, "bt": ts },\n {"n": "1", "v": data.networkInfo.currentBand },\n {"n": "2", "v": data.networkInfo.rsrp },\n {"n": "3", "v": data.networkInfo.areaCode },\n {"n": "4", "v": data.networkInfo.cellID },\n {"n": "5", "v": data.networkInfo.mccmnc },\n {"n": "6", "vs": data.networkInfo.ipAddress },\n {"n": "11", "v": data.networkInfo.eest }\n]'
70
+ "transform": "[\n {\"bn\": \"14203/0/\", \"n\": \"0\", \"vs\": data.networkInfo.networkMode, \"bt\": ts },\n {\"n\": \"1\", \"v\": data.networkInfo.currentBand },\n {\"n\": \"2\", \"v\": data.networkInfo.rsrp },\n {\"n\": \"3\", \"v\": data.networkInfo.areaCode },\n {\"n\": \"4\", \"v\": data.networkInfo.cellID },\n {\"n\": \"5\", \"v\": data.networkInfo.mccmnc },\n {\"n\": \"6\", \"vs\": data.networkInfo.ipAddress },\n {\"n\": \"11\", \"v\": data.networkInfo.eest }\n]"
71
71
  },
72
72
  {
73
73
  "type": TransformType.Messages,
74
74
  "match": "appId = 'AIR_PRESS'",
75
- "transform": '[\n {"bn": "14205/0/", "n": "2", "v": $number(data)*10, "bt": ts }\n]'
75
+ "transform": "[\n {\"bn\": \"14205/0/\", \"n\": \"2\", \"v\": $number(data)*10, \"bt\": ts }\n]"
76
76
  },
77
77
  {
78
78
  "type": TransformType.Messages,
79
79
  "match": "appId = 'TEMP'",
80
- "transform": '[\n {"bn": "14205/0/", "n": "0", "v": $number(data), "bt": ts }\n]'
80
+ "transform": "[\n {\"bn\": \"14205/0/\", \"n\": \"0\", \"v\": $number(data), \"bt\": ts }\n]"
81
81
  }
82
82
  ],
83
83
  "about": {
84
84
  "title": "Thingy:91 with Solar Shield",
85
- "description": "The Nordic Thingy:91 Solar Shield is a plug-and-play prototyping platform. Powerfoyle solar cell is mounted onto the Thingy to quickly get started exploring the endless possibilities with solar powered IoT applications and to develop products with eternal life or even battery-free products.​\nThe Thingy:91 runs the asset_tracker_v2 application and sends messages to nRF Cloud using MQTT."
85
+ "description": "The Nordic Thingy:91 Solar Shield is a plug-and-play prototyping platform. Powerfoyle solar cell is mounted onto the Thingy to quickly get started exploring the endless possibilities with solar powered IoT applications and to develop products with eternal life or even battery-free products.\u200B\nThe Thingy:91 runs the asset_tracker_v2 application and sends messages to nRF Cloud using MQTT."
86
86
  }
87
87
  }), _define_property(_obj, "asset_tracker_v2+AWS", {
88
88
  "id": "asset_tracker_v2+AWS",
@@ -90,37 +90,37 @@ var _obj;
90
90
  {
91
91
  "type": TransformType.Shadow,
92
92
  "match": "$exists(state.reported.gnss)",
93
- "transform": '[\n {"bn": "14201/0/", "n": "0", "v": state.reported.gnss.v.lat, "bt": state.reported.gnss.ts },\n {"n": "1", "v": state.reported.gnss.v.lng },\n {"n": "2", "v": state.reported.gnss.v.alt },\n {"n": "3", "v": state.reported.gnss.v.acc },\n {"n": "4", "v": state.reported.gnss.v.spd },\n {"n": "5", "v": state.reported.gnss.v.hdg },\n {"n": "6", "vs": "GNSS" }\n]'
93
+ "transform": "[\n {\"bn\": \"14201/0/\", \"n\": \"0\", \"v\": state.reported.gnss.v.lat, \"bt\": state.reported.gnss.ts },\n {\"n\": \"1\", \"v\": state.reported.gnss.v.lng },\n {\"n\": \"2\", \"v\": state.reported.gnss.v.alt },\n {\"n\": \"3\", \"v\": state.reported.gnss.v.acc },\n {\"n\": \"4\", \"v\": state.reported.gnss.v.spd },\n {\"n\": \"5\", \"v\": state.reported.gnss.v.hdg },\n {\"n\": \"6\", \"vs\": \"GNSS\" }\n]"
94
94
  },
95
95
  {
96
96
  "type": TransformType.Shadow,
97
97
  "match": "$exists(state.reported.bat)",
98
- "transform": '[\n {"bn": "14202/0/", "n": "1", "v": state.reported.bat.v/1000, "bt": state.reported.bat.ts }\n]'
98
+ "transform": "[\n {\"bn\": \"14202/0/\", \"n\": \"1\", \"v\": state.reported.bat.v/1000, \"bt\": state.reported.bat.ts }\n]"
99
99
  },
100
100
  {
101
101
  "type": TransformType.Shadow,
102
102
  "match": "$exists(state.reported.dev)",
103
- "transform": '[\n {"bn": "14204/0/", "n": "0", "vs": state.reported.dev.v.imei, "bt": state.reported.dev.ts },\n {"n": "1", "vs": state.reported.dev.v.iccid },\n {"n": "2", "vs": state.reported.dev.v.modV },\n {"n": "3", "vs": state.reported.dev.v.appV },\n {"n": "4", "vs": state.reported.dev.v.brdV }\n]'
103
+ "transform": "[\n {\"bn\": \"14204/0/\", \"n\": \"0\", \"vs\": state.reported.dev.v.imei, \"bt\": state.reported.dev.ts },\n {\"n\": \"1\", \"vs\": state.reported.dev.v.iccid },\n {\"n\": \"2\", \"vs\": state.reported.dev.v.modV },\n {\"n\": \"3\", \"vs\": state.reported.dev.v.appV },\n {\"n\": \"4\", \"vs\": state.reported.dev.v.brdV }\n]"
104
104
  },
105
105
  {
106
106
  "type": TransformType.Shadow,
107
107
  "match": "$exists(state.reported.env)",
108
- "transform": '[\n {"bn": "14205/0/", "n": "0", "v": state.reported.env.v.temp, "bt": state.reported.env.ts },\n {"n": "1", "v": state.reported.env.v.hum },\n {"n": "2", "v": state.reported.env.v.atmp },\n {"n": "10", "v": state.reported.env.v.bsec_iaq }\n]'
108
+ "transform": "[\n {\"bn\": \"14205/0/\", \"n\": \"0\", \"v\": state.reported.env.v.temp, \"bt\": state.reported.env.ts },\n {\"n\": \"1\", \"v\": state.reported.env.v.hum },\n {\"n\": \"2\", \"v\": state.reported.env.v.atmp },\n {\"n\": \"10\", \"v\": state.reported.env.v.bsec_iaq }\n]"
109
109
  },
110
110
  {
111
111
  "type": TransformType.Shadow,
112
112
  "match": "$exists(state.reported.fg)",
113
- "transform": '[\n {"bn": "14202/0/", "n": "0", "v": state.reported.fg.v.SoC, "bt": state.reported.fg.ts },\n {"n": "1", "v": state.reported.fg.v.V/1000 },\n {"n": "2", "v": state.reported.fg.v.I },\n {"n": "3", "v": state.reported.fg.v.T = null ? null : state.reported.fg.v.T/10 },\n {"n": "4", "v": state.reported.fg.v.TTF },\n {"n": "5", "v": state.reported.fg.v.TTE }\n]'
113
+ "transform": "[\n {\"bn\": \"14202/0/\", \"n\": \"0\", \"v\": state.reported.fg.v.SoC, \"bt\": state.reported.fg.ts },\n {\"n\": \"1\", \"v\": state.reported.fg.v.V/1000 },\n {\"n\": \"2\", \"v\": state.reported.fg.v.I },\n {\"n\": \"3\", \"v\": state.reported.fg.v.T = null ? null : state.reported.fg.v.T/10 },\n {\"n\": \"4\", \"v\": state.reported.fg.v.TTF },\n {\"n\": \"5\", \"v\": state.reported.fg.v.TTE }\n]"
114
114
  },
115
115
  {
116
116
  "type": TransformType.Shadow,
117
117
  "match": "$exists(state.reported.roam)",
118
- "transform": '[\n {"bn": "14203/0/", "n": "0", "vs": state.reported.roam.v.nw, "bt": state.reported.roam.ts },\n {"n": "1", "v": state.reported.roam.v.band },\n {"bn": "14203/0/", "n": "2", "v": state.reported.roam.v.rsrp, "bt": state.reported.roam.ts },\n {"n": "3", "v": state.reported.roam.v.area },\n {"n": "4", "v": state.reported.roam.v.cell },\n {"n": "5", "v": state.reported.roam.v.mccmnc },\n {"n": "6", "vs": state.reported.roam.v.ip },\n {"bn": "14203/0/", "n": "11", "v": state.reported.roam.v.eest, "bt": state.reported.roam.ts }\n]'
118
+ "transform": "[\n {\"bn\": \"14203/0/\", \"n\": \"0\", \"vs\": state.reported.roam.v.nw, \"bt\": state.reported.roam.ts },\n {\"n\": \"1\", \"v\": state.reported.roam.v.band },\n {\"bn\": \"14203/0/\", \"n\": \"2\", \"v\": state.reported.roam.v.rsrp, \"bt\": state.reported.roam.ts },\n {\"n\": \"3\", \"v\": state.reported.roam.v.area },\n {\"n\": \"4\", \"v\": state.reported.roam.v.cell },\n {\"n\": \"5\", \"v\": state.reported.roam.v.mccmnc },\n {\"n\": \"6\", \"vs\": state.reported.roam.v.ip },\n {\"bn\": \"14203/0/\", \"n\": \"11\", \"v\": state.reported.roam.v.eest, \"bt\": state.reported.roam.ts }\n]"
119
119
  },
120
120
  {
121
121
  "type": TransformType.Shadow,
122
122
  "match": "$exists(state.reported.sol)",
123
- "transform": '[\n {"bn": "14210/0/", "n": "0", "v": state.reported.sol.v.gain, "bt": state.reported.sol.ts },\n {"n": "1", "v": state.reported.sol.v.bat }\n]'
123
+ "transform": "[\n {\"bn\": \"14210/0/\", \"n\": \"0\", \"v\": state.reported.sol.v.gain, \"bt\": state.reported.sol.ts },\n {\"n\": \"1\", \"v\": state.reported.sol.v.bat }\n]"
124
124
  }
125
125
  ],
126
126
  "about": {
@@ -132,6 +132,6 @@ var _obj;
132
132
  "transforms": [],
133
133
  "about": {
134
134
  "title": "Kartverket Vasstandsdata",
135
- "description": "A simulated device reporting the current sea level as provided by the Kartverket's (Norwegian Mapping Authority) API for vasstandsdata (API for water level data).\nReports sea water level using the Object 14230.\nThe data is licensed by the Norwegian Mapping Authority’s under the Creative Commons Attribution 4.0 International (CC BY 4.0) license."
135
+ "description": "A simulated device reporting the current sea level as provided by the Kartverket's (Norwegian Mapping Authority) API for vasstandsdata (API for water level data).\nReports sea water level using the Object 14230.\nThe data is licensed by the Norwegian Mapping Authority\u2019s under the Creative Commons Attribution 4.0 International (CC BY 4.0) license."
136
136
  }
137
137
  }), _obj);
@@ -1,4 +1,4 @@
1
- import { Type } from "@sinclair/typebox";
1
+ import { Type } from '@sinclair/typebox';
2
2
  export var ModelIDRegExp = /^[A-Za-z0-9+_-]+$/;
3
3
  export var TransformType;
4
4
  (function(TransformType) {
@@ -7,7 +7,7 @@ export var TransformType;
7
7
  })(TransformType || (TransformType = {}));
8
8
  export var FrontMatter = Type.Object({
9
9
  type: Type.Union([
10
- Type.Literal("shadow"),
11
- Type.Literal("messages")
10
+ Type.Literal('shadow'),
11
+ Type.Literal('messages')
12
12
  ])
13
13
  });
@@ -1,22 +1,22 @@
1
- import { Type } from "@sinclair/typebox";
1
+ import { Type } from '@sinclair/typebox';
2
2
  var ResourceIDPart = Type.RegExp(/^[0-9/]+$/, {
3
- title: "ResourceIDPart",
4
- description: "Combines `bn` and `n` to a fully qualified resource identifier in the form of `/<object ID>/<object instance ID>/<resource ID>/0`. (Multiple resource instances are not supported right now.).",
3
+ title: 'ResourceIDPart',
4
+ description: 'Combines `bn` and `n` to a fully qualified resource identifier in the form of `/<object ID>/<object instance ID>/<resource ID>/0`. (Multiple resource instances are not supported right now.).',
5
5
  examples: [
6
- "/",
7
- "/14201/0/",
8
- "5"
6
+ '/',
7
+ '/14201/0/',
8
+ '5'
9
9
  ]
10
10
  });
11
11
  var BaseValue = Type.Number({
12
- title: "Base Value"
12
+ title: 'Base Value'
13
13
  });
14
14
  var Value = Type.Number({
15
- title: "Value"
15
+ title: 'Value'
16
16
  });
17
17
  var Time = Type.Integer({
18
18
  minimum: 0,
19
- title: "Time"
19
+ title: 'Time'
20
20
  });
21
21
  /**
22
22
  * Defines a SenML type with some unsupported elements removed: Sum, Base Sum, Update Time
@@ -32,8 +32,8 @@ var Time = Type.Integer({
32
32
  n: ResourceIDPart,
33
33
  blv: Type.String({
34
34
  minLength: 1,
35
- description: "The LwM2M object version used",
36
- default: "1.0"
35
+ description: 'The LwM2M object version used',
36
+ default: '1.0'
37
37
  }),
38
38
  bt: Type.Optional(Time)
39
39
  })
@@ -56,23 +56,23 @@ var Time = Type.Integer({
56
56
  Type.Object({
57
57
  vs: Type.String({
58
58
  minLength: 1,
59
- title: "String Value"
59
+ title: 'String Value'
60
60
  })
61
61
  }),
62
62
  Type.Object({
63
63
  vb: Type.Boolean({
64
- title: "Boolean Value"
64
+ title: 'Boolean Value'
65
65
  })
66
66
  }),
67
67
  Type.Object({
68
68
  vd: Type.String({
69
- title: "Data Value.",
70
- description: "Octets in the Data Value are base64 encoded with the URL-safe alphabet as defined in Section 5 of [RFC4648], with padding omitted."
69
+ title: 'Data Value.',
70
+ description: 'Octets in the Data Value are base64 encoded with the URL-safe alphabet as defined in Section 5 of [RFC4648], with padding omitted.'
71
71
  })
72
72
  })
73
73
  ])
74
74
  ], {
75
- description: "SenML schema for conversion results. This is limited to properties useful for the hello.nrfcloud.com/map application."
75
+ description: 'SenML schema for conversion results. This is limited to properties useful for the hello.nrfcloud.com/map application.'
76
76
  });
77
77
  export var SenML = Type.Array(Measurement, {
78
78
  minItems: 1
@@ -1,23 +1,23 @@
1
- import { describe, it } from "node:test";
2
- import { SenML } from "./SenMLSchema.js";
3
- import assert from "node:assert/strict";
4
- import { validate } from "../validate.js";
5
- void describe("SenMLType", function() {
6
- void it("it should validate a SenML payload", function() {
1
+ import { describe, it } from 'node:test';
2
+ import { SenML } from './SenMLSchema.js';
3
+ import assert from 'node:assert/strict';
4
+ import { validate } from '../validate.js';
5
+ void describe('SenMLType', function() {
6
+ void it('it should validate a SenML payload', function() {
7
7
  var example = [
8
8
  {
9
- bn: "14201/0/",
10
- n: "0",
9
+ bn: '14201/0/',
10
+ n: '0',
11
11
  v: 33.98755678796222,
12
12
  bt: 1698155694999
13
13
  },
14
14
  {
15
- n: "1",
15
+ n: '1',
16
16
  v: -84.506132079174634
17
17
  }
18
18
  ];
19
19
  var res = validate(SenML)(example);
20
- assert.equal("errors" in res, false);
21
- assert.deepEqual("value" in res && res.value, example);
20
+ assert.equal('errors' in res, false);
21
+ assert.deepEqual('value' in res && res.value, example);
22
22
  });
23
23
  });