node-opcua-client-dynamic-extension-object 2.70.3 → 2.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/client_dynamic_extension_object.d.ts +22 -0
  2. package/dist/client_dynamic_extension_object.js +1012 -0
  3. package/dist/client_dynamic_extension_object.js.map +1 -0
  4. package/dist/convert_data_type_definition_to_structuretype_schema.d.ts +12 -12
  5. package/dist/convert_data_type_definition_to_structuretype_schema.js +343 -331
  6. package/dist/convert_data_type_definition_to_structuretype_schema.js.map +1 -1
  7. package/dist/extra_data_type_manager.d.ts +16 -16
  8. package/dist/extra_data_type_manager.js +75 -75
  9. package/dist/get_extension_object_constructor.d.ts +7 -7
  10. package/dist/get_extension_object_constructor.js +37 -37
  11. package/dist/get_extra_data_type_manager.d.ts +3 -3
  12. package/dist/get_extra_data_type_manager.js +51 -51
  13. package/dist/index.d.ts +12 -12
  14. package/dist/index.js +28 -28
  15. package/dist/populate_data_type_manager.d.ts +3 -3
  16. package/dist/populate_data_type_manager.js +25 -25
  17. package/dist/private/find_encodings.d.ts +4 -4
  18. package/dist/private/find_encodings.js +55 -55
  19. package/dist/private/populate_data_type_manager_103.d.ts +9 -9
  20. package/dist/private/populate_data_type_manager_103.js +601 -601
  21. package/dist/private/populate_data_type_manager_104.d.ts +9 -9
  22. package/dist/private/populate_data_type_manager_104.js +182 -182
  23. package/dist/private/populate_data_type_manager_104.js.map +1 -1
  24. package/dist/promote_opaque_structure.d.ts +6 -6
  25. package/dist/promote_opaque_structure.js +41 -41
  26. package/dist/promote_opaque_structure_in_notification_data.d.ts +3 -3
  27. package/dist/promote_opaque_structure_in_notification_data.js +51 -51
  28. package/dist/resolve_dynamic_extension_object.d.ts +4 -4
  29. package/dist/resolve_dynamic_extension_object.js +105 -105
  30. package/dist/resolve_dynamic_extension_object.js.map +1 -1
  31. package/package.json +16 -16
  32. package/source/convert_data_type_definition_to_structuretype_schema.ts +43 -30
  33. package/source/private/populate_data_type_manager_104.ts +1 -0
  34. package/source/resolve_dynamic_extension_object.ts +13 -10
