node-opcua-address-space 2.123.0 → 2.125.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-address-space",
3
- "version": "2.123.0",
3
+ "version": "2.125.0",
4
4
  "description": "pure nodejs OPCUA SDK - module address-space",
5
5
  "main": "./dist/src/index_current.js",
6
6
  "types": "./dist/source/index.d.ts",
@@ -16,57 +16,57 @@
16
16
  "c": "mocha --version"
17
17
  },
18
18
  "dependencies": {
19
- "@types/lodash": "4.14.202",
19
+ "@types/lodash": "4.17.4",
20
20
  "@types/semver": "^7.5.8",
21
21
  "async": "^3.2.5",
22
22
  "chalk": "4.1.2",
23
23
  "dequeue": "^1.0.5",
24
24
  "lodash": "4.17.21",
25
- "node-opcua-address-space-base": "2.123.0",
25
+ "node-opcua-address-space-base": "2.125.0",
26
26
  "node-opcua-assert": "2.120.0",
27
- "node-opcua-basic-types": "2.121.0",
28
- "node-opcua-binary-stream": "2.120.0",
29
- "node-opcua-client-dynamic-extension-object": "2.123.0",
30
- "node-opcua-constants": "2.121.0",
27
+ "node-opcua-basic-types": "2.125.0",
28
+ "node-opcua-binary-stream": "2.125.0",
29
+ "node-opcua-client-dynamic-extension-object": "2.125.0",
30
+ "node-opcua-constants": "2.125.0",
31
31
  "node-opcua-crypto": "4.8.0",
32
- "node-opcua-data-access": "2.123.0",
33
- "node-opcua-data-model": "2.121.0",
34
- "node-opcua-data-value": "2.121.0",
35
- "node-opcua-date-time": "2.121.0",
36
- "node-opcua-debug": "2.121.0",
37
- "node-opcua-enum": "2.120.0",
38
- "node-opcua-extension-object": "2.121.0",
39
- "node-opcua-factory": "2.121.0",
40
- "node-opcua-nodeid": "2.121.0",
41
- "node-opcua-nodeset-ua": "2.123.0",
42
- "node-opcua-numeric-range": "2.121.0",
43
- "node-opcua-object-registry": "2.121.0",
44
- "node-opcua-pseudo-session": "2.123.0",
45
- "node-opcua-service-browse": "2.123.0",
46
- "node-opcua-service-call": "2.123.0",
47
- "node-opcua-service-history": "2.123.0",
48
- "node-opcua-service-translate-browse-path": "2.123.0",
49
- "node-opcua-service-write": "2.123.0",
50
- "node-opcua-status-code": "2.121.0",
51
- "node-opcua-types": "2.123.0",
52
- "node-opcua-utils": "2.120.0",
53
- "node-opcua-variant": "2.121.0",
54
- "node-opcua-xml2json": "2.123.0",
55
- "semver": "^7.6.0",
32
+ "node-opcua-data-access": "2.125.0",
33
+ "node-opcua-data-model": "2.125.0",
34
+ "node-opcua-data-value": "2.125.0",
35
+ "node-opcua-date-time": "2.125.0",
36
+ "node-opcua-debug": "2.125.0",
37
+ "node-opcua-enum": "2.125.0",
38
+ "node-opcua-extension-object": "2.125.0",
39
+ "node-opcua-factory": "2.125.0",
40
+ "node-opcua-nodeid": "2.125.0",
41
+ "node-opcua-nodeset-ua": "2.125.0",
42
+ "node-opcua-numeric-range": "2.125.0",
43
+ "node-opcua-object-registry": "2.125.0",
44
+ "node-opcua-pseudo-session": "2.125.0",
45
+ "node-opcua-service-browse": "2.125.0",
46
+ "node-opcua-service-call": "2.125.0",
47
+ "node-opcua-service-history": "2.125.0",
48
+ "node-opcua-service-translate-browse-path": "2.125.0",
49
+ "node-opcua-service-write": "2.125.0",
50
+ "node-opcua-status-code": "2.125.0",
51
+ "node-opcua-types": "2.125.0",
52
+ "node-opcua-utils": "2.125.0",
53
+ "node-opcua-variant": "2.125.0",
54
+ "node-opcua-xml2json": "2.125.0",
55
+ "semver": "^7.6.2",
56
56
  "set-prototype-of": "^1.0.0",
57
57
  "thenify": "^3.3.1",
58
58
  "xml-writer": "^1.7.0"
59
59
  },
