opcjs-client 0.1.17-alpha → 0.1.20-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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ISecureChannel, RequestHeader, NodeId, EndpointDescription, UserIdentityToken, Configuration, UserTokenTypeEnum, ILoggerFactory, Encoder, Decoder } from 'opcjs-base';
1
+ import { ISecureChannel, RequestHeader, NodeId, EndpointDescription, UserIdentityToken, Configuration, UserTokenTypeEnum, ILoggerFactory, Encoder, Decoder, ExpandedNodeId, QualifiedName, LocalizedText, NodeClassEnum, UaPrimitive } from 'opcjs-base';
2
2
 
3
3
  declare abstract class ServiceBase {
4
4
  private authToken;
@@ -10,11 +10,19 @@ declare abstract class ServiceBase {
10
10
  declare class SessionService extends ServiceBase {
11
11
  private configuration;
12
12
  private logger;
13
+ /**
14
+ * Creates a new session on the server (OPC UA Part 4, Section 5.7.2).
15
+ * @returns The session ID, authentication token, and selected server endpoint.
16
+ */
13
17
  createSession(): Promise<{
14
18
  sessionId: number;
15
19
  authToken: NodeId;
16
20
  endpoint: EndpointDescription;
17
21
  }>;
22
+ /**
23
+ * Activates an existing session using the supplied identity token (OPC UA Part 4, Section 5.7.3).
24
+ * @param identityToken - User identity token (anonymous, username/password, certificate, or issued token).
25
+ */
18
26
  activateSession(identityToken: UserIdentityToken): Promise<void>;
19
27
  recreate(authToken: NodeId): SessionService;
20
28
  constructor(authToken: NodeId, secureChannel: ISecureChannel, configuration: Configuration);
@@ -70,8 +78,8 @@ declare class Session {
70
78
 
71
79
  declare class ReadValueResult {
72
80
  value: unknown;
73
- status: string;
74
- constructor(value: unknown, status: string);
81
+ statusCode: number;
82
+ constructor(value: unknown, statusCode: number);
75
83
  }
76
84
 
77
85
  declare class ConfigurationClient extends Configuration {
@@ -81,126 +89,28 @@ declare class ConfigurationClient extends Configuration {
81
89
 
82
90
  declare class CallMethodResult {
83
91
  values: unknown[];
84
- status: string;
85
- constructor(values: unknown[], status: string);
92
+ statusCode: number;
93
+ constructor(values: unknown[], statusCode: number);
86
94
  }
87
95
 
88
- /**
89
- * Enumeration of variant types based on BuiltinType NodeIds.
90
- */
91
- declare enum BuiltInType {
92
- Null = 0,
93
- Boolean = 1,
94
- SByte = 2,
95
- Byte = 3,
96
- Int16 = 4,
97
- UInt16 = 5,
98
- Int32 = 6,
99
- UInt32 = 7,
100
- Int64 = 8,
101
- UInt64 = 9,
102
- Float = 10,
103
- Double = 11,
104
- String = 12,
105
- DateTime = 13,
106
- Guid = 14,
107
- ByteString = 15,
108
- XmlElement = 16,
109
- NodeId = 17,
110
- ExpandedNodeId = 18,
111
- StatusCode = 19,
112
- QualifiedName = 20,
113
- LocalizedText = 21,
114
- ExtensionObject = 22,
115
- DataValue = 23,
116
- Variant = 24,
117
- DiagnosticInfo = 25
96
+ declare class BrowseNodeResult {
97
+ referenceTypeId: NodeId;
98
+ isForward: boolean;
99
+ nodeId: ExpandedNodeId;
100
+ browseName: QualifiedName;
101
+ displayName: LocalizedText;
102
+ nodeClass: NodeClassEnum;
103
+ typeDefinition: ExpandedNodeId;
104
+ constructor(referenceTypeId: NodeId, isForward: boolean, nodeId: ExpandedNodeId, browseName: QualifiedName, displayName: LocalizedText, nodeClass: NodeClassEnum, typeDefinition: ExpandedNodeId);
118
105
  }
119
106
 
120
- /**
121
- * OPC UA Primitive Type Mappings
122
- *
123
- * We try to use the JS built in types wherever we can. But sometimes, often in the context
124
- * where Variant is involved, we need to have a wrapper type that includes the BuiltInType
125
- * for type checking and encoding purposes. In those cases, we define a wrapper type with a
126
- * value and a type field. For simple cases like boolean, we can just use the native boolean
127
- * type directly as UaBoolean.
128
- * @module primitives
129
- */
130
-
131
- type UaBoolean = boolean;
132
- /**
133
- * OPC UA Builtin Type Numeric IDs
134
- *
135
- * These correspond to the NodeId numeric identifiers defined in OPC UA Part 6, Table 1.
136
- */
137
- type UaSbyte = {
138
- value: number;
139
- readonly type: BuiltInType.SByte;
140
- };
141
- type UaByte = {
142
- value: number;
143
- readonly type: BuiltInType.Byte;
144
- };
145
- type UaInt16 = {
146
- value: number;
147
- readonly type: BuiltInType.Int16;
148
- };
149
- type UaUint16 = {
150
- value: number;
151
- readonly type: BuiltInType.UInt16;
152
- };
153
- type UaInt32 = {
154
- value: number;
155
- readonly type: BuiltInType.Int32;
156
- };
157
- type UaUint32 = {
158
- value: number;
159
- readonly type: BuiltInType.UInt32;
160
- };
161
- type UaInt64 = {
162
- value: bigint;
163
- readonly type: BuiltInType.Int64;
164
- };
165
- type UaUint64 = {
166
- value: bigint;
167
- readonly type: BuiltInType.UInt64;
168
- };
169
- type UaFloat = {
170
- value: number;
171
- readonly type: BuiltInType.Float;
172
- };
173
- type UaDouble = {
174
- value: number;
175
- readonly type: BuiltInType.Double;
176
- };
177
- /**
178
- * OPC UA String primitive type.
179
- *
180
- * A String in OPC UA can be null (encoded as length -1 in binary).
181
- * Using `string | null` instead of `string | undefined` aligns with the
182
- * OPC UA specification where null is an explicit, valid value distinct
183
- * from an empty string. Same is true for ByteString which can be null (length -1)
184
- * or a Uint8Array.
185
- */
186
- type UaString = string | null;
187
- type UaByteString = Uint8Array | null;
188
- type UaGuid = {
189
- value: string;
190
- readonly type: BuiltInType.Guid;
191
- };
192
- type UaDateTime = Date;
193
- /**
194
- * Union of all OPC UA primitive types accepted by {@link Variant.newFrom}.
195
- */
196
- type UaPrimitive = UaBoolean | UaSbyte | UaByte | UaInt16 | UaUint16 | UaInt32 | UaUint32 | UaInt64 | UaUint64 | UaFloat | UaDouble | UaString | UaDateTime | UaGuid | UaByteString;
197
-
198
107
  declare class Client {
199
108
  private configuration;
200
109
  private identity;
201
110
  private endpointUrl;
202
111
  private attributeService?;
203
112
  private methodService?;
113
+ private browseService?;
204
114
  private session?;
205
115
  private subscriptionHandler?;
206
116
  private logger;
@@ -216,6 +126,8 @@ declare class Client {
216
126
  * @returns The CallMethodResult for the invoked method.
217
127
  */
218
128
  callMethod(objectId: NodeId, methodId: NodeId, inputArguments?: UaPrimitive[]): Promise<CallMethodResult>;
129
+ browse(nodeId: NodeId, recursive?: boolean): Promise<BrowseNodeResult[]>;
130
+ private browseRecursive;
219
131
  subscribe(ids: NodeId[], callback: (data: {
220
132
  id: NodeId;
221
133
  value: unknown;
@@ -223,4 +135,4 @@ declare class Client {
223
135
  constructor(endpointUrl: string, configuration: ConfigurationClient, identity: UserIdentity);
224
136
  }
225
137
 
226
- export { Client, ConfigurationClient, UserIdentity };
138
+ export { BrowseNodeResult, Client, ConfigurationClient, UserIdentity };