node-opcua-schemas 2.76.0 → 2.76.2

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.
@@ -1,2 +1,2 @@
1
- import { DataTypeFactory } from "node-opcua-factory";
2
- export declare function toTypeScript(dataTypeFactory: DataTypeFactory): string;
1
+ import { DataTypeFactory } from "node-opcua-factory";
2
+ export declare function toTypeScript(dataTypeFactory: DataTypeFactory): string;
@@ -1,106 +1,106 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toTypeScript = void 0;
4
- function toTypeScript(dataTypeFactory) {
5
- const enumeratedTypes = dataTypeFactory._enumerations;
6
- const structuredTypes = dataTypeFactory._structureTypeConstructorByNameMap;
7
- const declaration = new Map();
8
- function adjustType(t) {
9
- if (t === "String") {
10
- t = "UAString";
11
- }
12
- else if (t === "Boolean") {
13
- t = "UABoolean";
14
- }
15
- if (!enumeratedTypes.has(t) && !structuredTypes.has(t)) {
16
- declaration.set(t, t);
17
- }
18
- return t;
19
- }
20
- const l = [];
21
- // enumeration
22
- for (const e of enumeratedTypes.values()) {
23
- l.push(`export enum ${e.name} {`);
24
- // console.log((e.typedEnum as any).enumItems);
25
- for (const v of Object.entries(e.enumValues)) {
26
- const vv = parseInt(v[0], 10);
27
- if (vv >= 0) {
28
- continue;
29
- }
30
- l.push(` ${v[0]} = ${v[1]},`);
31
- }
32
- l.push(`}`);
33
- }
34
- const alreadyDone = new Set();
35
- function dumpType(o) {
36
- var _a;
37
- // base type first
38
- const b = o.baseType;
39
- const bt = (_a = structuredTypes.get(b)) === null || _a === void 0 ? void 0 : _a.schema;
40
- if (b && !alreadyDone.has(o.baseType) && bt) {
41
- dumpType(bt);
42
- }
43
- alreadyDone.add(o.name);
44
- const ex1 = b && bt ? `extends ${b} ` : "";
45
- if (o.baseType === "Union") {
46
- const p = [];
47
- let switchFieldName = "";
48
- // find switchFieldName
49
- for (const field of o.fields) {
50
- if (field.switchValue === undefined) {
51
- // this is the switch value field
52
- switchFieldName = field.name;
53
- break;
54
- }
55
- }
56
- // export all flavors
57
- for (const field of o.fields) {
58
- const name = field.name;
59
- if (field.switchValue === undefined) {
60
- continue;
61
- }
62
- const a = field.isArray ? "[]" : "";
63
- const fieldType = adjustType(field.schema.name);
64
- l.push(`interface ${o.name}${field.switchValue} ${ex1}{`);
65
- l.push(` ${switchFieldName}: ${field.switchValue};`);
66
- l.push(` ${field.name}: ${fieldType}${a};`);
67
- l.push(`}`);
68
- p.push(`${o.name}${field.switchValue}`);
69
- }
70
- const pp = p.join(" | ");
71
- l.push(`type ${o.name} = ${pp};`);
72
- }
73
- else {
74
- if (o.fields.length === 0) {
75
- l.push("// tslint:disable-next-line: no-empty-interface");
76
- }
77
- l.push(`interface ${o.name} ${ex1}{`);
78
- for (const f of o.fields) {
79
- if (f.documentation) {
80
- l.push(` // ${f.documentation}`);
81
- }
82
- const isOpt = f.switchBit !== undefined ? "?" : "";
83
- const fieldType = adjustType(f.schema.name);
84
- if (f.isArray) {
85
- l.push(` ${f.name}${isOpt}: ${fieldType}[];`);
86
- }
87
- else {
88
- l.push(` ${f.name}${isOpt}: ${fieldType};`);
89
- }
90
- }
91
- l.push(`}`);
92
- }
93
- }
94
- // objects
95
- for (const o of structuredTypes.values()) {
96
- if (alreadyDone.has(o.schema.name)) {
97
- continue;
98
- }
99
- dumpType(o.schema);
100
- }
101
- const opcuaTypes = [...declaration.keys()].sort().join(",\n ");
102
- l.unshift(`import {\n ${opcuaTypes}\n} from "node-opcua";`);
103
- return l.join("\n");
104
- }
105
- exports.toTypeScript = toTypeScript;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toTypeScript = void 0;
4
+ function toTypeScript(dataTypeFactory) {
5
+ const enumeratedTypes = dataTypeFactory._enumerations;
6
+ const structuredTypes = dataTypeFactory._structureTypeConstructorByNameMap;
7
+ const declaration = new Map();
8
+ function adjustType(t) {
9
+ if (t === "String") {
10
+ t = "UAString";
11
+ }
12
+ else if (t === "Boolean") {
13
+ t = "UABoolean";
14
+ }
15
+ if (!enumeratedTypes.has(t) && !structuredTypes.has(t)) {
16
+ declaration.set(t, t);
17
+ }
18
+ return t;
19
+ }
20
+ const l = [];
21
+ // enumeration
22
+ for (const e of enumeratedTypes.values()) {
23
+ l.push(`export enum ${e.name} {`);
24
+ // console.log((e.typedEnum as any).enumItems);
25
+ for (const v of Object.entries(e.enumValues)) {
26
+ const vv = parseInt(v[0], 10);
27
+ if (vv >= 0) {
28
+ continue;
29
+ }
30
+ l.push(` ${v[0]} = ${v[1]},`);
31
+ }
32
+ l.push(`}`);
33
+ }
34
+ const alreadyDone = new Set();
35
+ function dumpType(o) {
36
+ var _a;
37
+ // base type first
38
+ const b = o.baseType;
39
+ const bt = (_a = structuredTypes.get(b)) === null || _a === void 0 ? void 0 : _a.schema;
40
+ if (b && !alreadyDone.has(o.baseType) && bt) {
41
+ dumpType(bt);
42
+ }
43
+ alreadyDone.add(o.name);
44
+ const ex1 = b && bt ? `extends ${b} ` : "";
45
+ if (o.baseType === "Union") {
46
+ const p = [];
47
+ let switchFieldName = "";
48
+ // find switchFieldName
49
+ for (const field of o.fields) {
50
+ if (field.switchValue === undefined) {
51
+ // this is the switch value field
52
+ switchFieldName = field.name;
53
+ break;
54
+ }
55
+ }
56
+ // export all flavors
57
+ for (const field of o.fields) {
58
+ const name = field.name;
59
+ if (field.switchValue === undefined) {
60
+ continue;
61
+ }
62
+ const a = field.isArray ? "[]" : "";
63
+ const fieldType = adjustType(field.schema.name);
64
+ l.push(`interface ${o.name}${field.switchValue} ${ex1}{`);
65
+ l.push(` ${switchFieldName}: ${field.switchValue};`);
66
+ l.push(` ${field.name}: ${fieldType}${a};`);
67
+ l.push(`}`);
68
+ p.push(`${o.name}${field.switchValue}`);
69
+ }
70
+ const pp = p.join(" | ");
71
+ l.push(`type ${o.name} = ${pp};`);
72
+ }
73
+ else {
74
+ if (o.fields.length === 0) {
75
+ l.push("// tslint:disable-next-line: no-empty-interface");
76
+ }
77
+ l.push(`interface ${o.name} ${ex1}{`);
78
+ for (const f of o.fields) {
79
+ if (f.documentation) {
80
+ l.push(` // ${f.documentation}`);
81
+ }
82
+ const isOpt = f.switchBit !== undefined ? "?" : "";
83
+ const fieldType = adjustType(f.schema.name);
84
+ if (f.isArray) {
85
+ l.push(` ${f.name}${isOpt}: ${fieldType}[];`);
86
+ }
87
+ else {
88
+ l.push(` ${f.name}${isOpt}: ${fieldType};`);
89
+ }
90
+ }
91
+ l.push(`}`);
92
+ }
93
+ }
94
+ // objects
95
+ for (const o of structuredTypes.values()) {
96
+ if (alreadyDone.has(o.schema.name)) {
97
+ continue;
98
+ }
99
+ dumpType(o.schema);
100
+ }
101
+ const opcuaTypes = [...declaration.keys()].sort().join(",\n ");
102
+ l.unshift(`import {\n ${opcuaTypes}\n} from "node-opcua";`);
103
+ return l.join("\n");
104
+ }
105
+ exports.toTypeScript = toTypeScript;
106
106
  //# sourceMappingURL=toTypeScript.js.map