@@ -1,106 +1,106 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.resolveDynamicExtensionObject = void 0;
13
- const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
14
- const node_opcua_extension_object_1 = require("node-opcua-extension-object");
15
- const node_opcua_variant_1 = require("node-opcua-variant");
16
- const node_opcua_debug_1 = require("node-opcua-debug");
17
- const node_opcua_data_model_1 = require("node-opcua-data-model");
18
- const node_opcua_status_code_1 = require("node-opcua-status-code");
19
- const populate_data_type_manager_104_1 = require("./private/populate_data_type_manager_104");
20
- const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
21
- function getOrExtractConstructor(session, binaryEncodingNodeId, dataTypeManager) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- const dataTypeFactory = dataTypeManager.getDataTypeFactoryForNamespace(binaryEncodingNodeId.namespace);
24
- const Constructor = dataTypeFactory.getConstructor(binaryEncodingNodeId);
25
- if (Constructor) {
26
- return Constructor;
27
- }
28
- if (binaryEncodingNodeId.namespace === 0) {
29
- throw new Error("Internal Error");
30
- }
31
- // need to extract it
32
- const browseResult = yield session.browse({
33
- nodeId: binaryEncodingNodeId,
34
- referenceTypeId: "HasEncoding",
35
- browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
36
- includeSubtypes: false,
37
- nodeClassMask: node_opcua_data_model_1.NodeClassMask.DataType,
38
- resultMask: node_opcua_data_model_1.ResultMask.BrowseName
39
- });
40
- if (browseResult.statusCode !== node_opcua_status_code_1.StatusCodes.Good || browseResult.references.length !== 1) {
41
- throw new Error("browse failed");
42
- }
43
- const r = browseResult.references[0];
44
- const dataTypeNodeId = r.nodeId;
45
- if (dataTypeFactory.getConstructorForDataType(dataTypeNodeId)) {
46
- throw new Error("Internal Error: we are not expecting this dataType to be processed already");
47
- }
48
- yield (0, populate_data_type_manager_104_1.readDataTypeDefinitionAndBuildType)(session, dataTypeNodeId, r.browseName.name, dataTypeFactory, {});
49
- return dataTypeFactory.getConstructorForDataType(dataTypeNodeId);
50
- });
51
- }
52
- function resolveDynamicExtensionObjectV(session, opaque, dataTypeManager) {
53
- var _a, _b;
54
- return __awaiter(this, void 0, void 0, function* () {
55
- try {
56
- const Constructor = yield getOrExtractConstructor(session, opaque.nodeId, dataTypeManager);
57
- const object = new Constructor();
58
- const stream = new node_opcua_binary_stream_1.BinaryStream(opaque.buffer);
59
- try {
60
- object.decode(stream);
61
- return object;
62
- }
63
- catch (err) {
64
- warningLog("Constructor = ", Constructor.name);
65
- warningLog("opaqueStructure = ", (_a = opaque === null || opaque === void 0 ? void 0 : opaque.nodeId) === null || _a === void 0 ? void 0 : _a.toString());
66
- warningLog("opaqueStructure = ", "0x" + ((_b = opaque === null || opaque === void 0 ? void 0 : opaque.buffer) === null || _b === void 0 ? void 0 : _b.toString("hex")));
67
- warningLog((0, node_opcua_debug_1.hexDump)(opaque.buffer));
68
- warningLog("resolveDynamicExtensionObjectV err = ", err);
69
- // try again for debugging
70
- object.decode(stream);
71
- return opaque;
72
- }
73
- }
74
- catch (err) {
75
- warningLog("err", err);
76
- warningLog("opaqueStructure = ", opaque.nodeId.toString());
77
- warningLog("opaqueStructure = ", "0x" + opaque.buffer.toString("hex"));
78
- warningLog((0, node_opcua_debug_1.hexDump)(opaque.buffer));
79
- warningLog(dataTypeManager.toString());
80
- throw err;
81
- }
82
- });
83
- }
84
- function resolveDynamicExtensionObject(session, variant, dataTypeManager) {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- if (variant.dataType !== node_opcua_variant_1.DataType.ExtensionObject) {
87
- return;
88
- }
89
- if (variant.arrayType !== node_opcua_variant_1.VariantArrayType.Scalar) {
90
- if (variant.value instanceof Array) {
91
- for (let i = 0; i < variant.value.length; i++) {
92
- if (variant.value[i] instanceof node_opcua_extension_object_1.OpaqueStructure) {
93
- variant.value[i] = yield resolveDynamicExtensionObjectV(session, variant.value[i], dataTypeManager);
94
- }
95
- }
96
- }
97
- return;
98
- }
99
- if (!(variant.value instanceof node_opcua_extension_object_1.OpaqueStructure)) {
100
- return;
101
- }
102
- variant.value = yield resolveDynamicExtensionObjectV(session, variant.value, dataTypeManager);
103
- });
104
- }
105
- exports.resolveDynamicExtensionObject = resolveDynamicExtensionObject;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.resolveDynamicExtensionObject = void 0;
13
+ const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
14
+ const node_opcua_extension_object_1 = require("node-opcua-extension-object");
15
+ const node_opcua_variant_1 = require("node-opcua-variant");
16
+ const node_opcua_debug_1 = require("node-opcua-debug");
17
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
18
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
19
+ const populate_data_type_manager_104_1 = require("./private/populate_data_type_manager_104");
20
+ const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
21
+ function getOrExtractConstructor(session, binaryEncodingNodeId, dataTypeManager) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const dataTypeFactory = dataTypeManager.getDataTypeFactoryForNamespace(binaryEncodingNodeId.namespace);
24
+ const Constructor = dataTypeFactory.getConstructor(binaryEncodingNodeId);
25
+ if (Constructor) {
26
+ return Constructor;
27
+ }
28
+ if (binaryEncodingNodeId.namespace === 0) {
29
+ throw new Error("Internal Error");
30
+ }
31
+ // need to extract it
32
+ const browseResult = yield session.browse({
33
+ nodeId: binaryEncodingNodeId,
34
+ referenceTypeId: "HasEncoding",
35
+ browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
36
+ includeSubtypes: false,
37
+ nodeClassMask: node_opcua_data_model_1.NodeClassMask.DataType,
38
+ resultMask: node_opcua_data_model_1.ResultMask.BrowseName
39
+ });
40
+ if (browseResult.statusCode !== node_opcua_status_code_1.StatusCodes.Good || browseResult.references.length !== 1) {
41
+ throw new Error("browse failed");
42
+ }
43
+ const r = browseResult.references[0];
44
+ const dataTypeNodeId = r.nodeId;
45
+ if (dataTypeFactory.getConstructorForDataType(dataTypeNodeId)) {
46
+ throw new Error("Internal Error: we are not expecting this dataType to be processed already");
47
+ }
48
+ yield (0, populate_data_type_manager_104_1.readDataTypeDefinitionAndBuildType)(session, dataTypeNodeId, r.browseName.name, dataTypeFactory, {});
49
+ return dataTypeFactory.getConstructorForDataType(dataTypeNodeId);
50
+ });
51
+ }
52
+ function resolveDynamicExtensionObjectV(session, opaque, dataTypeManager) {
53
+ var _a, _b;
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ try {
56
+ const Constructor = yield getOrExtractConstructor(session, opaque.nodeId, dataTypeManager);
57
+ const object = new Constructor();
58
+ const stream = new node_opcua_binary_stream_1.BinaryStream(opaque.buffer);
59
+ try {
60
+ object.decode(stream);
61
+ return object;
62
+ }
63
+ catch (err) {
64
+ warningLog("Constructor = ", Constructor.name);
65
+ warningLog("opaqueStructure = ", (_a = opaque === null || opaque === void 0 ? void 0 : opaque.nodeId) === null || _a === void 0 ? void 0 : _a.toString());
66
+ warningLog("opaqueStructure = ", "0x" + ((_b = opaque === null || opaque === void 0 ? void 0 : opaque.buffer) === null || _b === void 0 ? void 0 : _b.toString("hex")));
67
+ warningLog((0, node_opcua_debug_1.hexDump)(opaque.buffer));
68
+ warningLog("resolveDynamicExtensionObjectV err = ", err);
69
+ // try again for debugging
70
+ object.decode(stream);
71
+ return opaque;
72
+ }
73
+ }
74
+ catch (err) {
75
+ warningLog("err", err);
76
+ warningLog("opaqueStructure = ", opaque.nodeId.toString());
77
+ warningLog("opaqueStructure = ", "0x" + opaque.buffer.toString("hex"));
78
+ warningLog((0, node_opcua_debug_1.hexDump)(opaque.buffer));
79
+ warningLog(dataTypeManager.toString());
80
+ throw err;
81
+ }
82
+ });
83
+ }
84
+ function resolveDynamicExtensionObject(session, variant, dataTypeManager) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ if (variant.dataType !== node_opcua_variant_1.DataType.ExtensionObject) {
87
+ return;
88
+ }
89
+ if (variant.arrayType !== node_opcua_variant_1.VariantArrayType.Scalar) {
90
+ if (variant.value instanceof Array) {
91
+ for (let i = 0; i < variant.value.length; i++) {
92
+ if (variant.value[i] instanceof node_opcua_extension_object_1.OpaqueStructure) {
93
+ variant.value[i] = yield resolveDynamicExtensionObjectV(session, variant.value[i], dataTypeManager);
94
+ }
95
+ }
96
+ }
97
+ return;
98
+ }
99
+ if (!(variant.value instanceof node_opcua_extension_object_1.OpaqueStructure)) {
100
+ return;
101
+ }
102
+ variant.value = yield resolveDynamicExtensionObjectV(session, variant.value, dataTypeManager);
103
+ });
104
+ }
105
+ exports.resolveDynamicExtensionObject = resolveDynamicExtensionObject;
106
106
  //# sourceMappingURL=resolve_dynamic_extension_object.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve_dynamic_extension_object.js","sourceRoot":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
