node-opcua-address-space 2.167.0 → 2.169.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/dist/source/loader/namespace_post_step.js +25 -17
- package/dist/source/loader/namespace_post_step.js.map +1 -1
- package/dist/source/session_context.d.ts +3 -1
- package/dist/source/session_context.js +26 -1
- package/dist/source/session_context.js.map +1 -1
- package/dist/src/address_space.d.ts +14 -11
- package/dist/src/address_space.js +55 -54
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.d.ts +8 -8
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +19 -19
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +11 -13
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +21 -13
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +1 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/base_node_impl.d.ts +1 -0
- package/dist/src/base_node_impl.js +26 -15
- package/dist/src/base_node_impl.js.map +1 -1
- package/dist/src/namespace_impl.d.ts +40 -31
- package/dist/src/namespace_impl.js +174 -161
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/namespace_private.d.ts +12 -4
- package/dist/src/namespace_private.js +1 -4
- package/dist/src/namespace_private.js.map +1 -1
- package/dist/src/ua_method_impl.d.ts +11 -9
- package/dist/src/ua_method_impl.js +24 -27
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/tsconfig_base.tsbuildinfo +1 -1
- package/package.json +35 -37
- package/source/loader/namespace_post_step.ts +28 -19
- package/source/session_context.ts +30 -1
- package/src/address_space.ts +113 -109
- package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +26 -28
- package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +33 -27
- package/src/alarms_and_conditions/ua_condition_impl.ts +1 -1
- package/src/base_node_impl.ts +27 -14
- package/src/namespace_impl.ts +232 -201
- package/src/namespace_private.ts +15 -9
- package/src/ua_method_impl.ts +43 -50
package/src/namespace_private.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-address-space.Private
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
6
|
-
import {
|
|
4
|
+
import type {
|
|
7
5
|
AddReferenceOpts,
|
|
8
6
|
BaseNode,
|
|
9
7
|
ConstructNodeIdOptions,
|
|
10
8
|
CreateNodeOptions,
|
|
11
|
-
ModellingRuleType,
|
|
12
9
|
INamespace,
|
|
10
|
+
ModellingRuleType,
|
|
11
|
+
RequiredModel,
|
|
13
12
|
UADataType,
|
|
14
|
-
RequiredModel
|
|
15
13
|
} from "node-opcua-address-space-base";
|
|
14
|
+
import { assert } from "node-opcua-assert";
|
|
15
|
+
import type { NodeId } from "node-opcua-nodeid";
|
|
16
16
|
|
|
17
|
-
import { AddressSpacePrivate } from "./address_space_private";
|
|
17
|
+
import type { AddressSpacePrivate } from "./address_space_private";
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
export interface NamespacePrivate extends INamespace {
|
|
@@ -40,10 +40,16 @@ export interface NamespacePrivate extends INamespace {
|
|
|
40
40
|
|
|
41
41
|
registerSymbolicNames: boolean;
|
|
42
42
|
|
|
43
|
+
_aliasCount(): number;
|
|
44
|
+
_objectTypeCount(): number;
|
|
45
|
+
_variableTypeCount(): number;
|
|
46
|
+
_dataTypeCount(): number;
|
|
47
|
+
_referenceTypeCount(): number;
|
|
48
|
+
|
|
43
49
|
|
|
44
50
|
}
|
|
45
51
|
|
|
46
|
-
export declare const NamespacePrivate: new (options:
|
|
52
|
+
export declare const NamespacePrivate: new (options: unknown) => NamespacePrivate;
|
|
47
53
|
|
|
48
54
|
function isValidModellingRule(ruleName: string) {
|
|
49
55
|
return (
|
|
@@ -62,12 +68,12 @@ function isValidModellingRule(ruleName: string) {
|
|
|
62
68
|
* @private
|
|
63
69
|
*/
|
|
64
70
|
export function UANamespace_process_modelling_rule(
|
|
65
|
-
references: AddReferenceOpts[],
|
|
71
|
+
references: AddReferenceOpts[],
|
|
66
72
|
modellingRule?: ModellingRuleType
|
|
67
73
|
): void {
|
|
68
74
|
if (modellingRule) {
|
|
69
75
|
assert(isValidModellingRule(modellingRule), "expecting a valid modelling rule");
|
|
70
|
-
const modellingRuleName =
|
|
76
|
+
const modellingRuleName = `ModellingRule_${modellingRule}`;
|
|
71
77
|
// assert(this.findNode(modellingRuleName),"Modelling rule must exist");
|
|
72
78
|
references.push({
|
|
73
79
|
nodeId: modellingRuleName,
|
package/src/ua_method_impl.ts
CHANGED
|
@@ -1,41 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-address-space
|
|
3
3
|
*/
|
|
4
|
-
import { callbackify } from "util";
|
|
5
|
-
import chalk from "chalk";
|
|
6
|
-
import { assert } from "node-opcua-assert";
|
|
7
4
|
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import { DataValue, DataValueLike } from "node-opcua-data-value";
|
|
11
|
-
import { make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
|
|
12
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
13
|
-
import { NumericRange } from "node-opcua-numeric-range";
|
|
14
|
-
import { Argument } from "node-opcua-service-call";
|
|
15
|
-
import { CallbackT, StatusCode, StatusCodes } from "node-opcua-status-code";
|
|
16
|
-
import { CallMethodResultOptions, PermissionType } from "node-opcua-types";
|
|
17
|
-
import { Variant } from "node-opcua-variant";
|
|
18
|
-
import { DataType, VariantLike } from "node-opcua-variant";
|
|
5
|
+
import { callbackify } from "node:util";
|
|
6
|
+
import chalk from "chalk";
|
|
19
7
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
UAMethod,
|
|
24
|
-
UAObject,
|
|
25
|
-
CloneExtraInfo,
|
|
26
|
-
CloneFilter,
|
|
27
|
-
CloneOptions,
|
|
28
|
-
UAObjectType,
|
|
29
|
-
ISessionContext,
|
|
30
|
-
UAVariable,
|
|
8
|
+
type CloneExtraInfo,
|
|
9
|
+
type CloneFilter,
|
|
10
|
+
type CloneOptions,
|
|
31
11
|
defaultCloneFilter,
|
|
32
|
-
|
|
12
|
+
type ISessionContext,
|
|
13
|
+
type MethodFunctor,
|
|
14
|
+
type MethodFunctorA,
|
|
15
|
+
type MethodFunctorC,
|
|
16
|
+
makeDefaultCloneExtraInfo,
|
|
17
|
+
type UAMethod,
|
|
18
|
+
type UAObject,
|
|
19
|
+
type UAObjectType,
|
|
20
|
+
type UAVariable
|
|
33
21
|
} from "node-opcua-address-space-base";
|
|
34
|
-
import {
|
|
22
|
+
import { assert } from "node-opcua-assert";
|
|
23
|
+
import { AttributeIds, type DiagnosticInfo, NodeClass, type QualifiedNameLike } from "node-opcua-data-model";
|
|
24
|
+
import { DataValue, type DataValueLike } from "node-opcua-data-value";
|
|
25
|
+
import { make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
|
|
26
|
+
import type { NodeId } from "node-opcua-nodeid";
|
|
27
|
+
import type { NumericRange } from "node-opcua-numeric-range";
|
|
28
|
+
import { Argument } from "node-opcua-service-call";
|
|
29
|
+
import { type CallbackT, type StatusCode, StatusCodes } from "node-opcua-status-code";
|
|
30
|
+
import { type CallMethodResultOptions, PermissionType } from "node-opcua-types";
|
|
31
|
+
import { DataType, Variant, type VariantLike } from "node-opcua-variant";
|
|
32
|
+
import type { SessionContext } from "../source/session_context";
|
|
33
|
+
import type { AddressSpacePrivate } from "./address_space_private";
|
|
34
|
+
import { BaseNodeImpl } from "./base_node_impl";
|
|
35
35
|
import { _clone } from "./base_node_private";
|
|
36
36
|
import { _handle_hierarchy_parent } from "./namespace_impl";
|
|
37
|
-
import { BaseNodeImpl } from "./base_node_impl";
|
|
38
|
-
import { AddressSpacePrivate } from "./address_space_private";
|
|
39
37
|
|
|
40
38
|
const warningLog = make_warningLog(__filename);
|
|
41
39
|
const debugLog = make_debugLog(__filename);
|
|
@@ -135,7 +133,7 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
135
133
|
if (async_func.length === 2) {
|
|
136
134
|
async_func = callbackify(async_func as MethodFunctorA) as MethodFunctorC;
|
|
137
135
|
}
|
|
138
|
-
assert(async_func.length === 3,
|
|
136
|
+
assert(async_func.length === 3, ` a method with callback should have 3 arguments : got ${async_func.length}`);
|
|
139
137
|
this._asyncExecutionFunction = async_func;
|
|
140
138
|
}
|
|
141
139
|
public execute(
|
|
@@ -181,17 +179,17 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
181
179
|
" " +
|
|
182
180
|
this.browseName.toString() +
|
|
183
181
|
" called for a node that is not a Object/ObjectType but " +
|
|
184
|
-
NodeClass[context.object
|
|
182
|
+
NodeClass[context.object?.nodeClass as number]
|
|
185
183
|
);
|
|
186
184
|
return callback(null, { statusCode: StatusCodes.BadNodeIdInvalid });
|
|
187
185
|
}
|
|
188
186
|
if (!this._asyncExecutionFunction) {
|
|
189
|
-
warningLog(
|
|
187
|
+
warningLog(`Method ${this.nodeId.toString()} ${this.browseName.toString()} has not been bound`);
|
|
190
188
|
return callback(null, { statusCode: StatusCodes.BadInternalError });
|
|
191
189
|
}
|
|
192
190
|
|
|
193
191
|
if (!this.getExecutableFlag(context)) {
|
|
194
|
-
warningLog(
|
|
192
|
+
warningLog(`Method ${this.nodeId.toString()} ${this.browseName.toString()} is not executable`);
|
|
195
193
|
return callback(null, { statusCode: StatusCodes.BadNotExecutable });
|
|
196
194
|
}
|
|
197
195
|
|
|
@@ -212,7 +210,7 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
212
210
|
// ── method call interceptors ──
|
|
213
211
|
const addressSpace = this.addressSpace as AddressSpacePrivate;
|
|
214
212
|
const interceptors = addressSpace._methodCallInterceptors;
|
|
215
|
-
|
|
213
|
+
|
|
216
214
|
const coercedInputArguments = inputArguments as Variant[];
|
|
217
215
|
const callObject = object;
|
|
218
216
|
|
|
@@ -221,13 +219,13 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
221
219
|
for (const interceptor of interceptors) {
|
|
222
220
|
let status: StatusCode;
|
|
223
221
|
try {
|
|
224
|
-
status = await interceptor(context, callObject,
|
|
222
|
+
status = await interceptor(context, callObject, this, coercedInputArguments);
|
|
225
223
|
} catch (err) {
|
|
226
224
|
if (err instanceof Error) {
|
|
227
225
|
warningLog(chalk.red("ERR in method interceptor"), err.message);
|
|
228
226
|
}
|
|
229
227
|
const callMethodResponse = { statusCode: StatusCodes.BadInternalError };
|
|
230
|
-
callback
|
|
228
|
+
callback?.(err as Error, callMethodResponse);
|
|
231
229
|
return;
|
|
232
230
|
}
|
|
233
231
|
if (status !== StatusCodes.Good) {
|
|
@@ -237,14 +235,14 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
237
235
|
inputArgumentResults: coercedInputArguments?.map(() => status) || [],
|
|
238
236
|
inputArgumentDiagnosticInfos
|
|
239
237
|
};
|
|
240
|
-
return callback
|
|
238
|
+
return callback?.(null, callMethodResult);
|
|
241
239
|
}
|
|
242
240
|
}
|
|
243
241
|
|
|
244
242
|
// All interceptors passed — execute the method body
|
|
245
243
|
try {
|
|
246
|
-
|
|
247
|
-
|
|
244
|
+
this._asyncExecutionFunction?.call(
|
|
245
|
+
this as UAMethodImpl,
|
|
248
246
|
coercedInputArguments,
|
|
249
247
|
context,
|
|
250
248
|
(err: Error | null, callMethodResult?: CallMethodResultOptions) => {
|
|
@@ -266,14 +264,14 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
266
264
|
|
|
267
265
|
// ── afterCall event ──
|
|
268
266
|
try {
|
|
269
|
-
|
|
267
|
+
this.emit("afterCall", context, coercedInputArguments, callMethodResult);
|
|
270
268
|
} catch (afterCallErr) {
|
|
271
269
|
if (afterCallErr instanceof Error) {
|
|
272
270
|
warningLog(chalk.red("ERR in afterCall listener"), afterCallErr.message);
|
|
273
271
|
}
|
|
274
272
|
}
|
|
275
273
|
|
|
276
|
-
callback
|
|
274
|
+
callback?.(err, callMethodResult);
|
|
277
275
|
}
|
|
278
276
|
);
|
|
279
277
|
} catch (err) {
|
|
@@ -282,7 +280,7 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
282
280
|
warningLog(err.stack);
|
|
283
281
|
}
|
|
284
282
|
const callMethodResponse = { statusCode: StatusCodes.BadInternalError };
|
|
285
|
-
callback
|
|
283
|
+
callback?.(err as Error, callMethodResponse);
|
|
286
284
|
}
|
|
287
285
|
};
|
|
288
286
|
|
|
@@ -291,7 +289,7 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
291
289
|
warningLog(chalk.red("ERR in method interceptor"), err.message);
|
|
292
290
|
}
|
|
293
291
|
const callMethodResponse = { statusCode: StatusCodes.BadInternalError };
|
|
294
|
-
callback
|
|
292
|
+
callback?.(err as Error, callMethodResponse);
|
|
295
293
|
});
|
|
296
294
|
}
|
|
297
295
|
|
|
@@ -310,13 +308,7 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
310
308
|
if (!extraInfo) {
|
|
311
309
|
extraInfo = makeDefaultCloneExtraInfo(this);
|
|
312
310
|
}
|
|
313
|
-
const clonedMethod = _clone(
|
|
314
|
-
this,
|
|
315
|
-
UAMethodImpl,
|
|
316
|
-
options,
|
|
317
|
-
optionalFilter || defaultCloneFilter,
|
|
318
|
-
extraInfo
|
|
319
|
-
) as UAMethodImpl;
|
|
311
|
+
const clonedMethod = _clone(this, UAMethodImpl, options, optionalFilter || defaultCloneFilter, extraInfo) as UAMethodImpl;
|
|
320
312
|
|
|
321
313
|
clonedMethod._asyncExecutionFunction = this._asyncExecutionFunction;
|
|
322
314
|
clonedMethod._getExecutableFlag = this._getExecutableFlag;
|
|
@@ -351,4 +343,5 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
351
343
|
// tslint:disable:no-var-requires
|
|
352
344
|
// tslint:disable:max-line-length
|
|
353
345
|
import { withCallback } from "thenify-ex";
|
|
346
|
+
|
|
354
347
|
UAMethodImpl.prototype.execute = withCallback(UAMethodImpl.prototype.execute);
|