node-opcua-nodeid
Advanced tools
Comparing version 2.79.0 to 2.81.0
@@ -96,4 +96,5 @@ /// <reference types="node" /> | ||
* @description: | ||
* - if nodeId is a string of form : "i=1234" => nodeId({value=1234, identifierType: NodeIdType.NUMERIC}) | ||
* - if nodeId is a string of form : "s=foo" => nodeId({value="foo", identifierType: NodeIdType.STRING}) | ||
* - if nodeId is a string of form : "i=1234" => nodeId({value=1234, identifierType: NodeIdType.NUMERIC}) | ||
* - if nodeId is a string of form : "s=foo" => nodeId({value="foo", identifierType: NodeIdType.STRING}) | ||
* - if nodeId is a string of form : "b=ABCD=" => nodeId({value=decodeBase64("ABCD="), identifierType: NodeIdType.BYTESTRING}) | ||
* - if nodeId is a {@link NodeId} : coerceNodeId returns value | ||
@@ -100,0 +101,0 @@ * @param value |
@@ -88,2 +88,5 @@ "use strict"; | ||
(0, node_opcua_assert_1.assert)(this.identifierType !== NodeIdType.STRING || typeof this.value === "string"); | ||
if (this.identifierType === NodeIdType.GUID) { | ||
this.value = (0, node_opcua_guid_1.normalizeGuid)(value); | ||
} | ||
} | ||
@@ -120,3 +123,3 @@ ; | ||
case NodeIdType.GUID: | ||
str = "ns=" + this.namespace + ";g=" + this.value; | ||
str = "ns=" + this.namespace + ";g=" + (0, node_opcua_guid_1.normalizeGuid)(this.value); | ||
break; | ||
@@ -193,3 +196,3 @@ default: | ||
const regexNamespaceB = /ns=([0-9]+);b=(.*)/; | ||
const regexNamespaceG = /ns=([0-9]+);g=(.*)/; | ||
const regexNamespaceG = /ns=([0-9]+);g=([0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12})/; | ||
/** | ||
@@ -202,4 +205,5 @@ * Convert a value into a nodeId: | ||
* @description: | ||
* - if nodeId is a string of form : "i=1234" => nodeId({value=1234, identifierType: NodeIdType.NUMERIC}) | ||
* - if nodeId is a string of form : "s=foo" => nodeId({value="foo", identifierType: NodeIdType.STRING}) | ||
* - if nodeId is a string of form : "i=1234" => nodeId({value=1234, identifierType: NodeIdType.NUMERIC}) | ||
* - if nodeId is a string of form : "s=foo" => nodeId({value="foo", identifierType: NodeIdType.STRING}) | ||
* - if nodeId is a string of form : "b=ABCD=" => nodeId({value=decodeBase64("ABCD="), identifierType: NodeIdType.BYTESTRING}) | ||
* - if nodeId is a {@link NodeId} : coerceNodeId returns value | ||
@@ -209,2 +213,3 @@ * @param value | ||
*/ | ||
// eslint-disable-next-line max-statements | ||
function coerceNodeId(value, namespace) { | ||
@@ -236,6 +241,8 @@ let matches; | ||
identifierType = NodeIdType.GUID; | ||
value = value.substring(2); | ||
value = (0, node_opcua_guid_1.normalizeGuid)(value.substring(2)); | ||
(0, node_opcua_assert_1.assert)((0, node_opcua_guid_1.isValidGuid)(value)); | ||
} | ||
else if ((0, node_opcua_guid_1.isValidGuid)(value)) { | ||
identifierType = NodeIdType.GUID; | ||
value = (0, node_opcua_guid_1.normalizeGuid)(value); | ||
} | ||
@@ -260,3 +267,3 @@ else if ((matches = regexNamespaceI.exec(value)) !== null) { | ||
namespace = parseInt(matches[1], 10); | ||
value = matches[2]; | ||
value = (0, node_opcua_guid_1.normalizeGuid)(matches[2]); | ||
} | ||
@@ -304,2 +311,3 @@ else { | ||
identifierType = NodeIdType.GUID; | ||
value = (0, node_opcua_guid_1.normalizeGuid)(value); | ||
} | ||
@@ -306,0 +314,0 @@ else { |
@@ -5,3 +5,3 @@ { | ||
"types": "./dist/index.d.ts", | ||
"version": "2.79.0", | ||
"version": "2.81.0", | ||
"description": "pure nodejs OPCUA SDK - module -nodeid", | ||
@@ -20,3 +20,3 @@ "scripts": { | ||
"node-opcua-constants": "2.77.0", | ||
"node-opcua-guid": "2.77.0" | ||
"node-opcua-guid": "2.81.0" | ||
}, | ||
@@ -43,3 +43,3 @@ "devDependencies": { | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "1a6d41827954dccf2c2cdff9344cc11fc99767f3" | ||
"gitHead": "fd89928bc4a4b9f31a6b6e5921f743e8284eba2b" | ||
} |
@@ -17,3 +17,3 @@ /** | ||
} from "node-opcua-constants"; | ||
import { emptyGuid, Guid, isValidGuid } from "node-opcua-guid"; | ||
import { emptyGuid, Guid, isValidGuid, normalizeGuid } from "node-opcua-guid"; | ||
@@ -106,2 +106,5 @@ /** | ||
assert(this.identifierType !== NodeIdType.STRING || typeof this.value === "string"); | ||
if (this.identifierType === NodeIdType.GUID) { | ||
this.value = normalizeGuid(value as string); | ||
} | ||
} | ||
@@ -138,3 +141,3 @@ | ||
case NodeIdType.GUID: | ||
str = "ns=" + this.namespace + ";g=" + this.value; | ||
str = "ns=" + this.namespace + ";g=" + normalizeGuid(this.value as string); | ||
break; | ||
@@ -218,3 +221,3 @@ default: | ||
const regexNamespaceB = /ns=([0-9]+);b=(.*)/; | ||
const regexNamespaceG = /ns=([0-9]+);g=(.*)/; | ||
const regexNamespaceG = /ns=([0-9]+);g=([0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12})/; | ||
@@ -228,4 +231,5 @@ /** | ||
* @description: | ||
* - if nodeId is a string of form : "i=1234" => nodeId({value=1234, identifierType: NodeIdType.NUMERIC}) | ||
* - if nodeId is a string of form : "s=foo" => nodeId({value="foo", identifierType: NodeIdType.STRING}) | ||
* - if nodeId is a string of form : "i=1234" => nodeId({value=1234, identifierType: NodeIdType.NUMERIC}) | ||
* - if nodeId is a string of form : "s=foo" => nodeId({value="foo", identifierType: NodeIdType.STRING}) | ||
* - if nodeId is a string of form : "b=ABCD=" => nodeId({value=decodeBase64("ABCD="), identifierType: NodeIdType.BYTESTRING}) | ||
* - if nodeId is a {@link NodeId} : coerceNodeId returns value | ||
@@ -235,2 +239,3 @@ * @param value | ||
*/ | ||
// eslint-disable-next-line max-statements | ||
export function coerceNodeId(value: unknown, namespace?: number): NodeId { | ||
@@ -263,5 +268,7 @@ let matches; | ||
identifierType = NodeIdType.GUID; | ||
value = value.substring(2); | ||
value = normalizeGuid(value.substring(2)); | ||
assert(isValidGuid(value as string)); | ||
} else if (isValidGuid(value)) { | ||
identifierType = NodeIdType.GUID; | ||
value = normalizeGuid(value); | ||
} else if ((matches = regexNamespaceI.exec(value)) !== null) { | ||
@@ -282,3 +289,3 @@ identifierType = NodeIdType.NUMERIC; | ||
namespace = parseInt(matches[1], 10); | ||
value = matches[2]; | ||
value =normalizeGuid(matches[2]); | ||
} else { | ||
@@ -324,2 +331,3 @@ throw new Error("String cannot be coerced to a nodeId : " + value); | ||
identifierType = NodeIdType.GUID; | ||
value = normalizeGuid(value); | ||
} else { | ||
@@ -326,0 +334,0 @@ identifierType = NodeIdType.STRING; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58945
1204
+ Addednode-opcua-guid@2.81.0(transitive)
- Removednode-opcua-guid@2.77.0(transitive)
Updatednode-opcua-guid@2.81.0