node-opcua-address-space 2.176.0 → 2.178.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.176.0",
3
+ "version": "2.178.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",
@@ -18,38 +18,38 @@
18
18
  "fix:tsconfig": "node ../../code_gen/extract-modules.js tsconfig_base.json"
19
19
  },
20
20
  "dependencies": {
21
- "@types/semver": "7.7.1",
21
+ "@types/semver": "7.8.0",
22
22
  "chalk": "4.1.2",
23
23
  "dequeue": "^1.0.5",
24
- "node-opcua-address-space-base": "2.176.0",
24
+ "node-opcua-address-space-base": "2.178.0",
25
25
  "node-opcua-assert": "2.175.6",
26
- "node-opcua-basic-types": "2.176.0",
26
+ "node-opcua-basic-types": "2.177.0",
27
27
  "node-opcua-binary-stream": "2.176.0",
28
- "node-opcua-client-dynamic-extension-object": "2.176.0",
28
+ "node-opcua-client-dynamic-extension-object": "2.178.0",
29
29
  "node-opcua-constants": "2.176.0",
30
- "node-opcua-crypto": "5.4.0",
31
- "node-opcua-data-access": "2.176.0",
32
- "node-opcua-data-model": "2.176.0",
33
- "node-opcua-data-value": "2.176.0",
30
+ "node-opcua-crypto": "5.6.0",
31
+ "node-opcua-data-access": "2.177.0",
32
+ "node-opcua-data-model": "2.177.0",
33
+ "node-opcua-data-value": "2.177.0",
34
34
  "node-opcua-date-time": "2.176.0",
35
35
  "node-opcua-debug": "2.175.6",
36
36
  "node-opcua-enum": "2.176.0",
37
- "node-opcua-extension-object": "2.176.0",
38
- "node-opcua-factory": "2.176.0",
39
- "node-opcua-nodeid": "2.176.0",
40
- "node-opcua-nodeset-ua": "2.176.0",
41
- "node-opcua-numeric-range": "2.176.0",
37
+ "node-opcua-extension-object": "2.177.0",
38
+ "node-opcua-factory": "2.177.0",
39
+ "node-opcua-nodeid": "2.177.0",
40
+ "node-opcua-nodeset-ua": "2.178.0",
41
+ "node-opcua-numeric-range": "2.177.0",
42
42
  "node-opcua-object-registry": "2.175.6",
43
- "node-opcua-pseudo-session": "2.176.0",
44
- "node-opcua-service-browse": "2.176.0",
45
- "node-opcua-service-call": "2.176.0",
46
- "node-opcua-service-history": "2.176.0",
47
- "node-opcua-service-translate-browse-path": "2.176.0",
48
- "node-opcua-service-write": "2.176.0",
43
+ "node-opcua-pseudo-session": "2.178.0",
44
+ "node-opcua-service-browse": "2.177.0",
45
+ "node-opcua-service-call": "2.177.0",
46
+ "node-opcua-service-history": "2.177.0",
47
+ "node-opcua-service-translate-browse-path": "2.177.0",
48
+ "node-opcua-service-write": "2.177.0",
49
49
  "node-opcua-status-code": "2.176.0",
50
- "node-opcua-types": "2.176.0",
50
+ "node-opcua-types": "2.177.0",
51
51
  "node-opcua-utils": "2.176.0",
52
- "node-opcua-variant": "2.176.0",
52
+ "node-opcua-variant": "2.177.0",
53
53
  "node-opcua-xml2json": "2.176.0",
54
54
  "semver": "^7.8.5",
55
55
  "thenify-ex": "4.4.0",
@@ -60,9 +60,9 @@
60
60
  "node-opcua-benchmarker": "2.176.0",
61
61
  "node-opcua-leak-detector": "2.175.6",
62
62
  "node-opcua-nodesets": "2.175.3",
63
- "node-opcua-packet-analyzer": "2.176.0",
64
- "node-opcua-schemas": "2.176.0",
65
- "node-opcua-service-filter": "2.176.0",
63
+ "node-opcua-packet-analyzer": "2.177.0",
64
+ "node-opcua-schemas": "2.177.0",
65
+ "node-opcua-service-filter": "2.178.0",
66
66
  "node-opcua-test-fixtures": "2.175.1"
67
67
  },