+ {"version":3,"file":"resolve_dynamic_extension_object.js","sourceRoot":"","sources":["../source/resolve_dynamic_extension_object.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uEAAwD;AACxD,6EAA+E;AAC/E,2DAAyE;AACzE,uDAA4D;AAI5D,iEAAmF;AACnF,mEAAqD;AAGrD,6FAA8F;AAE9F,MAAM,UAAU,GAAG,IAAA,kCAAe,EAAC,UAAU,CAAC,CAAC;AAE/C,SAAe,uBAAuB,CAClC,OAAsB,EACtB,oBAA4B,EAC5B,eAAqC;;QAErC,MAAM,eAAe,GAAG,eAAe,CAAC,8BAA8B,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;QACvG,MAAM,WAAW,GAAG,eAAe,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;QACzE,IAAI,WAAW,EAAE;YACb,OAAO,WAAW,CAAC;SACtB;QACD,IAAI,oBAAoB,CAAC,SAAS,KAAK,CAAC,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;SACrC;QACD,qBAAqB;QACrB,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC;YACtC,MAAM,EAAE,oBAAoB;YAC5B,eAAe,EAAE,aAAa;YAC9B,eAAe,EAAE,uCAAe,CAAC,OAAO;YACxC,eAAe,EAAE,KAAK;YACtB,aAAa,EAAE,qCAAa,CAAC,QAAQ;YACrC,UAAU,EAAE,kCAAU,CAAC,UAAU;SACpC,CAAC,CAAC;QACH,IAAI,YAAY,CAAC,UAAU,KAAK,oCAAW,CAAC,IAAI,IAAI,YAAY,CAAC,UAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YACvF,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;SACpC;QACD,MAAM,CAAC,GAAG,YAAY,CAAC,UAAW,CAAC,CAAC,CAAC,CAAC;QACtC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;QAEhC,IAAI,eAAe,CAAC,yBAAyB,CA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AAC;IAClG,CAAC;CAAA;AAvBD,sEAuBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-client-dynamic-extension-object",
3
- "version": "2.70.3",
3
+ "version": "2.71.0",
4
4
  "description": "pure nodejs OPCUA SDK - module client-dynamic-extension-object",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -12,21 +12,21 @@
12
12
  "dependencies": {
13
13
  "chalk": "4.1.2",
14
14
  "node-opcua-assert": "2.66.0",
15
- "node-opcua-binary-stream": "2.69.0",
15
+ "node-opcua-binary-stream": "2.71.0",
16
16
  "node-opcua-constants": "2.70.0",
17
- "node-opcua-data-model": "2.70.0",
18
- "node-opcua-data-value": "2.70.0",
19
- "node-opcua-debug": "2.69.0",
20
- "node-opcua-extension-object": "2.70.0",
21
- "node-opcua-factory": "2.70.0",
22
- "node-opcua-nodeid": "2.70.0",
23
- "node-opcua-pseudo-session": "2.70.3",
24
- "node-opcua-schemas": "2.70.3",
25
- "node-opcua-service-browse": "2.70.3",
26
- "node-opcua-service-translate-browse-path": "2.70.3",
27
- "node-opcua-status-code": "2.70.0",
28
- "node-opcua-types": "2.70.3",
29
- "node-opcua-variant": "2.70.0"
17
+ "node-opcua-data-model": "2.71.0",
18
+ "node-opcua-data-value": "2.71.0",
19
+ "node-opcua-debug": "2.71.0",
20
+ "node-opcua-extension-object": "2.71.0",
21
+ "node-opcua-factory": "2.71.0",
22
+ "node-opcua-nodeid": "2.71.0",
23
+ "node-opcua-pseudo-session": "2.71.0",
24
+ "node-opcua-schemas": "2.71.0",
25
+ "node-opcua-service-browse": "2.71.0",
26
+ "node-opcua-service-translate-browse-path": "2.71.0",
27
+ "node-opcua-status-code": "2.71.0",
28
+ "node-opcua-types": "2.71.0",
29
+ "node-opcua-variant": "2.71.0"
30
30
  },
31
31
  "author": "Etienne Rossignon",
32
32
  "license": "MIT",
@@ -43,5 +43,5 @@
43
43
  "internet of things"
44
44
  ],
45
45
  "homepage": "http://node-opcua.github.io/",
46
- "gitHead": "08b5465af631fd010bc48843c951b2e556270de4"
46
+ "gitHead": "10f7cc1e1cd30dfef75adad9cb709a78401fabf3"
47
47
  }
