node-opcua-client 2.183.1 → 2.184.1
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/alarms_and_conditions/client_alarm_tools.d.ts +1 -0
- package/dist/alarms_and_conditions/client_alarm_tools.d.ts.map +1 -0
- package/dist/alarms_and_conditions/client_alarm_tools.js +23 -27
- package/dist/alarms_and_conditions/client_alarm_tools.js.map +1 -1
- package/dist/alarms_and_conditions/client_tools.d.ts +1 -0
- package/dist/alarms_and_conditions/client_tools.d.ts.map +1 -0
- package/dist/alarms_and_conditions/client_tools.js +17 -19
- package/dist/alarms_and_conditions/client_tools.js.map +1 -1
- package/dist/client_base.d.ts +1 -0
- package/dist/client_base.d.ts.map +1 -0
- package/dist/client_base.js +3 -6
- package/dist/client_base.js.map +1 -1
- package/dist/client_monitored_item.d.ts +1 -0
- package/dist/client_monitored_item.d.ts.map +1 -0
- package/dist/client_monitored_item.js +4 -7
- package/dist/client_monitored_item.js.map +1 -1
- package/dist/client_monitored_item_base.d.ts +1 -0
- package/dist/client_monitored_item_base.d.ts.map +1 -0
- package/dist/client_monitored_item_base.js +1 -2
- package/dist/client_monitored_item_group.d.ts +1 -0
- package/dist/client_monitored_item_group.d.ts.map +1 -0
- package/dist/client_monitored_item_group.js +2 -5
- package/dist/client_monitored_item_group.js.map +1 -1
- package/dist/client_monitored_item_toolbox.d.ts +1 -0
- package/dist/client_monitored_item_toolbox.d.ts.map +1 -0
- package/dist/client_monitored_item_toolbox.js +21 -27
- package/dist/client_monitored_item_toolbox.js.map +1 -1
- package/dist/client_session.d.ts +2 -1
- package/dist/client_session.d.ts.map +1 -0
- package/dist/client_session.js +2 -7
- package/dist/client_session.js.map +1 -1
- package/dist/client_session_keepalive_manager.d.ts +1 -0
- package/dist/client_session_keepalive_manager.d.ts.map +1 -0
- package/dist/client_session_keepalive_manager.js +24 -31
- package/dist/client_session_keepalive_manager.js.map +1 -1
- package/dist/client_subscription.d.ts +1 -0
- package/dist/client_subscription.d.ts.map +1 -0
- package/dist/client_subscription.js +1 -5
- package/dist/client_subscription.js.map +1 -1
- package/dist/client_utils.d.ts +1 -0
- package/dist/client_utils.d.ts.map +1 -0
- package/dist/client_utils.js +7 -10
- package/dist/client_utils.js.map +1 -1
- package/dist/common.d.ts +1 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +1 -2
- package/dist/common.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -118
- package/dist/index.js.map +1 -1
- package/dist/opcua_client.d.ts +1 -0
- package/dist/opcua_client.d.ts.map +1 -0
- package/dist/opcua_client.js +6 -10
- package/dist/opcua_client.js.map +1 -1
- package/dist/private/client_base_impl.d.ts +1 -0
- package/dist/private/client_base_impl.d.ts.map +1 -0
- package/dist/private/client_base_impl.js +146 -150
- package/dist/private/client_base_impl.js.map +1 -1
- package/dist/private/client_monitored_item_base_impl.d.ts +1 -0
- package/dist/private/client_monitored_item_base_impl.d.ts.map +1 -0
- package/dist/private/client_monitored_item_base_impl.js +1 -2
- package/dist/private/client_monitored_item_base_impl.js.map +1 -1
- package/dist/private/client_monitored_item_group_impl.d.ts +1 -0
- package/dist/private/client_monitored_item_group_impl.d.ts.map +1 -0
- package/dist/private/client_monitored_item_group_impl.js +31 -35
- package/dist/private/client_monitored_item_group_impl.js.map +1 -1
- package/dist/private/client_monitored_item_impl.d.ts +1 -0
- package/dist/private/client_monitored_item_impl.d.ts.map +1 -0
- package/dist/private/client_monitored_item_impl.js +41 -45
- package/dist/private/client_monitored_item_impl.js.map +1 -1
- package/dist/private/client_publish_engine.d.ts +1 -0
- package/dist/private/client_publish_engine.d.ts.map +1 -0
- package/dist/private/client_publish_engine.js +47 -54
- package/dist/private/client_publish_engine.js.map +1 -1
- package/dist/private/client_session_impl.d.ts +1 -0
- package/dist/private/client_session_impl.d.ts.map +1 -0
- package/dist/private/client_session_impl.js +231 -238
- package/dist/private/client_session_impl.js.map +1 -1
- package/dist/private/client_subscription_impl.d.ts +1 -0
- package/dist/private/client_subscription_impl.d.ts.map +1 -0
- package/dist/private/client_subscription_impl.js +93 -102
- package/dist/private/client_subscription_impl.js.map +1 -1
- package/dist/private/i_private_client.d.ts +1 -0
- package/dist/private/i_private_client.d.ts.map +1 -0
- package/dist/private/i_private_client.js +1 -2
- package/dist/private/opcua_client_impl.d.ts +1 -0
- package/dist/private/opcua_client_impl.d.ts.map +1 -0
- package/dist/private/opcua_client_impl.js +138 -145
- package/dist/private/opcua_client_impl.js.map +1 -1
- package/dist/private/performance.d.ts +1 -0
- package/dist/private/performance.d.ts.map +1 -0
- package/dist/private/performance.js +1 -4
- package/dist/private/performance.js.map +1 -1
- package/dist/private/reconnection/client_publish_engine_reconnection.d.ts +1 -0
- package/dist/private/reconnection/client_publish_engine_reconnection.d.ts.map +1 -0
- package/dist/private/reconnection/client_publish_engine_reconnection.js +28 -34
- package/dist/private/reconnection/client_publish_engine_reconnection.js.map +1 -1
- package/dist/private/reconnection/client_reconnection.d.ts +1 -0
- package/dist/private/reconnection/client_reconnection.d.ts.map +1 -0
- package/dist/private/reconnection/client_reconnection.js +1 -4
- package/dist/private/reconnection/client_reconnection.js.map +1 -1
- package/dist/private/reconnection/client_subscription_reconnection.d.ts +1 -0
- package/dist/private/reconnection/client_subscription_reconnection.d.ts.map +1 -0
- package/dist/private/reconnection/client_subscription_reconnection.js +25 -31
- package/dist/private/reconnection/client_subscription_reconnection.js.map +1 -1
- package/dist/private/reconnection/reconnection.d.ts +1 -0
- package/dist/private/reconnection/reconnection.d.ts.map +1 -0
- package/dist/private/reconnection/reconnection.js +50 -59
- package/dist/private/reconnection/reconnection.js.map +1 -1
- package/dist/reverse/client_reverse_connect.d.ts +1 -0
- package/dist/reverse/client_reverse_connect.d.ts.map +1 -0
- package/dist/reverse/client_reverse_connect.js +20 -24
- package/dist/reverse/client_reverse_connect.js.map +1 -1
- package/dist/tools/findservers.d.ts +1 -0
- package/dist/tools/findservers.d.ts.map +1 -0
- package/dist/tools/findservers.js +7 -13
- package/dist/tools/findservers.js.map +1 -1
- package/dist/tools/read_history_server_capabilities.d.ts +1 -0
- package/dist/tools/read_history_server_capabilities.d.ts.map +1 -0
- package/dist/tools/read_history_server_capabilities.js +13 -16
- package/dist/tools/read_history_server_capabilities.js.map +1 -1
- package/dist/user_identity_info.d.ts +2 -1
- package/dist/user_identity_info.d.ts.map +1 -0
- package/dist/user_identity_info.js +1 -2
- package/dist/verify.d.ts +1 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +15 -19
- package/dist/verify.js.map +1 -1
- package/package.json +48 -47
- package/source/alarms_and_conditions/client_alarm_tools.ts +1 -1
- package/source/client_monitored_item_toolbox.ts +1 -1
- package/source/client_session.ts +1 -1
- package/source/index.ts +5 -3
- package/source/private/client_base_impl.ts +5 -2
- package/source/private/client_publish_engine.ts +16 -16
- package/source/private/client_subscription_impl.ts +1 -1
- package/source/private/opcua_client_impl.ts +4 -4
- package/source/private/reconnection/client_publish_engine_reconnection.ts +7 -7
- package/source/private/reconnection/client_subscription_reconnection.ts +5 -5
- package/source/private/reconnection/reconnection.ts +3 -3
- package/source/reverse/client_reverse_connect.ts +1 -1
- package/source/user_identity_info.ts +1 -1
|
@@ -1,49 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @module node-opcua-client-private
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
33
|
-
const client_session_keepalive_manager_js_1 = require("../client_session_keepalive_manager.js");
|
|
34
|
-
const client_publish_engine_js_1 = require("./client_publish_engine.js");
|
|
35
|
-
const client_subscription_impl_js_1 = require("./client_subscription_impl.js");
|
|
36
|
-
const reconnection_js_1 = require("./reconnection/reconnection.js");
|
|
4
|
+
import { EventEmitter } from "node:events";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { assert } from "node-opcua-assert";
|
|
7
|
+
import { extractDataValueToPromote, getExtensionObjectConstructor, getExtraDataTypeManager, promoteOpaqueStructure } from "node-opcua-client-dynamic-extension-object";
|
|
8
|
+
import { BrowseDirection } from "node-opcua-data-model";
|
|
9
|
+
import { DataValue } from "node-opcua-data-value";
|
|
10
|
+
import { checkDebugFlag, make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
|
|
11
|
+
import { coerceNodeId, NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
12
|
+
import { getArgumentDefinitionHelper, getBuiltInDataType, readAllAttributes, readNamespaceArray } from "node-opcua-pseudo-session";
|
|
13
|
+
import { ClientSecureChannelLayer, requestHandleNotSetValue } from "node-opcua-secure-channel";
|
|
14
|
+
import { BrowseDescription, BrowseRequest, BrowseResponse, BrowseResult } from "node-opcua-service-browse";
|
|
15
|
+
import { CallMethodRequest, CallRequest, CallResponse } from "node-opcua-service-call";
|
|
16
|
+
import { HistoryData, HistoryReadRequest, HistoryReadResponse, ReadProcessedDetails, ReadRawModifiedDetails } from "node-opcua-service-history";
|
|
17
|
+
import { QueryFirstRequest, QueryFirstResponse } from "node-opcua-service-query";
|
|
18
|
+
import { AttributeIds, ReadRequest, ReadResponse, ReadValueId, TimestampsToReturn } from "node-opcua-service-read";
|
|
19
|
+
import { RegisterNodesRequest, RegisterNodesResponse, UnregisterNodesRequest, UnregisterNodesResponse } from "node-opcua-service-register-node";
|
|
20
|
+
import { CreateMonitoredItemsRequest, CreateMonitoredItemsResponse, CreateSubscriptionRequest, CreateSubscriptionResponse, DeleteMonitoredItemsRequest, DeleteMonitoredItemsResponse, DeleteSubscriptionsRequest, DeleteSubscriptionsResponse, ModifyMonitoredItemsRequest, ModifyMonitoredItemsResponse, ModifySubscriptionRequest, ModifySubscriptionResponse, PublishRequest, PublishResponse, RepublishRequest, RepublishResponse, SetMonitoringModeRequest, SetMonitoringModeResponse, SetPublishingModeRequest, SetPublishingModeResponse, SetTriggeringRequest, SetTriggeringResponse, TransferSubscriptionsRequest, TransferSubscriptionsResponse } from "node-opcua-service-subscription";
|
|
21
|
+
import { TranslateBrowsePathsToNodeIdsRequest, TranslateBrowsePathsToNodeIdsResponse } from "node-opcua-service-translate-browse-path";
|
|
22
|
+
import { WriteRequest, WriteResponse, WriteValue } from "node-opcua-service-write";
|
|
23
|
+
import { StatusCodes } from "node-opcua-status-code";
|
|
24
|
+
import { ActivateSessionRequest, BrowseNextRequest, BrowseNextResponse, CloseSessionRequest, UserTokenType } from "node-opcua-types";
|
|
25
|
+
import { buffer_ellipsis, getFunctionParameterNames, isNullOrUndefined } from "node-opcua-utils";
|
|
26
|
+
import { DataType } from "node-opcua-variant";
|
|
27
|
+
import { ClientSessionKeepAliveManager } from "../client_session_keepalive_manager.js";
|
|
28
|
+
import { ClientSidePublishEngine } from "./client_publish_engine.js";
|
|
29
|
+
import { ClientSubscriptionImpl } from "./client_subscription_impl.js";
|
|
30
|
+
import { repair_client_session } from "./reconnection/reconnection.js";
|
|
37
31
|
const helpAPIChange = process.env.DEBUG?.match(/API/);
|
|
38
|
-
const debugLog =
|
|
39
|
-
const doDebug =
|
|
40
|
-
const warningLog =
|
|
41
|
-
const _errorLog =
|
|
32
|
+
const debugLog = make_debugLog("client_session_impl");
|
|
33
|
+
const doDebug = checkDebugFlag("client_session_impl");
|
|
34
|
+
const warningLog = make_warningLog("client_session_impl");
|
|
35
|
+
const _errorLog = make_errorLog("client_session_impl");
|
|
42
36
|
let pendingTransactionMessageDisplayed = false;
|
|
43
37
|
function coerceBrowseDescription(data) {
|
|
44
|
-
if (typeof data === "string" || data instanceof
|
|
38
|
+
if (typeof data === "string" || data instanceof NodeId) {
|
|
45
39
|
return coerceBrowseDescription({
|
|
46
|
-
browseDirection:
|
|
40
|
+
browseDirection: BrowseDirection.Forward,
|
|
47
41
|
includeSubtypes: true,
|
|
48
42
|
nodeClassMask: 0,
|
|
49
43
|
nodeId: data,
|
|
@@ -53,23 +47,23 @@ function coerceBrowseDescription(data) {
|
|
|
53
47
|
}
|
|
54
48
|
else {
|
|
55
49
|
const options = data;
|
|
56
|
-
options.nodeId =
|
|
57
|
-
options.referenceTypeId = options.referenceTypeId ?
|
|
58
|
-
return new
|
|
50
|
+
options.nodeId = resolveNodeId(options.nodeId);
|
|
51
|
+
options.referenceTypeId = options.referenceTypeId ? resolveNodeId(options.referenceTypeId) : null;
|
|
52
|
+
return new BrowseDescription(options);
|
|
59
53
|
}
|
|
60
54
|
}
|
|
61
55
|
function coerceReadValueId(node) {
|
|
62
|
-
if (typeof node === "string" || node instanceof
|
|
63
|
-
return new
|
|
64
|
-
attributeId:
|
|
56
|
+
if (typeof node === "string" || node instanceof NodeId) {
|
|
57
|
+
return new ReadValueId({
|
|
58
|
+
attributeId: AttributeIds.Value,
|
|
65
59
|
dataEncoding: undefined, // {namespaceIndex: 0, name: undefined}
|
|
66
60
|
indexRange: undefined,
|
|
67
|
-
nodeId:
|
|
61
|
+
nodeId: resolveNodeId(node)
|
|
68
62
|
});
|
|
69
63
|
}
|
|
70
64
|
else {
|
|
71
|
-
|
|
72
|
-
return new
|
|
65
|
+
assert(node instanceof Object);
|
|
66
|
+
return new ReadValueId(node);
|
|
73
67
|
}
|
|
74
68
|
}
|
|
75
69
|
const emptyUint32Array = new Uint32Array(0);
|
|
@@ -96,7 +90,7 @@ function annotateWithDiagnostics(err, response) {
|
|
|
96
90
|
/**
|
|
97
91
|
* @class ClientSession
|
|
98
92
|
*/
|
|
99
|
-
class ClientSessionImpl extends
|
|
93
|
+
export class ClientSessionImpl extends EventEmitter {
|
|
100
94
|
static reconnectingElement = new WeakMap();
|
|
101
95
|
timeout;
|
|
102
96
|
authenticationToken;
|
|
@@ -110,7 +104,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
110
104
|
serverNonce;
|
|
111
105
|
serverSignature; // todo : remove ?
|
|
112
106
|
serverEndpoints = [];
|
|
113
|
-
lastActivateSessionStatusCode =
|
|
107
|
+
lastActivateSessionStatusCode = StatusCodes.Good;
|
|
114
108
|
_client;
|
|
115
109
|
_closed;
|
|
116
110
|
_reconnecting;
|
|
@@ -125,7 +119,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
125
119
|
constructor(client) {
|
|
126
120
|
super();
|
|
127
121
|
this.serverCertificate = Buffer.alloc(0);
|
|
128
|
-
this.sessionId = new
|
|
122
|
+
this.sessionId = new NodeId();
|
|
129
123
|
this._closeEventHasBeenEmitted = false;
|
|
130
124
|
this._client = client;
|
|
131
125
|
this._publishEngine = null;
|
|
@@ -176,31 +170,31 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
176
170
|
return this.toString();
|
|
177
171
|
}
|
|
178
172
|
resolveNodeId(nodeId) {
|
|
179
|
-
return
|
|
173
|
+
return resolveNodeId(nodeId);
|
|
180
174
|
}
|
|
181
175
|
getPublishEngine() {
|
|
182
176
|
if (!this._publishEngine) {
|
|
183
|
-
this._publishEngine = new
|
|
177
|
+
this._publishEngine = new ClientSidePublishEngine(this);
|
|
184
178
|
}
|
|
185
179
|
return this._publishEngine;
|
|
186
180
|
}
|
|
187
181
|
changeUser(userIdentityInfo, callback) {
|
|
188
182
|
userIdentityInfo = userIdentityInfo || {
|
|
189
|
-
type:
|
|
183
|
+
type: UserTokenType.Anonymous
|
|
190
184
|
};
|
|
191
185
|
if (!this._client || !this.userIdentityInfo) {
|
|
192
186
|
warningLog("changeUser: invalid session");
|
|
193
|
-
return callback?.(null,
|
|
187
|
+
return callback?.(null, StatusCodes.BadInternalError);
|
|
194
188
|
}
|
|
195
189
|
const old_userIdentity = this.userIdentityInfo;
|
|
196
190
|
this._client._activateSession(this, userIdentityInfo, (err1, _session2) => {
|
|
197
191
|
if (err1) {
|
|
198
192
|
this.userIdentityInfo = old_userIdentity;
|
|
199
193
|
warningLog("activate session error = ", err1.message);
|
|
200
|
-
return callback?.(null,
|
|
194
|
+
return callback?.(null, StatusCodes.BadUserAccessDenied);
|
|
201
195
|
}
|
|
202
196
|
this.userIdentityInfo = userIdentityInfo;
|
|
203
|
-
callback?.(null,
|
|
197
|
+
callback?.(null, StatusCodes.Good);
|
|
204
198
|
});
|
|
205
199
|
return undefined;
|
|
206
200
|
}
|
|
@@ -212,10 +206,10 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
212
206
|
const arg0 = args[0];
|
|
213
207
|
const isArray = Array.isArray(arg0);
|
|
214
208
|
const callback = args[1];
|
|
215
|
-
|
|
216
|
-
|
|
209
|
+
assert(typeof callback === "function");
|
|
210
|
+
assert(Number.isFinite(this.requestedMaxReferencesPerNode));
|
|
217
211
|
const nodesToBrowse = (isArray ? arg0 : [arg0]).map(coerceBrowseDescription);
|
|
218
|
-
const request = new
|
|
212
|
+
const request = new BrowseRequest({
|
|
219
213
|
nodesToBrowse,
|
|
220
214
|
requestedMaxReferencesPerNode: this.requestedMaxReferencesPerNode
|
|
221
215
|
});
|
|
@@ -224,7 +218,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
224
218
|
return callback(err);
|
|
225
219
|
}
|
|
226
220
|
/* c8 ignore next */
|
|
227
|
-
if (!response || !(response instanceof
|
|
221
|
+
if (!response || !(response instanceof BrowseResponse)) {
|
|
228
222
|
return callback(new Error("Internal Error"));
|
|
229
223
|
}
|
|
230
224
|
const results = response.results ? response.results : [];
|
|
@@ -233,7 +227,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
233
227
|
const r = results[i];
|
|
234
228
|
/* c8 ignore next */
|
|
235
229
|
if (r.references && r.references.length > this.requestedMaxReferencesPerNode) {
|
|
236
|
-
warningLog(
|
|
230
|
+
warningLog(chalk.yellow("warning") +
|
|
237
231
|
" BrowseResponse : the server didn't take into" +
|
|
238
232
|
" account our requestedMaxReferencesPerNode ");
|
|
239
233
|
warningLog(` this.requestedMaxReferencesPerNode= ${this.requestedMaxReferencesPerNode}`);
|
|
@@ -245,7 +239,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
245
239
|
for (const r of results) {
|
|
246
240
|
r.references = r.references || /* c8 ignore next */ [];
|
|
247
241
|
}
|
|
248
|
-
|
|
242
|
+
assert(results[0] instanceof BrowseResult);
|
|
249
243
|
return callback(null, isArray ? results : results[0]);
|
|
250
244
|
});
|
|
251
245
|
}
|
|
@@ -254,9 +248,9 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
254
248
|
const isArray = Array.isArray(arg0);
|
|
255
249
|
const releaseContinuationPoints = args[1];
|
|
256
250
|
const callback = args[2];
|
|
257
|
-
|
|
251
|
+
assert(typeof callback === "function", "expecting a callback function here");
|
|
258
252
|
const continuationPoints = isArray ? arg0 : [arg0];
|
|
259
|
-
const request = new
|
|
253
|
+
const request = new BrowseNextRequest({
|
|
260
254
|
continuationPoints,
|
|
261
255
|
releaseContinuationPoints
|
|
262
256
|
});
|
|
@@ -266,14 +260,14 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
266
260
|
return callback(err);
|
|
267
261
|
}
|
|
268
262
|
/* c8 ignore next */
|
|
269
|
-
if (!response || !(response instanceof
|
|
263
|
+
if (!response || !(response instanceof BrowseNextResponse)) {
|
|
270
264
|
return callback(new Error("Internal Error"));
|
|
271
265
|
}
|
|
272
266
|
const results = response.results ? response.results : [];
|
|
273
267
|
for (const r of results) {
|
|
274
268
|
r.references = r.references || [];
|
|
275
269
|
}
|
|
276
|
-
|
|
270
|
+
assert(results[0] instanceof BrowseResult);
|
|
277
271
|
return callback(null, isArray ? results : results[0]);
|
|
278
272
|
});
|
|
279
273
|
}
|
|
@@ -283,13 +277,13 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
283
277
|
*/
|
|
284
278
|
readVariableValue(...args) {
|
|
285
279
|
const callback = args[1];
|
|
286
|
-
|
|
280
|
+
assert(typeof callback === "function");
|
|
287
281
|
const isArray = Array.isArray(args[0]);
|
|
288
282
|
const nodes = isArray ? args[0] : [args[0]];
|
|
289
283
|
const nodesToRead = nodes.map(coerceReadValueId);
|
|
290
|
-
const request = new
|
|
284
|
+
const request = new ReadRequest({
|
|
291
285
|
nodesToRead,
|
|
292
|
-
timestampsToReturn:
|
|
286
|
+
timestampsToReturn: TimestampsToReturn.Neither
|
|
293
287
|
});
|
|
294
288
|
return this.performMessageTransaction(request, (err, response) => {
|
|
295
289
|
/* c8 ignore next */
|
|
@@ -297,18 +291,18 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
297
291
|
return callback(err);
|
|
298
292
|
}
|
|
299
293
|
/* c8 ignore next */
|
|
300
|
-
if (!(response instanceof
|
|
294
|
+
if (!(response instanceof ReadResponse)) {
|
|
301
295
|
return callback(new Error("Internal Error"));
|
|
302
296
|
}
|
|
303
297
|
/* c8 ignore next */
|
|
304
|
-
if (response.responseHeader.serviceResult.isNot(
|
|
298
|
+
if (response.responseHeader.serviceResult.isNot(StatusCodes.Good)) {
|
|
305
299
|
return callback(new Error(response.responseHeader.serviceResult.toString()));
|
|
306
300
|
}
|
|
307
301
|
/* c8 ignore next */
|
|
308
302
|
if (!response.results) {
|
|
309
303
|
response.results = [];
|
|
310
304
|
}
|
|
311
|
-
|
|
305
|
+
assert(nodes.length === response.results.length);
|
|
312
306
|
callback(null, isArray ? response.results : response.results[0]);
|
|
313
307
|
});
|
|
314
308
|
}
|
|
@@ -321,13 +315,13 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
321
315
|
options = args[3];
|
|
322
316
|
callback = args[4];
|
|
323
317
|
}
|
|
324
|
-
|
|
318
|
+
assert(typeof callback === "function");
|
|
325
319
|
const cb = callback;
|
|
326
320
|
// adjust parameters
|
|
327
321
|
options.numValuesPerNode = options.numValuesPerNode || 0;
|
|
328
322
|
options.returnBounds = !!(options.returnBounds || options.returnBounds === undefined);
|
|
329
323
|
options.isReadModified = options.isReadModified || false;
|
|
330
|
-
options.timestampsToReturn = options.timestampsToReturn ??
|
|
324
|
+
options.timestampsToReturn = options.timestampsToReturn ?? TimestampsToReturn.Both;
|
|
331
325
|
const arg0 = args[0];
|
|
332
326
|
const isArray = Array.isArray(arg0);
|
|
333
327
|
const nodes = isArray ? arg0 : [arg0];
|
|
@@ -345,32 +339,32 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
345
339
|
nodesToRead.push(node);
|
|
346
340
|
}
|
|
347
341
|
}
|
|
348
|
-
const readRawModifiedDetails = new
|
|
342
|
+
const readRawModifiedDetails = new ReadRawModifiedDetails({
|
|
349
343
|
endTime,
|
|
350
344
|
isReadModified: false,
|
|
351
345
|
numValuesPerNode: options.numValuesPerNode,
|
|
352
346
|
returnBounds: options.returnBounds,
|
|
353
347
|
startTime
|
|
354
348
|
});
|
|
355
|
-
const request = new
|
|
349
|
+
const request = new HistoryReadRequest({
|
|
356
350
|
historyReadDetails: readRawModifiedDetails,
|
|
357
351
|
nodesToRead,
|
|
358
352
|
releaseContinuationPoints: false,
|
|
359
353
|
timestampsToReturn: options.timestampsToReturn
|
|
360
354
|
});
|
|
361
355
|
request.nodesToRead = request.nodesToRead || [];
|
|
362
|
-
|
|
356
|
+
assert(nodes.length === request.nodesToRead.length);
|
|
363
357
|
return this.historyRead(request, (err, response) => {
|
|
364
358
|
/* c8 ignore next */
|
|
365
359
|
if (err) {
|
|
366
360
|
return cb(err);
|
|
367
361
|
}
|
|
368
362
|
/* c8 ignore next */
|
|
369
|
-
if (!response || !(response instanceof
|
|
363
|
+
if (!response || !(response instanceof HistoryReadResponse)) {
|
|
370
364
|
return cb(new Error("Internal Error"));
|
|
371
365
|
}
|
|
372
366
|
response.results = response.results || [];
|
|
373
|
-
|
|
367
|
+
assert(nodes.length === response.results.length);
|
|
374
368
|
cb(null, isArray ? response.results : response.results[0]);
|
|
375
369
|
});
|
|
376
370
|
}
|
|
@@ -385,18 +379,18 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
385
379
|
return callback(err);
|
|
386
380
|
}
|
|
387
381
|
/* c8 ignore next */
|
|
388
|
-
if (!response || !(response instanceof
|
|
382
|
+
if (!response || !(response instanceof HistoryReadResponse)) {
|
|
389
383
|
return callback(new Error("Internal Error"));
|
|
390
384
|
}
|
|
391
|
-
if (response.responseHeader.serviceResult.isNot(
|
|
385
|
+
if (response.responseHeader.serviceResult.isNot(StatusCodes.Good)) {
|
|
392
386
|
return callback(new Error(response.responseHeader.serviceResult.toString()));
|
|
393
387
|
}
|
|
394
388
|
response.results = response.results || /* c8 ignore next */ [];
|
|
395
389
|
// perform ExtensionObject resolution
|
|
396
390
|
const promises = response.results.map(async (result) => {
|
|
397
|
-
if (result.historyData && result.historyData instanceof
|
|
391
|
+
if (result.historyData && result.historyData instanceof HistoryData) {
|
|
398
392
|
if (result.historyData.dataValues) {
|
|
399
|
-
await
|
|
393
|
+
await promoteOpaqueStructure(this, result.historyData.dataValues);
|
|
400
394
|
}
|
|
401
395
|
}
|
|
402
396
|
});
|
|
@@ -409,7 +403,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
409
403
|
}
|
|
410
404
|
readAggregateValue(arg0, startTime, endTime, aggregateFn, processingInterval, ...args) {
|
|
411
405
|
const callback = (typeof args[0] === "function" ? args[0] : args[1]);
|
|
412
|
-
|
|
406
|
+
assert(typeof callback === "function");
|
|
413
407
|
const defaultAggregateFunction = {
|
|
414
408
|
percentDataBad: 100,
|
|
415
409
|
percentDataGood: 100,
|
|
@@ -425,35 +419,35 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
425
419
|
const aggregateFns = Array.isArray(aggregateFn)
|
|
426
420
|
? aggregateFn
|
|
427
421
|
: [aggregateFn];
|
|
428
|
-
|
|
429
|
-
const readProcessedDetails = new
|
|
422
|
+
assert(aggregateFns.length === nodesToRead.length);
|
|
423
|
+
const readProcessedDetails = new ReadProcessedDetails({
|
|
430
424
|
aggregateType: aggregateFns,
|
|
431
425
|
endTime,
|
|
432
426
|
processingInterval,
|
|
433
427
|
startTime,
|
|
434
428
|
aggregateConfiguration
|
|
435
429
|
});
|
|
436
|
-
const request = new
|
|
430
|
+
const request = new HistoryReadRequest({
|
|
437
431
|
historyReadDetails: readProcessedDetails,
|
|
438
432
|
nodesToRead,
|
|
439
433
|
releaseContinuationPoints: false,
|
|
440
|
-
timestampsToReturn:
|
|
434
|
+
timestampsToReturn: TimestampsToReturn.Both
|
|
441
435
|
});
|
|
442
|
-
|
|
436
|
+
assert(nodesToRead.length === request.nodesToRead?.length);
|
|
443
437
|
return this.performMessageTransaction(request, (err, response) => {
|
|
444
438
|
/* c8 ignore next */
|
|
445
439
|
if (err) {
|
|
446
440
|
return callback(err);
|
|
447
441
|
}
|
|
448
442
|
/* c8 ignore next */
|
|
449
|
-
if (!response || !(response instanceof
|
|
443
|
+
if (!response || !(response instanceof HistoryReadResponse)) {
|
|
450
444
|
return callback(new Error("Internal Error"));
|
|
451
445
|
}
|
|
452
|
-
if (response.responseHeader.serviceResult.isNot(
|
|
446
|
+
if (response.responseHeader.serviceResult.isNot(StatusCodes.Good)) {
|
|
453
447
|
return callback(new Error(response.responseHeader.serviceResult.toString()));
|
|
454
448
|
}
|
|
455
449
|
response.results = response.results || /* c8 ignore next */ [];
|
|
456
|
-
|
|
450
|
+
assert(nodesToRead.length === response.results.length);
|
|
457
451
|
callback(null, isArray ? response.results : response.results[0]);
|
|
458
452
|
});
|
|
459
453
|
}
|
|
@@ -466,23 +460,23 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
466
460
|
const isArray = Array.isArray(arg0);
|
|
467
461
|
const nodesToWrite = isArray ? arg0 : [arg0];
|
|
468
462
|
const callback = args[1];
|
|
469
|
-
|
|
470
|
-
const request = new
|
|
463
|
+
assert(typeof callback === "function");
|
|
464
|
+
const request = new WriteRequest({ nodesToWrite });
|
|
471
465
|
return this.performMessageTransaction(request, (err, response) => {
|
|
472
466
|
/* c8 ignore next */
|
|
473
467
|
if (err) {
|
|
474
468
|
return callback(err, response);
|
|
475
469
|
}
|
|
476
470
|
/* c8 ignore next */
|
|
477
|
-
if (!response || !(response instanceof
|
|
471
|
+
if (!response || !(response instanceof WriteResponse)) {
|
|
478
472
|
return callback(new Error("Internal Error"));
|
|
479
473
|
}
|
|
480
474
|
/* c8 ignore next */
|
|
481
|
-
if (response.responseHeader.serviceResult.isNot(
|
|
475
|
+
if (response.responseHeader.serviceResult.isNot(StatusCodes.Good)) {
|
|
482
476
|
return callback(new Error(response.responseHeader.serviceResult.toString()));
|
|
483
477
|
}
|
|
484
478
|
response.results = response.results || /* c8 ignore next */ [];
|
|
485
|
-
|
|
479
|
+
assert(nodesToWrite.length === response.results.length);
|
|
486
480
|
callback(null, isArray ? response.results : response.results[0]);
|
|
487
481
|
});
|
|
488
482
|
}
|
|
@@ -490,26 +484,26 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
490
484
|
const nodeId = args[0];
|
|
491
485
|
const value = args[1];
|
|
492
486
|
const callback = args[2];
|
|
493
|
-
|
|
494
|
-
const nodeToWrite = new
|
|
495
|
-
attributeId:
|
|
487
|
+
assert(typeof callback === "function");
|
|
488
|
+
const nodeToWrite = new WriteValue({
|
|
489
|
+
attributeId: AttributeIds.Value,
|
|
496
490
|
indexRange: undefined,
|
|
497
491
|
nodeId: this.resolveNodeId(nodeId),
|
|
498
|
-
value: new
|
|
492
|
+
value: new DataValue({ value })
|
|
499
493
|
});
|
|
500
494
|
return this.write(nodeToWrite, (err, statusCode) => {
|
|
501
495
|
/* c8 ignore next */
|
|
502
496
|
if (err) {
|
|
503
497
|
return callback(err);
|
|
504
498
|
}
|
|
505
|
-
|
|
499
|
+
assert(statusCode);
|
|
506
500
|
callback(null, statusCode);
|
|
507
501
|
});
|
|
508
502
|
}
|
|
509
503
|
readAllAttributes(...args) {
|
|
510
504
|
const nodes = args[0];
|
|
511
505
|
const callback = args[1];
|
|
512
|
-
|
|
506
|
+
readAllAttributes(this, nodes)
|
|
513
507
|
.then((data) => callback(null, data))
|
|
514
508
|
.catch((err) => callback(err));
|
|
515
509
|
}
|
|
@@ -521,27 +515,27 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
521
515
|
if (args.length === 2) {
|
|
522
516
|
return this.read(args[0], 0, args[1]);
|
|
523
517
|
}
|
|
524
|
-
|
|
518
|
+
assert(args.length === 3);
|
|
525
519
|
const isArray = Array.isArray(args[0]);
|
|
526
520
|
const nodesToRead = isArray ? args[0] : [args[0]];
|
|
527
|
-
|
|
521
|
+
assert(Array.isArray(nodesToRead));
|
|
528
522
|
const maxAge = args[1];
|
|
529
523
|
const callback = args[2];
|
|
530
|
-
|
|
524
|
+
assert(typeof callback === "function");
|
|
531
525
|
/* c8 ignore next */
|
|
532
526
|
if (helpAPIChange) {
|
|
533
527
|
// the read method deprecation detection and warning
|
|
534
|
-
if (!(
|
|
535
|
-
|
|
536
|
-
warningLog(
|
|
537
|
-
warningLog(
|
|
538
|
-
warningLog(
|
|
539
|
-
warningLog(
|
|
540
|
-
warningLog(
|
|
528
|
+
if (!(getFunctionParameterNames(callback)[1] === "dataValues" ||
|
|
529
|
+
getFunctionParameterNames(callback)[1] === "dataValue")) {
|
|
530
|
+
warningLog(chalk.red("[NODE-OPCUA-E04] the ClientSession#read API has changed !!, please fix the client code"));
|
|
531
|
+
warningLog(chalk.red(" replace ..:"));
|
|
532
|
+
warningLog(chalk.cyan(" session.read(nodesToRead,function(err,nodesToRead,results) {}"));
|
|
533
|
+
warningLog(chalk.red(" with .... :"));
|
|
534
|
+
warningLog(chalk.cyan(" session.read(nodesToRead,function(err,dataValues) {}"));
|
|
541
535
|
warningLog("");
|
|
542
|
-
warningLog(
|
|
543
|
-
"the second argument of your callback function is named"),
|
|
544
|
-
warningLog(
|
|
536
|
+
warningLog(chalk.yellow("please make sure to refactor your code and check that " +
|
|
537
|
+
"the second argument of your callback function is named"), chalk.cyan(`dataValue${isArray ? "s" : ""}`));
|
|
538
|
+
warningLog(chalk.cyan("to make this exception disappear"));
|
|
545
539
|
throw new Error("ERROR ClientSession#read API has changed !!, please fix the client code");
|
|
546
540
|
}
|
|
547
541
|
}
|
|
@@ -551,10 +545,10 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
551
545
|
node.nodeId = this.resolveNodeId(node.nodeId);
|
|
552
546
|
}
|
|
553
547
|
}
|
|
554
|
-
const request = new
|
|
548
|
+
const request = new ReadRequest({
|
|
555
549
|
maxAge,
|
|
556
550
|
nodesToRead,
|
|
557
|
-
timestampsToReturn:
|
|
551
|
+
timestampsToReturn: TimestampsToReturn.Both
|
|
558
552
|
});
|
|
559
553
|
return this.performMessageTransaction(request, (err, response) => {
|
|
560
554
|
/* c8 ignore next */
|
|
@@ -562,11 +556,11 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
562
556
|
return callback(err, response);
|
|
563
557
|
}
|
|
564
558
|
/* c8 ignore next */
|
|
565
|
-
if (!response || !(response instanceof
|
|
559
|
+
if (!response || !(response instanceof ReadResponse)) {
|
|
566
560
|
return callback(new Error("Internal Error"));
|
|
567
561
|
}
|
|
568
562
|
// perform ExtensionObject resolution
|
|
569
|
-
|
|
563
|
+
promoteOpaqueStructure(this, response.results || [])
|
|
570
564
|
.then(() => {
|
|
571
565
|
response.results = response.results || /* c8 ignore next */ [];
|
|
572
566
|
callback(null, isArray ? response.results : response.results[0]);
|
|
@@ -585,12 +579,12 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
585
579
|
}
|
|
586
580
|
}
|
|
587
581
|
createSubscription(options, callback) {
|
|
588
|
-
return this._defaultRequest(
|
|
582
|
+
return this._defaultRequest(CreateSubscriptionRequest, CreateSubscriptionResponse, options, callback);
|
|
589
583
|
}
|
|
590
584
|
createSubscription2(...args) {
|
|
591
585
|
const createSubscriptionRequest = args[0];
|
|
592
586
|
let callback = args[1];
|
|
593
|
-
const subscription = new
|
|
587
|
+
const subscription = new ClientSubscriptionImpl(this, createSubscriptionRequest);
|
|
594
588
|
subscription.on("error", (err) => {
|
|
595
589
|
if (callback) {
|
|
596
590
|
callback(err);
|
|
@@ -598,7 +592,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
598
592
|
}
|
|
599
593
|
});
|
|
600
594
|
subscription.on("started", () => {
|
|
601
|
-
|
|
595
|
+
assert(subscription.session === this, "expecting a session here");
|
|
602
596
|
if (callback) {
|
|
603
597
|
callback(null, subscription);
|
|
604
598
|
callback = null;
|
|
@@ -607,47 +601,47 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
607
601
|
return undefined;
|
|
608
602
|
}
|
|
609
603
|
deleteSubscriptions(options, callback) {
|
|
610
|
-
return this._defaultRequest(
|
|
604
|
+
return this._defaultRequest(DeleteSubscriptionsRequest, DeleteSubscriptionsResponse, options, callback);
|
|
611
605
|
}
|
|
612
606
|
setTriggering(request, callback) {
|
|
613
|
-
return this._defaultRequest(
|
|
607
|
+
return this._defaultRequest(SetTriggeringRequest, SetTriggeringResponse, request, callback);
|
|
614
608
|
}
|
|
615
609
|
/**
|
|
616
610
|
*/
|
|
617
611
|
transferSubscriptions(options, callback) {
|
|
618
|
-
return this._defaultRequest(
|
|
612
|
+
return this._defaultRequest(TransferSubscriptionsRequest, TransferSubscriptionsResponse, options, callback);
|
|
619
613
|
}
|
|
620
614
|
createMonitoredItems(options, callback) {
|
|
621
|
-
return this._defaultRequest(
|
|
615
|
+
return this._defaultRequest(CreateMonitoredItemsRequest, CreateMonitoredItemsResponse, options, callback);
|
|
622
616
|
}
|
|
623
617
|
modifyMonitoredItems(options, callback) {
|
|
624
|
-
return this._defaultRequest(
|
|
618
|
+
return this._defaultRequest(ModifyMonitoredItemsRequest, ModifyMonitoredItemsResponse, options, callback);
|
|
625
619
|
}
|
|
626
620
|
/**
|
|
627
621
|
*
|
|
628
622
|
*/
|
|
629
623
|
modifySubscription(options, callback) {
|
|
630
|
-
return this._defaultRequest(
|
|
624
|
+
return this._defaultRequest(ModifySubscriptionRequest, ModifySubscriptionResponse, options, callback);
|
|
631
625
|
}
|
|
632
626
|
setMonitoringMode(options, callback) {
|
|
633
|
-
return this._defaultRequest(
|
|
627
|
+
return this._defaultRequest(SetMonitoringModeRequest, SetMonitoringModeResponse, options, callback);
|
|
634
628
|
}
|
|
635
629
|
/**
|
|
636
630
|
*/
|
|
637
631
|
publish(options, callback) {
|
|
638
|
-
this._defaultRequest(
|
|
632
|
+
this._defaultRequest(PublishRequest, PublishResponse, options, callback);
|
|
639
633
|
}
|
|
640
634
|
/**
|
|
641
635
|
*
|
|
642
636
|
*/
|
|
643
637
|
republish(options, callback) {
|
|
644
|
-
this._defaultRequest(
|
|
638
|
+
this._defaultRequest(RepublishRequest, RepublishResponse, options, callback);
|
|
645
639
|
}
|
|
646
640
|
/**
|
|
647
641
|
*
|
|
648
642
|
*/
|
|
649
643
|
deleteMonitoredItems(options, callback) {
|
|
650
|
-
this._defaultRequest(
|
|
644
|
+
this._defaultRequest(DeleteMonitoredItemsRequest, DeleteMonitoredItemsResponse, options, callback);
|
|
651
645
|
}
|
|
652
646
|
/**
|
|
653
647
|
* @internal
|
|
@@ -657,13 +651,13 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
657
651
|
const isArray = Array.isArray(args[1]);
|
|
658
652
|
const subscriptionIds = isArray ? args[1] : [args[1]];
|
|
659
653
|
const callback = args[2];
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
const options = new
|
|
654
|
+
assert(typeof callback === "function");
|
|
655
|
+
assert(publishingEnabled === true || publishingEnabled === false);
|
|
656
|
+
const options = new SetPublishingModeRequest({
|
|
663
657
|
publishingEnabled,
|
|
664
658
|
subscriptionIds
|
|
665
659
|
});
|
|
666
|
-
return this._defaultRequest(
|
|
660
|
+
return this._defaultRequest(SetPublishingModeRequest, SetPublishingModeResponse, options, (err, response) => {
|
|
667
661
|
/* c8 ignore next */
|
|
668
662
|
if (err) {
|
|
669
663
|
return callback(err);
|
|
@@ -684,15 +678,15 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
684
678
|
const isArray = Array.isArray(args[0]);
|
|
685
679
|
const browsePaths = isArray ? args[0] : [args[0]];
|
|
686
680
|
const callback = args[1];
|
|
687
|
-
|
|
688
|
-
const request = new
|
|
681
|
+
assert(typeof callback === "function");
|
|
682
|
+
const request = new TranslateBrowsePathsToNodeIdsRequest({ browsePaths });
|
|
689
683
|
return this.performMessageTransaction(request, (err, response) => {
|
|
690
684
|
/* c8 ignore next */
|
|
691
685
|
if (err) {
|
|
692
686
|
return callback(err, response);
|
|
693
687
|
}
|
|
694
688
|
/* c8 ignore next */
|
|
695
|
-
if (!response || !(response instanceof
|
|
689
|
+
if (!response || !(response instanceof TranslateBrowsePathsToNodeIdsResponse)) {
|
|
696
690
|
return callback(new Error("Internal Error"));
|
|
697
691
|
}
|
|
698
692
|
response.results = response.results || /* c8 ignore next */ [];
|
|
@@ -707,7 +701,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
707
701
|
/* c8 ignore next */
|
|
708
702
|
if (!this._client) {
|
|
709
703
|
// c8 ignore next
|
|
710
|
-
doDebug && debugLog(
|
|
704
|
+
doDebug && debugLog(chalk.red("Warning SessionClient is null ?"));
|
|
711
705
|
}
|
|
712
706
|
return !!this._client?._secureChannel?.isOpened();
|
|
713
707
|
}
|
|
@@ -717,9 +711,9 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
717
711
|
callback(new Error("Session has been closed and should not be used to perform a transaction anymore"));
|
|
718
712
|
return;
|
|
719
713
|
}
|
|
720
|
-
if (request instanceof
|
|
721
|
-
request instanceof
|
|
722
|
-
request instanceof
|
|
714
|
+
if (request instanceof PublishRequest ||
|
|
715
|
+
request instanceof ActivateSessionRequest ||
|
|
716
|
+
request instanceof CloseSessionRequest) {
|
|
723
717
|
this._performMessageTransaction(request, callback);
|
|
724
718
|
return;
|
|
725
719
|
}
|
|
@@ -735,13 +729,13 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
735
729
|
if (!pendingTransactionMessageDisplayed) {
|
|
736
730
|
pendingTransactionMessageDisplayed = true;
|
|
737
731
|
warningLog("[NODE-OPCUA-W21]", "Pending transactions: ", this._reconnecting.pendingTransactions.map((a) => a.request.constructor.name).join(" "));
|
|
738
|
-
warningLog("[NODE-OPCUA-W22]",
|
|
732
|
+
warningLog("[NODE-OPCUA-W22]", chalk.yellow("Warning : your opcua client is sending multiple requests simultaneously to the server", request.constructor.name), "\n", chalk.yellow(" please fix your application code"));
|
|
739
733
|
}
|
|
740
734
|
}
|
|
741
735
|
else if (this._reconnecting.pendingTransactions.length > 3) {
|
|
742
736
|
// c8 ignore next
|
|
743
737
|
doDebug &&
|
|
744
|
-
debugLog(
|
|
738
|
+
debugLog(chalk.yellow("Warning : your client is sending multiple requests simultaneously to the server", request.constructor.name));
|
|
745
739
|
}
|
|
746
740
|
this._reconnecting.pendingTransactions.push({ request, callback });
|
|
747
741
|
return;
|
|
@@ -754,7 +748,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
754
748
|
this._performMessageTransaction(request, (err, response) => {
|
|
755
749
|
if (err?.message.match(/BadSessionIdInvalid/) && request.constructor.name !== "ActivateSessionRequest") {
|
|
756
750
|
warningLog("Transaction on Invalid Session ", request.constructor.name, err.message, "isReconnecting?=", this.isReconnecting, "q=", this._reconnecting.pendingTransactions.length);
|
|
757
|
-
request.requestHeader.requestHandle =
|
|
751
|
+
request.requestHeader.requestHandle = requestHandleNotSetValue;
|
|
758
752
|
if (this.isReconnecting) {
|
|
759
753
|
// Hand it back to the queue rather than parking it on a one-shot
|
|
760
754
|
// session_restored listener: that event is emitted only when a repair
|
|
@@ -820,7 +814,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
820
814
|
}
|
|
821
815
|
}
|
|
822
816
|
_performMessageTransaction(request, callback) {
|
|
823
|
-
|
|
817
|
+
assert(typeof callback === "function");
|
|
824
818
|
/* c8 ignore next */
|
|
825
819
|
if (!this._client) {
|
|
826
820
|
// session may have been closed by user ... but is still in used !!
|
|
@@ -832,7 +826,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
832
826
|
// for a long time
|
|
833
827
|
// we may need to queue this transaction, as a secure token may be being reprocessed
|
|
834
828
|
// c8 ignore next
|
|
835
|
-
doDebug && debugLog(
|
|
829
|
+
doDebug && debugLog(chalk.bgWhite.red("!!! Performing transaction on invalid channel !!! ", request.constructor.name));
|
|
836
830
|
callback(new Error("Invalid Channel BadConnectionClosed"));
|
|
837
831
|
return;
|
|
838
832
|
}
|
|
@@ -853,7 +847,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
853
847
|
if (!response) {
|
|
854
848
|
return callback(new Error("internal Error"));
|
|
855
849
|
}
|
|
856
|
-
if (response.responseHeader.serviceResult.isNot(
|
|
850
|
+
if (response.responseHeader.serviceResult.isNot(StatusCodes.Good)) {
|
|
857
851
|
const serviceResultError = new Error(" ServiceResult is " +
|
|
858
852
|
response.responseHeader.serviceResult.toString() +
|
|
859
853
|
" request was " +
|
|
@@ -913,15 +907,15 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
913
907
|
}
|
|
914
908
|
const deleteSubscription = args[0];
|
|
915
909
|
const callback = args[1];
|
|
916
|
-
|
|
917
|
-
|
|
910
|
+
assert(typeof callback === "function");
|
|
911
|
+
assert(typeof deleteSubscription === "boolean");
|
|
918
912
|
/* c8 ignore next */
|
|
919
913
|
if (!this._client) {
|
|
920
914
|
// c8 ignore next
|
|
921
915
|
doDebug && debugLog("ClientSession#close : warning, client is already closed");
|
|
922
916
|
return callback(); // already close ?
|
|
923
917
|
}
|
|
924
|
-
|
|
918
|
+
assert(this._client);
|
|
925
919
|
this._terminatePublishEngine();
|
|
926
920
|
this._client.closeSession(this, deleteSubscription, (err) => {
|
|
927
921
|
// c8 ignore next
|
|
@@ -935,7 +929,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
935
929
|
* @return {Boolean}
|
|
936
930
|
*/
|
|
937
931
|
hasBeenClosed() {
|
|
938
|
-
return
|
|
932
|
+
return isNullOrUndefined(this._client) || this._closed || this._closeEventHasBeenEmitted;
|
|
939
933
|
}
|
|
940
934
|
/**
|
|
941
935
|
* @internal
|
|
@@ -946,7 +940,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
946
940
|
const methodsToCall = isArray
|
|
947
941
|
? args[0]
|
|
948
942
|
: [args[0]];
|
|
949
|
-
|
|
943
|
+
assert(Array.isArray(methodsToCall));
|
|
950
944
|
const callback = args[1];
|
|
951
945
|
// Note : The client has no explicit address space and therefore will struggle to
|
|
952
946
|
// access the method arguments signature.
|
|
@@ -954,14 +948,14 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
954
948
|
// - get the object definition by querying the server
|
|
955
949
|
// - load a fake address space to have some thing to query on our end
|
|
956
950
|
// const request = this._client.factory.constructObjectId("CallRequest",{ methodsToCall: methodsToCall});
|
|
957
|
-
const request = new
|
|
951
|
+
const request = new CallRequest({ methodsToCall });
|
|
958
952
|
return this.performMessageTransaction(request, (err, response) => {
|
|
959
953
|
/* c8 ignore next */
|
|
960
954
|
if (err) {
|
|
961
955
|
return callback(err);
|
|
962
956
|
}
|
|
963
957
|
/* c8 ignore next */
|
|
964
|
-
if (!response || !(response instanceof
|
|
958
|
+
if (!response || !(response instanceof CallResponse)) {
|
|
965
959
|
return callback(new Error("internal error"));
|
|
966
960
|
}
|
|
967
961
|
const results = response.results || [];
|
|
@@ -982,13 +976,13 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
982
976
|
// <UAMethod NodeId="i=11492" BrowseName="GetMonitoredItems"
|
|
983
977
|
// ParentNodeId="i=2253" MethodDeclarationId="i=11489">
|
|
984
978
|
// <UAMethod NodeId="i=11489" BrowseName="GetMonitoredItems" ParentNodeId="i=2004">
|
|
985
|
-
const methodsToCall = new
|
|
979
|
+
const methodsToCall = new CallMethodRequest({
|
|
986
980
|
inputArguments: [
|
|
987
981
|
// BaseDataType
|
|
988
|
-
{ dataType:
|
|
982
|
+
{ dataType: DataType.UInt32, value: subscriptionId }
|
|
989
983
|
],
|
|
990
|
-
methodId:
|
|
991
|
-
objectId:
|
|
984
|
+
methodId: coerceNodeId("ns=0;i=11492"), // MethodIds.Server_GetMonitoredItems;
|
|
985
|
+
objectId: coerceNodeId("ns=0;i=2253") // ObjectId.Server
|
|
992
986
|
});
|
|
993
987
|
return this.call(methodsToCall, (err, result) => {
|
|
994
988
|
/* c8 ignore next */
|
|
@@ -1000,12 +994,12 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1000
994
|
return callback(new Error("internal error"));
|
|
1001
995
|
}
|
|
1002
996
|
/* c8 ignore next */
|
|
1003
|
-
if (result.statusCode.isNot(
|
|
997
|
+
if (result.statusCode.isNot(StatusCodes.Good)) {
|
|
1004
998
|
callback(new Error(result.statusCode.toString()));
|
|
1005
999
|
}
|
|
1006
1000
|
else {
|
|
1007
1001
|
result.outputArguments = result.outputArguments || [];
|
|
1008
|
-
|
|
1002
|
+
assert(result.outputArguments.length === 2);
|
|
1009
1003
|
const data = {
|
|
1010
1004
|
clientHandles: result.outputArguments[1].value,
|
|
1011
1005
|
serverHandles: result.outputArguments[0].value //
|
|
@@ -1014,8 +1008,8 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1014
1008
|
// let make sure we have Uint32Array and not a null pointer
|
|
1015
1009
|
data.serverHandles = data.serverHandles || /* c8 ignore next */ emptyUint32Array;
|
|
1016
1010
|
data.clientHandles = data.clientHandles || /* c8 ignore next */ emptyUint32Array;
|
|
1017
|
-
|
|
1018
|
-
|
|
1011
|
+
assert(data.serverHandles instanceof Uint32Array);
|
|
1012
|
+
assert(data.clientHandles instanceof Uint32Array);
|
|
1019
1013
|
callback(null, data);
|
|
1020
1014
|
}
|
|
1021
1015
|
});
|
|
@@ -1026,8 +1020,8 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1026
1020
|
getArgumentDefinition(...args) {
|
|
1027
1021
|
const methodId = args[0];
|
|
1028
1022
|
const callback = args[1];
|
|
1029
|
-
|
|
1030
|
-
return
|
|
1023
|
+
assert(typeof callback === "function");
|
|
1024
|
+
return getArgumentDefinitionHelper(this, methodId)
|
|
1031
1025
|
.then((result) => {
|
|
1032
1026
|
callback?.(null, result);
|
|
1033
1027
|
})
|
|
@@ -1038,9 +1032,9 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1038
1032
|
registerNodes(...args) {
|
|
1039
1033
|
const nodesToRegister = args[0];
|
|
1040
1034
|
const callback = args[1];
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
const request = new
|
|
1035
|
+
assert(typeof callback === "function");
|
|
1036
|
+
assert(Array.isArray(nodesToRegister));
|
|
1037
|
+
const request = new RegisterNodesRequest({
|
|
1044
1038
|
nodesToRegister: nodesToRegister.map((n) => this.resolveNodeId(n))
|
|
1045
1039
|
});
|
|
1046
1040
|
return this.performMessageTransaction(request, (err, response) => {
|
|
@@ -1049,7 +1043,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1049
1043
|
return callback(err);
|
|
1050
1044
|
}
|
|
1051
1045
|
/* c8 ignore next */
|
|
1052
|
-
if (!response || !(response instanceof
|
|
1046
|
+
if (!response || !(response instanceof RegisterNodesResponse)) {
|
|
1053
1047
|
return callback(new Error("Internal Error"));
|
|
1054
1048
|
}
|
|
1055
1049
|
response.registeredNodeIds = response.registeredNodeIds || /* c8 ignore next */ [];
|
|
@@ -1059,9 +1053,9 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1059
1053
|
unregisterNodes(...args) {
|
|
1060
1054
|
const nodesToUnregister = args[0];
|
|
1061
1055
|
const callback = args[1];
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
const request = new
|
|
1056
|
+
assert(typeof callback === "function");
|
|
1057
|
+
assert(Array.isArray(nodesToUnregister));
|
|
1058
|
+
const request = new UnregisterNodesRequest({
|
|
1065
1059
|
nodesToUnregister: nodesToUnregister.map((n) => this.resolveNodeId(n))
|
|
1066
1060
|
});
|
|
1067
1061
|
return this.performMessageTransaction(request, (err, response) => {
|
|
@@ -1070,7 +1064,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1070
1064
|
return callback(err);
|
|
1071
1065
|
}
|
|
1072
1066
|
/* c8 ignore next */
|
|
1073
|
-
if (!response || !(response instanceof
|
|
1067
|
+
if (!response || !(response instanceof UnregisterNodesResponse)) {
|
|
1074
1068
|
return callback(new Error("Internal Error"));
|
|
1075
1069
|
}
|
|
1076
1070
|
callback();
|
|
@@ -1079,15 +1073,15 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1079
1073
|
queryFirst(...args) {
|
|
1080
1074
|
const queryFirstRequest = args[0];
|
|
1081
1075
|
const callback = args[1];
|
|
1082
|
-
|
|
1083
|
-
const request = new
|
|
1076
|
+
assert(typeof callback === "function");
|
|
1077
|
+
const request = new QueryFirstRequest(queryFirstRequest);
|
|
1084
1078
|
return this.performMessageTransaction(request, (err, response) => {
|
|
1085
1079
|
/* c8 ignore next */
|
|
1086
1080
|
if (err) {
|
|
1087
1081
|
return callback(err);
|
|
1088
1082
|
}
|
|
1089
1083
|
/* c8 ignore next */
|
|
1090
|
-
if (!response || !(response instanceof
|
|
1084
|
+
if (!response || !(response instanceof QueryFirstResponse)) {
|
|
1091
1085
|
return callback(new Error("internal error"));
|
|
1092
1086
|
}
|
|
1093
1087
|
callback(null, response);
|
|
@@ -1098,7 +1092,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1098
1092
|
// "keepAliveManger already started"
|
|
1099
1093
|
return;
|
|
1100
1094
|
}
|
|
1101
|
-
this._keepAliveManager = new
|
|
1095
|
+
this._keepAliveManager = new ClientSessionKeepAliveManager(this);
|
|
1102
1096
|
this._keepAliveManager.on("failure", () => {
|
|
1103
1097
|
/**
|
|
1104
1098
|
* raised when a keep-alive request has failed on the session, may be the session has timeout
|
|
@@ -1122,7 +1116,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1122
1116
|
}
|
|
1123
1117
|
}
|
|
1124
1118
|
dispose() {
|
|
1125
|
-
|
|
1119
|
+
assert(this._closeEventHasBeenEmitted);
|
|
1126
1120
|
this._terminatePublishEngine();
|
|
1127
1121
|
this.stopKeepAliveManager();
|
|
1128
1122
|
this.removeAllListeners();
|
|
@@ -1136,15 +1130,15 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1136
1130
|
const lap2 = now - this.lastResponseReceivedTime.getTime();
|
|
1137
1131
|
const timeoutDelay = this.timeout - lap1;
|
|
1138
1132
|
const timeoutInfo = timeoutDelay < 0
|
|
1139
|
-
?
|
|
1140
|
-
:
|
|
1133
|
+
? chalk.red(` expired since ${-timeoutDelay / 1000} seconds`)
|
|
1134
|
+
: chalk.green(` timeout in ${timeoutDelay / 1000} seconds`);
|
|
1141
1135
|
let str = "";
|
|
1142
1136
|
str += ` name..................... ${this.name}`;
|
|
1143
1137
|
str += `\n sessionId................ ${this.sessionId.toString()}`;
|
|
1144
1138
|
str += `\n authenticationToken...... ${this.authenticationToken ? this.authenticationToken?.toString() : ""}`;
|
|
1145
1139
|
str += `\n timeout.................. ${this.timeout}ms${timeoutInfo}`;
|
|
1146
1140
|
str += `\n serverNonce.............. ${this.serverNonce ? this.serverNonce?.toString("hex") : ""}`;
|
|
1147
|
-
str += `\n serverCertificate........ ${
|
|
1141
|
+
str += `\n serverCertificate........ ${buffer_ellipsis(this.serverCertificate)}`;
|
|
1148
1142
|
str += `\n serverSignature.......... ${this.serverSignature}`;
|
|
1149
1143
|
str += `\n lastRequestSentTime...... ${new Date(this.lastRequestSentTime).toISOString()} (${lap1})`;
|
|
1150
1144
|
str += `\n lastResponseReceivedTime. ${new Date(this.lastResponseReceivedTime).toISOString()} (${lap2})`;
|
|
@@ -1161,7 +1155,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1161
1155
|
if (this._keepAliveManager) {
|
|
1162
1156
|
str += `\n keepAlive ................ ${this._keepAliveManager}`;
|
|
1163
1157
|
str += `\n keepAlive checkInterval.. ${this._keepAliveManager.checkInterval} ms`;
|
|
1164
|
-
str += `\n (defaultTransportTimeout).${
|
|
1158
|
+
str += `\n (defaultTransportTimeout).${ClientSecureChannelLayer.defaultTransportTimeout} ms`;
|
|
1165
1159
|
str += `\n session timeout ${this.timeout} ms`;
|
|
1166
1160
|
}
|
|
1167
1161
|
return str;
|
|
@@ -1169,13 +1163,13 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1169
1163
|
getBuiltInDataType(...args) {
|
|
1170
1164
|
const nodeId = args[0];
|
|
1171
1165
|
const callback = args[1];
|
|
1172
|
-
return
|
|
1166
|
+
return getBuiltInDataType(this, nodeId)
|
|
1173
1167
|
.then((dataType) => callback(null, dataType))
|
|
1174
1168
|
.catch(callback);
|
|
1175
1169
|
}
|
|
1176
1170
|
readNamespaceArray(...args) {
|
|
1177
1171
|
const callback = args[0];
|
|
1178
|
-
|
|
1172
|
+
readNamespaceArray(this)
|
|
1179
1173
|
.then((namespaceArray) => callback(null, namespaceArray))
|
|
1180
1174
|
.catch((err) => {
|
|
1181
1175
|
callback(err);
|
|
@@ -1183,7 +1177,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1183
1177
|
return undefined;
|
|
1184
1178
|
}
|
|
1185
1179
|
getNamespaceIndex(namespaceUri) {
|
|
1186
|
-
|
|
1180
|
+
assert(this.$$namespaceArray, "please make sure that readNamespaceArray has been called");
|
|
1187
1181
|
if (!this.$$namespaceArray) {
|
|
1188
1182
|
throw new Error("please make sure that readNamespaceArray has been called");
|
|
1189
1183
|
}
|
|
@@ -1216,10 +1210,10 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1216
1210
|
/** empty */
|
|
1217
1211
|
}
|
|
1218
1212
|
async extractNamespaceDataType() {
|
|
1219
|
-
return
|
|
1213
|
+
return getExtraDataTypeManager(this);
|
|
1220
1214
|
}
|
|
1221
1215
|
async getExtensionObjectConstructor(dataTypeNodeId) {
|
|
1222
|
-
return
|
|
1216
|
+
return getExtensionObjectConstructor(this, dataTypeNodeId);
|
|
1223
1217
|
}
|
|
1224
1218
|
/**
|
|
1225
1219
|
* construct a Extension object from a DataType and a pojo
|
|
@@ -1231,7 +1225,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1231
1225
|
return new Constructor(pojo);
|
|
1232
1226
|
}
|
|
1233
1227
|
_defaultRequest(requestClass, _responseClass, options, callback) {
|
|
1234
|
-
|
|
1228
|
+
assert(typeof callback === "function");
|
|
1235
1229
|
if (!callback) {
|
|
1236
1230
|
throw new Error("_defaultRequest: expecting a callback function here");
|
|
1237
1231
|
}
|
|
@@ -1267,8 +1261,8 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1267
1261
|
const now = Date.now();
|
|
1268
1262
|
/* c8 ignore next */
|
|
1269
1263
|
if (doDebug) {
|
|
1270
|
-
debugLog(
|
|
1271
|
-
debugLog(
|
|
1264
|
+
debugLog(chalk.bgWhite.red(" server send BadSessionClosed !"));
|
|
1265
|
+
debugLog(chalk.bgWhite.red(" request was "), request.toString());
|
|
1272
1266
|
debugLog(" timeout.................. ", this.timeout);
|
|
1273
1267
|
debugLog(" lastRequestSentTime...... ", new Date(this.lastRequestSentTime).toISOString(), now - this.lastRequestSentTime.getTime());
|
|
1274
1268
|
debugLog(" lastResponseReceivedTime. ", new Date(this.lastResponseReceivedTime).toISOString(), now - this.lastResponseReceivedTime.getTime());
|
|
@@ -1282,7 +1276,7 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1282
1276
|
* send when the session has been closed by the server ( probably due to inactivity and timeout)
|
|
1283
1277
|
* @event session_closed
|
|
1284
1278
|
*/
|
|
1285
|
-
this.emitCloseEvent(
|
|
1279
|
+
this.emitCloseEvent(StatusCodes.BadSessionClosed);
|
|
1286
1280
|
}
|
|
1287
1281
|
}
|
|
1288
1282
|
return callback(err, response);
|
|
@@ -1300,24 +1294,23 @@ class ClientSessionImpl extends node_events_1.EventEmitter {
|
|
|
1300
1294
|
return callback(new Error("Cannot recreate session: session has no client"));
|
|
1301
1295
|
}
|
|
1302
1296
|
this.recursive_repair_detector += 1;
|
|
1303
|
-
warningLog(
|
|
1304
|
-
|
|
1297
|
+
warningLog(chalk.red("----------------> Repairing Client Session as Server believes it is invalid now "));
|
|
1298
|
+
repair_client_session(this._client, this, (err) => {
|
|
1305
1299
|
this.recursive_repair_detector -= 1;
|
|
1306
1300
|
if (err) {
|
|
1307
|
-
warningLog(
|
|
1301
|
+
warningLog(chalk.red("----------------> session Repaired has failed with error", err.message));
|
|
1308
1302
|
return callback(err);
|
|
1309
1303
|
}
|
|
1310
|
-
warningLog(
|
|
1304
|
+
warningLog(chalk.red("----------------> session Repaired, now redoing original transaction "));
|
|
1311
1305
|
this._performMessageTransaction(request, callback);
|
|
1312
1306
|
});
|
|
1313
1307
|
}
|
|
1314
1308
|
}
|
|
1315
|
-
exports.ClientSessionImpl = ClientSessionImpl;
|
|
1316
1309
|
async function promoteOpaqueStructureForCallMethodResult(session, callMethodResult) {
|
|
1317
1310
|
if (!callMethodResult?.outputArguments || callMethodResult.outputArguments.length === 0) {
|
|
1318
1311
|
return;
|
|
1319
1312
|
}
|
|
1320
|
-
await
|
|
1313
|
+
await promoteOpaqueStructure(session, callMethodResult.outputArguments.map((a) => ({ value: a })));
|
|
1321
1314
|
}
|
|
1322
1315
|
function countOpaqueStructures(callMethodResults) {
|
|
1323
1316
|
const x = (a) => {
|
|
@@ -1328,7 +1321,7 @@ function countOpaqueStructures(callMethodResults) {
|
|
|
1328
1321
|
});
|
|
1329
1322
|
};
|
|
1330
1323
|
const opaqueStructureCount = callMethodResults.reduce((prev, callMethodResult) => {
|
|
1331
|
-
return prev +
|
|
1324
|
+
return prev + extractDataValueToPromote(x(callMethodResult.outputArguments)).length;
|
|
1332
1325
|
}, 0);
|
|
1333
1326
|
return opaqueStructureCount;
|
|
1334
1327
|
}
|
|
@@ -1337,45 +1330,45 @@ async function promoteOpaqueStructureForCall(session, callMethodResults) {
|
|
|
1337
1330
|
if (0 === opaqueStructureCount)
|
|
1338
1331
|
return;
|
|
1339
1332
|
// construct dataTypeManager if not already present
|
|
1340
|
-
await
|
|
1333
|
+
await getExtraDataTypeManager(session);
|
|
1341
1334
|
const promises = callMethodResults.map(async (x) => promoteOpaqueStructureForCallMethodResult(session, x));
|
|
1342
1335
|
await Promise.all(promises);
|
|
1343
1336
|
}
|
|
1344
|
-
|
|
1337
|
+
import { withCallback } from "thenify-ex";
|
|
1345
1338
|
const opts = { multiArgs: false };
|
|
1346
|
-
ClientSessionImpl.prototype.browse =
|
|
1347
|
-
ClientSessionImpl.prototype.browseNext =
|
|
1348
|
-
ClientSessionImpl.prototype.readVariableValue =
|
|
1349
|
-
ClientSessionImpl.prototype.readHistoryValue =
|
|
1350
|
-
ClientSessionImpl.prototype.readAggregateValue =
|
|
1351
|
-
ClientSessionImpl.prototype.historyRead =
|
|
1352
|
-
ClientSessionImpl.prototype.write =
|
|
1353
|
-
ClientSessionImpl.prototype.writeSingleNode =
|
|
1354
|
-
ClientSessionImpl.prototype.readAllAttributes =
|
|
1355
|
-
ClientSessionImpl.prototype.read =
|
|
1356
|
-
ClientSessionImpl.prototype.createSubscription =
|
|
1357
|
-
ClientSessionImpl.prototype.createSubscription2 =
|
|
1358
|
-
ClientSessionImpl.prototype.deleteSubscriptions =
|
|
1359
|
-
ClientSessionImpl.prototype.transferSubscriptions =
|
|
1360
|
-
ClientSessionImpl.prototype.createMonitoredItems =
|
|
1361
|
-
ClientSessionImpl.prototype.modifyMonitoredItems =
|
|
1362
|
-
ClientSessionImpl.prototype.modifySubscription =
|
|
1363
|
-
ClientSessionImpl.prototype.setTriggering =
|
|
1364
|
-
ClientSessionImpl.prototype.setMonitoringMode =
|
|
1365
|
-
ClientSessionImpl.prototype.publish =
|
|
1366
|
-
ClientSessionImpl.prototype.republish =
|
|
1367
|
-
ClientSessionImpl.prototype.deleteMonitoredItems =
|
|
1368
|
-
ClientSessionImpl.prototype.setPublishingMode =
|
|
1369
|
-
ClientSessionImpl.prototype.translateBrowsePath =
|
|
1370
|
-
ClientSessionImpl.prototype.performMessageTransaction =
|
|
1371
|
-
ClientSessionImpl.prototype.close =
|
|
1372
|
-
ClientSessionImpl.prototype.call =
|
|
1373
|
-
ClientSessionImpl.prototype.getMonitoredItems =
|
|
1374
|
-
ClientSessionImpl.prototype.getArgumentDefinition =
|
|
1375
|
-
ClientSessionImpl.prototype.queryFirst =
|
|
1376
|
-
ClientSessionImpl.prototype.registerNodes =
|
|
1377
|
-
ClientSessionImpl.prototype.unregisterNodes =
|
|
1378
|
-
ClientSessionImpl.prototype.readNamespaceArray =
|
|
1379
|
-
ClientSessionImpl.prototype.getBuiltInDataType =
|
|
1380
|
-
ClientSessionImpl.prototype.changeUser =
|
|
1339
|
+
ClientSessionImpl.prototype.browse = withCallback(ClientSessionImpl.prototype.browse, opts);
|
|
1340
|
+
ClientSessionImpl.prototype.browseNext = withCallback(ClientSessionImpl.prototype.browseNext, opts);
|
|
1341
|
+
ClientSessionImpl.prototype.readVariableValue = withCallback(ClientSessionImpl.prototype.readVariableValue, opts);
|
|
1342
|
+
ClientSessionImpl.prototype.readHistoryValue = withCallback(ClientSessionImpl.prototype.readHistoryValue, opts);
|
|
1343
|
+
ClientSessionImpl.prototype.readAggregateValue = withCallback(ClientSessionImpl.prototype.readAggregateValue, opts);
|
|
1344
|
+
ClientSessionImpl.prototype.historyRead = withCallback(ClientSessionImpl.prototype.historyRead, opts);
|
|
1345
|
+
ClientSessionImpl.prototype.write = withCallback(ClientSessionImpl.prototype.write, opts);
|
|
1346
|
+
ClientSessionImpl.prototype.writeSingleNode = withCallback(ClientSessionImpl.prototype.writeSingleNode, opts);
|
|
1347
|
+
ClientSessionImpl.prototype.readAllAttributes = withCallback(ClientSessionImpl.prototype.readAllAttributes, opts);
|
|
1348
|
+
ClientSessionImpl.prototype.read = withCallback(ClientSessionImpl.prototype.read, opts);
|
|
1349
|
+
ClientSessionImpl.prototype.createSubscription = withCallback(ClientSessionImpl.prototype.createSubscription, opts);
|
|
1350
|
+
ClientSessionImpl.prototype.createSubscription2 = withCallback(ClientSessionImpl.prototype.createSubscription2, opts);
|
|
1351
|
+
ClientSessionImpl.prototype.deleteSubscriptions = withCallback(ClientSessionImpl.prototype.deleteSubscriptions, opts);
|
|
1352
|
+
ClientSessionImpl.prototype.transferSubscriptions = withCallback(ClientSessionImpl.prototype.transferSubscriptions, opts);
|
|
1353
|
+
ClientSessionImpl.prototype.createMonitoredItems = withCallback(ClientSessionImpl.prototype.createMonitoredItems, opts);
|
|
1354
|
+
ClientSessionImpl.prototype.modifyMonitoredItems = withCallback(ClientSessionImpl.prototype.modifyMonitoredItems, opts);
|
|
1355
|
+
ClientSessionImpl.prototype.modifySubscription = withCallback(ClientSessionImpl.prototype.modifySubscription, opts);
|
|
1356
|
+
ClientSessionImpl.prototype.setTriggering = withCallback(ClientSessionImpl.prototype.setTriggering, opts);
|
|
1357
|
+
ClientSessionImpl.prototype.setMonitoringMode = withCallback(ClientSessionImpl.prototype.setMonitoringMode, opts);
|
|
1358
|
+
ClientSessionImpl.prototype.publish = withCallback(ClientSessionImpl.prototype.publish, opts);
|
|
1359
|
+
ClientSessionImpl.prototype.republish = withCallback(ClientSessionImpl.prototype.republish, opts);
|
|
1360
|
+
ClientSessionImpl.prototype.deleteMonitoredItems = withCallback(ClientSessionImpl.prototype.deleteMonitoredItems, opts);
|
|
1361
|
+
ClientSessionImpl.prototype.setPublishingMode = withCallback(ClientSessionImpl.prototype.setPublishingMode, opts);
|
|
1362
|
+
ClientSessionImpl.prototype.translateBrowsePath = withCallback(ClientSessionImpl.prototype.translateBrowsePath, opts);
|
|
1363
|
+
ClientSessionImpl.prototype.performMessageTransaction = withCallback(ClientSessionImpl.prototype.performMessageTransaction, opts);
|
|
1364
|
+
ClientSessionImpl.prototype.close = withCallback(ClientSessionImpl.prototype.close, opts);
|
|
1365
|
+
ClientSessionImpl.prototype.call = withCallback(ClientSessionImpl.prototype.call, opts);
|
|
1366
|
+
ClientSessionImpl.prototype.getMonitoredItems = withCallback(ClientSessionImpl.prototype.getMonitoredItems, opts);
|
|
1367
|
+
ClientSessionImpl.prototype.getArgumentDefinition = withCallback(ClientSessionImpl.prototype.getArgumentDefinition, opts);
|
|
1368
|
+
ClientSessionImpl.prototype.queryFirst = withCallback(ClientSessionImpl.prototype.queryFirst, opts);
|
|
1369
|
+
ClientSessionImpl.prototype.registerNodes = withCallback(ClientSessionImpl.prototype.registerNodes, opts);
|
|
1370
|
+
ClientSessionImpl.prototype.unregisterNodes = withCallback(ClientSessionImpl.prototype.unregisterNodes, opts);
|
|
1371
|
+
ClientSessionImpl.prototype.readNamespaceArray = withCallback(ClientSessionImpl.prototype.readNamespaceArray, opts);
|
|
1372
|
+
ClientSessionImpl.prototype.getBuiltInDataType = withCallback(ClientSessionImpl.prototype.getBuiltInDataType, opts);
|
|
1373
|
+
ClientSessionImpl.prototype.changeUser = withCallback(ClientSessionImpl.prototype.changeUser, opts);
|
|
1381
1374
|
//# sourceMappingURL=client_session_impl.js.map
|