60
60
  "devDependencies": {
61
- "mocha": "^10.3.0",
62
- "node-opcua-benchmarker": "2.120.0",
63
- "node-opcua-leak-detector": "2.121.0",
61
+ "mocha": "^10.4.0",
62
+ "node-opcua-benchmarker": "2.125.0",
63
+ "node-opcua-leak-detector": "2.125.0",
64
64
  "node-opcua-nodesets": "2.121.0",
65
- "node-opcua-packet-analyzer": "2.121.0",
66
- "node-opcua-service-filter": "2.123.0",
67
- "node-opcua-test-fixtures": "2.123.0",
65
+ "node-opcua-packet-analyzer": "2.125.0",
66
+ "node-opcua-service-filter": "2.125.0",
67
+ "node-opcua-test-fixtures": "2.125.0",
68
68
  "should": "^13.2.3",
69
- "sinon": "^17.0.1",
69
+ "sinon": "^18.0.0",
70
70
  "source-map-support": "^0.5.21"
71
71
  },
72
72
  "author": "Etienne Rossignon",
@@ -84,7 +84,7 @@
84
84
  "internet of things"
85
85
  ],
86
86
  "homepage": "http://node-opcua.github.io/",
87
- "gitHead": "64b4575687f6a8130e06fa78b6f61b6eeaa05e74",
87
+ "gitHead": "a0e0a2f1045e6e402dd4619c625c90008f0617ed",
88
88
  "files": [
89
89
  "dist",
90
90
  "distHelpers",
@@ -344,7 +344,9 @@ export class AddressSpace implements AddressSpacePrivate {
344
344
  }
345
345
  }
346
346
  }
347
- return resolveNodeId(nodeId);
347
+ const namespaceArray: string[] = this.getNamespaceArray().map((a)=>a.namespaceUri);
348
+
349
+ return resolveNodeId(nodeId, { namespaceArray });
348
350
  }
349
351
 
350
352
  /**
@@ -488,9 +490,9 @@ export class AddressSpace implements AddressSpacePrivate {
488
490
  if (!(dataTypeNode instanceof UADataTypeImpl)) {
489
491
  throw new Error(
490
492
  "we are expecting an UADataType here : " +
491
- _orig_dataTypeNode.toString() +
492
- " should not refer to a " +
493
- (dataTypeNode as BaseNode).browseName.name
493
+ _orig_dataTypeNode.toString() +
494
+ " should not refer to a " +
495
+ (dataTypeNode as BaseNode).browseName.name
494
496
  );
495
497
  }
496
498
 
@@ -783,18 +785,18 @@ export class AddressSpace implements AddressSpacePrivate {
783
785
  // tslint:disable:no-console
784
786
  errorLog(
785
787
  chalk.red("ERROR : AddressSpace#constructEventData(eventType,options) " + "cannot find property ") +
786
- self.browseName.toString() +
787
- " => " +
788
- chalk.cyan(lowerName)
788
+ self.browseName.toString() +
789
+ " => " +
790
+ chalk.cyan(lowerName)
789
791
  );
790
792
  } else {
791
793
  errorLog(
792
794
  chalk.yellow(
793
795
  "Warning : AddressSpace#constructEventData(eventType,options)" + " cannot find property "
794
796
  ) +
795
- self.browseName.toString() +
796
- " => " +
797
- chalk.cyan(lowerName)
797
+ self.browseName.toString() +
798
+ " => " +
799
+ chalk.cyan(lowerName)
798
800
  );
799
801
  }
800
802
  }
@@ -811,11 +813,11 @@ export class AddressSpace implements AddressSpacePrivate {
811
813
  if (!alreadyVisited(k)) {
812
814
  warningLog(
813
815
  "constructEventData: cannot find property '" +
814
- k +
815
- "' in [ " +
816
- Object.keys(visitedProperties).join(", ") +
817
- "] when filling " +
818
- eventTypeNode.browseName.toString()
816
+ k +
817
+ "' in [ " +
818
+ Object.keys(visitedProperties).join(", ") +
819
+ "] when filling " +
820
+ eventTypeNode.browseName.toString()
819
821
  );
820
822
  }
821
823
  });
@@ -1237,15 +1239,12 @@ export class AddressSpace implements AddressSpacePrivate {
1237
1239
  this._modelChangeTransactionCounter = this._modelChangeTransactionCounter || 0;
1238
1240
 
1239
1241
  function beginModelChange(this: AddressSpace) {
1240
- /* jshint validthis:true */
1241
- assert(this);
1242
1242
  this._modelChanges = this._modelChanges || [];
1243
1243
  assert(this._modelChangeTransactionCounter >= 0);
