node-opcua-client 2.173.0 → 2.174.0

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/README.md CHANGED
@@ -1,54 +1,88 @@
1
1
  # node-opcua-client
2
2
 
3
- an implementation of an OPC UA stack fully written in javascript and NodeJS
3
+ [![NPM version](https://img.shields.io/npm/v/node-opcua-client)](https://www.npmjs.com/package/node-opcua-client)
4
+ [![NPM downloads](https://img.shields.io/npm/dm/node-opcua-client.svg)](https://www.npmjs.com/package/node-opcua-client)
5
+ [![CI](https://github.com/node-opcua/node-opcua/actions/workflows/workflow.yml/badge.svg)](https://github.com/node-opcua/node-opcua/actions/workflows/workflow.yml)
4
6
 
5
- see http://node-opcua.github.io/
7
+ **Lightweight OPC UA client for Node.js** — connect to any OPC UA server, browse, read, write, and subscribe to data changes.
6
8
 
7
- # Documentation
9
+ Part of the [node-opcua](https://github.com/node-opcua/node-opcua) project — the most popular OPC UA stack for Node.js.
8
10
 
9
- "NodeOPCUA by Example" (https://leanpub.com/node-opcuabyexample-edition2024) provides a good starting point to understand and start using node-opcua.
11
+ ## When to use this package
10
12
 
11
- More advanced interactive material & documentation is made available online for Registered members of the NodeOPCUA Subscription. Please visit https://support.sterfive.com to apply or contact Sterfive.
13
+ | Package | Use case |
14
+ |---|---|
15
+ | **`node-opcua-client`** | You only need **client** capabilities (smaller install, faster startup) |
16
+ | **`node-opcua`** | You need **both** client and server in the same project |
12
17
 
13
- ## Sponsors & Backers
18
+ ## Quick Start
14
19
 
15
- We appreciate that, once you have evaluated the software you consider supporting our effort by applying to our sponsor program:
20
+ ```bash
21
+ npm install node-opcua-client
22
+ ```
16
23
 
17
- - https://github.com/sponsors/node-opcua
18
- - https://opencollective.com/node-opcua
24
+ > **Requires Node.js 20 or later.**
19
25
 
20
- Grants ensure the following:
26
+ ### Connect, read, and disconnect
21
27
 
22
- - 🔨 Long-term maintenance of the project
23
- - ⚙️ maintain the website and continuous integration platform
24
- - 🛣 Progress on the road map
25
- - 🐛 Quick responses to bug reports
26
- - 🚀 New features & enhancements
27
- - ⚖️ representing the node-opcua user community at the OPC Foundation
28
+ ```typescript
29
+ import {
30
+ OPCUAClient,
31
+ AttributeIds,
32
+ DataValue,
33
+ } from "node-opcua-client";
28
34
 
29
- # Support
35
+ (async () => {
36
+ // 1. Create a client and connect to an OPC UA server
37
+ const client = OPCUAClient.create({ endpointMustExist: false });
38
+ await client.connect("opc.tcp://opcuademo.sterfive.com:26543");
30
39
 
31
- Technical Support is exclusively provided to registered members of the NodeOPCUA Subscription (https://support.sterfive.com) or through dedicated Professional Services.
40
+ // 2. Create a session
41
+ const session = await client.createSession();
32
42
 
33
- # License
43
+ // 3. Read the server's current time (ns=0;i=2258)
44
+ const dataValue: DataValue = await session.read({
45
+ nodeId: "ns=0;i=2258",
46
+ attributeId: AttributeIds.Value,
47
+ });
48
+ console.log("Server time:", dataValue.value.value);
34
49
 
35
- Node-OPCUA is made available to you under the MIT open-source license.
50
+ // 4. Clean up
51
+ await session.close();
52
+ await client.disconnect();
53
+ })();
54
+ ```
36
55
 
37
- See [LICENSE](./LICENSE) for details.
56
+ ## 📖 Documentation
38
57
 
39
- # value-added extensions
58
+ - 📘 [**NodeOPCUA by Example**](https://leanpub.com/node-opcuabyexample-edition2024) — The best starting point: practical, ready-to-use examples with full explanations.
59
+ - 📚 [**API Reference**](https://node-opcua.github.io/api_doc/index.html) — Complete API documentation.
60
+ - 🛠️ [**Client Tutorial**](https://github.com/node-opcua/node-opcua/blob/master/documentation/creating_a_client_typescript.md) — Step-by-step guide to building an OPC UA client in TypeScript.
40
61
 
41
- Contact Sterfive SAS (mailto:contact@sterfive.com) for additional companion modules that are available to registered members:
62
+ ## 🏢 Professional Support
42
63
 
43
- - node-opcua-pub-sub : Part 14 implementation to develop OPC UA PubSub over MQTT applications
44
- - node-opcua-webproxy: to operate node-opcua from within a web browser
45
- - node-opcua-optimized-client: super-charge OPC UA Client
46
- - react-components: a collection of React UI components
47
- - aggregator: a powerful OPC UA aggregator that can combine and monitored hundred of servers and millions of variables.
48
- - node-opcua-gds: a Global Discovery Server (Part 12)
49
- - node-opcua-modeler-ex: a powerful NO-GUI OPC UA modeler
64
+ | Feature | Community (GitHub) | Professional ([Sterfive](https://support.sterfive.com)) |
65
+ |---|:---:|:---:|
66
+ | Bug reports via GitHub Issues | ✅ | ✅ |
67
+ | CVE security advisories | After disclosure | **Early access — patch before public disclosure** |
68
+ | Priority response time | | |
69
+ | Private support channel | | ✅ |
70
+ | Architecture & code review | — | ✅ |
71
+ | Dedicated consulting hours | — | ✅ |
72
+ | Certifiable version | — | ✅ |
50
73
 
51
- # Copyright
74
+ [![Professional Support](https://img.shields.io/static/v1?style=for-the-badge&label=Professional&message=Support&labelColor=blue&color=green&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDQ5MS41MiA0OTEuNTIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDQ5MS41MiA0OTEuNTI7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KCTxnPg0KCQk8cGF0aCBkPSJNNDg3Ljk4OSwzODkuNzU1bC05My4xMDktOTIuOTc2Yy00LjgxMy00LjgwNi0xMi42NDItNC42Sinaptik-AI/pandas-aiNzQtMTcuMjczLDAuMzA3Yy03LjE0OCw3LjY4OS0xNC42NCwxNS41NTQtMjEuNzMsMjIuNjM0ICAgIGMtMC4yNzEsMC4yNy0wLjUwMSwwLjQ5My0wLjc2MywwLjc1NUw0NjcuMyw0MzIuNTA0YzguOTEtMTAuNjE0LDE2LjY1Ny0yMC40MSwyMS43My0yNi45NyAgICBDNDkyLjcyLDQwMC43NjIsNDkyLjI1NywzOTQuMDE5LDQ4Ny45ODksMzg5Ljc1NXoiLz4NCgk8L2c+DQo8L2c+DQo8Zz4NCgk8Zz4NCgkJPHBhdGggZD0iTTMzNC4zLDMzNy42NjFjLTM0LjMwNCwxMS4zNzktNzcuNTYsMC40MTMtMTE0LjU1NC0yOS41NDJjLTQ5LjAyMS0zOS42OTMtNzUuOTcyLTEwMi42NDItNjUuODM4LTE1MC41OTNMMzcuNjM0LDQxLjQxOCAgICBDMTcuNjUzLDU5LjQyNCwwLDc4LjU0NSwwLDkwYzAsMTQxLjc1MSwyNjAuMzQ0LDQxNS44OTYsNDAxLjUwMyw0MDAuOTMxYzExLjI5Ni0xLjE5OCwzMC4xNzYtMTguNjUxLDQ4LjA2Mi0zOC4xNjdMMzM0LjMsMzM3LjY2MSAgICB6Ii8+DQoJPC9nPg0KPC9nPg0KPGc+DQoJPGc+DQoJCTxwYXRoIGQ9Ik0xOTMuODU0LDk2LjA0MUwxMDEuMjEzLDMuNTNjLTQuMjI1LTQuMjItMTAuODgyLTQuNzI0LTE1LjY2NC0xLjE0NWMtNi42NTQsNC45ODMtMTYuNjQ4LDEyLjY1MS0yNy40NTMsMjEuNDk4ICAgIGwxMTEuOTQ1LDExMS43ODVjMC4wNjEtMC4wNiwwLjExMS0wLjExMywwLjE3Mi0wLjE3NGM3LjIzOC03LjIyOCwxNS4zNTUtMTQuODg1LDIzLjI5MS0yMi4xNjcgICAgQzE5OC41MzQsMTA4LjcxMywxOTguNjg0LDEwMC44NjMsMTkzLjg1NCw5Ni4wNDF6Ii8+DQoJPC9nPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPC9zdmc+)](https://support.sterfive.com)
52
75
 
53
- - Copyright (c) 2022-2024 Sterfive SAS - https://www.sterfive.com
54
- - Copyright (c) 2014-2022 Etienne Rossignon
76
+ 📧 Contact: [contact@sterfive.com](mailto:contact@sterfive.com)
77
+
78
+ ## :heart: Sponsors
79
+
80
+ If you find this package valuable, please consider supporting the project:
81
+
82
+ - [**Become a sponsor on GitHub**](https://github.com/sponsors/node-opcua)
83
+
84
+ Your sponsorship ensures long-term maintenance, new features, and continued OPC Foundation representation.
85
+
86
+ ## License
87
+
88
+ MIT — Copyright © 2014-2026 [Etienne Rossignon](https://github.com/erossignon) / [Sterfive SAS](https://www.sterfive.com)
@@ -69,10 +69,58 @@ export interface ClientSessionBase {
69
69
  * the session name
70
70
  */
71
71
  name: string;
72
+ /**
73
+ * the StatusCode returned by the last ActivateSession — usually `Good`, but
74
+ * e.g. `Good_PasswordChangeRequired` when the user must change the password
75
+ * (OPC 10000-18 §5.2.8). Lets a Client react without server-side access.
76
+ */
77
+ lastActivateSessionStatusCode: StatusCode;
78
+ /**
79
+ * Close the session.
80
+ *
81
+ * @param deleteSubscription - if `true` (the default), all
82
+ * subscriptions created on this session are deleted on
83
+ * the server. Set to `false` to preserve subscriptions
84
+ * for later transfer to a new session.
85
+ */
72
86
  close(callback: ErrorCallback): void;
73
87
  close(deleteSubscription: boolean, callback: ErrorCallback): void;
74
88
  close(deleteSubscription?: boolean): Promise<void>;
75
89
  }
90
+ /**
91
+ * An active session to an OPC UA server.
92
+ *
93
+ * `ClientSession` provides access to all OPC UA services:
94
+ * reading and writing node values, browsing the address space,
95
+ * calling methods, and creating subscriptions for data change
96
+ * or event notifications.
97
+ *
98
+ * Sessions are created via {@link OPCUAClient.createSession} or
99
+ * {@link OPCUAClient.create} followed by `client.createSession()`.
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const session = await client.createSession();
104
+ *
105
+ * // Read a value
106
+ * const dataValue = await session.read({
107
+ * nodeId: "ns=0;i=2258",
108
+ * attributeId: AttributeIds.Value,
109
+ * });
110
+ *
111
+ * // Browse the root folder
112
+ * const browseResult = await session.browse("RootFolder");
113
+ *
114
+ * // Write a value
115
+ * await session.write({
116
+ * nodeId: "ns=1;s=MyVariable",
117
+ * attributeId: AttributeIds.Value,
118
+ * value: { value: { dataType: DataType.Double, value: 42.0 } },
119
+ * });
120
+ *
121
+ * await session.close();
122
+ * ```
123
+ */
76
124
  export interface ClientSession extends ClientSessionBase {
77
125
  serverEndpoints: EndpointDescription[];
78
126
  }
@@ -87,11 +135,17 @@ export interface ClientSession extends EventEmitter {
87
135
  on(event: "session_restored", eventHandler: () => void): this;
88
136
  on(event: string | symbol, listener: (...args: any[]) => void): this;
89
137
  }
138
+ /**
139
+ * Browse service — navigate the OPC UA address space.
140
+ *
141
+ * The `browse()` and `browseNext()` methods are inherited from
142
+ * {@link node-opcua-pseudo-session!IBasicSessionBrowse}.
143
+ */
90
144
  export interface ClientSessionBrowseService extends IBasicSessionBrowse, IBasicSessionBrowseNext {
91
145
  /**
92
- * the maximum number of reference that the server should return per browseResult
93
- * Continuous points will be return by server to allow retrieving remaining references
94
- * with browseNext
146
+ * The maximum number of references the server should return
147
+ * per browse result. If the server has more, it returns a
148
+ * continuation point to retrieve the rest with `browseNext()`.
95
149
  */
96
150
  requestedMaxReferencesPerNode: number;
97
151
  }
@@ -101,7 +155,19 @@ export interface ClientSessionQueryService {
101
155
  queryFirst(queryFirstRequest: QueryFirstRequestLike): Promise<QueryFirstResponse>;
102
156
  queryFirst(queryFirstRequest: QueryFirstRequestLike, callback: ResponseCallback<QueryFirstResponse>): void;
103
157
  }
158
+ /**
159
+ * Call service — invoke methods on server objects.
160
+ *
161
+ * The `call()` method is inherited from
162
+ * {@link node-opcua-pseudo-session!IBasicSessionCall}.
163
+ */
104
164
  export interface ClientSessionCallService extends IBasicSessionCall {
165
+ /**
166
+ * Retrieve the input and output argument definitions of a method.
167
+ *
168
+ * @param methodId - the NodeId of the method
169
+ * @returns the argument definitions (input and output)
170
+ */
105
171
  getArgumentDefinition(methodId: MethodId): Promise<ArgumentDefinition>;
106
172
  getArgumentDefinition(methodId: MethodId, callback: (err: Error | null, args?: ArgumentDefinition) => void): void;
107
173
  }
@@ -139,6 +205,12 @@ export interface ClientSessionWriteService extends IBasicSessionWrite {
139
205
  */
140
206
  writeSingleNode(nodeToWrite: NodeIdLike, value: Variant, callback: ResponseCallback<StatusCode>): void;
141
207
  }
208
+ /**
209
+ * Raw subscription service — low-level OPC UA subscription management.
210
+ *
211
+ * For a higher-level API, use {@link ClientSubscription} via
212
+ * `ClientSession.createSubscription2()`.
213
+ */
142
214
  export interface ClientSessionRawSubscriptionService {
143
215
  /**
144
216
  *
@@ -48,47 +48,181 @@ export type WithSessionFunc = (session: ClientSession) => Promise<void>;
48
48
  export type WithSessionFuncP<T> = (session: ClientSession) => Promise<T>;
49
49
  export type WithSubscriptionFunc = (session: ClientSession, subscription: ClientSubscription) => Promise<void>;
50
50
  export type WithSubscriptionFuncP<T> = (session: ClientSession, subscription: ClientSubscription) => Promise<T>;
51
+ /**
52
+ * The OPC UA client interface.
53
+ *
54
+ * `OPCUAClient` provides methods to connect to an OPC UA server,
55
+ * create sessions, and manage the client lifecycle.
56
+ *
57
+ * Use {@link OPCUAClient.create} to instantiate a client.
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const client = OPCUAClient.create({ endpointMustExist: false });
62
+ * await client.connect("opc.tcp://localhost:26543");
63
+ * const session = await client.createSession();
64
+ * // ... use the session ...
65
+ * await session.close();
66
+ * await client.disconnect();
67
+ * ```
68
+ */
51
69
  export interface OPCUAClient<Events extends OPCUAClientBaseEvents = OPCUAClientBaseEvents> extends OPCUAClientBase<Events> {
70
+ /**
71
+ * Connect the client to the specified OPC UA server endpoint.
72
+ *
73
+ * The client will establish a secure channel, negotiate security
74
+ * parameters, and verify the server certificate.
75
+ *
76
+ * @param endpointUrl - the OPC UA endpoint URL (e.g. `"opc.tcp://host:4840"`)
77
+ */
52
78
  connect(endpointUrl: string): Promise<void>;
53
79
  connect(endpointUrl: string, callback: ErrorCallback): void;
80
+ /**
81
+ * Disconnect the client from the server.
82
+ *
83
+ * This closes all active sessions, subscriptions, and the
84
+ * underlying secure channel.
85
+ */
54
86
  disconnect(): Promise<void>;
55
87
  disconnect(callback: ErrorCallback): void;
88
+ /**
89
+ * Retrieve the list of endpoints exposed by the server.
90
+ *
91
+ * @param options - optional filter criteria for the endpoint query
92
+ * @returns the array of endpoint descriptions advertised by the server
93
+ */
56
94
  getEndpoints(options?: GetEndpointsOptions): Promise<EndpointDescription[]>;
57
95
  getEndpoints(options: GetEndpointsOptions, callback: ResponseCallback<EndpointDescription[]>): void;
58
96
  getEndpoints(callback: ResponseCallback<EndpointDescription[]>): void;
97
+ /**
98
+ * Discover OPC UA servers registered on the network.
99
+ *
100
+ * @param options - optional filter criteria for the discovery query
101
+ * @returns the array of discovered server application descriptions
102
+ */
59
103
  findServers(options?: FindServersRequestLike): Promise<ApplicationDescription[]>;
60
104
  findServers(options: FindServersRequestLike, callback: ResponseCallback<ApplicationDescription[]>): void;
61
105
  findServers(callback: ResponseCallback<ApplicationDescription[]>): void;
106
+ /**
107
+ * Create a new session on the connected server.
108
+ *
109
+ * If `userIdentityInfo` is not provided, an anonymous session
110
+ * is created.
111
+ *
112
+ * @param userIdentityInfo - optional credentials for user authentication
113
+ * @returns the newly created client session
114
+ */
62
115
  createSession(userIdentityInfo?: UserIdentityInfo): Promise<ClientSession>;
63
116
  createSession(userIdentityInfo: UserIdentityInfo, callback: (err: Error | null, session?: ClientSession) => void): void;
64
117
  createSession(callback: (err: Error | null, session?: ClientSession) => void): void;
118
+ /**
119
+ * Create a new session, using createSession2 service (OPC UA 1.04+).
120
+ *
121
+ * @param userIdentityInfo - optional credentials for user authentication
122
+ * @returns the newly created client session
123
+ */
65
124
  createSession2(userIdentityInfo?: UserIdentityInfo): Promise<ClientSession>;
66
125
  createSession2(userIdentityInfo: UserIdentityInfo, callback: (err: Error | null, session?: ClientSession) => void): void;
67
126
  createSession2(callback: (err: Error | null, session?: ClientSession) => void): void;
68
127
  /** @deprecated */
69
128
  changeSessionIdentity(session: ClientSession, userIdentityInfo: UserIdentityInfo): Promise<StatusCode>;
70
129
  changeSessionIdentity(session: ClientSession, userIdentityInfo: UserIdentityInfo, callback: CallbackT<StatusCode>): void;
130
+ /**
131
+ * Close a previously created session.
132
+ *
133
+ * @param session - the session to close
134
+ * @param deleteSubscriptions - if `true`, all subscriptions
135
+ * associated with the session are deleted on the server
136
+ */
71
137
  closeSession(session: ClientSession, deleteSubscriptions: boolean): Promise<void>;
72
138
  closeSession(session: ClientSession, deleteSubscriptions: boolean, callback: (err?: Error) => void): void;
139
+ /**
140
+ * Reactivate a session that was previously transferred or
141
+ * disconnected.
142
+ *
143
+ * @param session - the session to reactivate
144
+ */
73
145
  reactivateSession(session: ClientSession): Promise<void>;
74
146
  reactivateSession(session: ClientSession, callback: (err?: Error) => void): void;
147
+ /** @internal */
75
148
  createDefaultCertificate(): Promise<void>;
76
149
  /**
150
+ * Connect to a server, execute an async function within a session,
151
+ * then automatically close the session and disconnect.
152
+ *
153
+ * This is a convenience method for simple one-shot operations.
154
+ *
155
+ * @param endpointUrl - the server endpoint URL or endpoint with credentials
156
+ * @param inner_func - the async function to execute with the session
157
+ * @returns the value returned by `inner_func`
77
158
  *
78
- * @param endpointUrl
79
- * @param inner_func
159
+ * @example
160
+ * ```typescript
161
+ * const result = await client.withSessionAsync(
162
+ * "opc.tcp://localhost:26543",
163
+ * async (session) => {
164
+ * return await session.read({ nodeId: "ns=0;i=2258",
165
+ * attributeId: AttributeIds.Value });
166
+ * }
167
+ * );
168
+ * ```
80
169
  */
81
170
  withSessionAsync<T>(endpointUrl: string | EndpointWithUserIdentity, inner_func: WithSessionFuncP<T>): Promise<T>;
82
171
  /**
172
+ * Connect to a server, create a session and a subscription,
173
+ * execute an async function, then clean up everything.
83
174
  *
84
- * @param endpointUrl
85
- * @param parameters
86
- * @param inner_func
175
+ * This is a convenience method for subscription-based operations.
176
+ *
177
+ * @param endpointUrl - the server endpoint URL or endpoint with credentials
178
+ * @param parameters - subscription creation parameters
179
+ * @param inner_func - the async function to execute with the session and subscription
180
+ * @returns the value returned by `inner_func`
87
181
  */
88
182
  withSubscriptionAsync<T>(endpointUrl: string | EndpointWithUserIdentity, parameters: ClientSubscriptionOptions, inner_func: WithSubscriptionFuncP<T>): Promise<T>;
89
183
  }
184
+ /**
185
+ * Factory class for creating OPC UA client instances.
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * import { OPCUAClient } from "node-opcua-client";
190
+ *
191
+ * const client = OPCUAClient.create({
192
+ * endpointMustExist: false,
193
+ * requestedSessionTimeout: 60000,
194
+ * });
195
+ * ```
196
+ */
90
197
  export declare class OPCUAClient {
198
+ /**
199
+ * Create a new OPC UA client instance.
200
+ *
201
+ * @param options - client configuration options
202
+ * @returns a configured OPC UA client ready to connect
203
+ */
91
204
  static create(options: OPCUAClientOptions): OPCUAClient;
205
+ /**
206
+ * Convenience method to create a client, connect, and establish
207
+ * a session in one call.
208
+ *
209
+ * @param endpointUrl - the OPC UA endpoint URL
210
+ * @param userIdentity - optional user credentials
211
+ * @param clientOptions - optional client configuration
212
+ * @returns a connected client session
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * const session = await OPCUAClient.createSession(
217
+ * "opc.tcp://localhost:26543"
218
+ * );
219
+ * const dataValue = await session.read({
220
+ * nodeId: "ns=0;i=2258",
221
+ * attributeId: AttributeIds.Value,
222
+ * });
223
+ * await session.close(true); // deleteSubscriptions = true
224
+ * ```
225
+ */
92
226
  static createSession(endpointUrl: string, userIdentity?: UserIdentityInfo, clientOptions?: OPCUAClientOptions): Promise<ClientSession>;
93
227
  static set minimumRevisedSessionTimeout(minimumRevisedSessionTimeout: number);
94
228
  static get minimumRevisedSessionTimeout(): number;
@@ -5,10 +5,50 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.OPCUAClient = void 0;
7
7
  const opcua_client_impl_1 = require("./private/opcua_client_impl");
8
+ /**
9
+ * Factory class for creating OPC UA client instances.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { OPCUAClient } from "node-opcua-client";
14
+ *
15
+ * const client = OPCUAClient.create({
16
+ * endpointMustExist: false,
17
+ * requestedSessionTimeout: 60000,
18
+ * });
19
+ * ```
20
+ */
8
21
  class OPCUAClient {
22
+ /**
23
+ * Create a new OPC UA client instance.
24
+ *
25
+ * @param options - client configuration options
26
+ * @returns a configured OPC UA client ready to connect
27
+ */
9
28
  static create(options) {
10
29
  return new opcua_client_impl_1.OPCUAClientImpl(options);
11
30
  }
31
+ /**
32
+ * Convenience method to create a client, connect, and establish
33
+ * a session in one call.
34
+ *
35
+ * @param endpointUrl - the OPC UA endpoint URL
36
+ * @param userIdentity - optional user credentials
37
+ * @param clientOptions - optional client configuration
38
+ * @returns a connected client session
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const session = await OPCUAClient.createSession(
43
+ * "opc.tcp://localhost:26543"
44
+ * );
45
+ * const dataValue = await session.read({
46
+ * nodeId: "ns=0;i=2258",
47
+ * attributeId: AttributeIds.Value,
48
+ * });
49
+ * await session.close(true); // deleteSubscriptions = true
50
+ * ```
51
+ */
12
52
  static async createSession(endpointUrl, userIdentity, clientOptions) {
13
53
  return opcua_client_impl_1.OPCUAClientImpl.createSession(endpointUrl, userIdentity, clientOptions);
14
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"opcua_client.js","sourceRoot":"","sources":["../source/opcua_client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAeH,mEAA8D;AAgH9D,MAAa,WAAW;IACb,MAAM,CAAC,MAAM,CAAC,OAA2B;QAC5C,OAAO,IAAI,mCAAe,CAAC,OAAO,CAA2B,CAAC;IAClE,CAAC;IACM,MAAM,CAAC,KAAK,CAAC,aAAa,CAC7B,WAAmB,EACnB,YAA+B,EAC/B,aAAkC;QAElC,OAAO,mCAAe,CAAC,aAAa,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;IACnF,CAAC;IACM,MAAM,KAAK,4BAA4B,CAAC,4BAAoC;QAC/E,mCAAe,CAAC,4BAA4B,GAAG,4BAA4B,CAAC;IAChF,CAAC;IACM,MAAM,KAAK,4BAA4B;QAC1C,OAAO,mCAAe,CAAC,4BAA4B,CAAC;IACxD,CAAC;CACJ;AAjBD,kCAiBC"}
1
+ {"version":3,"file":"opcua_client.js","sourceRoot":"","sources":["../source/opcua_client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAeH,mEAA8D;AA6M9D;;;;;;;;;;;;GAYG;AACH,MAAa,WAAW;IACpB;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,OAA2B;QAC5C,OAAO,IAAI,mCAAe,CAAC,OAAO,CAA2B,CAAC;IAClE,CAAC;IACD;;;;;;;;;;;;;;;;;;;;OAoBG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa,CAC7B,WAAmB,EACnB,YAA+B,EAC/B,aAAkC;QAElC,OAAO,mCAAe,CAAC,aAAa,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;IACnF,CAAC;IACM,MAAM,KAAK,4BAA4B,CAAC,4BAAoC;QAC/E,mCAAe,CAAC,4BAA4B,GAAG,4BAA4B,CAAC;IAChF,CAAC;IACM,MAAM,KAAK,4BAA4B;QAC1C,OAAO,mCAAe,CAAC,4BAA4B,CAAC;IACxD,CAAC;CACJ;AA5CD,kCA4CC"}
@@ -59,6 +59,7 @@ export declare class ClientSessionImpl extends EventEmitter implements ClientSes
59
59
  serverNonce?: Nonce;
60
60
  serverSignature?: SignatureData;
61
61
  serverEndpoints: EndpointDescription[];
62
+ lastActivateSessionStatusCode: StatusCode;
62
63
  _client: IClientBase | null;
63
64
  _closed: boolean;
64
65
  _reconnecting: {
@@ -89,6 +89,7 @@ class ClientSessionImpl extends events_1.EventEmitter {
89
89
  serverNonce;
90
90
  serverSignature; // todo : remove ?
91
91
  serverEndpoints = [];
92
+ lastActivateSessionStatusCode = node_opcua_status_code_1.StatusCodes.Good;
92
93
  _client;
93
94
  _closed;
94
95
  _reconnecting;