@@ -1,3 +1,3 @@
1
- import { DataTypeFactory, IStructuredTypeSchema } from "node-opcua-factory";
2
- import { MapDataTypeAndEncodingIdProvider, TypeDictionary } from "./parse_binary_xsd";
3
- export declare function getOrCreateStructuredTypeSchema(name: string, typeDictionary: TypeDictionary, dataTypeFactory: DataTypeFactory, idProvider: MapDataTypeAndEncodingIdProvider): IStructuredTypeSchema;
1
+ import { DataTypeFactory, IStructuredTypeSchema } from "node-opcua-factory";
2
+ import { MapDataTypeAndEncodingIdProvider, TypeDictionary } from "./parse_binary_xsd";
3
+ export declare function getOrCreateStructuredTypeSchema(name: string, typeDictionary: TypeDictionary, dataTypeFactory: DataTypeFactory, idProvider: MapDataTypeAndEncodingIdProvider): IStructuredTypeSchema;
@@ -1,171 +1,171 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOrCreateStructuredTypeSchema = void 0;
4
- /* eslint-disable max-depth */
5
- /* eslint-disable max-statements */
6
- const node_opcua_debug_1 = require("node-opcua-debug");
7
- const node_opcua_factory_1 = require("node-opcua-factory");
8
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
9
- const dynamic_extension_object_1 = require("./dynamic_extension_object");
10
- const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
11
- function _removeNamespacePart(str) {
12
- if (!str) {
13
- return str;
14
- }
15
- const data = str.split(":");
16
- return data.length > 1 ? data[1] : str;
17
- }
18
- function _getNamespacePart(str) {
19
- return str.split(":")[0];
20
- }
21
- function _adjustFieldTypeName(fieldTypeName) {
22
- // special cases
23
- if (fieldTypeName === "UAString" || fieldTypeName === "CharArray") {
24
- fieldTypeName = "String";
25
- }
26
- if (fieldTypeName === "UABoolean") {
27
- fieldTypeName = "Boolean";
28
- }
29
- return fieldTypeName;
30
- }
31
- function getOrCreateStructuredTypeSchema(name, typeDictionary, dataTypeFactory, idProvider) {
32
- // eslint-disable-next-line complexity
33
- function _getOrCreateStructuredTypeSchema(_name) {
34
- if (dataTypeFactory.hasStructuredType(_name)) {
35
- return dataTypeFactory.getStructuredTypeSchema(_name);
36
- }
37
- if (dataTypeFactory.hasEnumeration(_name)) {
38
- return dataTypeFactory.getEnumeration(_name);
39
- }
40
- if (dataTypeFactory.hasBuiltInType(_name)) {
41
- return dataTypeFactory.getBuiltInType(_name);
42
- }
43
- // construct it !
44
- const structuredType = typeDictionary.getStructuredTypesRawByName(_name);
45
- if (!structuredType) {
46
- throw new Error("Cannot find structuredType " + _name);
47
- }
48
- structuredType.baseType = _removeNamespacePart(structuredType.baseType);
49
- structuredType.baseType = structuredType.baseType ? structuredType.baseType : "ExtensionObject";
50
- const baseSchema = typeDictionary.getStructuredTypesRawByName(structuredType.baseType);
51
- // remove redundant fields
52
- // Note :some file do no thave SourceType property and may be replicated here ..
53
- // but they belongs to the base class and shall be remove/
54
- // For instance DataTypeSchemaHeader => UABinaryFileDataType
55
- if (baseSchema && baseSchema.fields && baseSchema.name !== "ExtensionObject") {
56
- structuredType.fields = structuredType.fields.filter((field) => {
57
- const name = field.name;
58
- const index = baseSchema.fields.findIndex((f) => f.name === name);
59
- // istanbul ignore next
60
- if (index >= 0) {
61
- errorLog("Warning : find duplicated field from base structure : field name ", name, "baseSchema = ", baseSchema.name, "schema =", structuredType.name);
62
- }
63
- return index < 0;
64
- });
65
- }
66
- for (const field of structuredType.fields) {
67
- const fieldType = field.fieldType;
68
- if (!field.schema) {
69
- const prefix = _getNamespacePart(fieldType);
70
- const fieldTypeName = _adjustFieldTypeName(_removeNamespacePart(fieldType));
71
- switch (prefix) {
72
- case "tns":
73
- field.fieldType = fieldTypeName;
74
- if (dataTypeFactory.hasEnumeration(fieldTypeName)) {
75
- const enumeratedType = dataTypeFactory.getEnumeration(fieldTypeName);
76
- field.category = node_opcua_factory_1.FieldCategory.enumeration;
77
- field.schema = enumeratedType;
78
- }
79
- else {
80
- // must be a structure then ....
81
- field.category = node_opcua_factory_1.FieldCategory.complex;
82
- const schema1 = dataTypeFactory.getStructuredTypeSchema(fieldTypeName);
83
- field.schema = schema1;
84
- // _getOrCreateStructuredTypeSchema(fieldTypeName);
85
- // istanbul ignore next
86
- if (!field.schema) {
87
- errorLog("cannot find schema for ", fieldTypeName);
88
- }
89
- }
90
- break;
91
- case "ua":
92
- field.fieldType = fieldTypeName;
93
- if ((0, node_opcua_factory_1.hasBuiltInType)(fieldTypeName)) {
94
- field.category = node_opcua_factory_1.FieldCategory.basic;
95
- field.schema = (0, node_opcua_factory_1.getBuiltInType)(fieldTypeName);
96
- }
97
- else if (dataTypeFactory.hasStructuredType(fieldTypeName)) {
98
- field.category = node_opcua_factory_1.FieldCategory.complex;
99
- field.schema = dataTypeFactory.getStructuredTypeSchema(fieldTypeName);
100
- }
101
- else {
102
- field.category = node_opcua_factory_1.FieldCategory.basic;
103
- // try in this
104
- field.schema = _getOrCreateStructuredTypeSchema(fieldTypeName);
105
- // istanbul ignore next
106
- if (!field.schema) {
107
- errorLog("What should I do ??", fieldTypeName, " ", (0, node_opcua_factory_1.hasStructuredType)(fieldTypeName));
108
- }
109
- else {
110
- if ((0, node_opcua_factory_1.hasBuiltInType)(fieldTypeName)) {
111
- field.category = node_opcua_factory_1.FieldCategory.basic;
112
- }
113
- else {
114
- field.category = node_opcua_factory_1.FieldCategory.complex;
115
- }
116
- }
117
- }
118
- break;
119
- case "opc":
120
- if ((fieldTypeName === "UAString" || fieldTypeName === "String") && field.name === "IndexRange") {
121
- field.fieldType = "NumericRange";
122
- }
123
- else {
124
- field.fieldType = fieldTypeName;
125
- }
126
- if (!(0, node_opcua_factory_1.hasBuiltInType)(fieldTypeName)) {
127
- throw new Error("Unknown basic type " + fieldTypeName);
128
- }
129
- field.category = node_opcua_factory_1.FieldCategory.basic;
130
- break;
131
- default:
132
- if (dataTypeFactory.hasEnumeration(fieldTypeName)) {
133
- field.category = node_opcua_factory_1.FieldCategory.enumeration;
134
- const enumeratedType = dataTypeFactory.getEnumeration(fieldTypeName);
135
- field.schema = enumeratedType;
136
- }
137
- else if (dataTypeFactory.hasStructuredType(fieldTypeName)) {
138
- field.category = node_opcua_factory_1.FieldCategory.complex;
139
- const schema1 = dataTypeFactory.getStructuredTypeSchema(fieldTypeName);
140
- field.schema = schema1;
141
- }
142
- break;
143
- }
144
- }
145
- }
146
- const schema = (0, node_opcua_factory_1.buildStructuredType)(structuredType);
147
- const ids = idProvider.getDataTypeAndEncodingId(schema.name);
148
- if (!ids) {
149
- // this may happen if the type is abstract or if the type referes to a internal ExtnsionObject
150
- // that can only exists inside an other extension object.this Type of extension object cannot
151
- // instantiated as standalone object and do not have encoding nodeIds...
152
- const Constructor = (0, dynamic_extension_object_1.createDynamicObjectConstructor)(schema, dataTypeFactory);
153
- return schema;
154
- }
155
- schema.id = ids.dataTypeNodeId;
156
- schema.dataTypeNodeId = ids.dataTypeNodeId;
157
- if (schema.id.namespace === 0 && schema.id.value === 0) {
158
- return schema;
159
- }
160
- schema.encodingDefaultXml = node_opcua_nodeid_1.ExpandedNodeId.fromNodeId(ids.xmlEncodingNodeId);
161
- schema.encodingDefaultJson = node_opcua_nodeid_1.ExpandedNodeId.fromNodeId(ids.jsonEncodingNodeId);
162
- schema.encodingDefaultBinary = node_opcua_nodeid_1.ExpandedNodeId.fromNodeId(ids.binaryEncodingNodeId);
163
- const Constructor = (0, dynamic_extension_object_1.createDynamicObjectConstructor)(schema, dataTypeFactory);
164
- Constructor.encodingDefaultBinary = schema.encodingDefaultBinary;
165
- Constructor.encodingDefaultXml = schema.encodingDefaultXml;
166
- return schema;
167
- }
168
- return _getOrCreateStructuredTypeSchema(name);
169
- }
170
- exports.getOrCreateStructuredTypeSchema = getOrCreateStructuredTypeSchema;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOrCreateStructuredTypeSchema = void 0;
4
+ /* eslint-disable max-depth */
5
+ /* eslint-disable max-statements */
6
+ const node_opcua_debug_1 = require("node-opcua-debug");
7
+ const node_opcua_factory_1 = require("node-opcua-factory");
8
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
9
+ const dynamic_extension_object_1 = require("./dynamic_extension_object");
10
+ const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
11
+ function _removeNamespacePart(str) {
12
+ if (!str) {
13
+ return str;
14
+ }
15
+ const data = str.split(":");
16
+ return data.length > 1 ? data[1] : str;
17
+ }
18
+ function _getNamespacePart(str) {
19
+ return str.split(":")[0];
20
+ }
21
+ function _adjustFieldTypeName(fieldTypeName) {
22
+ // special cases
23
+ if (fieldTypeName === "UAString" || fieldTypeName === "CharArray") {
24
+ fieldTypeName = "String";
25
+ }
26
+ if (fieldTypeName === "UABoolean") {
27
+ fieldTypeName = "Boolean";
28
+ }
29
+ return fieldTypeName;
30
+ }
31
+ function getOrCreateStructuredTypeSchema(name, typeDictionary, dataTypeFactory, idProvider) {
32
+ // eslint-disable-next-line complexity
33
+ function _getOrCreateStructuredTypeSchema(_name) {
34
+ if (dataTypeFactory.hasStructuredType(_name)) {
35
+ return dataTypeFactory.getStructuredTypeSchema(_name);
36
+ }
37
+ if (dataTypeFactory.hasEnumeration(_name)) {
38
+ return dataTypeFactory.getEnumeration(_name);
39
+ }
40
+ if (dataTypeFactory.hasBuiltInType(_name)) {
41
+ return dataTypeFactory.getBuiltInType(_name);
42
+ }
43
+ // construct it !
44
+ const structuredType = typeDictionary.getStructuredTypesRawByName(_name);
45
+ if (!structuredType) {
46
+ throw new Error("Cannot find structuredType " + _name);
47
+ }
48
+ structuredType.baseType = _removeNamespacePart(structuredType.baseType);
49
+ structuredType.baseType = structuredType.baseType ? structuredType.baseType : "ExtensionObject";
50
+ const baseSchema = typeDictionary.getStructuredTypesRawByName(structuredType.baseType);
51
+ // remove redundant fields
52
+ // Note :some file do no thave SourceType property and may be replicated here ..
53
+ // but they belongs to the base class and shall be remove/
54
+ // For instance DataTypeSchemaHeader => UABinaryFileDataType
55
+ if (baseSchema && baseSchema.fields && baseSchema.name !== "ExtensionObject") {
56
+ structuredType.fields = structuredType.fields.filter((field) => {
57
+ const name = field.name;
58
+ const index = baseSchema.fields.findIndex((f) => f.name === name);
59
+ // istanbul ignore next
60
+ if (index >= 0) {
61
+ errorLog("Warning : find duplicated field from base structure : field name ", name, "baseSchema = ", baseSchema.name, "schema =", structuredType.name);
62
+ }
63
+ return index < 0;
64
+ });
65
+ }
66
+ for (const field of structuredType.fields) {
67
+ const fieldType = field.fieldType;
68
+ if (!field.schema) {
69
+ const prefix = _getNamespacePart(fieldType);
70
+ const fieldTypeName = _adjustFieldTypeName(_removeNamespacePart(fieldType));
71
+ switch (prefix) {
72
+ case "tns":
73
+ field.fieldType = fieldTypeName;
74
+ if (dataTypeFactory.hasEnumeration(fieldTypeName)) {
75
+ const enumeratedType = dataTypeFactory.getEnumeration(fieldTypeName);
76
+ field.category = node_opcua_factory_1.FieldCategory.enumeration;
77
+ field.schema = enumeratedType;
78
+ }
79
+ else {
80
+ // must be a structure then ....
81
+ field.category = node_opcua_factory_1.FieldCategory.complex;
82
+ const schema1 = dataTypeFactory.getStructuredTypeSchema(fieldTypeName);
83
+ field.schema = schema1;
84
+ // _getOrCreateStructuredTypeSchema(fieldTypeName);
85
+ // istanbul ignore next
86
+ if (!field.schema) {
87
+ errorLog("cannot find schema for ", fieldTypeName);
88
+ }
89
+ }
90
+ break;
91
+ case "ua":
92
+ field.fieldType = fieldTypeName;
93
+ if ((0, node_opcua_factory_1.hasBuiltInType)(fieldTypeName)) {
94
+ field.category = node_opcua_factory_1.FieldCategory.basic;
95
+ field.schema = (0, node_opcua_factory_1.getBuiltInType)(fieldTypeName);
96
+ }
97
+ else if (dataTypeFactory.hasStructuredType(fieldTypeName)) {
98
+ field.category = node_opcua_factory_1.FieldCategory.complex;
99
+ field.schema = dataTypeFactory.getStructuredTypeSchema(fieldTypeName);
100
+ }
101
+ else {
102
+ field.category = node_opcua_factory_1.FieldCategory.basic;
103
+ // try in this
104
+ field.schema = _getOrCreateStructuredTypeSchema(fieldTypeName);
105
+ // istanbul ignore next
106
+ if (!field.schema) {
107
+ errorLog("What should I do ??", fieldTypeName, " ", (0, node_opcua_factory_1.hasStructuredType)(fieldTypeName));
108
+ }
109
+ else {
110
+ if ((0, node_opcua_factory_1.hasBuiltInType)(fieldTypeName)) {
111
+ field.category = node_opcua_factory_1.FieldCategory.basic;
112
+ }
113
+ else {
114
+ field.category = node_opcua_factory_1.FieldCategory.complex;
115
+ }
116
+ }
117
+ }
118
+ break;
119
+ case "opc":
120
+ if ((fieldTypeName === "UAString" || fieldTypeName === "String") && field.name === "IndexRange") {
121
+ field.fieldType = "NumericRange";
122
+ }
123
+ else {
124
+ field.fieldType = fieldTypeName;
125
+ }
126
+ if (!(0, node_opcua_factory_1.hasBuiltInType)(fieldTypeName)) {
127
+ throw new Error("Unknown basic type " + fieldTypeName);
128
+ }
129
+ field.category = node_opcua_factory_1.FieldCategory.basic;
130
+ break;
131
+ default:
132
+ if (dataTypeFactory.hasEnumeration(fieldTypeName)) {
133
+ field.category = node_opcua_factory_1.FieldCategory.enumeration;
134
+ const enumeratedType = dataTypeFactory.getEnumeration(fieldTypeName);
135
+ field.schema = enumeratedType;
136
+ }
137
+ else if (dataTypeFactory.hasStructuredType(fieldTypeName)) {
138
+ field.category = node_opcua_factory_1.FieldCategory.complex;
139
+ const schema1 = dataTypeFactory.getStructuredTypeSchema(fieldTypeName);
140
+ field.schema = schema1;
141
+ }
142
+ break;
143
+ }
144
+ }
145
+ }
146
+ const schema = (0, node_opcua_factory_1.buildStructuredType)(structuredType);
147
+ const ids = idProvider.getDataTypeAndEncodingId(schema.name);
148
+ if (!ids) {
149
+ // this may happen if the type is abstract or if the type referes to a internal ExtnsionObject
150
+ // that can only exists inside an other extension object.this Type of extension object cannot
151
+ // instantiated as standalone object and do not have encoding nodeIds...
152
+ const Constructor = (0, dynamic_extension_object_1.createDynamicObjectConstructor)(schema, dataTypeFactory);
153
+ return schema;
154
+ }
155
+ schema.id = ids.dataTypeNodeId;
156
+ schema.dataTypeNodeId = ids.dataTypeNodeId;
157
+ if (schema.id.namespace === 0 && schema.id.value === 0) {
158
+ return schema;
159
+ }
160
+ schema.encodingDefaultXml = node_opcua_nodeid_1.ExpandedNodeId.fromNodeId(ids.xmlEncodingNodeId);
161
+ schema.encodingDefaultJson = node_opcua_nodeid_1.ExpandedNodeId.fromNodeId(ids.jsonEncodingNodeId);
162
+ schema.encodingDefaultBinary = node_opcua_nodeid_1.ExpandedNodeId.fromNodeId(ids.binaryEncodingNodeId);
163
+ const Constructor = (0, dynamic_extension_object_1.createDynamicObjectConstructor)(schema, dataTypeFactory);
164
+ Constructor.encodingDefaultBinary = schema.encodingDefaultBinary;
165
+ Constructor.encodingDefaultXml = schema.encodingDefaultXml;
166
+ return schema;
167
+ }
168
+ return _getOrCreateStructuredTypeSchema(name);
169
+ }
170
+ exports.getOrCreateStructuredTypeSchema = getOrCreateStructuredTypeSchema;
171
171
  //# sourceMappingURL=tools.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-schemas",
