node-opcua-json 0.8.0 → 0.12.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.
package/dist2/index.d.ts CHANGED
@@ -33,4 +33,5 @@ export * from "./json_basic_encoding_decoding_int64";
33
33
  export * from "./json_basic_encoding_decoding_nodeid";
34
34
  export * from "./json_basic_encoding_decoding_statuscode";
35
35
  export * from "./json_basic_encoding_decoding_extension_object";
36
+ export * from "./json_basic_encoding_body_functor";
36
37
  export { opcuaJsonEncodeExtensionObject, opcuaJsonDecodeExtensionObject } from "./json_basic_encoding_decoding_extension_object";
package/dist2/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 584: (__unused_webpack_module, exports, __nccwpck_require__) => {
4
+ 114: (__unused_webpack_module, exports, __nccwpck_require__) => {
5
5
  Object.defineProperty(exports, "__esModule", { value: !0 }),
6
6
  (exports.decodeOPCUA_JSON = exports.decodeOPCUA_JSONOld = void 0);
7
- const node_opcua_nodeid_1 = __nccwpck_require__(597),
8
- node_opcua_factory_1 = __nccwpck_require__(217),
9
- json_basic_encoding_decoding_extension_object_1 = __nccwpck_require__(894);
7
+ const node_opcua_nodeid_1 = __nccwpck_require__(791),
8
+ node_opcua_factory_1 = __nccwpck_require__(745),
9
+ json_basic_encoding_decoding_extension_object_1 = __nccwpck_require__(889);
10
10
  (exports.decodeOPCUA_JSONOld = function (dataType, pojo) {
11
11
  const Constructor = (0, node_opcua_factory_1.getStandardDataTypeFactory)().findConstructorForDataType(
12
12
  (0, node_opcua_nodeid_1.resolveNodeId)(dataType)
@@ -23,7 +23,7 @@
23
23
  );
24
24
  });
25
25
  },
26
- 632: function (__unused_webpack_module, exports, __nccwpck_require__) {
26
+ 370: function (__unused_webpack_module, exports, __nccwpck_require__) {
27
27
  var __createBinding =
28
28
  (this && this.__createBinding) ||
29
29
  (Object.create
@@ -54,7 +54,7 @@
54
54
  exports.opcuaJsonDecodeVariant =
55
55
  exports.opcuaJsonEncodeVariant =
56
56
  void 0);
57
- var json_basic_encoding_decoding_variant_1 = __nccwpck_require__(725);
57
+ var json_basic_encoding_decoding_variant_1 = __nccwpck_require__(349);
58
58
  Object.defineProperty(exports, "opcuaJsonEncodeVariant", {
59
59
  enumerable: !0,
60
60
  get: function () {
@@ -67,7 +67,7 @@
67
67
  return json_basic_encoding_decoding_variant_1.opcuaJsonDecodeVariant;
68
68
  },
69
69
  });
70
- var json_basic_encoding_decoding_data_value_1 = __nccwpck_require__(266);
70
+ var json_basic_encoding_decoding_data_value_1 = __nccwpck_require__(373);
71
71
  Object.defineProperty(exports, "opcuaJsonEncodeDataValue", {
72
72
  enumerable: !0,
73
73
  get: function () {
@@ -86,16 +86,17 @@
86
86
  return json_basic_encoding_decoding_data_value_1.opcuaJsonEncodeDataValueMQTT;
87
87
  },
88
88
  }),
89
- __exportStar(__nccwpck_require__(584), exports),
90
- __exportStar(__nccwpck_require__(303), exports),
91
- __exportStar(__nccwpck_require__(86), exports),
92
- __exportStar(__nccwpck_require__(648), exports),
93
- __exportStar(__nccwpck_require__(272), exports),
94
- __exportStar(__nccwpck_require__(805), exports),
95
- __exportStar(__nccwpck_require__(35), exports),
96
- __exportStar(__nccwpck_require__(303), exports),
97
- __exportStar(__nccwpck_require__(894), exports);
98
- var json_basic_encoding_decoding_extension_object_1 = __nccwpck_require__(894);
89
+ __exportStar(__nccwpck_require__(114), exports),
90
+ __exportStar(__nccwpck_require__(720), exports),
91
+ __exportStar(__nccwpck_require__(182), exports),
92
+ __exportStar(__nccwpck_require__(510), exports),
93
+ __exportStar(__nccwpck_require__(275), exports),
94
+ __exportStar(__nccwpck_require__(376), exports),
95
+ __exportStar(__nccwpck_require__(937), exports),
96
+ __exportStar(__nccwpck_require__(720), exports),
97
+ __exportStar(__nccwpck_require__(889), exports),
98
+ __exportStar(__nccwpck_require__(694), exports);
99
+ var json_basic_encoding_decoding_extension_object_1 = __nccwpck_require__(889);
99
100
  Object.defineProperty(exports, "opcuaJsonEncodeExtensionObject", {
100
101
  enumerable: !0,
101
102
  get: function () {
@@ -109,20 +110,20 @@
109
110
  },
110
111
  });
111
112
  },
112
- 922: (__unused_webpack_module, exports, __nccwpck_require__) => {
113
+ 694: (__unused_webpack_module, exports, __nccwpck_require__) => {
113
114
  Object.defineProperty(exports, "__esModule", { value: !0 }),
114
115
  (exports.bodyDecodeFunctor = exports.bodyEncodeFunctor = void 0);
115
- const node_opcua_variant_1 = __nccwpck_require__(567),
116
- json_basic_encoding_decoding_byte_string_1 = __nccwpck_require__(86),
117
- json_basic_encoding_decoding_data_value_1 = __nccwpck_require__(266),
118
- json_basic_encoding_decoding_date_time_1 = __nccwpck_require__(80),
119
- json_basic_encoding_decoding_extension_object_1 = __nccwpck_require__(894),
120
- json_basic_encoding_decoding_int64_1 = __nccwpck_require__(805),
121
- json_basic_encoding_decoding_localizedtext_1 = __nccwpck_require__(648),
122
- json_basic_encoding_decoding_nodeid_1 = __nccwpck_require__(35),
123
- json_basic_encoding_decoding_qualifiedname_1 = __nccwpck_require__(272),
124
- json_basic_encoding_decoding_statuscode_1 = __nccwpck_require__(303),
125
- json_basic_encoding_decoding_variant_1 = __nccwpck_require__(725);
116
+ const node_opcua_variant_1 = __nccwpck_require__(298),
117
+ json_basic_encoding_decoding_byte_string_1 = __nccwpck_require__(182),
118
+ json_basic_encoding_decoding_data_value_1 = __nccwpck_require__(373),
119
+ json_basic_encoding_decoding_date_time_1 = __nccwpck_require__(818),
120
+ json_basic_encoding_decoding_extension_object_1 = __nccwpck_require__(889),
121
+ json_basic_encoding_decoding_int64_1 = __nccwpck_require__(376),
122
+ json_basic_encoding_decoding_localizedtext_1 = __nccwpck_require__(510),
123
+ json_basic_encoding_decoding_nodeid_1 = __nccwpck_require__(937),
124
+ json_basic_encoding_decoding_qualifiedname_1 = __nccwpck_require__(275),
125
+ json_basic_encoding_decoding_statuscode_1 = __nccwpck_require__(720),
126
+ json_basic_encoding_decoding_variant_1 = __nccwpck_require__(349);
126
127
  (exports.bodyEncodeFunctor = function (dataType) {
127
128
  switch (dataType) {
128
129
  case node_opcua_variant_1.DataType.Null:
@@ -212,7 +213,7 @@
212
213
  }
213
214
  });
214
215
  },
215
- 86: (__unused_webpack_module, exports) => {
216
+ 182: (__unused_webpack_module, exports) => {
216
217
  Object.defineProperty(exports, "__esModule", { value: !0 }),
217
218
  (exports.opcuaJsonDecodeByteString = exports.opcuaJsonEncodeByteString = void 0),
218
219
  (exports.opcuaJsonEncodeByteString = function (byteString, reversible = !1, namespaceArray) {
@@ -222,14 +223,14 @@
222
223
  return pojo ? Buffer.from(pojo, "base64") : null;
223
224
  });
224
225
  },
225
- 266: (__unused_webpack_module, exports, __nccwpck_require__) => {
226
+ 373: (__unused_webpack_module, exports, __nccwpck_require__) => {
226
227
  Object.defineProperty(exports, "__esModule", { value: !0 }),
227
228
  (exports.opcuaJsonDecodeDataValue = exports.opcuaJsonEncodeDataValue = exports.opcuaJsonEncodeDataValueMQTT = void 0);
228
- const node_opcua_data_value_1 = __nccwpck_require__(169),
229
- node_opcua_variant_1 = __nccwpck_require__(567),
230
- node_opcua_types_1 = __nccwpck_require__(67),
231
- json_basic_encoding_decoding_variant_1 = __nccwpck_require__(725),
232
- json_basic_encoding_decoding_statuscode_1 = __nccwpck_require__(303);
229
+ const node_opcua_data_value_1 = __nccwpck_require__(146),
230
+ node_opcua_variant_1 = __nccwpck_require__(298),
231
+ node_opcua_types_1 = __nccwpck_require__(196),
232
+ json_basic_encoding_decoding_variant_1 = __nccwpck_require__(349),
233
+ json_basic_encoding_decoding_statuscode_1 = __nccwpck_require__(720);
233
234
  (exports.opcuaJsonEncodeDataValueMQTT = function (dataValue, mask) {
234
235
  if (mask === node_opcua_types_1.DataSetFieldContentMask.None)
235
236
  return (0, json_basic_encoding_decoding_variant_1.opcuaJsonEncodeVariant)(dataValue.value, !0);
@@ -273,7 +274,7 @@
273
274
  pojo
274
275
  );
275
276
  }),
276
- (exports.opcuaJsonDecodeDataValue = function (pojo) {
277
+ (exports.opcuaJsonDecodeDataValue = function (pojo, builder) {
277
278
  if (!pojo) return new node_opcua_data_value_1.DataValue({ value: { dataType: node_opcua_variant_1.DataType.Null } });
278
279
  const dataValueOpt = {};
279
280
  return (
@@ -285,12 +286,13 @@
285
286
  (dataValueOpt.statusCode = (0, json_basic_encoding_decoding_statuscode_1.opcuaJsonDecodeStatusCode)(
286
287
  pojo.StatusCode
287
288
  )),
288
- pojo.Value && (dataValueOpt.value = (0, json_basic_encoding_decoding_variant_1.opcuaJsonDecodeVariant)(pojo.Value)),
289
+ pojo.Value &&
290
+ (dataValueOpt.value = (0, json_basic_encoding_decoding_variant_1.opcuaJsonDecodeVariant)(pojo.Value, builder)),
289
291
  new node_opcua_data_value_1.DataValue(dataValueOpt)
290
292
  );
291
293
  });
292
294
  },
293
- 80: (__unused_webpack_module, exports) => {
295
+ 818: (__unused_webpack_module, exports) => {
294
296
  Object.defineProperty(exports, "__esModule", { value: !0 }),
295
297
  (exports.opcuaJsonDecodeDateTime = exports.opcuaJsonEncodeDateTime = void 0),
296
298
  (exports.opcuaJsonEncodeDateTime = function (date, reversible = !1, namespaceArray) {
@@ -300,7 +302,7 @@
300
302
  return "string" == typeof pojo ? new Date(pojo) : pojo;
301
303
  });
302
304
  },
303
- 894: (__unused_webpack_module, exports, __nccwpck_require__) => {
305
+ 889: (__unused_webpack_module, exports, __nccwpck_require__) => {
304
306
  Object.defineProperty(exports, "__esModule", { value: !0 }),
305
307
  (exports.opcuaJsonDecodeExtensionObject =
306
308
  exports.opcuaJsonEncodeExtensionObject =
@@ -308,27 +310,34 @@
308
310
  exports.opcuaJsonDecodeExtensionObjectBody =
309
311
  exports.makeBody =
310
312
  void 0);
311
- const node_opcua_variant_1 = __nccwpck_require__(567),
312
- node_opcua_numeric_range_1 = __nccwpck_require__(654),
313
- node_opcua_debug_1 = __nccwpck_require__(543),
314
- node_opcua_factory_1 = __nccwpck_require__(217),
315
- json_basic_encoding_body_functor_1 = __nccwpck_require__(922),
316
- json_basic_encoding_decoding_nodeid_1 = __nccwpck_require__(35),
313
+ const node_opcua_variant_1 = __nccwpck_require__(298),
314
+ node_opcua_numeric_range_1 = __nccwpck_require__(138),
315
+ node_opcua_debug_1 = __nccwpck_require__(647),
316
+ node_opcua_factory_1 = __nccwpck_require__(745),
317
+ json_basic_encoding_body_functor_1 = __nccwpck_require__(694),
318
+ json_basic_encoding_decoding_nodeid_1 = __nccwpck_require__(937),
317
319
  errorLog = (0, node_opcua_debug_1.make_errorLog)("JSON");
318
320
  function originalName(name) {
319
321
  return name[0].toUpperCase() + name.slice(1);
320
322
  }
323
+ const g_DataType = node_opcua_variant_1.DataType;
321
324
  function toDataType(field) {
322
- return node_opcua_variant_1.DataType[field];
325
+ let dataType = g_DataType[field.fieldType];
326
+ return (
327
+ void 0 === dataType &&
328
+ (field.schema instanceof node_opcua_factory_1.BasicTypeSchema
329
+ ? (dataType = g_DataType[field.schema.subType || field.schema.name])
330
+ : ((dataType = g_DataType[field.schema.name]), dataType || g_DataType[field.schema.subType])),
331
+ dataType
332
+ );
323
333
  }
324
334
  function findEncoder(field) {
325
- let dataType = toDataType(field.fieldType);
335
+ const dataType = toDataType(field);
326
336
  if (!dataType) {
327
337
  if ("NumericRange" === field.fieldType) return (numericRange) => numericRange.toString();
328
338
  if ("UAString" === field.fieldType) return (str, reversible, namespaceArray) => str;
329
- dataType = toDataType(field.schema.subType);
330
339
  }
331
- const f = (() => {
340
+ const encoderFunc = (() => {
332
341
  switch (field.category) {
333
342
  case "complex":
334
343
  return "ExtensionObject" === field.fieldType ? opcuaJsonEncodeExtensionObject : opcuaJsonEncodeExtensionObjectBody;
@@ -338,20 +347,23 @@
338
347
  return (a) => a;
339
348
  }
340
349
  })();
341
- return f || (errorLog("findEncoder: Cannot find f for ", dataType, field), null);
350
+ return (
351
+ encoderFunc ||
352
+ (errorLog("findEncoder: Cannot find encoderFunc for ", node_opcua_variant_1.DataType[dataType], field), null)
353
+ );
342
354
  }
343
355
  function findDecoder(field) {
344
- let dataType = toDataType(field.fieldType);
356
+ const dataType = toDataType(field);
345
357
  if (!dataType) {
346
358
  if ("NumericRange" === field.fieldType)
347
359
  return (numericRange) => new node_opcua_numeric_range_1.NumericRange(numericRange);
348
360
  if ("UAString" === field.fieldType) return (str) => str;
349
- dataType = toDataType(field.schema.subType);
350
361
  }
351
- const f = (() => {
362
+ const decoderFunc = (() => {
352
363
  switch (field.category) {
353
364
  case "complex":
354
365
  if ("ExtensionObject" === field.fieldType) return opcuaJsonDecodeExtensionObject;
366
+ if (field.schema) return opcuaJsonDecodeExtensionObjectBody.bind(null, field.schema);
355
367
  {
356
368
  const schema = (0, node_opcua_factory_1.getStandardDataTypeFactory)().getStructuredTypeSchema(field.fieldType);
357
369
  return opcuaJsonDecodeExtensionObjectBody.bind(null, schema);
@@ -362,7 +374,10 @@
362
374
  return (a) => a;
363
375
  }
364
376
  })();
365
- return f || (errorLog("findEncoder: Cannot find f for ", dataType, field), null);
377
+ return (
378
+ decoderFunc ||
379
+ (errorLog("findEncoder: Cannot find decoderFunc for ", node_opcua_variant_1.DataType[dataType], field), null)
380
+ );
366
381
  }
367
382
  function makeBody(extensionObject, reversible = !1) {
368
383
  const pojo = {};
@@ -384,7 +399,7 @@
384
399
  }
385
400
  return pojo;
386
401
  }
387
- function adaptBody(body, schema) {
402
+ function adaptBody(body, schema, builder) {
388
403
  const pojo = {};
389
404
  for (const field of schema.fields) {
390
405
  const value = body[originalName(field.name)];
@@ -396,16 +411,16 @@
396
411
  if ("object" == typeof value && value && 0 === value.length) pojo[field.name] = [];
397
412
  else {
398
413
  const valueAsArray = value;
399
- pojo[field.name] = valueAsArray.map((a) => (a ? decoder(a) : void 0));
414
+ pojo[field.name] = valueAsArray.map((a) => (a ? decoder(a, builder) : void 0));
400
415
  }
401
416
  else pojo[field.name] = [];
402
- else null != value ? (pojo[field.name] = decoder(value)) : null === value && (pojo[field.name] = null);
417
+ else null != value ? (pojo[field.name] = decoder(value, builder)) : null === value && (pojo[field.name] = null);
403
418
  else errorLog("Cannot find decoder for", field);
404
419
  }
405
420
  return pojo;
406
421
  }
407
- function opcuaJsonDecodeExtensionObjectBody(schema, body) {
408
- return adaptBody(body, schema);
422
+ function opcuaJsonDecodeExtensionObjectBody(schema, body, builder) {
423
+ return adaptBody(body, schema, builder);
409
424
  }
410
425
  function opcuaJsonEncodeExtensionObjectBody(extensionObject, reversible = !1, namespaceArray) {
411
426
  return extensionObject ? makeBody(extensionObject, reversible) : null;
@@ -420,13 +435,19 @@
420
435
  }
421
436
  : body;
422
437
  }
423
- function opcuaJsonDecodeExtensionObject(_pojo) {
424
- const factory = (0, node_opcua_factory_1.getStandardDataTypeFactory)();
438
+ function opcuaJsonDecodeExtensionObject(_pojo, builder) {
425
439
  if (!_pojo) return null;
426
440
  const typeId = (0, json_basic_encoding_decoding_nodeid_1.opcuaJsonDecodeNodeId)(_pojo.TypeId),
427
- body = _pojo.Body,
428
- Constructor = factory.findConstructorForDataType(typeId);
429
- return new Constructor(adaptBody(body, Constructor.schema));
441
+ body = _pojo.Body;
442
+ if (0 === typeId.namespace) {
443
+ const Constructor = (0, node_opcua_factory_1.getStandardDataTypeFactory)().findConstructorForDataType(typeId);
444
+ return new Constructor(adaptBody(body, Constructor.schema));
445
+ }
446
+ {
447
+ if (!builder) throw new Error("Expecting a extension object builder for non-0 namespace extension objects");
448
+ const Constructor = builder.getExtensionObjectConstructor(typeId);
449
+ return new Constructor(adaptBody(body, Constructor.schema, builder));
450
+ }
430
451
  }
431
452
  (exports.makeBody = makeBody),
432
453
  (exports.opcuaJsonDecodeExtensionObjectBody = opcuaJsonDecodeExtensionObjectBody),
@@ -434,7 +455,7 @@
434
455
  (exports.opcuaJsonEncodeExtensionObject = opcuaJsonEncodeExtensionObject),
435
456
  (exports.opcuaJsonDecodeExtensionObject = opcuaJsonDecodeExtensionObject);
436
457
  },
437
- 805: (__unused_webpack_module, exports) => {
458
+ 376: (__unused_webpack_module, exports) => {
438
459
  Object.defineProperty(exports, "__esModule", { value: !0 }),
439
460
  (exports.opcuaJsonDecodeUInt64 =
440
461
  exports.opcuaJsonDecodeInt64 =
@@ -467,10 +488,10 @@
467
488
  return [Number(r / shiftHigh), Number(r % shiftHigh)];
468
489
  });
469
490
  },
470
- 648: (__unused_webpack_module, exports, __nccwpck_require__) => {
491
+ 510: (__unused_webpack_module, exports, __nccwpck_require__) => {
471
492
  Object.defineProperty(exports, "__esModule", { value: !0 }),
472
493
  (exports.opcuaJsonDecodeLocalizedText = exports.opcuaJsonEncodeLocalizedText = void 0);
473
- const node_opcua_data_model_1 = __nccwpck_require__(730);
494
+ const node_opcua_data_model_1 = __nccwpck_require__(626);
474
495
  (exports.opcuaJsonEncodeLocalizedText = function (localizedText, reversible = !1, namespaceArray) {
475
496
  if (!localizedText) return null;
476
497
  if (!reversible) return localizedText.text || null;
@@ -485,10 +506,10 @@
485
506
  : new node_opcua_data_model_1.LocalizedText();
486
507
  });
487
508
  },
488
- 35: (__unused_webpack_module, exports, __nccwpck_require__) => {
509
+ 937: (__unused_webpack_module, exports, __nccwpck_require__) => {
489
510
  Object.defineProperty(exports, "__esModule", { value: !0 }),
490
511
  (exports.opcuaJsonDecodeNodeId = exports.opcuaJsonEncodeNodeId = void 0);
491
- const node_opcua_nodeid_1 = __nccwpck_require__(597);
512
+ const node_opcua_nodeid_1 = __nccwpck_require__(791);
492
513
  (exports.opcuaJsonEncodeNodeId = function (value, reversible = !1, namespaceArray) {
493
514
  const IdType = (() => {
494
515
  switch (value.identifierType) {
@@ -557,10 +578,10 @@
557
578
  return new node_opcua_nodeid_1.NodeId(identifierType, value, namespace);
558
579
  });
559
580
  },
560
- 272: (__unused_webpack_module, exports, __nccwpck_require__) => {
581
+ 275: (__unused_webpack_module, exports, __nccwpck_require__) => {
561
582
  Object.defineProperty(exports, "__esModule", { value: !0 }),
562
583
  (exports.opcuaJsonDecodeQualifiedName = exports.opcuaJsonEncodeQualifiedName = void 0);
563
- const node_opcua_data_model_1 = __nccwpck_require__(730);
584
+ const node_opcua_data_model_1 = __nccwpck_require__(626);
564
585
  (exports.opcuaJsonEncodeQualifiedName = function (qualifiedName, reversible = !1, namespaceArray) {
565
586
  const pojo = { Name: qualifiedName.name || "" };
566
587
  return 0 === qualifiedName.namespaceIndex
@@ -576,10 +597,10 @@
576
597
  return new node_opcua_data_model_1.QualifiedName({ name: pojo.Name, namespaceIndex: namespaceIndex });
577
598
  });
578
599
  },
579
- 303: (__unused_webpack_module, exports, __nccwpck_require__) => {
600
+ 720: (__unused_webpack_module, exports, __nccwpck_require__) => {
580
601
  Object.defineProperty(exports, "__esModule", { value: !0 }),
581
602
  (exports.opcuaJsonDecodeStatusCode = exports.opcuaJsonEncodeStatusCode = void 0);
582
- const node_opcua_status_code_1 = __nccwpck_require__(8);
603
+ const node_opcua_status_code_1 = __nccwpck_require__(912);
583
604
  (exports.opcuaJsonEncodeStatusCode = function (statusCode, reversible = !1) {
584
605
  if (reversible) return statusCode.value;
585
606
  if (0 === statusCode.value) return;
@@ -594,11 +615,11 @@
594
615
  : node_opcua_status_code_1.StatusCodes.Good;
595
616
  });
596
617
  },
597
- 725: (__unused_webpack_module, exports, __nccwpck_require__) => {
618
+ 349: (__unused_webpack_module, exports, __nccwpck_require__) => {
598
619
  Object.defineProperty(exports, "__esModule", { value: !0 }),
599
620
  (exports.opcuaJsonDecodeVariant = exports.opcuaJsonEncodeVariant = void 0);
600
- const node_opcua_variant_1 = __nccwpck_require__(567),
601
- json_basic_encoding_body_functor_1 = __nccwpck_require__(922);
621
+ const node_opcua_variant_1 = __nccwpck_require__(298),
622
+ json_basic_encoding_body_functor_1 = __nccwpck_require__(694);
602
623
  function body(variant, reversible, namespaceArray) {
603
624
  const f = (0, json_basic_encoding_body_functor_1.bodyEncodeFunctor)(variant.dataType);
604
625
  if (variant.arrayType === node_opcua_variant_1.VariantArrayType.Scalar)
@@ -621,12 +642,12 @@
621
642
  pojo
622
643
  );
623
644
  }),
624
- (exports.opcuaJsonDecodeVariant = function (pojo) {
645
+ (exports.opcuaJsonDecodeVariant = function (pojo, builder) {
625
646
  if (!pojo) return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null });
626
647
  const dataType = pojo.Type,
627
648
  f = (0, json_basic_encoding_body_functor_1.bodyDecodeFunctor)(dataType);
628
649
  if (Array.isArray(pojo.Body)) {
629
- const value = pojo.Body.map((a) => f(a));
650
+ const value = pojo.Body.map((a) => f(a, builder));
630
651
  return pojo.Dimensions
631
652
  ? new node_opcua_variant_1.Variant({
632
653
  arrayType: node_opcua_variant_1.VariantArrayType.Matrix,
@@ -640,34 +661,38 @@
640
661
  value: value,
641
662
  });
642
663
  }
643
- return new node_opcua_variant_1.Variant({ dataType: dataType, value: f(pojo.Body) });
664
+ return new node_opcua_variant_1.Variant({
665
+ dataType: dataType,
666
+ arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
667
+ value: f(pojo.Body, builder),
668
+ });
644
669
  });
645
670
  },
646
- 730: (module) => {
671
+ 626: (module) => {
647
672
  module.exports = require("node-opcua-data-model");
648
673
  },
649
- 169: (module) => {
674
+ 146: (module) => {
650
675
  module.exports = require("node-opcua-data-value");
651
676
  },
652
- 543: (module) => {
677
+ 647: (module) => {
653
678
  module.exports = require("node-opcua-debug");
654
679
  },
655
- 217: (module) => {
680
+ 745: (module) => {
656
681
  module.exports = require("node-opcua-factory");
657
682
  },
658
- 597: (module) => {
683
+ 791: (module) => {
659
684
  module.exports = require("node-opcua-nodeid");
660
685
  },
661
- 654: (module) => {
686
+ 138: (module) => {
662
687
  module.exports = require("node-opcua-numeric-range");
663
688
  },
664
- 8: (module) => {
689
+ 912: (module) => {
665
690
  module.exports = require("node-opcua-status-code");
666
691
  },
667
- 67: (module) => {
692
+ 196: (module) => {
668
693
  module.exports = require("node-opcua-types");
669
694
  },
670
- 567: (module) => {
695
+ 298: (module) => {
671
696
  module.exports = require("node-opcua-variant");
672
697
  },
673
698
  },
@@ -685,6 +710,6 @@
685
710
  return module.exports;
686
711
  }
687
712
  __nccwpck_require__.ab = __dirname + "/";
688
- var __webpack_exports__ = __nccwpck_require__(632);
713
+ var __webpack_exports__ = __nccwpck_require__(370);
689
714
  module.exports = __webpack_exports__;
690
715
  })();
@@ -22,8 +22,14 @@
22
22
  *
23
23
  */
24
24
 
25
+ import { NodeId } from "node-opcua-nodeid";
25
26
  import { DataType } from "node-opcua-variant";
27
+ import { ExtensionObjectConstructorFuncWithSchema } from "node-opcua-address-space/dist/src/ua_data_type_impl";
28
+ export { ExtensionObjectConstructorFuncWithSchema } from "node-opcua-address-space/dist/src/ua_data_type_impl";
26
29
  export declare type EncoderFunc<T> = (t: T, reversible: boolean, namespaceArray?: string[]) => unknown;
27
- export declare type DecoderFunc<T> = (t: T) => unknown;
30
+ export interface ExtensionObjectBuilder {
31
+ getExtensionObjectConstructor(dataTypeNodeId: NodeId): ExtensionObjectConstructorFuncWithSchema;
32
+ }
33
+ export declare type DecoderFunc<T> = (t: T, builder?: ExtensionObjectBuilder) => unknown;
28
34
  export declare function bodyEncodeFunctor(dataType: DataType): EncoderFunc<unknown>;
29
35
  export declare function bodyDecodeFunctor(dataType: DataType): DecoderFunc<unknown>;
@@ -26,6 +26,7 @@ import { DataValue } from "node-opcua-data-value";
26
26
  import { DataSetFieldContentMask } from "node-opcua-types";
27
27
  import { VariantJSON, VariantJSONBody } from "./json_basic_encoding_decoding_variant";
28
28
  import { StatusCodeJSON } from "./json_basic_encoding_decoding_statuscode";
29
+ import { ExtensionObjectBuilder } from "./json_basic_encoding_body_functor";
29
30
  export interface DataValueJSON {
30
31
  Value?: VariantJSON | null;
31
32
  StatusCode?: StatusCodeJSON | number;
@@ -42,4 +43,4 @@ export interface DataValueJSON {
42
43
  */
43
44
  export declare function opcuaJsonEncodeDataValueMQTT(dataValue: DataValue, mask: DataSetFieldContentMask): VariantJSONBody | VariantJSON | DataValueJSON | null;
44
45
  export declare function opcuaJsonEncodeDataValue(dataValue: DataValue, reversible: boolean): DataValueJSON;
45
- export declare function opcuaJsonDecodeDataValue(pojo: DataValueJSON | null | undefined): DataValue;
46
+ export declare function opcuaJsonDecodeDataValue(pojo: DataValueJSON | null | undefined, builder?: ExtensionObjectBuilder): DataValue;
@@ -1,5 +1,6 @@
1
1
  import { ExtensionObject } from "node-opcua-extension-object";
2
2
  import { StructuredTypeSchema } from "node-opcua-factory";
3
+ import { ExtensionObjectBuilder } from "./json_basic_encoding_body_functor";
3
4
  import { NodeIdJSON } from "./json_basic_encoding_decoding_nodeid";
4
5
  import { Pojo } from "./decode_opcua_json";
5
6
  export interface ExtensionObjectJSON {
@@ -7,7 +8,7 @@ export interface ExtensionObjectJSON {
7
8
  Body: Pojo;
8
9
  }
9
10
  export declare function makeBody(extensionObject: ExtensionObject, reversible?: boolean): Pojo;
10
- export declare function opcuaJsonDecodeExtensionObjectBody(schema: StructuredTypeSchema, body: Pojo): Pojo;
11
+ export declare function opcuaJsonDecodeExtensionObjectBody(schema: StructuredTypeSchema, body: Pojo, builder?: ExtensionObjectBuilder): Pojo;
11
12
  export declare function opcuaJsonEncodeExtensionObjectBody(extensionObject: ExtensionObject | null, reversible?: boolean, namespaceArray?: string[]): ExtensionObjectJSON | Pojo | null;
12
13
  /**
13
14
  *
@@ -28,4 +29,4 @@ export declare function opcuaJsonEncodeExtensionObjectBody(extensionObject: Exte
28
29
  * the value of the Body field. The TypeId and Encoding fields are dropped.
29
30
  */
30
31
  export declare function opcuaJsonEncodeExtensionObject(extensionObject: ExtensionObject | null, reversible?: boolean, namespaceArray?: string[]): ExtensionObjectJSON | Pojo | null;
31
- export declare function opcuaJsonDecodeExtensionObject(_pojo: ExtensionObjectJSON): ExtensionObject | null;
32
+ export declare function opcuaJsonDecodeExtensionObject(_pojo: ExtensionObjectJSON, builder?: ExtensionObjectBuilder): ExtensionObject | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-json",
3
- "version": "0.8.0",
3
+ "version": "0.12.0",
4
4
  "description": "OPCUA JSON encoder/decoder for node-opcua",
5
5
  "author": "Etienne Rossignon <etienne.rossignon@sterfive.com>",
6
6
  "homepage": "https://support.sterfive.com",
@@ -14,21 +14,24 @@
14
14
  "type": "git",
15
15
  "url": "git@gitlab.sterfive.fr:sterfive/node-opcua-pubsub.git"
16
16
  },
17
- "scripts": {},
18
17
  "peerDependencies": {
19
- "node-opcua-basic-types": "2.57.0",
18
+ "node-opcua-basic-types": "2.61.0",
20
19
  "node-opcua-binary-stream": "2.55.0",
21
20
  "node-opcua-buffer-utils": "2.55.0",
22
- "node-opcua-data-model": "2.57.0",
23
- "node-opcua-data-value": "2.57.0",
24
- "node-opcua-date-time": "2.55.0",
25
- "node-opcua-extension-object": "2.57.0",
26
- "node-opcua-factory": "2.57.0",
27
- "node-opcua-nodeid": "2.55.0",
28
- "node-opcua-numeric-range": "2.57.0",
21
+ "node-opcua-data-model": "2.61.0",
22
+ "node-opcua-data-value": "2.61.0",
23
+ "node-opcua-date-time": "2.61.0",
24
+ "node-opcua-extension-object": "2.61.0",
25
+ "node-opcua-factory": "2.61.0",
26
+ "node-opcua-nodeid": "2.61.0",
27
+ "node-opcua-numeric-range": "2.61.0",
29
28
  "node-opcua-status-code": "2.56.0",
30
- "node-opcua-types": "2.57.0",
31
- "node-opcua-variant": "2.57.0"
29
+ "node-opcua-types": "2.61.0",
30
+ "node-opcua-variant": "2.61.0"
32
31
  },
33
- "gitHead": "092c80425fdaf5de81462ce7a225842dfbd13708"
32
+ "gitHead": "092c80425fdaf5de81462ce7a225842dfbd13708",
33
+ "dependencies": {
34
+ "@types/aws-iot-device-sdk": "^2.2.3"
35
+ },
36
+ "scripts": {}
34
37
  }