@hello.nrfcloud.com/proto-map 16.1.40 → 16.2.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.
Files changed (84) hide show
  1. package/api/DeviceJWT.ts +1 -1
  2. package/api/Devices.ts +1 -1
  3. package/api/Email.spec.ts +3 -3
  4. package/api/IsoDateType.spec.ts +2 -2
  5. package/api/UserDevices.ts +1 -1
  6. package/api/index.ts +5 -5
  7. package/dist/api/DeviceJWT.js +1 -1
  8. package/dist/api/Devices.js +1 -1
  9. package/dist/api/Email.spec.js +3 -3
  10. package/dist/api/IsoDateType.spec.js +2 -2
  11. package/dist/api/UserDevices.js +1 -1
  12. package/dist/api/index.js +5 -5
  13. package/dist/generator/generateLwM2MDefinitions.js +1 -1
  14. package/dist/generator/generateLwM2MDefinitions.spec.js +1 -1
  15. package/dist/generator/generateModels.js +1 -1
  16. package/dist/generator/generateType.js +2 -2
  17. package/dist/generator/generateValidator.js +1 -1
  18. package/dist/generator/generateValidators.js +1 -1
  19. package/dist/generator/lwm2m.js +4 -4
  20. package/dist/generator/tokenizeName.spec.js +2 -2
  21. package/dist/generator/types.js +4 -5
  22. package/dist/lwm2m/InvalidTimeError.js +119 -0
  23. package/dist/lwm2m/aws/NoHistoryMeasuresError.js +119 -0
  24. package/dist/lwm2m/aws/instanceMeasuresToRecord.js +48 -0
  25. package/dist/lwm2m/aws/instanceMeasuresToRecord.spec.js +39 -0
  26. package/dist/lwm2m/aws/instanceToMeasure.spec.js +50 -0
  27. package/dist/lwm2m/aws/instanceToMeasures.js +112 -0
  28. package/dist/lwm2m/aws/objectsToShadow.spec.js +3 -3
  29. package/dist/lwm2m/aws/shadowToObjects.spec.js +3 -3
  30. package/dist/lwm2m/check-lwm2m-rules.js +4 -4
  31. package/dist/lwm2m/correctOffset.js +12 -0
  32. package/dist/lwm2m/correctOffset.spec.js +11 -0
  33. package/dist/lwm2m/fromXML2JSON.js +1 -1
  34. package/dist/lwm2m/index.js +11 -7
  35. package/dist/lwm2m/instanceTs.spec.js +1 -1
  36. package/dist/lwm2m/isNumber.js +3 -0
  37. package/dist/lwm2m/isNumeric.js +15 -0
  38. package/dist/lwm2m/isNumeric.spec.js +38 -0
  39. package/dist/lwm2m/isUnixTimeInSeconds.js +7 -0
  40. package/dist/lwm2m/isUnixTimeInSeconds.spec.js +14 -0
  41. package/dist/lwm2m/parseRangeEnumeration.spec.js +2 -2
  42. package/dist/lwm2m/unwrapNestedArray.spec.js +1 -1
  43. package/dist/lwm2m/validate.spec.js +1 -1
  44. package/dist/models/check-model-rules.js +1 -1
  45. package/dist/senml/SenMLSchema.spec.js +2 -2
  46. package/dist/senml/hasValue.spec.js +1 -1
  47. package/dist/senml/index.js +2 -2
  48. package/dist/senml/lwm2mToSenML.js +2 -2
  49. package/dist/senml/lwm2mToSenML.spec.js +2 -2
  50. package/dist/senml/validateSenML.spec.js +1 -1
  51. package/lwm2m/InvalidTimeError.ts +6 -0
  52. package/lwm2m/LwM2MObject.ts +1 -1
  53. package/lwm2m/aws/NoHistoryMeasuresError.ts +6 -0
  54. package/lwm2m/aws/instanceMeasuresToRecord.spec.ts +37 -0
  55. package/lwm2m/aws/instanceMeasuresToRecord.ts +62 -0
  56. package/lwm2m/aws/instanceToMeasure.spec.ts +53 -0
  57. package/lwm2m/aws/instanceToMeasures.ts +72 -0
  58. package/lwm2m/aws/objectsToShadow.spec.ts +3 -3
  59. package/lwm2m/aws/shadowToObjects.spec.ts +3 -3
  60. package/lwm2m/aws/shadowToObjects.ts +1 -1
  61. package/lwm2m/check-lwm2m-rules.ts +4 -4
  62. package/lwm2m/correctOffset.spec.ts +24 -0
  63. package/lwm2m/correctOffset.ts +12 -0
  64. package/lwm2m/fromXML2JSON.ts +1 -1
  65. package/lwm2m/index.ts +11 -7
  66. package/lwm2m/instanceTs.spec.ts +1 -1
  67. package/lwm2m/isNumber.ts +2 -0
  68. package/lwm2m/isNumeric.spec.ts +30 -0
  69. package/lwm2m/isNumeric.ts +17 -0
  70. package/lwm2m/isUnixTimeInSeconds.spec.ts +16 -0
  71. package/lwm2m/isUnixTimeInSeconds.ts +8 -0
  72. package/lwm2m/parseRangeEnumeration.spec.ts +2 -2
  73. package/lwm2m/unwrapNestedArray.spec.ts +1 -1
  74. package/lwm2m/validate.spec.ts +1 -1
  75. package/lwm2m/validate.ts +1 -1
  76. package/lwm2m/validation.ts +1 -1
  77. package/models/check-model-rules.ts +1 -1
  78. package/package.json +5 -4
  79. package/senml/SenMLSchema.spec.ts +2 -2
  80. package/senml/hasValue.spec.ts +1 -1
  81. package/senml/index.ts +2 -2
  82. package/senml/lwm2mToSenML.spec.ts +5 -5
  83. package/senml/lwm2mToSenML.ts +3 -3
  84. package/senml/validateSenML.spec.ts +2 -2
