opcjs-base 0.1.26-alpha → 0.1.29-alpha
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/dist/index.cjs +43 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -23
- package/dist/index.d.ts +20 -23
- package/dist/index.js +43 -50
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -107,7 +107,7 @@ declare class NodeId {
|
|
|
107
107
|
/**
|
|
108
108
|
* OPC UA ExpandedNodeId Type
|
|
109
109
|
*
|
|
110
|
-
* ExpandedNodeId
|
|
110
|
+
* ExpandedNodeId wraps a NodeId with optional server identification,
|
|
111
111
|
* allowing nodes to be identified across multiple servers.
|
|
112
112
|
*
|
|
113
113
|
* @module expanded-nodeid
|
|
@@ -116,41 +116,38 @@ declare class NodeId {
|
|
|
116
116
|
/**
|
|
117
117
|
* OPC UA ExpandedNodeId
|
|
118
118
|
*
|
|
119
|
-
* An ExpandedNodeId
|
|
119
|
+
* An ExpandedNodeId wraps a NodeId with optional server identification,
|
|
120
120
|
* allowing nodes to be identified across multiple servers.
|
|
121
121
|
*
|
|
122
122
|
* @example
|
|
123
123
|
* ```typescript
|
|
124
124
|
* import { ExpandedNodeId } from '@opcua/types';
|
|
125
125
|
*
|
|
126
|
-
* const expandedNodeId = new ExpandedNodeId(
|
|
126
|
+
* const expandedNodeId = new ExpandedNodeId(
|
|
127
|
+
* new NodeId(2, 123),
|
|
128
|
+
* 'http://opcfoundation.org/UA/',
|
|
129
|
+
* 1,
|
|
130
|
+
* );
|
|
127
131
|
* console.log(expandedNodeId.toString());
|
|
128
132
|
* // "svr=1;nsu=http://opcfoundation.org/UA/;ns=2;i=123"
|
|
129
133
|
* ```
|
|
130
134
|
*/
|
|
131
|
-
declare class ExpandedNodeId
|
|
132
|
-
/**
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
declare class ExpandedNodeId {
|
|
136
|
+
/** The wrapped NodeId. */
|
|
137
|
+
readonly nodeId: NodeId;
|
|
138
|
+
/** The server index (optional, for cross-server references). */
|
|
135
139
|
readonly serverIndex?: number;
|
|
136
|
-
/**
|
|
137
|
-
* The namespace URI (optional, alternative to namespace index)
|
|
138
|
-
*/
|
|
140
|
+
/** The namespace URI (optional, alternative to the namespace index on nodeId). */
|
|
139
141
|
readonly namespaceUri?: string;
|
|
140
142
|
/**
|
|
141
|
-
* Create a new ExpandedNodeId
|
|
143
|
+
* Create a new ExpandedNodeId.
|
|
142
144
|
*
|
|
143
|
-
* @param
|
|
144
|
-
* @param identifier - The identifier
|
|
145
|
+
* @param nodeId - The wrapped NodeId
|
|
145
146
|
* @param namespaceUri - Optional namespace URI
|
|
146
147
|
* @param serverIndex - Optional server index
|
|
147
148
|
*/
|
|
148
|
-
constructor(
|
|
149
|
-
/**
|
|
150
|
-
* Convert ExpandedNodeId to string representation
|
|
151
|
-
*
|
|
152
|
-
* @returns String representation of the ExpandedNodeId
|
|
153
|
-
*/
|
|
149
|
+
constructor(nodeId: NodeId, namespaceUri?: string, serverIndex?: number);
|
|
150
|
+
/** Convert ExpandedNodeId to string representation. */
|
|
154
151
|
toString(): string;
|
|
155
152
|
}
|
|
156
153
|
|
|
@@ -739,9 +736,9 @@ declare enum ExtensionObjectEncoding {
|
|
|
739
736
|
*/
|
|
740
737
|
declare class ExtensionObject {
|
|
741
738
|
/**
|
|
742
|
-
* The NodeId that identifies the type of structure encoded in the body.
|
|
739
|
+
* The NodeId (or ExpandedNodeId) that identifies the type of structure encoded in the body.
|
|
743
740
|
*/
|
|
744
|
-
readonly typeId: NodeId;
|
|
741
|
+
readonly typeId: NodeId | ExpandedNodeId;
|
|
745
742
|
/**
|
|
746
743
|
* The encoding used for the body.
|
|
747
744
|
*/
|
|
@@ -760,7 +757,7 @@ declare class ExtensionObject {
|
|
|
760
757
|
* @param encoding - The encoding type
|
|
761
758
|
* @param body - The encoded body (null for None encoding)
|
|
762
759
|
*/
|
|
763
|
-
constructor(typeId: NodeId, encoding?: ExtensionObjectEncoding, data?: IOpcType);
|
|
760
|
+
constructor(typeId: NodeId | ExpandedNodeId, encoding?: ExtensionObjectEncoding, data?: IOpcType);
|
|
764
761
|
/**
|
|
765
762
|
* Creates an ExtensionObject with no body.
|
|
766
763
|
*
|
|
@@ -783,7 +780,7 @@ declare class ExtensionObject {
|
|
|
783
780
|
* @param body - The XML encoded body
|
|
784
781
|
* @returns A new ExtensionObject with Xml encoding
|
|
785
782
|
*/
|
|
786
|
-
static newXml(typeId: NodeId, data: IOpcType): ExtensionObject;
|
|
783
|
+
static newXml(typeId: NodeId | ExpandedNodeId, data: IOpcType): ExtensionObject;
|
|
787
784
|
}
|
|
788
785
|
|
|
789
786
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -107,7 +107,7 @@ declare class NodeId {
|
|
|
107
107
|
/**
|
|
108
108
|
* OPC UA ExpandedNodeId Type
|
|
109
109
|
*
|
|
110
|
-
* ExpandedNodeId
|
|
110
|
+
* ExpandedNodeId wraps a NodeId with optional server identification,
|
|
111
111
|
* allowing nodes to be identified across multiple servers.
|
|
112
112
|
*
|
|
113
113
|
* @module expanded-nodeid
|
|
@@ -116,41 +116,38 @@ declare class NodeId {
|
|
|
116
116
|
/**
|
|
117
117
|
* OPC UA ExpandedNodeId
|
|
118
118
|
*
|
|
119
|
-
* An ExpandedNodeId
|
|
119
|
+
* An ExpandedNodeId wraps a NodeId with optional server identification,
|
|
120
120
|
* allowing nodes to be identified across multiple servers.
|
|
121
121
|
*
|
|
122
122
|
* @example
|
|
123
123
|
* ```typescript
|
|
124
124
|
* import { ExpandedNodeId } from '@opcua/types';
|
|
125
125
|
*
|
|
126
|
-
* const expandedNodeId = new ExpandedNodeId(
|
|
126
|
+
* const expandedNodeId = new ExpandedNodeId(
|
|
127
|
+
* new NodeId(2, 123),
|
|
128
|
+
* 'http://opcfoundation.org/UA/',
|
|
129
|
+
* 1,
|
|
130
|
+
* );
|
|
127
131
|
* console.log(expandedNodeId.toString());
|
|
128
132
|
* // "svr=1;nsu=http://opcfoundation.org/UA/;ns=2;i=123"
|
|
129
133
|
* ```
|
|
130
134
|
*/
|
|
131
|
-
declare class ExpandedNodeId
|
|
132
|
-
/**
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
declare class ExpandedNodeId {
|
|
136
|
+
/** The wrapped NodeId. */
|
|
137
|
+
readonly nodeId: NodeId;
|
|
138
|
+
/** The server index (optional, for cross-server references). */
|
|
135
139
|
readonly serverIndex?: number;
|
|
136
|
-
/**
|
|
137
|
-
* The namespace URI (optional, alternative to namespace index)
|
|
138
|
-
*/
|
|
140
|
+
/** The namespace URI (optional, alternative to the namespace index on nodeId). */
|
|
139
141
|
readonly namespaceUri?: string;
|
|
140
142
|
/**
|
|
141
|
-
* Create a new ExpandedNodeId
|
|
143
|
+
* Create a new ExpandedNodeId.
|
|
142
144
|
*
|
|
143
|
-
* @param
|
|
144
|
-
* @param identifier - The identifier
|
|
145
|
+
* @param nodeId - The wrapped NodeId
|
|
145
146
|
* @param namespaceUri - Optional namespace URI
|
|
146
147
|
* @param serverIndex - Optional server index
|
|
147
148
|
*/
|
|
148
|
-
constructor(
|
|
149
|
-
/**
|
|
150
|
-
* Convert ExpandedNodeId to string representation
|
|
151
|
-
*
|
|
152
|
-
* @returns String representation of the ExpandedNodeId
|
|
153
|
-
*/
|
|
149
|
+
constructor(nodeId: NodeId, namespaceUri?: string, serverIndex?: number);
|
|
150
|
+
/** Convert ExpandedNodeId to string representation. */
|
|
154
151
|
toString(): string;
|
|
155
152
|
}
|
|
156
153
|
|
|
@@ -739,9 +736,9 @@ declare enum ExtensionObjectEncoding {
|
|
|
739
736
|
*/
|
|
740
737
|
declare class ExtensionObject {
|
|
741
738
|
/**
|
|
742
|
-
* The NodeId that identifies the type of structure encoded in the body.
|
|
739
|
+
* The NodeId (or ExpandedNodeId) that identifies the type of structure encoded in the body.
|
|
743
740
|
*/
|
|
744
|
-
readonly typeId: NodeId;
|
|
741
|
+
readonly typeId: NodeId | ExpandedNodeId;
|
|
745
742
|
/**
|
|
746
743
|
* The encoding used for the body.
|
|
747
744
|
*/
|
|
@@ -760,7 +757,7 @@ declare class ExtensionObject {
|
|
|
760
757
|
* @param encoding - The encoding type
|
|
761
758
|
* @param body - The encoded body (null for None encoding)
|
|
762
759
|
*/
|
|
763
|
-
constructor(typeId: NodeId, encoding?: ExtensionObjectEncoding, data?: IOpcType);
|
|
760
|
+
constructor(typeId: NodeId | ExpandedNodeId, encoding?: ExtensionObjectEncoding, data?: IOpcType);
|
|
764
761
|
/**
|
|
765
762
|
* Creates an ExtensionObject with no body.
|
|
766
763
|
*
|
|
@@ -783,7 +780,7 @@ declare class ExtensionObject {
|
|
|
783
780
|
* @param body - The XML encoded body
|
|
784
781
|
* @returns A new ExtensionObject with Xml encoding
|
|
785
782
|
*/
|
|
786
|
-
static newXml(typeId: NodeId, data: IOpcType): ExtensionObject;
|
|
783
|
+
static newXml(typeId: NodeId | ExpandedNodeId, data: IOpcType): ExtensionObject;
|
|
787
784
|
}
|
|
788
785
|
|
|
789
786
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
import { XMLParser } from 'fast-xml-parser';
|
|
2
2
|
|
|
3
|
+
// src/types/expandedNodeId.ts
|
|
4
|
+
var ExpandedNodeId = class {
|
|
5
|
+
/** The wrapped NodeId. */
|
|
6
|
+
nodeId;
|
|
7
|
+
/** The server index (optional, for cross-server references). */
|
|
8
|
+
serverIndex;
|
|
9
|
+
/** The namespace URI (optional, alternative to the namespace index on nodeId). */
|
|
10
|
+
namespaceUri;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new ExpandedNodeId.
|
|
13
|
+
*
|
|
14
|
+
* @param nodeId - The wrapped NodeId
|
|
15
|
+
* @param namespaceUri - Optional namespace URI
|
|
16
|
+
* @param serverIndex - Optional server index
|
|
17
|
+
*/
|
|
18
|
+
constructor(nodeId, namespaceUri, serverIndex) {
|
|
19
|
+
this.nodeId = nodeId;
|
|
20
|
+
this.namespaceUri = namespaceUri;
|
|
21
|
+
this.serverIndex = serverIndex;
|
|
22
|
+
}
|
|
23
|
+
/** Convert ExpandedNodeId to string representation. */
|
|
24
|
+
toString() {
|
|
25
|
+
let result = "";
|
|
26
|
+
if (this.serverIndex !== void 0) {
|
|
27
|
+
result += `svr=${this.serverIndex};`;
|
|
28
|
+
}
|
|
29
|
+
if (this.namespaceUri !== void 0) {
|
|
30
|
+
result += `nsu=${this.namespaceUri};`;
|
|
31
|
+
}
|
|
32
|
+
result += this.nodeId.toString();
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
3
37
|
// src/types/nodeId.ts
|
|
4
38
|
var NodeIdType = /* @__PURE__ */ ((NodeIdType2) => {
|
|
5
39
|
NodeIdType2[NodeIdType2["Numeric"] = 0] = "Numeric";
|
|
@@ -170,47 +204,6 @@ var NodeId = class _NodeId {
|
|
|
170
204
|
}
|
|
171
205
|
};
|
|
172
206
|
|
|
173
|
-
// src/types/expandedNodeId.ts
|
|
174
|
-
var ExpandedNodeId = class extends NodeId {
|
|
175
|
-
/**
|
|
176
|
-
* The server index (optional, for cross-server references)
|
|
177
|
-
*/
|
|
178
|
-
serverIndex;
|
|
179
|
-
/**
|
|
180
|
-
* The namespace URI (optional, alternative to namespace index)
|
|
181
|
-
*/
|
|
182
|
-
namespaceUri;
|
|
183
|
-
/**
|
|
184
|
-
* Create a new ExpandedNodeId
|
|
185
|
-
*
|
|
186
|
-
* @param namespace - The namespace index
|
|
187
|
-
* @param identifier - The identifier
|
|
188
|
-
* @param namespaceUri - Optional namespace URI
|
|
189
|
-
* @param serverIndex - Optional server index
|
|
190
|
-
*/
|
|
191
|
-
constructor(namespace = 0, identifier = 0, namespaceUri, serverIndex) {
|
|
192
|
-
super(namespace, identifier);
|
|
193
|
-
this.namespaceUri = namespaceUri;
|
|
194
|
-
this.serverIndex = serverIndex;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Convert ExpandedNodeId to string representation
|
|
198
|
-
*
|
|
199
|
-
* @returns String representation of the ExpandedNodeId
|
|
200
|
-
*/
|
|
201
|
-
toString() {
|
|
202
|
-
let result = "";
|
|
203
|
-
if (this.serverIndex !== void 0) {
|
|
204
|
-
result += `svr=${this.serverIndex};`;
|
|
205
|
-
}
|
|
206
|
-
if (this.namespaceUri !== void 0) {
|
|
207
|
-
result += `nsu=${this.namespaceUri};`;
|
|
208
|
-
}
|
|
209
|
-
result += super.toString();
|
|
210
|
-
return result;
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
|
|
214
207
|
// src/codecs/encoder.ts
|
|
215
208
|
var Encoder = class {
|
|
216
209
|
encoders = /* @__PURE__ */ new Map();
|
|
@@ -228,7 +221,7 @@ var Encoder = class {
|
|
|
228
221
|
}
|
|
229
222
|
const writer = writerFactory();
|
|
230
223
|
const encodingId = value.getBinaryEncodingId();
|
|
231
|
-
const eid = new ExpandedNodeId(0, encodingId);
|
|
224
|
+
const eid = new ExpandedNodeId(new NodeId(0, encodingId));
|
|
232
225
|
writer.writeExpandedNodeId(eid);
|
|
233
226
|
const typeId = value.getTypeId();
|
|
234
227
|
const encodingFunction = this.encoders.get(typeId);
|
|
@@ -275,7 +268,7 @@ var Decoder = class {
|
|
|
275
268
|
}
|
|
276
269
|
const reader = readerFactory(data);
|
|
277
270
|
const eid = reader.readExpandedNodeId();
|
|
278
|
-
return this.decodeWithEncodingId(eid.identifier, reader);
|
|
271
|
+
return this.decodeWithEncodingId(eid.nodeId.identifier, reader);
|
|
279
272
|
}
|
|
280
273
|
decodeWithEncodingId(encodingId, reader) {
|
|
281
274
|
const decodingInfo = this.encodingIdMap.get(encodingId);
|
|
@@ -491,7 +484,7 @@ function decodeExpandedNodeId(reader) {
|
|
|
491
484
|
if (hasServerIndex) {
|
|
492
485
|
serverIndex = reader.readUInt32();
|
|
493
486
|
}
|
|
494
|
-
return new ExpandedNodeId(nodeId
|
|
487
|
+
return new ExpandedNodeId(nodeId, namespaceUri, serverIndex);
|
|
495
488
|
}
|
|
496
489
|
function encodeExpandedNodeId(writer, value) {
|
|
497
490
|
let extraFlags = 0;
|
|
@@ -502,9 +495,9 @@ function encodeExpandedNodeId(writer, value) {
|
|
|
502
495
|
extraFlags |= ExpandedNodeIdMask.ServerIndexFlag;
|
|
503
496
|
}
|
|
504
497
|
if (extraFlags === 0) {
|
|
505
|
-
encodeNodeId(writer, value);
|
|
498
|
+
encodeNodeId(writer, value.nodeId);
|
|
506
499
|
} else {
|
|
507
|
-
encodeNodeIdWithExtraFlags(writer, value, extraFlags);
|
|
500
|
+
encodeNodeIdWithExtraFlags(writer, value.nodeId, extraFlags);
|
|
508
501
|
}
|
|
509
502
|
if (value.namespaceUri !== void 0) {
|
|
510
503
|
writer.writeString(value.namespaceUri);
|
|
@@ -725,7 +718,7 @@ function encodeLocalizedText(writer, value) {
|
|
|
725
718
|
// src/types/extensionObject.ts
|
|
726
719
|
var ExtensionObject = class _ExtensionObject {
|
|
727
720
|
/**
|
|
728
|
-
* The NodeId that identifies the type of structure encoded in the body.
|
|
721
|
+
* The NodeId (or ExpandedNodeId) that identifies the type of structure encoded in the body.
|
|
729
722
|
*/
|
|
730
723
|
typeId;
|
|
731
724
|
/**
|
|
@@ -1054,7 +1047,7 @@ function decodeExtensionObject(reader, decoder) {
|
|
|
1054
1047
|
}
|
|
1055
1048
|
function encodeExtensionObject(writer, value, encoder) {
|
|
1056
1049
|
const typeId = value.typeId;
|
|
1057
|
-
if (
|
|
1050
|
+
if (typeId instanceof ExpandedNodeId) {
|
|
1058
1051
|
encodeExpandedNodeId(writer, typeId);
|
|
1059
1052
|
} else {
|
|
1060
1053
|
encodeNodeId(writer, typeId);
|
|
@@ -1370,7 +1363,7 @@ function StatusCodeToString(statusCode) {
|
|
|
1370
1363
|
if (statusCode === void 0) {
|
|
1371
1364
|
return "Unknown";
|
|
1372
1365
|
}
|
|
1373
|
-
const baseCode = statusCode & 4294901760;
|
|
1366
|
+
const baseCode = (statusCode & 4294901760) >>> 0;
|
|
1374
1367
|
const name = Object.entries(StatusCode).find(([, v]) => v === baseCode)?.[0];
|
|
1375
1368
|
return name ?? `0x${baseCode.toString(16).toUpperCase().padStart(8, "0")}`;
|
|
1376
1369
|
}
|
|
@@ -1393,7 +1386,7 @@ function StatusCodeGetFlagBits(statusCode) {
|
|
|
1393
1386
|
};
|
|
1394
1387
|
}
|
|
1395
1388
|
function StatusCodeIs(statusCode, expected) {
|
|
1396
|
-
return (statusCode & 4294901760) === expected;
|
|
1389
|
+
return (statusCode & 4294901760) >>> 0 === expected;
|
|
1397
1390
|
}
|
|
1398
1391
|
|
|
1399
1392
|
// src/types/dataValue.ts
|