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.
Files changed (40) hide show
  1. package/dist/source/loader/namespace_post_step.js +25 -17
  2. package/dist/source/loader/namespace_post_step.js.map +1 -1
  3. package/dist/source/session_context.d.ts +3 -1
  4. package/dist/source/session_context.js +26 -1
  5. package/dist/source/session_context.js.map +1 -1
  6. package/dist/src/address_space.d.ts +14 -11
  7. package/dist/src/address_space.js +55 -54
  8. package/dist/src/address_space.js.map +1 -1
  9. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.d.ts +8 -8
  10. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +19 -19
  11. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
  12. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +11 -13
  13. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +21 -13
  14. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
  15. package/dist/src/alarms_and_conditions/ua_condition_impl.js +1 -1
  16. package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
  17. package/dist/src/base_node_impl.d.ts +1 -0
  18. package/dist/src/base_node_impl.js +26 -15
  19. package/dist/src/base_node_impl.js.map +1 -1
  20. package/dist/src/namespace_impl.d.ts +40 -31
  21. package/dist/src/namespace_impl.js +174 -161
  22. package/dist/src/namespace_impl.js.map +1 -1
  23. package/dist/src/namespace_private.d.ts +12 -4
  24. package/dist/src/namespace_private.js +1 -4
  25. package/dist/src/namespace_private.js.map +1 -1
  26. package/dist/src/ua_method_impl.d.ts +11 -9
  27. package/dist/src/ua_method_impl.js +24 -27
  28. package/dist/src/ua_method_impl.js.map +1 -1
  29. package/dist/tsconfig_base.tsbuildinfo +1 -1
  30. package/package.json +35 -37
  31. package/source/loader/namespace_post_step.ts +28 -19
  32. package/source/session_context.ts +30 -1
  33. package/src/address_space.ts +113 -109
  34. package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +26 -28
  35. package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +33 -27
  36. package/src/alarms_and_conditions/ua_condition_impl.ts +1 -1
  37. package/src/base_node_impl.ts +27 -14
  38. package/src/namespace_impl.ts +232 -201
  39. package/src/namespace_private.ts +15 -9
  40. package/src/ua_method_impl.ts +43 -50