package/api/DeviceJWT.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Type } from '@sinclair/typebox'
2
+ import { Context } from './Context.js'
2
3
  import { DeviceId, PublicDeviceId } from './DeviceId.js'
3
4
  import { Model } from './Devices.js'
4
- import { Context } from './Context.js'
5
5
 
6
6
  export const DeviceJWTPayload = Type.Object(
7
7
  {
package/api/Devices.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Type } from '@sinclair/typebox'
2
+ import { models } from '../models/models.js'
2
3
  import { Context } from './Context.js'
3
4
  import { DeviceId, PublicDeviceId } from './DeviceId.js'
4
5
  import {
@@ -7,7 +8,6 @@ import {
7
8
  ObjectVersion,
8
9
  Resources,
9
10
  } from './LwM2M.js'
10
- import { models } from '../models/models.js'
11
11
 
12
12
  export const LwM2MObjectInstance = Type.Object({
13
13
  ObjectID,
package/api/Email.spec.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { describe, it } from 'node:test'
2
1
  import assert from 'node:assert/strict'
3
- import invalidEmails from './test/invalid-emails.json' assert { type: 'json' }
4
- import { Email } from './Email.js'
2
+ import { describe, it } from 'node:test'
5
3
  import { validate } from '../validate.js'
4
+ import { Email } from './Email.js'
5
+ import invalidEmails from './test/invalid-emails.json' assert { type: 'json' }
6
6
 
7
7
  const v = validate(Email)
8
8
 
@@ -1,7 +1,7 @@
1
- import { IsoDateType } from './IsoDateType.js'
2
- import { describe, test as it } from 'node:test'
3
1
  import assert from 'node:assert/strict'
2
+ import { describe, test as it } from 'node:test'
4
3
  import { validate } from '../validate.js'
4
+ import { IsoDateType } from './IsoDateType.js'
5
5
 
6
6
  void describe('isoDateRegExp', () => {
7
7
  void it('should match a date string', () => {
@@ -1,8 +1,8 @@
1
1
  import { Type } from '@sinclair/typebox'
2
2
  import { Context } from './Context.js'
3
3
  import { DeviceId, PublicDeviceId } from './DeviceId.js'
4
- import { IsoDateType } from './IsoDateType.js'
5
4
  import { Model } from './Devices.js'
5
+ import { IsoDateType } from './IsoDateType.js'
6
6
 
7
7
  export const UserDevices = Type.Object({
8
8
  '@context': Type.Literal(Context.userDevices.toString()),
package/api/index.ts CHANGED
@@ -1,11 +1,11 @@
1
+ export * from './APIHealth.js'
1
2
  export * from './Context.js'
3
+ export * from './DeviceCredentials.js'
2
4
  export * from './DeviceId.js'
3
- export * from './Devices.js'
4
- export * from './LwM2M.js'
5
5
  export * from './DeviceJWT.js'
6
- export * from './UserJWT.js'
7
- export * from './APIHealth.js'
8
- export * from './DeviceCredentials.js'
6
+ export * from './Devices.js'
9
7
  export * from './Email.js'
10
8
  export * from './IsoDateType.js'
9
+ export * from './LwM2M.js'
11
10
  export * from './UserDevices.js'
11
+ export * from './UserJWT.js'
@@ -1,7 +1,7 @@
1
1
  import { Type } from '@sinclair/typebox';
2
+ import { Context } from './Context.js';
2
3
  import { DeviceId, PublicDeviceId } from './DeviceId.js';
3
4
  import { Model } from './Devices.js';
4
- import { Context } from './Context.js';
5
5
  export var DeviceJWTPayload = Type.Object({
6
6
  '@context': Type.Literal(Context.deviceJWT.toString()),
7
7
  id: PublicDeviceId,
@@ -1,8 +1,8 @@
1
1
  import { Type } from '@sinclair/typebox';
2
+ import { models } from '../models/models.js';
2
3
  import { Context } from './Context.js';
3
4
  import { DeviceId, PublicDeviceId } from './DeviceId.js';
4
5
  import { ObjectID, ObjectInstanceID, ObjectVersion, Resources } from './LwM2M.js';
5
- import { models } from '../models/models.js';
6
6
  export var LwM2MObjectInstance = Type.Object({
7
7
  ObjectID: ObjectID,
8
8
  ObjectVersion: Type.Optional(ObjectVersion),
@@ -1,10 +1,10 @@
1
- import { describe, it } from 'node:test';
2
1
  import assert from 'node:assert/strict';
2
+ import { describe, it } from 'node:test';
3
+ import { validate } from '../validate.js';
4
+ import { Email } from './Email.js';
3
5
  import invalidEmails from './test/invalid-emails.json' assert {
4
6
  type: 'json'
5
7
  };
6
- import { Email } from './Email.js';
7
- import { validate } from '../validate.js';
8
8
  var v = validate(Email);
9
9
  void describe('it should validate emails', function() {
10
10
  var _loop = function(_i, _iter) {
@@ -1,7 +1,7 @@
1
- import { IsoDateType } from './IsoDateType.js';
2
- import { describe, test as it } from 'node:test';
3
1
  import assert from 'node:assert/strict';
2
+ import { describe, test as it } from 'node:test';
4
3
  import { validate } from '../validate.js';
4
+ import { IsoDateType } from './IsoDateType.js';
5
5
  void describe('isoDateRegExp', function() {
6
6
  void it('should match a date string', function() {
7
7
  var isoTs = new Date().toISOString();
@@ -1,8 +1,8 @@
1
1
  import { Type } from '@sinclair/typebox';
2
2
  import { Context } from './Context.js';
3
3
  import { DeviceId, PublicDeviceId } from './DeviceId.js';
4
- import { IsoDateType } from './IsoDateType.js';
5
4
  import { Model } from './Devices.js';
5
+ import { IsoDateType } from './IsoDateType.js';
6
6
  export var UserDevices = Type.Object({
7
7
  '@context': Type.Literal(Context.userDevices.toString()),
8
8
  devices: Type.Array(Type.Object({
package/dist/api/index.js CHANGED
@@ -1,11 +1,11 @@
1
+ export * from './APIHealth.js';
1
2
  export * from './Context.js';
3
+ export * from './DeviceCredentials.js';
2
4
  export * from './DeviceId.js';
3
- export * from './Devices.js';
4
- export * from './LwM2M.js';
5
5
  export * from './DeviceJWT.js';
6
- export * from './UserJWT.js';
7
- export * from './APIHealth.js';
8
- export * from './DeviceCredentials.js';
6
+ export * from './Devices.js';
9
7
  export * from './Email.js';
10
8
  export * from './IsoDateType.js';
9
+ export * from './LwM2M.js';
11
10
  export * from './UserDevices.js';
11
+ export * from './UserJWT.js';
@@ -1,7 +1,7 @@
1
1
  import ts from 'typescript';
2
+ import { parseRangeEnumeration } from '../lwm2m/parseRangeEnumeration.js';
2
3
  import { addDocBlock } from './addDocBlock.js';
3
4
  import { generateName } from './generateType.js';
4
- import { parseRangeEnumeration } from '../lwm2m/parseRangeEnumeration.js';
5
5
  export var generateLwM2MDefinitions = function(definitions) {
6
6
  var importLWM2MObjectInfo = ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([
7
7
  ts.factory.createImportSpecifier(true, undefined, ts.factory.createIdentifier("LWM2MObjectInfo")),
@@ -1,5 +1,5 @@
1
- import { describe, it } from 'node:test';
2
1
  import assert from 'node:assert/strict';
2
+ import { describe, it } from 'node:test';
3
3
  import { definitions } from '../lwm2m/definitions.js';
4
4
  import { LwM2MObjectID } from '../lwm2m/LwM2MObjectID.js';
5
5
  import { ResourceType } from '../lwm2m/LWM2MObjectInfo.js';
@@ -1,7 +1,7 @@
1
+ import { parseREADME } from 'markdown/parseREADME.js';
1
2
  import ts from 'typescript';
2
3
  import { addDocBlock } from './addDocBlock.js';
3
4
  import { tokenizeName } from './tokenizeName.js';
4
- import { parseREADME } from 'markdown/parseREADME.js';
5
5
  export var generateModels = function(models) {
6
6
  var types = [];
7
7
  types.push(addDocBlock([
@@ -1,8 +1,8 @@
1
+ import { parseRangeEnumeration } from 'lwm2m/parseRangeEnumeration.js';
1
2
  import ts from 'typescript';
2
- import { addDocBlock } from './addDocBlock.js';
3
3
  import { LwM2MType } from '../lwm2m/resourceType.js';
4
+ import { addDocBlock } from './addDocBlock.js';
4
5
  import { tokenizeName } from './tokenizeName.js';
5
- import { parseRangeEnumeration } from 'lwm2m/parseRangeEnumeration.js';
6
6
  export var generateType = function(param) {
7
7
  var ObjectID = param.ObjectID, ObjectVersion = param.ObjectVersion, Name = param.Name, Description1 = param.Description1, Resources = param.Resources;
8
8
  var name = generateName({
@@ -24,8 +24,8 @@ function _unsupported_iterable_to_array(o, minLen) {
24
24
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
25
25
  }
26
26
  import ts from 'typescript';
27
- import { generateName } from './generateType.js';
28
27
  import { addDocBlock } from './addDocBlock.js';
28
+ import { generateName } from './generateType.js';
29
29
  export var generateValidator = function(param) {
30
30
  var ObjectID = param.ObjectID, ObjectVersion = param.ObjectVersion, Name = param.Name, Resources = param.Resources;
31
31
  // import type { LwM2MObject } from './LwM2MObject.js'
@@ -24,8 +24,8 @@ function _unsupported_iterable_to_array(o, minLen) {
24
24
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
25
25
  }
26
26
  import ts from 'typescript';
27
- import { generateName } from './generateType.js';
28
27
  import { addDocBlock } from './addDocBlock.js';
28
+ import { generateName } from './generateType.js';
29
29
  export var generateValidators = function(objects) {
30
30
  // import { LwM2MObjectID } from './LwM2MObjectID.js'
31
31
  var importLwM2MObjectID = ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([
@@ -26,14 +26,14 @@ function _unsupported_iterable_to_array(o, minLen) {
26
26
  var _path;
27
27
  import chalk from 'chalk';
28
28
  import { readFile, readdir, writeFile } from 'node:fs/promises';
29
+ import os from 'node:os';
29
30
  import path from 'node:path';
30
- import { unwrapNestedArray } from '../lwm2m/unwrapNestedArray.js';
31
31
  import xml2js from 'xml2js';
32
- import { generateLwm2mTimestampResources } from './generateLwm2mTimestampResources.js';
33
- import { printNode } from './printNode.js';
34
- import os from 'node:os';
32
+ import { unwrapNestedArray } from '../lwm2m/unwrapNestedArray.js';
35
33
  import { generateLwM2MDefinitions } from './generateLwM2MDefinitions.js';
34
+ import { generateLwm2mTimestampResources } from './generateLwm2mTimestampResources.js';
36
35
  import { generateName } from './generateType.js';
36
+ import { printNode } from './printNode.js';
37
37
  var baseDir = process.cwd();
38
38
  var subDir = function() {
39
39
  for(var _len = arguments.length, tree = new Array(_len), _key = 0; _key < _len; _key++){
@@ -44,9 +44,9 @@ function _unsupported_iterable_to_array(o, minLen) {
44
44
  if (n === "Map" || n === "Set") return Array.from(n);
45
45
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
46
46
  }
47
- import { tokenizeName } from './tokenizeName.js';
48
- import { describe, it } from 'node:test';
49
47
  import assert from 'node:assert/strict';
48
+ import { describe, it } from 'node:test';
49
+ import { tokenizeName } from './tokenizeName.js';
50
50
  void describe('tokenizeName', function() {
51
51
  var _loop = function(_i, _iter) {
52
52
  var _iter__i = _sliced_to_array(_iter[_i], 2), name = _iter__i[0], expected = _iter__i[1];
@@ -27,16 +27,15 @@ var _path;
27
27
  import chalk from 'chalk';
28
28
  import { mkdir, readFile, readdir, writeFile } from 'node:fs/promises';
29
29
  import path from 'node:path';
30
- import { unwrapNestedArray } from '../lwm2m/unwrapNestedArray.js';
31
- import xml2js from 'xml2js';
32
30
  import ts from 'typescript';
33
- import { printNode } from './printNode.js';
31
+ import xml2js from 'xml2js';
32
+ import { unwrapNestedArray } from '../lwm2m/unwrapNestedArray.js';
34
33
  import os from 'node:os';
35
- import { generateType } from './generateType.js';
36
34
  import { addDocBlock } from './addDocBlock.js';
37
- import { generateName } from './generateType.js';
35
+ import { generateName, generateType } from './generateType.js';
38
36
  import { generateValidator } from './generateValidator.js';
39
37
  import { generateValidators } from './generateValidators.js';
38
+ import { printNode } from './printNode.js';
40
39
  var baseDir = process.cwd();
41
40
  var subDir = function() {
42
41
  for(var _len = arguments.length, tree = new Array(_len), _key = 0; _key < _len; _key++){
@@ -0,0 +1,119 @@
1
+ function _assert_this_initialized(self) {
2
+ if (self === void 0) {
3
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4
+ }
5
+ return self;
6
+ }
7
+ function _call_super(_this, derived, args) {
8
+ derived = _get_prototype_of(derived);
9
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
10
+ }
11
+ function _class_call_check(instance, Constructor) {
12
+ if (!(instance instanceof Constructor)) {
13
+ throw new TypeError("Cannot call a class as a function");
14
+ }
15
+ }
16
+ function _construct(Parent, args, Class) {
17
+ if (_is_native_reflect_construct()) {
18
+ _construct = Reflect.construct;
19
+ } else {
20
+ _construct = function construct(Parent, args, Class) {
21
+ var a = [
22
+ null
23
+ ];
24
+ a.push.apply(a, args);
25
+ var Constructor = Function.bind.apply(Parent, a);
26
+ var instance = new Constructor();
27
+ if (Class) _set_prototype_of(instance, Class.prototype);
28
+ return instance;
29
+ };
30
+ }
31
+ return _construct.apply(null, arguments);
32
+ }
33
+ function _get_prototype_of(o) {
34
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
35
+ return o.__proto__ || Object.getPrototypeOf(o);
36
+ };
37
+ return _get_prototype_of(o);
38
+ }
39
+ function _inherits(subClass, superClass) {
40
+ if (typeof superClass !== "function" && superClass !== null) {
41
+ throw new TypeError("Super expression must either be null or a function");
42
+ }
43
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
44
+ constructor: {
45
+ value: subClass,
46
+ writable: true,
47
+ configurable: true
48
+ }
49
+ });
50
+ if (superClass) _set_prototype_of(subClass, superClass);
51
+ }
52
+ function _is_native_function(fn) {
53
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
54
+ }
55
+ function _possible_constructor_return(self, call) {
56
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
57
+ return call;
58
+ }
59
+ return _assert_this_initialized(self);
60
+ }
61
+ function _set_prototype_of(o, p) {
62
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
63
+ o.__proto__ = p;
64
+ return o;
65
+ };
66
+ return _set_prototype_of(o, p);
67
+ }
68
+ function _type_of(obj) {
69
+ "@swc/helpers - typeof";
70
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
71
+ }
72
+ function _wrap_native_super(Class) {
73
+ var _cache = typeof Map === "function" ? new Map() : undefined;
74
+ _wrap_native_super = function wrapNativeSuper(Class) {
75
+ if (Class === null || !_is_native_function(Class)) return Class;
76
+ if (typeof Class !== "function") {
77
+ throw new TypeError("Super expression must either be null or a function");
78
+ }
79
+ if (typeof _cache !== "undefined") {
80
+ if (_cache.has(Class)) return _cache.get(Class);
81
+ _cache.set(Class, Wrapper);
82
+ }
83
+ function Wrapper() {
84
+ return _construct(Class, arguments, _get_prototype_of(this).constructor);
85
+ }
86
+ Wrapper.prototype = Object.create(Class.prototype, {
87
+ constructor: {
88
+ value: Wrapper,
89
+ enumerable: false,
90
+ writable: true,
91
+ configurable: true
92
+ }
93
+ });
94
+ return _set_prototype_of(Wrapper, Class);
95
+ };
96
+ return _wrap_native_super(Class);
97
+ }
98
+ function _is_native_reflect_construct() {
99
+ try {
100
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
101
+ } catch (_) {}
102
+ return (_is_native_reflect_construct = function() {
103
+ return !!result;
104
+ })();
105
+ }
106
+ export var InvalidTimeError = /*#__PURE__*/ function(Error1) {
107
+ "use strict";
108
+ _inherits(InvalidTimeError, Error1);
109
+ function InvalidTimeError(message) {
110
+ _class_call_check(this, InvalidTimeError);
111
+ var _this;
112
+ _this = _call_super(this, InvalidTimeError, [
113
+ message
114
+ ]);
115
+ _this.name = 'InvalidTimeError';
116
+ return _this;
117
+ }
118
+ return InvalidTimeError;
119
+ }(_wrap_native_super(Error));
@@ -0,0 +1,119 @@
1
+ function _assert_this_initialized(self) {
2
+ if (self === void 0) {
3
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4
+ }
5
+ return self;
6
+ }
7
+ function _call_super(_this, derived, args) {
8
+ derived = _get_prototype_of(derived);
9
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
10
+ }
11
+ function _class_call_check(instance, Constructor) {
12
+ if (!(instance instanceof Constructor)) {
13
+ throw new TypeError("Cannot call a class as a function");
14
+ }
15
+ }
16
+ function _construct(Parent, args, Class) {
17
+ if (_is_native_reflect_construct()) {
18
+ _construct = Reflect.construct;
19
+ } else {
20
+ _construct = function construct(Parent, args, Class) {
21
+ var a = [
22
+ null
23
+ ];
24
+ a.push.apply(a, args);
25
+ var Constructor = Function.bind.apply(Parent, a);
26
+ var instance = new Constructor();
27
+ if (Class) _set_prototype_of(instance, Class.prototype);
28
+ return instance;
29
+ };
30
+ }
31
+ return _construct.apply(null, arguments);
32
+ }
33
+ function _get_prototype_of(o) {
34
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
35
+ return o.__proto__ || Object.getPrototypeOf(o);
36
+ };
37
+ return _get_prototype_of(o);
38
+ }
39
+ function _inherits(subClass, superClass) {
40
+ if (typeof superClass !== "function" && superClass !== null) {
41
+ throw new TypeError("Super expression must either be null or a function");
42
+ }
43
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
44
+ constructor: {
45
+ value: subClass,
46
+ writable: true,
47
+ configurable: true
48
+ }
49
+ });
50
+ if (superClass) _set_prototype_of(subClass, superClass);
51
+ }
52
+ function _is_native_function(fn) {
53
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
54
+ }
55
+ function _possible_constructor_return(self, call) {
56
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
57
+ return call;
58
+ }
59
+ return _assert_this_initialized(self);
60
+ }
61
+ function _set_prototype_of(o, p) {
62
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
63
+ o.__proto__ = p;
64
+ return o;
65
+ };
66
+ return _set_prototype_of(o, p);
67
+ }
68
+ function _type_of(obj) {
69
+ "@swc/helpers - typeof";
70
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
71
+ }
72
+ function _wrap_native_super(Class) {
73
+ var _cache = typeof Map === "function" ? new Map() : undefined;
74
+ _wrap_native_super = function wrapNativeSuper(Class) {
75
+ if (Class === null || !_is_native_function(Class)) return Class;
76
+ if (typeof Class !== "function") {
77
+ throw new TypeError("Super expression must either be null or a function");
78
+ }
79
+ if (typeof _cache !== "undefined") {
80
+ if (_cache.has(Class)) return _cache.get(Class);
81
+ _cache.set(Class, Wrapper);
82
+ }
83
+ function Wrapper() {
84
+ return _construct(Class, arguments, _get_prototype_of(this).constructor);
85
+ }
86
+ Wrapper.prototype = Object.create(Class.prototype, {
87
+ constructor: {
88
+ value: Wrapper,
89
+ enumerable: false,
90
+ writable: true,
91
+ configurable: true
92
+ }
93
+ });
94
+ return _set_prototype_of(Wrapper, Class);
95
+ };
96
+ return _wrap_native_super(Class);
97
+ }
98
+ function _is_native_reflect_construct() {
99
+ try {
100
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
101
+ } catch (_) {}
102
+ return (_is_native_reflect_construct = function() {
103
+ return !!result;
104
+ })();
105
+ }
106
+ export var NoHistoryMeasuresError = /*#__PURE__*/ function(Error1) {
107
+ "use strict";
108
+ _inherits(NoHistoryMeasuresError, Error1);
109
+ function NoHistoryMeasuresError(message) {
110
+ _class_call_check(this, NoHistoryMeasuresError);
111
+ var _this;
112
+ _this = _call_super(this, NoHistoryMeasuresError, [
113
+ message
114
+ ]);
115
+ _this.name = 'NoHistoryMeasuresError';
116
+ return _this;
117
+ }
118
+ return NoHistoryMeasuresError;
119
+ }(_wrap_native_super(Error));
@@ -0,0 +1,48 @@
1
+ import { MeasureValueType, TimeUnit } from '@aws-sdk/client-timestream-write';
2
+ import { instanceTsAsDate } from 'lwm2m/instanceTs.js';
3
+ import { instanceToMeasures } from './instanceToMeasures.js';
4
+ import { NoHistoryMeasuresError } from './NoHistoryMeasuresError.js';
5
+ export var instanceMeasuresToRecord = function(param) {
6
+ var ObjectID = param.ObjectID, ObjectInstanceID = param.ObjectInstanceID, ObjectVersion = param.ObjectVersion, Resources = param.Resources;
7
+ var maybeMeasures = instanceToMeasures({
8
+ ObjectID: ObjectID,
9
+ ObjectInstanceID: ObjectInstanceID,
10
+ ObjectVersion: ObjectVersion,
11
+ Resources: Resources
12
+ });
13
+ if ('error' in maybeMeasures) return maybeMeasures;
14
+ if (maybeMeasures.measures.length === 0) return {
15
+ error: new NoHistoryMeasuresError("No measure to be stored in history for object ".concat(ObjectID, "!"))
16
+ };
17
+ var instanceTs = instanceTsAsDate({
18
+ ObjectID: ObjectID,
19
+ ObjectInstanceID: ObjectInstanceID,
20
+ Resources: Resources
21
+ });
22
+ if (instanceTs === undefined) return {
23
+ error: new Error("No timestamp found for ".concat(ObjectID, "!"))
24
+ };
25
+ return {
26
+ record: {
27
+ Dimensions: [
28
+ {
29
+ Name: 'ObjectID',
30
+ Value: ObjectID.toString()
31
+ },
32
+ {
33
+ Name: 'ObjectInstanceID',
34
+ Value: (ObjectInstanceID !== null && ObjectInstanceID !== void 0 ? ObjectInstanceID : 0).toString()
35
+ },
36
+ {
37
+ Name: 'ObjectVersion',
38
+ Value: ObjectVersion
39
+ }
40
+ ],
41
+ MeasureName: "".concat(ObjectID, "/").concat(ObjectInstanceID !== null && ObjectInstanceID !== void 0 ? ObjectInstanceID : 0),
42
+ MeasureValues: maybeMeasures.measures,
43
+ MeasureValueType: MeasureValueType.MULTI,
44
+ Time: instanceTs.getTime().toString(),
45
+ TimeUnit: TimeUnit.MILLISECONDS
46
+ }
47
+ };
48
+ };
@@ -0,0 +1,39 @@
1
+ function _instanceof(left, right) {
2
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
3
+ return !!right[Symbol.hasInstance](left);
4
+ } else {
5
+ return left instanceof right;
6
+ }
7
+ }
8
+ import { InvalidTimeError } from 'lwm2m/InvalidTimeError.js';
9
+ import { LwM2MObjectID } from 'lwm2m/LwM2MObjectID.js';
10
+ import assert from 'node:assert/strict';
11
+ import { describe, it } from 'node:test';
12
+ import { instanceMeasuresToRecord } from './instanceMeasuresToRecord.js';
13
+ import { NoHistoryMeasuresError } from './NoHistoryMeasuresError.js';
14
+ void describe('instanceMeasuresToRecord()', function() {
15
+ void it('should return an error if no measures are found', function() {
16
+ var res = instanceMeasuresToRecord({
17
+ ObjectID: LwM2MObjectID.DeviceInformation_14204,
18
+ Resources: {
19
+ '0': '352656108602296',
20
+ '1': '89457387300008502299',
21
+ '2': 'mfw_nrf9160_1.3.5',
22
+ '3': 'v1.3.1+thingy91.sol.lp.mmflt',
23
+ '4': 'thingy91_nrf9160',
24
+ '99': 1717419305
25
+ }
26
+ });
27
+ assert.equal('error' in res && _instanceof(res.error, NoHistoryMeasuresError), true);
28
+ });
29
+ void it('should return an error if the timestamp is invalid', function() {
30
+ var res = instanceMeasuresToRecord({
31
+ ObjectID: LwM2MObjectID.Environment_14205,
32
+ Resources: {
33
+ '0': 13.8,
34
+ '99': 1718878270596
35
+ }
36
+ });
37
+ assert.equal('error' in res && _instanceof(res.error, InvalidTimeError), true);
38
+ });
39
+ });
@@ -0,0 +1,50 @@
1
+ import { LwM2MObjectID } from 'lwm2m/LwM2MObjectID.js';
2
+ import assert from 'node:assert';
3
+ import { describe, it } from 'node:test';
4
+ import { instanceMeasuresToRecord } from './instanceMeasuresToRecord.js';
5
+ void describe('instanceMeasuresToRecord()', function() {
6
+ void it('should convert LwM2M object instance to Timestream records', function() {
7
+ var env = {
8
+ ObjectID: LwM2MObjectID.Environment_14205,
9
+ ObjectVersion: '1.0',
10
+ Resources: {
11
+ 0: 21,
12
+ 1: 45,
13
+ '99': 1717419305
14
+ }
15
+ };
16
+ var maybeRecord = instanceMeasuresToRecord(env);
17
+ assert.deepEqual('record' in maybeRecord && maybeRecord.record, {
18
+ Dimensions: [
19
+ {
20
+ Name: 'ObjectID',
21
+ Value: LwM2MObjectID.Environment_14205
22
+ },
23
+ {
24
+ Name: 'ObjectInstanceID',
25
+ Value: '0'
26
+ },
27
+ {
28
+ Name: 'ObjectVersion',
29
+ Value: '1.0'
30
+ }
31
+ ],
32
+ MeasureName: '14205/0',
33
+ MeasureValueType: 'MULTI',
34
+ MeasureValues: [
35
+ {
36
+ Name: '14205/1.0/0',
37
+ Type: 'DOUBLE',
38
+ Value: '21'
39
+ },
40
+ {
41
+ Name: '14205/1.0/1',
42
+ Type: 'DOUBLE',
43
+ Value: '45'
44
+ }
45
+ ],
46
+ Time: '1717419305000',
47
+ TimeUnit: 'MILLISECONDS'
48
+ });
49
+ });
50
+ });