node-opcua-convert-nodeset-to-javascript 2.135.0 → 2.137.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.
- package/dist/_dataType.js +1 -1
- package/dist/_dataType.js.map +1 -1
- package/dist/convert_namespace_to_typescript.js +50 -0
- package/dist/convert_namespace_to_typescript.js.map +1 -1
- package/dist/convert_to_typescript.d.ts +3 -0
- package/dist/convert_to_typescript.js +29 -7
- package/dist/convert_to_typescript.js.map +1 -1
- package/dist/main.js +14 -6
- package/dist/main.js.map +1 -1
- package/dist/private/get_corresponding_data_type.d.ts +4 -0
- package/dist/private/get_corresponding_data_type.js +86 -60
- package/dist/private/get_corresponding_data_type.js.map +1 -1
- package/dist/private/utils.d.ts +12 -2
- package/dist/private/utils.js +23 -3
- package/dist/private/utils.js.map +1 -1
- package/dist/update_parent_tsconfig.js +6 -5
- package/dist/update_parent_tsconfig.js.map +1 -1
- package/package.json +12 -12
- package/source/_dataType.ts +1 -1
- package/source/convert_namespace_to_typescript.ts +60 -1
- package/source/convert_to_typescript.ts +40 -11
- package/source/main.ts +13 -5
- package/source/private/get_corresponding_data_type.ts +90 -63
- package/source/private/utils.ts +36 -5
- package/source/update_parent_tsconfig.ts +7 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable max-depth */
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import { LocalizedText, NodeClass, QualifiedName } from "node-opcua-data-model";
|
|
4
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
4
|
+
import { NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
5
5
|
import { IBasicSessionBrowseAsyncSimple, IBasicSessionReadAsyncSimple } from "node-opcua-pseudo-session";
|
|
6
6
|
import {
|
|
7
7
|
ReferenceDescription,
|
|
@@ -14,7 +14,6 @@ import assert from "node-opcua-assert";
|
|
|
14
14
|
import { ModellingRuleType } from "node-opcua-address-space-base";
|
|
15
15
|
import { make_warningLog, make_debugLog } from "node-opcua-debug";
|
|
16
16
|
import {
|
|
17
|
-
_convertNodeIdToDataTypeAsync,
|
|
18
17
|
getBrowseName,
|
|
19
18
|
getIsAbstract,
|
|
20
19
|
getDefinition,
|
|
@@ -25,7 +24,8 @@ import {
|
|
|
25
24
|
getTypeDefOrBaseType,
|
|
26
25
|
getChildrenOrFolderElements,
|
|
27
26
|
getDataTypeNodeId,
|
|
28
|
-
extractBasicDataType
|
|
27
|
+
extractBasicDataType,
|
|
28
|
+
getValueRank} from "./private/utils";
|
|
29
29
|
|
|
30
30
|
import {
|
|
31
31
|
Cache,
|
|
@@ -57,6 +57,10 @@ const m9 = !doDebug ? "" : `/* 9 */`;
|
|
|
57
57
|
const mA = !doDebug ? "" : `/* a */`;
|
|
58
58
|
const mB = !doDebug ? "" : `/* b */`;
|
|
59
59
|
const mC = !doDebug ? "" : `/* c */`;
|
|
60
|
+
const mD = !doDebug ? "" : `/* d */`;
|
|
61
|
+
const mE = !doDebug ? "" : `/* e */`;
|
|
62
|
+
const mF = !doDebug ? "" : `/* f */`;
|
|
63
|
+
|
|
60
64
|
|
|
61
65
|
export async function convertDataTypeToTypescript(session: IBasicSessionReadAsyncSimple, dataTypeId: NodeId): Promise<void> {
|
|
62
66
|
const definition = await getDefinition(session, dataTypeId);
|
|
@@ -92,6 +96,8 @@ interface ClassDefinition {
|
|
|
92
96
|
dataType: DataType;
|
|
93
97
|
dataTypeName: string;
|
|
94
98
|
dataTypeImport?: Import[];
|
|
99
|
+
valueRank?: number;
|
|
100
|
+
dataTypeCombination?: string;
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
export function makeTypeName2(nodeClass: NodeClass, browseName: QualifiedName, suffix?: string): Import {
|
|
@@ -128,19 +134,24 @@ export async function extractClassDefinition(
|
|
|
128
134
|
let dataTypeName = "";
|
|
129
135
|
let dataType: DataType = DataType.Null;
|
|
130
136
|
let dataTypeImport: Import[] | undefined = undefined;
|
|
137
|
+
let valueRank: number| undefined;
|
|
138
|
+
let dataTypeCombination: string| undefined;;
|
|
131
139
|
if (nodeClass === NodeClass.VariableType) {
|
|
132
140
|
dataType = await extractBasicDataType(session, dataTypeNodeId!);
|
|
133
141
|
const importCollector = (i: Import) => {
|
|
134
142
|
extraImports.push(i);
|
|
135
143
|
cache.ensureImported(i);
|
|
136
144
|
};
|
|
137
|
-
const
|
|
145
|
+
const info = await getCorrespondingJavascriptType2(session, nodeId, dataTypeNodeId!, cache, importCollector);
|
|
146
|
+
const jtype = info.jtype;
|
|
147
|
+
dataTypeCombination = info.dataTypeCombination;
|
|
138
148
|
dataTypeName = jtype; // with decoration
|
|
139
149
|
if (!dataTypeNodeId?.isEmpty()) {
|
|
140
150
|
// "DT" + (await getBrowseName(session, dataTypeNodeId!))?.name! || "";
|
|
141
151
|
// const bn = await getBrowseName(session, dataTypeNodeId!);
|
|
142
152
|
dataTypeImport = extraImports; // makeTypeName2(NodeClass.DataType, bn);
|
|
143
153
|
}
|
|
154
|
+
valueRank = await getValueRank(session, nodeId);
|
|
144
155
|
}
|
|
145
156
|
|
|
146
157
|
const baseClassDef = !superType ? null : await extractClassDefinition(session, superType.nodeId, cache);
|
|
@@ -177,7 +188,10 @@ export async function extractClassDefinition(
|
|
|
177
188
|
members,
|
|
178
189
|
|
|
179
190
|
interfaceName,
|
|
180
|
-
baseInterfaceName
|
|
191
|
+
baseInterfaceName,
|
|
192
|
+
valueRank,
|
|
193
|
+
dataTypeCombination
|
|
194
|
+
|
|
181
195
|
};
|
|
182
196
|
_c[nodeId.toString()] = classDef;
|
|
183
197
|
|
|
@@ -236,6 +250,7 @@ interface ClassMember extends ClassMemberBasic {
|
|
|
236
250
|
suffix2?: string;
|
|
237
251
|
suffix3?: string;
|
|
238
252
|
innerClass?: Import | null;
|
|
253
|
+
dataTypeCombination?: string;
|
|
239
254
|
childBase?: Import | null;
|
|
240
255
|
}
|
|
241
256
|
|
|
@@ -381,6 +396,7 @@ async function _extractLocalMembers(
|
|
|
381
396
|
classMember: ClassMember,
|
|
382
397
|
cache: Cache
|
|
383
398
|
): Promise<ClassMemberBasic[]> {
|
|
399
|
+
|
|
384
400
|
const children2: ClassMemberBasic[] = [];
|
|
385
401
|
for (const child of classMember.children) {
|
|
386
402
|
const nodeId = child.nodeId;
|
|
@@ -446,8 +462,9 @@ async function extractVariableExtra(
|
|
|
446
462
|
const nodeClass = await getNodeClass(session, nodeId);
|
|
447
463
|
if (nodeClass === NodeClass.Variable) {
|
|
448
464
|
const dataTypeNodeId = await getDataTypeNodeId(session, nodeId);
|
|
465
|
+
const valueRank = await getValueRank(session, nodeId);
|
|
449
466
|
|
|
450
|
-
const { dataType, jtype } = await getCorrespondingJavascriptType2(session, nodeId, dataTypeNodeId!, cache, importCollector);
|
|
467
|
+
const { dataType, jtype, dataTypeCombination, type } = await getCorrespondingJavascriptType2(session, nodeId, dataTypeNodeId!, cache, importCollector);
|
|
451
468
|
|
|
452
469
|
cache && cache.referenceBasicType("DataType");
|
|
453
470
|
importCollector({ name: "DataType", namespace: -1, module: "BasicType" });
|
|
@@ -457,7 +474,7 @@ async function extractVariableExtra(
|
|
|
457
474
|
const suffix =
|
|
458
475
|
jtype === "undefined" || isUnspecifiedDataType(dataType)
|
|
459
476
|
? `<any, any>`
|
|
460
|
-
: `<${jtype}${t ? `, ${m0}DataType.${DataType[dataType]}` :
|
|
477
|
+
: `<${jtype}${t ? `, ${m0}DataType.${DataType[dataType]}` :""}>`;
|
|
461
478
|
|
|
462
479
|
// const suffix2 = `<T${t ? `, /DT extends DataType` : ""}>`;
|
|
463
480
|
const suffix3 = `<T${t ? `, ${m1}DT` : ""}>`;
|
|
@@ -479,13 +496,22 @@ async function extractVariableExtra(
|
|
|
479
496
|
}
|
|
480
497
|
} else {
|
|
481
498
|
if (!isUnspecifiedDataType(typeDefCD.dataType)) {
|
|
482
|
-
|
|
499
|
+
|
|
500
|
+
if (jtype === "number" && (dataTypeNodeId!.value as number> 25)) {
|
|
501
|
+
console.log("dataTypeNodeId", dataTypeNodeId?.toString()), dataTypeCombination;
|
|
502
|
+
}
|
|
503
|
+
if (dataTypeCombination) {
|
|
504
|
+
suffixInstantiate = `<${jtype}${mD},${dataTypeCombination}>`;
|
|
505
|
+
} else {
|
|
506
|
+
suffixInstantiate = `<${jtype}${mE}>`;
|
|
507
|
+
|
|
508
|
+
}
|
|
483
509
|
} else {
|
|
484
|
-
suffixInstantiate = `<${jtype}, DataType.${DataType[dataType]}>`;
|
|
510
|
+
suffixInstantiate = `<${jtype}, DataType.${DataType[dataType]}${mF}>`;
|
|
485
511
|
}
|
|
486
512
|
}
|
|
487
513
|
|
|
488
|
-
return { suffixInstantiate, suffix, suffix2, suffix3, dataTypeNodeId, dataType, jtype, typeToReference, chevrons };
|
|
514
|
+
return { suffixInstantiate, suffix, suffix2, suffix3, dataTypeNodeId, dataType, jtype, typeToReference, chevrons , dataTypeCombination};
|
|
489
515
|
}
|
|
490
516
|
return { suffix: "", typeToReference };
|
|
491
517
|
}
|
|
@@ -577,7 +603,7 @@ export async function extractClassMemberDef(
|
|
|
577
603
|
} else {
|
|
578
604
|
// may not expose definition but we may want to used the augment typescript class defined in the definition
|
|
579
605
|
// we don't need to create an inner class ...
|
|
580
|
-
childType = sameMemberInBaseClass ? sameMemberInBaseClass?.childType : childType;
|
|
606
|
+
// xxxx NOT HERE childType = sameMemberInBaseClass ? sameMemberInBaseClass?.childType : childType;
|
|
581
607
|
assert(!innerClass);
|
|
582
608
|
assert(!childBase);
|
|
583
609
|
}
|
|
@@ -882,8 +908,11 @@ export async function _convertTypeToTypescript(
|
|
|
882
908
|
f.write(` * |nodeClass |${f1(NodeClass[nodeClass])}|`);
|
|
883
909
|
f.write(` * |typedDefinition |${f1(browseName.name!.toString() + " " + n(nodeId))}|`);
|
|
884
910
|
if (nodeClass === NodeClass.VariableType) {
|
|
911
|
+
const { valueRank } = classDef;
|
|
885
912
|
f.write(` * |dataType |${f1(DataType[dataType])}|`);
|
|
886
913
|
f.write(` * |dataType Name |${f1(dataTypeName + " " + n(dataTypeNodeId))}|`);
|
|
914
|
+
valueRank && f.write(` * |value rank |${f1(valueRank.toString())}|`);
|
|
915
|
+
|
|
887
916
|
}
|
|
888
917
|
f.write(` * |isAbstract |${f1(isAbstract.toString())}|`);
|
|
889
918
|
f.write(` */`);
|
package/source/main.ts
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { AddressSpace, PseudoSession } from "node-opcua-address-space";
|
|
3
3
|
import { generateAddressSpace } from "node-opcua-address-space/nodeJS";
|
|
4
|
-
import {
|
|
4
|
+
import { constructNodesetFilename, nodesetCatalog } from "node-opcua-nodesets";
|
|
5
5
|
import { convertNamespaceTypeToTypescript } from "./convert_namespace_to_typescript";
|
|
6
6
|
import { updateParentTSConfig } from './update_parent_tsconfig';
|
|
7
7
|
|
|
8
8
|
async function main() {
|
|
9
9
|
const addressSpace = AddressSpace.create();
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
const xmlFiles = nodesetCatalog.map((set) => constructNodesetFilename(set.xmlFile));
|
|
12
|
+
await generateAddressSpace(addressSpace, xmlFiles);
|
|
11
13
|
|
|
12
14
|
const session = new PseudoSession(addressSpace);
|
|
13
15
|
const options = {
|
|
14
16
|
baseFolder: path.join(__dirname, "../../"),
|
|
15
|
-
prefix: "node-opcua-nodeset-"
|
|
17
|
+
prefix: "node-opcua-nodeset-",
|
|
16
18
|
};
|
|
17
|
-
await Promise.all(
|
|
18
|
-
|
|
19
|
+
await Promise.all(nodesetCatalog.map((meta) => {
|
|
20
|
+
const index = addressSpace.getNamespaceIndex(meta.uri);
|
|
21
|
+
if (index === -1) {
|
|
22
|
+
console.log("namespace not found", meta.uri);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
convertNamespaceTypeToTypescript(session, index, {
|
|
19
26
|
...options,
|
|
20
27
|
nsName: meta.name,
|
|
21
28
|
})
|
|
29
|
+
}
|
|
22
30
|
));
|
|
23
31
|
await updateParentTSConfig();
|
|
24
32
|
}
|
|
@@ -11,10 +11,24 @@ export async function getCorrespondingJavascriptType2(
|
|
|
11
11
|
dataTypeNodeId: NodeId,
|
|
12
12
|
cache: Cache,
|
|
13
13
|
importCollect?: (t: Import) => void
|
|
14
|
-
): Promise<{ dataType: DataType; jtype: string }> {
|
|
15
|
-
const
|
|
14
|
+
): Promise<{ dataType: DataType; jtype: string, dataTypeCombination?: string, type: "enum" | "basic" | "genericNumber"}> {
|
|
15
|
+
const { dataType, jtype, dataTypeCombination, type} = await getCorrespondingJavascriptType(session, dataTypeNodeId, cache, importCollect);
|
|
16
16
|
const valueRank = await getValueRank(session, nodeId);
|
|
17
|
-
|
|
17
|
+
let jtype2 = "";
|
|
18
|
+
if (valueRank >= 0) {
|
|
19
|
+
jtype2 = jtype + "[]";
|
|
20
|
+
} else if (valueRank === -1) {
|
|
21
|
+
jtype2 = jtype;
|
|
22
|
+
} else if (valueRank === -2) {
|
|
23
|
+
// The value can be a scalar or an array with any number of dimensions.
|
|
24
|
+
jtype2 = `(${jtype} | ${jtype}[])`;
|
|
25
|
+
} else if (valueRank === -3) {
|
|
26
|
+
// ScalarOrOneDimension (-3): The value can be a scalar or a one dimensional array.
|
|
27
|
+
jtype2 = `(${jtype} | ${jtype}[])`;
|
|
28
|
+
} else {
|
|
29
|
+
throw new Error("Invalid valueRank " + valueRank);
|
|
30
|
+
}
|
|
31
|
+
return { dataType: dataType, jtype: jtype2, dataTypeCombination, type };
|
|
18
32
|
}
|
|
19
33
|
|
|
20
34
|
// eslint-disable-next-line complexity
|
|
@@ -23,22 +37,30 @@ export async function getCorrespondingJavascriptType(
|
|
|
23
37
|
dataTypeNodeId: NodeId,
|
|
24
38
|
cache: Cache,
|
|
25
39
|
importCollect?: (t: Import) => void
|
|
26
|
-
): Promise<{
|
|
27
|
-
|
|
40
|
+
): Promise<{
|
|
41
|
+
enumerationType?: string;
|
|
42
|
+
dataType: DataType;
|
|
43
|
+
jtype: string,
|
|
44
|
+
type: "enum" | "basic" | "genericNumber",
|
|
45
|
+
dataTypeCombination?: string
|
|
46
|
+
}> {
|
|
47
|
+
|
|
48
|
+
const info = await _convertNodeIdToDataTypeAsync(session, dataTypeNodeId);
|
|
49
|
+
const { type } = info;
|
|
28
50
|
|
|
29
|
-
if (enumerationType) {
|
|
51
|
+
if (type == "enum" && info.enumerationType) {
|
|
30
52
|
// we have a enmeration name here
|
|
31
53
|
const jtypeImport = await referenceEnumeration(session, dataTypeNodeId);
|
|
32
54
|
const jtype = jtypeImport.name;
|
|
33
55
|
importCollect && importCollect(jtypeImport);
|
|
34
|
-
return { dataType, jtype };
|
|
56
|
+
return { dataType: info.dataType, jtype, type };
|
|
35
57
|
}
|
|
36
58
|
|
|
37
|
-
if (dataType === DataType.ExtensionObject) {
|
|
59
|
+
if (type == "basic" && info.dataType === DataType.ExtensionObject) {
|
|
38
60
|
const jtypeImport = await referenceExtensionObject(session, dataTypeNodeId);
|
|
39
61
|
const jtype = jtypeImport.name;
|
|
40
62
|
importCollect && importCollect(jtypeImport);
|
|
41
|
-
return { dataType, jtype };
|
|
63
|
+
return { dataType: info.dataType, jtype, type };
|
|
42
64
|
}
|
|
43
65
|
const referenceBasicType = (name: string): string => {
|
|
44
66
|
const t = { name, namespace: -1, module: "BasicType" };
|
|
@@ -46,59 +68,64 @@ export async function getCorrespondingJavascriptType(
|
|
|
46
68
|
cache.ensureImported(t);
|
|
47
69
|
return t.name;
|
|
48
70
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
71
|
+
if (type == "genericNumber") {
|
|
72
|
+
const { dataTypeCombination } = info;
|
|
73
|
+
return { dataType: DataType.Variant, jtype: "number", type, dataTypeCombination };
|
|
74
|
+
} else {
|
|
75
|
+
const { dataType } = info;
|
|
76
|
+
switch (dataType) {
|
|
77
|
+
case DataType.Null:
|
|
78
|
+
return { dataType: DataType.Variant, jtype: referenceBasicType("VariantOptions"), type };
|
|
79
|
+
case DataType.Boolean:
|
|
80
|
+
return { dataType, jtype: "boolean", type };
|
|
81
|
+
case DataType.Byte:
|
|
82
|
+
return { dataType, jtype: referenceBasicType("Byte"), type };
|
|
83
|
+
case DataType.ByteString:
|
|
84
|
+
return { dataType, jtype: "Buffer", type };
|
|
85
|
+
case DataType.DataValue:
|
|
86
|
+
return { dataType, jtype: referenceBasicType("DataValue"), type };
|
|
87
|
+
case DataType.DateTime:
|
|
88
|
+
return { dataType, jtype: "Date", type };
|
|
89
|
+
case DataType.DiagnosticInfo:
|
|
90
|
+
return { dataType, jtype: referenceBasicType("DiagnosticInfo"), type };
|
|
91
|
+
case DataType.Double:
|
|
92
|
+
return { dataType, jtype: "number", type };
|
|
93
|
+
case DataType.Float:
|
|
94
|
+
return { dataType, jtype: "number", type };
|
|
95
|
+
case DataType.Guid:
|
|
96
|
+
return { dataType, jtype: referenceBasicType("Guid"), type };
|
|
97
|
+
case DataType.Int16:
|
|
98
|
+
return { dataType, jtype: referenceBasicType("Int16"), type };
|
|
99
|
+
case DataType.Int32:
|
|
100
|
+
return { dataType, jtype: referenceBasicType("Int32"), type };
|
|
101
|
+
case DataType.UInt16:
|
|
102
|
+
return { dataType, jtype: referenceBasicType("UInt16"), type };
|
|
103
|
+
case DataType.UInt32:
|
|
104
|
+
return { dataType, jtype: referenceBasicType("UInt32"), type };
|
|
105
|
+
case DataType.UInt64:
|
|
106
|
+
return { dataType, jtype: referenceBasicType("UInt64"), type };
|
|
107
|
+
case DataType.Int64:
|
|
108
|
+
return { dataType, jtype: referenceBasicType("Int64"), type };
|
|
109
|
+
case DataType.LocalizedText:
|
|
110
|
+
return { dataType, jtype: referenceBasicType("LocalizedText"), type };
|
|
111
|
+
case DataType.NodeId:
|
|
112
|
+
return { dataType, jtype: referenceBasicType("NodeId"), type };
|
|
113
|
+
case DataType.ExpandedNodeId:
|
|
114
|
+
return { dataType, jtype: referenceBasicType("ExpandedNodeId"), type };
|
|
115
|
+
case DataType.QualifiedName:
|
|
116
|
+
return { dataType, jtype: referenceBasicType("QualifiedName"), type };
|
|
117
|
+
case DataType.SByte:
|
|
118
|
+
return { dataType, jtype: referenceBasicType("SByte"), type };
|
|
119
|
+
case DataType.StatusCode:
|
|
120
|
+
return { dataType, jtype: referenceBasicType("StatusCode"), type };
|
|
121
|
+
case DataType.String:
|
|
122
|
+
return { dataType, jtype: referenceBasicType("UAString"), type };
|
|
123
|
+
case DataType.Variant:
|
|
124
|
+
return { dataType, jtype: referenceBasicType("Variant"), type };
|
|
125
|
+
case DataType.XmlElement:
|
|
126
|
+
return { dataType, jtype: referenceBasicType("String"), type };
|
|
127
|
+
default:
|
|
128
|
+
throw new Error("Unsupported " + dataType + " " + DataType[dataType]);
|
|
129
|
+
}
|
|
103
130
|
}
|
|
104
131
|
}
|
package/source/private/utils.ts
CHANGED
|
@@ -184,11 +184,22 @@ async function readBrowseName(session: IBasicSessionReadAsyncSimple, nodeId: Nod
|
|
|
184
184
|
return dataTypeName;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
interface
|
|
187
|
+
interface DataTypeInfoBasic {
|
|
188
|
+
type: "basic";
|
|
188
189
|
dataType: DataType;
|
|
189
|
-
|
|
190
|
+
}
|
|
191
|
+
interface DataTypeInfoEnum {
|
|
192
|
+
type: "enum";
|
|
193
|
+
dataType: DataType.Int32;
|
|
194
|
+
enumerationId: NodeId;
|
|
190
195
|
enumerationType?: string;
|
|
191
196
|
}
|
|
197
|
+
interface DataTypeInfoGenericNumber {
|
|
198
|
+
type: "genericNumber";
|
|
199
|
+
dataTypeCombination: string;
|
|
200
|
+
}
|
|
201
|
+
type DataTypeInfo = DataTypeInfoBasic | DataTypeInfoEnum | DataTypeInfoGenericNumber;
|
|
202
|
+
|
|
192
203
|
// see also client-proxy
|
|
193
204
|
export async function _convertNodeIdToDataTypeAsync(
|
|
194
205
|
session: IBasicSessionReadAsyncSimple & IBasicSessionBrowseAsyncSimple,
|
|
@@ -198,12 +209,32 @@ export async function _convertNodeIdToDataTypeAsync(
|
|
|
198
209
|
|
|
199
210
|
let dataType: DataType;
|
|
200
211
|
|
|
212
|
+
if (dataTypeId.namespace === 0 && dataTypeId.value === DataTypeIds.Number) {
|
|
213
|
+
return {
|
|
214
|
+
type: "genericNumber",
|
|
215
|
+
dataTypeCombination: "DataType.Float | DataType.Double | " +
|
|
216
|
+
"DataType.UInt64 | DataType.UInt32 | DataType.UInt16 | DataType.SByte | " +
|
|
217
|
+
"DataType.Int64 | DataType.Int32 | DataType.Int16 | DataType.Byte"
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
if (dataTypeId.namespace === 0 && dataTypeId.value === DataTypeIds.Integer) {
|
|
221
|
+
return {
|
|
222
|
+
type: "genericNumber",
|
|
223
|
+
dataTypeCombination: "DataType.Int64 | DataType.Int32 | DataType.Int16 | DataType.SByte"
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
if (dataTypeId.namespace === 0 && dataTypeId.value === DataTypeIds.UInteger) {
|
|
227
|
+
return {
|
|
228
|
+
type: "genericNumber",
|
|
229
|
+
dataTypeCombination: "DataType.UInt64 | DataType.UInt32 | DataType.UInt16 | DataType.Byte"
|
|
230
|
+
};
|
|
231
|
+
}
|
|
201
232
|
if (dataTypeId.namespace === 0 && dataTypeId.value === DataTypeIds.Enumeration) {
|
|
202
|
-
return { dataType: DataType.Int32, enumerationId: dataTypeId };
|
|
233
|
+
return { type: "enum", dataType: DataType.Int32, enumerationId: dataTypeId };
|
|
203
234
|
}
|
|
204
235
|
if (dataTypeId.namespace === 0 && DataType[dataTypeId.value as number]) {
|
|
205
236
|
dataType = dataTypeId.value as DataType;
|
|
206
|
-
return { dataType };
|
|
237
|
+
return { type: "basic", dataType };
|
|
207
238
|
}
|
|
208
239
|
|
|
209
240
|
/// example => Duration (i=290) => Double (i=11)
|
|
@@ -225,7 +256,7 @@ export async function _convertNodeIdToDataTypeAsync(
|
|
|
225
256
|
const nodeId = references[0].nodeId;
|
|
226
257
|
|
|
227
258
|
const info = await _convertNodeIdToDataTypeAsync(session, nodeId);
|
|
228
|
-
if (info.enumerationId) {
|
|
259
|
+
if (info.type == "enum" && info.enumerationId) {
|
|
229
260
|
return { ...info, enumerationId: dataTypeId, enumerationType: dataTypeName.name! };
|
|
230
261
|
}
|
|
231
262
|
return info;
|
|
@@ -8,7 +8,7 @@ import path from 'path';
|
|
|
8
8
|
//import { fileURLToPath } from 'url';
|
|
9
9
|
//const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { nodesetCatalog } from "node-opcua-nodesets";
|
|
12
12
|
|
|
13
13
|
export async function updateParentTSConfig() {
|
|
14
14
|
const packagesFolder = path.join(__dirname, '..', '..');
|
|
@@ -23,15 +23,16 @@ export async function updateParentTSConfig() {
|
|
|
23
23
|
|
|
24
24
|
type TSConfigReference = { path: string };
|
|
25
25
|
const unlistedReferences: TSConfigReference[] = [];
|
|
26
|
-
for (const meta of
|
|
27
|
-
const
|
|
26
|
+
for (const meta of nodesetCatalog) {
|
|
27
|
+
const packageName = `node-opcua-nodeset-${meta.packageName}`;
|
|
28
|
+
const nodesetPackageFolder = path.join(packagesFolder, packageName);
|
|
28
29
|
if (!existsSync(nodesetPackageFolder)) {
|
|
29
30
|
console.log(`Ignoring ${meta.packageName} since package folder does not exist (${nodesetPackageFolder})`);
|
|
30
31
|
continue;
|
|
31
32
|
}
|
|
32
|
-
if (!parentTSConfig.references.some((ref: TSConfigReference) => ref.path ===
|
|
33
|
-
console.log(`Found nodeset package that was not listed in tsconfig.json: ${
|
|
34
|
-
unlistedReferences.push({ path:
|
|
33
|
+
if (!parentTSConfig.references.some((ref: TSConfigReference) => ref.path === packageName)) {
|
|
34
|
+
console.log(`Found nodeset package that was not listed in tsconfig.json: ${packageName}`);
|
|
35
|
+
unlistedReferences.push({ path: packageName });
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
|