node-opcua-json 0.50.0 → 2.182.2

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 (86) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +168 -4
  3. package/dist/104/index.d.ts +56 -0
  4. package/dist/104/index.js +93 -0
  5. package/dist/104/index.js.map +1 -0
  6. package/dist/105/index.d.ts +55 -0
  7. package/dist/105/index.js +95 -0
  8. package/dist/105/index.js.map +1 -0
  9. package/dist/decode_opcua_json.d.ts +31 -0
  10. package/dist/decode_opcua_json.js +61 -0
  11. package/dist/decode_opcua_json.js.map +1 -0
  12. package/dist/extension_object_constructor.d.ts +46 -0
  13. package/dist/extension_object_constructor.js +26 -0
  14. package/dist/extension_object_constructor.js.map +1 -0
  15. package/dist/index.d.ts +39 -0
  16. package/dist/index.js +100 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/json_basic_encoding_body_functor.d.ts +34 -0
  19. package/dist/json_basic_encoding_body_functor.js +170 -0
  20. package/dist/json_basic_encoding_body_functor.js.map +1 -0
  21. package/dist/json_basic_encoding_decoding_byte_string.d.ts +27 -0
  22. package/dist/json_basic_encoding_decoding_byte_string.js +27 -0
  23. package/dist/json_basic_encoding_decoding_byte_string.js.map +1 -0
  24. package/dist/json_basic_encoding_decoding_data_value.d.ts +81 -0
  25. package/dist/json_basic_encoding_decoding_data_value.js +290 -0
  26. package/dist/json_basic_encoding_decoding_data_value.js.map +1 -0
  27. package/dist/json_basic_encoding_decoding_date_time.d.ts +26 -0
  28. package/dist/json_basic_encoding_decoding_date_time.js +43 -0
  29. package/dist/json_basic_encoding_decoding_date_time.js.map +1 -0
  30. package/dist/json_basic_encoding_decoding_extension_object.d.ts +65 -0
  31. package/dist/json_basic_encoding_decoding_extension_object.js +461 -0
  32. package/dist/json_basic_encoding_decoding_extension_object.js.map +1 -0
  33. package/dist/json_basic_encoding_decoding_int64.d.ts +30 -0
  34. package/dist/json_basic_encoding_decoding_int64.js +56 -0
  35. package/dist/json_basic_encoding_decoding_int64.js.map +1 -0
  36. package/dist/json_basic_encoding_decoding_localizedtext.d.ts +33 -0
  37. package/dist/json_basic_encoding_decoding_localizedtext.js +62 -0
  38. package/dist/json_basic_encoding_decoding_localizedtext.js.map +1 -0
  39. package/dist/json_basic_encoding_decoding_nodeid.d.ts +73 -0
  40. package/dist/json_basic_encoding_decoding_nodeid.js +314 -0
  41. package/dist/json_basic_encoding_decoding_nodeid.js.map +1 -0
  42. package/dist/json_basic_encoding_decoding_qualifiedname.d.ts +35 -0
  43. package/dist/json_basic_encoding_decoding_qualifiedname.js +126 -0
  44. package/dist/json_basic_encoding_decoding_qualifiedname.js.map +1 -0
  45. package/dist/json_basic_encoding_decoding_statuscode.d.ts +39 -0
  46. package/dist/json_basic_encoding_decoding_statuscode.js +139 -0
  47. package/dist/json_basic_encoding_decoding_statuscode.js.map +1 -0
  48. package/dist/json_basic_encoding_decoding_variant.d.ts +101 -0
  49. package/dist/json_basic_encoding_decoding_variant.js +234 -0
  50. package/dist/json_basic_encoding_decoding_variant.js.map +1 -0
  51. package/dist/json_encoding_scheme.d.ts +50 -0
  52. package/dist/json_encoding_scheme.js +117 -0
  53. package/dist/json_encoding_scheme.js.map +1 -0
  54. package/package.json +90 -35
  55. package/source/104/index.ts +117 -0
  56. package/source/105/index.ts +118 -0
  57. package/source/decode_opcua_json.ts +67 -0
  58. package/source/extension_object_constructor.ts +48 -0
  59. package/source/index.ts +71 -0
  60. package/source/json_basic_encoding_body_functor.ts +190 -0
  61. package/source/json_basic_encoding_decoding_byte_string.ts +52 -0
  62. package/source/json_basic_encoding_decoding_data_value.ts +392 -0
  63. package/source/json_basic_encoding_decoding_date_time.ts +42 -0
  64. package/source/json_basic_encoding_decoding_extension_object.ts +531 -0
  65. package/source/json_basic_encoding_decoding_int64.ts +74 -0
  66. package/source/json_basic_encoding_decoding_localizedtext.ts +69 -0
  67. package/source/json_basic_encoding_decoding_nodeid.ts +375 -0
  68. package/source/json_basic_encoding_decoding_qualifiedname.ts +144 -0
  69. package/source/json_basic_encoding_decoding_statuscode.ts +151 -0
  70. package/source/json_basic_encoding_decoding_variant.ts +339 -0
  71. package/source/json_encoding_scheme.ts +114 -0
  72. package/LICENSE.md +0 -40
  73. package/dist2/decode_opcua_json.d.ts +0 -12
  74. package/dist2/index.d.ts +0 -17
  75. package/dist2/index.js +0 -1
  76. package/dist2/json_basic_encoding_body_functor.d.ts +0 -14
  77. package/dist2/json_basic_encoding_decoding_byte_string.d.ts +0 -8
  78. package/dist2/json_basic_encoding_decoding_data_value.d.ts +0 -26
  79. package/dist2/json_basic_encoding_decoding_date_time.d.ts +0 -6
  80. package/dist2/json_basic_encoding_decoding_extension_object.d.ts +0 -32
  81. package/dist2/json_basic_encoding_decoding_int64.d.ts +0 -9
  82. package/dist2/json_basic_encoding_decoding_localizedtext.d.ts +0 -14
  83. package/dist2/json_basic_encoding_decoding_nodeid.d.ts +0 -33
  84. package/dist2/json_basic_encoding_decoding_qualifiedname.d.ts +0 -14
  85. package/dist2/json_basic_encoding_decoding_statuscode.d.ts +0 -16
  86. 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,174 @@
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
+ ## One edition only: `node-opcua-json/104` and `node-opcua-json/105`
76
+
77
+ The root entry point is deliberately flexible: it takes a `JsonEncodingScheme` and dispatches
78
+ to whichever edition it names. Code that speaks a single edition, such as a PubSub publisher
79
+ pinned to 1.05 or a bridge to a 1.04-only stack, is better off importing that edition directly.
80
+
81
+ ```ts
82
+ import { opcuaJsonEncodeDataValue, JsonEncoderMode, type DataValueJSON } from "node-opcua-json/105";
83
+
84
+ const pojo: DataValueJSON = opcuaJsonEncodeDataValue(dataValue, JsonEncoderMode.Compact, namespaceArray);
85
+ // { UaType: 11, Value: 3.5, ... } and nothing else can come out
86
+ ```
87
+
88
+ Each subpath exposes the whole API under **version-free names**: `opcuaJsonEncodeDataValue`,
89
+ `opcuaJsonDecodeVariant`, `opcuaJsonEncodeStatusCode`, `opcuaJsonEncodeNodeId`,
90
+ `opcuaJsonEncodeExtensionObject`, the `DataValueJSON` / `VariantJSON` / `NodeIdJSON` /
91
+ `ExtensionObjectJSON` types and a `JsonEncoderMode` enum, every one bound to that edition alone.
92
+ The mode parameter is the edition's own two-value enum, so a 1.04 mode is a type error in the
93
+ 1.05 realm and vice versa, and the JSON types are the edition's exact shapes rather than a union.
94
+ Version-agnostic scalars (`Int64`, `ByteString`, `DateTime`, ...) are the same functions in both.
95
+
96
+ Switching an existing file from one edition to the other is a one-line change of the import
97
+ path. The root package keeps the suffixed names (`opcuaJsonEncodeDataValue104`,
98
+ `opcuaJsonEncodeVariant105`, ...) and also exposes both realms as the `v104` and `v105`
99
+ namespaces for code that has to handle both in one place.
100
+
101
+ ## Decoding structures
102
+
103
+ Decoding a `Variant` that contains a structure means constructing that structure, and only the
104
+ caller knows how to find its class. That is the whole of the `ExtensionObjectBuilder` interface:
105
+
106
+ ```ts
107
+ interface ExtensionObjectBuilder {
108
+ getExtensionObjectConstructor(dataTypeNodeId: NodeId): ExtensionObjectConstructorFuncWithSchema;
109
+ }
110
+ ```
111
+
112
+ ```ts
113
+ import { opcuaJsonDecodeVariant, type VariantJSON105 } from "node-opcua-json";
114
+
115
+ const variant = opcuaJsonDecodeVariant(json as VariantJSON105, builder, namespaceArray);
116
+ ```
117
+
118
+ For a model with custom structures, `builder` resolves the DataType NodeId against a live
119
+ address space or a dynamically built factory. For a model with only built-in types, a builder
120
+ that throws is enough, because it is never reached.
121
+
122
+ Handing the whole thing over at once, when you already know the type:
123
+
124
+ ```ts
125
+ import { PubSubConnectionDataType } from "node-opcua-types";
126
+ import { decodeOPCUA_JSON } from "node-opcua-json";
127
+
128
+ const config = decodeOPCUA_JSON(PubSubConnectionDataType, JSON.parse(text));
129
+ config.address; // a NetworkAddressUrlDataType, reconstructed from its UaTypeId
130
+ ```
131
+
132
+ The test suite reads configuration files produced by the .NET stack, so this path is checked
133
+ against another implementation rather than only against itself.
134
+
135
+ ## API
136
+
137
+ Every built-in type has an `opcuaJsonEncodeX` / `opcuaJsonDecodeX` pair, and each takes the
138
+ scheme, so one call site serves all four.
139
+
140
+ | area | exports |
141
+ |---|---|
142
+ | Variant | `opcuaJsonEncodeVariant`, `opcuaJsonDecodeVariant`, the `104` / `105` pairs, `VariantJSON`, `VariantJSON104`, `VariantJSON105` |
143
+ | DataValue | `opcuaJsonEncodeDataValue`, `opcuaJsonDecodeDataValue`, `opcuaJsonEncodeDataValueMQTT`, the `104` / `105` variants of all three, `DataValueJSON`, `DataValueJSON104`, `DataValueJSON105` |
144
+ | ExtensionObject | `opcuaJsonEncodeExtensionObject`, `opcuaJsonDecodeExtensionObject`, the `...Body` pair, `makeBody`, `ExtensionObjectJSON104`, `ExtensionObjectJSON105` |
145
+ | NodeId | `opcuaJsonEncodeNodeId`, `opcuaJsonDecodeNodeId`, the `ExpandedNodeId` pair, the `104` / `105` encoders, `opcuaJsonEncodeNodeIdAsString` |
146
+ | realms | `node-opcua-json/104`, `node-opcua-json/105`, and the `v104` / `v105` namespaces on the root |
147
+ | scalars | `Int64`, `UInt64`, `ByteString`, `DateTime`, `LocalizedText`, `QualifiedName`, `StatusCode` |
148
+ | structures | `decodeOPCUA_JSON`, `decodeOPCUA_JSONOld` |
149
+ | schemes | `JsonEncodingScheme`, `JsonEncoderMode104`, `JsonEncoderMode105`, `toJsonEncodingScheme`, `makeDataValueEncodingEnum`, the two `JsonDataSetMessageContentMask` converters |
150
+ | dispatch | `bodyEncodeFunctor(dataType)`, `bodyDecodeFunctor(dataType)`, `EncoderFunc`, `DecoderFunc`, `ExtensionObjectBuilder` |
151
+
152
+ `opcuaJsonEncodeVariant` and `opcuaJsonDecodeVariant` are overloaded across all four schemes and
153
+ so cannot express the 1.05 object shape for Verbose alone. Where you need that exact type, reach
154
+ for the explicit `opcuaJsonEncodeVariant105` / `opcuaJsonDecodeVariant105`, or the matching
155
+ `...104` pair.
156
+
157
+ ## Position in the SDK
158
+
159
+ This package sits **low in the dependency graph**, on the type and factory packages and nothing
160
+ else. It does not depend on `node-opcua-address-space`, which is what allows the address space to
161
+ depend on it, and in turn lets
162
+ [`node-opcua-uanodeset-json`](../node-opcua-uanodeset-json) encode nodeset values with the same
163
+ codec the PubSub layer uses.
164
+
165
+ The `ExtensionObjectBuilder` parameter is the price of that position: rather than reaching for an
166
+ address space itself, the package asks the caller to resolve structures.
167
+
168
+ ## Provenance and licence
169
+
170
+ This code was written for `@sterfive/node-opcua-json`, part of the node-opcua-pubsub work, and is
171
+ contributed here by its copyright holder under **MIT**, so that JSON encoding is not a licensing
172
+ question for anyone building on the SDK.
173
+
174
+ MIT
@@ -0,0 +1,56 @@
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
+ /**
25
+ * The OPC UA 1.04 JSON encoding (Part 6, "reversible" and "non-reversible" forms), exposed
26
+ * under version-free names: `import { opcuaJsonEncodeDataValue } from "node-opcua-json/104"`.
27
+ *
28
+ * Everything here is locked to 1.04: the encoders take a JsonEncoderMode (Reversible or
29
+ * NonReversible) and the JSON types are the 1.04 shapes (Type/Body, TypeId/Body, NodeId objects).
30
+ * The root "node-opcua-json" entry point dispatches on JsonEncodingScheme and accepts either edition.
31
+ */
32
+ import type { ExtensionObject } from "node-opcua-extension-object";
33
+ import type { Pojo } from "../decode_opcua_json.js";
34
+ import type { ExtensionObjectBuilder } from "../json_basic_encoding_body_functor.js";
35
+ import { type ExtensionObjectJSON104 } from "../json_basic_encoding_decoding_extension_object.js";
36
+ import { type JsonEncoderMode104 } from "../json_encoding_scheme.js";
37
+ export * from "../decode_opcua_json.js";
38
+ export type { ExtensionObjectConstructorFuncWithSchema } from "../extension_object_constructor.js";
39
+ export * from "../json_basic_encoding_body_functor.js";
40
+ export * from "../json_basic_encoding_decoding_byte_string.js";
41
+ export { type DataValueJSON104 as DataValueJSON, type DataValueStatusAndTimestamps, opcuaJsonDecodeDataValue104 as opcuaJsonDecodeDataValue, opcuaJsonEncodeDataValue104 as opcuaJsonEncodeDataValue, opcuaJsonEncodeDataValueMQTT104 as opcuaJsonEncodeDataValueMQTT } from "../json_basic_encoding_decoding_data_value.js";
42
+ export * from "../json_basic_encoding_decoding_date_time.js";
43
+ export { type ExtensionObjectJSON104 as ExtensionObjectJSON, makeBody, opcuaJsonDecodeExtensionObjectBody, opcuaJsonEncodeExtensionObjectBody } from "../json_basic_encoding_decoding_extension_object.js";
44
+ export * from "../json_basic_encoding_decoding_int64.js";
45
+ export * from "../json_basic_encoding_decoding_localizedtext.js";
46
+ export { type NodeIdJSON104 as NodeIdJSON, opcuaDecodeURIComponent, opcuaEncodeURIComponent, opcuaJsonDecodeExpandedNodeId, opcuaJsonDecodeNodeId, opcuaJsonEncodeExpandedNodeId104 as opcuaJsonEncodeExpandedNodeId, opcuaJsonEncodeNodeId104 as opcuaJsonEncodeNodeId } from "../json_basic_encoding_decoding_nodeid.js";
47
+ export * from "../json_basic_encoding_decoding_qualifiedname.js";
48
+ export { opcuaJsonDecodeStatusCode, opcuaJsonEncodeStatusCode104 as opcuaJsonEncodeStatusCode, type StatusCodeJSON } from "../json_basic_encoding_decoding_statuscode.js";
49
+ export { opcuaJsonDecodeVariant104 as opcuaJsonDecodeVariant, opcuaJsonEncodeVariant104 as opcuaJsonEncodeVariant, type VariantJSON104 as VariantJSON, type VariantJSONBody, type VariantJSONBodyScalar } from "../json_basic_encoding_decoding_variant.js";
50
+ export { JsonEncoderMode104 as JsonEncoderMode, JsonEncodingScheme, toJsonEncodingScheme } from "../json_encoding_scheme.js";
51
+ /**
52
+ * encode an ExtensionObject with the 1.04 rules: Reversible yields { TypeId, Body },
53
+ * NonReversible yields the bare body.
54
+ */
55
+ export declare function opcuaJsonEncodeExtensionObject(extensionObject: ExtensionObject | ExtensionObject[] | null, mode: JsonEncoderMode104, namespaceArray?: string[]): ExtensionObjectJSON104 | Pojo | (ExtensionObjectJSON104 | Pojo)[] | null;
56
+ export declare function opcuaJsonDecodeExtensionObject(pojo: ExtensionObjectJSON104, builder: ExtensionObjectBuilder, namespaceArray: string[]): ExtensionObject | ExtensionObject[] | null;
@@ -0,0 +1,93 @@
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.toJsonEncodingScheme = exports.JsonEncodingScheme = exports.JsonEncoderMode = exports.opcuaJsonEncodeVariant = exports.opcuaJsonDecodeVariant = exports.opcuaJsonEncodeStatusCode = exports.opcuaJsonDecodeStatusCode = exports.opcuaJsonEncodeNodeId = exports.opcuaJsonEncodeExpandedNodeId = exports.opcuaJsonDecodeNodeId = exports.opcuaJsonDecodeExpandedNodeId = exports.opcuaEncodeURIComponent = exports.opcuaDecodeURIComponent = exports.opcuaJsonEncodeExtensionObjectBody = exports.opcuaJsonDecodeExtensionObjectBody = exports.makeBody = exports.opcuaJsonEncodeDataValueMQTT = exports.opcuaJsonEncodeDataValue = exports.opcuaJsonDecodeDataValue = void 0;
41
+ exports.opcuaJsonEncodeExtensionObject = opcuaJsonEncodeExtensionObject;
42
+ exports.opcuaJsonDecodeExtensionObject = opcuaJsonDecodeExtensionObject;
43
+ const json_basic_encoding_decoding_extension_object_js_1 = require("../json_basic_encoding_decoding_extension_object.js");
44
+ const json_encoding_scheme_js_1 = require("../json_encoding_scheme.js");
45
+ // version-agnostic parts, shared with the root entry point
46
+ __exportStar(require("../decode_opcua_json.js"), exports);
47
+ __exportStar(require("../json_basic_encoding_body_functor.js"), exports);
48
+ __exportStar(require("../json_basic_encoding_decoding_byte_string.js"), exports);
49
+ // DataValue
50
+ var json_basic_encoding_decoding_data_value_js_1 = require("../json_basic_encoding_decoding_data_value.js");
51
+ Object.defineProperty(exports, "opcuaJsonDecodeDataValue", { enumerable: true, get: function () { return json_basic_encoding_decoding_data_value_js_1.opcuaJsonDecodeDataValue104; } });
52
+ Object.defineProperty(exports, "opcuaJsonEncodeDataValue", { enumerable: true, get: function () { return json_basic_encoding_decoding_data_value_js_1.opcuaJsonEncodeDataValue104; } });
53
+ Object.defineProperty(exports, "opcuaJsonEncodeDataValueMQTT", { enumerable: true, get: function () { return json_basic_encoding_decoding_data_value_js_1.opcuaJsonEncodeDataValueMQTT104; } });
54
+ __exportStar(require("../json_basic_encoding_decoding_date_time.js"), exports);
55
+ // ExtensionObject
56
+ var json_basic_encoding_decoding_extension_object_js_2 = require("../json_basic_encoding_decoding_extension_object.js");
57
+ Object.defineProperty(exports, "makeBody", { enumerable: true, get: function () { return json_basic_encoding_decoding_extension_object_js_2.makeBody; } });
58
+ Object.defineProperty(exports, "opcuaJsonDecodeExtensionObjectBody", { enumerable: true, get: function () { return json_basic_encoding_decoding_extension_object_js_2.opcuaJsonDecodeExtensionObjectBody; } });
59
+ Object.defineProperty(exports, "opcuaJsonEncodeExtensionObjectBody", { enumerable: true, get: function () { return json_basic_encoding_decoding_extension_object_js_2.opcuaJsonEncodeExtensionObjectBody; } });
60
+ __exportStar(require("../json_basic_encoding_decoding_int64.js"), exports);
61
+ __exportStar(require("../json_basic_encoding_decoding_localizedtext.js"), exports);
62
+ // NodeId
63
+ var json_basic_encoding_decoding_nodeid_js_1 = require("../json_basic_encoding_decoding_nodeid.js");
64
+ Object.defineProperty(exports, "opcuaDecodeURIComponent", { enumerable: true, get: function () { return json_basic_encoding_decoding_nodeid_js_1.opcuaDecodeURIComponent; } });
65
+ Object.defineProperty(exports, "opcuaEncodeURIComponent", { enumerable: true, get: function () { return json_basic_encoding_decoding_nodeid_js_1.opcuaEncodeURIComponent; } });
66
+ Object.defineProperty(exports, "opcuaJsonDecodeExpandedNodeId", { enumerable: true, get: function () { return json_basic_encoding_decoding_nodeid_js_1.opcuaJsonDecodeExpandedNodeId; } });
67
+ Object.defineProperty(exports, "opcuaJsonDecodeNodeId", { enumerable: true, get: function () { return json_basic_encoding_decoding_nodeid_js_1.opcuaJsonDecodeNodeId; } });
68
+ Object.defineProperty(exports, "opcuaJsonEncodeExpandedNodeId", { enumerable: true, get: function () { return json_basic_encoding_decoding_nodeid_js_1.opcuaJsonEncodeExpandedNodeId104; } });
69
+ Object.defineProperty(exports, "opcuaJsonEncodeNodeId", { enumerable: true, get: function () { return json_basic_encoding_decoding_nodeid_js_1.opcuaJsonEncodeNodeId104; } });
70
+ __exportStar(require("../json_basic_encoding_decoding_qualifiedname.js"), exports);
71
+ // StatusCode
72
+ var json_basic_encoding_decoding_statuscode_js_1 = require("../json_basic_encoding_decoding_statuscode.js");
73
+ Object.defineProperty(exports, "opcuaJsonDecodeStatusCode", { enumerable: true, get: function () { return json_basic_encoding_decoding_statuscode_js_1.opcuaJsonDecodeStatusCode; } });
74
+ Object.defineProperty(exports, "opcuaJsonEncodeStatusCode", { enumerable: true, get: function () { return json_basic_encoding_decoding_statuscode_js_1.opcuaJsonEncodeStatusCode104; } });
75
+ // Variant
76
+ var json_basic_encoding_decoding_variant_js_1 = require("../json_basic_encoding_decoding_variant.js");
77
+ Object.defineProperty(exports, "opcuaJsonDecodeVariant", { enumerable: true, get: function () { return json_basic_encoding_decoding_variant_js_1.opcuaJsonDecodeVariant104; } });
78
+ Object.defineProperty(exports, "opcuaJsonEncodeVariant", { enumerable: true, get: function () { return json_basic_encoding_decoding_variant_js_1.opcuaJsonEncodeVariant104; } });
79
+ var json_encoding_scheme_js_2 = require("../json_encoding_scheme.js");
80
+ Object.defineProperty(exports, "JsonEncoderMode", { enumerable: true, get: function () { return json_encoding_scheme_js_2.JsonEncoderMode104; } });
81
+ Object.defineProperty(exports, "JsonEncodingScheme", { enumerable: true, get: function () { return json_encoding_scheme_js_2.JsonEncodingScheme; } });
82
+ Object.defineProperty(exports, "toJsonEncodingScheme", { enumerable: true, get: function () { return json_encoding_scheme_js_2.toJsonEncodingScheme; } });
83
+ /**
84
+ * encode an ExtensionObject with the 1.04 rules: Reversible yields { TypeId, Body },
85
+ * NonReversible yields the bare body.
86
+ */
87
+ function opcuaJsonEncodeExtensionObject(extensionObject, mode, namespaceArray) {
88
+ return (0, json_basic_encoding_decoding_extension_object_js_1.opcuaJsonEncodeExtensionObject)(extensionObject, (0, json_encoding_scheme_js_1.toJsonEncodingScheme)(mode), namespaceArray);
89
+ }
90
+ function opcuaJsonDecodeExtensionObject(pojo, builder, namespaceArray) {
91
+ return (0, json_basic_encoding_decoding_extension_object_js_1.opcuaJsonDecodeExtensionObject)(pojo, builder, namespaceArray);
92
+ }
93
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/104/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;;AA4EH,wEAUC;AAED,wEAMC;AAhFD,0HAI6D;AAC7D,wEAA2F;AAE3F,2DAA2D;AAC3D,0DAAwC;AAExC,yEAAuD;AACvD,iFAA+D;AAC/D,YAAY;AACZ,4GAMuD;AAHnD,sJAAA,2BAA2B,OAA4B;AACvD,sJAAA,2BAA2B,OAA4B;AACvD,0JAAA,+BAA+B,OAAgC;AAEnE,+EAA6D;AAC7D,kBAAkB;AAClB,wHAK6D;AAHzD,4IAAA,QAAQ,OAAA;AACR,sKAAA,kCAAkC,OAAA;AAClC,sKAAA,kCAAkC,OAAA;AAEtC,2EAAyD;AACzD,mFAAiE;AACjE,SAAS;AACT,oGAQmD;AAN/C,iJAAA,uBAAuB,OAAA;AACvB,iJAAA,uBAAuB,OAAA;AACvB,uJAAA,6BAA6B,OAAA;AAC7B,+IAAA,qBAAqB,OAAA;AACrB,uJAAA,gCAAgC,OAAiC;AACjE,+IAAA,wBAAwB,OAAyB;AAErD,mFAAiE;AAEjE,aAAa;AACb,4GAIuD;AAHnD,uJAAA,yBAAyB,OAAA;AACzB,uJAAA,4BAA4B,OAA6B;AAG7D,UAAU;AACV,sGAMoD;AALhD,iJAAA,yBAAyB,OAA0B;AACnD,iJAAA,yBAAyB,OAA0B;AAKvD,sEAA6H;AAApH,0HAAA,kBAAkB,OAAmB;AAAE,6HAAA,kBAAkB,OAAA;AAAE,+HAAA,oBAAoB,OAAA;AAExF;;;GAGG;AACH,SAAgB,8BAA8B,CAC1C,eAA2D,EAC3D,IAAwB,EACxB,cAAyB;IAEzB,OAAO,IAAA,iFAAiC,EAAC,eAAe,EAAE,IAAA,8CAAoB,EAAC,IAAI,CAAC,EAAE,cAAc,CAI1F,CAAC;AACf,CAAC;AAED,SAAgB,8BAA8B,CAC1C,IAA4B,EAC5B,OAA+B,EAC/B,cAAwB;IAExB,OAAO,IAAA,iFAAiC,EAAC,IAAI,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,55 @@
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
+ /**
25
+ * The OPC UA 1.05 JSON encoding (Part 6, "Compact" and "Verbose" forms), exposed under
26
+ * version-free names: `import { opcuaJsonEncodeDataValue } from "node-opcua-json/105"`.
27
+ *
28
+ * Everything here is locked to 1.05: the encoders take a JsonEncoderMode (Compact or Verbose)
29
+ * and the JSON types are the 1.05 shapes (UaType/Value, UaTypeId/UaBody, NodeId strings).
30
+ * The root "node-opcua-json" entry point dispatches on JsonEncodingScheme and accepts either edition.
31
+ */
32
+ import type { ExtensionObject } from "node-opcua-extension-object";
33
+ import type { ExtensionObjectBuilder } from "../json_basic_encoding_body_functor.js";
34
+ import { type ExtensionObjectJSON105 } from "../json_basic_encoding_decoding_extension_object.js";
35
+ import { type JsonEncoderMode105 } from "../json_encoding_scheme.js";
36
+ export * from "../decode_opcua_json.js";
37
+ export type { ExtensionObjectConstructorFuncWithSchema } from "../extension_object_constructor.js";
38
+ export * from "../json_basic_encoding_body_functor.js";
39
+ export * from "../json_basic_encoding_decoding_byte_string.js";
40
+ export { type DataValueJSON105 as DataValueJSON, type DataValueStatusAndTimestamps, opcuaJsonDecodeDataValue105 as opcuaJsonDecodeDataValue, opcuaJsonEncodeDataValue105 as opcuaJsonEncodeDataValue, opcuaJsonEncodeDataValueMQTT105 as opcuaJsonEncodeDataValueMQTT } from "../json_basic_encoding_decoding_data_value.js";
41
+ export * from "../json_basic_encoding_decoding_date_time.js";
42
+ export { type ExtensionObjectJSON105 as ExtensionObjectJSON, makeBody, opcuaJsonDecodeExtensionObjectBody, opcuaJsonEncodeExtensionObjectBody } from "../json_basic_encoding_decoding_extension_object.js";
43
+ export * from "../json_basic_encoding_decoding_int64.js";
44
+ export * from "../json_basic_encoding_decoding_localizedtext.js";
45
+ export { type NodeIdJSON105 as NodeIdJSON, opcuaDecodeURIComponent, opcuaEncodeURIComponent, opcuaJsonDecodeExpandedNodeId, opcuaJsonDecodeNodeId, opcuaJsonEncodeExpandedNodeId105 as opcuaJsonEncodeExpandedNodeId, opcuaJsonEncodeExpandedNodeIdAsString, opcuaJsonEncodeNodeId105 as opcuaJsonEncodeNodeId, opcuaJsonEncodeNodeIdAsString } from "../json_basic_encoding_decoding_nodeid.js";
46
+ export * from "../json_basic_encoding_decoding_qualifiedname.js";
47
+ export { opcuaJsonDecodeStatusCode, opcuaJsonEncodeStatusCode105 as opcuaJsonEncodeStatusCode, type StatusCodeJSON } from "../json_basic_encoding_decoding_statuscode.js";
48
+ export { opcuaJsonDecodeVariant105 as opcuaJsonDecodeVariant, opcuaJsonEncodeVariant105 as opcuaJsonEncodeVariant, type VariantJSON105 as VariantJSON, type VariantJSONBody, type VariantJSONBodyScalar } from "../json_basic_encoding_decoding_variant.js";
49
+ export { JsonEncoderMode105 as JsonEncoderMode, JsonEncodingScheme, toJsonEncodingScheme } from "../json_encoding_scheme.js";
50
+ /**
51
+ * encode an ExtensionObject with the 1.05 rules: { UaTypeId, UaBody }, UaBody omitted in
52
+ * Compact mode when empty; a null ExtensionObject is omitted (undefined) in Compact mode.
53
+ */
54
+ export declare function opcuaJsonEncodeExtensionObject(extensionObject: ExtensionObject | ExtensionObject[] | null, mode: JsonEncoderMode105, namespaceArray?: string[]): ExtensionObjectJSON105 | ExtensionObjectJSON105[] | null | undefined;
55
+ export declare function opcuaJsonDecodeExtensionObject(pojo: ExtensionObjectJSON105, builder: ExtensionObjectBuilder, namespaceArray: string[]): ExtensionObject | ExtensionObject[] | null;
@@ -0,0 +1,95 @@
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.toJsonEncodingScheme = exports.JsonEncodingScheme = exports.JsonEncoderMode = exports.opcuaJsonEncodeVariant = exports.opcuaJsonDecodeVariant = exports.opcuaJsonEncodeStatusCode = exports.opcuaJsonDecodeStatusCode = exports.opcuaJsonEncodeNodeIdAsString = exports.opcuaJsonEncodeNodeId = exports.opcuaJsonEncodeExpandedNodeIdAsString = exports.opcuaJsonEncodeExpandedNodeId = exports.opcuaJsonDecodeNodeId = exports.opcuaJsonDecodeExpandedNodeId = exports.opcuaEncodeURIComponent = exports.opcuaDecodeURIComponent = exports.opcuaJsonEncodeExtensionObjectBody = exports.opcuaJsonDecodeExtensionObjectBody = exports.makeBody = exports.opcuaJsonEncodeDataValueMQTT = exports.opcuaJsonEncodeDataValue = exports.opcuaJsonDecodeDataValue = void 0;
41
+ exports.opcuaJsonEncodeExtensionObject = opcuaJsonEncodeExtensionObject;
42
+ exports.opcuaJsonDecodeExtensionObject = opcuaJsonDecodeExtensionObject;
43
+ const json_basic_encoding_decoding_extension_object_js_1 = require("../json_basic_encoding_decoding_extension_object.js");
44
+ const json_encoding_scheme_js_1 = require("../json_encoding_scheme.js");
45
+ // version-agnostic parts, shared with the root entry point
46
+ __exportStar(require("../decode_opcua_json.js"), exports);
47
+ __exportStar(require("../json_basic_encoding_body_functor.js"), exports);
48
+ __exportStar(require("../json_basic_encoding_decoding_byte_string.js"), exports);
49
+ // DataValue
50
+ var json_basic_encoding_decoding_data_value_js_1 = require("../json_basic_encoding_decoding_data_value.js");
51
+ Object.defineProperty(exports, "opcuaJsonDecodeDataValue", { enumerable: true, get: function () { return json_basic_encoding_decoding_data_value_js_1.opcuaJsonDecodeDataValue105; } });
52
+ Object.defineProperty(exports, "opcuaJsonEncodeDataValue", { enumerable: true, get: function () { return json_basic_encoding_decoding_data_value_js_1.opcuaJsonEncodeDataValue105; } });
53
+ Object.defineProperty(exports, "opcuaJsonEncodeDataValueMQTT", { enumerable: true, get: function () { return json_basic_encoding_decoding_data_value_js_1.opcuaJsonEncodeDataValueMQTT105; } });
54
+ __exportStar(require("../json_basic_encoding_decoding_date_time.js"), exports);
55
+ // ExtensionObject
56
+ var json_basic_encoding_decoding_extension_object_js_2 = require("../json_basic_encoding_decoding_extension_object.js");
57
+ Object.defineProperty(exports, "makeBody", { enumerable: true, get: function () { return json_basic_encoding_decoding_extension_object_js_2.makeBody; } });
58
+ Object.defineProperty(exports, "opcuaJsonDecodeExtensionObjectBody", { enumerable: true, get: function () { return json_basic_encoding_decoding_extension_object_js_2.opcuaJsonDecodeExtensionObjectBody; } });
59
+ Object.defineProperty(exports, "opcuaJsonEncodeExtensionObjectBody", { enumerable: true, get: function () { return json_basic_encoding_decoding_extension_object_js_2.opcuaJsonEncodeExtensionObjectBody; } });
60
+ __exportStar(require("../json_basic_encoding_decoding_int64.js"), exports);
61
+ __exportStar(require("../json_basic_encoding_decoding_localizedtext.js"), exports);
62
+ // NodeId
63
+ var json_basic_encoding_decoding_nodeid_js_1 = require("../json_basic_encoding_decoding_nodeid.js");
64
+ Object.defineProperty(exports, "opcuaDecodeURIComponent", { enumerable: true, get: function () { return json_basic_encoding_decoding_nodeid_js_1.opcuaDecodeURIComponent; } });
65
+ Object.defineProperty(exports, "opcuaEncodeURIComponent", { enumerable: true, get: function () { return json_basic_encoding_decoding_nodeid_js_1.opcuaEncodeURIComponent; } });
66
+ Object.defineProperty(exports, "opcuaJsonDecodeExpandedNodeId", { enumerable: true, get: function () { return json_basic_encoding_decoding_nodeid_js_1.opcuaJsonDecodeExpandedNodeId; } });
67
+ Object.defineProperty(exports, "opcuaJsonDecodeNodeId", { enumerable: true, get: function () { return json_basic_encoding_decoding_nodeid_js_1.opcuaJsonDecodeNodeId; } });
68
+ Object.defineProperty(exports, "opcuaJsonEncodeExpandedNodeId", { enumerable: true, get: function () { return json_basic_encoding_decoding_nodeid_js_1.opcuaJsonEncodeExpandedNodeId105; } });
69
+ Object.defineProperty(exports, "opcuaJsonEncodeExpandedNodeIdAsString", { enumerable: true, get: function () { return json_basic_encoding_decoding_nodeid_js_1.opcuaJsonEncodeExpandedNodeIdAsString; } });
70
+ Object.defineProperty(exports, "opcuaJsonEncodeNodeId", { enumerable: true, get: function () { return json_basic_encoding_decoding_nodeid_js_1.opcuaJsonEncodeNodeId105; } });
71
+ Object.defineProperty(exports, "opcuaJsonEncodeNodeIdAsString", { enumerable: true, get: function () { return json_basic_encoding_decoding_nodeid_js_1.opcuaJsonEncodeNodeIdAsString; } });
72
+ __exportStar(require("../json_basic_encoding_decoding_qualifiedname.js"), exports);
73
+ // StatusCode
74
+ var json_basic_encoding_decoding_statuscode_js_1 = require("../json_basic_encoding_decoding_statuscode.js");
75
+ Object.defineProperty(exports, "opcuaJsonDecodeStatusCode", { enumerable: true, get: function () { return json_basic_encoding_decoding_statuscode_js_1.opcuaJsonDecodeStatusCode; } });
76
+ Object.defineProperty(exports, "opcuaJsonEncodeStatusCode", { enumerable: true, get: function () { return json_basic_encoding_decoding_statuscode_js_1.opcuaJsonEncodeStatusCode105; } });
77
+ // Variant
78
+ var json_basic_encoding_decoding_variant_js_1 = require("../json_basic_encoding_decoding_variant.js");
79
+ Object.defineProperty(exports, "opcuaJsonDecodeVariant", { enumerable: true, get: function () { return json_basic_encoding_decoding_variant_js_1.opcuaJsonDecodeVariant105; } });
80
+ Object.defineProperty(exports, "opcuaJsonEncodeVariant", { enumerable: true, get: function () { return json_basic_encoding_decoding_variant_js_1.opcuaJsonEncodeVariant105; } });
81
+ var json_encoding_scheme_js_2 = require("../json_encoding_scheme.js");
82
+ Object.defineProperty(exports, "JsonEncoderMode", { enumerable: true, get: function () { return json_encoding_scheme_js_2.JsonEncoderMode105; } });
83
+ Object.defineProperty(exports, "JsonEncodingScheme", { enumerable: true, get: function () { return json_encoding_scheme_js_2.JsonEncodingScheme; } });
84
+ Object.defineProperty(exports, "toJsonEncodingScheme", { enumerable: true, get: function () { return json_encoding_scheme_js_2.toJsonEncodingScheme; } });
85
+ /**
86
+ * encode an ExtensionObject with the 1.05 rules: { UaTypeId, UaBody }, UaBody omitted in
87
+ * Compact mode when empty; a null ExtensionObject is omitted (undefined) in Compact mode.
88
+ */
89
+ function opcuaJsonEncodeExtensionObject(extensionObject, mode, namespaceArray) {
90
+ return (0, json_basic_encoding_decoding_extension_object_js_1.opcuaJsonEncodeExtensionObject)(extensionObject, (0, json_encoding_scheme_js_1.toJsonEncodingScheme)(mode), namespaceArray);
91
+ }
92
+ function opcuaJsonDecodeExtensionObject(pojo, builder, namespaceArray) {
93
+ return (0, json_basic_encoding_decoding_extension_object_js_1.opcuaJsonDecodeExtensionObject)(pojo, builder, namespaceArray);
94
+ }
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/105/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;;AA6EH,wEAUC;AAED,wEAMC;AAlFD,0HAI6D;AAC7D,wEAA2F;AAE3F,2DAA2D;AAC3D,0DAAwC;AAExC,yEAAuD;AACvD,iFAA+D;AAC/D,YAAY;AACZ,4GAMuD;AAHnD,sJAAA,2BAA2B,OAA4B;AACvD,sJAAA,2BAA2B,OAA4B;AACvD,0JAAA,+BAA+B,OAAgC;AAEnE,+EAA6D;AAC7D,kBAAkB;AAClB,wHAK6D;AAHzD,4IAAA,QAAQ,OAAA;AACR,sKAAA,kCAAkC,OAAA;AAClC,sKAAA,kCAAkC,OAAA;AAEtC,2EAAyD;AACzD,mFAAiE;AACjE,SAAS;AACT,oGAUmD;AAR/C,iJAAA,uBAAuB,OAAA;AACvB,iJAAA,uBAAuB,OAAA;AACvB,uJAAA,6BAA6B,OAAA;AAC7B,+IAAA,qBAAqB,OAAA;AACrB,uJAAA,gCAAgC,OAAiC;AACjE,+JAAA,qCAAqC,OAAA;AACrC,+IAAA,wBAAwB,OAAyB;AACjD,uJAAA,6BAA6B,OAAA;AAEjC,mFAAiE;AAEjE,aAAa;AACb,4GAIuD;AAHnD,uJAAA,yBAAyB,OAAA;AACzB,uJAAA,4BAA4B,OAA6B;AAG7D,UAAU;AACV,sGAMoD;AALhD,iJAAA,yBAAyB,OAA0B;AACnD,iJAAA,yBAAyB,OAA0B;AAKvD,sEAA6H;AAApH,0HAAA,kBAAkB,OAAmB;AAAE,6HAAA,kBAAkB,OAAA;AAAE,+HAAA,oBAAoB,OAAA;AAExF;;;GAGG;AACH,SAAgB,8BAA8B,CAC1C,eAA2D,EAC3D,IAAwB,EACxB,cAAyB;IAEzB,OAAO,IAAA,iFAAiC,EAAC,eAAe,EAAE,IAAA,8CAAoB,EAAC,IAAI,CAAC,EAAE,cAAc,CAIrF,CAAC;AACpB,CAAC;AAED,SAAgB,8BAA8B,CAC1C,IAA4B,EAC5B,OAA+B,EAC/B,cAAwB;IAExB,OAAO,IAAA,iFAAiC,EAAC,IAAI,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;AAC5E,CAAC"}
@@ -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"}