node-opcua-address-space 2.167.0 → 2.168.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/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/base_node_impl.js +15 -15
- package/dist/src/base_node_impl.js.map +1 -1
- package/dist/src/namespace_impl.d.ts +38 -31
- package/dist/src/namespace_impl.js +161 -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/tsconfig_base.tsbuildinfo +1 -1
- package/package.json +34 -36
- 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/base_node_impl.ts +14 -14
- package/src/namespace_impl.ts +216 -201
- package/src/namespace_private.ts +15 -9
|
@@ -15,17 +15,14 @@ const node_opcua_assert_1 = require("node-opcua-assert");
|
|
|
15
15
|
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
16
16
|
const node_opcua_data_access_1 = require("node-opcua-data-access");
|
|
17
17
|
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
18
|
-
const node_opcua_data_model_2 = require("node-opcua-data-model");
|
|
19
|
-
const node_opcua_data_model_3 = require("node-opcua-data-model");
|
|
20
|
-
const node_opcua_data_model_4 = require("node-opcua-data-model");
|
|
21
18
|
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
22
19
|
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
23
|
-
const node_opcua_nodeid_2 = require("node-opcua-nodeid");
|
|
24
20
|
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
25
21
|
const node_opcua_types_1 = require("node-opcua-types");
|
|
26
22
|
const node_opcua_utils_1 = require("node-opcua-utils");
|
|
27
23
|
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
28
24
|
const address_space_change_event_tools_1 = require("./address_space_change_event_tools");
|
|
25
|
+
const alarms_and_conditions_1 = require("./alarms_and_conditions");
|
|
29
26
|
const ua_condition_impl_1 = require("./alarms_and_conditions/ua_condition_impl");
|
|
30
27
|
const ua_discrete_alarm_impl_1 = require("./alarms_and_conditions/ua_discrete_alarm_impl");
|
|
31
28
|
const ua_exclusive_deviation_alarm_impl_1 = require("./alarms_and_conditions/ua_exclusive_deviation_alarm_impl");
|
|
@@ -33,27 +30,26 @@ const ua_exclusive_limit_alarm_impl_1 = require("./alarms_and_conditions/ua_excl
|
|
|
33
30
|
const ua_limit_alarm_impl_1 = require("./alarms_and_conditions/ua_limit_alarm_impl");
|
|
34
31
|
const ua_non_exclusive_deviation_alarm_impl_1 = require("./alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl");
|
|
35
32
|
const ua_non_exclusive_limit_alarm_impl_1 = require("./alarms_and_conditions/ua_non_exclusive_limit_alarm_impl");
|
|
36
|
-
const alarms_and_conditions_1 = require("./alarms_and_conditions");
|
|
37
33
|
const ua_off_normal_alarm_impl_1 = require("./alarms_and_conditions/ua_off_normal_alarm_impl");
|
|
34
|
+
const base_node_impl_1 = require("./base_node_impl");
|
|
38
35
|
const add_dataItem_stuff_1 = require("./data_access/add_dataItem_stuff");
|
|
39
36
|
const ua_multistate_discrete_impl_1 = require("./data_access/ua_multistate_discrete_impl");
|
|
40
|
-
|
|
41
|
-
const
|
|
37
|
+
const ua_multistate_value_discrete_impl_1 = require("./data_access/ua_multistate_value_discrete_impl");
|
|
38
|
+
const ua_two_state_discrete_impl_1 = require("./data_access/ua_two_state_discrete_impl");
|
|
42
39
|
//
|
|
43
40
|
const namespace_private_1 = require("./namespace_private");
|
|
44
|
-
const base_node_impl_1 = require("./base_node_impl");
|
|
45
|
-
const ua_variable_impl_1 = require("./ua_variable_impl");
|
|
46
41
|
const nodeid_manager_1 = require("./nodeid_manager");
|
|
47
|
-
const ua_two_state_discrete_impl_1 = require("./data_access/ua_two_state_discrete_impl");
|
|
48
42
|
const role_permissions_1 = require("./role_permissions");
|
|
49
|
-
|
|
43
|
+
// state machine
|
|
44
|
+
const ua_two_state_variable_1 = require("./state_machine/ua_two_state_variable");
|
|
50
45
|
const ua_data_type_impl_1 = require("./ua_data_type_impl");
|
|
51
|
-
const ua_object_type_impl_1 = require("./ua_object_type_impl");
|
|
52
46
|
const ua_method_impl_1 = require("./ua_method_impl");
|
|
53
|
-
const
|
|
47
|
+
const ua_object_impl_1 = require("./ua_object_impl");
|
|
48
|
+
const ua_object_type_impl_1 = require("./ua_object_type_impl");
|
|
54
49
|
const ua_reference_type_impl_1 = require("./ua_reference_type_impl");
|
|
50
|
+
const ua_variable_impl_1 = require("./ua_variable_impl");
|
|
51
|
+
const ua_variable_type_impl_1 = require("./ua_variable_type_impl");
|
|
55
52
|
const ua_view_impl_1 = require("./ua_view_impl");
|
|
56
|
-
const ua_multistate_value_discrete_impl_1 = require("./data_access/ua_multistate_value_discrete_impl");
|
|
57
53
|
function _makeHashKey(nodeId) {
|
|
58
54
|
switch (nodeId.identifierType) {
|
|
59
55
|
case node_opcua_nodeid_1.NodeIdType.STRING:
|
|
@@ -76,16 +72,16 @@ const regExp1 = /^(s|i|b|g)=/;
|
|
|
76
72
|
const regExpNamespaceDotBrowseName = /^[0-9]+:(.*)/;
|
|
77
73
|
function detachNode(node) {
|
|
78
74
|
const addressSpace = node.addressSpace;
|
|
79
|
-
const nonHierarchicalReferences = node.findReferencesEx("NonHierarchicalReferences",
|
|
75
|
+
const nonHierarchicalReferences = node.findReferencesEx("NonHierarchicalReferences", node_opcua_data_model_1.BrowseDirection.Inverse);
|
|
80
76
|
for (const ref of nonHierarchicalReferences) {
|
|
81
77
|
(0, node_opcua_assert_1.assert)(!ref.isForward);
|
|
82
|
-
ref.node
|
|
78
|
+
ref.node?.removeReference({
|
|
83
79
|
isForward: !ref.isForward,
|
|
84
80
|
nodeId: node.nodeId,
|
|
85
81
|
referenceType: ref.referenceType
|
|
86
82
|
});
|
|
87
83
|
}
|
|
88
|
-
const nonHierarchicalReferencesF = node.findReferencesEx("NonHierarchicalReferences",
|
|
84
|
+
const nonHierarchicalReferencesF = node.findReferencesEx("NonHierarchicalReferences", node_opcua_data_model_1.BrowseDirection.Forward);
|
|
89
85
|
for (const ref of nonHierarchicalReferencesF) {
|
|
90
86
|
if (!ref.node) {
|
|
91
87
|
// could be a special case of a frequently use target node such as ModellingRule_Mandatory that do not back trace
|
|
@@ -93,14 +89,14 @@ function detachNode(node) {
|
|
|
93
89
|
continue;
|
|
94
90
|
}
|
|
95
91
|
(0, node_opcua_assert_1.assert)(ref.isForward);
|
|
96
|
-
ref.node
|
|
92
|
+
ref.node?.removeReference({
|
|
97
93
|
isForward: !ref.isForward,
|
|
98
94
|
nodeId: node.nodeId,
|
|
99
95
|
referenceType: ref.referenceType
|
|
100
96
|
});
|
|
101
97
|
}
|
|
102
98
|
// remove reversed Hierarchical references
|
|
103
|
-
const hierarchicalReferences = node.findReferencesEx("HierarchicalReferences",
|
|
99
|
+
const hierarchicalReferences = node.findReferencesEx("HierarchicalReferences", node_opcua_data_model_1.BrowseDirection.Inverse);
|
|
104
100
|
for (const ref of hierarchicalReferences) {
|
|
105
101
|
(0, node_opcua_assert_1.assert)(!ref.isForward);
|
|
106
102
|
const parent = addressSpace.findNode(ref.nodeId);
|
|
@@ -112,6 +108,21 @@ function detachNode(node) {
|
|
|
112
108
|
}
|
|
113
109
|
node.unpropagate_back_references();
|
|
114
110
|
}
|
|
111
|
+
function toNodeId(nodeId) {
|
|
112
|
+
if (!nodeId) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
if (nodeId instanceof node_opcua_nodeid_1.NodeId) {
|
|
116
|
+
return nodeId;
|
|
117
|
+
}
|
|
118
|
+
if (typeof nodeId === "string") {
|
|
119
|
+
return (0, node_opcua_nodeid_1.coerceNodeId)(nodeId);
|
|
120
|
+
}
|
|
121
|
+
if (typeof nodeId === "number") {
|
|
122
|
+
return (0, node_opcua_nodeid_1.coerceNodeId)(nodeId);
|
|
123
|
+
}
|
|
124
|
+
return nodeId.nodeId;
|
|
125
|
+
}
|
|
115
126
|
/**
|
|
116
127
|
*
|
|
117
128
|
* @constructor
|
|
@@ -147,7 +158,7 @@ class NamespaceImpl {
|
|
|
147
158
|
constructor(options) {
|
|
148
159
|
// c8 ignore next
|
|
149
160
|
if (!(typeof options.namespaceUri === "string")) {
|
|
150
|
-
throw new Error(
|
|
161
|
+
throw new Error(`NamespaceImpl constructor: namespaceUri must exists and be a string : got ${options.namespaceUri}`);
|
|
151
162
|
}
|
|
152
163
|
// c8 ignore next
|
|
153
164
|
if (typeof options.index !== "number") {
|
|
@@ -223,7 +234,7 @@ class NamespaceImpl {
|
|
|
223
234
|
findNode(nodeId) {
|
|
224
235
|
if (typeof nodeId === "string") {
|
|
225
236
|
if (nodeId.match(regExp1)) {
|
|
226
|
-
nodeId =
|
|
237
|
+
nodeId = `ns=${this.index};${nodeId}`;
|
|
227
238
|
}
|
|
228
239
|
}
|
|
229
240
|
nodeId = (0, node_opcua_nodeid_1.resolveNodeId)(nodeId);
|
|
@@ -270,7 +281,7 @@ class NamespaceImpl {
|
|
|
270
281
|
findReferenceTypeFromInverseName(inverseName) {
|
|
271
282
|
(0, node_opcua_assert_1.assert)(typeof inverseName === "string");
|
|
272
283
|
const node = this._referenceTypeMapInv.get(inverseName);
|
|
273
|
-
(0, node_opcua_assert_1.assert)(!node || (node.nodeClass ===
|
|
284
|
+
(0, node_opcua_assert_1.assert)(!node || (node.nodeClass === node_opcua_data_model_1.NodeClass.ReferenceType && node.inverseName.text === inverseName));
|
|
274
285
|
return node ? node : null;
|
|
275
286
|
}
|
|
276
287
|
/**
|
|
@@ -281,7 +292,7 @@ class NamespaceImpl {
|
|
|
281
292
|
*/
|
|
282
293
|
addAlias(alias_name, nodeId) {
|
|
283
294
|
(0, node_opcua_assert_1.assert)(typeof alias_name === "string");
|
|
284
|
-
(0, node_opcua_assert_1.assert)(nodeId instanceof
|
|
295
|
+
(0, node_opcua_assert_1.assert)(nodeId instanceof node_opcua_nodeid_1.NodeId);
|
|
285
296
|
(0, node_opcua_assert_1.assert)(nodeId.namespace === this.index);
|
|
286
297
|
this._aliases.set(alias_name, nodeId);
|
|
287
298
|
}
|
|
@@ -303,10 +314,10 @@ class NamespaceImpl {
|
|
|
303
314
|
*
|
|
304
315
|
*/
|
|
305
316
|
addObjectType(options) {
|
|
306
|
-
(0, node_opcua_assert_1.assert)(!Object.
|
|
307
|
-
(0, node_opcua_assert_1.assert)(!Object.
|
|
308
|
-
(0, node_opcua_assert_1.assert)(!Object.
|
|
309
|
-
return this._addObjectOrVariableType(options, "BaseObjectType",
|
|
317
|
+
(0, node_opcua_assert_1.assert)(!Object.hasOwn(options, "dataType"), "an objectType should not have a dataType");
|
|
318
|
+
(0, node_opcua_assert_1.assert)(!Object.hasOwn(options, "valueRank"), "an objectType should not have a valueRank");
|
|
319
|
+
(0, node_opcua_assert_1.assert)(!Object.hasOwn(options, "arrayDimensions"), "an objectType should not have a arrayDimensions");
|
|
320
|
+
return this._addObjectOrVariableType(options, "BaseObjectType", node_opcua_data_model_1.NodeClass.ObjectType);
|
|
310
321
|
}
|
|
311
322
|
/**
|
|
312
323
|
* add a new Variable type to the address space
|
|
@@ -324,17 +335,17 @@ class NamespaceImpl {
|
|
|
324
335
|
*
|
|
325
336
|
*/
|
|
326
337
|
addVariableType(options) {
|
|
327
|
-
(0, node_opcua_assert_1.assert)(!Object.
|
|
338
|
+
(0, node_opcua_assert_1.assert)(!Object.hasOwn(options, "arrayDimension"), "Do you mean ArrayDimensions ?");
|
|
328
339
|
// dataType
|
|
329
340
|
options.dataType = options.dataType || "Int32";
|
|
330
341
|
options.dataType = this.addressSpace._coerce_DataType(options.dataType);
|
|
331
342
|
// valueRank/ arrayDimensions
|
|
332
343
|
(0, node_opcua_variant_1.verifyRankAndDimensions)(options);
|
|
333
344
|
// arrayDimensions
|
|
334
|
-
const variableType = this._addObjectOrVariableType(options, "BaseVariableType",
|
|
345
|
+
const variableType = this._addObjectOrVariableType(options, "BaseVariableType", node_opcua_data_model_1.NodeClass.VariableType);
|
|
335
346
|
variableType.dataType = options.dataType;
|
|
336
347
|
variableType.valueRank = options.valueRank || 0;
|
|
337
|
-
variableType.arrayDimensions = options.arrayDimensions;
|
|
348
|
+
variableType.arrayDimensions = options.arrayDimensions || [];
|
|
338
349
|
return variableType;
|
|
339
350
|
}
|
|
340
351
|
/**
|
|
@@ -342,7 +353,7 @@ class NamespaceImpl {
|
|
|
342
353
|
*/
|
|
343
354
|
addVariable(options) {
|
|
344
355
|
(0, node_opcua_assert_1.assert)(arguments.length === 1, "Invalid arguments IAddressSpace#addVariable now takes only one argument.");
|
|
345
|
-
if (Object.
|
|
356
|
+
if (Object.hasOwn(options, "propertyOf") && options.propertyOf) {
|
|
346
357
|
(0, node_opcua_assert_1.assert)(!options.typeDefinition || options.typeDefinition === "PropertyType");
|
|
347
358
|
options.typeDefinition = options.typeDefinition || "PropertyType";
|
|
348
359
|
}
|
|
@@ -352,41 +363,39 @@ class NamespaceImpl {
|
|
|
352
363
|
return this._addVariable(options);
|
|
353
364
|
}
|
|
354
365
|
addView(options) {
|
|
355
|
-
(0, node_opcua_assert_1.assert)(
|
|
356
|
-
(0, node_opcua_assert_1.assert)(options);
|
|
357
|
-
(0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "browseName"));
|
|
358
|
-
(0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "organizedBy"));
|
|
366
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(options, "browseName"));
|
|
367
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(options, "organizedBy"));
|
|
359
368
|
const browseName = options.browseName;
|
|
360
369
|
(0, node_opcua_assert_1.assert)(typeof browseName === "string");
|
|
361
370
|
const addressSpace = this.addressSpace;
|
|
362
|
-
const baseDataVariableTypeId = addressSpace.findVariableType("BaseDataVariableType")
|
|
371
|
+
const baseDataVariableTypeId = addressSpace.findVariableType("BaseDataVariableType")?.nodeId;
|
|
363
372
|
// ------------------------------------------ TypeDefinition
|
|
364
|
-
const
|
|
373
|
+
const _typeDefinition = options.typeDefinition || baseDataVariableTypeId;
|
|
365
374
|
options.references = options.references || [];
|
|
366
375
|
options.references.push({
|
|
367
376
|
isForward: true,
|
|
368
|
-
nodeId:
|
|
377
|
+
nodeId: toNodeId(_typeDefinition) || node_opcua_nodeid_1.NodeId.nullNodeId,
|
|
369
378
|
referenceType: "HasTypeDefinition"
|
|
370
379
|
});
|
|
371
380
|
const createOptions = options;
|
|
372
381
|
(0, node_opcua_assert_1.assert)(!createOptions.nodeClass);
|
|
373
|
-
createOptions.nodeClass =
|
|
382
|
+
createOptions.nodeClass = node_opcua_data_model_1.NodeClass.View;
|
|
374
383
|
const view = this.createNode(createOptions);
|
|
375
|
-
(0, node_opcua_assert_1.assert)(view.nodeId instanceof
|
|
376
|
-
(0, node_opcua_assert_1.assert)(view.nodeClass ===
|
|
384
|
+
(0, node_opcua_assert_1.assert)(view.nodeId instanceof node_opcua_nodeid_1.NodeId);
|
|
385
|
+
(0, node_opcua_assert_1.assert)(view.nodeClass === node_opcua_data_model_1.NodeClass.View);
|
|
377
386
|
return view;
|
|
378
387
|
}
|
|
379
388
|
addObject(options1) {
|
|
380
389
|
const options = options1;
|
|
381
|
-
(0, node_opcua_assert_1.assert)(!options.nodeClass || options.nodeClass ===
|
|
382
|
-
options.nodeClass =
|
|
390
|
+
(0, node_opcua_assert_1.assert)(!options.nodeClass || options.nodeClass === node_opcua_data_model_1.NodeClass.Object);
|
|
391
|
+
options.nodeClass = node_opcua_data_model_1.NodeClass.Object;
|
|
383
392
|
const typeDefinition = options.typeDefinition || "BaseObjectType";
|
|
384
393
|
options.references = options.references || [];
|
|
385
394
|
options.references.push({ referenceType: "HasTypeDefinition", isForward: true, nodeId: typeDefinition });
|
|
386
395
|
options.eventNotifier = +(options.eventNotifier || 0);
|
|
387
396
|
const obj = this.createNode(options);
|
|
388
397
|
(0, node_opcua_assert_1.assert)(obj instanceof ua_object_impl_1.UAObjectImpl);
|
|
389
|
-
(0, node_opcua_assert_1.assert)(obj.nodeClass ===
|
|
398
|
+
(0, node_opcua_assert_1.assert)(obj.nodeClass === node_opcua_data_model_1.NodeClass.Object);
|
|
390
399
|
return obj;
|
|
391
400
|
}
|
|
392
401
|
/**
|
|
@@ -407,7 +416,7 @@ class NamespaceImpl {
|
|
|
407
416
|
(0, node_opcua_assert_1.assert)(!options.typeDefinition, "addFolder does not expect typeDefinition to be defined ");
|
|
408
417
|
const typeDefinition = addressSpace._coerceTypeDefinition("FolderType");
|
|
409
418
|
parentFolder = addressSpace._coerceFolder(parentFolder);
|
|
410
|
-
options.nodeClass =
|
|
419
|
+
options.nodeClass = node_opcua_data_model_1.NodeClass.Object;
|
|
411
420
|
options.references = [
|
|
412
421
|
{ referenceType: "HasTypeDefinition", isForward: true, nodeId: typeDefinition },
|
|
413
422
|
{ referenceType: "Organizes", isForward: false, nodeId: parentFolder.nodeId }
|
|
@@ -425,11 +434,11 @@ class NamespaceImpl {
|
|
|
425
434
|
addReferenceType(options) {
|
|
426
435
|
const addressSpace = this.addressSpace;
|
|
427
436
|
const options1 = options;
|
|
428
|
-
options1.nodeClass =
|
|
437
|
+
options1.nodeClass = node_opcua_data_model_1.NodeClass.ReferenceType;
|
|
429
438
|
options1.references = options.references || [];
|
|
430
439
|
options1.nodeId = options.nodeId;
|
|
431
440
|
if (options.subtypeOf) {
|
|
432
|
-
const subtypeOfNodeId = addressSpace._coerceType(options.subtypeOf, "References",
|
|
441
|
+
const subtypeOfNodeId = addressSpace._coerceType(options.subtypeOf, "References", node_opcua_data_model_1.NodeClass.ReferenceType);
|
|
433
442
|
(0, node_opcua_assert_1.assert)(subtypeOfNodeId);
|
|
434
443
|
options1.references.push({
|
|
435
444
|
isForward: false,
|
|
@@ -450,11 +459,11 @@ class NamespaceImpl {
|
|
|
450
459
|
|
|
451
460
|
*/
|
|
452
461
|
createDataType(options) {
|
|
453
|
-
(0, node_opcua_assert_1.assert)(Object.
|
|
454
|
-
(0, node_opcua_assert_1.assert)(!Object.
|
|
455
|
-
(0, node_opcua_assert_1.assert)(Object.
|
|
462
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(options, "isAbstract"), "must provide isAbstract");
|
|
463
|
+
(0, node_opcua_assert_1.assert)(!Object.hasOwn(options, "nodeClass"));
|
|
464
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(options, "browseName"), "must provide a browseName");
|
|
456
465
|
const options1 = options;
|
|
457
|
-
options1.nodeClass =
|
|
466
|
+
options1.nodeClass = node_opcua_data_model_1.NodeClass.DataType;
|
|
458
467
|
options1.references = options.references || [];
|
|
459
468
|
if (options1.references.length === 0) {
|
|
460
469
|
if (!options1.subtypeOf) {
|
|
@@ -492,7 +501,7 @@ class NamespaceImpl {
|
|
|
492
501
|
addressSpace.modelChangeTransaction(() => {
|
|
493
502
|
(0, node_opcua_assert_1.assert)(isNonEmptyQualifiedName(options.browseName));
|
|
494
503
|
// xx assert(Object.prototype.hasOwnProperty.call(options,"browseName") && options.browseName.length > 0);
|
|
495
|
-
(0, node_opcua_assert_1.assert)(Object.
|
|
504
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(options, "nodeClass"));
|
|
496
505
|
options.references = addressSpace.normalizeReferenceTypes(options.references);
|
|
497
506
|
const references = _copy_references(options.references);
|
|
498
507
|
_handle_hierarchy_parent(addressSpace, references, options);
|
|
@@ -500,7 +509,7 @@ class NamespaceImpl {
|
|
|
500
509
|
(0, namespace_private_1.UANamespace_process_modelling_rule)(references, options.modellingRule);
|
|
501
510
|
options.references = references;
|
|
502
511
|
node = this.internalCreateNode(options);
|
|
503
|
-
(0, node_opcua_assert_1.assert)(node.nodeId instanceof
|
|
512
|
+
(0, node_opcua_assert_1.assert)(node.nodeId instanceof node_opcua_nodeid_1.NodeId);
|
|
504
513
|
node.propagate_back_references();
|
|
505
514
|
node.install_extra_properties();
|
|
506
515
|
_create_node_version_if_needed(node, options);
|
|
@@ -518,13 +527,13 @@ class NamespaceImpl {
|
|
|
518
527
|
*/
|
|
519
528
|
deleteNode(nodeOrNodeId) {
|
|
520
529
|
let node = null;
|
|
521
|
-
let nodeId = new
|
|
522
|
-
if (nodeOrNodeId instanceof
|
|
530
|
+
let nodeId = new node_opcua_nodeid_1.NodeId();
|
|
531
|
+
if (nodeOrNodeId instanceof node_opcua_nodeid_1.NodeId) {
|
|
523
532
|
nodeId = nodeOrNodeId;
|
|
524
533
|
node = this.findNode(nodeId);
|
|
525
534
|
// c8 ignore next
|
|
526
535
|
if (!node) {
|
|
527
|
-
throw new Error(
|
|
536
|
+
throw new Error(` deleteNode : cannot find node with nodeId${nodeId.toString()}`);
|
|
528
537
|
}
|
|
529
538
|
}
|
|
530
539
|
else if (nodeOrNodeId instanceof base_node_impl_1.BaseNodeImpl) {
|
|
@@ -542,7 +551,7 @@ class NamespaceImpl {
|
|
|
542
551
|
throw new Error("this node doesn't belong to this namespace");
|
|
543
552
|
}
|
|
544
553
|
// notify parent that node is being removed
|
|
545
|
-
const hierarchicalReferences = node.findReferencesEx("HierarchicalReferences",
|
|
554
|
+
const hierarchicalReferences = node.findReferencesEx("HierarchicalReferences", node_opcua_data_model_1.BrowseDirection.Inverse);
|
|
546
555
|
for (const ref of hierarchicalReferences) {
|
|
547
556
|
(0, node_opcua_assert_1.assert)(!ref.isForward);
|
|
548
557
|
const parent = addressSpace.findNode(ref.nodeId);
|
|
@@ -555,10 +564,10 @@ class NamespaceImpl {
|
|
|
555
564
|
}
|
|
556
565
|
// recursively delete all nodes below in the hierarchy of nodes
|
|
557
566
|
// TODO : a better idea would be to extract any references of type "HasChild"
|
|
558
|
-
const components = node.findReferencesEx("HasComponent",
|
|
559
|
-
const properties = node.findReferencesEx("HasProperty",
|
|
567
|
+
const components = node.findReferencesEx("HasComponent", node_opcua_data_model_1.BrowseDirection.Forward);
|
|
568
|
+
const properties = node.findReferencesEx("HasProperty", node_opcua_data_model_1.BrowseDirection.Forward);
|
|
560
569
|
// TODO: shall we delete nodes pointed by "Organizes" links here ?
|
|
561
|
-
const subFolders = node.findReferencesEx("Organizes",
|
|
570
|
+
const subFolders = node.findReferencesEx("Organizes", node_opcua_data_model_1.BrowseDirection.Forward);
|
|
562
571
|
for (const r of components) {
|
|
563
572
|
deleteNodePointedByReference(r);
|
|
564
573
|
}
|
|
@@ -584,10 +593,10 @@ class NamespaceImpl {
|
|
|
584
593
|
referenceTypeIds: {}
|
|
585
594
|
};
|
|
586
595
|
for (const referenceType of this._referenceTypeMap.values()) {
|
|
587
|
-
standardNodeIds.referenceTypeIds[referenceType
|
|
596
|
+
standardNodeIds.referenceTypeIds[referenceType?.browseName?.name] = referenceType.nodeId.toString();
|
|
588
597
|
}
|
|
589
598
|
for (const objectType of this._objectTypeMap.values()) {
|
|
590
|
-
standardNodeIds.objectTypeIds[objectType
|
|
599
|
+
standardNodeIds.objectTypeIds[objectType?.browseName?.name] = objectType.nodeId.toString();
|
|
591
600
|
}
|
|
592
601
|
return standardNodeIds;
|
|
593
602
|
}
|
|
@@ -618,7 +627,7 @@ class NamespaceImpl {
|
|
|
618
627
|
options.subtypeOf = options.subtypeOf || "BaseEventType";
|
|
619
628
|
// are eventType always abstract ?? No => Condition can be instantiated!
|
|
620
629
|
// but, by default is abstract is true
|
|
621
|
-
options.isAbstract = Object.
|
|
630
|
+
options.isAbstract = Object.hasOwn(options, "isAbstract") ? !!options.isAbstract : true;
|
|
622
631
|
return this.addObjectType(options);
|
|
623
632
|
}
|
|
624
633
|
// ---------------------------------------------------------------------------------------------------
|
|
@@ -676,7 +685,7 @@ class NamespaceImpl {
|
|
|
676
685
|
*/
|
|
677
686
|
addAnalogDataItem(options) {
|
|
678
687
|
const addressSpace = this.addressSpace;
|
|
679
|
-
(0, node_opcua_assert_1.assert)(Object.
|
|
688
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(options, "engineeringUnitsRange"), "expecting engineeringUnitsRange");
|
|
680
689
|
const dataType = options.dataType || "Number";
|
|
681
690
|
const analogItemType = addressSpace.findVariableType("AnalogItemType");
|
|
682
691
|
if (!analogItemType) {
|
|
@@ -710,7 +719,7 @@ class NamespaceImpl {
|
|
|
710
719
|
(0, node_opcua_assert_1.assert)(euRange.readValue().value.value instanceof node_opcua_types_1.Range);
|
|
711
720
|
const handler = variable.handle_semantic_changed.bind(variable);
|
|
712
721
|
euRange.on("value_changed", handler);
|
|
713
|
-
if (Object.
|
|
722
|
+
if (Object.hasOwn(options, "instrumentRange")) {
|
|
714
723
|
const instrumentRange = this.addVariable({
|
|
715
724
|
accessLevel: "CurrentRead | CurrentWrite",
|
|
716
725
|
browseName: { name: "InstrumentRange", namespaceIndex: 0 },
|
|
@@ -727,7 +736,7 @@ class NamespaceImpl {
|
|
|
727
736
|
instrumentRange.on("value_changed", handler);
|
|
728
737
|
}
|
|
729
738
|
variable.acceptValueOutOfRange = options.acceptValueOutOfRange;
|
|
730
|
-
if (Object.
|
|
739
|
+
if (Object.hasOwn(options, "engineeringUnits")) {
|
|
731
740
|
const engineeringUnits = new node_opcua_types_1.EUInformation(options.engineeringUnits);
|
|
732
741
|
(0, node_opcua_assert_1.assert)(engineeringUnits instanceof node_opcua_types_1.EUInformation, "expecting engineering units");
|
|
733
742
|
// EngineeringUnits specifies the units for the DataItem‟s value (e.g., degree, hertz, seconds). The
|
|
@@ -828,26 +837,17 @@ class NamespaceImpl {
|
|
|
828
837
|
* @param options.value
|
|
829
838
|
*/
|
|
830
839
|
addYArrayItem(options) {
|
|
831
|
-
(0, node_opcua_assert_1.assert)(Object.
|
|
832
|
-
(0, node_opcua_assert_1.assert)(Object.
|
|
840
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(options, "engineeringUnitsRange"), "expecting engineeringUnitsRange");
|
|
841
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(options, "axisScaleType"), "expecting axisScaleType");
|
|
833
842
|
(0, node_opcua_assert_1.assert)(options.xAxisDefinition !== null && typeof options.xAxisDefinition === "object", "expecting a xAxisDefinition");
|
|
834
843
|
const addressSpace = this.addressSpace;
|
|
835
844
|
const YArrayItemType = addressSpace.findVariableType("YArrayItemType");
|
|
836
845
|
if (!YArrayItemType) {
|
|
837
846
|
throw new Error("expecting YArrayItemType to be defined , check nodeset xml file");
|
|
838
847
|
}
|
|
839
|
-
|
|
840
|
-
if (!options) {
|
|
841
|
-
return (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_variant_1.DataType.Float);
|
|
842
|
-
}
|
|
843
|
-
if (Object.prototype.hasOwnProperty.call(options, "nodeId") || options instanceof base_node_impl_1.BaseNodeImpl) {
|
|
844
|
-
return options.nodeId;
|
|
845
|
-
}
|
|
846
|
-
return (0, node_opcua_nodeid_1.resolveNodeId)(options);
|
|
847
|
-
}
|
|
848
|
-
const dataType = toNodeId(options.dataType);
|
|
848
|
+
const dataType = toNodeId(options.dataType) || toNodeId(options.value?.dataType);
|
|
849
849
|
const optionals = [];
|
|
850
|
-
if (Object.
|
|
850
|
+
if (Object.hasOwn(options, "instrumentRange")) {
|
|
851
851
|
optionals.push("InstrumentRange");
|
|
852
852
|
}
|
|
853
853
|
const variable = YArrayItemType.instantiate({
|
|
@@ -866,7 +866,7 @@ class NamespaceImpl {
|
|
|
866
866
|
dataType: node_opcua_variant_1.DataType.ExtensionObject,
|
|
867
867
|
value: new node_opcua_types_1.Range(options.engineeringUnitsRange)
|
|
868
868
|
}));
|
|
869
|
-
if (Object.
|
|
869
|
+
if (Object.hasOwn(options, "instrumentRange") && variable.instrumentRange) {
|
|
870
870
|
variable.instrumentRange.setValueFromSource(new node_opcua_variant_1.Variant({
|
|
871
871
|
dataType: node_opcua_variant_1.DataType.ExtensionObject,
|
|
872
872
|
value: new node_opcua_types_1.Range(options.instrumentRange)
|
|
@@ -902,7 +902,7 @@ class NamespaceImpl {
|
|
|
902
902
|
addMethod(parentObject, options) {
|
|
903
903
|
const addressSpace = this.addressSpace;
|
|
904
904
|
(0, node_opcua_assert_1.assert)(parentObject !== null && typeof parentObject === "object" && parentObject instanceof base_node_impl_1.BaseNodeImpl, "expecting a valid parent object");
|
|
905
|
-
(0, node_opcua_assert_1.assert)(Object.
|
|
905
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(options, "browseName"));
|
|
906
906
|
options.componentOf = parentObject;
|
|
907
907
|
const method = this._addMethod(options);
|
|
908
908
|
const propertyTypeId = addressSpace._coerce_VariableTypeIds("PropertyType");
|
|
@@ -1028,18 +1028,17 @@ class NamespaceImpl {
|
|
|
1028
1028
|
(0, node_opcua_assert_1.assert)(typeof options.browseName === "string");
|
|
1029
1029
|
(0, node_opcua_assert_1.assert)(Array.isArray(options.enumeration));
|
|
1030
1030
|
const addressSpace = this.addressSpace;
|
|
1031
|
-
let definition;
|
|
1032
1031
|
const enumerationType = addressSpace.findDataType("Enumeration");
|
|
1033
|
-
(0, node_opcua_assert_1.assert)(enumerationType.nodeId instanceof
|
|
1032
|
+
(0, node_opcua_assert_1.assert)(enumerationType.nodeId instanceof node_opcua_nodeid_1.NodeId);
|
|
1034
1033
|
(0, node_opcua_assert_1.assert)(enumerationType instanceof ua_data_type_impl_1.UADataTypeImpl);
|
|
1035
1034
|
const references = [{ referenceType: "HasSubtype", isForward: false, nodeId: enumerationType.nodeId }];
|
|
1036
1035
|
const opts = {
|
|
1037
1036
|
browseName: options.browseName,
|
|
1038
|
-
definition,
|
|
1037
|
+
definition: undefined,
|
|
1039
1038
|
description: (0, node_opcua_data_model_1.coerceLocalizedText)(options.description) || null,
|
|
1040
1039
|
displayName: options.displayName || null,
|
|
1041
1040
|
isAbstract: false,
|
|
1042
|
-
nodeClass:
|
|
1041
|
+
nodeClass: node_opcua_data_model_1.NodeClass.DataType,
|
|
1043
1042
|
references
|
|
1044
1043
|
};
|
|
1045
1044
|
const enumType = this.internalCreateNode(opts); // as UAEnumeration;
|
|
@@ -1047,7 +1046,7 @@ class NamespaceImpl {
|
|
|
1047
1046
|
if (typeof options.enumeration[0] === "string") {
|
|
1048
1047
|
const enumeration = options.enumeration;
|
|
1049
1048
|
// enumeration is a array of string
|
|
1050
|
-
definition = enumeration.map((str,
|
|
1049
|
+
const definition = enumeration.map((str, _index) => (0, node_opcua_data_model_1.coerceLocalizedText)(str));
|
|
1051
1050
|
const value = new node_opcua_variant_1.Variant({
|
|
1052
1051
|
arrayType: node_opcua_variant_1.VariantArrayType.Array,
|
|
1053
1052
|
dataType: node_opcua_variant_1.DataType.LocalizedText,
|
|
@@ -1083,7 +1082,7 @@ class NamespaceImpl {
|
|
|
1083
1082
|
else {
|
|
1084
1083
|
const enumeration = options.enumeration;
|
|
1085
1084
|
// construct the definition object
|
|
1086
|
-
definition = enumeration.map((enumItem) => {
|
|
1085
|
+
const definition = enumeration.map((enumItem) => {
|
|
1087
1086
|
return new node_opcua_types_1.EnumValueType({
|
|
1088
1087
|
description: (0, node_opcua_data_model_1.coerceLocalizedText)(enumItem.description),
|
|
1089
1088
|
displayName: (0, node_opcua_data_model_1.coerceLocalizedText)(enumItem.displayName),
|
|
@@ -1106,7 +1105,7 @@ class NamespaceImpl {
|
|
|
1106
1105
|
});
|
|
1107
1106
|
(0, node_opcua_assert_1.assert)(enumValues.browseName.toString() === "EnumValues");
|
|
1108
1107
|
enumType.$fullDefinition = new node_opcua_types_1.EnumDefinition({
|
|
1109
|
-
fields: enumeration.map((x,
|
|
1108
|
+
fields: enumeration.map((x, _index) => new node_opcua_types_1.EnumField({
|
|
1110
1109
|
name: x.displayName.toString(),
|
|
1111
1110
|
description: x.description || "",
|
|
1112
1111
|
value: (0, node_opcua_basic_types_1.coerceInt64)(x.value)
|
|
@@ -1147,12 +1146,12 @@ class NamespaceImpl {
|
|
|
1147
1146
|
// State and Transition
|
|
1148
1147
|
// -------------------------------------------------------------------------
|
|
1149
1148
|
/**
|
|
1150
|
-
|
|
1149
|
+
*/
|
|
1151
1150
|
addState(component, stateName, stateNumber, isInitialState) {
|
|
1152
1151
|
const addressSpace = this.addressSpace;
|
|
1153
1152
|
isInitialState = !!isInitialState;
|
|
1154
1153
|
const _component = component;
|
|
1155
|
-
(0, node_opcua_assert_1.assert)(_component.nodeClass ===
|
|
1154
|
+
(0, node_opcua_assert_1.assert)(_component.nodeClass === node_opcua_data_model_1.NodeClass.Object || _component.nodeClass === node_opcua_data_model_1.NodeClass.ObjectType);
|
|
1156
1155
|
const initialStateType = addressSpace.findObjectType("InitialStateType");
|
|
1157
1156
|
const stateType = addressSpace.findObjectType("StateType");
|
|
1158
1157
|
let state;
|
|
@@ -1180,27 +1179,27 @@ class NamespaceImpl {
|
|
|
1180
1179
|
addTransition(component, fromState, toState, transitionNumber, browseName) {
|
|
1181
1180
|
const addressSpace = this.addressSpace;
|
|
1182
1181
|
const _component = component;
|
|
1183
|
-
(0, node_opcua_assert_1.assert)(_component.nodeClass ===
|
|
1182
|
+
(0, node_opcua_assert_1.assert)(_component.nodeClass === node_opcua_data_model_1.NodeClass.Object || _component.nodeClass === node_opcua_data_model_1.NodeClass.ObjectType);
|
|
1184
1183
|
(0, node_opcua_assert_1.assert)(typeof fromState === "string");
|
|
1185
1184
|
(0, node_opcua_assert_1.assert)(typeof toState === "string");
|
|
1186
|
-
(0, node_opcua_assert_1.assert)(isFinite(transitionNumber));
|
|
1185
|
+
(0, node_opcua_assert_1.assert)(Number.isFinite(transitionNumber));
|
|
1187
1186
|
const fromStateNode = _component.getComponentByName(fromState);
|
|
1188
1187
|
// c8 ignore next
|
|
1189
1188
|
if (!fromStateNode) {
|
|
1190
|
-
throw new Error(
|
|
1189
|
+
throw new Error(`Cannot find state with name ${fromState}`);
|
|
1191
1190
|
}
|
|
1192
|
-
(0, node_opcua_assert_1.assert)(fromStateNode.browseName.name
|
|
1191
|
+
(0, node_opcua_assert_1.assert)(fromStateNode.browseName.name?.toString() === fromState);
|
|
1193
1192
|
const toStateNode = _component.getComponentByName(toState);
|
|
1194
1193
|
// c8 ignore next
|
|
1195
1194
|
if (!toStateNode) {
|
|
1196
|
-
throw new Error(
|
|
1195
|
+
throw new Error(`Cannot find state with name ${toState}`);
|
|
1197
1196
|
}
|
|
1198
|
-
(0, node_opcua_assert_1.assert)(toStateNode.browseName.name
|
|
1197
|
+
(0, node_opcua_assert_1.assert)(toStateNode.browseName.name?.toString() === toState);
|
|
1199
1198
|
const transitionType = addressSpace.findObjectType("TransitionType");
|
|
1200
1199
|
if (!transitionType) {
|
|
1201
1200
|
throw new Error("Cannot find TransitionType");
|
|
1202
1201
|
}
|
|
1203
|
-
browseName = browseName || fromState
|
|
1202
|
+
browseName = browseName || `${fromState}To${toState}`; // "Transition";
|
|
1204
1203
|
const transition = transitionType.instantiate({
|
|
1205
1204
|
browseName,
|
|
1206
1205
|
componentOf: _component
|
|
@@ -1291,7 +1290,7 @@ class NamespaceImpl {
|
|
|
1291
1290
|
}
|
|
1292
1291
|
_register(node) {
|
|
1293
1292
|
(0, node_opcua_assert_1.assert)(node instanceof base_node_impl_1.BaseNodeImpl, "Expecting a instance of BaseNode in _register");
|
|
1294
|
-
(0, node_opcua_assert_1.assert)(node.nodeId instanceof
|
|
1293
|
+
(0, node_opcua_assert_1.assert)(node.nodeId instanceof node_opcua_nodeid_1.NodeId, "Expecting a NodeId");
|
|
1295
1294
|
// c8 ignore next
|
|
1296
1295
|
if (node.nodeId.namespace !== this.index) {
|
|
1297
1296
|
throw new Error("node must belong to this namespace : " +
|
|
@@ -1303,7 +1302,7 @@ class NamespaceImpl {
|
|
|
1303
1302
|
this.index);
|
|
1304
1303
|
}
|
|
1305
1304
|
(0, node_opcua_assert_1.assert)(node.nodeId.namespace === this.index, "node must belongs to this namespace");
|
|
1306
|
-
(0, node_opcua_assert_1.assert)(Object.
|
|
1305
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(node, "browseName"), "Node must have a browseName");
|
|
1307
1306
|
const hashKey = _makeHashKey(node.nodeId);
|
|
1308
1307
|
// c8 ignore next
|
|
1309
1308
|
if (this._nodeid_index.has(hashKey)) {
|
|
@@ -1327,22 +1326,22 @@ class NamespaceImpl {
|
|
|
1327
1326
|
}
|
|
1328
1327
|
this._nodeid_index.set(hashKey, node);
|
|
1329
1328
|
switch (node.nodeClass) {
|
|
1330
|
-
case
|
|
1329
|
+
case node_opcua_data_model_1.NodeClass.ObjectType:
|
|
1331
1330
|
this._registerObjectType(node);
|
|
1332
1331
|
break;
|
|
1333
|
-
case
|
|
1332
|
+
case node_opcua_data_model_1.NodeClass.VariableType:
|
|
1334
1333
|
this._registerVariableType(node);
|
|
1335
1334
|
break;
|
|
1336
|
-
case
|
|
1335
|
+
case node_opcua_data_model_1.NodeClass.ReferenceType:
|
|
1337
1336
|
this._registerReferenceType(node);
|
|
1338
1337
|
break;
|
|
1339
|
-
case
|
|
1338
|
+
case node_opcua_data_model_1.NodeClass.DataType:
|
|
1340
1339
|
this._registerDataType(node);
|
|
1341
1340
|
break;
|
|
1342
|
-
case
|
|
1343
|
-
case
|
|
1344
|
-
case
|
|
1345
|
-
case
|
|
1341
|
+
case node_opcua_data_model_1.NodeClass.Object:
|
|
1342
|
+
case node_opcua_data_model_1.NodeClass.Variable:
|
|
1343
|
+
case node_opcua_data_model_1.NodeClass.Method:
|
|
1344
|
+
case node_opcua_data_model_1.NodeClass.View:
|
|
1346
1345
|
break;
|
|
1347
1346
|
default:
|
|
1348
1347
|
// tslint:disable-next-line:no-console
|
|
@@ -1360,7 +1359,7 @@ class NamespaceImpl {
|
|
|
1360
1359
|
// xx assert(options.browseName instanceof QualifiedName
|
|
1361
1360
|
// ? (options.browseName.namespaceIndex === this.index): true,
|
|
1362
1361
|
// "Expecting browseName to have the same namespaceIndex as the namespace");
|
|
1363
|
-
options.description = (0, node_opcua_data_model_1.coerceLocalizedText)(options.description);
|
|
1362
|
+
options.description = (0, node_opcua_data_model_1.coerceLocalizedText)(options.description) || "";
|
|
1364
1363
|
// browseName adjustment
|
|
1365
1364
|
if (typeof options.browseName === "string") {
|
|
1366
1365
|
const match = options.browseName.match(regExpNamespaceDotBrowseName);
|
|
@@ -1381,31 +1380,32 @@ class NamespaceImpl {
|
|
|
1381
1380
|
" please refer to the NodeOPCUA documentation");
|
|
1382
1381
|
}
|
|
1383
1382
|
}
|
|
1384
|
-
options.browseName = new
|
|
1383
|
+
options.browseName = new node_opcua_data_model_1.QualifiedName({ name: options.browseName, namespaceIndex: this.index });
|
|
1385
1384
|
}
|
|
1386
|
-
else if (!(options.browseName instanceof
|
|
1387
|
-
options.browseName = new
|
|
1385
|
+
else if (!(options.browseName instanceof node_opcua_data_model_1.QualifiedName)) {
|
|
1386
|
+
options.browseName = new node_opcua_data_model_1.QualifiedName(options.browseName);
|
|
1388
1387
|
}
|
|
1389
|
-
(0, node_opcua_assert_1.assert)(options.browseName instanceof
|
|
1388
|
+
(0, node_opcua_assert_1.assert)(options.browseName instanceof node_opcua_data_model_1.QualifiedName, "Expecting options.browseName to be instanceof QualifiedName ");
|
|
1390
1389
|
// ------------- set display name
|
|
1391
1390
|
if (!options.displayName) {
|
|
1392
1391
|
(0, node_opcua_assert_1.assert)(typeof options.browseName.name === "string");
|
|
1393
|
-
options.displayName = (0, node_opcua_data_model_1.coerceLocalizedText)(options.browseName.name);
|
|
1392
|
+
options.displayName = (0, node_opcua_data_model_1.coerceLocalizedText)(options.browseName.name || "");
|
|
1394
1393
|
}
|
|
1395
|
-
if (!options.nodeClass || options.nodeClass
|
|
1394
|
+
if (!options.nodeClass || options.nodeClass === undefined) {
|
|
1396
1395
|
throw new Error("nodeclass must be specified");
|
|
1397
1396
|
}
|
|
1398
1397
|
// --- nodeId adjustment
|
|
1399
1398
|
options.nodeId = this.constructNodeId(options);
|
|
1400
1399
|
(0, node_opcua_debug_1.dumpIf)(!options.nodeId, options); // missing node Id
|
|
1401
|
-
(0, node_opcua_assert_1.assert)(options.nodeId instanceof
|
|
1400
|
+
(0, node_opcua_assert_1.assert)(options.nodeId instanceof node_opcua_nodeid_1.NodeId);
|
|
1402
1401
|
// assert(options.browseName.namespaceIndex === this.index,"Expecting browseName to have
|
|
1403
1402
|
// the same namespaceIndex as the namespace");
|
|
1404
|
-
const Constructor = _constructors_map[
|
|
1403
|
+
const Constructor = _constructors_map[node_opcua_data_model_1.NodeClass[options.nodeClass]];
|
|
1405
1404
|
if (!Constructor) {
|
|
1406
|
-
throw new Error(
|
|
1405
|
+
throw new Error(` missing constructor for NodeClass ${node_opcua_data_model_1.NodeClass[options.nodeClass]}`);
|
|
1407
1406
|
}
|
|
1408
1407
|
options.addressSpace = this.addressSpace;
|
|
1408
|
+
// biome-ignore lint/suspicious/noExplicitAny: to fix later
|
|
1409
1409
|
const node = new Constructor(options);
|
|
1410
1410
|
this._register(node);
|
|
1411
1411
|
// object shall now be registered
|
|
@@ -1420,19 +1420,19 @@ class NamespaceImpl {
|
|
|
1420
1420
|
const hashKey = _makeHashKey(node.nodeId);
|
|
1421
1421
|
// c8 ignore next
|
|
1422
1422
|
if (!this._nodeid_index.has(hashKey)) {
|
|
1423
|
-
throw new Error(
|
|
1423
|
+
throw new Error(`deleteNode : nodeId ${node.nodeId.displayText()} is not registered ${node.nodeId.toString()}`);
|
|
1424
1424
|
}
|
|
1425
1425
|
switch (node.nodeClass) {
|
|
1426
|
-
case
|
|
1426
|
+
case node_opcua_data_model_1.NodeClass.ObjectType:
|
|
1427
1427
|
this._unregisterObjectType(node);
|
|
1428
1428
|
break;
|
|
1429
|
-
case
|
|
1429
|
+
case node_opcua_data_model_1.NodeClass.VariableType:
|
|
1430
1430
|
this._unregisterVariableType(node);
|
|
1431
1431
|
break;
|
|
1432
|
-
case
|
|
1433
|
-
case
|
|
1434
|
-
case
|
|
1435
|
-
case
|
|
1432
|
+
case node_opcua_data_model_1.NodeClass.Object:
|
|
1433
|
+
case node_opcua_data_model_1.NodeClass.Variable:
|
|
1434
|
+
case node_opcua_data_model_1.NodeClass.Method:
|
|
1435
|
+
case node_opcua_data_model_1.NodeClass.View:
|
|
1436
1436
|
break;
|
|
1437
1437
|
default:
|
|
1438
1438
|
// tslint:disable:no-console
|
|
@@ -1447,19 +1447,19 @@ class NamespaceImpl {
|
|
|
1447
1447
|
_addObjectOrVariableType(options1, topMostBaseType, nodeClass) {
|
|
1448
1448
|
const addressSpace = this.addressSpace;
|
|
1449
1449
|
(0, node_opcua_assert_1.assert)(typeof topMostBaseType === "string");
|
|
1450
|
-
(0, node_opcua_assert_1.assert)(nodeClass ===
|
|
1450
|
+
(0, node_opcua_assert_1.assert)(nodeClass === node_opcua_data_model_1.NodeClass.ObjectType || nodeClass === node_opcua_data_model_1.NodeClass.VariableType);
|
|
1451
1451
|
const options = options1;
|
|
1452
1452
|
(0, node_opcua_assert_1.assert)(!options.nodeClass);
|
|
1453
1453
|
(0, node_opcua_assert_1.assert)(options.browseName);
|
|
1454
1454
|
(0, node_opcua_assert_1.assert)(typeof options.browseName === "string");
|
|
1455
|
-
if (Object.
|
|
1455
|
+
if (Object.hasOwn(options, "references")) {
|
|
1456
1456
|
throw new Error("options.references should not be provided, use options.subtypeOf instead");
|
|
1457
1457
|
}
|
|
1458
1458
|
const references = [];
|
|
1459
1459
|
function process_subtypeOf_options(options2, references1) {
|
|
1460
1460
|
// check common misspelling mistake
|
|
1461
1461
|
(0, node_opcua_assert_1.assert)(!options2.subTypeOf, "misspell error : it should be 'subtypeOf' instead");
|
|
1462
|
-
if (Object.
|
|
1462
|
+
if (Object.hasOwn(options2, "hasTypeDefinition")) {
|
|
1463
1463
|
throw new Error("hasTypeDefinition option is invalid. Do you mean typeDefinition instead ?");
|
|
1464
1464
|
}
|
|
1465
1465
|
(0, node_opcua_assert_1.assert)(!options2.typeDefinition, " do you mean subtypeOf ?");
|
|
@@ -1506,38 +1506,38 @@ class NamespaceImpl {
|
|
|
1506
1506
|
// }
|
|
1507
1507
|
_registerObjectType(node) {
|
|
1508
1508
|
(0, node_opcua_assert_1.assert)(this.index === node.nodeId.namespace);
|
|
1509
|
-
const key = node.browseName.name;
|
|
1509
|
+
const key = node.browseName.name || "";
|
|
1510
1510
|
if (this._objectTypeMap.has(key)) {
|
|
1511
|
-
throw new Error(
|
|
1511
|
+
throw new Error(` UAObjectType already declared ${node.browseName.toString()} ${node.nodeId.toString()}`);
|
|
1512
1512
|
}
|
|
1513
1513
|
this._objectTypeMap.set(key, node);
|
|
1514
1514
|
}
|
|
1515
1515
|
_registerVariableType(node) {
|
|
1516
1516
|
(0, node_opcua_assert_1.assert)(this.index === node.nodeId.namespace);
|
|
1517
|
-
const key = node.browseName.name;
|
|
1517
|
+
const key = node.browseName.name || "";
|
|
1518
1518
|
(0, node_opcua_assert_1.assert)(!this._variableTypeMap.has(key), " UAVariableType already declared");
|
|
1519
1519
|
this._variableTypeMap.set(key, node);
|
|
1520
1520
|
}
|
|
1521
1521
|
_registerReferenceType(node) {
|
|
1522
1522
|
(0, node_opcua_assert_1.assert)(this.index === node.nodeId.namespace);
|
|
1523
|
-
(0, node_opcua_assert_1.assert)(node.browseName instanceof
|
|
1524
|
-
const key = node.browseName.name;
|
|
1523
|
+
(0, node_opcua_assert_1.assert)(node.browseName instanceof node_opcua_data_model_1.QualifiedName);
|
|
1524
|
+
const key = node.browseName.name || "";
|
|
1525
1525
|
this._referenceTypeMap.set(key, node);
|
|
1526
|
-
this._referenceTypeMapInv.set(node.inverseName.text, node);
|
|
1526
|
+
this._referenceTypeMapInv.set(node.inverseName.text || "", node);
|
|
1527
1527
|
}
|
|
1528
1528
|
_registerDataType(node) {
|
|
1529
1529
|
(0, node_opcua_assert_1.assert)(this.index === node.nodeId.namespace);
|
|
1530
|
-
const key = node.browseName.name;
|
|
1531
|
-
(0, node_opcua_assert_1.assert)(node.browseName instanceof
|
|
1530
|
+
const key = node.browseName.name || "";
|
|
1531
|
+
(0, node_opcua_assert_1.assert)(node.browseName instanceof node_opcua_data_model_1.QualifiedName);
|
|
1532
1532
|
(0, node_opcua_assert_1.assert)(!this._dataTypeMap.has(key), " DataType already declared");
|
|
1533
1533
|
this._dataTypeMap.set(key, node);
|
|
1534
1534
|
}
|
|
1535
1535
|
_unregisterObjectType(node) {
|
|
1536
|
-
const key = node.browseName.name;
|
|
1536
|
+
const key = node.browseName.name || "";
|
|
1537
1537
|
this._objectTypeMap.delete(key);
|
|
1538
1538
|
}
|
|
1539
1539
|
_unregisterVariableType(node) {
|
|
1540
|
-
const key = node.browseName.name;
|
|
1540
|
+
const key = node.browseName.name || "";
|
|
1541
1541
|
this._variableTypeMap.delete(key);
|
|
1542
1542
|
}
|
|
1543
1543
|
/**
|
|
@@ -1550,33 +1550,33 @@ class NamespaceImpl {
|
|
|
1550
1550
|
throw new Error("cannot find BaseDataVariableType");
|
|
1551
1551
|
}
|
|
1552
1552
|
const baseDataVariableTypeId = baseDataVariableType.nodeId;
|
|
1553
|
-
(0, node_opcua_assert_1.assert)(Object.
|
|
1554
|
-
(0, node_opcua_assert_1.assert)(Object.
|
|
1553
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(options, "browseName"), "options.browseName must be provided");
|
|
1554
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(options, "dataType"), "options.dataType must be provided");
|
|
1555
1555
|
options.historizing = !!options.historizing;
|
|
1556
1556
|
// c8 ignore next
|
|
1557
|
-
if (Object.
|
|
1557
|
+
if (Object.hasOwn(options, "hasTypeDefinition")) {
|
|
1558
1558
|
throw new Error("hasTypeDefinition option is invalid. Do you mean typeDefinition instead ?");
|
|
1559
1559
|
}
|
|
1560
1560
|
// ------------------------------------------ TypeDefinition
|
|
1561
1561
|
let typeDefinition = options.typeDefinition || baseDataVariableTypeId;
|
|
1562
1562
|
if (typeDefinition instanceof base_node_impl_1.BaseNodeImpl) {
|
|
1563
1563
|
// c8 ignore next
|
|
1564
|
-
if (typeDefinition.nodeClass !==
|
|
1565
|
-
const message = `invalid typeDefinition expecting a VariableType got ${
|
|
1564
|
+
if (typeDefinition.nodeClass !== node_opcua_data_model_1.NodeClass.VariableType) {
|
|
1565
|
+
const message = `invalid typeDefinition expecting a VariableType got ${node_opcua_data_model_1.NodeClass[typeDefinition.nodeClass]}`;
|
|
1566
1566
|
errorLog(message);
|
|
1567
1567
|
throw new Error(message);
|
|
1568
1568
|
}
|
|
1569
1569
|
}
|
|
1570
1570
|
typeDefinition = addressSpace._coerce_VariableTypeIds(typeDefinition);
|
|
1571
|
-
(0, node_opcua_assert_1.assert)(typeDefinition instanceof
|
|
1571
|
+
(0, node_opcua_assert_1.assert)(typeDefinition instanceof node_opcua_nodeid_1.NodeId);
|
|
1572
1572
|
// ------------------------------------------ DataType
|
|
1573
|
-
options.dataType = addressSpace._coerce_DataType(options.dataType);
|
|
1573
|
+
options.dataType = addressSpace._coerce_DataType(options.dataType || node_opcua_variant_1.DataType.Null);
|
|
1574
1574
|
options.valueRank = (0, node_opcua_utils_1.isNullOrUndefined)(options.valueRank)
|
|
1575
1575
|
? options.arrayDimensions
|
|
1576
1576
|
? options.arrayDimensions.length
|
|
1577
1577
|
: -1
|
|
1578
1578
|
: options.valueRank;
|
|
1579
|
-
(0, node_opcua_assert_1.assert)(typeof options.valueRank === "number" && isFinite(options.valueRank));
|
|
1579
|
+
(0, node_opcua_assert_1.assert)(typeof options.valueRank === "number" && Number.isFinite(options.valueRank));
|
|
1580
1580
|
options.arrayDimensions = options.arrayDimensions || null;
|
|
1581
1581
|
(0, node_opcua_assert_1.assert)(options.arrayDimensions === null || Array.isArray(options.arrayDimensions));
|
|
1582
1582
|
// -----------------------------------------------------
|
|
@@ -1603,8 +1603,8 @@ class NamespaceImpl {
|
|
|
1603
1603
|
referenceType: "HasTypeDefinition"
|
|
1604
1604
|
}
|
|
1605
1605
|
]);
|
|
1606
|
-
(0, node_opcua_assert_1.assert)(!options.nodeClass || options.nodeClass ===
|
|
1607
|
-
options.nodeClass =
|
|
1606
|
+
(0, node_opcua_assert_1.assert)(!options.nodeClass || options.nodeClass === node_opcua_data_model_1.NodeClass.Variable);
|
|
1607
|
+
options.nodeClass = node_opcua_data_model_1.NodeClass.Variable;
|
|
1608
1608
|
options.references = references;
|
|
1609
1609
|
const variable = this.createNode(options);
|
|
1610
1610
|
return variable;
|
|
@@ -1625,7 +1625,7 @@ class NamespaceImpl {
|
|
|
1625
1625
|
displayName: options.displayName,
|
|
1626
1626
|
eventNotifier: +options.eventNotifier,
|
|
1627
1627
|
isAbstract: false,
|
|
1628
|
-
nodeClass:
|
|
1628
|
+
nodeClass: node_opcua_data_model_1.NodeClass.Method,
|
|
1629
1629
|
nodeId: options.nodeId,
|
|
1630
1630
|
references,
|
|
1631
1631
|
rolePermissions: options.rolePermissions
|
|
@@ -1661,7 +1661,7 @@ function _coerce_parent(addressSpace, value, coerceFunc) {
|
|
|
1661
1661
|
if (typeof value === "string") {
|
|
1662
1662
|
value = coerceFunc.call(addressSpace, value);
|
|
1663
1663
|
}
|
|
1664
|
-
if (value instanceof
|
|
1664
|
+
if (value instanceof node_opcua_nodeid_1.NodeId) {
|
|
1665
1665
|
value = addressSpace.findNode(value);
|
|
1666
1666
|
}
|
|
1667
1667
|
}
|
|
@@ -1699,7 +1699,7 @@ function _handle_hierarchy_parent(addressSpace, references, options) {
|
|
|
1699
1699
|
(0, node_opcua_assert_1.assert)(!options.componentOf);
|
|
1700
1700
|
(0, node_opcua_assert_1.assert)(!options.propertyOf);
|
|
1701
1701
|
(0, node_opcua_assert_1.assert)(!options.organizedBy);
|
|
1702
|
-
(0, node_opcua_assert_1.assert)(options.addInOf.nodeClass ===
|
|
1702
|
+
(0, node_opcua_assert_1.assert)(options.addInOf.nodeClass === node_opcua_data_model_1.NodeClass.Object || options.addInOf.nodeClass === node_opcua_data_model_1.NodeClass.ObjectType, "addInOf must be of nodeClass Object or ObjectType");
|
|
1703
1703
|
references.push({
|
|
1704
1704
|
isForward: false,
|
|
1705
1705
|
nodeId: options.addInOf.nodeId,
|
|
@@ -1741,7 +1741,7 @@ function _handle_hierarchy_parent(addressSpace, references, options) {
|
|
|
1741
1741
|
}
|
|
1742
1742
|
if (options.encodingOf) {
|
|
1743
1743
|
// parent must be a DataType
|
|
1744
|
-
(0, node_opcua_assert_1.assert)(options.encodingOf.nodeClass ===
|
|
1744
|
+
(0, node_opcua_assert_1.assert)(options.encodingOf.nodeClass === node_opcua_data_model_1.NodeClass.DataType, "encodingOf must be toward a DataType");
|
|
1745
1745
|
references.push({
|
|
1746
1746
|
isForward: false,
|
|
1747
1747
|
nodeId: options.encodingOf.nodeId,
|
|
@@ -1750,10 +1750,10 @@ function _handle_hierarchy_parent(addressSpace, references, options) {
|
|
|
1750
1750
|
}
|
|
1751
1751
|
}
|
|
1752
1752
|
function _copy_reference(reference) {
|
|
1753
|
-
(0, node_opcua_assert_1.assert)(Object.
|
|
1754
|
-
(0, node_opcua_assert_1.assert)(Object.
|
|
1755
|
-
(0, node_opcua_assert_1.assert)(Object.
|
|
1756
|
-
(0, node_opcua_assert_1.assert)(reference.nodeId instanceof
|
|
1753
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(reference, "referenceType"));
|
|
1754
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(reference, "isForward"));
|
|
1755
|
+
(0, node_opcua_assert_1.assert)(Object.hasOwn(reference, "nodeId"));
|
|
1756
|
+
(0, node_opcua_assert_1.assert)(reference.nodeId instanceof node_opcua_nodeid_1.NodeId);
|
|
1757
1757
|
return {
|
|
1758
1758
|
isForward: reference.isForward,
|
|
1759
1759
|
nodeId: reference.nodeId,
|
|
@@ -1771,16 +1771,16 @@ function isNonEmptyQualifiedName(browseName) {
|
|
|
1771
1771
|
if (typeof browseName === "string") {
|
|
1772
1772
|
return browseName.length >= 0;
|
|
1773
1773
|
}
|
|
1774
|
-
if (!(browseName instanceof
|
|
1775
|
-
browseName = new
|
|
1774
|
+
if (!(browseName instanceof node_opcua_data_model_1.QualifiedName)) {
|
|
1775
|
+
browseName = new node_opcua_data_model_1.QualifiedName(browseName);
|
|
1776
1776
|
}
|
|
1777
|
-
(0, node_opcua_assert_1.assert)(browseName instanceof
|
|
1778
|
-
return browseName.name
|
|
1777
|
+
(0, node_opcua_assert_1.assert)(browseName instanceof node_opcua_data_model_1.QualifiedName);
|
|
1778
|
+
return (browseName.name?.length || 0) > 0;
|
|
1779
1779
|
}
|
|
1780
1780
|
function _create_node_version_if_needed(node, options) {
|
|
1781
1781
|
(0, node_opcua_assert_1.assert)(options);
|
|
1782
|
-
if (typeof options.nodeVersion
|
|
1783
|
-
(0, node_opcua_assert_1.assert)(node.nodeClass ===
|
|
1782
|
+
if (typeof options.nodeVersion === "string") {
|
|
1783
|
+
(0, node_opcua_assert_1.assert)(node.nodeClass === node_opcua_data_model_1.NodeClass.Variable || node.nodeClass === node_opcua_data_model_1.NodeClass.Object);
|
|
1784
1784
|
// c8 ignore next
|
|
1785
1785
|
if (node.getNodeVersion()) {
|
|
1786
1786
|
return; // already exists
|