node-opcua-client-dynamic-extension-object 2.96.0 → 2.98.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 (42) hide show
  1. package/package.json +16 -16
  2. package/source/convert_data_type_definition_to_structuretype_schema.ts +16 -10
  3. package/dist/convert_data_type_definition_to_structuretype_schema.d.ts +0 -14
  4. package/dist/convert_data_type_definition_to_structuretype_schema.js +0 -406
  5. package/dist/convert_data_type_definition_to_structuretype_schema.js.map +0 -1
  6. package/dist/convert_structuretype_schema_to_structure_definition.d.ts +0 -3
  7. package/dist/convert_structuretype_schema_to_structure_definition.js +0 -54
  8. package/dist/convert_structuretype_schema_to_structure_definition.js.map +0 -1
  9. package/dist/extra_data_type_manager.d.ts +0 -16
  10. package/dist/extra_data_type_manager.js +0 -79
  11. package/dist/extra_data_type_manager.js.map +0 -1
  12. package/dist/get_extension_object_constructor.d.ts +0 -7
  13. package/dist/get_extension_object_constructor.js +0 -38
  14. package/dist/get_extension_object_constructor.js.map +0 -1
  15. package/dist/get_extra_data_type_manager.d.ts +0 -3
  16. package/dist/get_extra_data_type_manager.js +0 -52
  17. package/dist/get_extra_data_type_manager.js.map +0 -1
  18. package/dist/index.d.ts +0 -13
  19. package/dist/index.js +0 -30
  20. package/dist/index.js.map +0 -1
  21. package/dist/populate_data_type_manager.d.ts +0 -3
  22. package/dist/populate_data_type_manager.js +0 -89
  23. package/dist/populate_data_type_manager.js.map +0 -1
  24. package/dist/private/find_encodings.d.ts +0 -4
  25. package/dist/private/find_encodings.js +0 -56
  26. package/dist/private/find_encodings.js.map +0 -1
  27. package/dist/private/populate_data_type_manager_103.d.ts +0 -9
  28. package/dist/private/populate_data_type_manager_103.js +0 -640
  29. package/dist/private/populate_data_type_manager_103.js.map +0 -1
  30. package/dist/private/populate_data_type_manager_104.d.ts +0 -9
  31. package/dist/private/populate_data_type_manager_104.js +0 -218
  32. package/dist/private/populate_data_type_manager_104.js.map +0 -1
  33. package/dist/promote_opaque_structure.d.ts +0 -7
  34. package/dist/promote_opaque_structure.js +0 -47
  35. package/dist/promote_opaque_structure.js.map +0 -1
  36. package/dist/promote_opaque_structure_in_notification_data.d.ts +0 -3
  37. package/dist/promote_opaque_structure_in_notification_data.js +0 -52
  38. package/dist/promote_opaque_structure_in_notification_data.js.map +0 -1
  39. package/dist/resolve_dynamic_extension_object.d.ts +0 -6
  40. package/dist/resolve_dynamic_extension_object.js +0 -178
  41. package/dist/resolve_dynamic_extension_object.js.map +0 -1
  42. package/test/test_convertStructureTypeSchemaToStructureDefinition.ts +0 -117
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-client-dynamic-extension-object",
3
- "version": "2.96.0",
3
+ "version": "2.98.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.88.0",
15
- "node-opcua-binary-stream": "2.90.1",
15
+ "node-opcua-binary-stream": "2.98.0",
16
16
  "node-opcua-constants": "2.88.0",
17
- "node-opcua-data-model": "2.95.0",
18
- "node-opcua-data-value": "2.95.0",
19
- "node-opcua-debug": "2.90.1",
20
- "node-opcua-extension-object": "2.95.0",
21
- "node-opcua-factory": "2.95.0",
22
- "node-opcua-nodeid": "2.90.1",
23
- "node-opcua-pseudo-session": "2.96.0",
24
- "node-opcua-schemas": "2.96.0",
25
- "node-opcua-service-browse": "2.96.0",
26
- "node-opcua-service-translate-browse-path": "2.96.0",
27
- "node-opcua-status-code": "2.90.1",
28
- "node-opcua-types": "2.96.0",
29
- "node-opcua-variant": "2.95.0"
17
+ "node-opcua-data-model": "2.98.0",
18
+ "node-opcua-data-value": "2.98.0",
19
+ "node-opcua-debug": "2.98.0",
20
+ "node-opcua-extension-object": "2.98.0",
21
+ "node-opcua-factory": "2.98.0",
22
+ "node-opcua-nodeid": "2.98.0",
23
+ "node-opcua-pseudo-session": "2.98.0",
24
+ "node-opcua-schemas": "2.98.0",
25
+ "node-opcua-service-browse": "2.98.0",
26
+ "node-opcua-service-translate-browse-path": "2.98.0",
27
+ "node-opcua-status-code": "2.98.0",
28
+ "node-opcua-types": "2.98.0",
29
+ "node-opcua-variant": "2.98.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": "43642e4aaa1ca2a3938b044cc2237544dfff764a"
46
+ "gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c"
47
47
  }
