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
@@ -0,0 +1,39 @@
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 StatusCode, StatusCodes } from "node-opcua-status-code";
25
+ import { JsonEncoderMode104, JsonEncoderMode105, JsonEncodingScheme } from "./json_encoding_scheme.js";
26
+ export interface StatusCodeJSON {
27
+ Code?: number | keyof StatusCodes;
28
+ Symbol?: string;
29
+ }
30
+ export declare function opcuaJsonEncodeStatusCode104(statusCode: StatusCode, mode: JsonEncoderMode104): StatusCodeJSON | number | undefined;
31
+ export declare function opcuaJsonEncodeStatusCode105(statusCode: StatusCode, mode: JsonEncoderMode105): StatusCodeJSON | number | undefined;
32
+ export declare function opcuaJsonEncodeStatusCode(statusCode: StatusCode, scheme: JsonEncodingScheme): number | StatusCodeJSON | undefined;
33
+ /**
34
+ *
35
+ * @param pojo
36
+ *
37
+ * @returns
38
+ */
39
+ export declare function opcuaJsonDecodeStatusCode(pojo: StatusCodeJSON | number | null | undefined): StatusCode;
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.opcuaJsonEncodeStatusCode104 = opcuaJsonEncodeStatusCode104;
4
+ exports.opcuaJsonEncodeStatusCode105 = opcuaJsonEncodeStatusCode105;
5
+ exports.opcuaJsonEncodeStatusCode = opcuaJsonEncodeStatusCode;
6
+ exports.opcuaJsonDecodeStatusCode = opcuaJsonDecodeStatusCode;
7
+ /**
8
+ * ==========================================================================
9
+ * Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27
+ * IN THE SOFTWARE.
28
+ * ==========================================================================
29
+ */
30
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
31
+ const json_encoding_scheme_js_1 = require("./json_encoding_scheme.js");
32
+ function opcuaJsonEncodeStatusCode104(statusCode, mode) {
33
+ /*
34
+ * StatusCode values shall be encoded as a JSON number for the reversible encoding.
35
+ */
36
+ if (mode === json_encoding_scheme_js_1.JsonEncoderMode104.Reversible) {
37
+ return statusCode.value;
38
+ }
39
+ /*
40
+ * reference: https://reference.opcfoundation.org/Core/Part6/v104/docs/5.4.2.12
41
+ *
42
+ * For the non-reversible form, StatusCode values shall be encoded as a JSON object with the fields defined in Table
43
+ *
44
+ * Symbol The string literal associated with the numeric code encoded as JSON string.
45
+ *
46
+ * e.g. 0x80AB0000 has the associated literal “BadInvalidArgument”.
47
+ * Any InfoBits in the StatusCode are ignored when looking up the symbol.
48
+ * If the string literal is not known to the encoder the field is omitted.
49
+ * The field is omitted in the CompactEncoding.
50
+ * The field is omitted if the numeric code is 0 (Good).
51
+ */
52
+ /**
53
+ * A StatusCode of Good (0) is treated like a NULL and not encoded.
54
+ * (If it is an element of an JSON array it is encoded as the JSON literal ‘null’. )
55
+ */
56
+ if (statusCode.value === 0) {
57
+ return undefined;
58
+ }
59
+ const pojo = {};
60
+ // The Code is omitted if the numeric code is 0(Good).
61
+ if (statusCode.value !== 0) {
62
+ // The numeric code encoded as a JSON number.
63
+ pojo.Code = statusCode.value;
64
+ }
65
+ // The string literal associated with the numeric code encoded as JSON string.
66
+ // e.g. 0x80AB0000 has the associated literal “BadInvalidArgument”.
67
+ //
68
+ // The Symbol is omitted if the numeric code is 0(Good).
69
+ if (statusCode.value === 0) {
70
+ return pojo; // Good
71
+ }
72
+ const c = (0, node_opcua_status_code_1.coerceStatusCode)(statusCode.value & 0xffff0000); // remove InfoBits and OverflowBit
73
+ pojo.Symbol = c.name;
74
+ return pojo;
75
+ }
76
+ function opcuaJsonEncodeStatusCode105(statusCode, mode) {
77
+ /*
78
+ * For the non-reversible form, StatusCode values shall be encoded as a JSON object with the fields defined in Table
79
+ *
80
+ * Symbol The string literal associated with the numeric code encoded as JSON string.
81
+ */
82
+ const pojo = {};
83
+ if (statusCode.value !== 0) {
84
+ pojo.Code = statusCode.value;
85
+ }
86
+ /*
87
+ * e.g. 0x80AB0000 has the associated literal “BadInvalidArgument”.
88
+ * Any InfoBits in the StatusCode are ignored when looking up the symbol.
89
+ * If the string literal is not known to the encoder the field is omitted.
90
+ * The field is omitted in the CompactEncoding.
91
+ * The field is omitted if the numeric code is 0 (Good).
92
+ */
93
+ if (mode === json_encoding_scheme_js_1.JsonEncoderMode105.Verbose) {
94
+ if (statusCode.value !== 0) {
95
+ const c = (0, node_opcua_status_code_1.coerceStatusCode)(statusCode.value & 0xffff0000); // remove InfoBits and OverflowBit
96
+ if (c?.name) {
97
+ pojo.Symbol = c.name;
98
+ }
99
+ }
100
+ }
101
+ return pojo;
102
+ }
103
+ function opcuaJsonEncodeStatusCode(statusCode, scheme) {
104
+ switch (scheme) {
105
+ case json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedNonReversible:
106
+ return opcuaJsonEncodeStatusCode104(statusCode, json_encoding_scheme_js_1.JsonEncoderMode104.NonReversible);
107
+ case json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedReversible:
108
+ return opcuaJsonEncodeStatusCode104(statusCode, json_encoding_scheme_js_1.JsonEncoderMode104.Reversible);
109
+ case json_encoding_scheme_js_1.JsonEncodingScheme.Compact:
110
+ return opcuaJsonEncodeStatusCode105(statusCode, json_encoding_scheme_js_1.JsonEncoderMode105.Compact);
111
+ case json_encoding_scheme_js_1.JsonEncodingScheme.Verbose:
112
+ return opcuaJsonEncodeStatusCode105(statusCode, json_encoding_scheme_js_1.JsonEncoderMode105.Verbose);
113
+ default:
114
+ throw new Error("Unknown JsonEncodingScheme");
115
+ }
116
+ }
117
+ /**
118
+ *
119
+ * @param pojo
120
+ *
121
+ * @returns
122
+ */
123
+ function opcuaJsonDecodeStatusCode(pojo) {
124
+ if (!pojo) {
125
+ return node_opcua_status_code_1.StatusCodes.Good;
126
+ }
127
+ if (typeof pojo === "number") {
128
+ return (0, node_opcua_status_code_1.coerceStatusCode)(pojo);
129
+ }
130
+ if (typeof pojo.Code === "number") {
131
+ return (0, node_opcua_status_code_1.coerceStatusCode)(pojo.Code);
132
+ }
133
+ if (!pojo.Code) {
134
+ // to trap undefined or null Code
135
+ return node_opcua_status_code_1.StatusCodes.Good;
136
+ }
137
+ return (0, node_opcua_status_code_1.coerceStatusCode)(pojo.Code);
138
+ }
139
+ //# sourceMappingURL=json_basic_encoding_decoding_statuscode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json_basic_encoding_decoding_statuscode.js","sourceRoot":"","sources":["../source/json_basic_encoding_decoding_statuscode.ts"],"names":[],"mappings":";;AA+BA,oEAgDC;AAED,oEA+BC;AAED,8DAaC;AAQD,8DAeC;AAtJD;;;;;;;;;;;;;;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AAI,CAAC,IAAI,EAAE,CAAC;QACb,iCAAiC;QACjC,OAAO,oCAAW,CAAC,IAAI,CAAC;IAC5B,CAAC;IACD,OAAO,IAAA,yCAAgB,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,101 @@
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 { DataType, Variant } from "node-opcua-variant";
25
+ import type { Pojo } from "./decode_opcua_json.js";
26
+ import { type ExtensionObjectBuilder } from "./json_basic_encoding_body_functor.js";
27
+ import { JsonEncoderMode104, JsonEncoderMode105, JsonEncodingScheme } from "./json_encoding_scheme.js";
28
+ export type VariantJSONBodyScalar = Pojo | number | string | boolean | null | Date;
29
+ export type VariantJSONBody = VariantJSONBodyScalar | VariantJSONBodyScalar[];
30
+ export interface VariantJSON104 {
31
+ /**
32
+ * The Built-in type for the value contained in the Body encoded as JSON number.
33
+ * If type is 0 (NULL) the Variant contains a NULL value and the containing JSON
34
+ * object shall be omitted or replaced by the JSON literal ‘null’ (when an element of a JSON array).
35
+ */
36
+ Type: DataType;
37
+ /**
38
+ * If the value is a scalar it is encoded using the rules for type specified for the Type.
39
+ * If the value is a one-dimensional array it is encoded as JSON array.
40
+ * Multi-dimensional arrays are encoded as a one dimensional JSON array which is
41
+ * reconstructed using the value of the Dimensions field (see 5.2.2.16).
42
+ */
43
+ Body: VariantJSONBody;
44
+ /**
45
+ * The dimensions of the array encoded as an JSON array of JSON numbers.
46
+ * The Dimensions are omitted for scalar and one-dimensional array values.
47
+ */
48
+ Dimensions?: number[];
49
+ }
50
+ export interface VariantJSON105 {
51
+ /**
52
+ * The Built-in type for the value contained in the Body (see Table 1) encoded as JSON number.
53
+ */
54
+ UaType: DataType;
55
+ /**
56
+ * If the value is a scalar, it is encoded using the rules for type specified for the Type.
57
+ *
58
+ * If the value is a one-dimensional array it is e const Value = body(variant, scheme, builder, namespaceArray);
59
+ ncoded as JSON array (see 5.4.5)
60
+ *
61
+ * Multi-dimensional arrays are encoded as a JSON array containing all elements.
62
+ * The mapping of a multidimensional array to a flat list is described in 5.2.2.16.
63
+ * The field is not encoded if the value is a NULL for nullable Built-in types (see Table 1)
64
+ *
65
+ * 5.4.5
66
+ *
67
+ * One dimensional Arrays shall be encoded as JSON arrays.
68
+ * If an element is NULL, the element shall be encoded as the JSON literal ‘null’.
69
+ * Otherwise, the element is encoded according to the rules defined for the type.
70
+ *
71
+ * Multidimensional Arrays are encoded as JSON object with the fields defined in
72
+ * Table 43.
73
+ *
74
+ * Table 43.
75
+ * Name Description const Value = body(variant, scheme, builder, namespaceArray);
76
+
77
+ * --------- ---------------------------------------------------
78
+ * Array Multi-dimensional arrays are encoded as a one-dimensional
79
+ * JSON array which is reconstructed using the value of the
80
+ * Dimensions field (see 5.2.2.16).
81
+ * Dimensions The dimensions of the array encoded as a JSON array of JSON numbers.
82
+ */
83
+ Value?: VariantJSONBody;
84
+ /**
85
+ * The dimensions of the array encoded as a JSON array of JSON numbers.
86
+ */
87
+ UaDimensions?: number[];
88
+ }
89
+ export type VariantJSON = (VariantJSON104 & {
90
+ UaType: undefined;
91
+ }) | (VariantJSON105 & {
92
+ Type: undefined;
93
+ });
94
+ export declare function opcuaJsonEncodeVariant105(variant: Variant, mode: JsonEncoderMode105, namespaceArray?: string[]): VariantJSON105;
95
+ export declare function opcuaJsonEncodeVariant104(variant: Variant, mode: JsonEncoderMode104 | undefined, namespaceArray: string[]): VariantJSON104 | VariantJSONBody | null;
96
+ export declare function opcuaJsonEncodeVariant(variant: Variant, scheme: JsonEncodingScheme.Compact | JsonEncodingScheme.Verbose, namespaceArray: string[]): VariantJSONBody | null;
97
+ export declare function opcuaJsonEncodeVariant(variant: Variant, scheme: JsonEncodingScheme.Verbose, namespaceArray: string[]): VariantJSON105;
98
+ export declare function opcuaJsonEncodeVariant(variant: Variant, scheme: JsonEncodingScheme.DeprecatedNonReversible | JsonEncodingScheme.DeprecatedReversible, namespaceArray: string[]): VariantJSON104 | null;
99
+ export declare function opcuaJsonDecodeVariant104(pojo: VariantJSON104 | null | undefined, builder: ExtensionObjectBuilder, namespaceArray: string[]): Variant;
100
+ export declare function opcuaJsonDecodeVariant105(pojo: VariantJSON105 | null | undefined, builder: ExtensionObjectBuilder, namespaceArray: string[]): Variant;
101
+ export declare function opcuaJsonDecodeVariant(pojo: VariantJSON105 | VariantJSON104 | null | undefined, builder: ExtensionObjectBuilder, namespaceArray: string[]): Variant;
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.opcuaJsonEncodeVariant105 = opcuaJsonEncodeVariant105;
4
+ exports.opcuaJsonEncodeVariant104 = opcuaJsonEncodeVariant104;
5
+ exports.opcuaJsonEncodeVariant = opcuaJsonEncodeVariant;
6
+ exports.opcuaJsonDecodeVariant104 = opcuaJsonDecodeVariant104;
7
+ exports.opcuaJsonDecodeVariant105 = opcuaJsonDecodeVariant105;
8
+ exports.opcuaJsonDecodeVariant = opcuaJsonDecodeVariant;
9
+ /**
10
+ * ==========================================================================
11
+ * Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in
21
+ * all copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
29
+ * IN THE SOFTWARE.
30
+ * ==========================================================================
31
+ */
32
+ const node_opcua_variant_1 = require("node-opcua-variant");
33
+ const json_basic_encoding_body_functor_js_1 = require("./json_basic_encoding_body_functor.js");
34
+ const json_encoding_scheme_js_1 = require("./json_encoding_scheme.js");
35
+ // Array
36
+ // If an element is NULL, the element shall be encoded as the JSON literal ‘null’.
37
+ // Otherwise, the element is encoded according to the rules defined for the type.
38
+ // Multi-dimensional Arrays are encoded as nested JSON arrays.
39
+ // The outer array is the first dimension and the innermost array is the last dimension.
40
+ function body(variant, scheme, namespaceArray) {
41
+ const f = (0, json_basic_encoding_body_functor_js_1.bodyEncodeFunctor)(variant.dataType);
42
+ if (variant.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) {
43
+ return f(variant.value, scheme, namespaceArray);
44
+ }
45
+ else {
46
+ const array = [];
47
+ for (const e of variant.value) {
48
+ array.push(f(e, scheme, namespaceArray));
49
+ }
50
+ return array;
51
+ }
52
+ }
53
+ function opcuaJsonEncodeVariant105(variant, mode, namespaceArray) {
54
+ /**
55
+ * For the non-reversible form, Variant values shall be encoded as a JSON object containing only
56
+ * the value of the Body field. The Type and Dimensions fields are dropped. Multi-dimensional
57
+ * arrays are encoded as a multi dimensional JSON array.
58
+ */
59
+ if (variant.dataType === node_opcua_variant_1.DataType.Null && variant.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) {
60
+ if (mode === json_encoding_scheme_js_1.JsonEncoderMode105.Compact) {
61
+ return {
62
+ UaType: node_opcua_variant_1.DataType.Null
63
+ };
64
+ }
65
+ else {
66
+ return { UaType: node_opcua_variant_1.DataType.Null, Value: null };
67
+ }
68
+ }
69
+ const scheme = mode === json_encoding_scheme_js_1.JsonEncoderMode105.Compact ? json_encoding_scheme_js_1.JsonEncodingScheme.Compact : json_encoding_scheme_js_1.JsonEncodingScheme.Verbose;
70
+ const Value = body(variant, scheme, namespaceArray);
71
+ const pojo = {
72
+ UaType: variant.dataType
73
+ // Value: body(variant, scheme, namespaceArray),
74
+ };
75
+ if (Value !== undefined) {
76
+ pojo.Value = Value;
77
+ }
78
+ if (variant.arrayType === node_opcua_variant_1.VariantArrayType.Matrix && variant.dimensions) {
79
+ pojo.UaDimensions = [...variant.dimensions];
80
+ }
81
+ if (mode === json_encoding_scheme_js_1.JsonEncoderMode105.Compact && variant.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) {
82
+ // remove default values for compact encoding
83
+ switch (variant.dataType) {
84
+ case node_opcua_variant_1.DataType.Boolean:
85
+ if (pojo.Value === false) {
86
+ // remove false value for compact encoding
87
+ delete pojo.Value;
88
+ }
89
+ break;
90
+ case node_opcua_variant_1.DataType.SByte:
91
+ case node_opcua_variant_1.DataType.Byte:
92
+ case node_opcua_variant_1.DataType.Int16:
93
+ case node_opcua_variant_1.DataType.UInt16:
94
+ case node_opcua_variant_1.DataType.Int32:
95
+ case node_opcua_variant_1.DataType.UInt32:
96
+ case node_opcua_variant_1.DataType.Float:
97
+ case node_opcua_variant_1.DataType.Double:
98
+ if (pojo.Value === 0) {
99
+ // remove 0 value for compact encoding
100
+ delete pojo.Value;
101
+ }
102
+ break;
103
+ case node_opcua_variant_1.DataType.String:
104
+ if (pojo.Value === "") {
105
+ // remove empty string for compact encoding
106
+ delete pojo.Value;
107
+ }
108
+ break;
109
+ case node_opcua_variant_1.DataType.Int64:
110
+ case node_opcua_variant_1.DataType.UInt64:
111
+ case node_opcua_variant_1.DataType.DateTime:
112
+ case node_opcua_variant_1.DataType.Guid:
113
+ case node_opcua_variant_1.DataType.ByteString:
114
+ case node_opcua_variant_1.DataType.XmlElement:
115
+ case node_opcua_variant_1.DataType.NodeId:
116
+ case node_opcua_variant_1.DataType.QualifiedName:
117
+ case node_opcua_variant_1.DataType.LocalizedText:
118
+ case node_opcua_variant_1.DataType.ExtensionObject:
119
+ case node_opcua_variant_1.DataType.StatusCode:
120
+ // these are all scalar types, so we can remove the UaType
121
+ // delete pojo.UaType;
122
+ break;
123
+ }
124
+ }
125
+ return pojo;
126
+ }
127
+ function opcuaJsonEncodeVariant104(variant, mode = json_encoding_scheme_js_1.JsonEncoderMode104.NonReversible, namespaceArray) {
128
+ /**
129
+ * For the non-reversible form, Variant values shall be encoded as a JSON object containing only
130
+ * the value of the Body field. The Type and Dimensions fields are dropped. Multi-dimensional
131
+ * arrays are encoded as a multi dimensional JSON array.
132
+ */
133
+ if (variant.dataType === node_opcua_variant_1.DataType.Null) {
134
+ return null;
135
+ }
136
+ const reversible = mode === json_encoding_scheme_js_1.JsonEncoderMode104.Reversible;
137
+ const scheme = mode === json_encoding_scheme_js_1.JsonEncoderMode104.Reversible
138
+ ? json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedReversible
139
+ : json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedNonReversible;
140
+ if (!reversible && variant.arrayType !== node_opcua_variant_1.VariantArrayType.Matrix) {
141
+ return body(variant, scheme, namespaceArray);
142
+ }
143
+ const pojo = {
144
+ Type: variant.dataType,
145
+ Body: body(variant, scheme, namespaceArray)
146
+ };
147
+ if (variant.arrayType === node_opcua_variant_1.VariantArrayType.Matrix && variant.dimensions) {
148
+ pojo.Dimensions = [...variant.dimensions];
149
+ }
150
+ return pojo;
151
+ }
152
+ function opcuaJsonEncodeVariant(variant, scheme = json_encoding_scheme_js_1.JsonEncodingScheme.Compact, namespaceArray) {
153
+ switch (scheme) {
154
+ case json_encoding_scheme_js_1.JsonEncodingScheme.Compact:
155
+ return opcuaJsonEncodeVariant105(variant, json_encoding_scheme_js_1.JsonEncoderMode105.Compact, namespaceArray);
156
+ case json_encoding_scheme_js_1.JsonEncodingScheme.Verbose:
157
+ return opcuaJsonEncodeVariant105(variant, json_encoding_scheme_js_1.JsonEncoderMode105.Verbose, namespaceArray);
158
+ case json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedReversible:
159
+ return opcuaJsonEncodeVariant104(variant, json_encoding_scheme_js_1.JsonEncoderMode104.Reversible, namespaceArray);
160
+ case json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedNonReversible:
161
+ return opcuaJsonEncodeVariant104(variant, json_encoding_scheme_js_1.JsonEncoderMode104.NonReversible, namespaceArray);
162
+ default:
163
+ throw new Error("Unknown JsonEncodingScheme");
164
+ }
165
+ }
166
+ function opcuaJsonDecodeVariant104(pojo, builder, namespaceArray) {
167
+ if (!pojo) {
168
+ return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null });
169
+ }
170
+ const dataType = pojo.Type;
171
+ const f = (0, json_basic_encoding_body_functor_js_1.bodyDecodeFunctor)(dataType);
172
+ if (Array.isArray(pojo.Body)) {
173
+ const value = pojo.Body.map((a) => f(a, builder, namespaceArray));
174
+ if (pojo.Dimensions) {
175
+ return new node_opcua_variant_1.Variant({
176
+ arrayType: node_opcua_variant_1.VariantArrayType.Matrix,
177
+ dimensions: pojo.Dimensions,
178
+ dataType,
179
+ value
180
+ });
181
+ }
182
+ return new node_opcua_variant_1.Variant({
183
+ arrayType: node_opcua_variant_1.VariantArrayType.Array,
184
+ dataType,
185
+ value
186
+ });
187
+ }
188
+ return new node_opcua_variant_1.Variant({
189
+ dataType,
190
+ arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
191
+ value: f ? f(pojo.Body, builder, namespaceArray) : null
192
+ });
193
+ }
194
+ function opcuaJsonDecodeVariant105(pojo, builder, namespaceArray) {
195
+ if (!pojo) {
196
+ return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null });
197
+ }
198
+ const dataType = pojo.UaType;
199
+ const f = (0, json_basic_encoding_body_functor_js_1.bodyDecodeFunctor)(dataType);
200
+ if (Array.isArray(pojo.Value)) {
201
+ const value = pojo.Value.map((a) => f(a, builder, namespaceArray));
202
+ if (pojo.UaDimensions) {
203
+ return new node_opcua_variant_1.Variant({
204
+ arrayType: node_opcua_variant_1.VariantArrayType.Matrix,
205
+ dimensions: pojo.UaDimensions,
206
+ dataType,
207
+ value
208
+ });
209
+ }
210
+ return new node_opcua_variant_1.Variant({
211
+ arrayType: node_opcua_variant_1.VariantArrayType.Array,
212
+ dataType,
213
+ value
214
+ });
215
+ }
216
+ return new node_opcua_variant_1.Variant({
217
+ dataType,
218
+ arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
219
+ value: f ? f(pojo.Value, builder, namespaceArray) : null
220
+ });
221
+ }
222
+ function opcuaJsonDecodeVariant(pojo, builder, namespaceArray) {
223
+ if (!pojo) {
224
+ return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null });
225
+ }
226
+ if ("Type" in pojo || !("UaType" in pojo)) {
227
+ return opcuaJsonDecodeVariant104(pojo, builder, namespaceArray);
228
+ }
229
+ else if ("UaType" in pojo) {
230
+ return opcuaJsonDecodeVariant105(pojo, builder, namespaceArray);
231
+ }
232
+ throw new Error("Invalid Variant JSON format");
233
+ }
234
+ //# sourceMappingURL=json_basic_encoding_decoding_variant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json_basic_encoding_decoding_variant.js","sourceRoot":"","sources":["../source/json_basic_encoding_decoding_variant.ts"],"names":[],"mappings":";;AAoHA,8DAyEC;AAED,8DA+BC;AAiBD,wDAiBC;AACD,8DAgCC;AAED,8DAgCC;AACD,wDAcC;AAlVD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,2DAAyE;AAEzE,+FAA0H;AAC1H,uEAAuG;AAuEvG,QAAQ;AACR,kFAAkF;AAClF,iFAAiF;AACjF,8DAA8D;AAC9D,wFAAwF;AAExF,SAAS,IAAI,CAAC,OAAgB,EAAE,MAA0B,EAAE,cAAyB;IACjF,MAAM,CAAC,GAAG,IAAA,uDAAiB,EAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9C,IAAI,OAAO,CAAC,SAAS,KAAK,qCAAgB,CAAC,MAAM,EAAE,CAAC;QAChD,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,CAAoB,CAAC;IACvE,CAAC;SAAM,CAAC;QACJ,MAAM,KAAK,GAA4B,EAAE,CAAC;QAC1C,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAC5B,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,CAA0B,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC;AAED,SAAgB,yBAAyB,CAAC,OAAgB,EAAE,IAAwB,EAAE,cAAyB;IAC3G;;;;OAIG;IACH,IAAI,OAAO,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CAAC,CAAC;AACP,CAAC;AACD,SAAgB,sBAAsB,CAClC,IAAwD,EACxD,OAA+B,EAC/B,cAAwB;IAExB,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,OAAO,IAAI,4BAAO,CAAC,EAAE,QAAQ,EAAE,6BAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,MAAM,IAAI,IAAI,IAAI,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,EAAE,CAAC;QACxC,OAAO,yBAAyB,CAAC,IAAI,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IACpE,CAAC;SAAM,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QAC1B,OAAO,yBAAyB,CAAC,IAAI,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IACpE,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { JsonDataSetMessageContentMask } from "node-opcua-types";
2
+ export declare enum JsonEncodingScheme {
3
+ Verbose = 2,
4
+ Compact = 3,
5
+ DeprecatedNonReversible = 0,// false
6
+ DeprecatedReversible = 1
7
+ }
8
+ /**
9
+ * JSON encoders as per 1.04
10
+ */
11
+ export declare enum JsonEncoderMode104 {
12
+ Reversible = 1,
13
+ NonReversible = 0
14
+ }
15
+ /**
16
+ * From Part 6: 1.05.4:
17
+ *
18
+ * - The CompactEncoding omits all fields with a value equal to the default value for the type.
19
+ * - The VerboseEncoding includes all fields.
20
+ * - The CompactEncoding and VerboseEncoding replace the ReversibleEncoding and
21
+ * NonReversibleEncoding.
22
+ * The differences are described in Annex H.
23
+ * The VerboseEncoding also supports the RawData mode defined in OPC 10000-14.
24
+ *
25
+ * In RawData mode, encoders shall omit
26
+ * the following fields:
27
+ * UaType (see 5.4.2.17 and 5.4.2.18);
28
+ * UaTypeId (see 5.4.2.16);
29
+ * Decoders may not be able to process streams encoding in RawData mode unless they have
30
+ * access to the associated metadata.
31
+ *
32
+ * These fields are not omitted when serialization uses abstract DataTypes such as Structure
33
+ * (i.e. ExtensionObject) or BaseDataType (i.e. Variant).
34
+ *
35
+ * OPC 10000-14 specifies the behaviour if a Publisher is misconfigured with metadata that
36
+ * uses abstract DataTypes.
37
+ */
38
+ export declare enum JsonEncoderMode105 {
39
+ Verbose = 2,
40
+ /**
41
+ * A DataEncoding where encoding the serialized form omits optional and default values.
42
+ *
43
+ * All DataEncodings are CompactEncodings unless otherwise stated.
44
+ */
45
+ Compact = 3
46
+ }
47
+ export declare function toJsonEncodingScheme(mode: JsonEncoderMode104 | JsonEncoderMode105): JsonEncodingScheme;
48
+ export declare function makeDataValueEncodingEnum(fieldEncoding1: boolean, fieldEncoding2: boolean): JsonEncodingScheme;
49
+ export declare function JsonDataSetMessageContentMaskToJsonEncodingScheme(jsonDataMessageContentMask: JsonDataSetMessageContentMask): JsonEncodingScheme;
50
+ export declare function JsonEncodingSchemeToJsonDataSetMessageContentMask(scheme: JsonEncodingScheme): JsonDataSetMessageContentMask;