68
68
  "author": "Etienne Rossignon",
@@ -80,7 +80,7 @@
80
80
  "internet of things"
81
81
  ],
82
82
  "homepage": "http://node-opcua.github.io/",
83
- "gitHead": "a4569830a5a564a7ff3e8cf37c44fd35b3f72ac1",
83
+ "gitHead": "d0e850e5f7df80e14ceb6d8e092e793472965301",
84
84
  "files": [
85
85
  "dist",
86
86
  "distHelpers",
@@ -16,7 +16,7 @@ import type {
16
16
  UAVariable,
17
17
  UAVariableType
18
18
  } from "node-opcua-address-space-base";
19
- import { assert, renderError } from "node-opcua-assert";
19
+ import { assert } from "node-opcua-assert";
20
20
  import { coerceBoolean, coerceByte, coerceInt32, StatusCodes } from "node-opcua-basic-types";
21
21
  import { DataTypeIds } from "node-opcua-constants";
22
22
  import {
@@ -1160,7 +1160,19 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
1160
1160
  chalk.green("DONE")
1161
1161
  );
1162
1162
 
1163
- async function performPostLoadingTasks(tasks: Task[]): Promise<void> {
1163
+ /**
1164
+ * run every queued post-loading task.
1165
+ *
1166
+ * A task that throws (typically: a `<Value>` in a third-party nodeset that does not
1167
+ * match the declared DataType) is logged and skipped — it must NOT abort the remaining
1168
+ * tasks nor the remaining stages of finalSteps(). Previously the failing task was
1169
+ * re-run inside the catch block, the second throw escaped the loop, finalSteps() was
1170
+ * abandoned and `ensureDatatypeExtracted` was never called: the address space was
1171
+ * left half-initialised (no DataTypeManager) and any later use of a structured
1172
+ * DataType failed with an opaque
1173
+ * "Cannot read properties of undefined (reading 'getExtensionObjectConstructorFromDataType')".
1174
+ */
1175
+ async function performPostLoadingTasks(stage: string, tasks: Task[]): Promise<void> {
1164
1176
  for (const task of tasks) {
1165
1177
  try {
1166
1178
  await task(addressSpace1);
@@ -1168,9 +1180,11 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
1168
1180
  // c8 ignore next
1169
1181
  // tslint:disable:no-console
1170
1182
  if (types.isNativeError(err)) {
1171
- errorLog(" performPostLoadingTasks Err => ", err.message, "\n", err);
1183
+ errorLog(
1184
+ `[NODE-OPCUA-W36] generateAddressSpace: post-loading task failed during "${stage}" and was skipped: ${err.message}`
1185
+ );
1186
+ doDebug && debugLog(err);
1172
1187
  }
1173
- await task(addressSpace1);
1174
1188
  }
1175
1189
  }
1176
1190
  tasks.splice(0);
@@ -1179,11 +1193,11 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
1179
1193
  /// ----------------------------------------------------------------------------------------
1180
1194
  // perform post task
1181
1195
  doDebug && debugLog(chalk.bgGreenBright("Performing post loading tasks -------------------------------------------"));
1182
- await performPostLoadingTasks(postTasks);
1196
+ await performPostLoadingTasks("post tasks", postTasks);
1183
1197
 
1184
1198
  doDebug &&
1185
1199
  debugLog(chalk.bgGreenBright("Performing post loading task: Initializing Simple Variables ---------------------"));
1186
- await performPostLoadingTasks(postTasks0_InitializeVariable);
1200
+ await performPostLoadingTasks("initializing simple variables", postTasks0_InitializeVariable);
1187
1201
 
1188
1202
  doDebug && debugLog(chalk.bgGreenBright("Performing DataType extraction -------------------------------------------"));
1189
1203
  assert(!addressSpace1.suspendBackReference);
@@ -1202,14 +1216,17 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
1202
1216
  pendingSimpleTypeToRegister.splice(0);
1203
1217
 
1204
1218
  doDebug && debugLog(chalk.bgGreenBright("Performing post loading task: Decoding Pojo String (parsing XML objects) -"));
1205
- await performPostLoadingTasks(postTasks0_DecodePojoString);
1219
+ await performPostLoadingTasks("decoding XML extension objects", postTasks0_DecodePojoString);
1206
1220
 
1207
1221
  doDebug &&
1208
1222
  debugLog(chalk.bgGreenBright("Performing post loading task: Initializing Complex Variables ---------------------"));
1209
- await performPostLoadingTasks(postTasks1_InitializeVariable);
1223
+ await performPostLoadingTasks("initializing complex variables", postTasks1_InitializeVariable);
1210
1224
 
1211
1225
  doDebug && debugLog(chalk.bgGreenBright("Performing post loading tasks: (assigning Extension Object to Variables) -"));
1212
- await performPostLoadingTasks(postTasks2_AssignedExtensionObjectToDataValue);
1226
+ await performPostLoadingTasks(
1227
+ "assigning extension objects to variables",
1228
+ postTasks2_AssignedExtensionObjectToDataValue
1229
+ );
1213
1230
 
1214
1231
  doDebug && debugLog(chalk.bgGreenBright("Performing post variable initialization ---------------------"));
1215
1232
  promoteObjectsAndVariables(addressSpace);
@@ -1218,7 +1235,13 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
1218
1235
  try {
1219
1236
  await finalSteps();
1220
1237
  } catch (err) {
1221
- renderError(err);
1238
+ // `renderError` was a no-op here, so a failure in the final steps (DataType extraction,
1239
+ // promotion of objects/variables, ...) used to be silently swallowed and the caller was
1240
+ // handed back a half-initialised address space. Surface it: log and re-throw so that
1241
+ // generateAddressSpace() rejects.
1242
+ const message = types.isNativeError(err) ? err.message : String(err);
1243
+ errorLog(`[NODE-OPCUA-E30] generateAddressSpace: final post-loading steps failed: ${message}`);
1244
+ throw err;
1222
1245
  }
1223
1246
  }
1224
1247
  async function addNodeSet(xmlData: string): Promise<void> {
@@ -1028,7 +1028,15 @@ export class AddressSpace implements AddressSpacePrivate {
1028
1028
  }
1029
1029
  assert(_dataType.isSubtypeOf(this.findDataType("Structure")!));
1030
1030
  if (!_dataType._extensionObjectConstructor) {
1031
- const dataTypeManager = (this as any).$$extraDataTypeManager as ExtraDataTypeManager;
1031
+ const addressSpacePriv: any = this as any;
1032
+ if (!addressSpacePriv.$$extraDataTypeManager) {
1033
+ throw new Error(
1034
+ `getExtensionObjectConstructor: cannot build a constructor for ${_dataType.browseName.toString()} (${_dataType.nodeId.toString()}): ` +
1035
+ "the DataType manager is not initialised. " +
1036
+ "Make sure generateAddressSpace() completed successfully and/or that ensureDatatypeExtracted(addressSpace) was awaited before using structured DataTypes."
1037
+ );
1038
+ }
1039
+ const dataTypeManager = addressSpacePriv.$$extraDataTypeManager as ExtraDataTypeManager;
1032
1040
  _dataType._extensionObjectConstructor = dataTypeManager.getExtensionObjectConstructorFromDataType(
1033
1041
  _dataType.nodeId
1034
1042
  ) as ExtensionObjectConstructorFuncWithSchema;