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.
@@ -3,33 +3,7 @@
3
3
  */
4
4
  // tslint:disable:no-console
5
5
  import chalk from "chalk";
6
-
7
- import { assert } from "node-opcua-assert";
8
- import { coerceInt64 } from "node-opcua-basic-types";
9
- import { AxisScaleEnumeration } from "node-opcua-data-access";
10
- import { AccessRestrictionsFlag, coerceLocalizedText, coerceQualifiedName, QualifiedNameLike } from "node-opcua-data-model";
11
- import { QualifiedName } from "node-opcua-data-model";
12
- import { BrowseDirection } from "node-opcua-data-model";
13
- import { NodeClass } from "node-opcua-data-model";
14
- import { dumpIf, make_errorLog, make_warningLog } from "node-opcua-debug";
15
- import { NodeIdLike, NodeIdType, resolveNodeId } from "node-opcua-nodeid";
16
- import { NodeId } from "node-opcua-nodeid";
17
- import { StatusCodes } from "node-opcua-status-code";
18
- import {
19
- Argument,
20
- ArgumentOptions,
21
- AxisInformation,
22
- EnumDefinition,
23
- EnumField,
24
- EnumValueType,
25
- EUInformation,
26
- Range,
27
- RolePermissionType,
28
- RolePermissionTypeOptions
29
- } from "node-opcua-types";
30
- import { isNullOrUndefined } from "node-opcua-utils";
31
- import { DataType, Variant, VariantArrayType, VariantOptions, verifyRankAndDimensions } from "node-opcua-variant";
32
- import {
6
+ import type {
33
7
  AddBaseNodeOptions,
34
8
  AddEnumerationTypeOptions,
35
9
  AddMethodOptions,
@@ -57,40 +31,69 @@ import {
57
31
  UAVariableType,
58
32
  UAView
59
33
  } from "node-opcua-address-space-base";
60
- import { UAAnalogItem, UADataItem, UAInitialState, UAState } from "node-opcua-nodeset-ua";
61
-
34
+ import { assert } from "node-opcua-assert";
35
+ import { coerceInt64 } from "node-opcua-basic-types";
36
+ import { AxisScaleEnumeration } from "node-opcua-data-access";
62
37
  import {
63
- AddMultiStateDiscreteOptions,
64
- AddMultiStateValueDiscreteOptions,
65
- AddTwoStateDiscreteOptions,
66
- AddTwoStateVariableOptions
67
- } from "../source/address_space_ts";
68
- import { UAStateMachineEx } from "../source/interfaces/state_machine/ua_state_machine_type";
69
- import { UATransitionEx } from "../source/interfaces/state_machine/ua_transition_ex";
38
+ AccessRestrictionsFlag,
39
+ BrowseDirection,
40
+ coerceLocalizedText,
41
+ coerceQualifiedName,
42
+ NodeClass,
43
+ QualifiedName,
44
+ type QualifiedNameLike
45
+ } from "node-opcua-data-model";
46
+ import { dumpIf, make_errorLog, make_warningLog } from "node-opcua-debug";
47
+ import { coerceNodeId, NodeId, type NodeIdLike, NodeIdType, resolveNodeId } from "node-opcua-nodeid";
48
+ import type { UAAnalogItem, UADataItem, UAInitialState, UAState } from "node-opcua-nodeset-ua";
49
+ import { StatusCodes } from "node-opcua-status-code";
70
50
  import {
51
+ Argument,
52
+ type ArgumentOptions,
53
+ AxisInformation,
54
+ EnumDefinition,
55
+ EnumField,
56
+ EnumValueType,
57
+ EUInformation,
58
+ Range,
59
+ type RolePermissionType,
60
+ type RolePermissionTypeOptions
61
+ } from "node-opcua-types";
62
+ import { isNullOrUndefined } from "node-opcua-utils";
63
+ import { DataType, Variant, VariantArrayType, type VariantOptions, verifyRankAndDimensions } from "node-opcua-variant";
64
+ import type {
71
65
  InstantiateAlarmConditionOptions,
72
66
  InstantiateLimitAlarmOptions,
73
67
  InstantiateOffNormalAlarmOptions,
74
68
  UATwoStateDiscreteEx,
75
69
  UAYArrayItemEx
76
70
  } from "../source";
77
- import { AddAnalogDataItemOptions, AddDataItemOptions } from "../source/namespace_data_access";
78
- import { UATwoStateVariableEx } from "../source/ua_two_state_variable_ex";
79
- import { UAMultiStateValueDiscreteEx } from "../source/interfaces/data_access/ua_multistate_value_discrete_ex";
80
- import { UAAlarmConditionEx } from "../source/interfaces/alarms_and_conditions/ua_alarm_condition_ex";
81
- import { UADiscreteAlarmEx } from "../source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex";
82
- import { UAExclusiveDeviationAlarmEx } from "../source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex";
83
- import { UAExclusiveLimitAlarmEx } from "../source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex";
84
- import { UALimitAlarmEx } from "../source/interfaces/alarms_and_conditions/ua_limit_alarm_ex";
85
- import { UANonExclusiveDeviationAlarmEx } from "../source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex";
86
- import { UANonExclusiveLimitAlarmEx } from "../source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex";
87
- import { UAConditionEx } from "../source/interfaces/alarms_and_conditions/ua_condition_ex";
88
- import { InstantiateExclusiveDeviationAlarmOptions } from "../source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options";
89
- import { InstantiateNonExclusiveLimitAlarmOptions } from "../source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options";
90
- import { InstantiateNonExclusiveDeviationAlarmOptions } from "../source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options";
71
+ import type {
72
+ AddMultiStateDiscreteOptions,
73
+ AddMultiStateValueDiscreteOptions,
74
+ AddTwoStateDiscreteOptions,
75
+ AddTwoStateVariableOptions
76
+ } from "../source/address_space_ts";
77
+ import type { InstantiateExclusiveDeviationAlarmOptions } from "../source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options";
78
+ import type { InstantiateNonExclusiveDeviationAlarmOptions } from "../source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options";
79
+ import type { InstantiateNonExclusiveLimitAlarmOptions } from "../source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options";
80
+ import type { UAAlarmConditionEx } from "../source/interfaces/alarms_and_conditions/ua_alarm_condition_ex";
81
+ import type { UAConditionEx } from "../source/interfaces/alarms_and_conditions/ua_condition_ex";
82
+ import type { UADiscreteAlarmEx } from "../source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex";
83
+ import type { UAExclusiveDeviationAlarmEx } from "../source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex";
84
+ import type { UAExclusiveLimitAlarmEx } from "../source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex";
85
+ import type { UALimitAlarmEx } from "../source/interfaces/alarms_and_conditions/ua_limit_alarm_ex";
86
+ import type { UANonExclusiveDeviationAlarmEx } from "../source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex";
87
+ import type { UANonExclusiveLimitAlarmEx } from "../source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex";
88
+ import type { UAMultiStateValueDiscreteEx } from "../source/interfaces/data_access/ua_multistate_value_discrete_ex";
89
+ import type { UAStateMachineEx } from "../source/interfaces/state_machine/ua_state_machine_type";
90
+ import type { UATransitionEx } from "../source/interfaces/state_machine/ua_transition_ex";
91
+ import type { AddAnalogDataItemOptions, AddDataItemOptions } from "../source/namespace_data_access";
92
+ import type { UATwoStateVariableEx } from "../source/ua_two_state_variable_ex";
91
93
 
92
94
  import { _handle_delete_node_model_change_event, _handle_model_change_event } from "./address_space_change_event_tools";
93
- import { AddressSpacePrivate } from "./address_space_private";
95
+ import type { AddressSpacePrivate } from "./address_space_private";
96
+ import { UAAcknowledgeableConditionImpl, UAAlarmConditionImpl } from "./alarms_and_conditions";
94
97
  import { UAConditionImpl } from "./alarms_and_conditions/ua_condition_impl";
95
98
  import { UADiscreteAlarmImpl } from "./alarms_and_conditions/ua_discrete_alarm_impl";
96
99
  import { UAExclusiveDeviationAlarmImpl } from "./alarms_and_conditions/ua_exclusive_deviation_alarm_impl";
@@ -98,30 +101,28 @@ import { UAExclusiveLimitAlarmImpl } from "./alarms_and_conditions/ua_exclusive_
98
101
  import { UALimitAlarmImpl } from "./alarms_and_conditions/ua_limit_alarm_impl";
99
102
  import { UANonExclusiveDeviationAlarmImpl } from "./alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl";
100
103
  import { UANonExclusiveLimitAlarmImpl } from "./alarms_and_conditions/ua_non_exclusive_limit_alarm_impl";
101
- import { UAAcknowledgeableConditionImpl, UAAlarmConditionImpl } from "./alarms_and_conditions";
102
- import { UAOffNormalAlarmEx, UAOffNormalAlarmImpl } from "./alarms_and_conditions/ua_off_normal_alarm_impl";
104
+ import { type UAOffNormalAlarmEx, UAOffNormalAlarmImpl } from "./alarms_and_conditions/ua_off_normal_alarm_impl";
105
+ import { BaseNodeImpl } from "./base_node_impl";
103
106
  import { add_dataItem_stuff } from "./data_access/add_dataItem_stuff";
104
- import { UAMultiStateDiscreteImpl, _addMultiStateDiscrete } from "./data_access/ua_multistate_discrete_impl";
105
- // state machine
106
- import { _install_TwoStateVariable_machinery, _addTwoStateVariable } from "./state_machine/ua_two_state_variable";
107
-
107
+ import { _addMultiStateDiscrete, type UAMultiStateDiscreteImpl } from "./data_access/ua_multistate_discrete_impl";
108
+ import { _addMultiStateValueDiscrete } from "./data_access/ua_multistate_value_discrete_impl";
109
+ import { _addTwoStateDiscrete } from "./data_access/ua_two_state_discrete_impl";
108
110
  //
109
- import { NamespacePrivate, UANamespace_process_modelling_rule } from "./namespace_private";
110
- import { BaseNodeImpl } from "./base_node_impl";
111
- import { UAVariableImpl } from "./ua_variable_impl";
111
+ import { type NamespacePrivate, UANamespace_process_modelling_rule } from "./namespace_private";
112
112
 
113
- import { ConstructNodeIdOptions, NodeIdManager } from "./nodeid_manager";
114
- import { _addTwoStateDiscrete } from "./data_access/ua_two_state_discrete_impl";
113
+ import { type ConstructNodeIdOptions, NodeIdManager } from "./nodeid_manager";
115
114
  import { coerceRolePermissions } from "./role_permissions";
116
- import { UAObjectImpl } from "./ua_object_impl";
115
+ import type { UAStateMachineImpl, UATransitionImpl } from "./state_machine/finite_state_machine";
116
+ // state machine
117
+ import { _addTwoStateVariable } from "./state_machine/ua_two_state_variable";
117
118
  import { UADataTypeImpl } from "./ua_data_type_impl";
118
- import { UAObjectTypeImpl } from "./ua_object_type_impl";
119
119
  import { UAMethodImpl } from "./ua_method_impl";
120
- import { UAVariableTypeImpl } from "./ua_variable_type_impl";
120
+ import { UAObjectImpl } from "./ua_object_impl";
121
+ import { UAObjectTypeImpl } from "./ua_object_type_impl";
121
122
  import { UAReferenceTypeImpl } from "./ua_reference_type_impl";
123
+ import { UAVariableImpl } from "./ua_variable_impl";
124
+ import { UAVariableTypeImpl } from "./ua_variable_type_impl";
122
125
  import { UAViewImpl } from "./ua_view_impl";
123
- import { UAStateMachineImpl, UATransitionImpl } from "./state_machine/finite_state_machine";
124
- import { _addMultiStateValueDiscrete } from "./data_access/ua_multistate_value_discrete_impl";
125
126
 
126
127
  function _makeHashKey(nodeId: NodeId): string | number {
127
128
  switch (nodeId.identifierType) {
@@ -158,7 +159,7 @@ function detachNode(node: BaseNode) {
158
159
  const nonHierarchicalReferences = node.findReferencesEx("NonHierarchicalReferences", BrowseDirection.Inverse);
159
160
  for (const ref of nonHierarchicalReferences) {
160
161
  assert(!ref.isForward);
161
- ref.node!.removeReference({
162
+ ref.node?.removeReference({
162
163
  isForward: !ref.isForward,
163
164
  nodeId: node.nodeId,
164
165
  referenceType: ref.referenceType
@@ -172,7 +173,7 @@ function detachNode(node: BaseNode) {
172
173
  continue;
173
174
  }
174
175
  assert(ref.isForward);
175
- ref.node!.removeReference({
176
+ ref.node?.removeReference({
176
177
  isForward: !ref.isForward,
177
178
  nodeId: node.nodeId,
178
179
  referenceType: ref.referenceType
@@ -183,7 +184,7 @@ function detachNode(node: BaseNode) {
183
184
  const hierarchicalReferences = node.findReferencesEx("HierarchicalReferences", BrowseDirection.Inverse);
184
185
  for (const ref of hierarchicalReferences) {
185
186
  assert(!ref.isForward);
186
- const parent = addressSpace.findNode(ref.nodeId)! as BaseNode;
187
+ const parent = addressSpace.findNode(ref.nodeId) as BaseNode;
187
188
  parent.removeReference({
188
189
  isForward: !ref.isForward,
189
190
  nodeId: node.nodeId,
@@ -200,6 +201,23 @@ interface NamespaceConstructorOptions {
200
201
  publicationDate: Date;
201
202
  version: string;
202
203
  }
204
+
205
+ function toNodeId(nodeId: NodeId | { nodeId: NodeId } | string | number | undefined): NodeId | undefined {
206
+ if (!nodeId) {
207
+ return undefined;
208
+ }
209
+ if (nodeId instanceof NodeId) {
210
+ return nodeId;
211
+ }
212
+ if (typeof nodeId === "string") {
213
+ return coerceNodeId(nodeId);
214
+ }
215
+ if (typeof nodeId === "number") {
216
+ return coerceNodeId(nodeId);
217
+ }
218
+ return nodeId.nodeId;
219
+ }
220
+
203
221
  /**
204
222
  *
205
223
  * @constructor
@@ -232,7 +250,7 @@ export class NamespaceImpl implements NamespacePrivate {
232
250
  private _dataTypeMap: Map<string, UADataType>;
233
251
  private _referenceTypeMapInv: Map<string, UAReferenceType>;
234
252
  private _nodeIdManager: NodeIdManager;
235
- private _nodeid_index: Map<string | number| Buffer, BaseNode>;
253
+ private _nodeid_index: Map<string | number | Buffer, BaseNode>;
236
254
  private _aliases: Map<string, NodeId>;
237
255
  private defaultAccessRestrictions?: AccessRestrictionsFlag;
238
256
  private defaultRolePermissions?: RolePermissionType[];
@@ -240,7 +258,7 @@ export class NamespaceImpl implements NamespacePrivate {
240
258
  constructor(options: NamespaceConstructorOptions) {
241
259
  // c8 ignore next
242
260
  if (!(typeof options.namespaceUri === "string")) {
243
- throw new Error("NamespaceImpl constructor: namespaceUri must exists and be a string : got " + options.namespaceUri);
261
+ throw new Error(`NamespaceImpl constructor: namespaceUri must exists and be a string : got ${options.namespaceUri}`);
244
262
  }
245
263
  // c8 ignore next
246
264
  if (typeof options.index !== "number") {
@@ -334,7 +352,7 @@ export class NamespaceImpl implements NamespacePrivate {
334
352
  public findNode(nodeId: string | NodeId): BaseNode | null {
335
353
  if (typeof nodeId === "string") {
336
354
  if (nodeId.match(regExp1)) {
337
- nodeId = "ns=" + this.index + ";" + nodeId;
355
+ nodeId = `ns=${this.index};${nodeId}`;
338
356
  }
339
357
  }
340
358
  nodeId = resolveNodeId(nodeId);
@@ -421,12 +439,9 @@ export class NamespaceImpl implements NamespacePrivate {
421
439
  *
422
440
  */
423
441
  public addObjectType(options: AddObjectTypeOptions): UAObjectType {
424
- assert(!Object.prototype.hasOwnProperty.call(options, "dataType"), "an objectType should not have a dataType");
425
- assert(!Object.prototype.hasOwnProperty.call(options, "valueRank"), "an objectType should not have a valueRank");
426
- assert(
427
- !Object.prototype.hasOwnProperty.call(options, "arrayDimensions"),
428
- "an objectType should not have a arrayDimensions"
429
- );
442
+ assert(!Object.hasOwn(options, "dataType"), "an objectType should not have a dataType");
443
+ assert(!Object.hasOwn(options, "valueRank"), "an objectType should not have a valueRank");
444
+ assert(!Object.hasOwn(options, "arrayDimensions"), "an objectType should not have a arrayDimensions");
430
445
  return this._addObjectOrVariableType(options, "BaseObjectType", NodeClass.ObjectType) as UAObjectType;
431
446
  }
432
447
 
@@ -446,7 +461,7 @@ export class NamespaceImpl implements NamespacePrivate {
446
461
  *
447
462
  */
448
463
  public addVariableType(options: AddVariableTypeOptions): UAVariableType {
449
- assert(!Object.prototype.hasOwnProperty.call(options, "arrayDimension"), "Do you mean ArrayDimensions ?");
464
+ assert(!Object.hasOwn(options, "arrayDimension"), "Do you mean ArrayDimensions ?");
450
465
 
451
466
  // dataType
452
467
  options.dataType = options.dataType || "Int32";
@@ -460,7 +475,7 @@ export class NamespaceImpl implements NamespacePrivate {
460
475
 
461
476
  variableType.dataType = options.dataType;
462
477
  variableType.valueRank = options.valueRank || 0;
463
- variableType.arrayDimensions = options.arrayDimensions!;
478
+ variableType.arrayDimensions = options.arrayDimensions || [];
464
479
 
465
480
  return variableType as UAVariableType;
466
481
  }
@@ -470,7 +485,7 @@ export class NamespaceImpl implements NamespacePrivate {
470
485
  */
471
486
  public addVariable(options: AddVariableOptions): UAVariable {
472
487
  assert(arguments.length === 1, "Invalid arguments IAddressSpace#addVariable now takes only one argument.");
473
- if (Object.prototype.hasOwnProperty.call(options, "propertyOf") && options.propertyOf) {
488
+ if (Object.hasOwn(options, "propertyOf") && options.propertyOf) {
474
489
  assert(!options.typeDefinition || options.typeDefinition === "PropertyType");
475
490
  options.typeDefinition = options.typeDefinition || "PropertyType";
476
491
  } else {
@@ -480,23 +495,21 @@ export class NamespaceImpl implements NamespacePrivate {
480
495
  }
481
496
 
482
497
  public addView(options: AddViewOptions): UAView {
483
- assert(arguments.length === 1, "Namespace#addView expecting a single argument");
484
- assert(options);
485
- assert(Object.prototype.hasOwnProperty.call(options, "browseName"));
486
- assert(Object.prototype.hasOwnProperty.call(options, "organizedBy"));
498
+ assert(Object.hasOwn(options, "browseName"));
499
+ assert(Object.hasOwn(options, "organizedBy"));
487
500
  const browseName = options.browseName;
488
501
  assert(typeof browseName === "string");
489
502
 
490
503
  const addressSpace = this.addressSpace;
491
- const baseDataVariableTypeId = addressSpace.findVariableType("BaseDataVariableType")!.nodeId;
504
+ const baseDataVariableTypeId = addressSpace.findVariableType("BaseDataVariableType")?.nodeId;
492
505
 
493
506
  // ------------------------------------------ TypeDefinition
494
- const typeDefinition = options.typeDefinition || baseDataVariableTypeId;
507
+ const _typeDefinition = options.typeDefinition || baseDataVariableTypeId;
495
508
  options.references = options.references || [];
496
509
 
497
510
  options.references.push({
498
511
  isForward: true,
499
- nodeId: typeDefinition,
512
+ nodeId: toNodeId(_typeDefinition) || NodeId.nullNodeId,
500
513
  referenceType: "HasTypeDefinition"
501
514
  });
502
515
 
@@ -504,7 +517,7 @@ export class NamespaceImpl implements NamespacePrivate {
504
517
  assert(!createOptions.nodeClass);
505
518
  createOptions.nodeClass = NodeClass.View;
506
519
 
507
- const view = this.createNode(createOptions)! as UAView;
520
+ const view = this.createNode(createOptions) as UAView;
508
521
  assert(view.nodeId instanceof NodeId);
509
522
  assert(view.nodeClass === NodeClass.View);
510
523
  return view;
@@ -537,7 +550,6 @@ export class NamespaceImpl implements NamespacePrivate {
537
550
  * @return {BaseNode}
538
551
  */
539
552
  public addFolder(parentFolder: UAObject, options: AddFolderOptions | string): UAObject {
540
-
541
553
  if (typeof options === "string") {
542
554
  options = { browseName: options };
543
555
  }
@@ -546,7 +558,7 @@ export class NamespaceImpl implements NamespacePrivate {
546
558
 
547
559
  assert(!(options as any).typeDefinition, "addFolder does not expect typeDefinition to be defined ");
548
560
  const typeDefinition = addressSpace._coerceTypeDefinition("FolderType");
549
- parentFolder = addressSpace._coerceFolder(parentFolder)! as UAObject;
561
+ parentFolder = addressSpace._coerceFolder(parentFolder) as UAObject;
550
562
  (options as any).nodeClass = NodeClass.Object;
551
563
  (options as any).references = [
552
564
  { referenceType: "HasTypeDefinition", isForward: true, nodeId: typeDefinition },
@@ -569,7 +581,7 @@ export class NamespaceImpl implements NamespacePrivate {
569
581
  const options1 = options as CreateNodeOptions;
570
582
  options1.nodeClass = NodeClass.ReferenceType;
571
583
  options1.references = options.references || [];
572
- options1.nodeId = options.nodeId!;
584
+ options1.nodeId = options.nodeId;
573
585
 
574
586
  if (options.subtypeOf) {
575
587
  const subtypeOfNodeId = addressSpace._coerceType(options.subtypeOf, "References", NodeClass.ReferenceType);
@@ -599,9 +611,9 @@ export class NamespaceImpl implements NamespacePrivate {
599
611
 
600
612
  */
601
613
  public createDataType(options: CreateDataTypeOptions): UADataType {
602
- assert(Object.prototype.hasOwnProperty.call(options, "isAbstract"), "must provide isAbstract");
603
- assert(!Object.prototype.hasOwnProperty.call(options, "nodeClass"));
604
- assert(Object.prototype.hasOwnProperty.call(options, "browseName"), "must provide a browseName");
614
+ assert(Object.hasOwn(options, "isAbstract"), "must provide isAbstract");
615
+ assert(!Object.hasOwn(options, "nodeClass"));
616
+ assert(Object.hasOwn(options, "browseName"), "must provide a browseName");
605
617
 
606
618
  const options1 = options as unknown as { nodeClass: NodeClass; references: AddReferenceOpts[]; subtypeOf: UADataType };
607
619
  options1.nodeClass = NodeClass.DataType;
@@ -648,7 +660,7 @@ export class NamespaceImpl implements NamespacePrivate {
648
660
  assert(isNonEmptyQualifiedName(options.browseName));
649
661
  // xx assert(Object.prototype.hasOwnProperty.call(options,"browseName") && options.browseName.length > 0);
650
662
 
651
- assert(Object.prototype.hasOwnProperty.call(options, "nodeClass"));
663
+ assert(Object.hasOwn(options, "nodeClass"));
652
664
  options.references = addressSpace.normalizeReferenceTypes(options.references);
653
665
 
654
666
  const references = _copy_references(options.references);
@@ -691,7 +703,7 @@ export class NamespaceImpl implements NamespacePrivate {
691
703
  node = this.findNode(nodeId);
692
704
  // c8 ignore next
693
705
  if (!node) {
694
- throw new Error(" deleteNode : cannot find node with nodeId" + nodeId.toString());
706
+ throw new Error(` deleteNode : cannot find node with nodeId${nodeId.toString()}`);
695
707
  }
696
708
  } else if (nodeOrNodeId instanceof BaseNodeImpl) {
697
709
  node = nodeOrNodeId;
@@ -713,13 +725,13 @@ export class NamespaceImpl implements NamespacePrivate {
713
725
  const hierarchicalReferences = node.findReferencesEx("HierarchicalReferences", BrowseDirection.Inverse);
714
726
  for (const ref of hierarchicalReferences) {
715
727
  assert(!ref.isForward);
716
- const parent = addressSpace.findNode(ref.nodeId)! as BaseNodeImpl;
728
+ const parent = addressSpace.findNode(ref.nodeId) as BaseNodeImpl;
717
729
  assert(parent);
718
730
  parent._on_child_removed(node);
719
731
  }
720
732
 
721
733
  function deleteNodePointedByReference(ref: { nodeId: NodeId }) {
722
- const o = addressSpace.findNode(ref.nodeId)! as BaseNode;
734
+ const o = addressSpace.findNode(ref.nodeId) as BaseNode;
723
735
  addressSpace.deleteNode(o.nodeId);
724
736
  }
725
737
 
@@ -760,10 +772,10 @@ export class NamespaceImpl implements NamespacePrivate {
760
772
  };
761
773
 
762
774
  for (const referenceType of this._referenceTypeMap.values()) {
763
- standardNodeIds.referenceTypeIds[referenceType!.browseName!.name!] = referenceType.nodeId.toString();
775
+ standardNodeIds.referenceTypeIds[referenceType?.browseName?.name as string] = referenceType.nodeId.toString();
764
776
  }
765
777
  for (const objectType of this._objectTypeMap.values()) {
766
- standardNodeIds.objectTypeIds[objectType!.browseName!.name!] = objectType.nodeId.toString();
778
+ standardNodeIds.objectTypeIds[objectType?.browseName?.name as string] = objectType.nodeId.toString();
767
779
  }
768
780
  return standardNodeIds;
769
781
  }
@@ -795,13 +807,13 @@ export class NamespaceImpl implements NamespacePrivate {
795
807
  options.subtypeOf = options.subtypeOf || "BaseEventType";
796
808
  // are eventType always abstract ?? No => Condition can be instantiated!
797
809
  // but, by default is abstract is true
798
- options.isAbstract = Object.prototype.hasOwnProperty.call(options, "isAbstract") ? !!options.isAbstract : true;
810
+ options.isAbstract = Object.hasOwn(options, "isAbstract") ? !!options.isAbstract : true;
799
811
  return this.addObjectType(options);
800
812
  }
801
813
 
802
814
  // ---------------------------------------------------------------------------------------------------
803
- /**
804
- *
815
+ /**
816
+ *
805
817
  */
806
818
  public addDataItem<T, DT extends DataType>(options: AddDataItemOptions): UADataItem<T, DT> {
807
819
  const addressSpace = this.addressSpace;
@@ -859,7 +871,7 @@ export class NamespaceImpl implements NamespacePrivate {
859
871
  public addAnalogDataItem<T, DT extends DataType>(options: AddAnalogDataItemOptions): UAAnalogItem<T, DT> {
860
872
  const addressSpace = this.addressSpace;
861
873
 
862
- assert(Object.prototype.hasOwnProperty.call(options, "engineeringUnitsRange"), "expecting engineeringUnitsRange");
874
+ assert(Object.hasOwn(options, "engineeringUnitsRange"), "expecting engineeringUnitsRange");
863
875
 
864
876
  const dataType = options.dataType || "Number";
865
877
 
@@ -904,7 +916,7 @@ export class NamespaceImpl implements NamespacePrivate {
904
916
  const handler = variable.handle_semantic_changed.bind(variable);
905
917
  euRange.on("value_changed", handler);
906
918
 
907
- if (Object.prototype.hasOwnProperty.call(options, "instrumentRange")) {
919
+ if (Object.hasOwn(options, "instrumentRange")) {
908
920
  const instrumentRange = this.addVariable({
909
921
  accessLevel: "CurrentRead | CurrentWrite",
910
922
  browseName: { name: "InstrumentRange", namespaceIndex: 0 },
@@ -923,7 +935,7 @@ export class NamespaceImpl implements NamespacePrivate {
923
935
  }
924
936
  (variable as any).acceptValueOutOfRange = options.acceptValueOutOfRange;
925
937
 
926
- if (Object.prototype.hasOwnProperty.call(options, "engineeringUnits")) {
938
+ if (Object.hasOwn(options, "engineeringUnits")) {
927
939
  const engineeringUnits = new EUInformation(options.engineeringUnits);
928
940
  assert(engineeringUnits instanceof EUInformation, "expecting engineering units");
929
941
 
@@ -1033,8 +1045,8 @@ export class NamespaceImpl implements NamespacePrivate {
1033
1045
  * @param options.value
1034
1046
  */
1035
1047
  public addYArrayItem<DT extends DataType.Double | DataType.Float>(options: AddYArrayItemOptions): UAYArrayItemEx<DT> {
1036
- assert(Object.prototype.hasOwnProperty.call(options, "engineeringUnitsRange"), "expecting engineeringUnitsRange");
1037
- assert(Object.prototype.hasOwnProperty.call(options, "axisScaleType"), "expecting axisScaleType");
1048
+ assert(Object.hasOwn(options, "engineeringUnitsRange"), "expecting engineeringUnitsRange");
1049
+ assert(Object.hasOwn(options, "axisScaleType"), "expecting axisScaleType");
1038
1050
  assert(options.xAxisDefinition !== null && typeof options.xAxisDefinition === "object", "expecting a xAxisDefinition");
1039
1051
 
1040
1052
  const addressSpace = this.addressSpace;
@@ -1044,18 +1056,9 @@ export class NamespaceImpl implements NamespacePrivate {
1044
1056
  throw new Error("expecting YArrayItemType to be defined , check nodeset xml file");
1045
1057
  }
1046
1058
 
1047
- function toNodeId(options?: NodeIdLike | BaseNode | string | null): NodeId {
1048
- if (!options) {
1049
- return resolveNodeId(DataType.Float);
1050
- }
1051
- if (Object.prototype.hasOwnProperty.call(options, "nodeId") || options instanceof BaseNodeImpl) {
1052
- return (options as UADataType).nodeId;
1053
- }
1054
- return resolveNodeId(options as NodeIdLike);
1055
- }
1056
- const dataType = toNodeId(options.dataType as any);
1059
+ const dataType = toNodeId(options.dataType as unknown as NodeId) || toNodeId((options.value as Variant)?.dataType);
1057
1060
  const optionals = [];
1058
- if (Object.prototype.hasOwnProperty.call(options, "instrumentRange")) {
1061
+ if (Object.hasOwn(options, "instrumentRange")) {
1059
1062
  optionals.push("InstrumentRange");
1060
1063
  }
1061
1064
  const variable = YArrayItemType.instantiate({
@@ -1080,7 +1083,7 @@ export class NamespaceImpl implements NamespacePrivate {
1080
1083
  })
1081
1084
  );
1082
1085
 
1083
- if (Object.prototype.hasOwnProperty.call(options, "instrumentRange") && variable.instrumentRange) {
1086
+ if (Object.hasOwn(options, "instrumentRange") && variable.instrumentRange) {
1084
1087
  variable.instrumentRange.setValueFromSource(
1085
1088
  new Variant({
1086
1089
  dataType: DataType.ExtensionObject,
@@ -1133,7 +1136,7 @@ export class NamespaceImpl implements NamespacePrivate {
1133
1136
  parentObject !== null && typeof parentObject === "object" && parentObject instanceof BaseNodeImpl,
1134
1137
  "expecting a valid parent object"
1135
1138
  );
1136
- assert(Object.prototype.hasOwnProperty.call(options, "browseName"));
1139
+ assert(Object.hasOwn(options, "browseName"));
1137
1140
  options.componentOf = parentObject;
1138
1141
 
1139
1142
  const method = this._addMethod(options);
@@ -1277,14 +1280,13 @@ export class NamespaceImpl implements NamespacePrivate {
1277
1280
  assert(Array.isArray(options.enumeration));
1278
1281
 
1279
1282
  const addressSpace = this.addressSpace;
1280
- let definition;
1281
- const enumerationType = addressSpace.findDataType("Enumeration")!;
1283
+ const enumerationType = addressSpace.findDataType("Enumeration") as UADataType;
1282
1284
  assert(enumerationType.nodeId instanceof NodeId);
1283
1285
  assert(enumerationType instanceof UADataTypeImpl);
1284
1286
  const references = [{ referenceType: "HasSubtype", isForward: false, nodeId: enumerationType.nodeId }];
1285
1287
  const opts = {
1286
1288
  browseName: options.browseName,
1287
- definition,
1289
+ definition: undefined,
1288
1290
  description: coerceLocalizedText(options.description) || null,
1289
1291
  displayName: options.displayName || null,
1290
1292
  isAbstract: false,
@@ -1299,7 +1301,7 @@ export class NamespaceImpl implements NamespacePrivate {
1299
1301
  if (typeof options.enumeration[0] === "string") {
1300
1302
  const enumeration = options.enumeration as string[];
1301
1303
  // enumeration is a array of string
1302
- definition = enumeration.map((str: string, index: number) => coerceLocalizedText(str));
1304
+ const definition = enumeration.map((str: string, _index: number) => coerceLocalizedText(str));
1303
1305
 
1304
1306
  const value = new Variant({
1305
1307
  arrayType: VariantArrayType.Array,
@@ -1341,7 +1343,7 @@ export class NamespaceImpl implements NamespacePrivate {
1341
1343
  } else {
1342
1344
  const enumeration = options.enumeration as EnumerationItem[];
1343
1345
  // construct the definition object
1344
- definition = enumeration.map((enumItem: EnumerationItem) => {
1346
+ const definition = enumeration.map((enumItem: EnumerationItem) => {
1345
1347
  return new EnumValueType({
1346
1348
  description: coerceLocalizedText(enumItem.description),
1347
1349
  displayName: coerceLocalizedText(enumItem.displayName),
@@ -1368,7 +1370,7 @@ export class NamespaceImpl implements NamespacePrivate {
1368
1370
 
1369
1371
  (enumType as any).$fullDefinition = new EnumDefinition({
1370
1372
  fields: enumeration.map(
1371
- (x: EnumerationItem, index: number) =>
1373
+ (x: EnumerationItem, _index: number) =>
1372
1374
  new EnumField({
1373
1375
  name: x.displayName.toString(),
1374
1376
 
@@ -1415,7 +1417,7 @@ export class NamespaceImpl implements NamespacePrivate {
1415
1417
  // State and Transition
1416
1418
  // -------------------------------------------------------------------------
1417
1419
  /**
1418
- */
1420
+ */
1419
1421
  public addState(
1420
1422
  component: UAStateMachineEx,
1421
1423
  stateName: QualifiedNameLike,
@@ -1469,30 +1471,30 @@ export class NamespaceImpl implements NamespacePrivate {
1469
1471
  assert(_component.nodeClass === NodeClass.Object || _component.nodeClass === NodeClass.ObjectType);
1470
1472
  assert(typeof fromState === "string");
1471
1473
  assert(typeof toState === "string");
1472
- assert(isFinite(transitionNumber));
1474
+ assert(Number.isFinite(transitionNumber));
1473
1475
 
1474
1476
  const fromStateNode = _component.getComponentByName(fromState);
1475
1477
 
1476
1478
  // c8 ignore next
1477
1479
  if (!fromStateNode) {
1478
- throw new Error("Cannot find state with name " + fromState);
1480
+ throw new Error(`Cannot find state with name ${fromState}`);
1479
1481
  }
1480
- assert(fromStateNode.browseName.name!.toString() === fromState);
1482
+ assert(fromStateNode.browseName.name?.toString() === fromState);
1481
1483
 
1482
1484
  const toStateNode = _component.getComponentByName(toState);
1483
1485
 
1484
1486
  // c8 ignore next
1485
1487
  if (!toStateNode) {
1486
- throw new Error("Cannot find state with name " + toState);
1488
+ throw new Error(`Cannot find state with name ${toState}`);
1487
1489
  }
1488
- assert(toStateNode.browseName.name!.toString() === toState);
1490
+ assert(toStateNode.browseName.name?.toString() === toState);
1489
1491
 
1490
1492
  const transitionType = addressSpace.findObjectType("TransitionType");
1491
1493
  if (!transitionType) {
1492
1494
  throw new Error("Cannot find TransitionType");
1493
1495
  }
1494
1496
 
1495
- browseName = browseName || fromState + "To" + toState; // "Transition";
1497
+ browseName = browseName || `${fromState}To${toState}`; // "Transition";
1496
1498
 
1497
1499
  const transition = transitionType.instantiate({
1498
1500
  browseName,
@@ -1643,16 +1645,16 @@ export class NamespaceImpl implements NamespacePrivate {
1643
1645
  if (node.nodeId.namespace !== this.index) {
1644
1646
  throw new Error(
1645
1647
  "node must belong to this namespace : " +
1646
- node.nodeId.toString() +
1647
- " " +
1648
- " node.browseName = " +
1649
- node.browseName.toString() +
1650
- " this.index = " +
1651
- this.index
1648
+ node.nodeId.toString() +
1649
+ " " +
1650
+ " node.browseName = " +
1651
+ node.browseName.toString() +
1652
+ " this.index = " +
1653
+ this.index
1652
1654
  );
1653
1655
  }
1654
1656
  assert(node.nodeId.namespace === this.index, "node must belongs to this namespace");
1655
- assert(Object.prototype.hasOwnProperty.call(node, "browseName"), "Node must have a browseName");
1657
+ assert(Object.hasOwn(node, "browseName"), "Node must have a browseName");
1656
1658
 
1657
1659
  const hashKey = _makeHashKey(node.nodeId);
1658
1660
 
@@ -1661,21 +1663,21 @@ export class NamespaceImpl implements NamespacePrivate {
1661
1663
  const existingNode = this.findNode(node.nodeId)!;
1662
1664
  throw new Error(
1663
1665
  "node " +
1664
- node.browseName.toString() +
1665
- " nodeId = " +
1666
- node.nodeId.displayText() +
1667
- " already registered " +
1668
- node.nodeId.toString() +
1669
- "\n" +
1670
- " in namespace " +
1671
- this.namespaceUri +
1672
- " index = " +
1673
- this.index +
1674
- "\n" +
1675
- "existing node = " +
1676
- existingNode.toString() +
1677
- "this parent : " +
1678
- node.parentNodeId?.toString()
1666
+ node.browseName.toString() +
1667
+ " nodeId = " +
1668
+ node.nodeId.displayText() +
1669
+ " already registered " +
1670
+ node.nodeId.toString() +
1671
+ "\n" +
1672
+ " in namespace " +
1673
+ this.namespaceUri +
1674
+ " index = " +
1675
+ this.index +
1676
+ "\n" +
1677
+ "existing node = " +
1678
+ existingNode.toString() +
1679
+ "this parent : " +
1680
+ node.parentNodeId?.toString()
1679
1681
  );
1680
1682
  }
1681
1683
 
@@ -1717,7 +1719,7 @@ export class NamespaceImpl implements NamespacePrivate {
1717
1719
  // ? (options.browseName.namespaceIndex === this.index): true,
1718
1720
  // "Expecting browseName to have the same namespaceIndex as the namespace");
1719
1721
 
1720
- options.description = coerceLocalizedText(options.description)!;
1722
+ options.description = coerceLocalizedText(options.description) || "";
1721
1723
 
1722
1724
  // browseName adjustment
1723
1725
  if (typeof options.browseName === "string") {
@@ -1738,15 +1740,15 @@ export class NamespaceImpl implements NamespacePrivate {
1738
1740
  errorLog(
1739
1741
  chalk.red.bold(
1740
1742
  "Error: namespace index used at the front of the browseName " +
1741
- indexVerify +
1742
- " do not match the index of the current namespace (" +
1743
- this.index +
1744
- ")"
1743
+ indexVerify +
1744
+ " do not match the index of the current namespace (" +
1745
+ this.index +
1746
+ ")"
1745
1747
  )
1746
1748
  );
1747
1749
  errorLog(
1748
1750
  " Please fix your code so that the created node is inserted in the correct namespace," +
1749
- " please refer to the NodeOPCUA documentation"
1751
+ " please refer to the NodeOPCUA documentation"
1750
1752
  );
1751
1753
  }
1752
1754
  }
@@ -1760,27 +1762,29 @@ export class NamespaceImpl implements NamespacePrivate {
1760
1762
  // ------------- set display name
1761
1763
  if (!options.displayName) {
1762
1764
  assert(typeof options.browseName.name === "string");
1763
- options.displayName = coerceLocalizedText(options.browseName.name)!;
1765
+ options.displayName = coerceLocalizedText(options.browseName.name || "");
1764
1766
  }
1765
- if (!options.nodeClass || options.nodeClass == undefined) {
1767
+ if (!options.nodeClass || options.nodeClass === undefined) {
1766
1768
  throw new Error("nodeclass must be specified");
1767
1769
  }
1768
1770
  // --- nodeId adjustment
1769
- options.nodeId = this.constructNodeId(options as ConstructNodeIdOptions)
1771
+ options.nodeId = this.constructNodeId(options as ConstructNodeIdOptions);
1770
1772
  dumpIf(!options.nodeId, options); // missing node Id
1771
1773
  assert(options.nodeId instanceof NodeId);
1772
1774
 
1773
1775
  // assert(options.browseName.namespaceIndex === this.index,"Expecting browseName to have
1774
1776
  // the same namespaceIndex as the namespace");
1775
1777
 
1776
- const Constructor = _constructors_map[NodeClass[options.nodeClass!]];
1778
+ const Constructor = _constructors_map[NodeClass[options.nodeClass] as keyof typeof _constructors_map];
1777
1779
 
1778
1780
  if (!Constructor) {
1779
- throw new Error(" missing constructor for NodeClass " + NodeClass[options.nodeClass!]);
1781
+ throw new Error(` missing constructor for NodeClass ${NodeClass[options.nodeClass]}`);
1780
1782
  }
1781
1783
 
1782
- options.addressSpace = this.addressSpace;
1783
- const node = new Constructor(options);
1784
+ options.addressSpace = this.addressSpace as AddressSpacePrivate;
1785
+
1786
+ // biome-ignore lint/suspicious/noExplicitAny: to fix later
1787
+ const node = new Constructor(options as any);
1784
1788
  this._register(node);
1785
1789
 
1786
1790
  // object shall now be registered
@@ -1797,7 +1801,7 @@ export class NamespaceImpl implements NamespacePrivate {
1797
1801
  const hashKey = _makeHashKey(node.nodeId);
1798
1802
  // c8 ignore next
1799
1803
  if (!this._nodeid_index.has(hashKey)) {
1800
- throw new Error("deleteNode : nodeId " + node.nodeId.displayText() + " is not registered " + node.nodeId.toString());
1804
+ throw new Error(`deleteNode : nodeId ${node.nodeId.displayText()} is not registered ${node.nodeId.toString()}`);
1801
1805
  }
1802
1806
  switch (node.nodeClass) {
1803
1807
  case NodeClass.ObjectType:
@@ -1823,7 +1827,7 @@ export class NamespaceImpl implements NamespacePrivate {
1823
1827
 
1824
1828
  // --- Private stuff
1825
1829
 
1826
- private _addObjectOrVariableType<T>(
1830
+ private _addObjectOrVariableType<_T>(
1827
1831
  options1: AddBaseNodeOptions,
1828
1832
  topMostBaseType: string,
1829
1833
  nodeClass: NodeClass.ObjectType | NodeClass.VariableType
@@ -1837,7 +1841,7 @@ export class NamespaceImpl implements NamespacePrivate {
1837
1841
  assert(!options.nodeClass);
1838
1842
  assert(options.browseName);
1839
1843
  assert(typeof options.browseName === "string");
1840
- if (Object.prototype.hasOwnProperty.call(options, "references")) {
1844
+ if (Object.hasOwn(options, "references")) {
1841
1845
  throw new Error("options.references should not be provided, use options.subtypeOf instead");
1842
1846
  }
1843
1847
  const references: UAReference[] = [];
@@ -1845,7 +1849,7 @@ export class NamespaceImpl implements NamespacePrivate {
1845
1849
  function process_subtypeOf_options(this: NamespaceImpl, options2: any, references1: AddReferenceOpts[]) {
1846
1850
  // check common misspelling mistake
1847
1851
  assert(!options2.subTypeOf, "misspell error : it should be 'subtypeOf' instead");
1848
- if (Object.prototype.hasOwnProperty.call(options2, "hasTypeDefinition")) {
1852
+ if (Object.hasOwn(options2, "hasTypeDefinition")) {
1849
1853
  throw new Error("hasTypeDefinition option is invalid. Do you mean typeDefinition instead ?");
1850
1854
  }
1851
1855
  assert(!options2.typeDefinition, " do you mean subtypeOf ?");
@@ -1901,16 +1905,16 @@ export class NamespaceImpl implements NamespacePrivate {
1901
1905
 
1902
1906
  private _registerObjectType(node: UAObjectType) {
1903
1907
  assert(this.index === node.nodeId.namespace);
1904
- const key = node.browseName.name!;
1908
+ const key = node.browseName.name || "";
1905
1909
  if (this._objectTypeMap.has(key)) {
1906
- throw new Error(" UAObjectType already declared " + node.browseName.toString() + " " + node.nodeId.toString());
1910
+ throw new Error(` UAObjectType already declared ${node.browseName.toString()} ${node.nodeId.toString()}`);
1907
1911
  }
1908
1912
  this._objectTypeMap.set(key, node);
1909
1913
  }
1910
1914
 
1911
1915
  private _registerVariableType(node: UAVariableType) {
1912
1916
  assert(this.index === node.nodeId.namespace);
1913
- const key = node.browseName.name!;
1917
+ const key = node.browseName.name || "";
1914
1918
  assert(!this._variableTypeMap.has(key), " UAVariableType already declared");
1915
1919
  this._variableTypeMap.set(key, node);
1916
1920
  }
@@ -1918,26 +1922,26 @@ export class NamespaceImpl implements NamespacePrivate {
1918
1922
  private _registerReferenceType(node: UAReferenceType) {
1919
1923
  assert(this.index === node.nodeId.namespace);
1920
1924
  assert(node.browseName instanceof QualifiedName);
1921
- const key: string = node.browseName.name!;
1925
+ const key: string = node.browseName.name || "";
1922
1926
  this._referenceTypeMap.set(key, node);
1923
- this._referenceTypeMapInv.set(node.inverseName.text!, node);
1927
+ this._referenceTypeMapInv.set(node.inverseName.text || "", node);
1924
1928
  }
1925
1929
 
1926
1930
  private _registerDataType(node: UADataType) {
1927
1931
  assert(this.index === node.nodeId.namespace);
1928
- const key = node.browseName.name!;
1932
+ const key = node.browseName.name || "";
1929
1933
  assert(node.browseName instanceof QualifiedName);
1930
1934
  assert(!this._dataTypeMap.has(key), " DataType already declared");
1931
1935
  this._dataTypeMap.set(key, node);
1932
1936
  }
1933
1937
 
1934
1938
  private _unregisterObjectType(node: UAObjectType): void {
1935
- const key = node.browseName.name!;
1939
+ const key = node.browseName.name || "";
1936
1940
  this._objectTypeMap.delete(key);
1937
1941
  }
1938
1942
 
1939
1943
  private _unregisterVariableType(node: UAVariableType): void {
1940
- const key = node.browseName.name!;
1944
+ const key = node.browseName.name || "";
1941
1945
  this._variableTypeMap.delete(key);
1942
1946
  }
1943
1947
 
@@ -1953,13 +1957,13 @@ export class NamespaceImpl implements NamespacePrivate {
1953
1957
  }
1954
1958
  const baseDataVariableTypeId = baseDataVariableType.nodeId;
1955
1959
 
1956
- assert(Object.prototype.hasOwnProperty.call(options, "browseName"), "options.browseName must be provided");
1957
- assert(Object.prototype.hasOwnProperty.call(options, "dataType"), "options.dataType must be provided");
1960
+ assert(Object.hasOwn(options, "browseName"), "options.browseName must be provided");
1961
+ assert(Object.hasOwn(options, "dataType"), "options.dataType must be provided");
1958
1962
 
1959
1963
  options.historizing = !!options.historizing;
1960
1964
 
1961
1965
  // c8 ignore next
1962
- if (Object.prototype.hasOwnProperty.call(options, "hasTypeDefinition")) {
1966
+ if (Object.hasOwn(options, "hasTypeDefinition")) {
1963
1967
  throw new Error("hasTypeDefinition option is invalid. Do you mean typeDefinition instead ?");
1964
1968
  }
1965
1969
  // ------------------------------------------ TypeDefinition
@@ -1976,14 +1980,14 @@ export class NamespaceImpl implements NamespacePrivate {
1976
1980
  assert(typeDefinition instanceof NodeId);
1977
1981
 
1978
1982
  // ------------------------------------------ DataType
1979
- options.dataType = addressSpace._coerce_DataType(options.dataType!);
1983
+ options.dataType = addressSpace._coerce_DataType(options.dataType || DataType.Null);
1980
1984
 
1981
1985
  options.valueRank = isNullOrUndefined(options.valueRank)
1982
1986
  ? options.arrayDimensions
1983
1987
  ? options.arrayDimensions.length
1984
1988
  : -1
1985
1989
  : options.valueRank;
1986
- assert(typeof options.valueRank === "number" && isFinite(options.valueRank!));
1990
+ assert(typeof options.valueRank === "number" && Number.isFinite(options.valueRank));
1987
1991
 
1988
1992
  options.arrayDimensions = options.arrayDimensions || null;
1989
1993
  assert(options.arrayDimensions === null || Array.isArray(options.arrayDimensions));
@@ -1999,7 +2003,7 @@ export class NamespaceImpl implements NamespacePrivate {
1999
2003
  warningLog(
2000
2004
  "[NODE-OPCUA-W30",
2001
2005
  "namespace#addVariable a getter has been specified and minimumSamplingInterval is missing.\nMinimumSamplingInterval has been adjusted to 1000 ms\nvariable = " +
2002
- options?.browseName?.toString()
2006
+ options?.browseName?.toString()
2003
2007
  );
2004
2008
  options.minimumSamplingInterval = 1000;
2005
2009
  }
@@ -2067,7 +2071,7 @@ export class NamespaceImpl implements NamespacePrivate {
2067
2071
  }
2068
2072
  }
2069
2073
 
2070
- const _constructors_map: any = {
2074
+ const _constructors_map: Record<keyof Omit<typeof NodeClass, "Unspecified">, typeof BaseNodeImpl> = {
2071
2075
  DataType: UADataTypeImpl,
2072
2076
  Method: UAMethodImpl,
2073
2077
  Object: UAObjectImpl,
@@ -2088,7 +2092,7 @@ const _constructors_map: any = {
2088
2092
  */
2089
2093
  function _coerce_parent(
2090
2094
  addressSpace: AddressSpacePrivate,
2091
- value: null | string | BaseNode| undefined | NodeIdLike,
2095
+ value: null | string | BaseNode | undefined | NodeIdLike,
2092
2096
  coerceFunc: (data: string | NodeId | BaseNode) => BaseNode | null
2093
2097
  ): BaseNode | null {
2094
2098
  assert(typeof coerceFunc === "function");
@@ -2129,8 +2133,18 @@ function _handle_event_hierarchy_parent(
2129
2133
  });
2130
2134
  }
2131
2135
  }
2132
-
2133
- export function _handle_hierarchy_parent(addressSpace: AddressSpacePrivate, references: AddReferenceOpts[], options: any): void {
2136
+ interface HandleHierarchyParentOptions {
2137
+ addInOf?: NodeIdLike | BaseNode | null | undefined;
2138
+ componentOf?: NodeIdLike | BaseNode | null | undefined;
2139
+ propertyOf?: NodeIdLike | BaseNode | null | undefined;
2140
+ organizedBy?: NodeIdLike | BaseNode | null | undefined;
2141
+ encodingOf?: NodeIdLike | BaseNode | null | undefined;
2142
+ }
2143
+ export function _handle_hierarchy_parent(
2144
+ addressSpace: AddressSpacePrivate,
2145
+ references: AddReferenceOpts[],
2146
+ options: HandleHierarchyParentOptions
2147
+ ): void {
2134
2148
  options.addInOf = _coerce_parent(addressSpace, options.addInOf, addressSpace._coerceNode);
2135
2149
  options.componentOf = _coerce_parent(addressSpace, options.componentOf, addressSpace._coerceNode);
2136
2150
  options.propertyOf = _coerce_parent(addressSpace, options.propertyOf, addressSpace._coerceNode);
@@ -2141,9 +2155,10 @@ export function _handle_hierarchy_parent(addressSpace: AddressSpacePrivate, refe
2141
2155
  assert(!options.componentOf);
2142
2156
  assert(!options.propertyOf);
2143
2157
  assert(!options.organizedBy);
2144
- assert(options.addInOf.nodeClass === NodeClass.Object || options.addInOf.nodeClass === NodeClass.ObjectType,
2158
+ assert(
2159
+ options.addInOf.nodeClass === NodeClass.Object || options.addInOf.nodeClass === NodeClass.ObjectType,
2145
2160
  "addInOf must be of nodeClass Object or ObjectType"
2146
- );
2161
+ );
2147
2162
  references.push({
2148
2163
  isForward: false,
2149
2164
  nodeId: options.addInOf.nodeId,
@@ -2192,7 +2207,7 @@ export function _handle_hierarchy_parent(addressSpace: AddressSpacePrivate, refe
2192
2207
  referenceType: "Organizes"
2193
2208
  });
2194
2209
  }
2195
-
2210
+
2196
2211
  if (options.encodingOf) {
2197
2212
  // parent must be a DataType
2198
2213
  assert(options.encodingOf.nodeClass === NodeClass.DataType, "encodingOf must be toward a DataType");
@@ -2205,9 +2220,9 @@ export function _handle_hierarchy_parent(addressSpace: AddressSpacePrivate, refe
2205
2220
  }
2206
2221
 
2207
2222
  function _copy_reference(reference: UAReference | AddReferenceOpts): AddReferenceOpts {
2208
- assert(Object.prototype.hasOwnProperty.call(reference, "referenceType"));
2209
- assert(Object.prototype.hasOwnProperty.call(reference, "isForward"));
2210
- assert(Object.prototype.hasOwnProperty.call(reference, "nodeId"));
2223
+ assert(Object.hasOwn(reference, "referenceType"));
2224
+ assert(Object.hasOwn(reference, "isForward"));
2225
+ assert(Object.hasOwn(reference, "nodeId"));
2211
2226
  assert(reference.nodeId instanceof NodeId);
2212
2227
  return {
2213
2228
  isForward: reference.isForward,
@@ -2232,12 +2247,12 @@ export function isNonEmptyQualifiedName(browseName: QualifiedNameLike): boolean
2232
2247
  browseName = new QualifiedName(browseName);
2233
2248
  }
2234
2249
  assert(browseName instanceof QualifiedName);
2235
- return browseName.name!.length > 0;
2250
+ return (browseName.name?.length || 0) > 0;
2236
2251
  }
2237
2252
 
2238
2253
  function _create_node_version_if_needed(node: BaseNode, options: { nodeVersion?: string }) {
2239
2254
  assert(options);
2240
- if (typeof options.nodeVersion == "string") {
2255
+ if (typeof options.nodeVersion === "string") {
2241
2256
  assert(node.nodeClass === NodeClass.Variable || node.nodeClass === NodeClass.Object);
2242
2257
  // c8 ignore next
2243
2258
  if (node.getNodeVersion()) {