node-opcua-convert-nodeset-to-javascript 2.51.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 (48) hide show
  1. package/.mocharc.yml +10 -0
  2. package/LICENSE +20 -0
  3. package/dist/convert_namespace_to_typescript.d.ts +3 -0
  4. package/dist/convert_namespace_to_typescript.js +158 -0
  5. package/dist/convert_namespace_to_typescript.js.map +1 -0
  6. package/dist/convert_to_typescript.d.ts +109 -0
  7. package/dist/convert_to_typescript.js +879 -0
  8. package/dist/convert_to_typescript.js.map +1 -0
  9. package/dist/index.d.ts +3 -0
  10. package/dist/index.js +16 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/main.d.ts +1 -0
  13. package/dist/main.js +66 -0
  14. package/dist/main.js.map +1 -0
  15. package/dist/official_namespaces.d.ts +23 -0
  16. package/dist/official_namespaces.js +36 -0
  17. package/dist/official_namespaces.js.map +1 -0
  18. package/dist/options.d.ts +4 -0
  19. package/dist/options.js +3 -0
  20. package/dist/options.js.map +1 -0
  21. package/dist/private/cache.d.ts +58 -0
  22. package/dist/private/cache.js +213 -0
  23. package/dist/private/cache.js.map +1 -0
  24. package/dist/private/to_filename.d.ts +1 -0
  25. package/dist/private/to_filename.js +10 -0
  26. package/dist/private/to_filename.js.map +1 -0
  27. package/dist/private/utils.d.ts +24 -0
  28. package/dist/private/utils.js +261 -0
  29. package/dist/private/utils.js.map +1 -0
  30. package/dist/private-stuff.d.ts +4 -0
  31. package/dist/private-stuff.js +17 -0
  32. package/dist/private-stuff.js.map +1 -0
  33. package/dist/walk_through.d.ts +13 -0
  34. package/dist/walk_through.js +87 -0
  35. package/dist/walk_through.js.map +1 -0
  36. package/package.json +58 -0
  37. package/source/convert_namespace_to_typescript.ts +171 -0
  38. package/source/convert_to_typescript.ts +1095 -0
  39. package/source/index.ts +3 -0
  40. package/source/main.ts +56 -0
  41. package/source/official_namespaces.ts +35 -0
  42. package/source/options.ts +4 -0
  43. package/source/private/cache.ts +228 -0
  44. package/source/private/to_filename.ts +6 -0
  45. package/source/private/utils.ts +212 -0
  46. package/source/private-stuff.ts +6 -0
  47. package/source/walk_through.ts +73 -0
  48. package/tsconfig-generated.json +13 -0