@@ -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
- // state machine
41
- const ua_two_state_variable_1 = require("./state_machine/ua_two_state_variable");
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
- const ua_object_impl_1 = require("./ua_object_impl");
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 ua_variable_type_impl_1 = require("./ua_variable_type_impl");
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", node_opcua_data_model_3.BrowseDirection.Inverse);
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.removeReference({
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", node_opcua_data_model_3.BrowseDirection.Forward);
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.removeReference({
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", node_opcua_data_model_3.BrowseDirection.Inverse);
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("NamespaceImpl constructor: namespaceUri must exists and be a string : got " + options.namespaceUri);
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") {
@@ -172,6 +183,19 @@ class NamespaceImpl {
172
183
  getDefaultNamespace() {
173
184
  return this.index === 0 ? this : this.addressSpace.getDefaultNamespace();
174
185
  }
186
+ toJSON() {
187
+ return {
188
+ index: this.index,
189
+ namespaceUri: this.namespaceUri,
190
+ version: this.version
191
+ };
192
+ }
193
+ toString() {
194
+ return `Namespace({ index: ${this.index}, namespaceUri: "${this.namespaceUri}" })`;
195
+ }
196
+ [Symbol.for("nodejs.util.inspect.custom")]() {
197
+ return this.toString();
198
+ }
175
199
  dispose() {
176
200
  for (const node of this.nodeIterator()) {
177
201
  node.dispose();
@@ -223,7 +247,7 @@ class NamespaceImpl {
223
247
  findNode(nodeId) {
224
248
  if (typeof nodeId === "string") {
225
249
  if (nodeId.match(regExp1)) {
226
- nodeId = "ns=" + this.index + ";" + nodeId;
250
+ nodeId = `ns=${this.index};${nodeId}`;
227
251
  }
228
252
  }
229
253
  nodeId = (0, node_opcua_nodeid_1.resolveNodeId)(nodeId);
@@ -270,7 +294,7 @@ class NamespaceImpl {
270
294
  findReferenceTypeFromInverseName(inverseName) {
271
295
  (0, node_opcua_assert_1.assert)(typeof inverseName === "string");
272
296
  const node = this._referenceTypeMapInv.get(inverseName);
273
- (0, node_opcua_assert_1.assert)(!node || (node.nodeClass === node_opcua_data_model_4.NodeClass.ReferenceType && node.inverseName.text === inverseName));
297
+ (0, node_opcua_assert_1.assert)(!node || (node.nodeClass === node_opcua_data_model_1.NodeClass.ReferenceType && node.inverseName.text === inverseName));
274
298
  return node ? node : null;
275
299
  }
276
300
  /**
@@ -281,7 +305,7 @@ class NamespaceImpl {
281
305
  */
282
306
  addAlias(alias_name, nodeId) {
283
307
  (0, node_opcua_assert_1.assert)(typeof alias_name === "string");
284
- (0, node_opcua_assert_1.assert)(nodeId instanceof node_opcua_nodeid_2.NodeId);
308
+ (0, node_opcua_assert_1.assert)(nodeId instanceof node_opcua_nodeid_1.NodeId);
285
309
  (0, node_opcua_assert_1.assert)(nodeId.namespace === this.index);
286
310
  this._aliases.set(alias_name, nodeId);
287
311
  }
@@ -303,10 +327,10 @@ class NamespaceImpl {
303
327
  *
304
328
  */
305
329
  addObjectType(options) {
306
- (0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(options, "dataType"), "an objectType should not have a dataType");
307
- (0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(options, "valueRank"), "an objectType should not have a valueRank");
308
- (0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(options, "arrayDimensions"), "an objectType should not have a arrayDimensions");
309
- return this._addObjectOrVariableType(options, "BaseObjectType", node_opcua_data_model_4.NodeClass.ObjectType);
330
+ (0, node_opcua_assert_1.assert)(!Object.hasOwn(options, "dataType"), "an objectType should not have a dataType");
331
+ (0, node_opcua_assert_1.assert)(!Object.hasOwn(options, "valueRank"), "an objectType should not have a valueRank");
332
+ (0, node_opcua_assert_1.assert)(!Object.hasOwn(options, "arrayDimensions"), "an objectType should not have a arrayDimensions");
333
+ return this._addObjectOrVariableType(options, "BaseObjectType", node_opcua_data_model_1.NodeClass.ObjectType);
310
334
  }
311
335
  /**
312
336
  * add a new Variable type to the address space
@@ -324,17 +348,17 @@ class NamespaceImpl {
324
348
  *
325
349
  */
326
350
  addVariableType(options) {
327
- (0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(options, "arrayDimension"), "Do you mean ArrayDimensions ?");
351
+ (0, node_opcua_assert_1.assert)(!Object.hasOwn(options, "arrayDimension"), "Do you mean ArrayDimensions ?");
328
352
  // dataType
329
353
  options.dataType = options.dataType || "Int32";
330
354
  options.dataType = this.addressSpace._coerce_DataType(options.dataType);
331
355
  // valueRank/ arrayDimensions
332
356
  (0, node_opcua_variant_1.verifyRankAndDimensions)(options);
333
357
  // arrayDimensions
334
- const variableType = this._addObjectOrVariableType(options, "BaseVariableType", node_opcua_data_model_4.NodeClass.VariableType);
358
+ const variableType = this._addObjectOrVariableType(options, "BaseVariableType", node_opcua_data_model_1.NodeClass.VariableType);
335
359
  variableType.dataType = options.dataType;
336
360
  variableType.valueRank = options.valueRank || 0;
337
- variableType.arrayDimensions = options.arrayDimensions;
361
+ variableType.arrayDimensions = options.arrayDimensions || [];
338
362
  return variableType;
339
363
  }
340
364
  /**
@@ -342,7 +366,7 @@ class NamespaceImpl {
342
366
  */
343
367
  addVariable(options) {
344
368
  (0, node_opcua_assert_1.assert)(arguments.length === 1, "Invalid arguments IAddressSpace#addVariable now takes only one argument.");
345
- if (Object.prototype.hasOwnProperty.call(options, "propertyOf") && options.propertyOf) {
369
+ if (Object.hasOwn(options, "propertyOf") && options.propertyOf) {
346
370
  (0, node_opcua_assert_1.assert)(!options.typeDefinition || options.typeDefinition === "PropertyType");
347
371
  options.typeDefinition = options.typeDefinition || "PropertyType";
348
372
  }
@@ -352,41 +376,39 @@ class NamespaceImpl {
352
376
  return this._addVariable(options);
353
377
  }
354
378
  addView(options) {
355
- (0, node_opcua_assert_1.assert)(arguments.length === 1, "Namespace#addView expecting a single argument");
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"));
379
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(options, "browseName"));
380
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(options, "organizedBy"));
359
381
  const browseName = options.browseName;
360
382
  (0, node_opcua_assert_1.assert)(typeof browseName === "string");
361
383
  const addressSpace = this.addressSpace;
362
- const baseDataVariableTypeId = addressSpace.findVariableType("BaseDataVariableType").nodeId;
384
+ const baseDataVariableTypeId = addressSpace.findVariableType("BaseDataVariableType")?.nodeId;
363
385
  // ------------------------------------------ TypeDefinition
364
- const typeDefinition = options.typeDefinition || baseDataVariableTypeId;
386
+ const _typeDefinition = options.typeDefinition || baseDataVariableTypeId;
365
387
  options.references = options.references || [];
366
388
  options.references.push({
367
389
  isForward: true,
368
- nodeId: typeDefinition,
390
+ nodeId: toNodeId(_typeDefinition) || node_opcua_nodeid_1.NodeId.nullNodeId,
369
391
  referenceType: "HasTypeDefinition"
370
392
  });
371
393
  const createOptions = options;
372
394
  (0, node_opcua_assert_1.assert)(!createOptions.nodeClass);
373
- createOptions.nodeClass = node_opcua_data_model_4.NodeClass.View;
395
+ createOptions.nodeClass = node_opcua_data_model_1.NodeClass.View;
374
396
  const view = this.createNode(createOptions);
375
- (0, node_opcua_assert_1.assert)(view.nodeId instanceof node_opcua_nodeid_2.NodeId);
376
- (0, node_opcua_assert_1.assert)(view.nodeClass === node_opcua_data_model_4.NodeClass.View);
397
+ (0, node_opcua_assert_1.assert)(view.nodeId instanceof node_opcua_nodeid_1.NodeId);
398
+ (0, node_opcua_assert_1.assert)(view.nodeClass === node_opcua_data_model_1.NodeClass.View);
377
399
  return view;
378
400
  }
379
401
  addObject(options1) {
380
402
  const options = options1;
381
- (0, node_opcua_assert_1.assert)(!options.nodeClass || options.nodeClass === node_opcua_data_model_4.NodeClass.Object);
382
- options.nodeClass = node_opcua_data_model_4.NodeClass.Object;
403
+ (0, node_opcua_assert_1.assert)(!options.nodeClass || options.nodeClass === node_opcua_data_model_1.NodeClass.Object);
404
+ options.nodeClass = node_opcua_data_model_1.NodeClass.Object;
383
405
  const typeDefinition = options.typeDefinition || "BaseObjectType";
384
406
  options.references = options.references || [];
385
407
  options.references.push({ referenceType: "HasTypeDefinition", isForward: true, nodeId: typeDefinition });
386
408
  options.eventNotifier = +(options.eventNotifier || 0);
387
409
  const obj = this.createNode(options);
388
410
  (0, node_opcua_assert_1.assert)(obj instanceof ua_object_impl_1.UAObjectImpl);
389
- (0, node_opcua_assert_1.assert)(obj.nodeClass === node_opcua_data_model_4.NodeClass.Object);
411
+ (0, node_opcua_assert_1.assert)(obj.nodeClass === node_opcua_data_model_1.NodeClass.Object);
390
412
  return obj;
391
413
  }
392
414
  /**
@@ -407,7 +429,7 @@ class NamespaceImpl {
407
429
  (0, node_opcua_assert_1.assert)(!options.typeDefinition, "addFolder does not expect typeDefinition to be defined ");
408
430
  const typeDefinition = addressSpace._coerceTypeDefinition("FolderType");
409
431
  parentFolder = addressSpace._coerceFolder(parentFolder);
410
- options.nodeClass = node_opcua_data_model_4.NodeClass.Object;
432
+ options.nodeClass = node_opcua_data_model_1.NodeClass.Object;
411
433
  options.references = [
412
434
  { referenceType: "HasTypeDefinition", isForward: true, nodeId: typeDefinition },
413
435
  { referenceType: "Organizes", isForward: false, nodeId: parentFolder.nodeId }
@@ -425,11 +447,11 @@ class NamespaceImpl {
425
447
  addReferenceType(options) {
426
448
  const addressSpace = this.addressSpace;
427
449
  const options1 = options;
428
- options1.nodeClass = node_opcua_data_model_4.NodeClass.ReferenceType;
450
+ options1.nodeClass = node_opcua_data_model_1.NodeClass.ReferenceType;
429
451
  options1.references = options.references || [];
430
452
  options1.nodeId = options.nodeId;
431
453
  if (options.subtypeOf) {
432
- const subtypeOfNodeId = addressSpace._coerceType(options.subtypeOf, "References", node_opcua_data_model_4.NodeClass.ReferenceType);
454
+ const subtypeOfNodeId = addressSpace._coerceType(options.subtypeOf, "References", node_opcua_data_model_1.NodeClass.ReferenceType);
433
455
  (0, node_opcua_assert_1.assert)(subtypeOfNodeId);
434
456
  options1.references.push({
435
457
  isForward: false,
@@ -450,11 +472,11 @@ class NamespaceImpl {
450
472
 
451
473
  */
452
474
  createDataType(options) {
453
- (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "isAbstract"), "must provide isAbstract");
454
- (0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(options, "nodeClass"));
455
- (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "browseName"), "must provide a browseName");
475
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(options, "isAbstract"), "must provide isAbstract");
476
+ (0, node_opcua_assert_1.assert)(!Object.hasOwn(options, "nodeClass"));
477
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(options, "browseName"), "must provide a browseName");
456
478
  const options1 = options;
457
- options1.nodeClass = node_opcua_data_model_4.NodeClass.DataType;
479
+ options1.nodeClass = node_opcua_data_model_1.NodeClass.DataType;
458
480
  options1.references = options.references || [];
459
481
  if (options1.references.length === 0) {
460
482
  if (!options1.subtypeOf) {
@@ -492,7 +514,7 @@ class NamespaceImpl {
492
514
  addressSpace.modelChangeTransaction(() => {
493
515
  (0, node_opcua_assert_1.assert)(isNonEmptyQualifiedName(options.browseName));
494
516
  // xx assert(Object.prototype.hasOwnProperty.call(options,"browseName") && options.browseName.length > 0);
495
- (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "nodeClass"));
517
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(options, "nodeClass"));
496
518
  options.references = addressSpace.normalizeReferenceTypes(options.references);
497
519
  const references = _copy_references(options.references);
498
520
  _handle_hierarchy_parent(addressSpace, references, options);
@@ -500,7 +522,7 @@ class NamespaceImpl {
500
522
  (0, namespace_private_1.UANamespace_process_modelling_rule)(references, options.modellingRule);
501
523
  options.references = references;
502
524
  node = this.internalCreateNode(options);
503
- (0, node_opcua_assert_1.assert)(node.nodeId instanceof node_opcua_nodeid_2.NodeId);
525
+ (0, node_opcua_assert_1.assert)(node.nodeId instanceof node_opcua_nodeid_1.NodeId);
504
526
  node.propagate_back_references();
505
527
  node.install_extra_properties();
506
528
  _create_node_version_if_needed(node, options);
@@ -518,13 +540,13 @@ class NamespaceImpl {
518
540
  */
519
541
  deleteNode(nodeOrNodeId) {
520
542
  let node = null;
521
- let nodeId = new node_opcua_nodeid_2.NodeId();
522
- if (nodeOrNodeId instanceof node_opcua_nodeid_2.NodeId) {
543
+ let nodeId = new node_opcua_nodeid_1.NodeId();
544
+ if (nodeOrNodeId instanceof node_opcua_nodeid_1.NodeId) {
523
545
  nodeId = nodeOrNodeId;
524
546
  node = this.findNode(nodeId);
525
547
  // c8 ignore next
526
548
  if (!node) {
527
- throw new Error(" deleteNode : cannot find node with nodeId" + nodeId.toString());
549
+ throw new Error(` deleteNode : cannot find node with nodeId${nodeId.toString()}`);
528
550
  }
529
551
  }
530
552
  else if (nodeOrNodeId instanceof base_node_impl_1.BaseNodeImpl) {
@@ -542,7 +564,7 @@ class NamespaceImpl {
542
564
  throw new Error("this node doesn't belong to this namespace");
543
565
  }
544
566
  // notify parent that node is being removed
545
- const hierarchicalReferences = node.findReferencesEx("HierarchicalReferences", node_opcua_data_model_3.BrowseDirection.Inverse);
567
+ const hierarchicalReferences = node.findReferencesEx("HierarchicalReferences", node_opcua_data_model_1.BrowseDirection.Inverse);
546
568
  for (const ref of hierarchicalReferences) {
547
569
  (0, node_opcua_assert_1.assert)(!ref.isForward);
548
570
  const parent = addressSpace.findNode(ref.nodeId);
@@ -555,10 +577,10 @@ class NamespaceImpl {
555
577
  }
556
578
  // recursively delete all nodes below in the hierarchy of nodes
557
579
  // TODO : a better idea would be to extract any references of type "HasChild"
558
- const components = node.findReferencesEx("HasComponent", node_opcua_data_model_3.BrowseDirection.Forward);
559
- const properties = node.findReferencesEx("HasProperty", node_opcua_data_model_3.BrowseDirection.Forward);
580
+ const components = node.findReferencesEx("HasComponent", node_opcua_data_model_1.BrowseDirection.Forward);
581
+ const properties = node.findReferencesEx("HasProperty", node_opcua_data_model_1.BrowseDirection.Forward);
560
582
  // TODO: shall we delete nodes pointed by "Organizes" links here ?
561
- const subFolders = node.findReferencesEx("Organizes", node_opcua_data_model_3.BrowseDirection.Forward);
583
+ const subFolders = node.findReferencesEx("Organizes", node_opcua_data_model_1.BrowseDirection.Forward);
562
584
  for (const r of components) {
563
585
  deleteNodePointedByReference(r);
564
586
  }
@@ -584,10 +606,10 @@ class NamespaceImpl {
584
606
  referenceTypeIds: {}
585
607
  };
586
608
  for (const referenceType of this._referenceTypeMap.values()) {
587
- standardNodeIds.referenceTypeIds[referenceType.browseName.name] = referenceType.nodeId.toString();
609
+ standardNodeIds.referenceTypeIds[referenceType?.browseName?.name] = referenceType.nodeId.toString();
588
610
  }
589
611
  for (const objectType of this._objectTypeMap.values()) {
590
- standardNodeIds.objectTypeIds[objectType.browseName.name] = objectType.nodeId.toString();
612
+ standardNodeIds.objectTypeIds[objectType?.browseName?.name] = objectType.nodeId.toString();
591
613
  }
592
614
  return standardNodeIds;
593
615
  }
@@ -618,7 +640,7 @@ class NamespaceImpl {
618
640
  options.subtypeOf = options.subtypeOf || "BaseEventType";
619
641
  // are eventType always abstract ?? No => Condition can be instantiated!
620
642
  // but, by default is abstract is true
621
- options.isAbstract = Object.prototype.hasOwnProperty.call(options, "isAbstract") ? !!options.isAbstract : true;
643
+ options.isAbstract = Object.hasOwn(options, "isAbstract") ? !!options.isAbstract : true;
622
644
  return this.addObjectType(options);
623
645
  }
624
646
  // ---------------------------------------------------------------------------------------------------
@@ -676,7 +698,7 @@ class NamespaceImpl {
676
698
  */
677
699
  addAnalogDataItem(options) {
678
700
  const addressSpace = this.addressSpace;
679
- (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "engineeringUnitsRange"), "expecting engineeringUnitsRange");
701
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(options, "engineeringUnitsRange"), "expecting engineeringUnitsRange");
680
702
  const dataType = options.dataType || "Number";
681
703
  const analogItemType = addressSpace.findVariableType("AnalogItemType");
682
704
  if (!analogItemType) {
@@ -710,7 +732,7 @@ class NamespaceImpl {
710
732
  (0, node_opcua_assert_1.assert)(euRange.readValue().value.value instanceof node_opcua_types_1.Range);
711
733
  const handler = variable.handle_semantic_changed.bind(variable);
712
734
  euRange.on("value_changed", handler);
713
- if (Object.prototype.hasOwnProperty.call(options, "instrumentRange")) {
735
+ if (Object.hasOwn(options, "instrumentRange")) {
714
736
  const instrumentRange = this.addVariable({
715
737
  accessLevel: "CurrentRead | CurrentWrite",
716
738
  browseName: { name: "InstrumentRange", namespaceIndex: 0 },
@@ -727,7 +749,7 @@ class NamespaceImpl {
727
749
  instrumentRange.on("value_changed", handler);
728
750
  }
729
751
  variable.acceptValueOutOfRange = options.acceptValueOutOfRange;
730
- if (Object.prototype.hasOwnProperty.call(options, "engineeringUnits")) {
752
+ if (Object.hasOwn(options, "engineeringUnits")) {
731
753
  const engineeringUnits = new node_opcua_types_1.EUInformation(options.engineeringUnits);
732
754
  (0, node_opcua_assert_1.assert)(engineeringUnits instanceof node_opcua_types_1.EUInformation, "expecting engineering units");
733
755
  // EngineeringUnits specifies the units for the DataItem‟s value (e.g., degree, hertz, seconds). The
@@ -828,26 +850,17 @@ class NamespaceImpl {
828
850
  * @param options.value
829
851
  */
830
852
  addYArrayItem(options) {
831
- (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "engineeringUnitsRange"), "expecting engineeringUnitsRange");
832
- (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "axisScaleType"), "expecting axisScaleType");
853
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(options, "engineeringUnitsRange"), "expecting engineeringUnitsRange");
854
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(options, "axisScaleType"), "expecting axisScaleType");
833
855
  (0, node_opcua_assert_1.assert)(options.xAxisDefinition !== null && typeof options.xAxisDefinition === "object", "expecting a xAxisDefinition");
834
856
  const addressSpace = this.addressSpace;
835
857
  const YArrayItemType = addressSpace.findVariableType("YArrayItemType");
836
858
  if (!YArrayItemType) {
837
859
  throw new Error("expecting YArrayItemType to be defined , check nodeset xml file");
838
860
  }
839
- function toNodeId(options) {
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);
861
+ const dataType = toNodeId(options.dataType) || toNodeId(options.value?.dataType);
849
862
  const optionals = [];
850
- if (Object.prototype.hasOwnProperty.call(options, "instrumentRange")) {
863
+ if (Object.hasOwn(options, "instrumentRange")) {
851
864
  optionals.push("InstrumentRange");
852
865
  }
853
866
  const variable = YArrayItemType.instantiate({
@@ -866,7 +879,7 @@ class NamespaceImpl {
866
879
  dataType: node_opcua_variant_1.DataType.ExtensionObject,
867
880
  value: new node_opcua_types_1.Range(options.engineeringUnitsRange)
868
881
  }));
869
- if (Object.prototype.hasOwnProperty.call(options, "instrumentRange") && variable.instrumentRange) {
882
+ if (Object.hasOwn(options, "instrumentRange") && variable.instrumentRange) {
870
883
  variable.instrumentRange.setValueFromSource(new node_opcua_variant_1.Variant({
871
884
  dataType: node_opcua_variant_1.DataType.ExtensionObject,
872
885
  value: new node_opcua_types_1.Range(options.instrumentRange)
@@ -902,7 +915,7 @@ class NamespaceImpl {
902
915
  addMethod(parentObject, options) {
903
916
  const addressSpace = this.addressSpace;
904
917
  (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.prototype.hasOwnProperty.call(options, "browseName"));
918
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(options, "browseName"));
906
919
  options.componentOf = parentObject;
907
920
  const method = this._addMethod(options);
908
921
  const propertyTypeId = addressSpace._coerce_VariableTypeIds("PropertyType");
@@ -1028,18 +1041,17 @@ class NamespaceImpl {
1028
1041
  (0, node_opcua_assert_1.assert)(typeof options.browseName === "string");
1029
1042
  (0, node_opcua_assert_1.assert)(Array.isArray(options.enumeration));
1030
1043
  const addressSpace = this.addressSpace;
1031
- let definition;
1032
1044
  const enumerationType = addressSpace.findDataType("Enumeration");
1033
- (0, node_opcua_assert_1.assert)(enumerationType.nodeId instanceof node_opcua_nodeid_2.NodeId);
1045
+ (0, node_opcua_assert_1.assert)(enumerationType.nodeId instanceof node_opcua_nodeid_1.NodeId);
1034
1046
  (0, node_opcua_assert_1.assert)(enumerationType instanceof ua_data_type_impl_1.UADataTypeImpl);
1035
1047
  const references = [{ referenceType: "HasSubtype", isForward: false, nodeId: enumerationType.nodeId }];
1036
1048
  const opts = {
1037
1049
  browseName: options.browseName,
1038
- definition,
1050
+ definition: undefined,
1039
1051
  description: (0, node_opcua_data_model_1.coerceLocalizedText)(options.description) || null,
1040
1052
  displayName: options.displayName || null,
1041
1053
  isAbstract: false,
1042
- nodeClass: node_opcua_data_model_4.NodeClass.DataType,
1054
+ nodeClass: node_opcua_data_model_1.NodeClass.DataType,
1043
1055
  references
1044
1056
  };
1045
1057
  const enumType = this.internalCreateNode(opts); // as UAEnumeration;
@@ -1047,7 +1059,7 @@ class NamespaceImpl {
1047
1059
  if (typeof options.enumeration[0] === "string") {
1048
1060
  const enumeration = options.enumeration;
1049
1061
  // enumeration is a array of string
1050
- definition = enumeration.map((str, index) => (0, node_opcua_data_model_1.coerceLocalizedText)(str));
1062
+ const definition = enumeration.map((str, _index) => (0, node_opcua_data_model_1.coerceLocalizedText)(str));
1051
1063
  const value = new node_opcua_variant_1.Variant({
1052
1064
  arrayType: node_opcua_variant_1.VariantArrayType.Array,
1053
1065
  dataType: node_opcua_variant_1.DataType.LocalizedText,
@@ -1083,7 +1095,7 @@ class NamespaceImpl {
1083
1095
  else {
1084
1096
  const enumeration = options.enumeration;
1085
1097
  // construct the definition object
1086
- definition = enumeration.map((enumItem) => {
1098
+ const definition = enumeration.map((enumItem) => {
1087
1099
  return new node_opcua_types_1.EnumValueType({
1088
1100
  description: (0, node_opcua_data_model_1.coerceLocalizedText)(enumItem.description),
1089
1101
  displayName: (0, node_opcua_data_model_1.coerceLocalizedText)(enumItem.displayName),
@@ -1106,7 +1118,7 @@ class NamespaceImpl {
1106
1118
  });
1107
1119
  (0, node_opcua_assert_1.assert)(enumValues.browseName.toString() === "EnumValues");
1108
1120
  enumType.$fullDefinition = new node_opcua_types_1.EnumDefinition({
1109
- fields: enumeration.map((x, index) => new node_opcua_types_1.EnumField({
1121
+ fields: enumeration.map((x, _index) => new node_opcua_types_1.EnumField({
1110
1122
  name: x.displayName.toString(),
1111
1123
  description: x.description || "",
1112
1124
  value: (0, node_opcua_basic_types_1.coerceInt64)(x.value)
@@ -1147,12 +1159,12 @@ class NamespaceImpl {
1147
1159
  // State and Transition
1148
1160
  // -------------------------------------------------------------------------
1149
1161
  /**
1150
- */
1162
+ */
1151
1163
  addState(component, stateName, stateNumber, isInitialState) {
1152
1164
  const addressSpace = this.addressSpace;
1153
1165
  isInitialState = !!isInitialState;
1154
1166
  const _component = component;
1155
- (0, node_opcua_assert_1.assert)(_component.nodeClass === node_opcua_data_model_4.NodeClass.Object || _component.nodeClass === node_opcua_data_model_4.NodeClass.ObjectType);
1167
+ (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
1168
  const initialStateType = addressSpace.findObjectType("InitialStateType");
1157
1169
  const stateType = addressSpace.findObjectType("StateType");
1158
1170
  let state;
@@ -1180,27 +1192,27 @@ class NamespaceImpl {
1180
1192
  addTransition(component, fromState, toState, transitionNumber, browseName) {
1181
1193
  const addressSpace = this.addressSpace;
1182
1194
  const _component = component;
1183
- (0, node_opcua_assert_1.assert)(_component.nodeClass === node_opcua_data_model_4.NodeClass.Object || _component.nodeClass === node_opcua_data_model_4.NodeClass.ObjectType);
1195
+ (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
1196
  (0, node_opcua_assert_1.assert)(typeof fromState === "string");
1185
1197
  (0, node_opcua_assert_1.assert)(typeof toState === "string");
1186
- (0, node_opcua_assert_1.assert)(isFinite(transitionNumber));
1198
+ (0, node_opcua_assert_1.assert)(Number.isFinite(transitionNumber));
1187
1199
  const fromStateNode = _component.getComponentByName(fromState);
1188
1200
  // c8 ignore next
1189
1201
  if (!fromStateNode) {
1190
- throw new Error("Cannot find state with name " + fromState);
1202
+ throw new Error(`Cannot find state with name ${fromState}`);
1191
1203
  }
1192
- (0, node_opcua_assert_1.assert)(fromStateNode.browseName.name.toString() === fromState);
1204
+ (0, node_opcua_assert_1.assert)(fromStateNode.browseName.name?.toString() === fromState);
1193
1205
  const toStateNode = _component.getComponentByName(toState);
1194
1206
  // c8 ignore next
1195
1207
  if (!toStateNode) {
1196
- throw new Error("Cannot find state with name " + toState);
1208
+ throw new Error(`Cannot find state with name ${toState}`);
1197
1209
  }
1198
- (0, node_opcua_assert_1.assert)(toStateNode.browseName.name.toString() === toState);
1210
+ (0, node_opcua_assert_1.assert)(toStateNode.browseName.name?.toString() === toState);
1199
1211
  const transitionType = addressSpace.findObjectType("TransitionType");
1200
1212
  if (!transitionType) {
1201
1213
  throw new Error("Cannot find TransitionType");
1202
1214
  }
1203
- browseName = browseName || fromState + "To" + toState; // "Transition";
1215
+ browseName = browseName || `${fromState}To${toState}`; // "Transition";
1204
1216
  const transition = transitionType.instantiate({
1205
1217
  browseName,
1206
1218
  componentOf: _component
@@ -1291,7 +1303,7 @@ class NamespaceImpl {
1291
1303
  }
1292
1304
  _register(node) {
1293
1305
  (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 node_opcua_nodeid_2.NodeId, "Expecting a NodeId");
1306
+ (0, node_opcua_assert_1.assert)(node.nodeId instanceof node_opcua_nodeid_1.NodeId, "Expecting a NodeId");
1295
1307
  // c8 ignore next
1296
1308
  if (node.nodeId.namespace !== this.index) {
1297
1309
  throw new Error("node must belong to this namespace : " +
@@ -1303,7 +1315,7 @@ class NamespaceImpl {
1303
1315
  this.index);
1304
1316
  }
1305
1317
  (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.prototype.hasOwnProperty.call(node, "browseName"), "Node must have a browseName");
1318
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(node, "browseName"), "Node must have a browseName");
1307
1319
  const hashKey = _makeHashKey(node.nodeId);
1308
1320
  // c8 ignore next
1309
1321
  if (this._nodeid_index.has(hashKey)) {
@@ -1327,22 +1339,22 @@ class NamespaceImpl {
1327
1339
  }
1328
1340
  this._nodeid_index.set(hashKey, node);
1329
1341
  switch (node.nodeClass) {
1330
- case node_opcua_data_model_4.NodeClass.ObjectType:
1342
+ case node_opcua_data_model_1.NodeClass.ObjectType:
1331
1343
  this._registerObjectType(node);
1332
1344
  break;
1333
- case node_opcua_data_model_4.NodeClass.VariableType:
1345
+ case node_opcua_data_model_1.NodeClass.VariableType:
1334
1346
  this._registerVariableType(node);
1335
1347
  break;
1336
- case node_opcua_data_model_4.NodeClass.ReferenceType:
1348
+ case node_opcua_data_model_1.NodeClass.ReferenceType:
1337
1349
  this._registerReferenceType(node);
1338
1350
  break;
1339
- case node_opcua_data_model_4.NodeClass.DataType:
1351
+ case node_opcua_data_model_1.NodeClass.DataType:
1340
1352
  this._registerDataType(node);
1341
1353
  break;
1342
- case node_opcua_data_model_4.NodeClass.Object:
1343
- case node_opcua_data_model_4.NodeClass.Variable:
1344
- case node_opcua_data_model_4.NodeClass.Method:
1345
- case node_opcua_data_model_4.NodeClass.View:
1354
+ case node_opcua_data_model_1.NodeClass.Object:
1355
+ case node_opcua_data_model_1.NodeClass.Variable:
1356
+ case node_opcua_data_model_1.NodeClass.Method:
1357
+ case node_opcua_data_model_1.NodeClass.View:
1346
1358
  break;
1347
1359
  default:
1348
1360
  // tslint:disable-next-line:no-console
@@ -1360,7 +1372,7 @@ class NamespaceImpl {
1360
1372
  // xx assert(options.browseName instanceof QualifiedName
1361
1373
  // ? (options.browseName.namespaceIndex === this.index): true,
1362
1374
  // "Expecting browseName to have the same namespaceIndex as the namespace");
1363
- options.description = (0, node_opcua_data_model_1.coerceLocalizedText)(options.description);
1375
+ options.description = (0, node_opcua_data_model_1.coerceLocalizedText)(options.description) || "";
1364
1376
  // browseName adjustment
1365
1377
  if (typeof options.browseName === "string") {
1366
1378
  const match = options.browseName.match(regExpNamespaceDotBrowseName);
@@ -1381,31 +1393,32 @@ class NamespaceImpl {
1381
1393
  " please refer to the NodeOPCUA documentation");
1382
1394
  }
1383
1395
  }
1384
- options.browseName = new node_opcua_data_model_2.QualifiedName({ name: options.browseName, namespaceIndex: this.index });
1396
+ options.browseName = new node_opcua_data_model_1.QualifiedName({ name: options.browseName, namespaceIndex: this.index });
1385
1397
  }
1386
- else if (!(options.browseName instanceof node_opcua_data_model_2.QualifiedName)) {
1387
- options.browseName = new node_opcua_data_model_2.QualifiedName(options.browseName);
1398
+ else if (!(options.browseName instanceof node_opcua_data_model_1.QualifiedName)) {
1399
+ options.browseName = new node_opcua_data_model_1.QualifiedName(options.browseName);
1388
1400
  }
1389
- (0, node_opcua_assert_1.assert)(options.browseName instanceof node_opcua_data_model_2.QualifiedName, "Expecting options.browseName to be instanceof QualifiedName ");
1401
+ (0, node_opcua_assert_1.assert)(options.browseName instanceof node_opcua_data_model_1.QualifiedName, "Expecting options.browseName to be instanceof QualifiedName ");
1390
1402
  // ------------- set display name
1391
1403
  if (!options.displayName) {
1392
1404
  (0, node_opcua_assert_1.assert)(typeof options.browseName.name === "string");
1393
- options.displayName = (0, node_opcua_data_model_1.coerceLocalizedText)(options.browseName.name);
1405
+ options.displayName = (0, node_opcua_data_model_1.coerceLocalizedText)(options.browseName.name || "");
1394
1406
  }
1395
- if (!options.nodeClass || options.nodeClass == undefined) {
1407
+ if (!options.nodeClass || options.nodeClass === undefined) {
1396
1408
  throw new Error("nodeclass must be specified");
1397
1409
  }
1398
1410
  // --- nodeId adjustment
1399
1411
  options.nodeId = this.constructNodeId(options);
1400
1412
  (0, node_opcua_debug_1.dumpIf)(!options.nodeId, options); // missing node Id
1401
- (0, node_opcua_assert_1.assert)(options.nodeId instanceof node_opcua_nodeid_2.NodeId);
1413
+ (0, node_opcua_assert_1.assert)(options.nodeId instanceof node_opcua_nodeid_1.NodeId);
1402
1414
  // assert(options.browseName.namespaceIndex === this.index,"Expecting browseName to have
1403
1415
  // the same namespaceIndex as the namespace");
1404
- const Constructor = _constructors_map[node_opcua_data_model_4.NodeClass[options.nodeClass]];
1416
+ const Constructor = _constructors_map[node_opcua_data_model_1.NodeClass[options.nodeClass]];
1405
1417
  if (!Constructor) {
1406
- throw new Error(" missing constructor for NodeClass " + node_opcua_data_model_4.NodeClass[options.nodeClass]);
1418
+ throw new Error(` missing constructor for NodeClass ${node_opcua_data_model_1.NodeClass[options.nodeClass]}`);
1407
1419
  }
1408
1420
  options.addressSpace = this.addressSpace;
1421
+ // biome-ignore lint/suspicious/noExplicitAny: to fix later
1409
1422
  const node = new Constructor(options);
1410
1423
  this._register(node);
1411
1424
  // object shall now be registered
@@ -1420,19 +1433,19 @@ class NamespaceImpl {
1420
1433
  const hashKey = _makeHashKey(node.nodeId);
1421
1434
  // c8 ignore next
1422
1435
  if (!this._nodeid_index.has(hashKey)) {
1423
- throw new Error("deleteNode : nodeId " + node.nodeId.displayText() + " is not registered " + node.nodeId.toString());
1436
+ throw new Error(`deleteNode : nodeId ${node.nodeId.displayText()} is not registered ${node.nodeId.toString()}`);
1424
1437
  }
1425
1438
  switch (node.nodeClass) {
1426
- case node_opcua_data_model_4.NodeClass.ObjectType:
1439
+ case node_opcua_data_model_1.NodeClass.ObjectType:
1427
1440
  this._unregisterObjectType(node);
1428
1441
  break;
1429
- case node_opcua_data_model_4.NodeClass.VariableType:
1442
+ case node_opcua_data_model_1.NodeClass.VariableType:
1430
1443
  this._unregisterVariableType(node);
1431
1444
  break;
1432
- case node_opcua_data_model_4.NodeClass.Object:
1433
- case node_opcua_data_model_4.NodeClass.Variable:
1434
- case node_opcua_data_model_4.NodeClass.Method:
1435
- case node_opcua_data_model_4.NodeClass.View:
1445
+ case node_opcua_data_model_1.NodeClass.Object:
1446
+ case node_opcua_data_model_1.NodeClass.Variable:
1447
+ case node_opcua_data_model_1.NodeClass.Method:
1448
+ case node_opcua_data_model_1.NodeClass.View:
1436
1449
  break;
1437
1450
  default:
1438
1451
  // tslint:disable:no-console
@@ -1447,19 +1460,19 @@ class NamespaceImpl {
1447
1460
  _addObjectOrVariableType(options1, topMostBaseType, nodeClass) {
1448
1461
  const addressSpace = this.addressSpace;
1449
1462
  (0, node_opcua_assert_1.assert)(typeof topMostBaseType === "string");
1450
- (0, node_opcua_assert_1.assert)(nodeClass === node_opcua_data_model_4.NodeClass.ObjectType || nodeClass === node_opcua_data_model_4.NodeClass.VariableType);
1463
+ (0, node_opcua_assert_1.assert)(nodeClass === node_opcua_data_model_1.NodeClass.ObjectType || nodeClass === node_opcua_data_model_1.NodeClass.VariableType);
1451
1464
  const options = options1;
1452
1465
  (0, node_opcua_assert_1.assert)(!options.nodeClass);
1453
1466
  (0, node_opcua_assert_1.assert)(options.browseName);
1454
1467
  (0, node_opcua_assert_1.assert)(typeof options.browseName === "string");
1455
- if (Object.prototype.hasOwnProperty.call(options, "references")) {
1468
+ if (Object.hasOwn(options, "references")) {
1456
1469
  throw new Error("options.references should not be provided, use options.subtypeOf instead");
1457
1470
  }
1458
1471
  const references = [];
1459
1472
  function process_subtypeOf_options(options2, references1) {
1460
1473
  // check common misspelling mistake
1461
1474
  (0, node_opcua_assert_1.assert)(!options2.subTypeOf, "misspell error : it should be 'subtypeOf' instead");
1462
- if (Object.prototype.hasOwnProperty.call(options2, "hasTypeDefinition")) {
1475
+ if (Object.hasOwn(options2, "hasTypeDefinition")) {
1463
1476
  throw new Error("hasTypeDefinition option is invalid. Do you mean typeDefinition instead ?");
1464
1477
  }
1465
1478
  (0, node_opcua_assert_1.assert)(!options2.typeDefinition, " do you mean subtypeOf ?");
@@ -1506,38 +1519,38 @@ class NamespaceImpl {
1506
1519
  // }
1507
1520
  _registerObjectType(node) {
1508
1521
  (0, node_opcua_assert_1.assert)(this.index === node.nodeId.namespace);
1509
- const key = node.browseName.name;
1522
+ const key = node.browseName.name || "";
1510
1523
  if (this._objectTypeMap.has(key)) {
1511
- throw new Error(" UAObjectType already declared " + node.browseName.toString() + " " + node.nodeId.toString());
1524
+ throw new Error(` UAObjectType already declared ${node.browseName.toString()} ${node.nodeId.toString()}`);
1512
1525
  }
1513
1526
  this._objectTypeMap.set(key, node);
1514
1527
  }
1515
1528
  _registerVariableType(node) {
1516
1529
  (0, node_opcua_assert_1.assert)(this.index === node.nodeId.namespace);
1517
- const key = node.browseName.name;
1530
+ const key = node.browseName.name || "";
1518
1531
  (0, node_opcua_assert_1.assert)(!this._variableTypeMap.has(key), " UAVariableType already declared");
1519
1532
  this._variableTypeMap.set(key, node);
1520
1533
  }
1521
1534
  _registerReferenceType(node) {
1522
1535
  (0, node_opcua_assert_1.assert)(this.index === node.nodeId.namespace);
1523
- (0, node_opcua_assert_1.assert)(node.browseName instanceof node_opcua_data_model_2.QualifiedName);
1524
- const key = node.browseName.name;
1536
+ (0, node_opcua_assert_1.assert)(node.browseName instanceof node_opcua_data_model_1.QualifiedName);
1537
+ const key = node.browseName.name || "";
1525
1538
  this._referenceTypeMap.set(key, node);
1526
- this._referenceTypeMapInv.set(node.inverseName.text, node);
1539
+ this._referenceTypeMapInv.set(node.inverseName.text || "", node);
1527
1540
  }
1528
1541
  _registerDataType(node) {
1529
1542
  (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 node_opcua_data_model_2.QualifiedName);
1543
+ const key = node.browseName.name || "";
1544
+ (0, node_opcua_assert_1.assert)(node.browseName instanceof node_opcua_data_model_1.QualifiedName);
1532
1545
  (0, node_opcua_assert_1.assert)(!this._dataTypeMap.has(key), " DataType already declared");
1533
1546
  this._dataTypeMap.set(key, node);
1534
1547
  }
1535
1548
  _unregisterObjectType(node) {
1536
- const key = node.browseName.name;
1549
+ const key = node.browseName.name || "";
1537
1550
  this._objectTypeMap.delete(key);
1538
1551
  }
1539
1552
  _unregisterVariableType(node) {
1540
- const key = node.browseName.name;
1553
+ const key = node.browseName.name || "";
1541
1554
  this._variableTypeMap.delete(key);
1542
1555
  }
1543
1556
  /**
@@ -1550,33 +1563,33 @@ class NamespaceImpl {
1550
1563
  throw new Error("cannot find BaseDataVariableType");
1551
1564
  }
1552
1565
  const baseDataVariableTypeId = baseDataVariableType.nodeId;
1553
- (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "browseName"), "options.browseName must be provided");
1554
- (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(options, "dataType"), "options.dataType must be provided");
1566
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(options, "browseName"), "options.browseName must be provided");
1567
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(options, "dataType"), "options.dataType must be provided");
1555
1568
  options.historizing = !!options.historizing;
1556
1569
  // c8 ignore next
1557
- if (Object.prototype.hasOwnProperty.call(options, "hasTypeDefinition")) {
1570
+ if (Object.hasOwn(options, "hasTypeDefinition")) {
1558
1571
  throw new Error("hasTypeDefinition option is invalid. Do you mean typeDefinition instead ?");
1559
1572
  }
1560
1573
  // ------------------------------------------ TypeDefinition
1561
1574
  let typeDefinition = options.typeDefinition || baseDataVariableTypeId;
1562
1575
  if (typeDefinition instanceof base_node_impl_1.BaseNodeImpl) {
1563
1576
  // c8 ignore next
1564
- if (typeDefinition.nodeClass !== node_opcua_data_model_4.NodeClass.VariableType) {
1565
- const message = `invalid typeDefinition expecting a VariableType got ${node_opcua_data_model_4.NodeClass[typeDefinition.nodeClass]}`;
1577
+ if (typeDefinition.nodeClass !== node_opcua_data_model_1.NodeClass.VariableType) {
1578
+ const message = `invalid typeDefinition expecting a VariableType got ${node_opcua_data_model_1.NodeClass[typeDefinition.nodeClass]}`;
1566
1579
  errorLog(message);
1567
1580
  throw new Error(message);
1568
1581
  }
1569
1582
  }
1570
1583
  typeDefinition = addressSpace._coerce_VariableTypeIds(typeDefinition);
1571
- (0, node_opcua_assert_1.assert)(typeDefinition instanceof node_opcua_nodeid_2.NodeId);
1584
+ (0, node_opcua_assert_1.assert)(typeDefinition instanceof node_opcua_nodeid_1.NodeId);
1572
1585
  // ------------------------------------------ DataType
1573
- options.dataType = addressSpace._coerce_DataType(options.dataType);
1586
+ options.dataType = addressSpace._coerce_DataType(options.dataType || node_opcua_variant_1.DataType.Null);
1574
1587
  options.valueRank = (0, node_opcua_utils_1.isNullOrUndefined)(options.valueRank)
1575
1588
  ? options.arrayDimensions
1576
1589
  ? options.arrayDimensions.length
1577
1590
  : -1
1578
1591
  : options.valueRank;
1579
- (0, node_opcua_assert_1.assert)(typeof options.valueRank === "number" && isFinite(options.valueRank));
1592
+ (0, node_opcua_assert_1.assert)(typeof options.valueRank === "number" && Number.isFinite(options.valueRank));
1580
1593
  options.arrayDimensions = options.arrayDimensions || null;
1581
1594
  (0, node_opcua_assert_1.assert)(options.arrayDimensions === null || Array.isArray(options.arrayDimensions));
1582
1595
  // -----------------------------------------------------
@@ -1603,8 +1616,8 @@ class NamespaceImpl {
1603
1616
  referenceType: "HasTypeDefinition"
1604
1617
  }
1605
1618
  ]);
1606
- (0, node_opcua_assert_1.assert)(!options.nodeClass || options.nodeClass === node_opcua_data_model_4.NodeClass.Variable);
1607
- options.nodeClass = node_opcua_data_model_4.NodeClass.Variable;
1619
+ (0, node_opcua_assert_1.assert)(!options.nodeClass || options.nodeClass === node_opcua_data_model_1.NodeClass.Variable);
1620
+ options.nodeClass = node_opcua_data_model_1.NodeClass.Variable;
1608
1621
  options.references = references;
1609
1622
  const variable = this.createNode(options);
1610
1623
  return variable;
@@ -1625,7 +1638,7 @@ class NamespaceImpl {
1625
1638
  displayName: options.displayName,
1626
1639
  eventNotifier: +options.eventNotifier,
1627
1640
  isAbstract: false,
1628
- nodeClass: node_opcua_data_model_4.NodeClass.Method,
1641
+ nodeClass: node_opcua_data_model_1.NodeClass.Method,
1629
1642
  nodeId: options.nodeId,
1630
1643
  references,
1631
1644
  rolePermissions: options.rolePermissions
@@ -1661,7 +1674,7 @@ function _coerce_parent(addressSpace, value, coerceFunc) {
1661
1674
  if (typeof value === "string") {
1662
1675
  value = coerceFunc.call(addressSpace, value);
1663
1676
  }
1664
- if (value instanceof node_opcua_nodeid_2.NodeId) {
1677
+ if (value instanceof node_opcua_nodeid_1.NodeId) {
1665
1678
  value = addressSpace.findNode(value);
1666
1679
  }
1667
1680
  }
@@ -1699,7 +1712,7 @@ function _handle_hierarchy_parent(addressSpace, references, options) {
1699
1712
  (0, node_opcua_assert_1.assert)(!options.componentOf);
1700
1713
  (0, node_opcua_assert_1.assert)(!options.propertyOf);
1701
1714
  (0, node_opcua_assert_1.assert)(!options.organizedBy);
1702
- (0, node_opcua_assert_1.assert)(options.addInOf.nodeClass === node_opcua_data_model_4.NodeClass.Object || options.addInOf.nodeClass === node_opcua_data_model_4.NodeClass.ObjectType, "addInOf must be of nodeClass Object or ObjectType");
1715
+ (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
1716
  references.push({
1704
1717
  isForward: false,
1705
1718
  nodeId: options.addInOf.nodeId,
@@ -1741,7 +1754,7 @@ function _handle_hierarchy_parent(addressSpace, references, options) {
1741
1754
  }
1742
1755
  if (options.encodingOf) {
1743
1756
  // parent must be a DataType
1744
- (0, node_opcua_assert_1.assert)(options.encodingOf.nodeClass === node_opcua_data_model_4.NodeClass.DataType, "encodingOf must be toward a DataType");
1757
+ (0, node_opcua_assert_1.assert)(options.encodingOf.nodeClass === node_opcua_data_model_1.NodeClass.DataType, "encodingOf must be toward a DataType");
1745
1758
  references.push({
1746
1759
  isForward: false,
1747
1760
  nodeId: options.encodingOf.nodeId,
@@ -1750,10 +1763,10 @@ function _handle_hierarchy_parent(addressSpace, references, options) {
1750
1763
  }
1751
1764
  }
1752
1765
  function _copy_reference(reference) {
1753
- (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(reference, "referenceType"));
1754
- (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(reference, "isForward"));
1755
- (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(reference, "nodeId"));
1756
- (0, node_opcua_assert_1.assert)(reference.nodeId instanceof node_opcua_nodeid_2.NodeId);
1766
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(reference, "referenceType"));
1767
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(reference, "isForward"));
1768
+ (0, node_opcua_assert_1.assert)(Object.hasOwn(reference, "nodeId"));
1769
+ (0, node_opcua_assert_1.assert)(reference.nodeId instanceof node_opcua_nodeid_1.NodeId);
1757
1770
  return {
1758
1771
  isForward: reference.isForward,
1759
1772
  nodeId: reference.nodeId,
@@ -1771,16 +1784,16 @@ function isNonEmptyQualifiedName(browseName) {
1771
1784
  if (typeof browseName === "string") {
1772
1785
  return browseName.length >= 0;
1773
1786
  }
1774
- if (!(browseName instanceof node_opcua_data_model_2.QualifiedName)) {
1775
- browseName = new node_opcua_data_model_2.QualifiedName(browseName);
1787
+ if (!(browseName instanceof node_opcua_data_model_1.QualifiedName)) {
1788
+ browseName = new node_opcua_data_model_1.QualifiedName(browseName);
1776
1789
  }
1777
- (0, node_opcua_assert_1.assert)(browseName instanceof node_opcua_data_model_2.QualifiedName);
1778
- return browseName.name.length > 0;
1790
+ (0, node_opcua_assert_1.assert)(browseName instanceof node_opcua_data_model_1.QualifiedName);
1791
+ return (browseName.name?.length || 0) > 0;
1779
1792
  }
1780
1793
  function _create_node_version_if_needed(node, options) {
1781
1794
  (0, node_opcua_assert_1.assert)(options);
1782
- if (typeof options.nodeVersion == "string") {
1783
- (0, node_opcua_assert_1.assert)(node.nodeClass === node_opcua_data_model_4.NodeClass.Variable || node.nodeClass === node_opcua_data_model_4.NodeClass.Object);
1795
+ if (typeof options.nodeVersion === "string") {
1796
+ (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
1797
  // c8 ignore next
1785
1798
  if (node.getNodeVersion()) {
1786
1799
  return; // already exists