node-opcua-address-space 2.164.2 → 2.165.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.
@@ -2,16 +2,10 @@
2
2
  /**
3
3
  * @module node-opcua-address-space
4
4
  */
5
- import { types } from "util";
6
- import chalk from "chalk";
7
- import semver from "semver";
8
5
 
9
- import {
10
- coerceByte,
11
- coerceBoolean,
12
- coerceInt32
13
- } from "node-opcua-basic-types";
14
- import {
6
+ import { types } from "node:util";
7
+ import chalk from "chalk";
8
+ import type {
15
9
  AddReferenceTypeOptions,
16
10
  BaseNode,
17
11
  CreateNodeOptions,
@@ -23,38 +17,33 @@ import {
23
17
  UAVariableType
24
18
  } from "node-opcua-address-space-base";
25
19
  import { assert, renderError } from "node-opcua-assert";
26
- import { StatusCodes } from "node-opcua-basic-types";
20
+ import { coerceBoolean, coerceByte, coerceInt32, StatusCodes } from "node-opcua-basic-types";
21
+ import { DataTypeIds } from "node-opcua-constants";
27
22
  import {
28
- AccessLevelFlag,
23
+ type AccessLevelFlag,
29
24
  coerceLocalizedText,
30
- LocalizedText,
25
+ type LocalizedText,
31
26
  makeAccessLevelFlag,
32
27
  NodeClass,
33
- QualifiedName,
28
+ type QualifiedName,
34
29
  stringToQualifiedName
35
30
  } from "node-opcua-data-model";
36
31
  import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";
32
+ import type { ExtensionObject } from "node-opcua-extension-object";
37
33
  import { getBuiltInType } from "node-opcua-factory";
38
34
  import { NodeId, resolveNodeId } from "node-opcua-nodeid";
39
- import { EnumFieldOptions } from "node-opcua-types";
40
- import { DataType, Variant, VariantArrayType, VariantOptions } from "node-opcua-variant";
41
- import {
42
- _definitionParser,
43
- ReaderState,
44
- ReaderStateParserLike,
45
- Xml2Json,
46
- XmlAttributes,
47
- } from "node-opcua-xml2json";
48
-
49
- import { AddressSpacePrivate } from "../../src/address_space_private";
50
- import { NamespacePrivate } from "../../src/namespace_private";
51
- import { NodeSetLoaderOptions } from "../interfaces/nodeset_loader_options";
52
- import { promoteObjectsAndVariables } from "./namespace_post_step";
35
+ import type { EnumFieldOptions } from "node-opcua-types";
36
+ import { DataType, Variant, VariantArrayType, type VariantOptions } from "node-opcua-variant";
37
+ import { _definitionParser, ReaderState, type ReaderStateParserLike, Xml2Json, type XmlAttributes } from "node-opcua-xml2json";
38
+ import semver from "semver";
39
+ import type { AddressSpacePrivate } from "../../src/address_space_private";
40
+ import type { NamespacePrivate } from "../../src/namespace_private";
41
+ import type { StructureFieldOptionsEx } from "../../src/ua_data_type_impl";
42
+ import type { NodeSetLoaderOptions } from "../interfaces/nodeset_loader_options";
53
43
  import { ensureDatatypeExtracted } from "./ensure_datatype_extracted";
54
44
  import { makeSemverCompatible } from "./make_semver_compatible";
45
+ import { promoteObjectsAndVariables } from "./namespace_post_step";
55
46
  import { makeVariantReader } from "./parsers/variant_parser";
56
- import { ExtensionObject } from "node-opcua-extension-object";
57
- import { StructureFieldOptionsEx } from "../../src/ua_data_type_impl";
58
47
 
59
48
  const doDebug = checkDebugFlag(__filename);
60
49
  const debugLog = make_debugLog(__filename);
@@ -97,7 +86,7 @@ function makeDefaultVariant(
97
86
  let variant: VariantOptions = { dataType: DataType.Null };
98
87
 
99
88
  const nodeDataType = addressSpace.findNode(dataTypeNode) as UADataType;
100
- if (nodeDataType && nodeDataType.basicDataType) {
89
+ if (nodeDataType?.basicDataType) {
101
90
  const basicDataType = nodeDataType.basicDataType;
102
91
  if (basicDataType === DataType.Variant) {
103
92
  /// we don't now what is the variant
@@ -162,7 +151,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
162
151
  const postTasks1_InitializeVariable: Task[] = [];
163
152
  const postTasks2_AssignedExtensionObjectToDataValue: Task[] = [];
164
153
 
165
- let aliasMap: Map<string, NodeId> = new Map();
154
+ const aliasMap: Map<string, NodeId> = new Map();
166
155
 
167
156
  /**
168
157
  * @param aliasName
@@ -175,9 +164,9 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
175
164
  addressSpace1.getNamespace(nodeId.namespace).addAlias(aliasName, nodeId);
176
165
  }
177
166
 
178
- let namespaceUriTranslationMap: Map<number, number> = new Map();
167
+ const namespaceUriTranslationMap: Map<number, number> = new Map();
179
168
  let namespaceCounter = 0;
180
- let foundNamespaceMap: Map<string, NamespacePrivate> = new Map();
169
+ const foundNamespaceMap: Map<string, NamespacePrivate> = new Map();
181
170
  let models: Model[] = [];
182
171
  let performedCalled = false;
183
172
 
@@ -197,7 +186,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
197
186
  // c8 ignore next
198
187
  if (namespaceIndex === undefined) {
199
188
  errorLog("Error; namespace_uri_translation", namespaceUriTranslationMap.entries());
200
- throw new Error("_translateNamespaceIndex() ! Cannot find namespace definition for index " + innerIndex);
189
+ throw new Error(`_translateNamespaceIndex() ! Cannot find namespace definition for index ${innerIndex}`);
201
190
  }
202
191
  return namespaceIndex;
203
192
  }
@@ -208,7 +197,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
208
197
  throw new Error("invalid param");
209
198
  } // already translated
210
199
 
211
- const namespace = addressSpace1.getNamespace(params.nodeId!.namespace);
200
+ const namespace = addressSpace1.getNamespace(params.nodeId?.namespace);
212
201
  namespace.addReferenceType(params);
213
202
  }
214
203
 
@@ -267,7 +256,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
267
256
  "is loaded first when loading",
268
257
  model.modelUri
269
258
  );
270
- throw new Error("LoadNodeSet : Cannot find namespace for " + requiredModel.modelUri);
259
+ throw new Error(`LoadNodeSet : Cannot find namespace for ${requiredModel.modelUri}`);
271
260
  }
272
261
  /**
273
262
  * from https://reference.opcfoundation.org/Core/docs/Part6/F.2/
@@ -323,13 +312,15 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
323
312
  function _translateNodeId(nodeId: string): NodeId {
324
313
  if (aliasMap.has(nodeId)) {
325
314
  // note alias are already translated to the right namespaces
326
- const aliasedNodeId = aliasMap.get(nodeId)!;
327
- return aliasedNodeId;
315
+ const aliasedNodeId = aliasMap.get(nodeId);
316
+ if (aliasedNodeId) {
317
+ return aliasedNodeId;
318
+ }
328
319
  }
329
320
  const m = nodeId.match(reg);
330
321
  if (m) {
331
322
  const namespaceIndex = _translateNamespaceIndex(parseInt(m[1], 10));
332
- nodeId = "ns=" + namespaceIndex + ";" + m[2];
323
+ nodeId = `ns=${namespaceIndex};${m[2]}`;
333
324
  }
334
325
  return resolveNodeId(nodeId);
335
326
  }
@@ -366,21 +357,24 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
366
357
  }
367
358
 
368
359
  const state_Alias = {
360
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
369
361
  finish(this: any) {
370
362
  addAlias(this.attrs.Alias, this.text);
371
363
  }
372
364
  };
373
365
 
374
366
  const references_parser = {
367
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
375
368
  init(this: any) {
376
369
  this.parent.obj.references = [];
377
370
  this.array = this.parent.obj.references;
378
371
  },
379
372
  parser: {
380
373
  Reference: {
374
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
381
375
  finish(this: any) {
382
376
  this.parent.array.push({
383
- isForward: this.attrs.IsForward === undefined ? true : this.attrs.IsForward === "false" ? false : true,
377
+ isForward: this.attrs.IsForward === undefined ? true : this.attrs.IsForward !== "false",
384
378
  nodeId: convertToNodeId(this.text),
385
379
  referenceType: _translateReferenceType(this.attrs.ReferenceType)
386
380
  });
@@ -390,7 +384,8 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
390
384
  };
391
385
  // #region UAObject
392
386
  const state_UAObject = {
393
- init(this: any, name: string, attrs: XmlAttributes) {
387
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
388
+ init(this: any, _name: string, attrs: XmlAttributes) {
394
389
  _perform();
395
390
 
396
391
  this.obj = {
@@ -405,6 +400,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
405
400
  this.isDraft = attrs.ReleaseStatus === "Draft";
406
401
  this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
407
402
  },
403
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
408
404
  finish(this: any) {
409
405
  if (canIgnore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
410
406
  return;
@@ -413,12 +409,14 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
413
409
  },
414
410
  parser: {
415
411
  DisplayName: {
412
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
416
413
  finish(this: any) {
417
414
  this.parent.obj.displayName = this.text;
418
415
  }
419
416
  },
420
417
 
421
418
  Description: {
419
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
422
420
  finish(this: any) {
423
421
  this.parent.obj.description = this.text;
424
422
  }
@@ -430,7 +428,8 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
430
428
  // #endregion
431
429
  // #region UAObjectType
432
430
  const state_UAObjectType = {
433
- init(this: any, name: string, attrs: XmlAttributes) {
431
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
432
+ init(this: any, _name: string, attrs: XmlAttributes) {
434
433
  _perform();
435
434
 
436
435
  this.obj = {
@@ -441,17 +440,20 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
441
440
  eventNotifier: coerceByte(attrs.EventNotifier) || 0
442
441
  };
443
442
  },
443
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
444
444
  finish(this: any) {
445
445
  _internal_createNode(this.obj);
446
446
  },
447
447
  parser: {
448
448
  DisplayName: {
449
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
449
450
  finish(this: any) {
450
451
  this.parent.obj.displayName = this.text;
451
452
  }
452
453
  },
453
454
 
454
455
  Description: {
456
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
455
457
  finish(this: any) {
456
458
  this.parent.obj.description = this.text;
457
459
  }
@@ -463,7 +465,8 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
463
465
  // #endregion
464
466
  // #region UAReferenceType
465
467
  const state_UAReferenceType = {
466
- init(this: any, name: string, attrs: XmlAttributes) {
468
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
469
+ init(this: any, _name: string, attrs: XmlAttributes) {
467
470
  _perform();
468
471
 
469
472
  this.obj = {
@@ -473,23 +476,27 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
473
476
  browseName: convertQualifiedName(attrs.BrowseName)
474
477
  };
475
478
  },
479
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
476
480
  finish(this: any) {
477
481
  _internal_addReferenceType(this.obj);
478
482
  },
479
483
  parser: {
480
484
  DisplayName: {
485
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
481
486
  finish(this: any) {
482
487
  this.parent.obj.displayName = this.text;
483
488
  }
484
489
  },
485
490
 
486
491
  Description: {
492
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
487
493
  finish(this: any) {
488
494
  this.parent.obj.description = this.text;
489
495
  }
490
496
  },
491
497
 
492
498
  InverseName: {
499
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
493
500
  finish(this: any) {
494
501
  this.parent.obj.inverseName = this.text;
495
502
  }
@@ -499,23 +506,23 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
499
506
  };
500
507
 
501
508
  interface StateUADataType extends ReaderState {
502
- obj: Partial<CreateNodeOptions> & {
509
+ obj: Partial<CreateNodeOptions> & {
503
510
  browseName: QualifiedName;
504
511
  nodeClass: NodeClass.DataType;
505
- symbolicName : string | null,
512
+ symbolicName: string | null;
506
513
  partialDefinition: StructureFieldOptionsEx[] | EnumFieldOptions[];
507
514
  };
508
515
  isDraft: boolean;
509
516
  isDeprecated: boolean;
510
517
  nodeId: NodeId;
511
518
  definitionFields: StructureFieldOptionsEx[] | EnumFieldOptions[];
512
- };
519
+ }
513
520
 
514
521
  // #endregion
515
522
  // #region UADataType
516
- const pendingSimpleTypeToRegister: any[] = [];
523
+ const pendingSimpleTypeToRegister: { name: string; dataTypeNodeId: NodeId }[] = [];
517
524
  const state_UADataType = {
518
- init(this: StateUADataType, name: string, attrs: XmlAttributes) {
525
+ init(this: StateUADataType, _name: string, attrs: XmlAttributes) {
519
526
  _perform();
520
527
 
521
528
  this.obj = {
@@ -535,15 +542,15 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
535
542
  this.definitionFields = [];
536
543
  },
537
544
  finish(this: StateUADataType) {
538
-
539
545
  if (canIgnore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
540
546
  return;
541
547
  }
542
548
 
543
- const definitionFields = this.definitionFields as StructureFieldOptionsEx[] | EnumFieldOptions[];
544
-
549
+ const definitionFields = this.definitionFields as StructureFieldOptionsEx[] | EnumFieldOptions[];
550
+
545
551
  // replace DataType with nodeId, and description to LocalizedText
546
- definitionFields.forEach((x: any) => {
552
+ // biome-ignore lint/suspicious/noExplicitAny: fields transition from raw XML strings to typed objects
553
+ for (const x of definitionFields as any[]) {
547
554
  if (x.description) {
548
555
  x.description = { text: x.description };
549
556
  }
@@ -552,26 +559,27 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
552
559
  }
553
560
  if (x.dataType) {
554
561
  x.dataType = convertToNodeId(x.dataType);
562
+ } else {
563
+ x.dataType = resolveNodeId(DataTypeIds.BaseDataType);
555
564
  }
556
565
  if (x.allowSubTypes) {
557
566
  x.allowSubTypes = coerceBoolean(x.allowSubTypes);
558
567
  }
559
- return x;
560
- });
561
-
568
+ }
562
569
 
563
570
  this.obj.partialDefinition = definitionFields;
564
571
 
565
- let capturedDataTypeNode = _internal_createNode(this.obj) as UADataType;
566
- const processBasicDataType = async (addressSpace2: IAddressSpace) => {
567
- const definitionName = capturedDataTypeNode.browseName.name!;
572
+ let capturedDataTypeNode: UADataType | undefined = _internal_createNode(this.obj) as UADataType;
573
+ const processBasicDataType = async (_addressSpace2: IAddressSpace) => {
574
+ if (!capturedDataTypeNode) return;
575
+ const definitionName = capturedDataTypeNode.browseName.name || "";
568
576
  const isStructure = capturedDataTypeNode.isStructure();
569
577
  const isEnumeration = capturedDataTypeNode.isEnumeration();
570
578
  if (!isEnumeration && !isStructure && capturedDataTypeNode.nodeId.namespace !== 0) {
571
579
  // add a custom basic type that is not a structure nor a enumeration
572
580
  pendingSimpleTypeToRegister.push({ name: definitionName, dataTypeNodeId: capturedDataTypeNode.nodeId });
573
581
  }
574
- (capturedDataTypeNode as any) = undefined;
582
+ capturedDataTypeNode = undefined;
575
583
  };
576
584
  postTasks.push(processBasicDataType);
577
585
  },
@@ -610,12 +618,13 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
610
618
 
611
619
  function fixExtensionObjectAndArray(obj: { nodeId: NodeId }, deferred: () => ExtensionObject | ExtensionObject[] | null) {
612
620
  // let's create the mechanism that postpone the assignment of the extension object
613
- let capturedNode = obj;
621
+ const capturedNode = obj;
614
622
  const task = async (addressSpace2: IAddressSpace) => {
615
623
  const extensionObjOrArray = deferred();
616
- let nodeId = capturedNode.nodeId;
624
+ const nodeId = capturedNode.nodeId;
617
625
  assert(nodeId, "expecting a nodeid");
618
- const node = addressSpace2.findNode(nodeId)!;
626
+ const node = addressSpace2.findNode(nodeId);
627
+ if (!node) return;
619
628
 
620
629
  if (node.nodeClass === NodeClass.Variable) {
621
630
  const v = node as UAVariable;
@@ -625,7 +634,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
625
634
  }
626
635
  } else if (node.nodeClass === NodeClass.VariableType) {
627
636
  const v = node as UAVariableType;
628
- (v as any) /*fix me*/.value.value = extensionObjOrArray;
637
+ (v as unknown as { value: { value: unknown } }).value.value = extensionObjOrArray;
629
638
  }
630
639
  };
631
640
  postTasks2_AssignedExtensionObjectToDataValue.push(task);
@@ -651,7 +660,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
651
660
  type ReaderUAVariableL2 = ReaderStateParserLike & { parent: ReaderUAVariableL1; text: string };
652
661
 
653
662
  const state_UAVariable = {
654
- init(this: ReaderUAVariableL1, name: string, attrs: XmlAttributes) {
663
+ init(this: ReaderUAVariableL1, _name: string, attrs: XmlAttributes) {
655
664
  _perform();
656
665
 
657
666
  const valueRank = attrs.ValueRank === undefined ? -1 : coerceInt32(attrs.ValueRank);
@@ -690,16 +699,18 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
690
699
  }
691
700
  */
692
701
  // eslint-disable-next-line prefer-const
693
- let capturedVariable: UAVariable;
702
+ let capturedVariable: UAVariable | undefined;
694
703
  if (this.obj.value && this.obj.value.dataType !== DataType.Null) {
695
- let capturedValue: any | undefined = this.obj.value;
696
- const task = async (addressSpace2: IAddressSpace) => {
704
+ let capturedValue: VariantOptions | undefined = this.obj.value;
705
+ const task = async (_addressSpace2: IAddressSpace) => {
706
+ if (!capturedVariable) return;
707
+ const cv = capturedVariable;
697
708
  if (false && doDebug) {
698
- debugLog("1 setting value to ", capturedVariable.nodeId.toString(), new Variant(capturedValue).toString());
709
+ debugLog("1 setting value to ", cv.nodeId.toString(), new Variant(capturedValue).toString());
699
710
  }
700
- capturedVariable.setValueFromSource(capturedValue);
711
+ cv.setValueFromSource(capturedValue as VariantOptions);
701
712
  capturedValue = undefined;
702
- (capturedVariable as any) = undefined;
713
+ capturedVariable = undefined;
703
714
  };
704
715
  if (capturedValue.dataType !== DataType.ExtensionObject) {
705
716
  postTasks0_InitializeVariable.push(task);
@@ -708,23 +719,25 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
708
719
  postTasks1_InitializeVariable.push(task);
709
720
  }
710
721
  } else {
711
- const task = async (addressSpace2: IAddressSpace) => {
712
- const dataTypeNode = capturedVariable.dataType;
713
- const valueRank = capturedVariable.valueRank;
714
- const arrayDimensions = capturedVariable.arrayDimensions;
722
+ const task = async (_addressSpace2: IAddressSpace) => {
723
+ if (!capturedVariable) return;
724
+ const cv = capturedVariable;
725
+ const dataTypeNode = cv.dataType;
726
+ const valueRank = cv.valueRank;
727
+ const arrayDimensions = cv.arrayDimensions;
715
728
 
716
729
  const value = makeDefaultVariant(addressSpace, dataTypeNode, valueRank, arrayDimensions);
717
730
  if (value) {
718
731
  if (false && doDebug) {
719
- debugLog("2 setting value to ", capturedVariable.nodeId.toString(), value);
732
+ debugLog("2 setting value to ", cv.nodeId.toString(), value);
720
733
  }
721
734
  if (value.dataType === DataType.Null) {
722
- capturedVariable.setValueFromSource(value, StatusCodes.BadWaitingForInitialData);
735
+ cv.setValueFromSource(value, StatusCodes.BadWaitingForInitialData);
723
736
  } else {
724
- capturedVariable.setValueFromSource(value, StatusCodes.Good);
737
+ cv.setValueFromSource(value, StatusCodes.Good);
725
738
  }
726
739
  }
727
- (capturedVariable as any) = undefined;
740
+ capturedVariable = undefined;
728
741
  };
729
742
  postTasks0_InitializeVariable.push(task);
730
743
  }
@@ -734,13 +747,13 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
734
747
  parser: {
735
748
  DisplayName: {
736
749
  finish(this: ReaderUAVariableL2) {
737
- this.parent.obj.displayName = coerceLocalizedText(this.text)!;
750
+ this.parent.obj.displayName = coerceLocalizedText(this.text) ?? undefined;
738
751
  }
739
752
  },
740
753
 
741
754
  Description: {
742
755
  finish(this: ReaderUAVariableL2) {
743
- this.parent.obj.description = coerceLocalizedText(this.text)!;
756
+ this.parent.obj.description = coerceLocalizedText(this.text) ?? undefined;
744
757
  }
745
758
  },
746
759
  References: references_parser,
@@ -751,7 +764,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
751
764
  },
752
765
  (self: ReaderUAVariableL2, data: VariantOptions, deferredTask) => {
753
766
  self.parent.obj.value = data;
754
- const capturedVariable = { nodeId: self.parent.obj.nodeId! };
767
+ const capturedVariable = { nodeId: self.parent.obj.nodeId ?? NodeId.nullNodeId };
755
768
  fixExtensionObjectAndArray(capturedVariable, deferredTask);
756
769
  },
757
770
  (task) => {
@@ -769,7 +782,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
769
782
  type ReaderUAVariableTypeL1 = ReaderStateParserLike & { obj: IUAVariableTypeProps; isDraft: boolean; isDeprecated: boolean };
770
783
  type ReaderUAVariableTypeL2 = ReaderStateParserLike & { parent: ReaderUAVariableTypeL1; text: string };
771
784
  const state_UAVariableType = {
772
- init(this: ReaderUAVariableTypeL1, name: string, attrs: XmlAttributes) {
785
+ init(this: ReaderUAVariableTypeL1, _name: string, attrs: XmlAttributes) {
773
786
  _perform();
774
787
  const valueRank = coerceInt32(attrs.ValueRank) || -1;
775
788
  this.obj = {
@@ -797,13 +810,13 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
797
810
  parser: {
798
811
  DisplayName: {
799
812
  finish(this: ReaderUAVariableTypeL2) {
800
- this.parent.obj.displayName = coerceLocalizedText(this.text || "")!;
813
+ this.parent.obj.displayName = coerceLocalizedText(this.text || "") ?? undefined;
801
814
  }
802
815
  },
803
816
 
804
817
  Description: {
805
818
  finish(this: ReaderUAVariableTypeL2) {
806
- this.parent.obj.description = coerceLocalizedText(this.text || "")!;
819
+ this.parent.obj.description = coerceLocalizedText(this.text || "") ?? undefined;
807
820
  }
808
821
  },
809
822
  References: references_parser,
@@ -813,7 +826,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
813
826
  },
814
827
  (self: ReaderUAVariableTypeL2, data: VariantOptions, deferredTask) => {
815
828
  self.parent.obj.value = data;
816
- const capturedVariable = { nodeId: self.parent.obj.nodeId! };
829
+ const capturedVariable = { nodeId: self.parent.obj.nodeId ?? NodeId.nullNodeId };
817
830
  fixExtensionObjectAndArray(capturedVariable, deferredTask);
818
831
  },
819
832
  (task) => {
@@ -826,7 +839,8 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
826
839
  // #endregion
827
840
  // #region UAMethod
828
841
  const state_UAMethod = {
829
- init(this: any, name: string, attrs: XmlAttributes) {
842
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
843
+ init(this: any, _name: string, attrs: XmlAttributes) {
830
844
  _perform();
831
845
 
832
846
  this.obj = {
@@ -841,6 +855,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
841
855
  this.isDraft = attrs.ReleaseStatus === "Draft";
842
856
  this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
843
857
  },
858
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
844
859
  finish(this: any) {
845
860
  if (canIgnore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
846
861
  return;
@@ -849,6 +864,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
849
864
  },
850
865
  parser: {
851
866
  DisplayName: {
867
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
852
868
  finish(this: any) {
853
869
  this.parent.obj.displayName = this.text;
854
870
  }
@@ -870,23 +886,27 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
870
886
  const state_ModelTableEntry = new ReaderState({
871
887
  // ModelTableEntry
872
888
 
889
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
873
890
  init(this: any) {
874
891
  this._requiredModels = [] as RequiredModel[];
875
892
  },
876
893
  parser: {
877
894
  RequiredModel: {
878
- init(this: any, name: string, attrs: XmlAttributes) {
895
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
896
+ init(this: any, _name: string, attrs: XmlAttributes) {
879
897
  const modelUri = attrs.ModelUri;
880
898
  const version = attrs.Version;
881
899
  const publicationDate = new Date(Date.parse(attrs.PublicationDate));
882
900
 
883
901
  this.parent._requiredModels.push({ modelUri, version, publicationDate });
884
902
  },
903
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
885
904
  finish(this: any) {
886
905
  /** */
887
906
  }
888
907
  }
889
908
  },
909
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
890
910
  finish(this: any) {
891
911
  const modelUri = this.attrs.ModelUri; // //"http://opcfoundation.org/UA/"
892
912
  const version = this.attrs.Version; // 1.04
@@ -903,7 +923,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
903
923
  symbolicName,
904
924
  version
905
925
  };
906
- const namespace = _add_namespace(model);
926
+ const _namespace = _add_namespace(model);
907
927
  models.push(model);
908
928
  }
909
929
  });
@@ -941,6 +961,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
941
961
  const state_0: ReaderStateParserLike = {
942
962
  parser: {
943
963
  Aliases: {
964
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
944
965
  init(this: any) {
945
966
  _perform();
946
967
  },
@@ -948,17 +969,20 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
948
969
  },
949
970
 
950
971
  NamespaceUris: {
972
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
951
973
  init(this: any) {
952
974
  //
953
975
  _namespaceUris = [];
954
976
  },
955
977
  parser: {
956
978
  Uri: {
979
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
957
980
  finish(this: any) {
958
981
  _namespaceUris.push(this.text);
959
982
  }
960
983
  }
961
984
  },
985
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
962
986
  finish(this: any) {
963
987
  // verify that requested namespaces are already loaded or abort with a message
964
988
  }
@@ -966,13 +990,15 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
966
990
 
967
991
  Models: {
968
992
  // ModelTable
969
- init(this: any, name: string, attrs: XmlAttributes) {
993
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
994
+ init(this: any, _name: string, _attrs: XmlAttributes) {
970
995
  /* */
971
996
  },
972
997
  parser: {
973
998
  Model: state_ModelTableEntry
974
999
  },
975
1000
 
1001
+ // biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
976
1002
  finish(this: any) {
977
1003
  /** */
978
1004
  }
@@ -1048,11 +1074,11 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
1048
1074
  /// ----------------------------------------------------------------------------------------
1049
1075
  doDebug && debugLog(chalk.bgGreenBright("DataType extraction done ") + chalk.green("DONE"));
1050
1076
 
1051
- for (const { name, dataTypeNodeId } of pendingSimpleTypeToRegister) {
1077
+ for (const { name: _name, dataTypeNodeId } of pendingSimpleTypeToRegister) {
1052
1078
  if (dataTypeNodeId.namespace === 0) {
1053
1079
  continue;
1054
1080
  }
1055
- const dataTypeFactory = dataTypeManager.getDataTypeFactoryForNamespace(dataTypeNodeId.namespace);
1081
+ dataTypeManager.getDataTypeFactoryForNamespace(dataTypeNodeId.namespace);
1056
1082
  }
1057
1083
  pendingSimpleTypeToRegister.splice(0);
1058
1084
 
@@ -1089,10 +1115,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
1089
1115
 
1090
1116
  export class NodeSetLoader {
1091
1117
  _s: NodeSet2ParserEngine;
1092
- constructor(
1093
- addressSpace: IAddressSpace,
1094
- private options?: NodeSetLoaderOptions
1095
- ) {
1118
+ constructor(addressSpace: IAddressSpace, options?: NodeSetLoaderOptions) {
1096
1119
  this._s = makeNodeSetParserEngine(addressSpace, options || {});
1097
1120
  }
1098
1121