node-opcua-convert-nodeset-to-javascript 2.96.0 → 2.98.1
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/dist/_dataType.d.ts +10 -10
- package/dist/_dataType.js +152 -152
- package/dist/convert_namespace_to_typescript.d.ts +3 -3
- package/dist/convert_namespace_to_typescript.js +182 -182
- package/dist/convert_to_typescript.d.ts +105 -105
- package/dist/convert_to_typescript.js +753 -753
- package/dist/index.d.ts +3 -3
- package/dist/index.js +19 -19
- package/dist/main.d.ts +1 -1
- package/dist/main.js +77 -77
- package/dist/official_namespaces.d.ts +23 -23
- package/dist/official_namespaces.js +35 -35
- package/dist/options.d.ts +5 -5
- package/dist/options.js +2 -2
- package/dist/private/cache.d.ts +61 -61
- package/dist/private/cache.js +236 -236
- package/dist/private/get_corresponding_data_type.d.ts +14 -14
- package/dist/private/get_corresponding_data_type.js +103 -103
- package/dist/private/to_filename.d.ts +1 -1
- package/dist/private/to_filename.js +9 -9
- package/dist/private/utils.d.ts +31 -31
- package/dist/private/utils.js +291 -288
- package/dist/private/utils.js.map +1 -1
- package/dist/private-stuff.d.ts +4 -4
- package/dist/private-stuff.js +20 -20
- package/dist/utils2.d.ts +7 -7
- package/dist/utils2.js +57 -57
- package/dist/walk_through.d.ts +13 -13
- package/dist/walk_through.js +86 -86
- package/package.json +24 -20
- package/source/private/utils.ts +10 -6
- package/.eslintignore +0 -3
- package/tsconfig-generated.json +0 -16
package/dist/private/cache.js
CHANGED
|
@@ -1,237 +1,237 @@
|
|
|
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.makeTypeNameNew = exports.constructCache = exports.Cache2 = exports.referenceEnumeration = exports.referenceExtensionObject = exports.Cache = exports.makeName2 = void 0;
|
|
13
|
-
const path = require("path");
|
|
14
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
15
|
-
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
16
|
-
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
17
|
-
const node_opcua_types_1 = require("node-opcua-types");
|
|
18
|
-
const case_anything_1 = require("case-anything");
|
|
19
|
-
const utils_1 = require("./utils");
|
|
20
|
-
function makeName2(name) {
|
|
21
|
-
return "U" + name;
|
|
22
|
-
// if (name === "EUInformation") {
|
|
23
|
-
// return "EUInformation2";
|
|
24
|
-
// }
|
|
25
|
-
// return name.replace(/^DT/, "").replace(/^3/, "Three").replace(/^2/, "Two");
|
|
26
|
-
}
|
|
27
|
-
exports.makeName2 = makeName2;
|
|
28
|
-
class Cache {
|
|
29
|
-
constructor() {
|
|
30
|
-
this.namespace = [];
|
|
31
|
-
this.requestedSymbols = { namespace: [] };
|
|
32
|
-
this.requestedBasicTypes = {};
|
|
33
|
-
this.imports = {};
|
|
34
|
-
this.imports = {
|
|
35
|
-
"node-opcua-address-space-base": {
|
|
36
|
-
UAObject: 1,
|
|
37
|
-
UAVariable: 1,
|
|
38
|
-
UAVariableT: 1,
|
|
39
|
-
UAMethod: 1,
|
|
40
|
-
UADataType: 1,
|
|
41
|
-
UAProperty: 1
|
|
42
|
-
},
|
|
43
|
-
"node-opcua-variant": {
|
|
44
|
-
DataType: 1,
|
|
45
|
-
Variant: 1,
|
|
46
|
-
VariantOptions: 1,
|
|
47
|
-
},
|
|
48
|
-
"node-opcua-data-model": {
|
|
49
|
-
LocalizedText: 1,
|
|
50
|
-
QualifiedName: 1,
|
|
51
|
-
DiagnosticInfo: 1
|
|
52
|
-
},
|
|
53
|
-
"node-opcua-data-access": {
|
|
54
|
-
EUInformation: 1
|
|
55
|
-
},
|
|
56
|
-
"node-opcua-nodeid": {
|
|
57
|
-
NodeId: 1,
|
|
58
|
-
ExpandedNodeId: 1
|
|
59
|
-
},
|
|
60
|
-
"node-opcua-status-code": {
|
|
61
|
-
StatusCode: 1,
|
|
62
|
-
StatusCodes: 1
|
|
63
|
-
},
|
|
64
|
-
"node-opcua-basic-types": {
|
|
65
|
-
Int64: 1,
|
|
66
|
-
UInt64: 1,
|
|
67
|
-
UInt32: 1,
|
|
68
|
-
Int32: 1,
|
|
69
|
-
UInt16: 1,
|
|
70
|
-
Int16: 1,
|
|
71
|
-
Byte: 1,
|
|
72
|
-
SByte: 1,
|
|
73
|
-
UAString: 1,
|
|
74
|
-
DateTime: 1,
|
|
75
|
-
Guid: 1
|
|
76
|
-
},
|
|
77
|
-
"node-opcua-data-value": {
|
|
78
|
-
DataValue: 1
|
|
79
|
-
},
|
|
80
|
-
"node-opcua-types": {
|
|
81
|
-
EnumValueType: 1
|
|
82
|
-
},
|
|
83
|
-
"node-opcua-extension-object": {
|
|
84
|
-
ExtensionObject: 1
|
|
85
|
-
}
|
|
86
|
-
// "node-opcua-schemas": {
|
|
87
|
-
// ExtensionObject: 1
|
|
88
|
-
// }
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
resetRequire() {
|
|
92
|
-
this.requestedSymbols = { namespace: [] };
|
|
93
|
-
this.requestedBasicTypes = {};
|
|
94
|
-
}
|
|
95
|
-
referenceBasicType(basicType) {
|
|
96
|
-
this.requestedBasicTypes[basicType] = (this.requestedBasicTypes[basicType] || 0) + 1;
|
|
97
|
-
return basicType;
|
|
98
|
-
}
|
|
99
|
-
_reference(namespaceIndex, typeName, mainTypeName) {
|
|
100
|
-
var _a;
|
|
101
|
-
if (namespaceIndex <= 0 && this.imports["node-opcua-address-space-base"][typeName]) {
|
|
102
|
-
this.referenceBasicType(typeName);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
{
|
|
106
|
-
const sourceFolder = (_a = this.namespace[namespaceIndex]) === null || _a === void 0 ? void 0 : _a.sourceFolder;
|
|
107
|
-
if (!sourceFolder) {
|
|
108
|
-
throw new Error("Cannot find namespace " + namespaceIndex);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
const symbols = (this.namespace[namespaceIndex].symbols = this.namespace[namespaceIndex].symbols || {});
|
|
112
|
-
symbols[typeName] = (symbols[typeName] || 0) + 1;
|
|
113
|
-
const ns = this.requestedSymbols.namespace[namespaceIndex] || { symbols: {} };
|
|
114
|
-
this.requestedSymbols.namespace[namespaceIndex] = ns;
|
|
115
|
-
ns.symbols = ns.symbols || {};
|
|
116
|
-
if (!mainTypeName) {
|
|
117
|
-
mainTypeName = typeName;
|
|
118
|
-
}
|
|
119
|
-
const subs = (ns.symbols[mainTypeName] = ns.symbols[mainTypeName] || { subSymbols: {} });
|
|
120
|
-
subs.subSymbols[typeName] = (subs.subSymbols[typeName] || 0) + 1;
|
|
121
|
-
}
|
|
122
|
-
ensureImported(i) {
|
|
123
|
-
if (i.namespace < 0) {
|
|
124
|
-
this.referenceBasicType(i.name);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
this._reference(i.namespace, i.name, i.module);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
exports.Cache = Cache;
|
|
132
|
-
function getSourceFolderForNamespace(browseName, options, cache) {
|
|
133
|
-
const ns = browseName.namespaceIndex;
|
|
134
|
-
const n = cache.namespaceArray[ns].split("/").filter((s) => s.length !== 0);
|
|
135
|
-
const nn = (n[n.length - 1] !== "UA" && n[n.length - 2] !== "UA" ? n[n.length - 2] : "") + n[n.length - 1];
|
|
136
|
-
const module = options.prefix + (0, case_anything_1.kebabCase)(nn);
|
|
137
|
-
const namespaceFolder = path.join(options.baseFolder, module);
|
|
138
|
-
const sourceFolder = path.join(namespaceFolder);
|
|
139
|
-
return { sourceFolder, module };
|
|
140
|
-
}
|
|
141
|
-
function referenceExtensionObject(session, extensionObjectDataType) {
|
|
142
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
const browseName = yield (0, utils_1.getBrowseName)(session, extensionObjectDataType);
|
|
144
|
-
const definition = yield (0, utils_1.getDefinition)(session, extensionObjectDataType);
|
|
145
|
-
const dataTypeNameImport = makeTypeNameNew(node_opcua_data_model_1.NodeClass.DataType, definition, browseName);
|
|
146
|
-
return dataTypeNameImport;
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
exports.referenceExtensionObject = referenceExtensionObject;
|
|
150
|
-
function referenceEnumeration(session, enumerationDataType) {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
const browseName = yield (0, utils_1.getBrowseName)(session, enumerationDataType);
|
|
153
|
-
const definition = yield (0, utils_1.getDefinition)(session, enumerationDataType);
|
|
154
|
-
const dataTypeNameImport = makeTypeNameNew(node_opcua_data_model_1.NodeClass.DataType, definition, browseName);
|
|
155
|
-
return dataTypeNameImport;
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
exports.referenceEnumeration = referenceEnumeration;
|
|
159
|
-
class Cache2 extends Cache {
|
|
160
|
-
constructor() {
|
|
161
|
-
super(...arguments);
|
|
162
|
-
this.namespaceArray = [];
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
exports.Cache2 = Cache2;
|
|
166
|
-
function constructCache(session, options) {
|
|
167
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
-
const cache = new Cache2();
|
|
169
|
-
cache.namespaceArray = cache.namespaceArray.length
|
|
170
|
-
? cache.namespaceArray
|
|
171
|
-
: (yield session.read({
|
|
172
|
-
nodeId: (0, node_opcua_nodeid_1.resolveNodeId)("Server_NamespaceArray"),
|
|
173
|
-
attributeId: node_opcua_data_model_1.AttributeIds.Value
|
|
174
|
-
})).value.value;
|
|
175
|
-
for (let namespaceIndex = 0; namespaceIndex < cache.namespaceArray.length; namespaceIndex++) {
|
|
176
|
-
const namespaceUri = cache.namespaceArray[namespaceIndex];
|
|
177
|
-
const { sourceFolder, module } = getSourceFolderForNamespace(new node_opcua_data_model_1.QualifiedName({ name: namespaceUri, namespaceIndex }), options, cache);
|
|
178
|
-
cache.namespace.push({
|
|
179
|
-
namespaceUri,
|
|
180
|
-
sourceFolder,
|
|
181
|
-
module,
|
|
182
|
-
symbols: {}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
return cache;
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
exports.constructCache = constructCache;
|
|
189
|
-
function makeBasicTypeImport(name) {
|
|
190
|
-
return { name, module: "BasicType", namespace: -1 };
|
|
191
|
-
}
|
|
192
|
-
function makeTypeNameNew(nodeClass, definition, browseName, suffix) {
|
|
193
|
-
(0, node_opcua_assert_1.default)(browseName && !!browseName.name, "expecting a class name here");
|
|
194
|
-
const typeName = browseName.name.toString();
|
|
195
|
-
if (typeName === "EUInformation") {
|
|
196
|
-
return makeBasicTypeImport("EUInformation");
|
|
197
|
-
}
|
|
198
|
-
else if (typeName === "Enumeration") {
|
|
199
|
-
return makeBasicTypeImport("Enumeration");
|
|
200
|
-
}
|
|
201
|
-
else if (typeName === "BaseObjectType") {
|
|
202
|
-
return makeBasicTypeImport("UAObject");
|
|
203
|
-
}
|
|
204
|
-
else if (typeName === "BaseVariableType") {
|
|
205
|
-
return makeBasicTypeImport("UAVariableT");
|
|
206
|
-
}
|
|
207
|
-
else if (typeName === "BaseDataType") {
|
|
208
|
-
return makeBasicTypeImport("UADataType");
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
let name = "";
|
|
212
|
-
switch (nodeClass) {
|
|
213
|
-
case node_opcua_data_model_1.NodeClass.Method:
|
|
214
|
-
return makeBasicTypeImport("UAMethod");
|
|
215
|
-
case node_opcua_data_model_1.NodeClass.Variable:
|
|
216
|
-
case node_opcua_data_model_1.NodeClass.Object:
|
|
217
|
-
case node_opcua_data_model_1.NodeClass.VariableType:
|
|
218
|
-
case node_opcua_data_model_1.NodeClass.ObjectType:
|
|
219
|
-
name = `UA${typeName.replace(/Type$/, "")}` + (suffix || "");
|
|
220
|
-
break;
|
|
221
|
-
case node_opcua_data_model_1.NodeClass.DataType:
|
|
222
|
-
if (definition instanceof node_opcua_types_1.EnumDefinition) {
|
|
223
|
-
name = `Enum${typeName.replace(/(DataType|Enumeration|Type)$/, "")}`;
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
name = `DT${typeName.replace(/(DataType|Enumeration|Type)$/, "")}`;
|
|
227
|
-
}
|
|
228
|
-
break;
|
|
229
|
-
}
|
|
230
|
-
if (name === "") {
|
|
231
|
-
throw new Error("Internal Error " + node_opcua_data_model_1.NodeClass[nodeClass] + " " + typeName + "browseName = " + browseName.toString());
|
|
232
|
-
}
|
|
233
|
-
return { name, module: name, namespace: browseName.namespaceIndex };
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
exports.makeTypeNameNew = makeTypeNameNew;
|
|
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.makeTypeNameNew = exports.constructCache = exports.Cache2 = exports.referenceEnumeration = exports.referenceExtensionObject = exports.Cache = exports.makeName2 = void 0;
|
|
13
|
+
const path = require("path");
|
|
14
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
15
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
16
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
17
|
+
const node_opcua_types_1 = require("node-opcua-types");
|
|
18
|
+
const case_anything_1 = require("case-anything");
|
|
19
|
+
const utils_1 = require("./utils");
|
|
20
|
+
function makeName2(name) {
|
|
21
|
+
return "U" + name;
|
|
22
|
+
// if (name === "EUInformation") {
|
|
23
|
+
// return "EUInformation2";
|
|
24
|
+
// }
|
|
25
|
+
// return name.replace(/^DT/, "").replace(/^3/, "Three").replace(/^2/, "Two");
|
|
26
|
+
}
|
|
27
|
+
exports.makeName2 = makeName2;
|
|
28
|
+
class Cache {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.namespace = [];
|
|
31
|
+
this.requestedSymbols = { namespace: [] };
|
|
32
|
+
this.requestedBasicTypes = {};
|
|
33
|
+
this.imports = {};
|
|
34
|
+
this.imports = {
|
|
35
|
+
"node-opcua-address-space-base": {
|
|
36
|
+
UAObject: 1,
|
|
37
|
+
UAVariable: 1,
|
|
38
|
+
UAVariableT: 1,
|
|
39
|
+
UAMethod: 1,
|
|
40
|
+
UADataType: 1,
|
|
41
|
+
UAProperty: 1
|
|
42
|
+
},
|
|
43
|
+
"node-opcua-variant": {
|
|
44
|
+
DataType: 1,
|
|
45
|
+
Variant: 1,
|
|
46
|
+
VariantOptions: 1,
|
|
47
|
+
},
|
|
48
|
+
"node-opcua-data-model": {
|
|
49
|
+
LocalizedText: 1,
|
|
50
|
+
QualifiedName: 1,
|
|
51
|
+
DiagnosticInfo: 1
|
|
52
|
+
},
|
|
53
|
+
"node-opcua-data-access": {
|
|
54
|
+
EUInformation: 1
|
|
55
|
+
},
|
|
56
|
+
"node-opcua-nodeid": {
|
|
57
|
+
NodeId: 1,
|
|
58
|
+
ExpandedNodeId: 1
|
|
59
|
+
},
|
|
60
|
+
"node-opcua-status-code": {
|
|
61
|
+
StatusCode: 1,
|
|
62
|
+
StatusCodes: 1
|
|
63
|
+
},
|
|
64
|
+
"node-opcua-basic-types": {
|
|
65
|
+
Int64: 1,
|
|
66
|
+
UInt64: 1,
|
|
67
|
+
UInt32: 1,
|
|
68
|
+
Int32: 1,
|
|
69
|
+
UInt16: 1,
|
|
70
|
+
Int16: 1,
|
|
71
|
+
Byte: 1,
|
|
72
|
+
SByte: 1,
|
|
73
|
+
UAString: 1,
|
|
74
|
+
DateTime: 1,
|
|
75
|
+
Guid: 1
|
|
76
|
+
},
|
|
77
|
+
"node-opcua-data-value": {
|
|
78
|
+
DataValue: 1
|
|
79
|
+
},
|
|
80
|
+
"node-opcua-types": {
|
|
81
|
+
EnumValueType: 1
|
|
82
|
+
},
|
|
83
|
+
"node-opcua-extension-object": {
|
|
84
|
+
ExtensionObject: 1
|
|
85
|
+
}
|
|
86
|
+
// "node-opcua-schemas": {
|
|
87
|
+
// ExtensionObject: 1
|
|
88
|
+
// }
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
resetRequire() {
|
|
92
|
+
this.requestedSymbols = { namespace: [] };
|
|
93
|
+
this.requestedBasicTypes = {};
|
|
94
|
+
}
|
|
95
|
+
referenceBasicType(basicType) {
|
|
96
|
+
this.requestedBasicTypes[basicType] = (this.requestedBasicTypes[basicType] || 0) + 1;
|
|
97
|
+
return basicType;
|
|
98
|
+
}
|
|
99
|
+
_reference(namespaceIndex, typeName, mainTypeName) {
|
|
100
|
+
var _a;
|
|
101
|
+
if (namespaceIndex <= 0 && this.imports["node-opcua-address-space-base"][typeName]) {
|
|
102
|
+
this.referenceBasicType(typeName);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
{
|
|
106
|
+
const sourceFolder = (_a = this.namespace[namespaceIndex]) === null || _a === void 0 ? void 0 : _a.sourceFolder;
|
|
107
|
+
if (!sourceFolder) {
|
|
108
|
+
throw new Error("Cannot find namespace " + namespaceIndex);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const symbols = (this.namespace[namespaceIndex].symbols = this.namespace[namespaceIndex].symbols || {});
|
|
112
|
+
symbols[typeName] = (symbols[typeName] || 0) + 1;
|
|
113
|
+
const ns = this.requestedSymbols.namespace[namespaceIndex] || { symbols: {} };
|
|
114
|
+
this.requestedSymbols.namespace[namespaceIndex] = ns;
|
|
115
|
+
ns.symbols = ns.symbols || {};
|
|
116
|
+
if (!mainTypeName) {
|
|
117
|
+
mainTypeName = typeName;
|
|
118
|
+
}
|
|
119
|
+
const subs = (ns.symbols[mainTypeName] = ns.symbols[mainTypeName] || { subSymbols: {} });
|
|
120
|
+
subs.subSymbols[typeName] = (subs.subSymbols[typeName] || 0) + 1;
|
|
121
|
+
}
|
|
122
|
+
ensureImported(i) {
|
|
123
|
+
if (i.namespace < 0) {
|
|
124
|
+
this.referenceBasicType(i.name);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
this._reference(i.namespace, i.name, i.module);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.Cache = Cache;
|
|
132
|
+
function getSourceFolderForNamespace(browseName, options, cache) {
|
|
133
|
+
const ns = browseName.namespaceIndex;
|
|
134
|
+
const n = cache.namespaceArray[ns].split("/").filter((s) => s.length !== 0);
|
|
135
|
+
const nn = (n[n.length - 1] !== "UA" && n[n.length - 2] !== "UA" ? n[n.length - 2] : "") + n[n.length - 1];
|
|
136
|
+
const module = options.prefix + (0, case_anything_1.kebabCase)(nn);
|
|
137
|
+
const namespaceFolder = path.join(options.baseFolder, module);
|
|
138
|
+
const sourceFolder = path.join(namespaceFolder);
|
|
139
|
+
return { sourceFolder, module };
|
|
140
|
+
}
|
|
141
|
+
function referenceExtensionObject(session, extensionObjectDataType) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
const browseName = yield (0, utils_1.getBrowseName)(session, extensionObjectDataType);
|
|
144
|
+
const definition = yield (0, utils_1.getDefinition)(session, extensionObjectDataType);
|
|
145
|
+
const dataTypeNameImport = makeTypeNameNew(node_opcua_data_model_1.NodeClass.DataType, definition, browseName);
|
|
146
|
+
return dataTypeNameImport;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
exports.referenceExtensionObject = referenceExtensionObject;
|
|
150
|
+
function referenceEnumeration(session, enumerationDataType) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
const browseName = yield (0, utils_1.getBrowseName)(session, enumerationDataType);
|
|
153
|
+
const definition = yield (0, utils_1.getDefinition)(session, enumerationDataType);
|
|
154
|
+
const dataTypeNameImport = makeTypeNameNew(node_opcua_data_model_1.NodeClass.DataType, definition, browseName);
|
|
155
|
+
return dataTypeNameImport;
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
exports.referenceEnumeration = referenceEnumeration;
|
|
159
|
+
class Cache2 extends Cache {
|
|
160
|
+
constructor() {
|
|
161
|
+
super(...arguments);
|
|
162
|
+
this.namespaceArray = [];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.Cache2 = Cache2;
|
|
166
|
+
function constructCache(session, options) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
const cache = new Cache2();
|
|
169
|
+
cache.namespaceArray = cache.namespaceArray.length
|
|
170
|
+
? cache.namespaceArray
|
|
171
|
+
: (yield session.read({
|
|
172
|
+
nodeId: (0, node_opcua_nodeid_1.resolveNodeId)("Server_NamespaceArray"),
|
|
173
|
+
attributeId: node_opcua_data_model_1.AttributeIds.Value
|
|
174
|
+
})).value.value;
|
|
175
|
+
for (let namespaceIndex = 0; namespaceIndex < cache.namespaceArray.length; namespaceIndex++) {
|
|
176
|
+
const namespaceUri = cache.namespaceArray[namespaceIndex];
|
|
177
|
+
const { sourceFolder, module } = getSourceFolderForNamespace(new node_opcua_data_model_1.QualifiedName({ name: namespaceUri, namespaceIndex }), options, cache);
|
|
178
|
+
cache.namespace.push({
|
|
179
|
+
namespaceUri,
|
|
180
|
+
sourceFolder,
|
|
181
|
+
module,
|
|
182
|
+
symbols: {}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return cache;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
exports.constructCache = constructCache;
|
|
189
|
+
function makeBasicTypeImport(name) {
|
|
190
|
+
return { name, module: "BasicType", namespace: -1 };
|
|
191
|
+
}
|
|
192
|
+
function makeTypeNameNew(nodeClass, definition, browseName, suffix) {
|
|
193
|
+
(0, node_opcua_assert_1.default)(browseName && !!browseName.name, "expecting a class name here");
|
|
194
|
+
const typeName = browseName.name.toString();
|
|
195
|
+
if (typeName === "EUInformation") {
|
|
196
|
+
return makeBasicTypeImport("EUInformation");
|
|
197
|
+
}
|
|
198
|
+
else if (typeName === "Enumeration") {
|
|
199
|
+
return makeBasicTypeImport("Enumeration");
|
|
200
|
+
}
|
|
201
|
+
else if (typeName === "BaseObjectType") {
|
|
202
|
+
return makeBasicTypeImport("UAObject");
|
|
203
|
+
}
|
|
204
|
+
else if (typeName === "BaseVariableType") {
|
|
205
|
+
return makeBasicTypeImport("UAVariableT");
|
|
206
|
+
}
|
|
207
|
+
else if (typeName === "BaseDataType") {
|
|
208
|
+
return makeBasicTypeImport("UADataType");
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
let name = "";
|
|
212
|
+
switch (nodeClass) {
|
|
213
|
+
case node_opcua_data_model_1.NodeClass.Method:
|
|
214
|
+
return makeBasicTypeImport("UAMethod");
|
|
215
|
+
case node_opcua_data_model_1.NodeClass.Variable:
|
|
216
|
+
case node_opcua_data_model_1.NodeClass.Object:
|
|
217
|
+
case node_opcua_data_model_1.NodeClass.VariableType:
|
|
218
|
+
case node_opcua_data_model_1.NodeClass.ObjectType:
|
|
219
|
+
name = `UA${typeName.replace(/Type$/, "")}` + (suffix || "");
|
|
220
|
+
break;
|
|
221
|
+
case node_opcua_data_model_1.NodeClass.DataType:
|
|
222
|
+
if (definition instanceof node_opcua_types_1.EnumDefinition) {
|
|
223
|
+
name = `Enum${typeName.replace(/(DataType|Enumeration|Type)$/, "")}`;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
name = `DT${typeName.replace(/(DataType|Enumeration|Type)$/, "")}`;
|
|
227
|
+
}
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
if (name === "") {
|
|
231
|
+
throw new Error("Internal Error " + node_opcua_data_model_1.NodeClass[nodeClass] + " " + typeName + "browseName = " + browseName.toString());
|
|
232
|
+
}
|
|
233
|
+
return { name, module: name, namespace: browseName.namespaceIndex };
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.makeTypeNameNew = makeTypeNameNew;
|
|
237
237
|
//# sourceMappingURL=cache.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
2
|
-
import { IBasicSession } from "node-opcua-pseudo-session";
|
|
3
|
-
import { DataType } from "node-opcua-variant";
|
|
4
|
-
import { Import } from "./cache";
|
|
5
|
-
import { Cache } from "./cache";
|
|
6
|
-
export declare function getCorrepondingJavascriptType2(session: IBasicSession, nodeId: NodeId, dataTypeNodeId: NodeId, cache: Cache, importCollect?: (t: Import) => void): Promise<{
|
|
7
|
-
dataType: DataType;
|
|
8
|
-
jtype: string;
|
|
9
|
-
}>;
|
|
10
|
-
export declare function getCorrepondingJavascriptType(session: IBasicSession, dataTypeNodeId: NodeId, cache: Cache, importCollect?: (t: Import) => void): Promise<{
|
|
11
|
-
enumerationType?: string;
|
|
12
|
-
dataType: DataType;
|
|
13
|
-
jtype: string;
|
|
14
|
-
}>;
|
|
1
|
+
import { NodeId } from "node-opcua-nodeid";
|
|
2
|
+
import { IBasicSession } from "node-opcua-pseudo-session";
|
|
3
|
+
import { DataType } from "node-opcua-variant";
|
|
4
|
+
import { Import } from "./cache";
|
|
5
|
+
import { Cache } from "./cache";
|
|
6
|
+
export declare function getCorrepondingJavascriptType2(session: IBasicSession, nodeId: NodeId, dataTypeNodeId: NodeId, cache: Cache, importCollect?: (t: Import) => void): Promise<{
|
|
7
|
+
dataType: DataType;
|
|
8
|
+
jtype: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function getCorrepondingJavascriptType(session: IBasicSession, dataTypeNodeId: NodeId, cache: Cache, importCollect?: (t: Import) => void): Promise<{
|
|
11
|
+
enumerationType?: string;
|
|
12
|
+
dataType: DataType;
|
|
13
|
+
jtype: string;
|
|
14
|
+
}>;
|