@@ -0,0 +1,879 @@
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.convertTypeToTypescript = exports._convertTypeToTypescript = exports._exportDataTypeToTypescript = exports.findUsedImport = exports.extractClassMemberDef = exports.checkIfShouldExposeInnerDefinition = exports.findClassMember = exports.extractClassDefinition = exports.makeTypeName2 = exports.convertDataTypeToTypescript = void 0;
13
+ const wrap = require("wordwrap");
14
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
15
+ const node_opcua_types_1 = require("node-opcua-types");
16
+ const node_opcua_utils_1 = require("node-opcua-utils");
17
+ const node_opcua_variant_1 = require("node-opcua-variant");
18
+ const node_opcua_assert_1 = require("node-opcua-assert");
19
+ const chalk = require("chalk");
20
+ const utils_1 = require("./private/utils");
21
+ const cache_1 = require("./private/cache");
22
+ const to_filename_1 = require("./private/to_filename");
23
+ const wrapText = wrap(0, 50);
24
+ const f2 = (str) => str.padEnd(50, "-");
25
+ const f1 = (str) => str.padEnd(50, " ");
26
+ const baseExtension = "_Base";
27
+ function convertDataTypeToTypescript(session, dataTypeId) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const definition = yield (0, utils_1.getDefinition)(session, dataTypeId);
30
+ const browseName = yield (0, utils_1.getBrowseName)(session, dataTypeId);
31
+ const dataTypeTypescriptName = `UA${browseName.name.toString()}`;
32
+ const f = new node_opcua_utils_1.LineFile();
33
+ if (definition && definition instanceof node_opcua_types_1.StructureDefinition) {
34
+ f.write(`interface ${dataTypeTypescriptName} {`);
35
+ for (const field of definition.fields || []) {
36
+ /** */
37
+ }
38
+ f.write(`}`);
39
+ }
40
+ });
41
+ }
42
+ exports.convertDataTypeToTypescript = convertDataTypeToTypescript;
43
+ // to avoid clashes
44
+ function toJavascritPropertyName(childName) {
45
+ childName = (0, node_opcua_utils_1.lowerFirstLetter)(childName);
46
+ if (childName === "namespaceUri") {
47
+ childName = "$namespaceUri";
48
+ }
49
+ if (childName === "rolePermissions") {
50
+ childName = "$rolePermissions";
51
+ }
52
+ if (childName === "displayName") {
53
+ childName = "$displayName";
54
+ }
55
+ if (childName === "eventNotifier") {
56
+ childName = "$eventNotifier";
57
+ }
58
+ return childName.replace(/</g, "$").replace(/>/g, "$").replace(/ |\./g, "_").replace(/#/g, "_");
59
+ }
60
+ function quotifyIfNecessary(s) {
61
+ if (s.match(/(^[^a-zA-Z])|([^a-zA-Z_0-9])/)) {
62
+ return `"${s}"`;
63
+ }
64
+ if (s === "nodeClass") {
65
+ return `["$nodeClass"]`;
66
+ }
67
+ return s;
68
+ }
69
+ function getCorrepondingJavascriptType2(session, nodeId, dataTypeNodeId, cache, importCollect) {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ const q = yield getCorrepondingJavascriptType(session, dataTypeNodeId, cache, importCollect);
72
+ const valueRank = yield (0, utils_1.getValueRank)(session, nodeId);
73
+ return { dataType: q.dataType, jtype: q.jtype + (valueRank >= 1 ? "[]" : "") };
74
+ });
75
+ }
76
+ // eslint-disable-next-line complexity
77
+ function getCorrepondingJavascriptType(session, dataTypeNodeId, cache, importCollect) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ const dataType = yield (0, utils_1.convertNodeIdToDataTypeAsync)(session, dataTypeNodeId);
80
+ const referenceBasicType = (name) => {
81
+ const t = { name, namespace: -1, module: "BasicType" };
82
+ importCollect && importCollect(t);
83
+ cache.ensureImported(t);
84
+ return t.name;
85
+ };
86
+ if (dataType === node_opcua_variant_1.DataType.ExtensionObject) {
87
+ const jtypeImport = yield (0, cache_1.referenceExtensionObject)(session, dataTypeNodeId);
88
+ const jtype = jtypeImport.name;
89
+ importCollect && importCollect(jtypeImport);
90
+ return { dataType, jtype: jtype };
91
+ }
92
+ switch (dataType) {
93
+ case node_opcua_variant_1.DataType.Null:
94
+ return { dataType, jtype: "undefined" };
95
+ case node_opcua_variant_1.DataType.Boolean:
96
+ return { dataType, jtype: "boolean" };
97
+ case node_opcua_variant_1.DataType.Byte:
98
+ return { dataType, jtype: referenceBasicType("Byte") };
99
+ case node_opcua_variant_1.DataType.ByteString:
100
+ return { dataType, jtype: "Buffer" };
101
+ case node_opcua_variant_1.DataType.DataValue:
102
+ return { dataType, jtype: referenceBasicType("DataValue") };
103
+ case node_opcua_variant_1.DataType.DateTime:
104
+ return { dataType, jtype: "Date" };
105
+ case node_opcua_variant_1.DataType.DiagnosticInfo:
106
+ return { dataType, jtype: referenceBasicType("DiagnosticInfo") };
107
+ case node_opcua_variant_1.DataType.Double:
108
+ return { dataType, jtype: "number" };
109
+ case node_opcua_variant_1.DataType.Float:
110
+ return { dataType, jtype: "number" };
111
+ case node_opcua_variant_1.DataType.Guid:
112
+ return { dataType, jtype: referenceBasicType("Guid") };
113
+ case node_opcua_variant_1.DataType.Int16:
114
+ return { dataType, jtype: referenceBasicType("Int16") };
115
+ case node_opcua_variant_1.DataType.Int32:
116
+ return { dataType, jtype: referenceBasicType("Int32") };
117
+ case node_opcua_variant_1.DataType.UInt16:
118
+ return { dataType, jtype: referenceBasicType("UInt16") };
119
+ case node_opcua_variant_1.DataType.UInt32:
120
+ return { dataType, jtype: referenceBasicType("UInt32") };
121
+ case node_opcua_variant_1.DataType.UInt64:
122
+ return { dataType, jtype: referenceBasicType("UInt64") };
123
+ case node_opcua_variant_1.DataType.Int64:
124
+ return { dataType, jtype: referenceBasicType("Int64") };
125
+ case node_opcua_variant_1.DataType.LocalizedText:
126
+ return { dataType, jtype: referenceBasicType("LocalizedText") };
127
+ case node_opcua_variant_1.DataType.NodeId:
128
+ return { dataType, jtype: referenceBasicType("NodeId") };
129
+ case node_opcua_variant_1.DataType.ExpandedNodeId:
130
+ return { dataType, jtype: referenceBasicType("ExpandedNodeId") };
131
+ case node_opcua_variant_1.DataType.QualifiedName:
132
+ return { dataType, jtype: referenceBasicType("QualifiedName") };
133
+ case node_opcua_variant_1.DataType.SByte:
134
+ return { dataType, jtype: referenceBasicType("SByte") };
135
+ case node_opcua_variant_1.DataType.StatusCode:
136
+ return { dataType, jtype: referenceBasicType("StatusCode") };
137
+ case node_opcua_variant_1.DataType.String:
138
+ return { dataType, jtype: referenceBasicType("UAString") };
139
+ case node_opcua_variant_1.DataType.Variant:
140
+ return { dataType, jtype: referenceBasicType("Variant") };
141
+ case node_opcua_variant_1.DataType.XmlElement:
142
+ return { dataType, jtype: referenceBasicType("UAString") };
143
+ default:
144
+ throw new Error("Unsupported " + dataType + " " + node_opcua_variant_1.DataType[dataType]);
145
+ }
146
+ });
147
+ }
148
+ function makeTypeName2(nodeClass, browseName, suffix) {
149
+ (0, node_opcua_assert_1.default)(browseName);
150
+ if (nodeClass === node_opcua_data_model_1.NodeClass.Method) {
151
+ return { name: "UAMethod", namespace: 0, module: "UAMethod" };
152
+ }
153
+ return (0, cache_1.makeTypeNameNew)(nodeClass, null, browseName, suffix);
154
+ }
155
+ exports.makeTypeName2 = makeTypeName2;
156
+ function extractClassDefinition(session, nodeId, cache) {
157
+ return __awaiter(this, void 0, void 0, function* () {
158
+ const extraImports = [];
159
+ const _c = cache.classDefCache || {};
160
+ cache.classDefCache = _c;
161
+ let classDef = _c[nodeId.toString()];
162
+ if (classDef) {
163
+ return classDef;
164
+ }
165
+ const nodeClass = yield (0, utils_1.getNodeClass)(session, nodeId);
166
+ if (nodeClass !== node_opcua_data_model_1.NodeClass.VariableType && nodeClass !== node_opcua_data_model_1.NodeClass.ObjectType) {
167
+ throw new Error("Invalid nodeClass " + node_opcua_data_model_1.NodeClass[nodeClass] + " nodeId " + nodeId.toString());
168
+ }
169
+ const browseName = yield (0, utils_1.getBrowseName)(session, nodeId);
170
+ const isAbstract = yield (0, utils_1.getIsAbstract)(session, nodeId);
171
+ const superType = (yield (0, utils_1.getSubtypeNodeIdIfAny)(session, nodeId)) || undefined;
172
+ const dataTypeNodeId = yield (0, utils_1.getDataTypeNodeId)(session, nodeId);
173
+ let dataTypeName = "";
174
+ let dataType = node_opcua_variant_1.DataType.Null;
175
+ let dataTypeImport = undefined;
176
+ if (nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
177
+ dataType = yield (0, utils_1.extractBasicDataType)(session, dataTypeNodeId);
178
+ const importCollector = (i) => {
179
+ extraImports.push(i);
180
+ cache.ensureImported(i);
181
+ };
182
+ const { jtype } = yield getCorrepondingJavascriptType2(session, nodeId, dataTypeNodeId, cache, importCollector);
183
+ dataTypeName = jtype; // with decoration
184
+ if (!(dataTypeNodeId === null || dataTypeNodeId === void 0 ? void 0 : dataTypeNodeId.isEmpty())) {
185
+ // "DT" + (await getBrowseName(session, dataTypeNodeId!))?.name! || "";
186
+ // const bn = await getBrowseName(session, dataTypeNodeId!);
187
+ dataTypeImport = extraImports; // makeTypeName2(NodeClass.DataType, bn);
188
+ }
189
+ }
190
+ const baseClassDef = !superType ? null : yield extractClassDefinition(session, superType.nodeId, cache);
191
+ const description = yield (0, utils_1.getDescription)(session, nodeId);
192
+ // const definition = await getDefinition(session, nodeId);
193
+ const interfaceName = makeTypeName2(nodeClass, browseName);
194
+ const baseInterfaceName = !superType ? null : makeTypeName2(nodeClass, superType.browseName);
195
+ // extract member
196
+ const children = yield (0, utils_1.getChildrenOrFolderElements)(session, nodeId);
197
+ const members = [];
198
+ classDef = {
199
+ nodeClass,
200
+ browseName,
201
+ isAbstract,
202
+ dataType,
203
+ dataTypeNodeId,
204
+ dataTypeName,
205
+ dataTypeImport,
206
+ superType,
207
+ baseClassDef,
208
+ description,
209
+ // definition,
210
+ children,
211
+ members,
212
+ interfaceName,
213
+ baseInterfaceName
214
+ };
215
+ _c[nodeId.toString()] = classDef;
216
+ for (const child of children) {
217
+ const c = yield extractClassMemberDef(session, child.nodeId, classDef, cache);
218
+ classDef.members.push(c);
219
+ }
220
+ return classDef;
221
+ });
222
+ }
223
+ exports.extractClassDefinition = extractClassDefinition;
224
+ function classify(session, refs) {
225
+ return __awaiter(this, void 0, void 0, function* () {
226
+ const r = {
227
+ Mandatory: [],
228
+ Optional: [],
229
+ MandatoryPlaceholder: [],
230
+ OptionalPlaceholder: [],
231
+ ExposesItsArray: []
232
+ };
233
+ for (const mm of refs) {
234
+ const modellingRule = yield (0, utils_1.getModellingRule)(session, mm.nodeId);
235
+ if (modellingRule) {
236
+ r[modellingRule] = r[modellingRule] || [];
237
+ r[modellingRule].push(mm);
238
+ }
239
+ }
240
+ return r;
241
+ });
242
+ }
243
+ function extractAllMembers(session, classDef, cache) {
244
+ return __awaiter(this, void 0, void 0, function* () {
245
+ const m = [...classDef.children];
246
+ let s = classDef;
247
+ while (s.baseClassDef) {
248
+ s = s.baseClassDef;
249
+ // start from top most class
250
+ // do not overwrite most top member definition, so we get mandatory stuff
251
+ for (const mm of s.children) {
252
+ const found = m.findIndex((r) => r.browseName.toString() === mm.browseName.toString());
253
+ if (found < 0) {
254
+ m.push(mm);
255
+ }
256
+ }
257
+ }
258
+ // now separate mandatory and optionals
259
+ const members = yield classify(session, m);
260
+ return members;
261
+ });
262
+ }
263
+ function findClassMember(session, browseName, baseParentDef, cache) {
264
+ return __awaiter(this, void 0, void 0, function* () {
265
+ const str = browseName.toString();
266
+ const r = baseParentDef.children.find((a) => a.browseName.toString() === str);
267
+ if (r) {
268
+ const d = yield extractClassMemberDef(session, r.nodeId, baseParentDef, cache);
269
+ return d;
270
+ }
271
+ const baseBaseParentDef = baseParentDef.superType && (yield extractClassDefinition(session, baseParentDef.superType.nodeId, cache));
272
+ if (!baseBaseParentDef) {
273
+ return null;
274
+ }
275
+ return yield findClassMember(session, browseName, baseBaseParentDef, cache);
276
+ });
277
+ }
278
+ exports.findClassMember = findClassMember;
279
+ function hasNewMaterial(referenceMembers, instanceMembers) {
280
+ const ref = referenceMembers.map((x) => x.browseName.toString()).sort();
281
+ const instance = instanceMembers.map((x) => x.browseName.toString()).sort();
282
+ for (const n of instance) {
283
+ if (ref.findIndex((x) => x === n) < 0) {
284
+ return true;
285
+ }
286
+ }
287
+ return false;
288
+ }
289
+ // we should expose an inner definition if
290
+ // - at least one mandatory in instnace doesn't exist in main.Mandatory
291
+ // - at least one optional in instnace doesn't exist in main.Mandatory
292
+ function checkIfShouldExposeInnerDefinition(main, instance) {
293
+ const hasNewStuff = hasNewMaterial(main.Mandatory, instance.Mandatory) || hasNewMaterial(main.Optional, instance.Optional);
294
+ return hasNewStuff;
295
+ }
296
+ exports.checkIfShouldExposeInnerDefinition = checkIfShouldExposeInnerDefinition;
297
+ function dump1(a) {
298
+ console.log("Mandatory = ", a.Mandatory.map((x) => x.browseName.toString())
299
+ .sort()
300
+ .join(" "));
301
+ console.log("Optional = ", a.Optional.map((x) => x.browseName.toString())
302
+ .sort()
303
+ .join(" "));
304
+ }
305
+ function _extractLocalMembers(session, classMember, cache) {
306
+ var _a;
307
+ return __awaiter(this, void 0, void 0, function* () {
308
+ const children2 = [];
309
+ for (const child of classMember.children) {
310
+ const nodeId = child.nodeId;
311
+ const browseName = yield (0, utils_1.getBrowseName)(session, nodeId);
312
+ const name = toJavascritPropertyName(browseName.name);
313
+ if (name === "cartesianCoordinates") {
314
+ // debugger;
315
+ }
316
+ const description = yield (0, utils_1.getDescription)(session, nodeId);
317
+ const modellingRule = yield (0, utils_1.getModellingRule)(session, nodeId);
318
+ const isOptional = modellingRule === "Optional";
319
+ const typeDefinition = yield (0, utils_1.getTypeDefOrBaseType)(session, nodeId);
320
+ const childInBase = (_a = classMember.classDef) === null || _a === void 0 ? void 0 : _a.members.find((a) => a.browseName.toString() === browseName.toString());
321
+ let childType;
322
+ if (childInBase) {
323
+ childType = childInBase.childType;
324
+ }
325
+ else {
326
+ const d = typeDefinition.nodeId.isEmpty() ? null : yield extractClassDefinition(session, typeDefinition.nodeId, cache);
327
+ childType = (d === null || d === void 0 ? void 0 : d.interfaceName) || { name: "UAMethod", module: "BasicType", namespace: -1 };
328
+ }
329
+ // may be childType is already
330
+ const { suffix, suffixInstantiate, typeToReference, chevrons } = yield extractVariableExtra(session, child.nodeId, cache, classMember);
331
+ const c = {
332
+ childType,
333
+ description,
334
+ isOptional,
335
+ modellingRule,
336
+ name,
337
+ suffix,
338
+ suffixInstantiate,
339
+ typeToReference,
340
+ chevrons
341
+ };
342
+ children2.push(c);
343
+ }
344
+ return children2;
345
+ });
346
+ }
347
+ function isUnspecifiedDataType(dataType) {
348
+ return dataType === node_opcua_variant_1.DataType.Null || dataType === node_opcua_variant_1.DataType.Variant;
349
+ }
350
+ function extractVariableExtra(session, nodeId, cache, classMember) {
351
+ var _a;
352
+ return __awaiter(this, void 0, void 0, function* () {
353
+ const typeToReference = [];
354
+ const importCollector = (i) => {
355
+ typeToReference.push(i);
356
+ cache.ensureImported(i);
357
+ };
358
+ const nodeClass = yield (0, utils_1.getNodeClass)(session, nodeId);
359
+ if (nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
360
+ const dataTypeNodeId = yield (0, utils_1.getDataTypeNodeId)(session, nodeId);
361
+ const { dataType, jtype } = yield getCorrepondingJavascriptType2(session, nodeId, dataTypeNodeId, cache, importCollector);
362
+ cache && cache.referenceBasicType("DataType");
363
+ importCollector({ name: "DataType", namespace: -1, module: "BasicType" });
364
+ const t = isUnspecifiedDataType((_a = classMember.classDef) === null || _a === void 0 ? void 0 : _a.dataType);
365
+ const suffix = jtype === "undefined" || isUnspecifiedDataType(dataType)
366
+ ? `<any, any>`
367
+ : `<${jtype}${t ? `, /*c*/DataType.${node_opcua_variant_1.DataType[dataType]}` : ""}>`;
368
+ // const suffix2 = `<T${t ? `, /*a*/DT extends DataType` : ""}>`;
369
+ const suffix3 = `<T${t ? `, /*b*/DT` : ""}>`;
370
+ const typeDef = yield (0, utils_1.getTypeDefOrBaseType)(session, nodeId);
371
+ const typeDefCD = yield extractClassDefinition(session, typeDef.nodeId, cache);
372
+ const chevrons = calculateChevrons(typeDefCD, { dataType });
373
+ const suffix2 = chevrons.chevronsDef;
374
+ /** Suffix for instantiation
375
+ * if typeDef.dataType is not null, then we need to add a type argument
376
+ */
377
+ let suffixInstantiate = "";
378
+ if (isUnspecifiedDataType(dataType)) {
379
+ if (!isUnspecifiedDataType(typeDefCD.dataType)) {
380
+ suffixInstantiate = "<any>";
381
+ }
382
+ else {
383
+ suffixInstantiate = "<any, any>";
384
+ }
385
+ }
386
+ else {
387
+ if (!isUnspecifiedDataType(typeDefCD.dataType)) {
388
+ suffixInstantiate = `<${jtype}>`;
389
+ }
390
+ else {
391
+ suffixInstantiate = `<${jtype}, /*z*/DataType.${node_opcua_variant_1.DataType[dataType]}>`;
392
+ }
393
+ }
394
+ return { suffixInstantiate, suffix, suffix2, suffix3, dataTypeNodeId, dataType, jtype, typeToReference, chevrons };
395
+ }
396
+ return { suffix: "", typeToReference };
397
+ });
398
+ }
399
+ // eslint-disable-next-line max-statements
400
+ function extractClassMemberDef(session, nodeId, parentDef, cache) {
401
+ return __awaiter(this, void 0, void 0, function* () {
402
+ const nodeClass = yield (0, utils_1.getNodeClass)(session, nodeId);
403
+ const browseName = yield (0, utils_1.getBrowseName)(session, nodeId);
404
+ const name = toJavascritPropertyName(browseName.name);
405
+ if (nodeClass !== node_opcua_data_model_1.NodeClass.Method && nodeClass !== node_opcua_data_model_1.NodeClass.Object && nodeClass !== node_opcua_data_model_1.NodeClass.Variable) {
406
+ throw new Error("Invalid property " + node_opcua_data_model_1.NodeClass[nodeClass] + " " + (browseName === null || browseName === void 0 ? void 0 : browseName.toString()) + " " + nodeId.toString());
407
+ }
408
+ const description = yield (0, utils_1.getDescription)(session, nodeId);
409
+ const children = yield (0, utils_1.getChildrenOrFolderElements)(session, nodeId);
410
+ const modellingRule = yield (0, utils_1.getModellingRule)(session, nodeId);
411
+ const isOptional = modellingRule === "Optional";
412
+ const typeDefinition = yield (0, utils_1.getTypeDefOrBaseType)(session, nodeId);
413
+ if (!typeDefinition.browseName) {
414
+ console.log("cannot find typeDefinition for ", browseName.toString(), "( is the namespace loaded ?)");
415
+ }
416
+ let childType = makeTypeName2(nodeClass, typeDefinition.browseName);
417
+ const classDef = typeDefinition.nodeId.isEmpty() ? null : yield extractClassDefinition(session, typeDefinition.nodeId, cache);
418
+ let innerClass = null;
419
+ let childBase = null;
420
+ let shouldExposeInnerDefinition = false;
421
+ // find member exposed by type definition
422
+ const baseParentDef = parentDef.superType && (yield extractClassDefinition(session, parentDef.superType.nodeId, cache));
423
+ if (classDef && baseParentDef) {
424
+ const chevrons1 = calculateChevrons(classDef, baseParentDef);
425
+ (0, node_opcua_assert_1.default)(!innerClass);
426
+ // let's extract the member that are theorically defined in the member
427
+ const membersReference = yield extractAllMembers(session, classDef, cache);
428
+ // find member exposed by this member
429
+ const membersInstance = yield classify(session, children);
430
+ // if (name==="powerup") {
431
+ // dump1(membersReference);
432
+ // dump1(membersInstance);
433
+ // await extractAllMembers(session, classDef, cache);
434
+ // }
435
+ shouldExposeInnerDefinition = checkIfShouldExposeInnerDefinition(membersReference, membersInstance);
436
+ const sameMemberInBaseClass = baseParentDef && (yield findClassMember(session, browseName, baseParentDef, cache));
437
+ if (shouldExposeInnerDefinition) {
438
+ if (sameMemberInBaseClass) {
439
+ innerClass = {
440
+ module: parentDef.interfaceName.module,
441
+ name: parentDef.interfaceName.name + "_" + name,
442
+ namespace: nodeId.namespace
443
+ };
444
+ childBase = sameMemberInBaseClass.childType;
445
+ childType = innerClass;
446
+ }
447
+ else {
448
+ innerClass = {
449
+ module: parentDef.interfaceName.module,
450
+ name: parentDef.interfaceName.name + "_" + name,
451
+ namespace: nodeId.namespace
452
+ };
453
+ childBase = childType;
454
+ childType = innerClass;
455
+ }
456
+ (0, node_opcua_assert_1.default)(innerClass);
457
+ (0, node_opcua_assert_1.default)(childBase);
458
+ }
459
+ else {
460
+ // may not expose definition but we may want to used the augment typescript class defined in the definition
461
+ // we don't need to create an inner class ...
462
+ childType = sameMemberInBaseClass ? sameMemberInBaseClass === null || sameMemberInBaseClass === void 0 ? void 0 : sameMemberInBaseClass.childType : childType;
463
+ (0, node_opcua_assert_1.default)(!innerClass);
464
+ (0, node_opcua_assert_1.default)(!childBase);
465
+ }
466
+ }
467
+ else {
468
+ // the lass member has no HasTypeDefinition reference
469
+ // may be is a method
470
+ (0, node_opcua_assert_1.default)(!innerClass);
471
+ (0, node_opcua_assert_1.default)(!childBase);
472
+ }
473
+ let classMember = {
474
+ name,
475
+ nodeClass,
476
+ browseName,
477
+ modellingRule,
478
+ isOptional,
479
+ classDef,
480
+ description,
481
+ typeDefinition,
482
+ childType,
483
+ suffix2: "",
484
+ suffix: "",
485
+ suffix3: "",
486
+ suffixInstantiate: "",
487
+ children,
488
+ children2: [],
489
+ typeToReference: [],
490
+ //
491
+ innerClass,
492
+ childBase,
493
+ chevrons: null
494
+ };
495
+ classMember.children2 = yield _extractLocalMembers(session, classMember, cache);
496
+ if (nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
497
+ const extra = yield extractVariableExtra(session, nodeId, cache, classMember);
498
+ classMember = Object.assign(Object.assign({}, classMember), extra);
499
+ }
500
+ return classMember;
501
+ });
502
+ }
503
+ exports.extractClassMemberDef = extractClassMemberDef;
504
+ function preDumpChildren(session, padding, classDef, f, cache) {
505
+ return __awaiter(this, void 0, void 0, function* () {
506
+ f = f || new node_opcua_utils_1.LineFile();
507
+ for (const memberDef of classDef.members) {
508
+ const { innerClass, suffix2, suffix3, nodeClass, childBase, chevrons } = memberDef;
509
+ if (!innerClass || !childBase) {
510
+ continue; // no need to expose inner class
511
+ }
512
+ cache.ensureImported(childBase);
513
+ if (innerClass.name === "UAPubSubDiagnostics_counters" || innerClass.name === "UAProgramStateMachine_currentState") {
514
+ // debugger;
515
+ }
516
+ const baseStuff = getBaseClassWithOmit2(memberDef);
517
+ //f.write(`export interface ${innerClass.name}${suffix2} extends ${childBase.name}${suffix3} { // ${NodeClass[nodeClass]}`);
518
+ f.write(`export interface ${innerClass.name}${suffix2} extends ${baseStuff} { // ${node_opcua_data_model_1.NodeClass[nodeClass]}`);
519
+ yield dumpChildren(session, padding + " ", memberDef.children2, f, cache);
520
+ f.write("}");
521
+ }
522
+ });
523
+ }
524
+ function dumpChildren(session, padding, children, f, cache) {
525
+ f = f || new node_opcua_utils_1.LineFile();
526
+ for (const def of children) {
527
+ const { suffixInstantiate, name, childType, modellingRule, isOptional, description } = def;
528
+ def.typeToReference.forEach((t) => cache.ensureImported(t));
529
+ if (modellingRule === "MandatoryPlaceholder" || modellingRule === "OptionalPlaceholder")
530
+ continue;
531
+ cache.ensureImported(childType);
532
+ const adjustedName = toJavascritPropertyName(name);
533
+ if (description.text) {
534
+ f.write(`${padding}/**`);
535
+ f.write(`${padding} * ${name || ""}`);
536
+ f.write(toComment(`${padding} * `, description.text || ""));
537
+ f.write(`${padding} */`);
538
+ }
539
+ f.write(`${padding}${quotifyIfNecessary(adjustedName)}${isOptional ? "?" : ""}: ${childType.name}${suffixInstantiate || ""};`);
540
+ }
541
+ }
542
+ // now from other namespace
543
+ const getSubSymbolList = (s) => {
544
+ const subSymbolList = [];
545
+ for (const [subSymbol, count] of Object.entries(s.subSymbols)) {
546
+ subSymbolList.push(subSymbol);
547
+ }
548
+ return subSymbolList;
549
+ };
550
+ function findUsedImport(namespaceIndex, cache) {
551
+ const usedImport = [];
552
+ // from standard types
553
+ for (const imp of Object.keys(cache.imports)) {
554
+ const symbolToImport = Object.keys(cache.imports[imp]).filter((f) => Object.prototype.hasOwnProperty.call(cache.requestedBasicTypes, f));
555
+ if (symbolToImport.length == 0) {
556
+ continue;
557
+ }
558
+ usedImport.push(imp);
559
+ }
560
+ // from namespace
561
+ for (let ns = 0; ns < cache.requestedSymbols.namespace.length; ns++) {
562
+ if (ns === namespaceIndex) {
563
+ continue; // avoid self reference
564
+ }
565
+ const module = cache.namespace[ns].module;
566
+ if (cache.requestedSymbols.namespace[ns] && Object.values(cache.requestedSymbols.namespace[ns]).length > 0) {
567
+ usedImport.push(module);
568
+ }
569
+ }
570
+ return usedImport;
571
+ }
572
+ exports.findUsedImport = findUsedImport;
573
+ function dumpUsedExport(currentType, namespaceIndex, cache, f) {
574
+ f = f || new node_opcua_utils_1.LineFile();
575
+ for (const imp of Object.keys(cache.imports)) {
576
+ const symbolToImport = Object.keys(cache.imports[imp]).filter((f) => f !== currentType && Object.prototype.hasOwnProperty.call(cache.requestedBasicTypes, f));
577
+ if (symbolToImport.length == 0) {
578
+ continue;
579
+ }
580
+ f.write(`import { ${symbolToImport.join(", ")} } from "${imp}"`);
581
+ }
582
+ for (let ns = 0; ns < cache.requestedSymbols.namespace.length; ns++) {
583
+ const n = cache.namespace[ns];
584
+ const sourceFolder = n.sourceFolder;
585
+ const module = n.module;
586
+ if (ns === namespaceIndex) {
587
+ // include individuals stuff
588
+ for (const [symbol, s] of Object.entries(cache.requestedSymbols.namespace[ns].symbols).filter((a) => a[0] !== currentType)) {
589
+ const filename = (0, to_filename_1.toFilename)(symbol);
590
+ const subSymbolList = getSubSymbolList(s);
591
+ f.write(`import { ${subSymbolList.join(", ")} } from "./${filename}"`);
592
+ }
593
+ }
594
+ else {
595
+ if (cache.requestedSymbols.namespace[ns]) {
596
+ for (const [symbol, s] of Object.entries(cache.requestedSymbols.namespace[ns].symbols)) {
597
+ const subSymbolList = getSubSymbolList(s);
598
+ const filename = (0, to_filename_1.toFilename)(symbol);
599
+ f.write(`import { ${subSymbolList.join(", ")} } from "${module}/source/${filename}"`);
600
+ }
601
+ }
602
+ }
603
+ }
604
+ return f.toString();
605
+ }
606
+ function toComment(prefix, description) {
607
+ const d = wrapText(description);
608
+ return d
609
+ .split("\n")
610
+ .map((x) => prefix + x)
611
+ .join("\n");
612
+ }
613
+ // eslint-disable-next-line max-statements
614
+ function _exportDataTypeToTypescript(session, nodeId, cache, f) {
615
+ return __awaiter(this, void 0, void 0, function* () {
616
+ f = f || new node_opcua_utils_1.LineFile();
617
+ const importCollector = (i) => {
618
+ cache.ensureImported(i);
619
+ };
620
+ const nodeClass = node_opcua_data_model_1.NodeClass.DataType;
621
+ const description = yield (0, utils_1.getDescription)(session, nodeId);
622
+ const definition = yield (0, utils_1.getDefinition)(session, nodeId);
623
+ const browseName = yield (0, utils_1.getBrowseName)(session, nodeId);
624
+ const isAbstract = yield (0, utils_1.getIsAbstract)(session, nodeId);
625
+ const interfaceImport = (0, cache_1.makeTypeNameNew)(nodeClass, definition, browseName);
626
+ const interfaceName = interfaceImport.name;
627
+ const superType = yield (0, utils_1.getSubtypeNodeId)(session, nodeId);
628
+ const baseInterfaceImport = (0, cache_1.makeTypeNameNew)(nodeClass, definition, superType.browseName);
629
+ cache.ensureImported(baseInterfaceImport);
630
+ const baseInterfaceName = baseInterfaceImport.name;
631
+ // f.write(superType.toString());
632
+ f.write(`/**`);
633
+ if (description.text) {
634
+ f.write(toComment(" * ", description.text || ""));
635
+ f.write(` *`);
636
+ }
637
+ f.write(` * | |${f1(" ")}|`);
638
+ f.write(` * |-----------|${f2("-")}|`);
639
+ f.write(` * | namespace |${f1(cache.namespace[nodeId.namespace].namespaceUri)}|`);
640
+ f.write(` * | nodeClass |${f1(node_opcua_data_model_1.NodeClass[nodeClass])}|`);
641
+ f.write(` * | name |${f1(browseName.toString())}|`);
642
+ f.write(` * | isAbstract|${f1(isAbstract.toString())}|`);
643
+ f.write(` */`);
644
+ let type = "basic";
645
+ if (definition instanceof node_opcua_types_1.EnumDefinition) {
646
+ type = "enum";
647
+ f.write(`export enum ${interfaceName} {`);
648
+ for (const field of definition.fields) {
649
+ if (field.description.text) {
650
+ f.write(` /**`);
651
+ f.write(toComment(" * ", field.description.text || ""));
652
+ f.write(` */`);
653
+ }
654
+ f.write(` ${quotifyIfNecessary(field.name)} = ${field.value[1]},`);
655
+ }
656
+ f.write(`}`);
657
+ }
658
+ else if (definition instanceof node_opcua_types_1.StructureDefinition) {
659
+ type = "structure";
660
+ if (interfaceName === "DTStructure") {
661
+ f.write(`export interface ${interfaceName} {`);
662
+ }
663
+ else {
664
+ f.write(`export interface ${interfaceName} extends ${baseInterfaceName} {`);
665
+ }
666
+ for (const field of definition.fields) {
667
+ const fieldName = toJavascritPropertyName(field.name);
668
+ // special case ! fieldName=
669
+ if (field.description.text) {
670
+ f.write(`/** ${field.description.text}*/`);
671
+ }
672
+ let ar = "";
673
+ if (field.valueRank >= 1) {
674
+ ar = "[]";
675
+ }
676
+ const { dataType, jtype } = yield getCorrepondingJavascriptType(session, field.dataType, cache, importCollector);
677
+ f.write(` ${quotifyIfNecessary(fieldName)}: ${jtype}${ar}; // ${node_opcua_variant_1.DataType[dataType]} ${field.dataType.toString()}`);
678
+ }
679
+ f.write(`}`);
680
+ }
681
+ else {
682
+ type = "basic";
683
+ f.write(`// NO DEFINITION`);
684
+ f.write(`export interface ${interfaceName} extends ${baseInterfaceName} {`);
685
+ f.write(`}`);
686
+ // throw new Error("Invalid " + definition?.constructor.name);
687
+ }
688
+ return { type, content: f.toString(), typeName: interfaceName };
689
+ });
690
+ }
691
+ exports._exportDataTypeToTypescript = _exportDataTypeToTypescript;
692
+ function calculateChevrons(classDef, classDefDerived) {
693
+ const { nodeClass, dataType, dataTypeName } = classDef;
694
+ let chevronsDef = "";
695
+ let chevronsUse = "";
696
+ let chevronsExtend = "";
697
+ if (nodeClass !== node_opcua_data_model_1.NodeClass.VariableType) {
698
+ return { chevronsDef, chevronsUse, chevronsExtend };
699
+ }
700
+ if (!isUnspecifiedDataType(dataType)) {
701
+ chevronsDef = `<T extends ${dataTypeName}/*j*/>`;
702
+ chevronsUse = "<T/*k*/>";
703
+ if (classDefDerived) {
704
+ if (isUnspecifiedDataType(classDefDerived.dataType)) {
705
+ chevronsExtend = `<T, /*i*/DataType.${node_opcua_variant_1.DataType[dataType]}>`;
706
+ }
707
+ else {
708
+ chevronsExtend = `<T/*h*/>`;
709
+ }
710
+ }
711
+ }
712
+ else {
713
+ // classDef.dataType === DataType.Null
714
+ chevronsDef = `<T, DT extends DataType>`;
715
+ if (classDefDerived) {
716
+ if (isUnspecifiedDataType(classDefDerived.dataType)) {
717
+ chevronsUse = "<T, /*m*/DT>";
718
+ chevronsExtend = `<T/*g*/, DT>`;
719
+ }
720
+ else {
721
+ chevronsUse = `<T, /*n*/DataType.${node_opcua_variant_1.DataType[classDefDerived.dataType]}>`;
722
+ chevronsExtend = `<T, /*e*/DataType.${node_opcua_variant_1.DataType[classDefDerived.dataType]}>`;
723
+ }
724
+ }
725
+ }
726
+ return { chevronsDef, chevronsUse, chevronsExtend };
727
+ }
728
+ // find the structure member that are already in base structure definition and that are replicated here
729
+ // we will have to use the Omit<Base,"member1" |"member2"> typescript pattern to avoid issues
730
+ function extractMembersRecursively(classDef) {
731
+ if (!classDef) {
732
+ return [];
733
+ }
734
+ const m = classDef.members.map((m) => m.name);
735
+ if (classDef.baseClassDef) {
736
+ const m2 = extractMembersRecursively(classDef.baseClassDef);
737
+ return m.concat(m2);
738
+ }
739
+ return m;
740
+ }
741
+ function getBaseClassWithOmit(classDef) {
742
+ const { baseInterfaceName, members } = classDef;
743
+ const allMembers = extractMembersRecursively(classDef.baseClassDef);
744
+ const conflictingMembers = members.filter((m) => allMembers.indexOf(m.name) !== -1);
745
+ //console.log(allMembers.join(" "));
746
+ if (conflictingMembers.length) {
747
+ // console.log("conflictingMembers = ", conflictingMembers.map((a) => a.name).join(" "));
748
+ }
749
+ const chBase = calculateChevrons(classDef.baseClassDef, classDef);
750
+ let baseStuff = `${baseInterfaceName === null || baseInterfaceName === void 0 ? void 0 : baseInterfaceName.name}${chBase.chevronsUse}`;
751
+ if (conflictingMembers.length) {
752
+ baseStuff = `Omit<${baseStuff}, ${conflictingMembers.map((a) => `"${a.name}"`).join("|")}>`;
753
+ }
754
+ return baseStuff;
755
+ }
756
+ function getBaseClassWithOmit2(classMember) {
757
+ const members = classMember.children2;
758
+ const allMembers = extractMembersRecursively(classMember.classDef);
759
+ const conflictingMembers = members.filter((m) => allMembers.indexOf(m.name) !== -1);
760
+ //console.log(allMembers.join(" "));
761
+ if (conflictingMembers.length) {
762
+ console.log("conflictingMembers = ", conflictingMembers.map((a) => a.name).join(" "));
763
+ }
764
+ const childBase = classMember.childBase;
765
+ let baseStuff = `${childBase === null || childBase === void 0 ? void 0 : childBase.name}${classMember.suffix3}`;
766
+ if (conflictingMembers.length) {
767
+ baseStuff = `Omit<${baseStuff}, ${conflictingMembers.map((a) => `"${a.name}"`).join("|")}>`;
768
+ }
769
+ return baseStuff;
770
+ }
771
+ /**
772
+ * nodeId : a DataType, ReferenceType,AObjectType, VariableType node
773
+ */
774
+ // eslint-disable-next-line max-statements
775
+ function _convertTypeToTypescript(session, nodeId, cache, f) {
776
+ return __awaiter(this, void 0, void 0, function* () {
777
+ f = f || new node_opcua_utils_1.LineFile();
778
+ const nodeClass = yield (0, utils_1.getNodeClass)(session, nodeId);
779
+ if (nodeClass === node_opcua_data_model_1.NodeClass.DataType) {
780
+ return yield _exportDataTypeToTypescript(session, nodeId, cache, f);
781
+ }
782
+ const classDef = yield extractClassDefinition(session, nodeId, cache);
783
+ // if (classDef.browseName.toString().match(/PubSubDiagnosticsWriterGroupType/)) {
784
+ // debugger;
785
+ // }
786
+ const { dataTypeName, dataType, dataTypeNodeId, interfaceName, baseInterfaceName, browseName, description, isAbstract, members } = classDef;
787
+ yield preDumpChildren(session, " ", classDef, f, cache);
788
+ // f.write(superType.toString());
789
+ f.write(`/**`);
790
+ if (description.text) {
791
+ f.write(toComment(" * ", description.text || ""));
792
+ f.write(` *`);
793
+ }
794
+ f.write(` * | |${f1(" ")}|`);
795
+ f.write(` * |----------------|${f2("-")}|`);
796
+ f.write(` * |namespace |${f1(cache.namespace[nodeId.namespace].namespaceUri)}|`);
797
+ f.write(` * |nodeClass |${f1(node_opcua_data_model_1.NodeClass[nodeClass])}|`);
798
+ f.write(` * |typedDefinition |${f1(browseName.toString() + " " + nodeId.toString())}|`);
799
+ if (nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
800
+ f.write(` * |dataType |${f1(node_opcua_variant_1.DataType[dataType])}|`);
801
+ f.write(` * |dataType Name |${f1(dataTypeName + " " + (dataTypeNodeId === null || dataTypeNodeId === void 0 ? void 0 : dataTypeNodeId.toString()))}|`);
802
+ }
803
+ f.write(` * |isAbstract |${f1(isAbstract.toString())}|`);
804
+ f.write(` */`);
805
+ // if (interfaceName.name === "UAOperationLimits") {
806
+ // debugger;
807
+ // }
808
+ cache.ensureImported(baseInterfaceName);
809
+ cache.ensureImported(Object.assign(Object.assign({}, baseInterfaceName), { name: baseInterfaceName.name + `${baseExtension}` }));
810
+ const ch = calculateChevrons(classDef);
811
+ if (nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
812
+ if (classDef.dataTypeImport) {
813
+ console.log(chalk.red(" ----------------> ", classDef.browseName));
814
+ classDef.dataTypeImport.forEach((a) => {
815
+ console.log(chalk.red(" ------------------------> ", a.module, a.name, a.namespace));
816
+ });
817
+ classDef.dataTypeImport.forEach(cache.ensureImported.bind(cache));
818
+ }
819
+ cache.referenceBasicType("DataType");
820
+ const chevrons = calculateChevrons(classDef);
821
+ const chevronsBase = calculateChevrons(classDef.baseClassDef, classDef);
822
+ // Shall we cache.ensureImported({ ...baseInterfaceName!, module: dataTypeName, name: dataTypeName });
823
+ const classBaseName = `${interfaceName.name}${baseExtension}${chevrons.chevronsDef}`;
824
+ if ((baseInterfaceName === null || baseInterfaceName === void 0 ? void 0 : baseInterfaceName.name) === "UAVariableT") {
825
+ f.write(`export interface ${classBaseName} {`);
826
+ }
827
+ else {
828
+ const baseName = `${baseInterfaceName === null || baseInterfaceName === void 0 ? void 0 : baseInterfaceName.name}${baseExtension}${chevronsBase.chevronsExtend}`;
829
+ f.write(`export interface ${classBaseName} extends ${baseName} {`);
830
+ }
831
+ }
832
+ else {
833
+ const classBaseName = `${interfaceName.name}${baseExtension}`;
834
+ if ((baseInterfaceName === null || baseInterfaceName === void 0 ? void 0 : baseInterfaceName.name) === "UAObject") {
835
+ f.write(`export interface ${classBaseName} {`);
836
+ }
837
+ else {
838
+ const baseName = `${baseInterfaceName === null || baseInterfaceName === void 0 ? void 0 : baseInterfaceName.name}${baseExtension}`;
839
+ f.write(`export interface ${classBaseName} extends ${baseName} {`);
840
+ }
841
+ }
842
+ yield dumpChildren(session, " ", members, f, cache);
843
+ f.write(`}`);
844
+ const baseStuff = getBaseClassWithOmit(classDef);
845
+ if (nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
846
+ cache.referenceBasicType("DataType");
847
+ // if dataType is a extension object we can simpligy by forcing DT
848
+ const className = `${interfaceName.name}${ch.chevronsDef}`;
849
+ const c = isUnspecifiedDataType(dataType) ? "<T, DT /*A*/>" : "<T /*B*/>";
850
+ const classBaseName = `${interfaceName.name}${baseExtension}${c}`;
851
+ f.write(`export interface ${className} extends ${baseStuff}, ${classBaseName} {`);
852
+ }
853
+ else {
854
+ const className = `${interfaceName.name}`;
855
+ const classBaseName = `${interfaceName.name}${baseExtension}`;
856
+ f.write(`export interface ${className} extends ${baseStuff}, ${classBaseName} {`);
857
+ }
858
+ f.write(`}`);
859
+ return { type: "ua", content: f.toString(), typeName: interfaceName.name };
860
+ });
861
+ }
862
+ exports._convertTypeToTypescript = _convertTypeToTypescript;
863
+ function convertTypeToTypescript(session, nodeId, options, cache, f) {
864
+ return __awaiter(this, void 0, void 0, function* () {
865
+ f = new node_opcua_utils_1.LineFile();
866
+ cache = cache || (yield (0, cache_1.constructCache)(session, options));
867
+ const { type, content, typeName } = yield _convertTypeToTypescript(session, nodeId, cache);
868
+ f.write(`// ----- this file has been automatically generated - do not edit`);
869
+ f.write(dumpUsedExport(typeName, nodeId.namespace, cache));
870
+ f.write(content);
871
+ const folder = cache.namespace[nodeId.namespace].sourceFolder;
872
+ const module = cache.namespace[nodeId.namespace].module;
873
+ const filename = (0, to_filename_1.toFilename)(typeName);
874
+ const dependencies = findUsedImport(nodeId.namespace, cache);
875
+ return { type, content: f.toString(), folder, module, filename, dependencies };
876
+ });
877
+ }
878
+ exports.convertTypeToTypescript = convertTypeToTypescript;
879
+ //# sourceMappingURL=convert_to_typescript.js.map