node-opcua-nodeid
Advanced tools
Comparing version 2.6.0-alpha.1 to 2.6.1
/// <reference types="node" /> | ||
import { Guid } from "node-opcua-guid"; | ||
import { NodeId, NodeIdType } from "./nodeid"; | ||
/** | ||
* An ExpandedNodeId extends the NodeId structure. | ||
* | ||
* An ExpandedNodeId extends the NodeId structure by allowing the NamespaceUri to be | ||
* explicitly specified instead of using the NamespaceIndex. The NamespaceUri is optional. If it | ||
* is specified then the NamespaceIndex inside the NodeId shall be ignored. | ||
* | ||
* The ExpandedNodeId is encoded by first encoding a NodeId as described in Clause 5 .2.2.9 | ||
* and then encoding NamespaceUri as a String. | ||
* | ||
* An instance of an ExpandedNodeId may still use the NamespaceIndex instead of the | ||
* NamespaceUri. In this case, the NamespaceUri is not encoded in the stream. The presence of | ||
* the NamespaceUri in the stream is indicated by setting the NamespaceUri flag in the encoding | ||
* format byte for the NodeId. | ||
* | ||
* If the NamespaceUri is present then the encoder shall encode the NamespaceIndex as 0 in | ||
* the stream when the NodeId portion is encoded. The unused NamespaceIndex is included in | ||
* the stream for consistency, | ||
* | ||
* An ExpandedNodeId may also have a ServerIndex which is encoded as a UInt32 after the | ||
* NamespaceUri. The ServerIndex flag in the NodeId encoding byte indicates whether the | ||
* ServerIndex is present in the stream. The ServerIndex is omitted if it is equal to zero. | ||
* | ||
* @class ExpandedNodeId | ||
* @extends NodeId | ||
* | ||
* | ||
* | ||
* @param identifierType - the nodeID type | ||
* @param value - the node id value. The type of Value depends on identifierType. | ||
* @param namespace - the index of the related namespace (optional , default value = 0 ) | ||
* @param namespaceUri - NamespaceUri | ||
* @param serverIndex - the server Index | ||
* @constructor | ||
*/ | ||
export declare class ExpandedNodeId extends NodeId { | ||
@@ -10,6 +45,21 @@ static nullExpandedNodeId: ExpandedNodeId; | ||
constructor(identifierType: NodeIdType, value: number | string | Guid | Buffer, namespace: number, namespaceUri?: null | string, serverIndex?: number); | ||
/** | ||
* @method toString | ||
* @return {string} | ||
*/ | ||
toString(): string; | ||
/** | ||
* convert nodeId to a JSON string. same as {@link NodeId#toString } | ||
* @method toJSON | ||
* @return {String} | ||
*/ | ||
toJSON(): any; | ||
} | ||
export declare function coerceExpandedNodeId(value: any): ExpandedNodeId; | ||
/** | ||
* @method makeExpandedNodeId | ||
* @param value | ||
* @param [namespace=0] the namespace | ||
* @return {ExpandedNodeId} | ||
*/ | ||
export declare function makeExpandedNodeId(value: any, namespace?: number): ExpandedNodeId; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.makeExpandedNodeId = exports.coerceExpandedNodeId = exports.ExpandedNodeId = void 0; | ||
/** | ||
* @module node-opcua-nodeid | ||
*/ | ||
const _ = require("underscore"); | ||
const nodeid_1 = require("./nodeid"); | ||
let ExpandedNodeId = (() => { | ||
/** | ||
* An ExpandedNodeId extends the NodeId structure. | ||
* | ||
* An ExpandedNodeId extends the NodeId structure by allowing the NamespaceUri to be | ||
* explicitly specified instead of using the NamespaceIndex. The NamespaceUri is optional. If it | ||
* is specified then the NamespaceIndex inside the NodeId shall be ignored. | ||
* | ||
* The ExpandedNodeId is encoded by first encoding a NodeId as described in Clause 5 .2.2.9 | ||
* and then encoding NamespaceUri as a String. | ||
* | ||
* An instance of an ExpandedNodeId may still use the NamespaceIndex instead of the | ||
* NamespaceUri. In this case, the NamespaceUri is not encoded in the stream. The presence of | ||
* the NamespaceUri in the stream is indicated by setting the NamespaceUri flag in the encoding | ||
* format byte for the NodeId. | ||
* | ||
* If the NamespaceUri is present then the encoder shall encode the NamespaceIndex as 0 in | ||
* the stream when the NodeId portion is encoded. The unused NamespaceIndex is included in | ||
* the stream for consistency, | ||
* | ||
* An ExpandedNodeId may also have a ServerIndex which is encoded as a UInt32 after the | ||
* NamespaceUri. The ServerIndex flag in the NodeId encoding byte indicates whether the | ||
* ServerIndex is present in the stream. The ServerIndex is omitted if it is equal to zero. | ||
* | ||
* @class ExpandedNodeId | ||
* @extends NodeId | ||
* | ||
* | ||
* | ||
* @param identifierType - the nodeID type | ||
* @param value - the node id value. The type of Value depends on identifierType. | ||
* @param namespace - the index of the related namespace (optional , default value = 0 ) | ||
* @param namespaceUri - NamespaceUri | ||
* @param serverIndex - the server Index | ||
* @constructor | ||
*/ | ||
let ExpandedNodeId = /** @class */ (() => { | ||
class ExpandedNodeId extends nodeid_1.NodeId { | ||
@@ -16,2 +54,6 @@ constructor(identifierType, value, namespace, namespaceUri, serverIndex) { | ||
} | ||
/** | ||
* @method toString | ||
* @return {string} | ||
*/ | ||
toString() { | ||
@@ -27,2 +69,7 @@ let str = nodeid_1.NodeId.prototype.toString.call(this); | ||
} | ||
/** | ||
* convert nodeId to a JSON string. same as {@link NodeId#toString } | ||
* @method toJSON | ||
* @return {String} | ||
*/ | ||
toJSON() { | ||
@@ -38,5 +85,11 @@ return this.toString(); | ||
const n = nodeid_1.coerceNodeId(value); | ||
return new ExpandedNodeId(n.identifierType, n.value, n.namespace, null, 0); | ||
return new ExpandedNodeId(n.identifierType, n.value, n.namespace, /*namespaceUri*/ null, /*serverIndex*/ 0); | ||
} | ||
exports.coerceExpandedNodeId = coerceExpandedNodeId; | ||
/** | ||
* @method makeExpandedNodeId | ||
* @param value | ||
* @param [namespace=0] the namespace | ||
* @return {ExpandedNodeId} | ||
*/ | ||
function makeExpandedNodeId(value, namespace) { | ||
@@ -50,2 +103,3 @@ if (value === undefined && namespace === undefined) { | ||
if (value instanceof ExpandedNodeId) { | ||
// construct from a ExpandedNodeId => copy | ||
n = value; | ||
@@ -55,2 +109,3 @@ return new ExpandedNodeId(n.identifierType, n.value, n.namespace, n.namespaceUri, n.serverIndex); | ||
if (value instanceof nodeid_1.NodeId) { | ||
// construct from a nodeId | ||
n = value; | ||
@@ -57,0 +112,0 @@ return new ExpandedNodeId(n.identifierType, n.value, n.namespace, namespaceUri, serverIndex); |
@@ -0,2 +1,5 @@ | ||
/** | ||
* @module node-opcua-nodeid | ||
*/ | ||
export * from "./nodeid"; | ||
export * from "./expanded_nodeid"; |
@@ -11,6 +11,9 @@ "use strict"; | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* @module node-opcua-nodeid | ||
*/ | ||
__exportStar(require("./nodeid"), exports); | ||
__exportStar(require("./expanded_nodeid"), exports); | ||
//# sourceMappingURL=index.js.map |
/// <reference types="node" /> | ||
import { Guid } from "node-opcua-guid"; | ||
/** | ||
* `NodeIdType` an enumeration that specifies the possible types of a `NodeId` value. | ||
*/ | ||
export declare enum NodeIdType { | ||
/** | ||
* @static | ||
* @property NUMERIC | ||
* @default 0x1 | ||
*/ | ||
NUMERIC = 1, | ||
/** | ||
* @static | ||
* @property STRING | ||
* @default 0x2 | ||
*/ | ||
STRING = 2, | ||
/** | ||
* @static | ||
* @property GUID | ||
* @default 0x3 | ||
*/ | ||
GUID = 3, | ||
/** | ||
* @static | ||
* @property BYTESTRING | ||
* @default 0x4 | ||
*/ | ||
BYTESTRING = 4 | ||
} | ||
/** | ||
* Construct a node ID | ||
* | ||
* @class NodeId | ||
* @example | ||
* | ||
* ``` javascript | ||
* const nodeId = new NodeId(NodeIdType.NUMERIC,123,1); | ||
* ``` | ||
* @constructor | ||
*/ | ||
export declare class NodeId { | ||
@@ -17,14 +51,72 @@ static NodeIdType: typeof NodeIdType; | ||
namespace: number; | ||
/** | ||
* @param identifierType - the nodeID type | ||
* @param value - the node id value. The type of Value depends on identifierType. | ||
* @param namespace - the index of the related namespace (optional , default value = 0 ) | ||
*/ | ||
constructor(identifierType: NodeIdType, value: any, namespace?: number); | ||
/** | ||
* get the string representation of the nodeID. | ||
* | ||
* @method toString | ||
* @example | ||
* | ||
* ``` javascript | ||
* const nodeid = new NodeId(NodeIdType.NUMERIC, 123,1); | ||
* console.log(nodeid.toString()); | ||
* ``` | ||
* | ||
* ``` | ||
* >"ns=1;i=123" | ||
* ``` | ||
* | ||
* @param [options.addressSpace] {AddressSpace} | ||
* @return {String} | ||
*/ | ||
toString(options?: { | ||
addressSpace?: any; | ||
}): string; | ||
/** | ||
* convert nodeId to a JSON string. same as {@link NodeId#toString } | ||
*/ | ||
toJSON(): string; | ||
displayText(): string; | ||
/** | ||
* returns true if the NodeId is null or empty | ||
*/ | ||
isEmpty(): boolean; | ||
} | ||
export declare type NodeIdLike = string | NodeId | number; | ||
/** | ||
* Convert a value into a nodeId: | ||
* @class opcua | ||
* @method coerceNodeId | ||
* @static | ||
* | ||
* @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 {@link NodeId} : coerceNodeId returns value | ||
* @param value | ||
* @param namespace {number} | ||
*/ | ||
export declare function coerceNodeId(value: any, namespace?: number): NodeId; | ||
/** | ||
* construct a node Id from a value and a namespace. | ||
* @class opcua | ||
* @method makeNodeId | ||
* @static | ||
* @param {String|Buffer} value | ||
* @param [namespace]=0 {Number} the node id namespace | ||
* @return {NodeId} | ||
*/ | ||
export declare function makeNodeId(value: string | Buffer | number, namespace?: number): NodeId; | ||
/** | ||
* @class opcua | ||
* @method resolveNodeId | ||
* @static | ||
* @param nodeIdOrString | ||
* @return the nodeId | ||
*/ | ||
export declare function resolveNodeId(nodeIdOrString: NodeIdLike): NodeId; | ||
export declare function sameNodeId(n1: NodeId, n2: NodeId): boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sameNodeId = exports.resolveNodeId = exports.makeNodeId = exports.coerceNodeId = exports.NodeId = exports.NodeIdType = void 0; | ||
/** | ||
* @module node-opcua-nodeid | ||
*/ | ||
// tslint:disable:no-conditional-assignment | ||
const chalk = require("chalk"); | ||
@@ -9,11 +13,50 @@ const node_opcua_assert_1 = require("node-opcua-assert"); | ||
const _ = require("underscore"); | ||
/** | ||
* `NodeIdType` an enumeration that specifies the possible types of a `NodeId` value. | ||
*/ | ||
var NodeIdType; | ||
(function (NodeIdType) { | ||
/** | ||
* @static | ||
* @property NUMERIC | ||
* @default 0x1 | ||
*/ | ||
NodeIdType[NodeIdType["NUMERIC"] = 1] = "NUMERIC"; | ||
/** | ||
* @static | ||
* @property STRING | ||
* @default 0x2 | ||
*/ | ||
NodeIdType[NodeIdType["STRING"] = 2] = "STRING"; | ||
/** | ||
* @static | ||
* @property GUID | ||
* @default 0x3 | ||
*/ | ||
NodeIdType[NodeIdType["GUID"] = 3] = "GUID"; | ||
/** | ||
* @static | ||
* @property BYTESTRING | ||
* @default 0x4 | ||
*/ | ||
NodeIdType[NodeIdType["BYTESTRING"] = 4] = "BYTESTRING"; | ||
})(NodeIdType = exports.NodeIdType || (exports.NodeIdType = {})); | ||
let NodeId = (() => { | ||
/** | ||
* Construct a node ID | ||
* | ||
* @class NodeId | ||
* @example | ||
* | ||
* ``` javascript | ||
* const nodeId = new NodeId(NodeIdType.NUMERIC,123,1); | ||
* ``` | ||
* @constructor | ||
*/ | ||
let NodeId = /** @class */ (() => { | ||
class NodeId { | ||
/** | ||
* @param identifierType - the nodeID type | ||
* @param value - the node id value. The type of Value depends on identifierType. | ||
* @param namespace - the index of the related namespace (optional , default value = 0 ) | ||
*/ | ||
constructor(identifierType, value, namespace) { | ||
@@ -23,2 +66,3 @@ this.identifierType = identifierType; | ||
this.namespace = namespace || 0; | ||
// namespace shall be a UInt16 | ||
node_opcua_assert_1.assert(this.namespace >= 0 && this.namespace <= 0xFFFF); | ||
@@ -29,2 +73,20 @@ node_opcua_assert_1.assert(this.identifierType !== NodeIdType.NUMERIC || (this.value >= 0 && this.value <= 0xFFFFFFFF)); | ||
} | ||
/** | ||
* get the string representation of the nodeID. | ||
* | ||
* @method toString | ||
* @example | ||
* | ||
* ``` javascript | ||
* const nodeid = new NodeId(NodeIdType.NUMERIC, 123,1); | ||
* console.log(nodeid.toString()); | ||
* ``` | ||
* | ||
* ``` | ||
* >"ns=1;i=123" | ||
* ``` | ||
* | ||
* @param [options.addressSpace] {AddressSpace} | ||
* @return {String} | ||
*/ | ||
toString(options) { | ||
@@ -55,2 +117,3 @@ const addressSpace = options ? options.addressSpace : null; | ||
if (this.namespace === 0 && (this.identifierType === NodeIdType.NUMERIC)) { | ||
// find standard browse name | ||
const name = reverse_map(this.value.toString()) || "<undefined>"; | ||
@@ -60,2 +123,4 @@ str += " " + chalk.green.bold(name); | ||
else if (addressSpace.findNode) { | ||
// let use the provided address space to figure out the browseNode of this node. | ||
// to make the message a little bit more useful. | ||
const n = addressSpace.findNode(this); | ||
@@ -67,2 +132,5 @@ str += " " + (n ? n.browseName.toString() : " (????)"); | ||
} | ||
/** | ||
* convert nodeId to a JSON string. same as {@link NodeId#toString } | ||
*/ | ||
toJSON() { | ||
@@ -80,2 +148,5 @@ return this.toString(); | ||
} | ||
/** | ||
* returns true if the NodeId is null or empty | ||
*/ | ||
isEmpty() { | ||
@@ -104,2 +175,15 @@ switch (this.identifierType) { | ||
const regexNamespaceG = /ns=([0-9]+);g=(.*)/; | ||
/** | ||
* Convert a value into a nodeId: | ||
* @class opcua | ||
* @method coerceNodeId | ||
* @static | ||
* | ||
* @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 {@link NodeId} : coerceNodeId returns value | ||
* @param value | ||
* @param namespace {number} | ||
*/ | ||
function coerceNodeId(value, namespace) { | ||
@@ -164,2 +248,3 @@ let matches; | ||
else if (value instanceof Object) { | ||
// it could be a Enum or a NodeId Like object | ||
const tmp = value; | ||
@@ -174,2 +259,11 @@ value = tmp.value; | ||
exports.coerceNodeId = coerceNodeId; | ||
/** | ||
* construct a node Id from a value and a namespace. | ||
* @class opcua | ||
* @method makeNodeId | ||
* @static | ||
* @param {String|Buffer} value | ||
* @param [namespace]=0 {Number} the node id namespace | ||
* @return {NodeId} | ||
*/ | ||
function makeNodeId(value, namespace) { | ||
@@ -183,2 +277,5 @@ value = value || 0; | ||
} | ||
// 1 2 3 | ||
// 012345678901234567890123456789012345 | ||
// "72962B91-FA75-4AE6-8D28-B404DC7DAF63" | ||
if (node_opcua_guid_1.isValidGuid(value)) { | ||
@@ -189,2 +286,3 @@ identifierType = NodeIdType.GUID; | ||
identifierType = NodeIdType.STRING; | ||
// detect accidental string of form "ns=x;x"; | ||
node_opcua_assert_1.assert(value.indexOf("ns=") === -1, " makeNodeId(string) ? did you mean using coerceNodeId instead? "); | ||
@@ -201,2 +299,3 @@ } | ||
exports.makeNodeId = makeNodeId; | ||
// reverse maps | ||
let _nodeIdToNameIndex = {}; | ||
@@ -228,2 +327,9 @@ let _nameToNodeIdIndex = {}; | ||
} | ||
/** | ||
* @class opcua | ||
* @method resolveNodeId | ||
* @static | ||
* @param nodeIdOrString | ||
* @return the nodeId | ||
*/ | ||
function resolveNodeId(nodeIdOrString) { | ||
@@ -230,0 +336,0 @@ let nodeId; |
@@ -5,3 +5,3 @@ { | ||
"types": "./dist/index.d.ts", | ||
"version": "2.6.0-alpha.1", | ||
"version": "2.6.1", | ||
"description": "pure nodejs OPCUA SDK - module -nodeid", | ||
@@ -15,10 +15,10 @@ "scripts": { | ||
"dependencies": { | ||
"node-opcua-assert": "^2.6.0-alpha.1", | ||
"node-opcua-constants": "^2.6.0-alpha.1", | ||
"node-opcua-enum": "^2.6.0-alpha.1", | ||
"node-opcua-guid": "^2.6.0-alpha.1", | ||
"node-opcua-assert": "^2.6.1", | ||
"node-opcua-constants": "^2.6.1", | ||
"node-opcua-enum": "^2.6.1", | ||
"node-opcua-guid": "^2.6.1", | ||
"underscore": "^1.10.2" | ||
}, | ||
"devDependencies": { | ||
"node-opcua-benchmarker": "^2.6.0-alpha.1", | ||
"node-opcua-benchmarker": "^2.6.1", | ||
"should": "^13.2.3", | ||
@@ -42,3 +42,3 @@ "source-map-support": "^0.5.19" | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "becfcbe561410100413321e3f7f3913c6f75b837" | ||
"gitHead": "15f0c0f83232fc63310dc04fea187048c7a01e4b" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
55307
1135
0
Updatednode-opcua-assert@^2.6.1
Updatednode-opcua-constants@^2.6.1
Updatednode-opcua-enum@^2.6.1
Updatednode-opcua-guid@^2.6.1