node-opcua-json 0.7.0 → 0.10.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.js +110 -90
- package/dist2/json_basic_encoding_body_functor.d.ts +7 -1
- package/dist2/json_basic_encoding_decoding_byte_string.d.ts +1 -1
- package/dist2/json_basic_encoding_decoding_data_value.d.ts +11 -1
- package/dist2/json_basic_encoding_decoding_extension_object.d.ts +24 -3
- package/dist2/json_basic_encoding_decoding_nodeid.d.ts +24 -1
- package/dist2/json_basic_encoding_decoding_statuscode.d.ts +8 -1
- package/dist2/json_basic_encoding_decoding_variant.d.ts +0 -0
- package/package.json +13 -13
package/dist2/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
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__(
|
|
8
|
-
node_opcua_factory_1 = __nccwpck_require__(
|
|
9
|
-
json_basic_encoding_decoding_extension_object_1 = __nccwpck_require__(
|
|
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
|
-
|
|
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__(
|
|
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__(
|
|
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,16 @@
|
|
|
86
86
|
return json_basic_encoding_decoding_data_value_1.opcuaJsonEncodeDataValueMQTT;
|
|
87
87
|
},
|
|
88
88
|
}),
|
|
89
|
-
__exportStar(__nccwpck_require__(
|
|
90
|
-
__exportStar(__nccwpck_require__(
|
|
91
|
-
__exportStar(__nccwpck_require__(
|
|
92
|
-
__exportStar(__nccwpck_require__(
|
|
93
|
-
__exportStar(__nccwpck_require__(
|
|
94
|
-
__exportStar(__nccwpck_require__(
|
|
95
|
-
__exportStar(__nccwpck_require__(
|
|
96
|
-
__exportStar(__nccwpck_require__(
|
|
97
|
-
__exportStar(__nccwpck_require__(
|
|
98
|
-
var json_basic_encoding_decoding_extension_object_1 = __nccwpck_require__(
|
|
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
|
+
var json_basic_encoding_decoding_extension_object_1 = __nccwpck_require__(889);
|
|
99
99
|
Object.defineProperty(exports, "opcuaJsonEncodeExtensionObject", {
|
|
100
100
|
enumerable: !0,
|
|
101
101
|
get: function () {
|
|
@@ -109,20 +109,20 @@
|
|
|
109
109
|
},
|
|
110
110
|
});
|
|
111
111
|
},
|
|
112
|
-
|
|
112
|
+
694: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
113
113
|
Object.defineProperty(exports, "__esModule", { value: !0 }),
|
|
114
114
|
(exports.bodyDecodeFunctor = exports.bodyEncodeFunctor = void 0);
|
|
115
|
-
const node_opcua_variant_1 = __nccwpck_require__(
|
|
116
|
-
json_basic_encoding_decoding_byte_string_1 = __nccwpck_require__(
|
|
117
|
-
json_basic_encoding_decoding_data_value_1 = __nccwpck_require__(
|
|
118
|
-
json_basic_encoding_decoding_date_time_1 = __nccwpck_require__(
|
|
119
|
-
json_basic_encoding_decoding_extension_object_1 = __nccwpck_require__(
|
|
120
|
-
json_basic_encoding_decoding_int64_1 = __nccwpck_require__(
|
|
121
|
-
json_basic_encoding_decoding_localizedtext_1 = __nccwpck_require__(
|
|
122
|
-
json_basic_encoding_decoding_nodeid_1 = __nccwpck_require__(
|
|
123
|
-
json_basic_encoding_decoding_qualifiedname_1 = __nccwpck_require__(
|
|
124
|
-
json_basic_encoding_decoding_statuscode_1 = __nccwpck_require__(
|
|
125
|
-
json_basic_encoding_decoding_variant_1 = __nccwpck_require__(
|
|
115
|
+
const node_opcua_variant_1 = __nccwpck_require__(298),
|
|
116
|
+
json_basic_encoding_decoding_byte_string_1 = __nccwpck_require__(182),
|
|
117
|
+
json_basic_encoding_decoding_data_value_1 = __nccwpck_require__(373),
|
|
118
|
+
json_basic_encoding_decoding_date_time_1 = __nccwpck_require__(818),
|
|
119
|
+
json_basic_encoding_decoding_extension_object_1 = __nccwpck_require__(889),
|
|
120
|
+
json_basic_encoding_decoding_int64_1 = __nccwpck_require__(376),
|
|
121
|
+
json_basic_encoding_decoding_localizedtext_1 = __nccwpck_require__(510),
|
|
122
|
+
json_basic_encoding_decoding_nodeid_1 = __nccwpck_require__(937),
|
|
123
|
+
json_basic_encoding_decoding_qualifiedname_1 = __nccwpck_require__(275),
|
|
124
|
+
json_basic_encoding_decoding_statuscode_1 = __nccwpck_require__(720),
|
|
125
|
+
json_basic_encoding_decoding_variant_1 = __nccwpck_require__(349);
|
|
126
126
|
(exports.bodyEncodeFunctor = function (dataType) {
|
|
127
127
|
switch (dataType) {
|
|
128
128
|
case node_opcua_variant_1.DataType.Null:
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
}
|
|
213
213
|
});
|
|
214
214
|
},
|
|
215
|
-
|
|
215
|
+
182: (__unused_webpack_module, exports) => {
|
|
216
216
|
Object.defineProperty(exports, "__esModule", { value: !0 }),
|
|
217
217
|
(exports.opcuaJsonDecodeByteString = exports.opcuaJsonEncodeByteString = void 0),
|
|
218
218
|
(exports.opcuaJsonEncodeByteString = function (byteString, reversible = !1, namespaceArray) {
|
|
@@ -222,14 +222,14 @@
|
|
|
222
222
|
return pojo ? Buffer.from(pojo, "base64") : null;
|
|
223
223
|
});
|
|
224
224
|
},
|
|
225
|
-
|
|
225
|
+
373: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
226
226
|
Object.defineProperty(exports, "__esModule", { value: !0 }),
|
|
227
227
|
(exports.opcuaJsonDecodeDataValue = exports.opcuaJsonEncodeDataValue = exports.opcuaJsonEncodeDataValueMQTT = void 0);
|
|
228
|
-
const node_opcua_data_value_1 = __nccwpck_require__(
|
|
229
|
-
node_opcua_variant_1 = __nccwpck_require__(
|
|
230
|
-
node_opcua_types_1 = __nccwpck_require__(
|
|
231
|
-
json_basic_encoding_decoding_variant_1 = __nccwpck_require__(
|
|
232
|
-
json_basic_encoding_decoding_statuscode_1 = __nccwpck_require__(
|
|
228
|
+
const node_opcua_data_value_1 = __nccwpck_require__(146),
|
|
229
|
+
node_opcua_variant_1 = __nccwpck_require__(298),
|
|
230
|
+
node_opcua_types_1 = __nccwpck_require__(196),
|
|
231
|
+
json_basic_encoding_decoding_variant_1 = __nccwpck_require__(349),
|
|
232
|
+
json_basic_encoding_decoding_statuscode_1 = __nccwpck_require__(720);
|
|
233
233
|
(exports.opcuaJsonEncodeDataValueMQTT = function (dataValue, mask) {
|
|
234
234
|
if (mask === node_opcua_types_1.DataSetFieldContentMask.None)
|
|
235
235
|
return (0, json_basic_encoding_decoding_variant_1.opcuaJsonEncodeVariant)(dataValue.value, !0);
|
|
@@ -273,7 +273,7 @@
|
|
|
273
273
|
pojo
|
|
274
274
|
);
|
|
275
275
|
}),
|
|
276
|
-
(exports.opcuaJsonDecodeDataValue = function (pojo) {
|
|
276
|
+
(exports.opcuaJsonDecodeDataValue = function (pojo, builder) {
|
|
277
277
|
if (!pojo) return new node_opcua_data_value_1.DataValue({ value: { dataType: node_opcua_variant_1.DataType.Null } });
|
|
278
278
|
const dataValueOpt = {};
|
|
279
279
|
return (
|
|
@@ -285,12 +285,13 @@
|
|
|
285
285
|
(dataValueOpt.statusCode = (0, json_basic_encoding_decoding_statuscode_1.opcuaJsonDecodeStatusCode)(
|
|
286
286
|
pojo.StatusCode
|
|
287
287
|
)),
|
|
288
|
-
pojo.Value &&
|
|
288
|
+
pojo.Value &&
|
|
289
|
+
(dataValueOpt.value = (0, json_basic_encoding_decoding_variant_1.opcuaJsonDecodeVariant)(pojo.Value, builder)),
|
|
289
290
|
new node_opcua_data_value_1.DataValue(dataValueOpt)
|
|
290
291
|
);
|
|
291
292
|
});
|
|
292
293
|
},
|
|
293
|
-
|
|
294
|
+
818: (__unused_webpack_module, exports) => {
|
|
294
295
|
Object.defineProperty(exports, "__esModule", { value: !0 }),
|
|
295
296
|
(exports.opcuaJsonDecodeDateTime = exports.opcuaJsonEncodeDateTime = void 0),
|
|
296
297
|
(exports.opcuaJsonEncodeDateTime = function (date, reversible = !1, namespaceArray) {
|
|
@@ -300,7 +301,7 @@
|
|
|
300
301
|
return "string" == typeof pojo ? new Date(pojo) : pojo;
|
|
301
302
|
});
|
|
302
303
|
},
|
|
303
|
-
|
|
304
|
+
889: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
304
305
|
Object.defineProperty(exports, "__esModule", { value: !0 }),
|
|
305
306
|
(exports.opcuaJsonDecodeExtensionObject =
|
|
306
307
|
exports.opcuaJsonEncodeExtensionObject =
|
|
@@ -308,27 +309,34 @@
|
|
|
308
309
|
exports.opcuaJsonDecodeExtensionObjectBody =
|
|
309
310
|
exports.makeBody =
|
|
310
311
|
void 0);
|
|
311
|
-
const node_opcua_variant_1 = __nccwpck_require__(
|
|
312
|
-
node_opcua_numeric_range_1 = __nccwpck_require__(
|
|
313
|
-
node_opcua_debug_1 = __nccwpck_require__(
|
|
314
|
-
node_opcua_factory_1 = __nccwpck_require__(
|
|
315
|
-
json_basic_encoding_body_functor_1 = __nccwpck_require__(
|
|
316
|
-
json_basic_encoding_decoding_nodeid_1 = __nccwpck_require__(
|
|
312
|
+
const node_opcua_variant_1 = __nccwpck_require__(298),
|
|
313
|
+
node_opcua_numeric_range_1 = __nccwpck_require__(138),
|
|
314
|
+
node_opcua_debug_1 = __nccwpck_require__(647),
|
|
315
|
+
node_opcua_factory_1 = __nccwpck_require__(745),
|
|
316
|
+
json_basic_encoding_body_functor_1 = __nccwpck_require__(694),
|
|
317
|
+
json_basic_encoding_decoding_nodeid_1 = __nccwpck_require__(937),
|
|
317
318
|
errorLog = (0, node_opcua_debug_1.make_errorLog)("JSON");
|
|
318
319
|
function originalName(name) {
|
|
319
320
|
return name[0].toUpperCase() + name.slice(1);
|
|
320
321
|
}
|
|
322
|
+
const g_DataType = node_opcua_variant_1.DataType;
|
|
321
323
|
function toDataType(field) {
|
|
322
|
-
|
|
324
|
+
let dataType = g_DataType[field.fieldType];
|
|
325
|
+
return (
|
|
326
|
+
void 0 === dataType &&
|
|
327
|
+
(field.schema instanceof node_opcua_factory_1.BasicTypeSchema
|
|
328
|
+
? (dataType = g_DataType[field.schema.subType || field.schema.name])
|
|
329
|
+
: ((dataType = g_DataType[field.schema.name]), dataType || g_DataType[field.schema.subType])),
|
|
330
|
+
dataType
|
|
331
|
+
);
|
|
323
332
|
}
|
|
324
333
|
function findEncoder(field) {
|
|
325
|
-
|
|
334
|
+
const dataType = toDataType(field);
|
|
326
335
|
if (!dataType) {
|
|
327
336
|
if ("NumericRange" === field.fieldType) return (numericRange) => numericRange.toString();
|
|
328
337
|
if ("UAString" === field.fieldType) return (str, reversible, namespaceArray) => str;
|
|
329
|
-
dataType = toDataType(field.schema.subType);
|
|
330
338
|
}
|
|
331
|
-
const
|
|
339
|
+
const encoderFunc = (() => {
|
|
332
340
|
switch (field.category) {
|
|
333
341
|
case "complex":
|
|
334
342
|
return "ExtensionObject" === field.fieldType ? opcuaJsonEncodeExtensionObject : opcuaJsonEncodeExtensionObjectBody;
|
|
@@ -338,20 +346,23 @@
|
|
|
338
346
|
return (a) => a;
|
|
339
347
|
}
|
|
340
348
|
})();
|
|
341
|
-
return
|
|
349
|
+
return (
|
|
350
|
+
encoderFunc ||
|
|
351
|
+
(errorLog("findEncoder: Cannot find encoderFunc for ", node_opcua_variant_1.DataType[dataType], field), null)
|
|
352
|
+
);
|
|
342
353
|
}
|
|
343
354
|
function findDecoder(field) {
|
|
344
|
-
|
|
355
|
+
const dataType = toDataType(field);
|
|
345
356
|
if (!dataType) {
|
|
346
357
|
if ("NumericRange" === field.fieldType)
|
|
347
358
|
return (numericRange) => new node_opcua_numeric_range_1.NumericRange(numericRange);
|
|
348
359
|
if ("UAString" === field.fieldType) return (str) => str;
|
|
349
|
-
dataType = toDataType(field.schema.subType);
|
|
350
360
|
}
|
|
351
|
-
const
|
|
361
|
+
const decoderFunc = (() => {
|
|
352
362
|
switch (field.category) {
|
|
353
363
|
case "complex":
|
|
354
364
|
if ("ExtensionObject" === field.fieldType) return opcuaJsonDecodeExtensionObject;
|
|
365
|
+
if (field.schema) return opcuaJsonDecodeExtensionObjectBody.bind(null, field.schema);
|
|
355
366
|
{
|
|
356
367
|
const schema = (0, node_opcua_factory_1.getStandardDataTypeFactory)().getStructuredTypeSchema(field.fieldType);
|
|
357
368
|
return opcuaJsonDecodeExtensionObjectBody.bind(null, schema);
|
|
@@ -362,7 +373,10 @@
|
|
|
362
373
|
return (a) => a;
|
|
363
374
|
}
|
|
364
375
|
})();
|
|
365
|
-
return
|
|
376
|
+
return (
|
|
377
|
+
decoderFunc ||
|
|
378
|
+
(errorLog("findEncoder: Cannot find decoderFunc for ", node_opcua_variant_1.DataType[dataType], field), null)
|
|
379
|
+
);
|
|
366
380
|
}
|
|
367
381
|
function makeBody(extensionObject, reversible = !1) {
|
|
368
382
|
const pojo = {};
|
|
@@ -384,7 +398,7 @@
|
|
|
384
398
|
}
|
|
385
399
|
return pojo;
|
|
386
400
|
}
|
|
387
|
-
function adaptBody(body, schema) {
|
|
401
|
+
function adaptBody(body, schema, builder) {
|
|
388
402
|
const pojo = {};
|
|
389
403
|
for (const field of schema.fields) {
|
|
390
404
|
const value = body[originalName(field.name)];
|
|
@@ -396,16 +410,16 @@
|
|
|
396
410
|
if ("object" == typeof value && value && 0 === value.length) pojo[field.name] = [];
|
|
397
411
|
else {
|
|
398
412
|
const valueAsArray = value;
|
|
399
|
-
pojo[field.name] = valueAsArray.map((a) => (a ? decoder(a) : void 0));
|
|
413
|
+
pojo[field.name] = valueAsArray.map((a) => (a ? decoder(a, builder) : void 0));
|
|
400
414
|
}
|
|
401
415
|
else pojo[field.name] = [];
|
|
402
|
-
else null != value ? (pojo[field.name] = decoder(value)) : null === value && (pojo[field.name] = null);
|
|
416
|
+
else null != value ? (pojo[field.name] = decoder(value, builder)) : null === value && (pojo[field.name] = null);
|
|
403
417
|
else errorLog("Cannot find decoder for", field);
|
|
404
418
|
}
|
|
405
419
|
return pojo;
|
|
406
420
|
}
|
|
407
|
-
function opcuaJsonDecodeExtensionObjectBody(schema, body) {
|
|
408
|
-
return adaptBody(body, schema);
|
|
421
|
+
function opcuaJsonDecodeExtensionObjectBody(schema, body, builder) {
|
|
422
|
+
return adaptBody(body, schema, builder);
|
|
409
423
|
}
|
|
410
424
|
function opcuaJsonEncodeExtensionObjectBody(extensionObject, reversible = !1, namespaceArray) {
|
|
411
425
|
return extensionObject ? makeBody(extensionObject, reversible) : null;
|
|
@@ -420,13 +434,19 @@
|
|
|
420
434
|
}
|
|
421
435
|
: body;
|
|
422
436
|
}
|
|
423
|
-
function opcuaJsonDecodeExtensionObject(_pojo) {
|
|
424
|
-
const factory = (0, node_opcua_factory_1.getStandardDataTypeFactory)();
|
|
437
|
+
function opcuaJsonDecodeExtensionObject(_pojo, builder) {
|
|
425
438
|
if (!_pojo) return null;
|
|
426
439
|
const typeId = (0, json_basic_encoding_decoding_nodeid_1.opcuaJsonDecodeNodeId)(_pojo.TypeId),
|
|
427
|
-
body = _pojo.Body
|
|
428
|
-
|
|
429
|
-
|
|
440
|
+
body = _pojo.Body;
|
|
441
|
+
if (0 === typeId.namespace) {
|
|
442
|
+
const Constructor = (0, node_opcua_factory_1.getStandardDataTypeFactory)().findConstructorForDataType(typeId);
|
|
443
|
+
return new Constructor(adaptBody(body, Constructor.schema));
|
|
444
|
+
}
|
|
445
|
+
{
|
|
446
|
+
if (!builder) throw new Error("Expecting a extension object builder for non-0 namespace extension objects");
|
|
447
|
+
const Constructor = builder.getExtensionObjectConstructor(typeId);
|
|
448
|
+
return new Constructor(adaptBody(body, Constructor.schema, builder));
|
|
449
|
+
}
|
|
430
450
|
}
|
|
431
451
|
(exports.makeBody = makeBody),
|
|
432
452
|
(exports.opcuaJsonDecodeExtensionObjectBody = opcuaJsonDecodeExtensionObjectBody),
|
|
@@ -434,7 +454,7 @@
|
|
|
434
454
|
(exports.opcuaJsonEncodeExtensionObject = opcuaJsonEncodeExtensionObject),
|
|
435
455
|
(exports.opcuaJsonDecodeExtensionObject = opcuaJsonDecodeExtensionObject);
|
|
436
456
|
},
|
|
437
|
-
|
|
457
|
+
376: (__unused_webpack_module, exports) => {
|
|
438
458
|
Object.defineProperty(exports, "__esModule", { value: !0 }),
|
|
439
459
|
(exports.opcuaJsonDecodeUInt64 =
|
|
440
460
|
exports.opcuaJsonDecodeInt64 =
|
|
@@ -467,10 +487,10 @@
|
|
|
467
487
|
return [Number(r / shiftHigh), Number(r % shiftHigh)];
|
|
468
488
|
});
|
|
469
489
|
},
|
|
470
|
-
|
|
490
|
+
510: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
471
491
|
Object.defineProperty(exports, "__esModule", { value: !0 }),
|
|
472
492
|
(exports.opcuaJsonDecodeLocalizedText = exports.opcuaJsonEncodeLocalizedText = void 0);
|
|
473
|
-
const node_opcua_data_model_1 = __nccwpck_require__(
|
|
493
|
+
const node_opcua_data_model_1 = __nccwpck_require__(626);
|
|
474
494
|
(exports.opcuaJsonEncodeLocalizedText = function (localizedText, reversible = !1, namespaceArray) {
|
|
475
495
|
if (!localizedText) return null;
|
|
476
496
|
if (!reversible) return localizedText.text || null;
|
|
@@ -485,10 +505,10 @@
|
|
|
485
505
|
: new node_opcua_data_model_1.LocalizedText();
|
|
486
506
|
});
|
|
487
507
|
},
|
|
488
|
-
|
|
508
|
+
937: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
489
509
|
Object.defineProperty(exports, "__esModule", { value: !0 }),
|
|
490
510
|
(exports.opcuaJsonDecodeNodeId = exports.opcuaJsonEncodeNodeId = void 0);
|
|
491
|
-
const node_opcua_nodeid_1 = __nccwpck_require__(
|
|
511
|
+
const node_opcua_nodeid_1 = __nccwpck_require__(791);
|
|
492
512
|
(exports.opcuaJsonEncodeNodeId = function (value, reversible = !1, namespaceArray) {
|
|
493
513
|
const IdType = (() => {
|
|
494
514
|
switch (value.identifierType) {
|
|
@@ -557,10 +577,10 @@
|
|
|
557
577
|
return new node_opcua_nodeid_1.NodeId(identifierType, value, namespace);
|
|
558
578
|
});
|
|
559
579
|
},
|
|
560
|
-
|
|
580
|
+
275: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
561
581
|
Object.defineProperty(exports, "__esModule", { value: !0 }),
|
|
562
582
|
(exports.opcuaJsonDecodeQualifiedName = exports.opcuaJsonEncodeQualifiedName = void 0);
|
|
563
|
-
const node_opcua_data_model_1 = __nccwpck_require__(
|
|
583
|
+
const node_opcua_data_model_1 = __nccwpck_require__(626);
|
|
564
584
|
(exports.opcuaJsonEncodeQualifiedName = function (qualifiedName, reversible = !1, namespaceArray) {
|
|
565
585
|
const pojo = { Name: qualifiedName.name || "" };
|
|
566
586
|
return 0 === qualifiedName.namespaceIndex
|
|
@@ -576,10 +596,10 @@
|
|
|
576
596
|
return new node_opcua_data_model_1.QualifiedName({ name: pojo.Name, namespaceIndex: namespaceIndex });
|
|
577
597
|
});
|
|
578
598
|
},
|
|
579
|
-
|
|
599
|
+
720: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
580
600
|
Object.defineProperty(exports, "__esModule", { value: !0 }),
|
|
581
601
|
(exports.opcuaJsonDecodeStatusCode = exports.opcuaJsonEncodeStatusCode = void 0);
|
|
582
|
-
const node_opcua_status_code_1 = __nccwpck_require__(
|
|
602
|
+
const node_opcua_status_code_1 = __nccwpck_require__(912);
|
|
583
603
|
(exports.opcuaJsonEncodeStatusCode = function (statusCode, reversible = !1) {
|
|
584
604
|
if (reversible) return statusCode.value;
|
|
585
605
|
if (0 === statusCode.value) return;
|
|
@@ -594,11 +614,11 @@
|
|
|
594
614
|
: node_opcua_status_code_1.StatusCodes.Good;
|
|
595
615
|
});
|
|
596
616
|
},
|
|
597
|
-
|
|
617
|
+
349: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
598
618
|
Object.defineProperty(exports, "__esModule", { value: !0 }),
|
|
599
619
|
(exports.opcuaJsonDecodeVariant = exports.opcuaJsonEncodeVariant = void 0);
|
|
600
|
-
const node_opcua_variant_1 = __nccwpck_require__(
|
|
601
|
-
json_basic_encoding_body_functor_1 = __nccwpck_require__(
|
|
620
|
+
const node_opcua_variant_1 = __nccwpck_require__(298),
|
|
621
|
+
json_basic_encoding_body_functor_1 = __nccwpck_require__(694);
|
|
602
622
|
function body(variant, reversible, namespaceArray) {
|
|
603
623
|
const f = (0, json_basic_encoding_body_functor_1.bodyEncodeFunctor)(variant.dataType);
|
|
604
624
|
if (variant.arrayType === node_opcua_variant_1.VariantArrayType.Scalar)
|
|
@@ -621,12 +641,12 @@
|
|
|
621
641
|
pojo
|
|
622
642
|
);
|
|
623
643
|
}),
|
|
624
|
-
(exports.opcuaJsonDecodeVariant = function (pojo) {
|
|
644
|
+
(exports.opcuaJsonDecodeVariant = function (pojo, builder) {
|
|
625
645
|
if (!pojo) return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null });
|
|
626
646
|
const dataType = pojo.Type,
|
|
627
647
|
f = (0, json_basic_encoding_body_functor_1.bodyDecodeFunctor)(dataType);
|
|
628
648
|
if (Array.isArray(pojo.Body)) {
|
|
629
|
-
const value = pojo.Body.map((a) => f(a));
|
|
649
|
+
const value = pojo.Body.map((a) => f(a, builder));
|
|
630
650
|
return pojo.Dimensions
|
|
631
651
|
? new node_opcua_variant_1.Variant({
|
|
632
652
|
arrayType: node_opcua_variant_1.VariantArrayType.Matrix,
|
|
@@ -640,34 +660,34 @@
|
|
|
640
660
|
value: value,
|
|
641
661
|
});
|
|
642
662
|
}
|
|
643
|
-
return new node_opcua_variant_1.Variant({ dataType: dataType, value: f(pojo.Body) });
|
|
663
|
+
return new node_opcua_variant_1.Variant({ dataType: dataType, value: f(pojo.Body, builder) });
|
|
644
664
|
});
|
|
645
665
|
},
|
|
646
|
-
|
|
666
|
+
626: (module) => {
|
|
647
667
|
module.exports = require("node-opcua-data-model");
|
|
648
668
|
},
|
|
649
|
-
|
|
669
|
+
146: (module) => {
|
|
650
670
|
module.exports = require("node-opcua-data-value");
|
|
651
671
|
},
|
|
652
|
-
|
|
672
|
+
647: (module) => {
|
|
653
673
|
module.exports = require("node-opcua-debug");
|
|
654
674
|
},
|
|
655
|
-
|
|
675
|
+
745: (module) => {
|
|
656
676
|
module.exports = require("node-opcua-factory");
|
|
657
677
|
},
|
|
658
|
-
|
|
678
|
+
791: (module) => {
|
|
659
679
|
module.exports = require("node-opcua-nodeid");
|
|
660
680
|
},
|
|
661
|
-
|
|
681
|
+
138: (module) => {
|
|
662
682
|
module.exports = require("node-opcua-numeric-range");
|
|
663
683
|
},
|
|
664
|
-
|
|
684
|
+
912: (module) => {
|
|
665
685
|
module.exports = require("node-opcua-status-code");
|
|
666
686
|
},
|
|
667
|
-
|
|
687
|
+
196: (module) => {
|
|
668
688
|
module.exports = require("node-opcua-types");
|
|
669
689
|
},
|
|
670
|
-
|
|
690
|
+
298: (module) => {
|
|
671
691
|
module.exports = require("node-opcua-variant");
|
|
672
692
|
},
|
|
673
693
|
},
|
|
@@ -685,6 +705,6 @@
|
|
|
685
705
|
return module.exports;
|
|
686
706
|
}
|
|
687
707
|
__nccwpck_require__.ab = __dirname + "/";
|
|
688
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
708
|
+
var __webpack_exports__ = __nccwpck_require__(370);
|
|
689
709
|
module.exports = __webpack_exports__;
|
|
690
710
|
})();
|
|
@@ -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
|
|
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;
|
|
@@ -33,4 +34,13 @@ export interface DataValueJSON {
|
|
|
33
34
|
SourcePicoseconds?: number;
|
|
34
35
|
ServerTimestamp?: Date;
|
|
35
36
|
ServerPicoseconds?: number;
|
|
36
|
-
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param dataValue
|
|
41
|
+
* @param mask
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
export declare function opcuaJsonEncodeDataValueMQTT(dataValue: DataValue, mask: DataSetFieldContentMask): VariantJSONBody | VariantJSON | DataValueJSON | null;
|
|
45
|
+
export declare function opcuaJsonEncodeDataValue(dataValue: DataValue, reversible: boolean): DataValueJSON;
|
|
46
|
+
export declare function opcuaJsonDecodeDataValue(pojo: DataValueJSON | null | undefined, builder?: ExtensionObjectBuilder): DataValue;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ExtensionObject } from "node-opcua-extension-object";
|
|
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,5 +8,25 @@ 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 opcuaJsonEncodeExtensionObjectBody(extensionObject: ExtensionObject | null, reversible?: boolean, namespaceArray?: string[]): ExtensionObjectJSON | Pojo | null;
|
|
11
|
+
export declare function opcuaJsonDecodeExtensionObjectBody(schema: StructuredTypeSchema, body: Pojo, builder?: ExtensionObjectBuilder): Pojo;
|
|
12
|
+
export declare function opcuaJsonEncodeExtensionObjectBody(extensionObject: ExtensionObject | null, reversible?: boolean, namespaceArray?: string[]): ExtensionObjectJSON | Pojo | null;
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* ExtensionObject values shall be encoded as a JSON object with the fields shown:
|
|
16
|
+
*
|
|
17
|
+
* JSON Object - Definition for a ExtensionObject
|
|
18
|
+
* Name Description
|
|
19
|
+
* TypeId The NodeId of a DataTypeEncoding Node formatted using the rules in 5.4.2.10.
|
|
20
|
+
* Encoding The format of the Body field encoded as a JSON number.
|
|
21
|
+
* This value is 0 if the body is Structure encoded as a JSON object (see 5.4.6).
|
|
22
|
+
* This value is 1 if the body is a ByteString value encoded as a JSON string (see 5.4.2.8).
|
|
23
|
+
* This value is 2 if the body is a XmlElement value encoded as a JSON string (see 5.4.2.9).
|
|
24
|
+
* This field is omitted if the value is 0.
|
|
25
|
+
* Body Body of the ExtensionObject. The type of this field is specified by the Encoding field.
|
|
26
|
+
* If the Body is empty, the ExtensionObject is NULL and is omitted or encoded as a JSON null.
|
|
27
|
+
*
|
|
28
|
+
* For the non-reversible form, ExtensionObject values shall be encoded as a JSON object containing only
|
|
29
|
+
* the value of the Body field. The TypeId and Encoding fields are dropped.
|
|
30
|
+
*/
|
|
31
|
+
export declare function opcuaJsonEncodeExtensionObject(extensionObject: ExtensionObject | null, reversible?: boolean, namespaceArray?: string[]): ExtensionObjectJSON | Pojo | null;
|
|
32
|
+
export declare function opcuaJsonDecodeExtensionObject(_pojo: ExtensionObjectJSON, builder?: ExtensionObjectBuilder): ExtensionObject | null;
|
|
@@ -27,4 +27,27 @@ export interface NodeIdJSON {
|
|
|
27
27
|
IdType?: 0 | 1 | 2 | 3;
|
|
28
28
|
Id: number | string;
|
|
29
29
|
Namespace?: number | string;
|
|
30
|
-
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* IdType The IdentifierType encoded as a JSON number.
|
|
34
|
+
* Allowed values are:
|
|
35
|
+
* 0 - UInt32 Identifier encoded as a JSON number.
|
|
36
|
+
* 1 - A String Identifier encoded as a JSON string.
|
|
37
|
+
* 2 - A Guid Identifier.
|
|
38
|
+
* 3 - A ByteString Identifier
|
|
39
|
+
*
|
|
40
|
+
* This field is omitted for UInt32 identifiers.
|
|
41
|
+
*
|
|
42
|
+
* Id The Identifier.
|
|
43
|
+
* The value of the id field specifies the encoding of this field.
|
|
44
|
+
*
|
|
45
|
+
* Namespace The NamespaceIndex for the NodeId.
|
|
46
|
+
* The field is encoded as a JSON number for the reversible encoding.
|
|
47
|
+
* The field is omitted if the NamespaceIndex equals 0.
|
|
48
|
+
* For the non-reversible encoding, the field is the NamespaceUri associated with the NamespaceIndex,
|
|
49
|
+
* encoded as a JSON string.
|
|
50
|
+
* A NamespaceIndex of 1 is always encoded as a JSON number.
|
|
51
|
+
*/
|
|
52
|
+
export declare function opcuaJsonEncodeNodeId(value: NodeId, reversible?: boolean, namespaceArray?: string[]): NodeIdJSON;
|
|
53
|
+
export declare function opcuaJsonDecodeNodeId(pojo: NodeIdJSON, namespaceArray?: string[]): NodeId;
|
|
@@ -26,4 +26,11 @@ import { StatusCode, StatusCodes } from "node-opcua-status-code";
|
|
|
26
26
|
export interface StatusCodeJSON {
|
|
27
27
|
Code?: number | keyof StatusCodes;
|
|
28
28
|
Symbol?: string;
|
|
29
|
-
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param reversible
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
export declare function opcuaJsonEncodeStatusCode(statusCode: StatusCode, reversible?: boolean): StatusCodeJSON | number | undefined;
|
|
36
|
+
export declare function opcuaJsonDecodeStatusCode(pojo: StatusCodeJSON | number | null | undefined): StatusCode;
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.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,21 @@
|
|
|
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.
|
|
18
|
+
"node-opcua-basic-types": "2.60.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.
|
|
23
|
-
"node-opcua-data-value": "2.
|
|
24
|
-
"node-opcua-date-time": "2.
|
|
25
|
-
"node-opcua-extension-object": "2.
|
|
26
|
-
"node-opcua-factory": "2.
|
|
27
|
-
"node-opcua-nodeid": "2.
|
|
28
|
-
"node-opcua-numeric-range": "2.
|
|
21
|
+
"node-opcua-data-model": "2.60.0",
|
|
22
|
+
"node-opcua-data-value": "2.60.0",
|
|
23
|
+
"node-opcua-date-time": "2.60.0",
|
|
24
|
+
"node-opcua-extension-object": "2.60.0",
|
|
25
|
+
"node-opcua-factory": "2.60.0",
|
|
26
|
+
"node-opcua-nodeid": "2.60.0",
|
|
27
|
+
"node-opcua-numeric-range": "2.60.0",
|
|
29
28
|
"node-opcua-status-code": "2.56.0",
|
|
30
|
-
"node-opcua-types": "2.
|
|
31
|
-
"node-opcua-variant": "2.
|
|
29
|
+
"node-opcua-types": "2.60.0",
|
|
30
|
+
"node-opcua-variant": "2.60.0"
|
|
32
31
|
},
|
|
33
|
-
"gitHead": "092c80425fdaf5de81462ce7a225842dfbd13708"
|
|
32
|
+
"gitHead": "092c80425fdaf5de81462ce7a225842dfbd13708",
|
|
33
|
+
"scripts": {}
|
|
34
34
|
}
|