node-opcua-json 0.50.0 → 2.182.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 (78) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +141 -4
  3. package/dist/decode_opcua_json.d.ts +31 -0
  4. package/dist/decode_opcua_json.js +61 -0
  5. package/dist/decode_opcua_json.js.map +1 -0
  6. package/dist/extension_object_constructor.d.ts +46 -0
  7. package/dist/extension_object_constructor.js +26 -0
  8. package/dist/extension_object_constructor.js.map +1 -0
  9. package/dist/index.d.ts +38 -0
  10. package/dist/index.js +66 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/json_basic_encoding_body_functor.d.ts +34 -0
  13. package/dist/json_basic_encoding_body_functor.js +170 -0
  14. package/dist/json_basic_encoding_body_functor.js.map +1 -0
  15. package/dist/json_basic_encoding_decoding_byte_string.d.ts +27 -0
  16. package/dist/json_basic_encoding_decoding_byte_string.js +27 -0
  17. package/dist/json_basic_encoding_decoding_byte_string.js.map +1 -0
  18. package/dist/json_basic_encoding_decoding_data_value.d.ts +80 -0
  19. package/dist/json_basic_encoding_decoding_data_value.js +289 -0
  20. package/dist/json_basic_encoding_decoding_data_value.js.map +1 -0
  21. package/dist/json_basic_encoding_decoding_date_time.d.ts +26 -0
  22. package/dist/json_basic_encoding_decoding_date_time.js +43 -0
  23. package/dist/json_basic_encoding_decoding_date_time.js.map +1 -0
  24. package/dist/json_basic_encoding_decoding_extension_object.d.ts +65 -0
  25. package/dist/json_basic_encoding_decoding_extension_object.js +461 -0
  26. package/dist/json_basic_encoding_decoding_extension_object.js.map +1 -0
  27. package/dist/json_basic_encoding_decoding_int64.d.ts +30 -0
  28. package/dist/json_basic_encoding_decoding_int64.js +56 -0
  29. package/dist/json_basic_encoding_decoding_int64.js.map +1 -0
  30. package/dist/json_basic_encoding_decoding_localizedtext.d.ts +33 -0
  31. package/dist/json_basic_encoding_decoding_localizedtext.js +62 -0
  32. package/dist/json_basic_encoding_decoding_localizedtext.js.map +1 -0
  33. package/dist/json_basic_encoding_decoding_nodeid.d.ts +42 -0
  34. package/dist/json_basic_encoding_decoding_nodeid.js +298 -0
  35. package/dist/json_basic_encoding_decoding_nodeid.js.map +1 -0
  36. package/dist/json_basic_encoding_decoding_qualifiedname.d.ts +35 -0
  37. package/dist/json_basic_encoding_decoding_qualifiedname.js +126 -0
  38. package/dist/json_basic_encoding_decoding_qualifiedname.js.map +1 -0
  39. package/dist/json_basic_encoding_decoding_statuscode.d.ts +39 -0
  40. package/dist/json_basic_encoding_decoding_statuscode.js +139 -0
  41. package/dist/json_basic_encoding_decoding_statuscode.js.map +1 -0
  42. package/dist/json_basic_encoding_decoding_variant.d.ts +101 -0
  43. package/dist/json_basic_encoding_decoding_variant.js +234 -0
  44. package/dist/json_basic_encoding_decoding_variant.js.map +1 -0
  45. package/dist/json_encoding_scheme.d.ts +50 -0
  46. package/dist/json_encoding_scheme.js +117 -0
  47. package/dist/json_encoding_scheme.js.map +1 -0
  48. package/package.json +57 -35
  49. package/source/decode_opcua_json.ts +67 -0
  50. package/source/extension_object_constructor.ts +48 -0
  51. package/source/index.ts +59 -0
  52. package/source/json_basic_encoding_body_functor.ts +190 -0
  53. package/source/json_basic_encoding_decoding_byte_string.ts +52 -0
  54. package/source/json_basic_encoding_decoding_data_value.ts +392 -0
  55. package/source/json_basic_encoding_decoding_date_time.ts +42 -0
  56. package/source/json_basic_encoding_decoding_extension_object.ts +531 -0
  57. package/source/json_basic_encoding_decoding_int64.ts +74 -0
  58. package/source/json_basic_encoding_decoding_localizedtext.ts +69 -0
  59. package/source/json_basic_encoding_decoding_nodeid.ts +356 -0
  60. package/source/json_basic_encoding_decoding_qualifiedname.ts +144 -0
  61. package/source/json_basic_encoding_decoding_statuscode.ts +151 -0
  62. package/source/json_basic_encoding_decoding_variant.ts +339 -0
  63. package/source/json_encoding_scheme.ts +114 -0
  64. package/LICENSE.md +0 -40
  65. package/dist2/decode_opcua_json.d.ts +0 -12
  66. package/dist2/index.d.ts +0 -17
  67. package/dist2/index.js +0 -1
  68. package/dist2/json_basic_encoding_body_functor.d.ts +0 -14
  69. package/dist2/json_basic_encoding_decoding_byte_string.d.ts +0 -8
  70. package/dist2/json_basic_encoding_decoding_data_value.d.ts +0 -26
  71. package/dist2/json_basic_encoding_decoding_date_time.d.ts +0 -6
  72. package/dist2/json_basic_encoding_decoding_extension_object.d.ts +0 -32
  73. package/dist2/json_basic_encoding_decoding_int64.d.ts +0 -9
  74. package/dist2/json_basic_encoding_decoding_localizedtext.d.ts +0 -14
  75. package/dist2/json_basic_encoding_decoding_nodeid.d.ts +0 -33
  76. package/dist2/json_basic_encoding_decoding_qualifiedname.d.ts +0 -14
  77. package/dist2/json_basic_encoding_decoding_statuscode.d.ts +0 -16
  78. package/dist2/json_basic_encoding_decoding_variant.d.ts +0 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022-2024 Sterfive SAS - 833264583 RCS ORLEANS - France (https://www.sterfive.com)
4
+
5
+ Copyright (c) 2014-2022 Etienne Rossignon
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
8
+ this software and associated documentation files (the "Software"), to deal in
9
+ the Software without restriction, including without limitation the rights to
10
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11
+ the Software, and to permit persons to whom the Software is furnished to do so,
12
+ subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,10 +1,147 @@
1
+ # node-opcua-json
1
2
 
3
+ The **OPC UA JSON encoding**, OPC 10000-6 clause 5.4: encoders and decoders for every built-in
4
+ type, for `Variant`, `DataValue` and `ExtensionObject`, across all four encoding schemes the
5
+ specification has defined.
2
6
 
3
- ## module: node-opcua-json
7
+ see http://node-opcua.github.io/
4
8
 
5
- - the compiled version of this module is available under the MIT license (transpiled javascript).
9
+ ```bash
10
+ npm install node-opcua-json
11
+ ```
6
12
 
7
- - the full source code (in typescript form, including documentation, source code, test and examples) of this module is available under the STERFIVE EULA.
13
+ ## Why
8
14
 
9
- - you need to acquire a licence and/or a professional support on this module. Contact Sterfive at contact@sterfive.com.
15
+ JSON is how OPC UA data leaves the OPC UA world. It is the wire form of PubSub over MQTT and
16
+ AMQP (OPC 10000-14), the form a `PubSubConfigurationDataType` is exchanged in, and the form a
17
+ `Variant` takes inside an Annex I JSON nodeset. Anywhere a value has to survive a hop through a
18
+ broker, a database or another vendor's stack, this is the encoding it travels in.
10
19
 
20
+ The details are easy to get subtly wrong: a `UInt64` is a string, not a number; a NodeId carries
21
+ a namespace **URI**, not the index it had in the source document; and the field names changed
22
+ between 1.04 and 1.05. This package is the single place the SDK implements clause 5.4, so every
23
+ consumer agrees on those answers.
24
+
25
+ ## Quick start
26
+
27
+ ```ts
28
+ import { DataType, Variant } from "node-opcua-variant";
29
+ import { JsonEncodingScheme, opcuaJsonEncodeVariant } from "node-opcua-json";
30
+
31
+ const namespaceArray = ["http://opcfoundation.org/UA/"];
32
+ const v = new Variant({ dataType: DataType.Byte, value: 42 });
33
+
34
+ opcuaJsonEncodeVariant(v, JsonEncodingScheme.Compact, namespaceArray);
35
+ // { UaType: 3, Value: 42 }
36
+
37
+ opcuaJsonEncodeVariant(v, JsonEncodingScheme.DeprecatedReversible, namespaceArray);
38
+ // { Type: 3, Body: 42 }
39
+
40
+ opcuaJsonEncodeVariant(v, JsonEncodingScheme.DeprecatedNonReversible, namespaceArray);
41
+ // 42
42
+ ```
43
+
44
+ The `namespaceArray` is not decoration. NodeIds and QualifiedNames encode with their namespace
45
+ URI, so both directions need the document's namespace table to map an index to a URI and back.
46
+ Pass the array the document declares, not the one your address space happens to have.
47
+
48
+ ## The four schemes
49
+
50
+ Part 6 has changed JSON encoding once, and both generations are in the field, so both are here.
51
+
52
+ | `JsonEncodingScheme` | version | a `Variant` looks like |
53
+ |---|---|---|
54
+ | `DeprecatedNonReversible` | 1.04 | the bare value, with no type at all |
55
+ | `DeprecatedReversible` | 1.04 | `{ Type, Body, Dimensions? }` |
56
+ | `Verbose` | 1.05 | `{ UaType, Value, UaDimensions? }`, every field written |
57
+ | `Compact` | 1.05 | the same, with every field equal to its type's default omitted |
58
+
59
+ `JsonEncoderMode104` (`Reversible` / `NonReversible`) and `JsonEncoderMode105` (`Verbose` /
60
+ `Compact`) are aliases into that same enum, so a 1.05-only API can take a parameter that cannot
61
+ express a 1.04 mode. `toJsonEncodingScheme()` widens either back.
62
+
63
+ Two consequences worth knowing before you diff output against another stack:
64
+
65
+ - The 1.05 field names are `UaType` / `Value` / `UaDimensions`. They changed with the encoding,
66
+ so a 1.05 reader will not find `Type` or `Body`.
67
+ - `Compact` omits defaults, so a `Byte` of `0` encodes as `{ UaType: 3 }` with no `Value` at all,
68
+ while `Verbose` writes `{ UaType: 3, Value: 0 }`. Decoding is unaffected; byte-for-byte
69
+ comparison against a Verbose writer is not.
70
+
71
+ When a PubSub subscriber has to work out which scheme it is being sent,
72
+ `JsonDataSetMessageContentMaskToJsonEncodingScheme` reads the two `FieldEncoding` bits of
73
+ OPC 10000-14 Table 112, and `JsonEncodingSchemeToJsonDataSetMessageContentMask` writes them.
74
+
75
+ ## Decoding structures
76
+
77
+ Decoding a `Variant` that contains a structure means constructing that structure, and only the
78
+ caller knows how to find its class. That is the whole of the `ExtensionObjectBuilder` interface:
79
+
80
+ ```ts
81
+ interface ExtensionObjectBuilder {
82
+ getExtensionObjectConstructor(dataTypeNodeId: NodeId): ExtensionObjectConstructorFuncWithSchema;
83
+ }
84
+ ```
85
+
86
+ ```ts
87
+ import { opcuaJsonDecodeVariant, type VariantJSON105 } from "node-opcua-json";
88
+
89
+ const variant = opcuaJsonDecodeVariant(json as VariantJSON105, builder, namespaceArray);
90
+ ```
91
+
92
+ For a model with custom structures, `builder` resolves the DataType NodeId against a live
93
+ address space or a dynamically built factory. For a model with only built-in types, a builder
94
+ that throws is enough, because it is never reached.
95
+
96
+ Handing the whole thing over at once, when you already know the type:
97
+
98
+ ```ts
99
+ import { PubSubConnectionDataType } from "node-opcua-types";
100
+ import { decodeOPCUA_JSON } from "node-opcua-json";
101
+
102
+ const config = decodeOPCUA_JSON(PubSubConnectionDataType, JSON.parse(text));
103
+ config.address; // a NetworkAddressUrlDataType, reconstructed from its UaTypeId
104
+ ```
105
+
106
+ The test suite reads configuration files produced by the .NET stack, so this path is checked
107
+ against another implementation rather than only against itself.
108
+
109
+ ## API
110
+
111
+ Every built-in type has an `opcuaJsonEncodeX` / `opcuaJsonDecodeX` pair, and each takes the
112
+ scheme, so one call site serves all four.
113
+
114
+ | area | exports |
115
+ |---|---|
116
+ | Variant | `opcuaJsonEncodeVariant`, `opcuaJsonDecodeVariant`, the `104` / `105` pairs, `VariantJSON`, `VariantJSON104`, `VariantJSON105` |
117
+ | DataValue | `opcuaJsonEncodeDataValue`, `opcuaJsonDecodeDataValue`, `opcuaJsonEncodeDataValueMQTT`, `DataValueJSON105` |
118
+ | ExtensionObject | `opcuaJsonEncodeExtensionObject`, `opcuaJsonDecodeExtensionObject`, the `...Body` pair, `makeBody`, `ExtensionObjectJSON104`, `ExtensionObjectJSON105` |
119
+ | NodeId | `opcuaJsonEncodeNodeId`, `opcuaJsonDecodeNodeId`, the `ExpandedNodeId` pair, `opcuaJsonEncodeNodeIdAsString` |
120
+ | scalars | `Int64`, `UInt64`, `ByteString`, `DateTime`, `LocalizedText`, `QualifiedName`, `StatusCode` |
121
+ | structures | `decodeOPCUA_JSON`, `decodeOPCUA_JSONOld` |
122
+ | schemes | `JsonEncodingScheme`, `JsonEncoderMode104`, `JsonEncoderMode105`, `toJsonEncodingScheme`, `makeDataValueEncodingEnum`, the two `JsonDataSetMessageContentMask` converters |
123
+ | dispatch | `bodyEncodeFunctor(dataType)`, `bodyDecodeFunctor(dataType)`, `EncoderFunc`, `DecoderFunc`, `ExtensionObjectBuilder` |
124
+
125
+ `opcuaJsonEncodeVariant` and `opcuaJsonDecodeVariant` are overloaded across all four schemes and
126
+ so cannot express the 1.05 object shape for Verbose alone. Where you need that exact type, reach
127
+ for the explicit `opcuaJsonEncodeVariant105` / `opcuaJsonDecodeVariant105`, or the matching
128
+ `...104` pair.
129
+
130
+ ## Position in the SDK
131
+
132
+ This package sits **low in the dependency graph**, on the type and factory packages and nothing
133
+ else. It does not depend on `node-opcua-address-space`, which is what allows the address space to
134
+ depend on it, and in turn lets
135
+ [`node-opcua-uanodeset-json`](../node-opcua-uanodeset-json) encode nodeset values with the same
136
+ codec the PubSub layer uses.
137
+
138
+ The `ExtensionObjectBuilder` parameter is the price of that position: rather than reaching for an
139
+ address space itself, the package asks the caller to resolve structures.
140
+
141
+ ## Provenance and licence
142
+
143
+ This code was written for `@sterfive/node-opcua-json`, part of the node-opcua-pubsub work, and is
144
+ contributed here by its copyright holder under **MIT**, so that JSON encoding is not a licensing
145
+ question for anyone building on the SDK.
146
+
147
+ MIT
@@ -0,0 +1,31 @@
1
+ /**
2
+ * ==========================================================================
3
+ * Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
+ * IN THE SOFTWARE.
22
+ * ==========================================================================
23
+ */
24
+ import type { ExtensionObject } from "node-opcua-extension-object";
25
+ import { type ConstructorFuncWithSchema } from "node-opcua-factory";
26
+ import { type NodeIdLike } from "node-opcua-nodeid";
27
+ export type Pojo = {
28
+ [key: string]: unknown;
29
+ };
30
+ export declare function decodeOPCUA_JSONOld<T extends ExtensionObject>(dataType: NodeIdLike, pojo: Pojo): T | null;
31
+ export declare function decodeOPCUA_JSON<T extends ConstructorFuncWithSchema>(Constructor: T, pojo: Pojo): InstanceType<T>;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /**
3
+ * ==========================================================================
4
+ * Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
+ * IN THE SOFTWARE.
23
+ * ==========================================================================
24
+ */
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.decodeOPCUA_JSONOld = decodeOPCUA_JSONOld;
27
+ exports.decodeOPCUA_JSON = decodeOPCUA_JSON;
28
+ const node_opcua_factory_1 = require("node-opcua-factory");
29
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
30
+ const json_basic_encoding_decoding_extension_object_js_1 = require("./json_basic_encoding_decoding_extension_object.js");
31
+ const faekeBuilder = {
32
+ getExtensionObjectConstructor(_dataTypeNodeId) {
33
+ return null;
34
+ }
35
+ };
36
+ function decodeOPCUA_JSONOld(dataType, pojo) {
37
+ const factory = (0, node_opcua_factory_1.getStandardDataTypeFactory)();
38
+ const schema = factory.getStructureInfoForDataType((0, node_opcua_nodeid_1.resolveNodeId)(dataType));
39
+ if (!schema)
40
+ return null;
41
+ const Constructor = schema.constructor;
42
+ if (!Constructor) {
43
+ return null;
44
+ }
45
+ const adaptedBody = (0, json_basic_encoding_decoding_extension_object_js_1.opcuaJsonDecodeExtensionObjectBody)(Constructor.schema, pojo, faekeBuilder, []);
46
+ if (Array.isArray(adaptedBody)) {
47
+ throw new Error("decodeOPCUA_JSONOld: adaptedBody is an array, expected an object");
48
+ }
49
+ const extObj = new Constructor(adaptedBody);
50
+ return extObj;
51
+ }
52
+ function decodeOPCUA_JSON(Constructor, pojo) {
53
+ const adaptedBody = (0, json_basic_encoding_decoding_extension_object_js_1.opcuaJsonDecodeExtensionObjectBody)(Constructor.schema, pojo, faekeBuilder, []);
54
+ if (Array.isArray(adaptedBody)) {
55
+ // If the adapted body is an empty array, we return null
56
+ throw new Error("decodeOPCUA_JSONOld: adaptedBody is an array, expected an object");
57
+ }
58
+ const extObj = new Constructor(adaptedBody);
59
+ return extObj;
60
+ }
61
+ //# sourceMappingURL=decode_opcua_json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode_opcua_json.js","sourceRoot":"","sources":["../source/decode_opcua_json.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;AAgBH,kDAiBC;AAED,4CASC;AAzCD,2DAAgG;AAChG,yDAAgF;AAGhF,yHAAwG;AAIxG,MAAM,YAAY,GAAG;IACjB,6BAA6B,CAAC,eAAuB;QACjD,OAAO,IAA2D,CAAC;IACvE,CAAC;CACJ,CAAC;AACF,SAAgB,mBAAmB,CAA4B,QAAoB,EAAE,IAAU;IAC3F,MAAM,OAAO,GAAG,IAAA,+CAA0B,GAAE,CAAC;IAE7C,MAAM,MAAM,GAAG,OAAO,CAAC,2BAA2B,CAAC,IAAA,iCAAa,EAAC,QAAQ,CAAC,CAAC,CAAC;IAC5E,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzB,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACvC,IAAI,CAAC,WAAW,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,WAAW,GAAG,IAAA,qFAAkC,EAAC,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;IACnG,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;IACxF,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,WAAW,CAAC,CAAC;IAC5C,OAAO,MAAW,CAAC;AACvB,CAAC;AAED,SAAgB,gBAAgB,CAAsC,WAAc,EAAE,IAAU;IAC5F,MAAM,WAAW,GAAG,IAAA,qFAAkC,EAAC,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;IAEnG,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,wDAAwD;QACxD,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;IACxF,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,WAAW,CAAC,CAAC;IAC5C,OAAO,MAAyB,CAAC;AACrC,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * ==========================================================================
3
+ * Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
+ * IN THE SOFTWARE.
22
+ * ==========================================================================
23
+ */
24
+ import type { ExtensionObject } from "node-opcua-extension-object";
25
+ import type { IStructuredTypeSchema } from "node-opcua-factory";
26
+ import type { ExpandedNodeId } from "node-opcua-nodeid";
27
+ /**
28
+ * the constructor of a concrete ExtensionObject, together with the schema that describes it.
29
+ *
30
+ * This is `ConstructorFuncWithSchema` from node-opcua-factory narrowed to construct an
31
+ * ExtensionObject rather than an IBaseUAObject, which is what a JSON decoder needs: it hands back
32
+ * what it built, and the caller is entitled to an ExtensionObject.
33
+ *
34
+ * It is declared here rather than imported because the narrowing needs `ExtensionObject`, and
35
+ * node-opcua-factory cannot name that type without depending on node-opcua-extension-object, which
36
+ * depends on it. node-opcua-address-space declares an identical interface for the same reason; it
37
+ * could import this one instead, now that this package sits below it.
38
+ */
39
+ export interface ExtensionObjectConstructorFuncWithSchema {
40
+ new (options?: Record<string, unknown>): ExtensionObject;
41
+ schema: IStructuredTypeSchema;
42
+ possibleFields: string[];
43
+ encodingDefaultBinary: ExpandedNodeId;
44
+ encodingDefaultXml: ExpandedNodeId;
45
+ encodingDefaultJson?: ExpandedNodeId;
46
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ /**
3
+ * ==========================================================================
4
+ * Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
+ * IN THE SOFTWARE.
23
+ * ==========================================================================
24
+ */
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ //# sourceMappingURL=extension_object_constructor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension_object_constructor.js","sourceRoot":"","sources":["../source/extension_object_constructor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * ==========================================================================
3
+ * Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
+ * IN THE SOFTWARE.
22
+ * ==========================================================================
23
+ */
24
+ export * from "./decode_opcua_json.js";
25
+ export type { ExtensionObjectConstructorFuncWithSchema } from "./extension_object_constructor.js";
26
+ export * from "./json_basic_encoding_body_functor.js";
27
+ export * from "./json_basic_encoding_decoding_byte_string.js";
28
+ export { type DataValueJSON, type DataValueJSON104, type DataValueJSON105, opcuaJsonDecodeDataValue, opcuaJsonEncodeDataValue, opcuaJsonEncodeDataValueMQTT } from "./json_basic_encoding_decoding_data_value.js";
29
+ export * from "./json_basic_encoding_decoding_extension_object.js";
30
+ export { opcuaJsonDecodeExtensionObject, opcuaJsonEncodeExtensionObject } from "./json_basic_encoding_decoding_extension_object.js";
31
+ export * from "./json_basic_encoding_decoding_int64.js";
32
+ export * from "./json_basic_encoding_decoding_localizedtext.js";
33
+ export * from "./json_basic_encoding_decoding_nodeid.js";
34
+ export * from "./json_basic_encoding_decoding_qualifiedname.js";
35
+ export * from "./json_basic_encoding_decoding_statuscode.js";
36
+ export * from "./json_basic_encoding_decoding_statuscode.js";
37
+ export { opcuaJsonDecodeVariant, opcuaJsonDecodeVariant105, opcuaJsonEncodeVariant, opcuaJsonEncodeVariant105, type VariantJSON, type VariantJSON104, type VariantJSON105 } from "./json_basic_encoding_decoding_variant.js";
38
+ export * from "./json_encoding_scheme.js";
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ /**
3
+ * ==========================================================================
4
+ * Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
+ * IN THE SOFTWARE.
23
+ * ==========================================================================
24
+ */
25
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ var desc = Object.getOwnPropertyDescriptor(m, k);
28
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
29
+ desc = { enumerable: true, get: function() { return m[k]; } };
30
+ }
31
+ Object.defineProperty(o, k2, desc);
32
+ }) : (function(o, m, k, k2) {
33
+ if (k2 === undefined) k2 = k;
34
+ o[k2] = m[k];
35
+ }));
36
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
37
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.opcuaJsonEncodeVariant105 = exports.opcuaJsonEncodeVariant = exports.opcuaJsonDecodeVariant105 = exports.opcuaJsonDecodeVariant = exports.opcuaJsonEncodeExtensionObject = exports.opcuaJsonDecodeExtensionObject = exports.opcuaJsonEncodeDataValueMQTT = exports.opcuaJsonEncodeDataValue = exports.opcuaJsonDecodeDataValue = void 0;
41
+ __exportStar(require("./decode_opcua_json.js"), exports);
42
+ __exportStar(require("./json_basic_encoding_body_functor.js"), exports);
43
+ __exportStar(require("./json_basic_encoding_decoding_byte_string.js"), exports);
44
+ var json_basic_encoding_decoding_data_value_js_1 = require("./json_basic_encoding_decoding_data_value.js");
45
+ Object.defineProperty(exports, "opcuaJsonDecodeDataValue", { enumerable: true, get: function () { return json_basic_encoding_decoding_data_value_js_1.opcuaJsonDecodeDataValue; } });
46
+ Object.defineProperty(exports, "opcuaJsonEncodeDataValue", { enumerable: true, get: function () { return json_basic_encoding_decoding_data_value_js_1.opcuaJsonEncodeDataValue; } });
47
+ Object.defineProperty(exports, "opcuaJsonEncodeDataValueMQTT", { enumerable: true, get: function () { return json_basic_encoding_decoding_data_value_js_1.opcuaJsonEncodeDataValueMQTT; } });
48
+ __exportStar(require("./json_basic_encoding_decoding_extension_object.js"), exports);
49
+ var json_basic_encoding_decoding_extension_object_js_1 = require("./json_basic_encoding_decoding_extension_object.js");
50
+ Object.defineProperty(exports, "opcuaJsonDecodeExtensionObject", { enumerable: true, get: function () { return json_basic_encoding_decoding_extension_object_js_1.opcuaJsonDecodeExtensionObject; } });
51
+ Object.defineProperty(exports, "opcuaJsonEncodeExtensionObject", { enumerable: true, get: function () { return json_basic_encoding_decoding_extension_object_js_1.opcuaJsonEncodeExtensionObject; } });
52
+ __exportStar(require("./json_basic_encoding_decoding_int64.js"), exports);
53
+ __exportStar(require("./json_basic_encoding_decoding_localizedtext.js"), exports);
54
+ __exportStar(require("./json_basic_encoding_decoding_nodeid.js"), exports);
55
+ __exportStar(require("./json_basic_encoding_decoding_qualifiedname.js"), exports);
56
+ __exportStar(require("./json_basic_encoding_decoding_statuscode.js"), exports);
57
+ __exportStar(require("./json_basic_encoding_decoding_statuscode.js"), exports);
58
+ var json_basic_encoding_decoding_variant_js_1 = require("./json_basic_encoding_decoding_variant.js");
59
+ Object.defineProperty(exports, "opcuaJsonDecodeVariant", { enumerable: true, get: function () { return json_basic_encoding_decoding_variant_js_1.opcuaJsonDecodeVariant; } });
60
+ // the explicit 1.05 entry points: the dispatcher above overloads Compact and Verbose together
61
+ // and so cannot return the 1.05 object shape for Verbose alone
62
+ Object.defineProperty(exports, "opcuaJsonDecodeVariant105", { enumerable: true, get: function () { return json_basic_encoding_decoding_variant_js_1.opcuaJsonDecodeVariant105; } });
63
+ Object.defineProperty(exports, "opcuaJsonEncodeVariant", { enumerable: true, get: function () { return json_basic_encoding_decoding_variant_js_1.opcuaJsonEncodeVariant; } });
64
+ Object.defineProperty(exports, "opcuaJsonEncodeVariant105", { enumerable: true, get: function () { return json_basic_encoding_decoding_variant_js_1.opcuaJsonEncodeVariant105; } });
65
+ __exportStar(require("./json_encoding_scheme.js"), exports);
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;;AAEH,yDAAuC;AAEvC,wEAAsD;AACtD,gFAA8D;AAC9D,2GAOsD;AAHlD,sJAAA,wBAAwB,OAAA;AACxB,sJAAA,wBAAwB,OAAA;AACxB,0JAAA,4BAA4B,OAAA;AAEhC,qFAAmE;AACnE,uHAG4D;AAFxD,kKAAA,8BAA8B,OAAA;AAC9B,kKAAA,8BAA8B,OAAA;AAElC,0EAAwD;AACxD,kFAAgE;AAChE,2EAAyD;AACzD,kFAAgE;AAChE,+EAA6D;AAC7D,+EAA6D;AAC7D,qGAUmD;AAT/C,iJAAA,sBAAsB,OAAA;AACtB,8FAA8F;AAC9F,+DAA+D;AAC/D,oJAAA,yBAAyB,OAAA;AACzB,iJAAA,sBAAsB,OAAA;AACtB,oJAAA,yBAAyB,OAAA;AAK7B,4DAA0C"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * ==========================================================================
3
+ * Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
+ * IN THE SOFTWARE.
22
+ * ==========================================================================
23
+ */
24
+ import type { NodeId } from "node-opcua-nodeid";
25
+ import { DataType } from "node-opcua-variant";
26
+ import type { ExtensionObjectConstructorFuncWithSchema } from "./extension_object_constructor.js";
27
+ import { JsonEncodingScheme } from "./json_encoding_scheme.js";
28
+ export type EncoderFunc<T> = (t: T, encodingScheme: JsonEncodingScheme, namespaceArray?: string[]) => unknown;
29
+ export interface ExtensionObjectBuilder {
30
+ getExtensionObjectConstructor(dataTypeNodeId: NodeId): ExtensionObjectConstructorFuncWithSchema;
31
+ }
32
+ export type DecoderFunc<T> = (t: T, builder: ExtensionObjectBuilder, namespaceArray: string[]) => unknown;
33
+ export declare function bodyEncodeFunctor(dataType: DataType): EncoderFunc<unknown>;
34
+ export declare function bodyDecodeFunctor(dataType: DataType): DecoderFunc<unknown>;