1244
1244
  this._modelChangeTransactionCounter += 1;
1245
1245
  }
1246
1246
 
1247
1247
  function endModelChange(this: AddressSpace) {
1248
- /* jshint validthis:true */
1249
1248
  this._modelChangeTransactionCounter -= 1;
1250
1249
 
1251
1250
  if (this._modelChangeTransactionCounter === 0) {
@@ -21,10 +21,9 @@ const verbFlags = new Enum({
21
21
  NodeDeleted: 0x02,
22
22
 
23
23
  // ReferenceAdded 2 Indicates a Reference has been added. The affected Node may
24
- ReferenceAdded: 0x04,
25
-
26
24
  // be either a SourceNode or TargetNode. Note that an added
27
25
  // bidirectional Reference is reflected by two ChangeStructures.
26
+ ReferenceAdded: 0x04,
28
27
  // ReferenceDeleted 3 Indicates a Reference has been deleted. The affected Node may
29
28
  // be either a SourceNode or TargetNode. Note that a deleted
30
29
  // bidirectional Reference is reflected by two ChangeStructures.
@@ -105,7 +104,7 @@ export function _handle_model_change_event(node: BaseNodeImpl): void {
105
104
 
106
105
  const containingFolders = node.findReferencesExAsObject("Organizes", BrowseDirection.Inverse);
107
106
 
108
- let typeDefinitionNodeId: NodeId | null = null;
107
+ let typeDefinitionNodeId: NodeId | null = null;
109
108
  if (node.nodeClass === NodeClass.Object || node.nodeClass === NodeClass.Variable) {
110
109
  typeDefinitionNodeId = node.typeDefinitionObj.nodeId;
111
110
  }
@@ -150,7 +149,7 @@ export function _handle_delete_node_model_change_event(node: BaseNode): void {
150
149
  return addressSpace.findNode(r.nodeId)! as BaseNode;
151
150
  });
152
151
 
153
- const versionableNodes = parentNodes.filter((n: BaseNode) => !!n?.nodeVersion);
152
+ const versionableNodes = parentNodes.filter((n: BaseNode) => !!n?.getChildByName("NodeVersion", 0));
154
153
 
155
154
  if (versionableNodes.length >= 1 || !!node.nodeVersion) {
156
155
  addressSpace.modelChangeTransaction(() => {
@@ -7,7 +7,7 @@ import chalk from "chalk";
7
7
  import { assert } from "node-opcua-assert";
8
8
  import { coerceInt64 } from "node-opcua-basic-types";
9
9
  import { AxisScaleEnumeration } from "node-opcua-data-access";
10
- import { AccessRestrictionsFlag, coerceLocalizedText, QualifiedNameLike } from "node-opcua-data-model";
10
+ import { AccessRestrictionsFlag, coerceLocalizedText, coerceQualifiedName, QualifiedNameLike } from "node-opcua-data-model";
11
11
  import { QualifiedName } from "node-opcua-data-model";
12
12
  import { BrowseDirection } from "node-opcua-data-model";
13
13
  import { NodeClass } from "node-opcua-data-model";
@@ -1655,7 +1655,15 @@ export class NamespaceImpl implements NamespacePrivate {
1655
1655
  assert(node.nodeId instanceof NodeId, "Expecting a NodeId");
1656
1656
  // istanbul ignore next
1657
1657
  if (node.nodeId.namespace !== this.index) {
1658
- throw new Error("node must belongs to this namespace");
1658
+ throw new Error(
1659
+ "node must belong to this namespace : " +
1660
+ node.nodeId.toString() +
1661
+ " " +
1662
+ " node.browseName = " +
1663
+ node.browseName.toString() +
1664
+ " this.index = " +
1665
+ this.index
1666
+ );
1659
1667
  }
1660
1668
  assert(node.nodeId.namespace === this.index, "node must belongs to this namespace");
1661
1669
  assert(Object.prototype.hasOwnProperty.call(node, "browseName"), "Node must have a browseName");
@@ -2000,7 +2008,8 @@ export class NamespaceImpl implements NamespacePrivate {
2000
2008
  // a getter has been specified and no options.minimumSamplingInterval has been specified
2001
2009
  warningLog(
2002
2010
  "[NODE-OPCUA-W30",
2003
- "namespace#addVariable a getter has been specified and minimumSamplingInterval is missing.\nMinimumSamplingInterval has been adjusted to 1000 ms\nvariable = "+ options?.browseName?.toString()
2011
+ "namespace#addVariable a getter has been specified and minimumSamplingInterval is missing.\nMinimumSamplingInterval has been adjusted to 1000 ms\nvariable = " +
2012
+ options?.browseName?.toString()
2004
2013
  );
2005
2014
  options.minimumSamplingInterval = 1000;
2006
2015
  }
@@ -2225,12 +2234,14 @@ function _create_node_version_if_needed(node: BaseNode, options: { nodeVersion:
2225
2234
  if (node.getChildByName("NodeVersion")) {
2226
2235
  return; // already exists
2227
2236
  }
2228
- const namespace = node.addressSpace.getOwnNamespace();
2237
+
2238
+ const namespace = node.namespace;
2229
2239
  const nodeVersion = namespace.addVariable({
2230
- browseName: "NodeVersion",
2231
- dataType: "String",
2240
+ browseName: coerceQualifiedName({ name: "NodeVersion", namespaceIndex: 0 }),
2241
+ dataType: DataType.String,
2232
2242
  propertyOf: node
2233
2243
  });
2244
+
2234
2245
  const initialValue = typeof options.nodeVersion === "string" ? options.nodeVersion : "0";
2235
2246
  nodeVersion.setValueFromSource({ dataType: "String", value: initialValue });
2236
2247
  }
@@ -403,14 +403,30 @@ export class UAVariableImpl extends BaseNodeImpl implements UAVariable {
403
403
  if (this._timestamped_get_func) {
404
404
  if (this._timestamped_get_func.length === 0) {
405
405
  const dataValueOrPromise = (this._timestamped_get_func as VariableDataValueGetterSync)();
406
- if (!Object.prototype.hasOwnProperty.call(dataValueOrPromise, "then")) {
406
+ if (!Object.prototype.hasOwnProperty.call(dataValueOrPromise.constructor.prototype, "then")) {
407
407
  if (dataValueOrPromise !== this.$dataValue) {
408
+ // we may have a problem here if we use a getter that returns a dataValue that is a ExtensionObject
409
+ if (dataValueOrPromise.value?.dataType === DataType.ExtensionObject) {
410
+ // eslint-disable-next-line max-depth
411
+ if (this.$extensionObject || this.$$extensionObjectArray) {
412
+ // we have an extension object already bound to this node
413
+ // the client is asking us to replace the object entirely by a new one
414
+ // const ext = dataValue.value.value;
415
+ this._internal_set_dataValue(dataValueOrPromise);
416
+ return dataValueOrPromise;
417
+ }
418
+ }
419
+
408
420
  // TO DO : is this necessary ? this may interfere with current use of $dataValue
409
421
  this.$dataValue = dataValueOrPromise as DataValue;
410
- this.verifyVariantCompatibility(this.$dataValue.value);
422
+ if (this.$dataValue.statusCode.isGoodish()) {
423
+ this.verifyVariantCompatibility(this.$dataValue.value);
424
+ }
411
425
  }
412
426
  } else {
413
- errorLog("Unsupported: _timestamped_get_func returns a Promise !");
427
+ errorLog(
428
+ "[NODE-OPCUA-E28] Unsupported: _timestamped_get_func returns a Promise ! , when the uaVariable has an async getter. Fix your application code."
429
+ );
414
430
  }
415
431
  }
416
432
  }
@@ -2099,7 +2115,7 @@ function _Variable_bind_with_simple_get(this: UAVariableImpl, options: GetterOpt
2099
2115
  !this.$dataValue.statusCode.isGoodish() ||
2100
2116
  !sameVariant(this.$dataValue.value, value as Variant)
2101
2117
  ) {
2102
- // rebuilding artificially timestamps with current clock as they are not provided
2118
+ // rebuilding artificially timestamps with current clock as they are not provided
2103
2119
  // by the underlying getter function
2104
2120
  const { timestamp: sourceTimestamp, picoseconds: sourcePicoseconds } = getCurrentClock();
2105
2121
  const serverTimestamp = sourceTimestamp;
@@ -108,7 +108,7 @@ export function _touchValue(property: UAVariableImpl, now: PreciseClock): void {
108
108
  property.$dataValue.sourcePicoseconds = now.picoseconds;
109
109
  property.$dataValue.serverTimestamp = now.timestamp;
110
110
  property.$dataValue.serverPicoseconds = now.picoseconds;
111
- property.$dataValue.statusCode = StatusCodes.Good;
111
+ // don't change statusCode ! property.$dataValue.statusCode = StatusCodes.Good;
112
112
  if (property.listenerCount("value_changed") > 0) {
113
113
  property.emit("value_changed", property.$dataValue.clone());
114
114
  }