3
- "version": "2.76.0",
3
+ "version": "2.76.2",
4
4
  "description": "pure nodejs OPCUA SDK - module -schemas",
5
5
  "main": "dist/source/index.js",
6
6
  "types": "dist/source/index.d.ts",
@@ -14,18 +14,18 @@
14
14
  "dependencies": {
15
15
  "chalk": "4.1.2",
16
16
  "node-opcua-assert": "2.76.0",
17
- "node-opcua-binary-stream": "2.76.0",
18
- "node-opcua-debug": "2.76.0",
19
- "node-opcua-extension-object": "2.76.0",
20
- "node-opcua-factory": "2.76.0",
21
- "node-opcua-nodeid": "2.76.0",
22
- "node-opcua-variant": "2.76.0",
23
- "node-opcua-xml2json": "2.76.0"
17
+ "node-opcua-binary-stream": "2.76.2",
18
+ "node-opcua-debug": "2.76.2",
19
+ "node-opcua-extension-object": "2.76.2",
20
+ "node-opcua-factory": "2.76.2",
21
+ "node-opcua-nodeid": "2.76.2",
22
+ "node-opcua-variant": "2.76.2",
23
+ "node-opcua-xml2json": "2.76.2"
24
24
  },
25
25
  "devDependencies": {
26
26
  "mocha": "^10.0.0",
27
- "node-opcua-data-model": "2.76.0",
28
- "node-opcua-packet-analyzer": "2.76.0",
27
+ "node-opcua-data-model": "2.76.2",
28
+ "node-opcua-packet-analyzer": "2.76.2",
29
29
  "node-opcua-utils": "2.76.0",
30
30
  "should": "^13.2.3"
31
31
  },
@@ -44,5 +44,5 @@
44
44
  "internet of things"
45
45
  ],
46
46
  "homepage": "http://node-opcua.github.io/",
47
- "gitHead": "75d9b8cf894c8fbadf77d2c4a48a730d055465e7"
47
+ "gitHead": "acb5ecaf1e1c71af3b63e80909d58447f3f298e7"
48
48
  }