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.
- package/LICENSE +22 -0
- package/README.md +168 -4
- package/dist/104/index.d.ts +56 -0
- package/dist/104/index.js +93 -0
- package/dist/104/index.js.map +1 -0
- package/dist/105/index.d.ts +55 -0
- package/dist/105/index.js +95 -0
- package/dist/105/index.js.map +1 -0
- package/dist/decode_opcua_json.d.ts +31 -0
- package/dist/decode_opcua_json.js +61 -0
- package/dist/decode_opcua_json.js.map +1 -0
- package/dist/extension_object_constructor.d.ts +46 -0
- package/dist/extension_object_constructor.js +26 -0
- package/dist/extension_object_constructor.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +100 -0
- package/dist/index.js.map +1 -0
- package/dist/json_basic_encoding_body_functor.d.ts +34 -0
- package/dist/json_basic_encoding_body_functor.js +170 -0
- package/dist/json_basic_encoding_body_functor.js.map +1 -0
- package/dist/json_basic_encoding_decoding_byte_string.d.ts +27 -0
- package/dist/json_basic_encoding_decoding_byte_string.js +27 -0
- package/dist/json_basic_encoding_decoding_byte_string.js.map +1 -0
- package/dist/json_basic_encoding_decoding_data_value.d.ts +81 -0
- package/dist/json_basic_encoding_decoding_data_value.js +290 -0
- package/dist/json_basic_encoding_decoding_data_value.js.map +1 -0
- package/dist/json_basic_encoding_decoding_date_time.d.ts +26 -0
- package/dist/json_basic_encoding_decoding_date_time.js +43 -0
- package/dist/json_basic_encoding_decoding_date_time.js.map +1 -0
- package/dist/json_basic_encoding_decoding_extension_object.d.ts +65 -0
- package/dist/json_basic_encoding_decoding_extension_object.js +461 -0
- package/dist/json_basic_encoding_decoding_extension_object.js.map +1 -0
- package/dist/json_basic_encoding_decoding_int64.d.ts +30 -0
- package/dist/json_basic_encoding_decoding_int64.js +56 -0
- package/dist/json_basic_encoding_decoding_int64.js.map +1 -0
- package/dist/json_basic_encoding_decoding_localizedtext.d.ts +33 -0
- package/dist/json_basic_encoding_decoding_localizedtext.js +62 -0
- package/dist/json_basic_encoding_decoding_localizedtext.js.map +1 -0
- package/dist/json_basic_encoding_decoding_nodeid.d.ts +73 -0
- package/dist/json_basic_encoding_decoding_nodeid.js +314 -0
- package/dist/json_basic_encoding_decoding_nodeid.js.map +1 -0
- package/dist/json_basic_encoding_decoding_qualifiedname.d.ts +35 -0
- package/dist/json_basic_encoding_decoding_qualifiedname.js +126 -0
- package/dist/json_basic_encoding_decoding_qualifiedname.js.map +1 -0
- package/dist/json_basic_encoding_decoding_statuscode.d.ts +39 -0
- package/dist/json_basic_encoding_decoding_statuscode.js +139 -0
- package/dist/json_basic_encoding_decoding_statuscode.js.map +1 -0
- package/dist/json_basic_encoding_decoding_variant.d.ts +101 -0
- package/dist/json_basic_encoding_decoding_variant.js +234 -0
- package/dist/json_basic_encoding_decoding_variant.js.map +1 -0
- package/dist/json_encoding_scheme.d.ts +50 -0
- package/dist/json_encoding_scheme.js +117 -0
- package/dist/json_encoding_scheme.js.map +1 -0
- package/package.json +90 -35
- package/source/104/index.ts +117 -0
- package/source/105/index.ts +118 -0
- package/source/decode_opcua_json.ts +67 -0
- package/source/extension_object_constructor.ts +48 -0
- package/source/index.ts +71 -0
- package/source/json_basic_encoding_body_functor.ts +190 -0
- package/source/json_basic_encoding_decoding_byte_string.ts +52 -0
- package/source/json_basic_encoding_decoding_data_value.ts +392 -0
- package/source/json_basic_encoding_decoding_date_time.ts +42 -0
- package/source/json_basic_encoding_decoding_extension_object.ts +531 -0
- package/source/json_basic_encoding_decoding_int64.ts +74 -0
- package/source/json_basic_encoding_decoding_localizedtext.ts +69 -0
- package/source/json_basic_encoding_decoding_nodeid.ts +375 -0
- package/source/json_basic_encoding_decoding_qualifiedname.ts +144 -0
- package/source/json_basic_encoding_decoding_statuscode.ts +151 -0
- package/source/json_basic_encoding_decoding_variant.ts +339 -0
- package/source/json_encoding_scheme.ts +114 -0
- package/LICENSE.md +0 -40
- package/dist2/decode_opcua_json.d.ts +0 -12
- package/dist2/index.d.ts +0 -17
- package/dist2/index.js +0 -1
- package/dist2/json_basic_encoding_body_functor.d.ts +0 -14
- package/dist2/json_basic_encoding_decoding_byte_string.d.ts +0 -8
- package/dist2/json_basic_encoding_decoding_data_value.d.ts +0 -26
- package/dist2/json_basic_encoding_decoding_date_time.d.ts +0 -6
- package/dist2/json_basic_encoding_decoding_extension_object.d.ts +0 -32
- package/dist2/json_basic_encoding_decoding_int64.d.ts +0 -9
- package/dist2/json_basic_encoding_decoding_localizedtext.d.ts +0 -14
- package/dist2/json_basic_encoding_decoding_nodeid.d.ts +0 -33
- package/dist2/json_basic_encoding_decoding_qualifiedname.d.ts +0 -14
- package/dist2/json_basic_encoding_decoding_statuscode.d.ts +0 -16
- package/dist2/json_basic_encoding_decoding_variant.d.ts +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.opcuaJsonEncodeLocalizedText = opcuaJsonEncodeLocalizedText;
|
|
4
|
+
exports.opcuaJsonDecodeLocalizedText = opcuaJsonDecodeLocalizedText;
|
|
5
|
+
/**
|
|
6
|
+
* ==========================================================================
|
|
7
|
+
* Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in
|
|
17
|
+
* all copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
20
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
22
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
24
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
25
|
+
* IN THE SOFTWARE.
|
|
26
|
+
* ==========================================================================
|
|
27
|
+
*/
|
|
28
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
29
|
+
const json_encoding_scheme_js_1 = require("./json_encoding_scheme.js");
|
|
30
|
+
function opcuaJsonEncodeLocalizedText(localizedText, scheme = json_encoding_scheme_js_1.JsonEncodingScheme.Compact, _namespaceArray) {
|
|
31
|
+
if (!localizedText || (!localizedText.text && !localizedText.locale)) {
|
|
32
|
+
if (scheme === json_encoding_scheme_js_1.JsonEncodingScheme.Compact) {
|
|
33
|
+
// Compact encoding does not encode empty LocalizedText
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if (scheme === json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedNonReversible) {
|
|
39
|
+
// For the non-reversible form, LocalizedText value shall be encoded as a JSON string containing the Text component.
|
|
40
|
+
return localizedText.text || null;
|
|
41
|
+
}
|
|
42
|
+
const pojo = {
|
|
43
|
+
Text: localizedText.text || null
|
|
44
|
+
};
|
|
45
|
+
if (localizedText.locale) {
|
|
46
|
+
pojo.Locale = localizedText.locale;
|
|
47
|
+
}
|
|
48
|
+
return pojo;
|
|
49
|
+
}
|
|
50
|
+
function opcuaJsonDecodeLocalizedText(pojo) {
|
|
51
|
+
if (!pojo) {
|
|
52
|
+
return new node_opcua_data_model_1.LocalizedText();
|
|
53
|
+
}
|
|
54
|
+
if (typeof pojo === "string") {
|
|
55
|
+
return new node_opcua_data_model_1.LocalizedText({ text: pojo });
|
|
56
|
+
}
|
|
57
|
+
return new node_opcua_data_model_1.LocalizedText({
|
|
58
|
+
text: pojo.Text,
|
|
59
|
+
locale: pojo.Locale
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=json_basic_encoding_decoding_localizedtext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json_basic_encoding_decoding_localizedtext.js","sourceRoot":"","sources":["../source/json_basic_encoding_decoding_localizedtext.ts"],"names":[],"mappings":";;AAgCA,oEAuBC;AAED,oEAWC;AApED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iEAAsD;AACtD,uEAA+D;AAQ/D,SAAgB,4BAA4B,CACxC,aAAmC,EACnC,MAAM,GAAG,4CAAkB,CAAC,OAAO,EACnC,eAA0B;IAE1B,IAAI,CAAC,aAAa,IAAI,CAAC,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QACnE,IAAI,MAAM,KAAK,4CAAkB,CAAC,OAAO,EAAE,CAAC;YACxC,uDAAuD;YACvD,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,MAAM,KAAK,4CAAkB,CAAC,uBAAuB,EAAE,CAAC;QACxD,oHAAoH;QACpH,OAAO,aAAa,CAAC,IAAI,IAAI,IAAI,CAAC;IACtC,CAAC;IACD,MAAM,IAAI,GAAsB;QAC5B,IAAI,EAAE,aAAa,CAAC,IAAI,IAAI,IAAI;KACnC,CAAC;IACF,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;IACvC,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAgB,4BAA4B,CAAC,IAAmD;IAC5F,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,OAAO,IAAI,qCAAa,EAAE,CAAC;IAC/B,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO,IAAI,qCAAa,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,IAAI,qCAAa,CAAC;QACrB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM;KACtB,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 { ExpandedNodeId, NodeId } from "node-opcua-nodeid";
|
|
25
|
+
import type { ExtensionObjectBuilder } from "./json_basic_encoding_body_functor.js";
|
|
26
|
+
import { JsonEncodingScheme } from "./json_encoding_scheme.js";
|
|
27
|
+
export interface NodeIdJSON104 {
|
|
28
|
+
IdType?: 0 | 1 | 2 | 3;
|
|
29
|
+
Id: number | string;
|
|
30
|
+
Namespace?: number | string;
|
|
31
|
+
/** ExpandedNodeId only: the ServerIndex, omitted when 0 (Part 6 1.04 clause 5.4.2.11) */
|
|
32
|
+
ServerUri?: number;
|
|
33
|
+
}
|
|
34
|
+
export type NodeIdJSON105 = string;
|
|
35
|
+
export type NodeIdJSON = NodeIdJSON104 | NodeIdJSON105;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* IdType The IdentifierType encoded as a JSON number.
|
|
39
|
+
* Allowed values are:
|
|
40
|
+
* 0 - UInt32 Identifier encoded as a JSON number.
|
|
41
|
+
* 1 - A String Identifier encoded as a JSON string.
|
|
42
|
+
* 2 - A Guid Identifier.
|
|
43
|
+
* 3 - A ByteString Identifier
|
|
44
|
+
*
|
|
45
|
+
* This field is omitted for UInt32 identifiers.
|
|
46
|
+
*
|
|
47
|
+
* Id The Identifier.
|
|
48
|
+
* The value of the id field specifies the encoding of this field.
|
|
49
|
+
*
|
|
50
|
+
* Namespace The NamespaceIndex for the NodeId.
|
|
51
|
+
* The field is encoded as a JSON number for the reversible encoding.
|
|
52
|
+
* The field is omitted if the NamespaceIndex equals 0.
|
|
53
|
+
* For the non-reversible encoding, the field is the NamespaceUri associated with the NamespaceIndex,
|
|
54
|
+
* encoded as a JSON string.
|
|
55
|
+
* A NamespaceIndex of 1 is always encoded as a JSON number.
|
|
56
|
+
*/
|
|
57
|
+
export declare function opcuaJsonEncodeNodeId104(value: NodeId, scheme?: JsonEncodingScheme, namespaceArray?: string[]): NodeIdJSON104;
|
|
58
|
+
export declare function opcuaJsonEncodeNodeIdAsString(value: NodeId, namespaceArray: string[]): string;
|
|
59
|
+
export declare function opcuaJsonEncodeExpandedNodeIdAsString(value: ExpandedNodeId, namespaceArray: string[]): string;
|
|
60
|
+
export declare function opcuaJsonEncodeNodeId105(value: NodeId, scheme: JsonEncodingScheme, namespaceArray?: string[]): NodeIdJSON105 | undefined;
|
|
61
|
+
export declare function opcuaJsonEncodeExpandedNodeId105(value: ExpandedNodeId, scheme: JsonEncodingScheme, namespaceArray?: string[]): NodeIdJSON105 | undefined;
|
|
62
|
+
export declare function opcuaJsonEncodeNodeId(value: NodeId, scheme: JsonEncodingScheme, namespaceArray?: string[]): NodeIdJSON | undefined;
|
|
63
|
+
export declare function opcuaJsonEncodeExpandedNodeId(value: ExpandedNodeId, scheme: JsonEncodingScheme, namespaceArray?: string[]): NodeIdJSON | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Part 6 1.04 clause 5.4.2.11: an ExpandedNodeId is the NodeId object plus a ServerUri field
|
|
66
|
+
* carrying the ServerIndex, omitted when 0. A NamespaceUri set on the ExpandedNodeId wins over
|
|
67
|
+
* the index in the non-reversible form, where the namespace is written as a URI anyway.
|
|
68
|
+
*/
|
|
69
|
+
export declare function opcuaJsonEncodeExpandedNodeId104(value: ExpandedNodeId, scheme: JsonEncodingScheme, namespaceArray?: string[]): NodeIdJSON104;
|
|
70
|
+
export declare function opcuaEncodeURIComponent(value: string): string;
|
|
71
|
+
export declare function opcuaDecodeURIComponent(value: string): string;
|
|
72
|
+
export declare function opcuaJsonDecodeNodeId(pojoOrString: NodeIdJSON | undefined, _builder?: ExtensionObjectBuilder | undefined, namespaceArray?: string[]): NodeId;
|
|
73
|
+
export declare function opcuaJsonDecodeExpandedNodeId(pojoOrString: NodeIdJSON | undefined, builder?: ExtensionObjectBuilder | undefined, namespaceArray?: string[]): ExpandedNodeId;
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.opcuaJsonEncodeNodeId104 = opcuaJsonEncodeNodeId104;
|
|
4
|
+
exports.opcuaJsonEncodeNodeIdAsString = opcuaJsonEncodeNodeIdAsString;
|
|
5
|
+
exports.opcuaJsonEncodeExpandedNodeIdAsString = opcuaJsonEncodeExpandedNodeIdAsString;
|
|
6
|
+
exports.opcuaJsonEncodeNodeId105 = opcuaJsonEncodeNodeId105;
|
|
7
|
+
exports.opcuaJsonEncodeExpandedNodeId105 = opcuaJsonEncodeExpandedNodeId105;
|
|
8
|
+
exports.opcuaJsonEncodeNodeId = opcuaJsonEncodeNodeId;
|
|
9
|
+
exports.opcuaJsonEncodeExpandedNodeId = opcuaJsonEncodeExpandedNodeId;
|
|
10
|
+
exports.opcuaJsonEncodeExpandedNodeId104 = opcuaJsonEncodeExpandedNodeId104;
|
|
11
|
+
exports.opcuaEncodeURIComponent = opcuaEncodeURIComponent;
|
|
12
|
+
exports.opcuaDecodeURIComponent = opcuaDecodeURIComponent;
|
|
13
|
+
exports.opcuaJsonDecodeNodeId = opcuaJsonDecodeNodeId;
|
|
14
|
+
exports.opcuaJsonDecodeExpandedNodeId = opcuaJsonDecodeExpandedNodeId;
|
|
15
|
+
/**
|
|
16
|
+
* ==========================================================================
|
|
17
|
+
* Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
|
|
18
|
+
*
|
|
19
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
20
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
21
|
+
* in the Software without restriction, including without limitation the rights
|
|
22
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
24
|
+
* furnished to do so, subject to the following conditions:
|
|
25
|
+
*
|
|
26
|
+
* The above copyright notice and this permission notice shall be included in
|
|
27
|
+
* all copies or substantial portions of the Software.
|
|
28
|
+
*
|
|
29
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
30
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
31
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
32
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
33
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
34
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
35
|
+
* IN THE SOFTWARE.
|
|
36
|
+
* ==========================================================================
|
|
37
|
+
*/
|
|
38
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid"); // -nodeid";
|
|
39
|
+
const json_encoding_scheme_js_1 = require("./json_encoding_scheme.js");
|
|
40
|
+
const nodeIdValueToJson = (value) => {
|
|
41
|
+
switch (value.identifierType) {
|
|
42
|
+
case node_opcua_nodeid_1.NodeIdType.NUMERIC:
|
|
43
|
+
return value.value;
|
|
44
|
+
case node_opcua_nodeid_1.NodeIdType.STRING:
|
|
45
|
+
return value.value;
|
|
46
|
+
case node_opcua_nodeid_1.NodeIdType.GUID:
|
|
47
|
+
return value.value;
|
|
48
|
+
case node_opcua_nodeid_1.NodeIdType.BYTESTRING:
|
|
49
|
+
return value.value.toString("base64");
|
|
50
|
+
default:
|
|
51
|
+
throw new Error(`Unknown NodeId identifier type: ${value.identifierType}`);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const nodeIdValueToString = (value) => {
|
|
55
|
+
switch (value.identifierType) {
|
|
56
|
+
case node_opcua_nodeid_1.NodeIdType.NUMERIC:
|
|
57
|
+
return `i=${value.value}`;
|
|
58
|
+
case node_opcua_nodeid_1.NodeIdType.STRING:
|
|
59
|
+
return `s=${value.value}`;
|
|
60
|
+
case node_opcua_nodeid_1.NodeIdType.GUID:
|
|
61
|
+
return `g=${value.value}`;
|
|
62
|
+
case node_opcua_nodeid_1.NodeIdType.BYTESTRING:
|
|
63
|
+
return `b=${value.value.toString("base64")}`;
|
|
64
|
+
default:
|
|
65
|
+
throw new Error(`Unknown NodeId identifier type: ${value.identifierType}`);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* IdType The IdentifierType encoded as a JSON number.
|
|
71
|
+
* Allowed values are:
|
|
72
|
+
* 0 - UInt32 Identifier encoded as a JSON number.
|
|
73
|
+
* 1 - A String Identifier encoded as a JSON string.
|
|
74
|
+
* 2 - A Guid Identifier.
|
|
75
|
+
* 3 - A ByteString Identifier
|
|
76
|
+
*
|
|
77
|
+
* This field is omitted for UInt32 identifiers.
|
|
78
|
+
*
|
|
79
|
+
* Id The Identifier.
|
|
80
|
+
* The value of the id field specifies the encoding of this field.
|
|
81
|
+
*
|
|
82
|
+
* Namespace The NamespaceIndex for the NodeId.
|
|
83
|
+
* The field is encoded as a JSON number for the reversible encoding.
|
|
84
|
+
* The field is omitted if the NamespaceIndex equals 0.
|
|
85
|
+
* For the non-reversible encoding, the field is the NamespaceUri associated with the NamespaceIndex,
|
|
86
|
+
* encoded as a JSON string.
|
|
87
|
+
* A NamespaceIndex of 1 is always encoded as a JSON number.
|
|
88
|
+
*/
|
|
89
|
+
function opcuaJsonEncodeNodeId104(value, scheme = json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedReversible, namespaceArray) {
|
|
90
|
+
const nodeIdIdentifierTypeToJSON = () => {
|
|
91
|
+
switch (value.identifierType) {
|
|
92
|
+
case node_opcua_nodeid_1.NodeIdType.NUMERIC:
|
|
93
|
+
return 0;
|
|
94
|
+
case node_opcua_nodeid_1.NodeIdType.STRING:
|
|
95
|
+
return 1;
|
|
96
|
+
case node_opcua_nodeid_1.NodeIdType.GUID:
|
|
97
|
+
return 2;
|
|
98
|
+
default:
|
|
99
|
+
return 3;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const IdType = nodeIdIdentifierTypeToJSON();
|
|
103
|
+
const Id = nodeIdValueToJson(value);
|
|
104
|
+
const pojo = { Id };
|
|
105
|
+
if (IdType !== 0) {
|
|
106
|
+
pojo.IdType = IdType;
|
|
107
|
+
}
|
|
108
|
+
if (value.namespace === 0) {
|
|
109
|
+
return pojo;
|
|
110
|
+
}
|
|
111
|
+
const reversible = !(scheme === json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedNonReversible);
|
|
112
|
+
if (value.namespace === 1 || reversible || !namespaceArray) {
|
|
113
|
+
pojo.Namespace = value.namespace;
|
|
114
|
+
return pojo;
|
|
115
|
+
}
|
|
116
|
+
pojo.Namespace = namespaceArray[value.namespace];
|
|
117
|
+
return pojo;
|
|
118
|
+
}
|
|
119
|
+
function opcuaJsonEncodeNodeIdAsString(value, namespaceArray) {
|
|
120
|
+
const namespace = namespaceArray ? namespaceArray[value.namespace] : undefined;
|
|
121
|
+
if (namespace) {
|
|
122
|
+
if (namespace === "http://opcfoundation.org/UA/") {
|
|
123
|
+
return `${nodeIdValueToString(value)}`;
|
|
124
|
+
}
|
|
125
|
+
const encodedNamespace = opcuaEncodeURIComponent(namespace);
|
|
126
|
+
return `nsu=${encodedNamespace};${nodeIdValueToString(value)}`;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
if (value.namespace === 0) {
|
|
130
|
+
return nodeIdValueToString(value);
|
|
131
|
+
}
|
|
132
|
+
// If the namespace is not found, we assume it is a new namespace
|
|
133
|
+
return `ns=${value.namespace};${nodeIdValueToString(value)}`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function opcuaJsonEncodeExpandedNodeIdAsString(value, namespaceArray) {
|
|
137
|
+
// const namespace = namespaceArray ? namespaceArray[value.namespace] : undefined;
|
|
138
|
+
let result = opcuaJsonEncodeNodeIdAsString(value, namespaceArray);
|
|
139
|
+
if (value.namespaceUri) {
|
|
140
|
+
const encodedNamespaceUri = opcuaEncodeURIComponent(value.namespaceUri);
|
|
141
|
+
result = `svu=${encodedNamespaceUri};${result}`;
|
|
142
|
+
}
|
|
143
|
+
else if (value.serverIndex !== 0) {
|
|
144
|
+
result = `svr=${value.serverIndex};${result}`;
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
function opcuaJsonEncodeNodeId105(value, scheme, namespaceArray) {
|
|
149
|
+
if (value.namespace === 0 && value.identifierType === node_opcua_nodeid_1.NodeIdType.NUMERIC && value.value === 0) {
|
|
150
|
+
if (scheme === json_encoding_scheme_js_1.JsonEncodingScheme.Compact) {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return opcuaJsonEncodeNodeIdAsString(value, namespaceArray || []);
|
|
155
|
+
}
|
|
156
|
+
function opcuaJsonEncodeExpandedNodeId105(value, scheme, namespaceArray) {
|
|
157
|
+
if (value.namespace === 0 && value.identifierType === node_opcua_nodeid_1.NodeIdType.NUMERIC && value.value === 0 && value.serverIndex === 0) {
|
|
158
|
+
if (scheme === json_encoding_scheme_js_1.JsonEncodingScheme.Compact) {
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return opcuaJsonEncodeExpandedNodeIdAsString(value, namespaceArray || []);
|
|
163
|
+
}
|
|
164
|
+
function opcuaJsonEncodeNodeId(value, scheme, namespaceArray) {
|
|
165
|
+
switch (scheme) {
|
|
166
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedReversible:
|
|
167
|
+
return opcuaJsonEncodeNodeId104(value, scheme, namespaceArray);
|
|
168
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedNonReversible:
|
|
169
|
+
return opcuaJsonEncodeNodeId104(value, scheme, namespaceArray);
|
|
170
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.Compact:
|
|
171
|
+
return opcuaJsonEncodeNodeId105(value, scheme, namespaceArray);
|
|
172
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.Verbose:
|
|
173
|
+
return opcuaJsonEncodeNodeId105(value, scheme, namespaceArray);
|
|
174
|
+
default:
|
|
175
|
+
throw new Error(`Invalid JsonEncodingScheme: ${scheme}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function opcuaJsonEncodeExpandedNodeId(value, scheme, namespaceArray) {
|
|
179
|
+
switch (scheme) {
|
|
180
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedReversible:
|
|
181
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedNonReversible:
|
|
182
|
+
return opcuaJsonEncodeExpandedNodeId104(value, scheme, namespaceArray);
|
|
183
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.Compact:
|
|
184
|
+
case json_encoding_scheme_js_1.JsonEncodingScheme.Verbose:
|
|
185
|
+
return opcuaJsonEncodeExpandedNodeId105(value, scheme, namespaceArray);
|
|
186
|
+
default:
|
|
187
|
+
throw new Error(`Invalid JsonEncodingScheme: ${scheme}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Part 6 1.04 clause 5.4.2.11: an ExpandedNodeId is the NodeId object plus a ServerUri field
|
|
192
|
+
* carrying the ServerIndex, omitted when 0. A NamespaceUri set on the ExpandedNodeId wins over
|
|
193
|
+
* the index in the non-reversible form, where the namespace is written as a URI anyway.
|
|
194
|
+
*/
|
|
195
|
+
function opcuaJsonEncodeExpandedNodeId104(value, scheme, namespaceArray) {
|
|
196
|
+
const pojo = opcuaJsonEncodeNodeId104(value, scheme, namespaceArray);
|
|
197
|
+
if (value.namespaceUri && scheme === json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedNonReversible) {
|
|
198
|
+
pojo.Namespace = value.namespaceUri;
|
|
199
|
+
}
|
|
200
|
+
if (value.serverIndex !== 0) {
|
|
201
|
+
pojo.ServerUri = value.serverIndex;
|
|
202
|
+
}
|
|
203
|
+
return pojo;
|
|
204
|
+
}
|
|
205
|
+
function opcuaEncodeURIComponent(value) {
|
|
206
|
+
return value.replace(/;/g, (match) => {
|
|
207
|
+
// Encode semicolon as %3B
|
|
208
|
+
return encodeURIComponent(match);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function opcuaDecodeURIComponent(value) {
|
|
212
|
+
return value.replace(/%3B/g, (match) => {
|
|
213
|
+
// Decode %3B back to semicolon
|
|
214
|
+
return decodeURIComponent(match);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function coerceNodeIdEx(nodeIdAsString, namespaceArray) {
|
|
218
|
+
//nsu=tag:acme.com,2023:schemas:data#off%3B;b=M/RbKBsRVkePCePcx24oRA==
|
|
219
|
+
const match = nodeIdAsString.match(/^(nsu=([^;]+);)?(g=|s=|i=|b=)(.*)$/);
|
|
220
|
+
if (match) {
|
|
221
|
+
const namespaceUri = match[2];
|
|
222
|
+
const identifierType = match[3];
|
|
223
|
+
const identifierValue = match[4];
|
|
224
|
+
let namespaceIndex;
|
|
225
|
+
if (namespaceUri) {
|
|
226
|
+
if (!namespaceArray) {
|
|
227
|
+
namespaceIndex = 0; // NAMESPACE_NOT_FOUND
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
// A URI which has the RFC 3986 Percent - Encoding applied to it.
|
|
231
|
+
// Any ‘;’ in the URI shall be percent encoded.
|
|
232
|
+
const decodedNamespaceUri = opcuaDecodeURIComponent(namespaceUri);
|
|
233
|
+
namespaceIndex = namespaceArray.indexOf(decodedNamespaceUri);
|
|
234
|
+
if (namespaceIndex < 0) {
|
|
235
|
+
namespaceIndex = 0; // NAMESPACE_NOT_FOUND
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
namespaceIndex = 0;
|
|
241
|
+
}
|
|
242
|
+
switch (identifierType) {
|
|
243
|
+
case "i=":
|
|
244
|
+
return new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeIdType.NUMERIC, parseInt(identifierValue, 10), namespaceIndex);
|
|
245
|
+
case "s=":
|
|
246
|
+
return new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeIdType.STRING, identifierValue, namespaceIndex);
|
|
247
|
+
case "g=":
|
|
248
|
+
return new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeIdType.GUID, identifierValue, namespaceIndex);
|
|
249
|
+
case "b=":
|
|
250
|
+
return new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeIdType.BYTESTRING, Buffer.from(identifierValue, "base64"), namespaceIndex);
|
|
251
|
+
default:
|
|
252
|
+
throw new Error(`Invalid NodeId format: ${nodeIdAsString}`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// Fallback to coerceNodeId
|
|
256
|
+
return (0, node_opcua_nodeid_1.coerceNodeId)(nodeIdAsString);
|
|
257
|
+
}
|
|
258
|
+
function opcuaJsonDecodeNodeId(pojoOrString, _builder, namespaceArray) {
|
|
259
|
+
if (pojoOrString === null || pojoOrString === undefined) {
|
|
260
|
+
throw new Error("opcuaJsonDecodeNodeId: pojoOrString cannot be null or undefined");
|
|
261
|
+
}
|
|
262
|
+
if (typeof pojoOrString === "string") {
|
|
263
|
+
return coerceNodeIdEx(pojoOrString, namespaceArray);
|
|
264
|
+
}
|
|
265
|
+
const pojo = pojoOrString;
|
|
266
|
+
const identifierType = (() => {
|
|
267
|
+
if (!pojo.IdType) {
|
|
268
|
+
return node_opcua_nodeid_1.NodeIdType.NUMERIC;
|
|
269
|
+
}
|
|
270
|
+
switch (pojo.IdType) {
|
|
271
|
+
case 2:
|
|
272
|
+
return node_opcua_nodeid_1.NodeIdType.GUID;
|
|
273
|
+
case 3:
|
|
274
|
+
return node_opcua_nodeid_1.NodeIdType.BYTESTRING;
|
|
275
|
+
default:
|
|
276
|
+
return node_opcua_nodeid_1.NodeIdType.STRING;
|
|
277
|
+
}
|
|
278
|
+
})();
|
|
279
|
+
const namespace = (() => {
|
|
280
|
+
if (!pojo.Namespace)
|
|
281
|
+
return 0;
|
|
282
|
+
if (typeof pojo.Namespace === "number") {
|
|
283
|
+
return pojo.Namespace;
|
|
284
|
+
}
|
|
285
|
+
const NAMESPACE_NOT_FOUND = 0xffff;
|
|
286
|
+
if (!namespaceArray) {
|
|
287
|
+
return NAMESPACE_NOT_FOUND;
|
|
288
|
+
}
|
|
289
|
+
const index = namespaceArray.indexOf(pojo.Namespace);
|
|
290
|
+
if (index < 0) {
|
|
291
|
+
return NAMESPACE_NOT_FOUND;
|
|
292
|
+
}
|
|
293
|
+
return index;
|
|
294
|
+
})();
|
|
295
|
+
const value = (() => {
|
|
296
|
+
switch (identifierType) {
|
|
297
|
+
case node_opcua_nodeid_1.NodeIdType.NUMERIC:
|
|
298
|
+
return typeof pojo.Id === "string" ? parseInt(pojo.Id, 10) : pojo.Id;
|
|
299
|
+
case node_opcua_nodeid_1.NodeIdType.BYTESTRING:
|
|
300
|
+
return Buffer.from(pojo.Id, "base64");
|
|
301
|
+
default:
|
|
302
|
+
return pojo.Id;
|
|
303
|
+
}
|
|
304
|
+
})();
|
|
305
|
+
return new node_opcua_nodeid_1.NodeId(identifierType, value, namespace);
|
|
306
|
+
}
|
|
307
|
+
function opcuaJsonDecodeExpandedNodeId(pojoOrString, builder, namespaceArray) {
|
|
308
|
+
const nodeId = opcuaJsonDecodeNodeId(pojoOrString, builder, namespaceArray);
|
|
309
|
+
// the 1.05 string form carries svr=/svu=, which coerceNodeId does not parse; the 1.04 object
|
|
310
|
+
// form carries ServerUri as the ServerIndex
|
|
311
|
+
const serverIndex = typeof pojoOrString === "object" && pojoOrString ? (pojoOrString.ServerUri ?? 0) : 0;
|
|
312
|
+
return node_opcua_nodeid_1.ExpandedNodeId.fromNodeId(nodeId, undefined, serverIndex);
|
|
313
|
+
}
|
|
314
|
+
//# sourceMappingURL=json_basic_encoding_decoding_nodeid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json_basic_encoding_decoding_nodeid.js","sourceRoot":"","sources":["../source/json_basic_encoding_decoding_nodeid.ts"],"names":[],"mappings":";;AAyGA,4DAoCC;AAED,sEAeC;AACD,sFAWC;AAED,4DAYC;AAED,4EAWC;AAED,sDAiBC;AACD,sEAeC;AAOD,4EAaC;AAED,0DAKC;AACD,0DAKC;AA2CD,sDAsDC;AAED,sEAUC;AAtXD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,yDAAqF,CAAC,YAAY;AAElG,uEAA+D;AA2B/D,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAmB,EAAE;IACzD,QAAQ,KAAK,CAAC,cAAc,EAAE,CAAC;QAC3B,KAAK,8BAAU,CAAC,OAAO;YACnB,OAAO,KAAK,CAAC,KAAe,CAAC;QACjC,KAAK,8BAAU,CAAC,MAAM;YAClB,OAAO,KAAK,CAAC,KAAe,CAAC;QACjC,KAAK,8BAAU,CAAC,IAAI;YAChB,OAAO,KAAK,CAAC,KAAe,CAAC;QACjC,KAAK,8BAAU,CAAC,UAAU;YACtB,OAAQ,KAAK,CAAC,KAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACtD;YACI,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC;IACnF,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,KAAa,EAAU,EAAE;IAClD,QAAQ,KAAK,CAAC,cAAc,EAAE,CAAC;QAC3B,KAAK,8BAAU,CAAC,OAAO;YACnB,OAAO,KAAK,KAAK,CAAC,KAAe,EAAE,CAAC;QAExC,KAAK,8BAAU,CAAC,MAAM;YAClB,OAAO,KAAK,KAAK,CAAC,KAAe,EAAE,CAAC;QAExC,KAAK,8BAAU,CAAC,IAAI;YAChB,OAA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AgB,6BAA6B,CACzC,YAAoC,EACpC,OAA4C,EAC5C,cAAyB;IAEzB,MAAM,MAAM,GAAG,qBAAqB,CAAC,YAAY,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IAC5E,6FAA6F;IAC7F,4CAA4C;IAC5C,MAAM,WAAW,GAAG,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzG,OAAO,kCAAc,CAAC,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { QualifiedName } from "node-opcua-data-model";
|
|
25
|
+
import type { ExtensionObjectBuilder } from "./json_basic_encoding_body_functor.js";
|
|
26
|
+
import { JsonEncodingScheme } from "./json_encoding_scheme.js";
|
|
27
|
+
export interface QualifiedNameJSON {
|
|
28
|
+
/** The Name component of the QualifiedName. */
|
|
29
|
+
Name: string;
|
|
30
|
+
/** The NamespaceIndex component of the QualifiedName encoded as a JSON number. */
|
|
31
|
+
Uri?: string | number;
|
|
32
|
+
}
|
|
33
|
+
export declare function opcuaJsonEncodeQualifiedName(qualifiedName: QualifiedName, scheme?: JsonEncodingScheme, namespaceArray?: string[]): QualifiedNameJSON | undefined;
|
|
34
|
+
export declare function opcuaJsonEncodeQualifiedNameAsString(qualifiedName: QualifiedName, scheme?: JsonEncodingScheme, namespaceArray?: string[]): string;
|
|
35
|
+
export declare function opcuaJsonDecodeQualifiedName(pojo: null | undefined | string | QualifiedNameJSON, builder?: ExtensionObjectBuilder, namespaceArray?: string[]): QualifiedName;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.opcuaJsonEncodeQualifiedName = opcuaJsonEncodeQualifiedName;
|
|
4
|
+
exports.opcuaJsonEncodeQualifiedNameAsString = opcuaJsonEncodeQualifiedNameAsString;
|
|
5
|
+
exports.opcuaJsonDecodeQualifiedName = opcuaJsonDecodeQualifiedName;
|
|
6
|
+
/**
|
|
7
|
+
* ==========================================================================
|
|
8
|
+
* Copyright (c) 2021-2026 Sterfive - etienne.rossignon@sterfive.com
|
|
9
|
+
*
|
|
10
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
* in the Software without restriction, including without limitation the rights
|
|
13
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
* furnished to do so, subject to the following conditions:
|
|
16
|
+
*
|
|
17
|
+
* The above copyright notice and this permission notice shall be included in
|
|
18
|
+
* all copies or substantial portions of the Software.
|
|
19
|
+
*
|
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
21
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
23
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
25
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
26
|
+
* IN THE SOFTWARE.
|
|
27
|
+
* ==========================================================================
|
|
28
|
+
*/
|
|
29
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
30
|
+
const json_basic_encoding_decoding_nodeid_js_1 = require("./json_basic_encoding_decoding_nodeid.js");
|
|
31
|
+
const json_encoding_scheme_js_1 = require("./json_encoding_scheme.js");
|
|
32
|
+
function opcuaJsonEncodeQualifiedName(qualifiedName, scheme = json_encoding_scheme_js_1.JsonEncodingScheme.Compact, namespaceArray) {
|
|
33
|
+
if (!qualifiedName.name || !qualifiedName.namespaceIndex) {
|
|
34
|
+
if (scheme === json_encoding_scheme_js_1.JsonEncodingScheme.Compact) {
|
|
35
|
+
// Compact encoding does not encode empty QualifiedName
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const pojo = {
|
|
40
|
+
Name: qualifiedName.name || ""
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* The NamespaceIndex component of the QualifiedName encoded as a JSON number.
|
|
44
|
+
* The Uri field is omitted if the NamespaceIndex equals 0.
|
|
45
|
+
* For the non-reversible form, the NamespaceUri associated with the NamespaceIndex
|
|
46
|
+
* portion of the QualifiedName is encoded as JSON string unless
|
|
47
|
+
* the NamespaceIndex is 1 or if NamespaceUri is unknown.
|
|
48
|
+
* In these cases, the NamespaceIndex is encoded as a JSON number.
|
|
49
|
+
*/
|
|
50
|
+
if (qualifiedName.namespaceIndex === 0) {
|
|
51
|
+
return pojo;
|
|
52
|
+
}
|
|
53
|
+
const reversible = !(scheme === json_encoding_scheme_js_1.JsonEncodingScheme.DeprecatedNonReversible);
|
|
54
|
+
if (reversible || !namespaceArray || qualifiedName.namespaceIndex === 1) {
|
|
55
|
+
pojo.Uri = qualifiedName.namespaceIndex;
|
|
56
|
+
return pojo;
|
|
57
|
+
}
|
|
58
|
+
pojo.Uri = namespaceArray[qualifiedName.namespaceIndex];
|
|
59
|
+
return pojo;
|
|
60
|
+
}
|
|
61
|
+
function opcuaJsonEncodeQualifiedNameAsString(qualifiedName, scheme = json_encoding_scheme_js_1.JsonEncodingScheme.Compact, namespaceArray) {
|
|
62
|
+
const pojo = opcuaJsonEncodeQualifiedName(qualifiedName, scheme, namespaceArray);
|
|
63
|
+
if (!pojo) {
|
|
64
|
+
return "";
|
|
65
|
+
}
|
|
66
|
+
if (!pojo.Uri) {
|
|
67
|
+
// if Uri is not defined, it means namespaceIndex is 0
|
|
68
|
+
return pojo.Name;
|
|
69
|
+
}
|
|
70
|
+
const namespaceIndex = typeof pojo.Uri === "number" ? pojo.Uri : namespaceArray?.indexOf(pojo.Uri);
|
|
71
|
+
if (namespaceIndex !== undefined && namespaceIndex >= 0) {
|
|
72
|
+
const namespaceUri = namespaceArray ? namespaceArray[namespaceIndex] : pojo.Uri;
|
|
73
|
+
const encodedUri = (0, json_basic_encoding_decoding_nodeid_js_1.opcuaEncodeURIComponent)(namespaceUri);
|
|
74
|
+
return `nsu=${encodedUri};${pojo.Name}`;
|
|
75
|
+
}
|
|
76
|
+
return pojo.Name;
|
|
77
|
+
}
|
|
78
|
+
function opcuaJsonDecodeQualifiedName(pojo, builder, namespaceArray) {
|
|
79
|
+
builder; // unused parameter,
|
|
80
|
+
if (!pojo) {
|
|
81
|
+
return new node_opcua_data_model_1.QualifiedName();
|
|
82
|
+
}
|
|
83
|
+
if (typeof pojo === "string") {
|
|
84
|
+
// example:
|
|
85
|
+
// - Hello
|
|
86
|
+
// - Hello;World
|
|
87
|
+
// - 3:Hello:World
|
|
88
|
+
// - nsu=http://widgets.com/schemas/hello;Hello;World
|
|
89
|
+
// - nsu=tag:acme.com,2023:schemas:data#off%3B;Boiler2
|
|
90
|
+
// check if starts with number + ":"
|
|
91
|
+
if (/^\d+:/.test(pojo)) {
|
|
92
|
+
const parts = pojo.split(":");
|
|
93
|
+
const namespaceIndex = parseInt(parts[0], 10);
|
|
94
|
+
const name = parts.slice(1).join(":");
|
|
95
|
+
return new node_opcua_data_model_1.QualifiedName({
|
|
96
|
+
name,
|
|
97
|
+
namespaceIndex
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
// check if starts with "nsu=" up tot he next ";"
|
|
101
|
+
if (pojo.startsWith("nsu=")) {
|
|
102
|
+
const endIndex = pojo.indexOf(";");
|
|
103
|
+
if (endIndex === -1) {
|
|
104
|
+
throw new Error(`Invalid QualifiedName format: ${pojo}`);
|
|
105
|
+
}
|
|
106
|
+
const namespaceUri = (0, json_basic_encoding_decoding_nodeid_js_1.opcuaDecodeURIComponent)(pojo.substring(4, endIndex));
|
|
107
|
+
const name = pojo.substring(endIndex + 1);
|
|
108
|
+
const namespaceIndex = namespaceArray ? namespaceArray.indexOf(namespaceUri) : 0;
|
|
109
|
+
return new node_opcua_data_model_1.QualifiedName({
|
|
110
|
+
name,
|
|
111
|
+
namespaceIndex
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
// otherwise, treat as a simple name
|
|
115
|
+
return new node_opcua_data_model_1.QualifiedName({
|
|
116
|
+
name: pojo,
|
|
117
|
+
namespaceIndex: 0
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
const namespaceIndex = pojo.Uri && typeof pojo.Uri === "number" ? pojo.Uri : 0;
|
|
121
|
+
return new node_opcua_data_model_1.QualifiedName({
|
|
122
|
+
name: pojo.Name,
|
|
123
|
+
namespaceIndex
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=json_basic_encoding_decoding_qualifiedname.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json_basic_encoding_decoding_qualifiedname.js","sourceRoot":"","sources":["../source/json_basic_encoding_decoding_qualifiedname.ts"],"names":[],"mappings":";;AAiCA,oEAiCC;AACD,oFAqBC;AAED,oEAqDC;AA/ID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iEAAsD;AAEtD,qGAA4G;AAC5G,uEAA+D;AAO/D,SAAgB,4BAA4B,CACxC,aAA4B,EAC5B,MAAM,GAAG,4CAAkB,CAAC,OAAO,EACnC,cAAyB;IAEzB,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;QACvD,IAAI,MAAM,KAAK,4CAAkB,CAAC,OAAO,EAAE,CAAC;YACxC,uDAAuD;YACvD,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC;IACD,MAAM,IAAI,GAAsB;QAC5B,IAAI,EAAE,aAAa,CAAC,IAAI,IAAI,EAAE;KACjC,CAAC;IACF;;;;;;;OAOG;IACH,IAAI,aAAa,CAAC,cAAc,KAAK,CAAC,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,KAAK,4CAAkB,C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