@hello.nrfcloud.com/proto-map 16.1.8 → 16.1.10

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.
@@ -50,6 +50,33 @@ function _object_spread_props(target, source) {
50
50
  }
51
51
  return target;
52
52
  }
53
+ function _object_without_properties(source, excluded) {
54
+ if (source == null) return {};
55
+ var target = _object_without_properties_loose(source, excluded);
56
+ var key, i;
57
+ if (Object.getOwnPropertySymbols) {
58
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
59
+ for(i = 0; i < sourceSymbolKeys.length; i++){
60
+ key = sourceSymbolKeys[i];
61
+ if (excluded.indexOf(key) >= 0) continue;
62
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
63
+ target[key] = source[key];
64
+ }
65
+ }
66
+ return target;
67
+ }
68
+ function _object_without_properties_loose(source, excluded) {
69
+ if (source == null) return {};
70
+ var target = {};
71
+ var sourceKeys = Object.keys(source);
72
+ var key, i;
73
+ for(i = 0; i < sourceKeys.length; i++){
74
+ key = sourceKeys[i];
75
+ if (excluded.indexOf(key) >= 0) continue;
76
+ target[key] = source[key];
77
+ }
78
+ return target;
79
+ }
53
80
  import { timestampResources } from '../lwm2m/timestampResources.js';
54
81
  import { hasName } from './hasName.js';
55
82
  import { hasValue } from './hasValue.js';
@@ -145,17 +172,24 @@ export var senMLtoLwM2M = function(senML) {
145
172
  lwm2m: lwm2m
146
173
  };
147
174
  };
148
- var parseTimestampOnly = function(senML) {
175
+ /**
176
+ * Handle objects which are only `bt` (base time) and `bn` (base name)
177
+ */ var parseTimestampOnly = function(senML) {
149
178
  if (senML.length !== 1) return null;
150
179
  var item = senML[0];
151
180
  if (!('bn' in item) || !('bt' in item)) return null;
152
- var objectInfo = parseResourceId("".concat(item.bn, "0/0"));
181
+ var bn = item.bn, bt = item.bt, rest = _object_without_properties(item, [
182
+ "bn",
183
+ "bt"
184
+ ]);
185
+ if (Object.keys(rest).length !== 0) return null;
186
+ var objectInfo = parseResourceId("".concat(bn, "0/0"));
153
187
  if (objectInfo === null) return null;
154
188
  var tsRes = timestampResources.get(objectInfo.ObjectID);
155
189
  if (tsRes === undefined) return null;
156
190
  return {
157
191
  ObjectID: objectInfo.ObjectID,
158
192
  ObjectInstanceID: objectInfo.ObjectInstanceID,
159
- Resources: _define_property({}, tsRes, item.bt)
193
+ Resources: _define_property({}, tsRes, bt)
160
194
  };
161
195
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hello.nrfcloud.com/proto-map",
3
- "version": "16.1.8",
3
+ "version": "16.1.10",
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": {
@@ -40,7 +40,7 @@
40
40
  "@commitlint/config-conventional": "19.5.0",
41
41
  "@swc/cli": "0.4.0",
42
42
  "@swc/core": "1.7.28",
43
- "@types/node": "22.7.3",
43
+ "@types/node": "22.7.4",
44
44
  "@types/xml2js": "0.4.14",
45
45
  "chalk": "5.3.0",
46
46
  "globstar": "1.0.0",
@@ -98,6 +98,6 @@
98
98
  "lwm2m"
99
99
  ],
100
100
  "peerDependencies": {
101
- "@sinclair/typebox": "^0.33.12"
101
+ "@sinclair/typebox": "^0.33.13"
102
102
  }
103
103
  }
@@ -108,11 +108,16 @@ export const senMLtoLwM2M = (
108
108
  return { lwm2m }
109
109
  }
110
110
 
111
+ /**
112
+ * Handle objects which are only `bt` (base time) and `bn` (base name)
113
+ */
111
114
  const parseTimestampOnly = (senML: SenMLType): LwM2MObjectInstance | null => {
112
115
  if (senML.length !== 1) return null
113
116
  const item = senML[0]!
114
117
  if (!('bn' in item) || !('bt' in item)) return null
115
- const objectInfo = parseResourceId(`${item.bn}0/0`)
118
+ const { bn, bt, ...rest } = item
119
+ if (Object.keys(rest).length !== 0) return null
120
+ const objectInfo = parseResourceId(`${bn}0/0`)
116
121
  if (objectInfo === null) return null
117
122
  const tsRes = timestampResources.get(objectInfo.ObjectID)
118
123
  if (tsRes === undefined) return null
@@ -120,7 +125,7 @@ const parseTimestampOnly = (senML: SenMLType): LwM2MObjectInstance | null => {
120
125
  ObjectID: objectInfo.ObjectID,
121
126
  ObjectInstanceID: objectInfo.ObjectInstanceID,
122
127
  Resources: {
123
- [tsRes]: item.bt,
128
+ [tsRes]: bt,
124
129
  },
125
130
  }
126
131
  }