@@ -2,7 +2,7 @@ import { assert } from "node-opcua-assert";
2
2
  import { AttributeIds, BrowseDirection, makeResultMask, NodeClassMask } from "node-opcua-data-model";
3
3
  import { DataValue } from "node-opcua-data-value";
4
4
  import { make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
5
- import { sameNodeId } from "node-opcua-nodeid";
5
+ import { INodeId, NodeIdType, sameNodeId } from "node-opcua-nodeid";
6
6
  //import { DataTypeIds } from "node-opcua-constant";
7
7
  import {
8
8
  BitField,
@@ -80,9 +80,10 @@ async function findDataTypeCategory(
80
80
  return cache[key].category;
81
81
  }
82
82
  let category: FieldCategory;
83
- if (subTypeNodeId.namespace === 0 && subTypeNodeId.value <= 29) {
83
+ const n = subTypeNodeId as INodeId;
84
+ if (n.identifierType === NodeIdType.NUMERIC && n.namespace === 0 && n.value <= 29) {
84
85
  // well known node ID !
85
- switch (subTypeNodeId.value) {
86
+ switch (n.value) {
86
87
  case 22 /* Structure */:
87
88
  category = FieldCategory.complex;
88
89
  break;
@@ -112,8 +113,9 @@ async function findDataTypeBasicType(
112
113
  if (cache[key]) {
113
114
  return cache[key].schema;
114
115
  }
115
- if (subTypeNodeId.namespace === 0 && subTypeNodeId.value < 29) {
116
- switch (subTypeNodeId.value) {
116
+ const n = subTypeNodeId as INodeId;
117
+ if (n.identifierType === NodeIdType.NUMERIC && n.namespace === 0 && n.value < 29) {
118
+ switch (n.value) {
117
119
  case 22: /* Structure */
118
120
  case 29 /* Enumeration */:
119
121
  throw new Error("Not expecting Structure or Enumeration");
@@ -224,11 +226,15 @@ const isExtensionObject = async (session: IBasicSession, dataTypeNodeId: NodeId)
224
226
  return true;
225
227
  }
226
228
  const baseDataType = await findSuperType(session, dataTypeNodeId);
227
- if (baseDataType.namespace === 0 && baseDataType.value === DataType.ExtensionObject) {
228
- return true;
229
- }
230
- if (baseDataType.namespace === 0 && baseDataType.value < DataType.ExtensionObject) {
231
- return false;
229
+
230
+ const bn = baseDataType as INodeId;
231
+ if (bn.identifierType === NodeIdType.NUMERIC) {
232
+ if (bn.namespace === 0 && bn.value === DataType.ExtensionObject) {
233
+ return true;
234
+ }
235
+ if (bn.namespace === 0 && bn.value < DataType.ExtensionObject) {
236
+ return false;
237
+ }
232
238
  }
233
239
  return await isExtensionObject(session, baseDataType);
234
240
  };
@@ -1,14 +0,0 @@
1
- import { DataTypeFactory, FieldCategory, IStructuredTypeSchema, TypeDefinition } from "node-opcua-factory";
2
- import { NodeId } from "node-opcua-nodeid";
3
- import { IBasicSession } from "node-opcua-pseudo-session";
4
- import { DataTypeDefinition } from "node-opcua-types";
5
- export interface CacheForFieldResolution {
6
- fieldTypeName: string;
7
- schema: TypeDefinition;
8
- category: FieldCategory;
9
- allowSubType?: boolean;
10
- dataType?: NodeId;
11
- }
12
- export declare function convertDataTypeDefinitionToStructureTypeSchema(session: IBasicSession, dataTypeNodeId: NodeId, name: string, definition: DataTypeDefinition, dataTypeFactory: DataTypeFactory, isAbstract: boolean, cache: {
13
- [key: string]: CacheForFieldResolution;
14
- }): Promise<IStructuredTypeSchema>;
@@ -1,406 +0,0 @@
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.convertDataTypeDefinitionToStructureTypeSchema = void 0;
13
- const node_opcua_data_model_1 = require("node-opcua-data-model");
14
- const node_opcua_debug_1 = require("node-opcua-debug");
15
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
16
- //import { DataTypeIds } from "node-opcua-constant";
17
- const node_opcua_factory_1 = require("node-opcua-factory");
18
- const node_opcua_nodeid_2 = require("node-opcua-nodeid");
19
- const node_opcua_pseudo_session_1 = require("node-opcua-pseudo-session");
20
- const node_opcua_types_1 = require("node-opcua-types");
21
- const node_opcua_extension_object_1 = require("node-opcua-extension-object");
22
- //
23
- const node_opcua_variant_1 = require("node-opcua-variant");
24
- const find_encodings_1 = require("./private/find_encodings");
25
- const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
26
- const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
27
- const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
28
- function findSuperType(session, dataTypeNodeId) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- if (dataTypeNodeId.namespace === 0 && dataTypeNodeId.value === 24) {
31
- // BaseDataType !
32
- return (0, node_opcua_nodeid_2.coerceNodeId)(0);
33
- }
34
- const nodeToBrowse3 = {
35
- browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
36
- includeSubtypes: false,
37
- nodeClassMask: node_opcua_data_model_1.NodeClassMask.DataType,
38
- nodeId: dataTypeNodeId,
39
- referenceTypeId: (0, node_opcua_nodeid_2.resolveNodeId)("HasSubtype"),
40
- resultMask: (0, node_opcua_data_model_1.makeResultMask)("NodeId | ReferenceType | BrowseName | NodeClass")
41
- };
42
- const result3 = yield (0, node_opcua_pseudo_session_1.browseAll)(session, nodeToBrowse3);
43
- /* istanbul ignore next */
44
- if (result3.statusCode.isNotGood()) {
45
- throw new Error("Cannot find superType for " + dataTypeNodeId.toString());
46
- }
47
- result3.references = result3.references || [];
48
- /* istanbul ignore next */
49
- if (result3.references.length !== 1) {
50
- console.log(result3.toString());
51
- throw new Error("Invalid dataType with more than one (or 0) superType " + dataTypeNodeId.toString() + " l=" + result3.references.length);
52
- }
53
- return result3.references[0].nodeId;
54
- });
55
- }
56
- function findDataTypeCategory(session, cache, dataTypeNodeId) {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- const subTypeNodeId = yield findSuperType(session, dataTypeNodeId);
59
- debugLog("subTypeNodeId of ", dataTypeNodeId.toString(), " is ", subTypeNodeId.toString());
60
- const key = subTypeNodeId.toString();
61
- if (cache[key]) {
62
- return cache[key].category;
63
- }
64
- let category;
65
- if (subTypeNodeId.namespace === 0 && subTypeNodeId.value <= 29) {
66
- // well known node ID !
67
- switch (subTypeNodeId.value) {
68
- case 22 /* Structure */:
69
- category = node_opcua_factory_1.FieldCategory.complex;
70
- break;
71
- case 29 /* Enumeration */:
72
- category = node_opcua_factory_1.FieldCategory.enumeration;
73
- break;
74
- default:
75
- category = node_opcua_factory_1.FieldCategory.basic;
76
- break;
77
- }
78
- return category;
79
- }
80
- // must drill down ...
81
- return yield findDataTypeCategory(session, cache, subTypeNodeId);
82
- });
83
- }
84
- function findDataTypeBasicType(session, cache, dataTypeNodeId) {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- const subTypeNodeId = yield findSuperType(session, dataTypeNodeId);
87
- debugLog("subTypeNodeId of ", dataTypeNodeId.toString(), " is ", subTypeNodeId.toString());
88
- const key = subTypeNodeId.toString();
89
- if (cache[key]) {
90
- return cache[key].schema;
91
- }
92
- if (subTypeNodeId.namespace === 0 && subTypeNodeId.value < 29) {
93
- switch (subTypeNodeId.value) {
94
- case 22: /* Structure */
95
- case 29 /* Enumeration */:
96
- throw new Error("Not expecting Structure or Enumeration");
97
- default:
98
- break;
99
- }
100
- const nameDataValue = yield session.read({
101
- attributeId: node_opcua_data_model_1.AttributeIds.BrowseName,
102
- nodeId: subTypeNodeId
103
- });
104
- const name = nameDataValue.value.value.name;
105
- return (0, node_opcua_factory_1.getBuiltInType)(name);
106
- }
107
- // must drill down ...
108
- return yield findDataTypeBasicType(session, cache, subTypeNodeId);
109
- });
110
- }
111
- function readBrowseName(session, nodeId) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- const dataValue = yield session.read({ nodeId, attributeId: node_opcua_data_model_1.AttributeIds.BrowseName });
114
- if (dataValue.statusCode.isNotGood()) {
115
- const message = "cannot extract BrowseName of nodeId = " + nodeId.toString() + " statusCode = " + dataValue.statusCode.toString();
116
- debugLog(message);
117
- throw new Error(message);
118
- }
119
- return dataValue.value.value.name;
120
- });
121
- }
122
- function resolve2(session, dataTypeNodeId, dataTypeFactory, fieldTypeName, cache) {
123
- return __awaiter(this, void 0, void 0, function* () {
124
- const category = yield findDataTypeCategory(session, cache, dataTypeNodeId);
125
- debugLog(" type " + fieldTypeName + " has not been seen yet, let resolve it => (category = ", category, " )");
126
- let schema = undefined;
127
- switch (category) {
128
- case node_opcua_factory_1.FieldCategory.basic:
129
- schema = yield findDataTypeBasicType(session, cache, dataTypeNodeId);
130
- /* istanbul ignore next */
131
- if (!schema) {
132
- errorLog("Cannot find basic type " + fieldTypeName);
133
- }
134
- break;
135
- default:
136
- case node_opcua_factory_1.FieldCategory.complex:
137
- {
138
- const dataTypeDefinitionDataValue = yield session.read({
139
- attributeId: node_opcua_data_model_1.AttributeIds.DataTypeDefinition,
140
- nodeId: dataTypeNodeId
141
- });
142
- /* istanbul ignore next */
143
- if (dataTypeDefinitionDataValue.statusCode.isNotGood()) {
144
- throw new Error(" Cannot find dataType Definition ! with nodeId =" + dataTypeNodeId.toString());
145
- }
146
- const definition = dataTypeDefinitionDataValue.value.value;
147
- const convertIn64ToInteger = (a) => a[1];
148
- const convert = (fields) => {
149
- const retVal = {};
150
- fields && fields.forEach((field) => (retVal[field.name || ""] = convertIn64ToInteger(field.value)));
151
- return retVal;
152
- };
153
- if (category === node_opcua_factory_1.FieldCategory.enumeration) {
154
- if (definition instanceof node_opcua_types_1.EnumDefinition) {
155
- const e = new node_opcua_factory_1.EnumerationDefinitionSchema(dataTypeNodeId, {
156
- enumValues: convert(definition.fields),
157
- name: fieldTypeName
158
- });
159
- dataTypeFactory.registerEnumeration(e);
160
- schema = e;
161
- }
162
- }
163
- else {
164
- const isAbstract = false;
165
- schema = yield convertDataTypeDefinitionToStructureTypeSchema(session, dataTypeNodeId, fieldTypeName, definition, dataTypeFactory, isAbstract, cache);
166
- }
167
- // xx const schema1 = dataTypeFactory.getStructuredTypeSchema(fieldTypeName);
168
- }
169
- break;
170
- }
171
- return { schema, category };
172
- });
173
- }
174
- const isExtensionObject = (session, dataTypeNodeId) => __awaiter(void 0, void 0, void 0, function* () {
175
- if (dataTypeNodeId.namespace === 0 && dataTypeNodeId.value === node_opcua_variant_1.DataType.ExtensionObject) {
176
- return true;
177
- }
178
- const baseDataType = yield findSuperType(session, dataTypeNodeId);
179
- if (baseDataType.namespace === 0 && baseDataType.value === node_opcua_variant_1.DataType.ExtensionObject) {
180
- return true;
181
- }
182
- if (baseDataType.namespace === 0 && baseDataType.value < node_opcua_variant_1.DataType.ExtensionObject) {
183
- return false;
184
- }
185
- return yield isExtensionObject(session, baseDataType);
186
- });
187
- // eslint-disable-next-line max-statements
188
- function resolveFieldType(session, dataTypeNodeId, dataTypeFactory, cache) {
189
- return __awaiter(this, void 0, void 0, function* () {
190
- if (dataTypeNodeId.namespace === 0 && dataTypeNodeId.value === 22) {
191
- // ERN return null;
192
- const category = node_opcua_factory_1.FieldCategory.complex;
193
- const fieldTypeName = "Structure";
194
- const schema = node_opcua_extension_object_1.ExtensionObject.schema;
195
- return {
196
- category,
197
- fieldTypeName,
198
- schema,
199
- allowSubType: true,
200
- dataType: (0, node_opcua_nodeid_2.coerceNodeId)(node_opcua_variant_1.DataType.ExtensionObject)
201
- };
202
- }
203
- const key = dataTypeNodeId.toString();
204
- const v = cache[key];
205
- if (v) {
206
- return v;
207
- }
208
- if (dataTypeNodeId.value === 0) {
209
- const v3 = {
210
- category: node_opcua_factory_1.FieldCategory.basic,
211
- fieldTypeName: "Variant",
212
- schema: dataTypeFactory.getBuiltInType("Variant")
213
- };
214
- cache[key] = v3;
215
- return v3;
216
- }
217
- const isAbstract = (yield session.read({ nodeId: dataTypeNodeId, attributeId: node_opcua_data_model_1.AttributeIds.IsAbstract })).value.value;
218
- const fieldTypeName = yield readBrowseName(session, dataTypeNodeId);
219
- if (isAbstract) {
220
- const _isExtensionObject = yield isExtensionObject(session, dataTypeNodeId);
221
- debugLog(" dataType " + dataTypeNodeId.toString() + " " + fieldTypeName + " is abstract => extObj ?= " + _isExtensionObject);
222
- if (_isExtensionObject) {
223
- // we could have complex => Structure
224
- const v3 = {
225
- category: node_opcua_factory_1.FieldCategory.complex,
226
- fieldTypeName: fieldTypeName,
227
- schema: node_opcua_extension_object_1.ExtensionObject.schema,
228
- allowSubType: true,
229
- dataType: dataTypeNodeId
230
- };
231
- cache[key] = v3;
232
- return v3;
233
- }
234
- else {
235
- // we could have basic => Variant
236
- const v3 = {
237
- category: node_opcua_factory_1.FieldCategory.basic,
238
- fieldTypeName: fieldTypeName,
239
- schema: dataTypeFactory.getBuiltInType("Variant"),
240
- allowSubType: true,
241
- dataType: dataTypeNodeId
242
- };
243
- cache[key] = v3;
244
- return v3;
245
- }
246
- }
247
- let schema;
248
- let category = node_opcua_factory_1.FieldCategory.enumeration;
249
- if (dataTypeFactory.hasStructureByTypeName(fieldTypeName)) {
250
- schema = dataTypeFactory.getStructuredTypeSchema(fieldTypeName);
251
- category = node_opcua_factory_1.FieldCategory.complex;
252
- }
253
- else if (dataTypeFactory.hasBuiltInType(fieldTypeName)) {
254
- category = node_opcua_factory_1.FieldCategory.basic;
255
- schema = dataTypeFactory.getBuiltInType(fieldTypeName);
256
- }
257
- else if (dataTypeFactory.hasEnumeration(fieldTypeName)) {
258
- category = node_opcua_factory_1.FieldCategory.enumeration;
259
- schema = dataTypeFactory.getEnumeration(fieldTypeName);
260
- }
261
- else {
262
- debugLog(" type " + fieldTypeName + " has not been seen yet, let resolve it");
263
- const res = yield resolve2(session, dataTypeNodeId, dataTypeFactory, fieldTypeName, cache);
264
- schema = res.schema;
265
- category = res.category;
266
- }
267
- /* istanbul ignore next */
268
- if (!schema) {
269
- throw new Error("expecting a schema here fieldTypeName=" + fieldTypeName + " " + dataTypeNodeId.toString() + " category = " + category);
270
- }
271
- const v2 = {
272
- category,
273
- fieldTypeName,
274
- schema
275
- };
276
- cache[key] = v2;
277
- return v2;
278
- });
279
- }
280
- function _setupEncodings(session, dataTypeNodeId, schema) {
281
- return __awaiter(this, void 0, void 0, function* () {
282
- // read abstract flag
283
- const isAbstractDV = yield session.read({ nodeId: dataTypeNodeId, attributeId: node_opcua_data_model_1.AttributeIds.IsAbstract });
284
- schema.dataTypeNodeId = dataTypeNodeId;
285
- if (isAbstractDV.statusCode.isGood() && isAbstractDV.value.value === false) {
286
- const encodings = yield (0, find_encodings_1._findEncodings)(session, dataTypeNodeId);
287
- schema.encodingDefaultBinary = (0, node_opcua_nodeid_2.makeExpandedNodeId)(encodings.binaryEncodingNodeId);
288
- schema.encodingDefaultXml = (0, node_opcua_nodeid_2.makeExpandedNodeId)(encodings.xmlEncodingNodeId);
289
- schema.encodingDefaultJson = (0, node_opcua_nodeid_2.makeExpandedNodeId)(encodings.jsonEncodingNodeId);
290
- }
291
- return schema;
292
- });
293
- }
294
- // eslint-disable-next-line max-statements
295
- function convertDataTypeDefinitionToStructureTypeSchema(session, dataTypeNodeId, name, definition, dataTypeFactory, isAbstract, cache) {
296
- return __awaiter(this, void 0, void 0, function* () {
297
- if (definition instanceof node_opcua_types_1.StructureDefinition) {
298
- let fieldCountToIgnore = 0;
299
- const structureInfo = dataTypeFactory.getStructureInfoForDataType(definition.baseDataType);
300
- const baseSchema = structureInfo === null || structureInfo === void 0 ? void 0 : structureInfo.schema;
301
- if (baseSchema) {
302
- const possibleFields = (0, node_opcua_factory_1.extractAllPossibleFields)(baseSchema);
303
- fieldCountToIgnore += possibleFields.length;
304
- }
305
- // while (base && !(base.dataTypeNodeId.value === DataType.ExtensionObject && base.dataTypeNodeId.namespace === 0)) {
306
- // fieldCountToIgnore += base..length;
307
- // base = base.getBaseSchema();
308
- // }
309
- const fields = [];
310
- const isUnion = definition.structureType === node_opcua_types_1.StructureType.Union;
311
- switch (definition.structureType) {
312
- case node_opcua_types_1.StructureType.Union:
313
- // xx console.log("Union Found : ", name);
314
- fields.push({
315
- fieldType: "UInt32",
316
- name: "SwitchField"
317
- });
318
- break;
319
- case node_opcua_types_1.StructureType.Structure:
320
- case node_opcua_types_1.StructureType.StructureWithOptionalFields:
321
- break;
322
- }
323
- let switchValue = 1;
324
- let switchBit = 0;
325
- const bitFields = isUnion ? undefined : [];
326
- const postActions = [];
327
- if (definition.fields) {
328
- for (let i = fieldCountToIgnore; i < definition.fields.length; i++) {
329
- const fieldD = definition.fields[i];
330
- // we need to skip fields that have already been handled in base class
331
- let field;
332
- ({ field, switchBit, switchValue } = createField(fieldD, switchBit, bitFields, isUnion, switchValue));
333
- if (fieldD.dataType.value === dataTypeNodeId.value && fieldD.dataType.namespace === dataTypeNodeId.namespace) {
334
- // this is a structure with a field of the same type
335
- // push an empty placeholder that we will fill later
336
- const fieldTypeName = yield readBrowseName(session, dataTypeNodeId);
337
- (field.fieldType = fieldTypeName), (field.category = node_opcua_factory_1.FieldCategory.complex);
338
- fields.push(field);
339
- const capturedField = field;
340
- postActions.push((schema) => {
341
- capturedField.schema = schema;
342
- });
343
- continue;
344
- }
345
- const rt = (yield resolveFieldType(session, fieldD.dataType, dataTypeFactory, cache));
346
- if (!rt) {
347
- errorLog("convertDataTypeDefinitionToStructureTypeSchema cannot handle field", fieldD.name, "in", name, "because " + fieldD.dataType.toString() + " cannot be resolved");
348
- continue;
349
- }
350
- const { schema, category, fieldTypeName, dataType, allowSubType } = rt;
351
- field.fieldType = fieldTypeName;
352
- field.category = category;
353
- field.schema = schema;
354
- field.dataType = dataType || fieldD.dataType;
355
- field.allowSubType = allowSubType || false;
356
- field.basicDataType = yield (0, node_opcua_pseudo_session_1.findBasicDataType)(session, field.dataType);
357
- fields.push(field);
358
- }
359
- }
360
- /// some server may provide definition.baseDataType to be i=22 (ExtensionObject)
361
- /// instead of 12756 Union;
362
- if (isUnion && (0, node_opcua_nodeid_1.sameNodeId)(definition.baseDataType, (0, node_opcua_nodeid_2.coerceNodeId)("i=22"))) {
363
- definition.baseDataType = (0, node_opcua_nodeid_2.resolveNodeId)("i=1276"); // aka DataTypeIds.Union
364
- }
365
- const a = yield resolveFieldType(session, definition.baseDataType, dataTypeFactory, cache);
366
- const baseType = a ? a.fieldTypeName : isUnion ? "Union" : "ExtensionObject";
367
- const os = new node_opcua_factory_1.StructuredTypeSchema({
368
- baseType,
369
- bitFields,
370
- fields,
371
- name,
372
- dataTypeFactory
373
- });
374
- const structuredTypeSchema = yield _setupEncodings(session, dataTypeNodeId, os);
375
- postActions.forEach((action) => action(structuredTypeSchema));
376
- return structuredTypeSchema;
377
- }
378
- throw new Error("Not Implemented");
379
- function createField(fieldD, switchBit, bitFields, isUnion, switchValue) {
380
- const field = {
381
- fieldType: "",
382
- name: fieldD.name,
383
- schema: undefined
384
- };
385
- if (fieldD.isOptional) {
386
- field.switchBit = switchBit++;
387
- bitFields === null || bitFields === void 0 ? void 0 : bitFields.push({ name: fieldD.name + "Specified", length: 1 });
388
- }
389
- if (isUnion) {
390
- field.switchValue = switchValue;
391
- switchValue += 1;
392
- }
393
- // (fieldD.valueRank === -1 || fieldD.valueRank === 1 || fieldD.valueRank === 0);
394
- if (fieldD.valueRank >= 1) {
395
- field.valueRank = fieldD.valueRank;
396
- field.isArray = true;
397
- }
398
- else {
399
- field.isArray = false;
400
- }
401
- return { field, switchBit, switchValue };
402
- }
403
- });
404
- }
405
- exports.convertDataTypeDefinitionToStructureTypeSchema = convertDataTypeDefinitionToStructureTypeSchema;
406
- //# sourceMappingURL=convert_data_type_definition_to_structuretype_schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convert_data_type_definition_to_structuretype_schema.js","sourceRoot":"","sources":["../source/convert_data_type_definition_to_structuretype_schema.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iEAAqG;AAErG,uDAAiF;AACjF,yDAA+C;AAC/C,oDAAoD;AACpD,2DAY4B;AAC5B,yDAA4F;AAC5F,yEAAmI;AAEnI,uDAO0B;AAC1B,6EAA8D;AAC9D,EAAE;AACF,2DAA8C;AAC9C,6DAA0D;AAE1D,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,UAAU,GAAG,IAAA,kCAAe,EAAC,UAAU,CAAC,CAAC;AAE/C,SAAe,aAAa,CAAC,OAAsB,EAAE,cAAsB;;QACvE,IAAI,cAAc,CAAC,SAAS,KAAK,CAAC,IAAI,cAAc,CAAC,KAAK,KAAK,EAAE,EAAE;YAC/D,iBAAiB;YACjB,OAAO,IAAA,gCAAY,EAAC,CAAC,CAAC,CAAC;SAC1B;QAED,MAAM,aAAa,GAA0B;YACzC,eAAe,EAAE,uCAAe,CAAC,OAAO;YACxC,eAAe,EAAE,KAAK;YACtB,aAAa,EAAE,qCAAa,CAAC,QAAQ;YACrC,MAAM,EAAE,cAAc;YACtB,eAAe,EAAE,IAAA,iCAAa,EAAC,YAAY,CAAC;YAC5C,UAAU,EAAE,IAAA,sCAAc,EAAC,iDAAiD,CAAC;SAChF,CAAC;QACF,MAAM,OAAO,GAAG,MAAM,IAAA,qCAAS,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAExD,0BA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/B;QACD,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAEnC,SAAS,WAAW,CAChB,MAAsB,EACtB,SAAiB,EACjB,SAAiC,EACjC,OAAgB,EAChB,WAAmB;YAEnB,MAAM,KAAK,GAA0B;gBACjC,SAAS,EAAE,EAAE;gBACb,IAAI,EAAE,MAAM,CAAC,IAAK;gBAClB,MAAM,EAAE,SAAS;aACpB,CAAC;YAEF,IAAI,MAAM,CAAC,UAAU,EAAE;gBACnB,KAAK,CAAC,SAAS,GAAG,SAAS,EAAE,CAAC;gBAC9B,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAK,GAAG,WAAW,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;aACpE;YACD,IAAI,OAAO,EAAE;gBACT,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;gBAChC,WAAW,IAAI,CAAC,CAAC;aACpB;YAED,iFAAiF;YAEjF,IAAI,MAAM,CAAC,SAAS,IAAI,CAAC,EAAE;gBACvB,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;gBACnC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;aACxB;iBAAM;gBACH,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;aACzB;YACD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;QAC7C,CAAC;IACL,CAAC;CAAA;AAjJD,wGAiJC"}
@@ -1,3 +0,0 @@
1
- import { IStructuredTypeSchema } from "node-opcua-factory";
2
- import { StructureDefinition } from "node-opcua-types";
3
- export declare function convertStructureTypeSchemaToStructureDefinition(st: IStructuredTypeSchema): StructureDefinition;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertStructureTypeSchemaToStructureDefinition = void 0;
4
- const node_opcua_factory_1 = require("node-opcua-factory");
5
- const node_opcua_types_1 = require("node-opcua-types");
6
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
7
- function _getDataType(field) {
8
- switch (field.category) {
9
- case node_opcua_factory_1.FieldCategory.complex:
10
- return (0, node_opcua_nodeid_1.resolveNodeId)(field.schema.dataTypeNodeId);
11
- case node_opcua_factory_1.FieldCategory.basic:
12
- return (0, node_opcua_nodeid_1.resolveNodeId)(field.fieldType);
13
- case node_opcua_factory_1.FieldCategory.enumeration:
14
- default:
15
- return (0, node_opcua_nodeid_1.resolveNodeId)(field.dataType);
16
- }
17
- }
18
- function convertStructureTypeSchemaToStructureDefinition(st) {
19
- var _a;
20
- let structureType = node_opcua_types_1.StructureType.Invalid;
21
- let isUnion = false;
22
- if (st.baseType === "Union") {
23
- structureType = node_opcua_types_1.StructureType.Union;
24
- isUnion = true;
25
- }
26
- else {
27
- structureType = node_opcua_types_1.StructureType.Structure;
28
- }
29
- // convert partial field (not including base class)
30
- const structureDefinition = {
31
- fields: [],
32
- baseDataType: (_a = st.getBaseSchema()) === null || _a === void 0 ? void 0 : _a.dataTypeNodeId,
33
- defaultEncodingId: st.encodingDefaultBinary,
34
- structureType
35
- };
36
- const fields = structureDefinition.fields || [];
37
- for (const f of st.fields) {
38
- const dataType = _getDataType(f);
39
- if (isUnion && f.originalName === "SwitchField") {
40
- continue;
41
- }
42
- fields.push({
43
- arrayDimensions: f.isArray ? [] : undefined,
44
- valueRank: f.isArray ? 1 : -1,
45
- dataType,
46
- isOptional: isUnion ? undefined : f.switchValue !== undefined,
47
- description: f.documentation || undefined,
48
- name: f.originalName
49
- });
50
- }
51
- return new node_opcua_types_1.StructureDefinition(structureDefinition);
52
- }
53
- exports.convertStructureTypeSchemaToStructureDefinition = convertStructureTypeSchemaToStructureDefinition;
54
- //# sourceMappingURL=convert_structuretype_schema_to_structure_definition.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convert_structuretype_schema_to_structure_definition.js","sourceRoot":"","sources":["../source/convert_structuretype_schema_to_structure_definition.ts"],"names":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AAe,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;YAC3C,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7B,QAAQ;YACR,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,SAAS;YAC5D,WAAW,EAAE,CAAC,CAAC,aAAa,IAAI,SAAS;YACzC,IAAI,EAAE,CAAC,CAAC,YAAY;SACvB,CAAC,CAAC;KACN;IACD,OAAO,IAAI,sCAAmB,CAAC,mBAAmB,CAAC,CAAC;AACxD,CAAC;AAjCD,0GAiCC"}
@@ -1,16 +0,0 @@
1
- import { ConstructorFunc, DataTypeFactory } from "node-opcua-factory";
2
- import { NodeId } from "node-opcua-nodeid";
3
- import { AnyConstructorFunc } from "node-opcua-schemas";
4
- export declare class ExtraDataTypeManager {
5
- namespaceArray: string[];
6
- private dataTypeFactoryMapByNamespace;
7
- constructor();
8
- setNamespaceArray(namespaceArray: string[]): void;
9
- hasDataTypeFactory(namespaceIndex: number): boolean;
10
- registerDataTypeFactory(namespaceIndex: number, dataTypeFactory: DataTypeFactory): void;
11
- getDataTypeFactoryForNamespace(namespaceIndex: number): DataTypeFactory;
12
- getDataTypeFactory(namespaceIndex: number): DataTypeFactory;
13
- getExtensionObjectConstructorFromDataType(dataTypeNodeId: NodeId): AnyConstructorFunc;
14
- getExtensionObjectConstructorFromBinaryEncoding(binaryEncodingNodeId: NodeId): ConstructorFunc;
15
- toString(): string;
16
- }