@@ -24,6 +24,7 @@ import {
24
24
  } from "node-opcua-types";
25
25
  import { ExtensionObject } from "node-opcua-extension-object";
26
26
  //
27
+ import { DataType } from "node-opcua-variant";
27
28
  import { _findEncodings } from "./private/find_encodings";
28
29
 
29
30
  const debugLog = make_debugLog(__filename);
@@ -300,6 +301,14 @@ export async function convertDataTypeDefinitionToStructureTypeSchema(
300
301
  cache: { [key: string]: CacheForFieldResolution }
301
302
  ): Promise<StructuredTypeSchema> {
302
303
  if (definition instanceof StructureDefinition) {
304
+
305
+ let fieldCountToIgnore = 0;
306
+ let base: undefined | any = dataTypeFactory.getConstructorForDataType(definition.baseDataType)?.schema;
307
+ while (base && !(base.dataTypeNodeId.value === DataType.ExtensionObject && base.dataTypeNodeId.namespace === 0)) {
308
+ fieldCountToIgnore += base._possibleFields.length;
309
+ base = base._baseSchema;
310
+ }
311
+
303
312
  const fields: FieldInterfaceOptions[] = [];
304
313
 
305
314
  const isUnion = definition.structureType === StructureType.Union;
@@ -324,40 +333,44 @@ export async function convertDataTypeDefinitionToStructureTypeSchema(
324
333
 
325
334
  const postActions: ((schema: StructuredTypeSchema) => void)[] = [];
326
335
 
327
- for (const fieldD of definition.fields!) {
328
- let field: FieldInterfaceOptions | undefined;
329
- ({ field, switchBit, switchValue } = createField(fieldD, switchBit, bitFields, isUnion, switchValue));
336
+ if (definition.fields) {
337
+ for (let i = fieldCountToIgnore; i < definition.fields.length; i++) {
338
+ const fieldD = definition.fields[i];
339
+ // we need to skip fields that have already been handled in base class
340
+
341
+ let field: FieldInterfaceOptions | undefined;
342
+ ({ field, switchBit, switchValue } = createField(fieldD, switchBit, bitFields, isUnion, switchValue));
343
+
344
+ if (fieldD.dataType.value === dataTypeNodeId.value && fieldD.dataType.namespace === dataTypeNodeId.namespace) {
345
+ // this is a structure with a field of the same type
346
+ // push an empty placeholder that we will fill later
347
+ const fieldTypeName = await readBrowseName(session, dataTypeNodeId);
348
+ (field.fieldType = fieldTypeName!), (field.category = FieldCategory.complex);
349
+ fields.push(field);
350
+ const capturedField = field;
351
+ postActions.push((schema: StructuredTypeSchema) => {
352
+ capturedField.schema = schema;
353
+ });
354
+ continue;
355
+ }
356
+ const rt = (await resolveFieldType(session, fieldD.dataType, dataTypeFactory, cache))!;
357
+ if (!rt) {
358
+ errorLog(
359
+ "convertDataTypeDefinitionToStructureTypeSchema cannot handle field",
360
+ fieldD.name,
361
+ "in",
362
+ name,
363
+ "because " + fieldD.dataType.toString() + " cannot be resolved"
364
+ );
365
+ continue;
366
+ }
367
+ const { schema, category, fieldTypeName } = rt;
330
368
 
331
- if (fieldD.dataType.value === dataTypeNodeId.value && fieldD.dataType.namespace === dataTypeNodeId.namespace) {
332
- // this is a structure with a field of the same type
333
- // push an empty placeholder that we will fill later
334
- const fieldTypeName = await readBrowseName(session, dataTypeNodeId);
335
- (field.fieldType = fieldTypeName!), (field.category = FieldCategory.complex);
369
+ (field.fieldType = fieldTypeName!), (field.category = category);
370
+ field.schema = schema;
336
371
  fields.push(field);
337
- const capturedField = field;
338
- postActions.push((schema: StructuredTypeSchema) => {
339
- capturedField.schema = schema;
340
- });
341
- continue;
342
- }
343
- const rt = (await resolveFieldType(session, fieldD.dataType, dataTypeFactory, cache))!;
344
- if (!rt) {
345
- errorLog(
346
- "convertDataTypeDefinitionToStructureTypeSchema cannot handle field",
347
- fieldD.name,
348
- "in",
349
- name,
350
- "because " + fieldD.dataType.toString() + " cannot be resolved"
351
- );
352
- continue;
353
372
  }
354
- const { schema, category, fieldTypeName } = rt;
355
-
356
- (field.fieldType = fieldTypeName!), (field.category = category);
357
- field.schema = schema;
358
- fields.push(field);
359
373
  }
360
-
361
374
  const a = await resolveFieldType(session, definition.baseDataType, dataTypeFactory, cache);
362
375
  const baseType = a ? a.fieldTypeName : "ExtensionObject";
363
376
 
@@ -45,6 +45,7 @@ export async function readDataTypeDefinitionAndBuildType(
45
45
  );
46
46
 
47
47
  createDynamicObjectConstructor(schema, dataTypeFactory);
48
+
48
49
  } catch (err) {
49
50
  errorLog("Error", err);
50
51
  }
@@ -13,15 +13,18 @@ import { readDataTypeDefinitionAndBuildType } from "./private/populate_data_type
13
13
 
14
14
  const warningLog = make_warningLog(__filename);
15
15
 
16
- async function getOrExtractConstructor(session: IBasicSession, binaryEncodingNodeId: NodeId, dataTypeManager: ExtraDataTypeManager): Promise<ConstructorFunc>
17
- {
16
+ async function getOrExtractConstructor(
17
+ session: IBasicSession,
18
+ binaryEncodingNodeId: NodeId,
19
+ dataTypeManager: ExtraDataTypeManager
20
+ ): Promise<ConstructorFunc> {
18
21
  const dataTypeFactory = dataTypeManager.getDataTypeFactoryForNamespace(binaryEncodingNodeId.namespace);
19
22
  const Constructor = dataTypeFactory.getConstructor(binaryEncodingNodeId);
20
23
  if (Constructor) {
21
24
  return Constructor;
22
25
  }
23
- if (binaryEncodingNodeId.namespace ===0) {
24
- throw new Error("Internal Error");
26
+ if (binaryEncodingNodeId.namespace === 0) {
27
+ throw new Error("Internal Error");
25
28
  }
26
29
  // need to extract it
27
30
  const browseResult = await session.browse({
@@ -35,14 +38,14 @@ async function getOrExtractConstructor(session: IBasicSession, binaryEncodingNod
35
38
  if (browseResult.statusCode !== StatusCodes.Good || browseResult.references!.length !== 1) {
36
39
  throw new Error("browse failed");
37
40
  }
38
- const r = browseResult.references![0];
39
- const dataTypeNodeId =r.nodeId;
41
+ const r = browseResult.references![0];
42
+ const dataTypeNodeId = r.nodeId;
40
43
 
41
44
  if (dataTypeFactory.getConstructorForDataType(dataTypeNodeId)) {
42
- throw new Error("Internal Error: we are not expecting this dataType to be processed already");
45
+ throw new Error("Internal Error: we are not expecting this dataType to be processed already");
43
46
  }
44
47
  await readDataTypeDefinitionAndBuildType(session, dataTypeNodeId, r.browseName.name!, dataTypeFactory, {});
45
-
48
+
46
49
  return dataTypeFactory.getConstructorForDataType(dataTypeNodeId)!;
47
50
  }
48
51
 
@@ -100,5 +103,5 @@ export async function resolveDynamicExtensionObject(
100
103
  if (!(variant.value instanceof OpaqueStructure)) {
101
104
  return;
102
105
  }
103
- variant.value = await resolveDynamicExtensionObjectV(session, variant.value as OpaqueStructure, dataTypeManager);
104
- }
106
+ variant.value = await resolveDynamicExtensionObjectV(session, variant.value, dataTypeManager);
107
+ }