node-opcua-convert-nodeset-to-javascript 2.178.0 → 2.180.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.d.ts +4 -4
- package/dist/_dataType.js +33 -14
- package/dist/_dataType.js.map +1 -1
- package/dist/convert_namespace_to_typescript.d.ts +2 -2
- package/dist/convert_namespace_to_typescript.js +50 -52
- package/dist/convert_namespace_to_typescript.js.map +1 -1
- package/dist/convert_to_typescript.d.ts +16 -8
- package/dist/convert_to_typescript.js +122 -90
- package/dist/convert_to_typescript.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.js +4 -3
- package/dist/main.js.map +1 -1
- package/dist/private/cache.d.ts +4 -4
- package/dist/private/cache.js +16 -11
- package/dist/private/cache.js.map +1 -1
- package/dist/private/fs_retry.js +3 -1
- package/dist/private/fs_retry.js.map +1 -1
- package/dist/private/get_corresponding_data_type.d.ts +4 -4
- package/dist/private/get_corresponding_data_type.js +9 -10
- package/dist/private/get_corresponding_data_type.js.map +1 -1
- package/dist/private/to_filename.js.map +1 -1
- package/dist/private/utils.d.ts +5 -5
- package/dist/private/utils.js +28 -10
- package/dist/private/utils.js.map +1 -1
- package/dist/remove_unused.js +36 -7
- package/dist/remove_unused.js.map +1 -1
- package/dist/update_parent_tsconfig.js +14 -17
- package/dist/update_parent_tsconfig.js.map +1 -1
- package/dist/walk_through.d.ts +1 -1
- package/dist/walk_through.js.map +1 -1
- package/package.json +17 -17
- package/source/_dataType.ts +47 -27
- package/source/convert_namespace_to_typescript.ts +20 -25
- package/source/convert_to_typescript.ts +166 -138
- package/source/index.ts +2 -2
- package/source/main.ts +4 -3
- package/source/private/cache.ts +23 -16
- package/source/private/fs_retry.ts +3 -1
- package/source/private/get_corresponding_data_type.ts +29 -26
- package/source/private/to_filename.ts +1 -1
- package/source/private/utils.ts +41 -19
- package/source/private-stuff.ts +0 -2
- package/source/remove_unused.ts +38 -8
- package/source/update_parent_tsconfig.ts +27 -16
- package/source/walk_through.ts +3 -3
package/source/private/cache.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import path from "path";
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { kebabCase } from "case-anything";
|
|
2
3
|
import assert from "node-opcua-assert";
|
|
3
4
|
import { AttributeIds, NodeClass, QualifiedName } from "node-opcua-data-model";
|
|
4
|
-
import { NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
5
|
-
import { IBasicSessionReadAsyncSimple } from "node-opcua-pseudo-session";
|
|
6
|
-
import { DataTypeDefinition, EnumDefinition } from "node-opcua-types";
|
|
7
|
-
import {
|
|
8
|
-
import { Options } from "../options";
|
|
5
|
+
import { type NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
6
|
+
import type { IBasicSessionReadAsyncSimple } from "node-opcua-pseudo-session";
|
|
7
|
+
import { type DataTypeDefinition, EnumDefinition } from "node-opcua-types";
|
|
8
|
+
import type { Options } from "../options";
|
|
9
9
|
import { getBrowseName, getDefinition } from "./utils";
|
|
10
10
|
|
|
11
11
|
export interface Import {
|
|
@@ -33,7 +33,7 @@ interface RequestedSymbol {
|
|
|
33
33
|
}[];
|
|
34
34
|
}
|
|
35
35
|
export function makeName2(name: string) {
|
|
36
|
-
return
|
|
36
|
+
return `U${name}`;
|
|
37
37
|
// if (name === "EUInformation") {
|
|
38
38
|
// return "EUInformation2";
|
|
39
39
|
// }
|
|
@@ -57,7 +57,7 @@ export class Cache implements CacheInterface {
|
|
|
57
57
|
"node-opcua-variant": {
|
|
58
58
|
DataType: 1,
|
|
59
59
|
Variant: 1,
|
|
60
|
-
VariantOptions: 1
|
|
60
|
+
VariantOptions: 1
|
|
61
61
|
},
|
|
62
62
|
"node-opcua-data-model": {
|
|
63
63
|
LocalizedText: 1,
|
|
@@ -120,10 +120,11 @@ export class Cache implements CacheInterface {
|
|
|
120
120
|
{
|
|
121
121
|
const sourceFolder = this.namespace[namespaceIndex]?.sourceFolder;
|
|
122
122
|
if (!sourceFolder) {
|
|
123
|
-
throw new Error(
|
|
123
|
+
throw new Error(`Cannot find namespace ${namespaceIndex}`);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
|
|
126
|
+
this.namespace[namespaceIndex].symbols = this.namespace[namespaceIndex].symbols || {};
|
|
127
|
+
const symbols = this.namespace[namespaceIndex].symbols;
|
|
127
128
|
symbols[typeName] = (symbols[typeName] || 0) + 1;
|
|
128
129
|
|
|
129
130
|
const ns = this.requestedSymbols.namespace[namespaceIndex] || { symbols: {} };
|
|
@@ -134,7 +135,8 @@ export class Cache implements CacheInterface {
|
|
|
134
135
|
if (!mainTypeName) {
|
|
135
136
|
mainTypeName = typeName;
|
|
136
137
|
}
|
|
137
|
-
|
|
138
|
+
ns.symbols[mainTypeName] = ns.symbols[mainTypeName] || { subSymbols: {} };
|
|
139
|
+
const subs = ns.symbols[mainTypeName];
|
|
138
140
|
subs.subSymbols[typeName] = (subs.subSymbols[typeName] || 0) + 1;
|
|
139
141
|
}
|
|
140
142
|
|
|
@@ -157,7 +159,10 @@ function getSourceFolderForNamespace(browseName: QualifiedName, options: Options
|
|
|
157
159
|
return { sourceFolder, module };
|
|
158
160
|
}
|
|
159
161
|
|
|
160
|
-
export async function referenceExtensionObject(
|
|
162
|
+
export async function referenceExtensionObject(
|
|
163
|
+
session: IBasicSessionReadAsyncSimple,
|
|
164
|
+
extensionObjectDataType: NodeId
|
|
165
|
+
): Promise<Import> {
|
|
161
166
|
const browseName = await getBrowseName(session, extensionObjectDataType);
|
|
162
167
|
const definition = await getDefinition(session, extensionObjectDataType);
|
|
163
168
|
const dataTypeNameImport = makeTypeNameNew(NodeClass.DataType, definition, browseName);
|
|
@@ -214,8 +219,10 @@ export function makeTypeNameNew(
|
|
|
214
219
|
suffix?: string
|
|
215
220
|
): Import {
|
|
216
221
|
assert(browseName && !!browseName.name, "expecting a class name here");
|
|
217
|
-
|
|
218
|
-
|
|
222
|
+
if (!browseName.name) {
|
|
223
|
+
throw new Error("expecting a class name here");
|
|
224
|
+
}
|
|
225
|
+
const typeName = browseName.name.toString();
|
|
219
226
|
if (typeName === "EUInformation") {
|
|
220
227
|
return makeBasicTypeImport("EUInformation");
|
|
221
228
|
} else if (typeName === "Enumeration") {
|
|
@@ -235,7 +242,7 @@ export function makeTypeNameNew(
|
|
|
235
242
|
case NodeClass.Object:
|
|
236
243
|
case NodeClass.VariableType:
|
|
237
244
|
case NodeClass.ObjectType:
|
|
238
|
-
name = `UA${typeName.replace(/Type$/, "")}
|
|
245
|
+
name = `UA${typeName.replace(/Type$/, "")}${suffix || ""}`;
|
|
239
246
|
break;
|
|
240
247
|
case NodeClass.DataType:
|
|
241
248
|
if (definition instanceof EnumDefinition) {
|
|
@@ -246,7 +253,7 @@ export function makeTypeNameNew(
|
|
|
246
253
|
break;
|
|
247
254
|
}
|
|
248
255
|
if (name === "") {
|
|
249
|
-
throw new Error(
|
|
256
|
+
throw new Error(`Internal Error ${NodeClass[nodeClass]} ${typeName}browseName = ${browseName.toString()}`);
|
|
250
257
|
}
|
|
251
258
|
return { name, module: name, namespace: browseName.namespaceIndex };
|
|
252
259
|
}
|
|
@@ -22,7 +22,9 @@ export function retryOnTransientWrite<T>(write: () => T, attempts = 6): T {
|
|
|
22
22
|
} catch (err) {
|
|
23
23
|
if (!isTransientWriteError(err) || i === attempts - 1) throw err;
|
|
24
24
|
const until = Date.now() + 50 * (i + 1);
|
|
25
|
-
while (Date.now() < until) {
|
|
25
|
+
while (Date.now() < until) {
|
|
26
|
+
/* spin */
|
|
27
|
+
}
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
2
|
-
import { IBasicSessionBrowseAsyncSimple, IBasicSessionReadAsyncSimple } from "node-opcua-pseudo-session";
|
|
1
|
+
import type { NodeId } from "node-opcua-nodeid";
|
|
2
|
+
import type { IBasicSessionBrowseAsyncSimple, IBasicSessionReadAsyncSimple } from "node-opcua-pseudo-session";
|
|
3
3
|
import { DataType } from "node-opcua-variant";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import type { Cache } from "./cache";
|
|
5
|
+
import { type Import, referenceEnumeration, referenceExtensionObject } from "./cache";
|
|
6
|
+
import { _convertNodeIdToDataTypeAsync, getValueRank } from "./utils";
|
|
7
7
|
|
|
8
8
|
export async function getCorrespondingJavascriptType2(
|
|
9
9
|
session: IBasicSessionReadAsyncSimple & IBasicSessionBrowseAsyncSimple,
|
|
@@ -11,12 +11,17 @@ 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 { dataType, jtype, dataTypeCombination, type} = await getCorrespondingJavascriptType(
|
|
14
|
+
): Promise<{ dataType: DataType; jtype: string; dataTypeCombination?: string; type: "enum" | "basic" | "genericNumber" }> {
|
|
15
|
+
const { dataType, jtype, dataTypeCombination, type } = await getCorrespondingJavascriptType(
|
|
16
|
+
session,
|
|
17
|
+
dataTypeNodeId,
|
|
18
|
+
cache,
|
|
19
|
+
importCollect
|
|
20
|
+
);
|
|
16
21
|
const valueRank = await getValueRank(session, nodeId);
|
|
17
22
|
let jtype2 = "";
|
|
18
23
|
if (valueRank >= 0) {
|
|
19
|
-
jtype2 = jtype
|
|
24
|
+
jtype2 = `${jtype}[]`;
|
|
20
25
|
} else if (valueRank === -1) {
|
|
21
26
|
jtype2 = jtype;
|
|
22
27
|
} else if (valueRank === -2) {
|
|
@@ -26,50 +31,48 @@ export async function getCorrespondingJavascriptType2(
|
|
|
26
31
|
// ScalarOrOneDimension (-3): The value can be a scalar or a one dimensional array.
|
|
27
32
|
jtype2 = `(${jtype} | ${jtype}[])`;
|
|
28
33
|
} else {
|
|
29
|
-
throw new Error(
|
|
34
|
+
throw new Error(`Invalid valueRank ${valueRank}`);
|
|
30
35
|
}
|
|
31
36
|
return { dataType: dataType, jtype: jtype2, dataTypeCombination, type };
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
// eslint-disable-next-line complexity
|
|
35
39
|
export async function getCorrespondingJavascriptType(
|
|
36
40
|
session: IBasicSessionReadAsyncSimple & IBasicSessionBrowseAsyncSimple,
|
|
37
41
|
dataTypeNodeId: NodeId,
|
|
38
42
|
cache: Cache,
|
|
39
43
|
importCollect?: (t: Import) => void
|
|
40
|
-
): Promise<{
|
|
41
|
-
enumerationType?: string;
|
|
42
|
-
dataType: DataType;
|
|
43
|
-
jtype: string
|
|
44
|
-
type: "enum" | "basic" | "genericNumber"
|
|
45
|
-
dataTypeCombination?: string
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
): Promise<{
|
|
45
|
+
enumerationType?: string;
|
|
46
|
+
dataType: DataType;
|
|
47
|
+
jtype: string;
|
|
48
|
+
type: "enum" | "basic" | "genericNumber";
|
|
49
|
+
dataTypeCombination?: string;
|
|
50
|
+
}> {
|
|
48
51
|
const info = await _convertNodeIdToDataTypeAsync(session, dataTypeNodeId);
|
|
49
52
|
const { type } = info;
|
|
50
53
|
|
|
51
|
-
if (type
|
|
54
|
+
if (type === "enum" && info.enumerationType) {
|
|
52
55
|
// we have a enmeration name here
|
|
53
56
|
const jtypeImport = await referenceEnumeration(session, dataTypeNodeId);
|
|
54
57
|
const jtype = jtypeImport.name;
|
|
55
|
-
importCollect
|
|
58
|
+
importCollect?.(jtypeImport);
|
|
56
59
|
return { dataType: info.dataType, jtype, type };
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
if (type
|
|
62
|
+
if (type === "basic" && info.dataType === DataType.ExtensionObject) {
|
|
60
63
|
const jtypeImport = await referenceExtensionObject(session, dataTypeNodeId);
|
|
61
64
|
const jtype = jtypeImport.name;
|
|
62
|
-
importCollect
|
|
65
|
+
importCollect?.(jtypeImport);
|
|
63
66
|
return { dataType: info.dataType, jtype, type };
|
|
64
67
|
}
|
|
65
68
|
const referenceBasicType = (name: string): string => {
|
|
66
69
|
const t = { name, namespace: -1, module: "BasicType" };
|
|
67
|
-
importCollect
|
|
70
|
+
importCollect?.(t);
|
|
68
71
|
cache.ensureImported(t);
|
|
69
72
|
return t.name;
|
|
70
73
|
};
|
|
71
|
-
if (type
|
|
72
|
-
const { dataTypeCombination } = info;
|
|
74
|
+
if (type === "genericNumber") {
|
|
75
|
+
const { dataTypeCombination } = info;
|
|
73
76
|
return { dataType: DataType.Variant, jtype: "number", type, dataTypeCombination };
|
|
74
77
|
} else {
|
|
75
78
|
const { dataType } = info;
|
|
@@ -125,7 +128,7 @@ export async function getCorrespondingJavascriptType(
|
|
|
125
128
|
case DataType.XmlElement:
|
|
126
129
|
return { dataType, jtype: referenceBasicType("String"), type };
|
|
127
130
|
default:
|
|
128
|
-
throw new Error(
|
|
131
|
+
throw new Error(`Unsupported ${dataType} ${DataType[dataType]}`);
|
|
129
132
|
}
|
|
130
133
|
}
|
|
131
134
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { snakeCase } from "case-anything";
|
|
2
2
|
|
|
3
3
|
export function toFilename(str: string): string {
|
|
4
|
-
str = str.replace(/^DT/,"dt_").replace(/^UA/,"ua_").replace(/^Enum/,"enum_");
|
|
4
|
+
str = str.replace(/^DT/, "dt_").replace(/^UA/, "ua_").replace(/^Enum/, "enum_");
|
|
5
5
|
return snakeCase(str);
|
|
6
6
|
}
|
package/source/private/utils.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { INodeId, NodeId, NodeIdType, resolveNodeId } from "node-opcua-nodeid";
|
|
1
|
+
import type { ModellingRuleType } from "node-opcua-address-space-base";
|
|
3
2
|
import { DataTypeIds } from "node-opcua-constants";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { AttributeIds, BrowseDirection, type LocalizedText, NodeClass, NodeClassMask, QualifiedName } from "node-opcua-data-model";
|
|
4
|
+
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
|
|
5
|
+
import { type INodeId, type NodeId, NodeIdType, resolveNodeId } from "node-opcua-nodeid";
|
|
6
|
+
import type { IBasicSessionBrowseAsyncSimple, IBasicSessionReadAsyncSimple } from "node-opcua-pseudo-session";
|
|
7
|
+
import { type BrowseResult, type DataTypeDefinition, ReferenceDescription } from "node-opcua-types";
|
|
7
8
|
import { DataType } from "node-opcua-variant";
|
|
8
|
-
import { make_debugLog } from "node-opcua-debug";
|
|
9
9
|
|
|
10
10
|
const debugLog = make_debugLog(__filename);
|
|
11
|
+
const doDebug = checkDebugFlag(__filename);
|
|
11
12
|
|
|
12
13
|
export async function getDefinition(session: IBasicSessionReadAsyncSimple, nodeId: NodeId): Promise<DataTypeDefinition | null> {
|
|
13
14
|
const dataValue = await session.read({ nodeId, attributeId: AttributeIds.DataTypeDefinition });
|
|
@@ -69,7 +70,11 @@ export async function getModellingRule(session: IBasicSessionBrowseAsyncSimple,
|
|
|
69
70
|
if (!browseResult.references || browseResult.references.length === 0) {
|
|
70
71
|
return null;
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
+
const modellingRuleName = browseResult.references[0].browseName.name;
|
|
74
|
+
if (!modellingRuleName) {
|
|
75
|
+
throw new Error(`HasModellingRule reference for ${nodeId.toString()} has no browseName`);
|
|
76
|
+
}
|
|
77
|
+
return modellingRuleName as ModellingRuleType;
|
|
73
78
|
}
|
|
74
79
|
export async function isExtensionObject(session: IBasicSessionBrowseAsyncSimple, nodeId: NodeId): Promise<boolean> {
|
|
75
80
|
const n = nodeId as INodeId;
|
|
@@ -80,7 +85,10 @@ export async function isExtensionObject(session: IBasicSessionBrowseAsyncSimple,
|
|
|
80
85
|
return false;
|
|
81
86
|
}
|
|
82
87
|
const r = await getSubtypeNodeIdIfAny(session, nodeId);
|
|
83
|
-
|
|
88
|
+
if (!r) {
|
|
89
|
+
throw new Error(`cannot find SuperType of ${nodeId.toString()}`);
|
|
90
|
+
}
|
|
91
|
+
return await isExtensionObject(session, r.nodeId);
|
|
84
92
|
}
|
|
85
93
|
|
|
86
94
|
export async function isEnumeration(session: IBasicSessionBrowseAsyncSimple, nodeId: NodeId): Promise<boolean> {
|
|
@@ -92,7 +100,10 @@ export async function isEnumeration(session: IBasicSessionBrowseAsyncSimple, nod
|
|
|
92
100
|
return false;
|
|
93
101
|
}
|
|
94
102
|
const r = await getSubtypeNodeIdIfAny(session, nodeId);
|
|
95
|
-
|
|
103
|
+
if (!r) {
|
|
104
|
+
throw new Error(`cannot find SuperType of ${nodeId.toString()}`);
|
|
105
|
+
}
|
|
106
|
+
return await isEnumeration(session, r.nodeId);
|
|
96
107
|
}
|
|
97
108
|
|
|
98
109
|
export async function extractBasicDataType(session: IBasicSessionBrowseAsyncSimple, dataTypeNodeId: NodeId): Promise<DataType> {
|
|
@@ -101,10 +112,16 @@ export async function extractBasicDataType(session: IBasicSessionBrowseAsyncSimp
|
|
|
101
112
|
return dataTypeNodeId.value as DataType;
|
|
102
113
|
}
|
|
103
114
|
const r = await getSubtypeNodeIdIfAny(session, dataTypeNodeId);
|
|
104
|
-
|
|
115
|
+
if (!r) {
|
|
116
|
+
throw new Error(`cannot find SuperType of ${dataTypeNodeId.toString()}`);
|
|
117
|
+
}
|
|
118
|
+
return await extractBasicDataType(session, r.nodeId);
|
|
105
119
|
}
|
|
106
120
|
|
|
107
|
-
export async function getSubtypeNodeIdIfAny(
|
|
121
|
+
export async function getSubtypeNodeIdIfAny(
|
|
122
|
+
session: IBasicSessionBrowseAsyncSimple,
|
|
123
|
+
nodeId: NodeId
|
|
124
|
+
): Promise<ReferenceDescription | null> {
|
|
108
125
|
if (nodeId.isEmpty()) {
|
|
109
126
|
return null;
|
|
110
127
|
}
|
|
@@ -164,7 +181,8 @@ export async function getTypeDefinition(session: IBasicSessionBrowseAsyncSimple,
|
|
|
164
181
|
resultMask: 0xffff
|
|
165
182
|
});
|
|
166
183
|
if (!browseResult.references || browseResult.references.length === 0) {
|
|
167
|
-
|
|
184
|
+
// c8 ignore next
|
|
185
|
+
doDebug && debugLog("no subtype", nodeId.toString());
|
|
168
186
|
throw new Error("No subtype");
|
|
169
187
|
}
|
|
170
188
|
return browseResult.references[0];
|
|
@@ -212,7 +230,8 @@ export async function _convertNodeIdToDataTypeAsync(
|
|
|
212
230
|
if (dataTypeId.namespace === 0 && dataTypeId.value === DataTypeIds.Number) {
|
|
213
231
|
return {
|
|
214
232
|
type: "genericNumber",
|
|
215
|
-
dataTypeCombination:
|
|
233
|
+
dataTypeCombination:
|
|
234
|
+
"DataType.Float | DataType.Double | " +
|
|
216
235
|
"DataType.UInt64 | DataType.UInt32 | DataType.UInt16 | DataType.SByte | " +
|
|
217
236
|
"DataType.Int64 | DataType.Int32 | DataType.Int16 | DataType.Byte"
|
|
218
237
|
};
|
|
@@ -245,19 +264,22 @@ export async function _convertNodeIdToDataTypeAsync(
|
|
|
245
264
|
referenceTypeId: resolveNodeId("HasSubtype"),
|
|
246
265
|
resultMask: 0xff
|
|
247
266
|
};
|
|
248
|
-
// tslint:disable:no-shadowed-variable
|
|
249
267
|
const browseResult = await session.browse(nodeToBrowse);
|
|
250
268
|
|
|
251
|
-
const references = browseResult
|
|
269
|
+
const references = browseResult?.references;
|
|
252
270
|
|
|
253
|
-
if (
|
|
254
|
-
throw new Error(
|
|
271
|
+
if (references?.length !== 1) {
|
|
272
|
+
throw new Error(`cannot find SuperType of ${dataTypeName.toString()}`);
|
|
255
273
|
}
|
|
256
274
|
const nodeId = references[0].nodeId;
|
|
257
275
|
|
|
258
276
|
const info = await _convertNodeIdToDataTypeAsync(session, nodeId);
|
|
259
|
-
if (info.type
|
|
260
|
-
|
|
277
|
+
if (info.type === "enum" && info.enumerationId) {
|
|
278
|
+
const enumerationType = dataTypeName.name;
|
|
279
|
+
if (!enumerationType) {
|
|
280
|
+
throw new Error(`cannot find name for enumeration dataType ${dataTypeId.toString()}`);
|
|
281
|
+
}
|
|
282
|
+
return { ...info, enumerationId: dataTypeId, enumerationType };
|
|
261
283
|
}
|
|
262
284
|
return info;
|
|
263
285
|
}
|
package/source/private-stuff.ts
CHANGED
package/source/remove_unused.ts
CHANGED
|
@@ -9,11 +9,37 @@ import { retryOnTransientWrite } from "./private/fs_retry";
|
|
|
9
9
|
const dryRun = false;
|
|
10
10
|
|
|
11
11
|
const NODE_BUILTINS = new Set([
|
|
12
|
-
"assert",
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
12
|
+
"assert",
|
|
13
|
+
"async_hooks",
|
|
14
|
+
"buffer",
|
|
15
|
+
"child_process",
|
|
16
|
+
"cluster",
|
|
17
|
+
"console",
|
|
18
|
+
"crypto",
|
|
19
|
+
"dgram",
|
|
20
|
+
"dns",
|
|
21
|
+
"events",
|
|
22
|
+
"fs",
|
|
23
|
+
"http",
|
|
24
|
+
"http2",
|
|
25
|
+
"https",
|
|
26
|
+
"net",
|
|
27
|
+
"os",
|
|
28
|
+
"path",
|
|
29
|
+
"perf_hooks",
|
|
30
|
+
"process",
|
|
31
|
+
"querystring",
|
|
32
|
+
"readline",
|
|
33
|
+
"stream",
|
|
34
|
+
"string_decoder",
|
|
35
|
+
"tls",
|
|
36
|
+
"tty",
|
|
37
|
+
"url",
|
|
38
|
+
"util",
|
|
39
|
+
"v8",
|
|
40
|
+
"vm",
|
|
41
|
+
"worker_threads",
|
|
42
|
+
"zlib"
|
|
17
43
|
]);
|
|
18
44
|
|
|
19
45
|
function importGroup(spec: string): number {
|
|
@@ -122,7 +148,8 @@ function regroupImports(file: SourceFile) {
|
|
|
122
148
|
}
|
|
123
149
|
}
|
|
124
150
|
|
|
125
|
-
const BIOME_IGNORE_EMPTY_INTERFACE =
|
|
151
|
+
const BIOME_IGNORE_EMPTY_INTERFACE =
|
|
152
|
+
"// biome-ignore lint/suspicious/noEmptyInterface: forward-compatible placeholder for OPC-UA generated types";
|
|
126
153
|
|
|
127
154
|
function tidyEmptyInterfaces(file: SourceFile) {
|
|
128
155
|
// Two complaints to resolve:
|
|
@@ -152,7 +179,10 @@ function tidyEmptyInterfaces(file: SourceFile) {
|
|
|
152
179
|
if (iface.getMembers().length !== 0) continue;
|
|
153
180
|
// Rule only fires when there's no extends clause.
|
|
154
181
|
if (iface.getExtends().length !== 0) continue;
|
|
155
|
-
const leading = iface
|
|
182
|
+
const leading = iface
|
|
183
|
+
.getLeadingCommentRanges()
|
|
184
|
+
.map((c) => c.getText())
|
|
185
|
+
.join("\n");
|
|
156
186
|
if (leading.includes("biome-ignore lint/suspicious/noEmptyInterface")) continue;
|
|
157
187
|
positions.push(iface.getStart());
|
|
158
188
|
}
|
|
@@ -232,7 +262,7 @@ export async function cleanUpTypescriptModule(moduleFolder: string) {
|
|
|
232
262
|
const project = new Project({
|
|
233
263
|
skipAddingFilesFromTsConfig: true,
|
|
234
264
|
skipFileDependencyResolution: true,
|
|
235
|
-
skipLoadingLibFiles: true
|
|
265
|
+
skipLoadingLibFiles: true
|
|
236
266
|
});
|
|
237
267
|
|
|
238
268
|
const dirFiles = await fs.promises.readdir(sourceFolder);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// Purpose of this script is to help ensure that "references" array in packages/tsconfig.json
|
|
2
2
|
// stays up-to-date with nodeset package list.
|
|
3
3
|
|
|
4
|
-
import { existsSync, promises as fsPromises } from
|
|
4
|
+
import { existsSync, promises as fsPromises } from "node:fs";
|
|
5
|
+
|
|
5
6
|
const { readFile, writeFile } = fsPromises;
|
|
6
|
-
|
|
7
|
+
|
|
8
|
+
import path from "node:path";
|
|
7
9
|
// Uncomment the following to get __dirname equivalent when compiling to ESM
|
|
8
10
|
//import { fileURLToPath } from 'url';
|
|
9
11
|
//const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -11,20 +13,23 @@ import path from 'path';
|
|
|
11
13
|
import { nodesetCatalog } from "node-opcua-nodesets";
|
|
12
14
|
|
|
13
15
|
export async function updateParentTSConfig() {
|
|
14
|
-
const packagesFolder = path.join(__dirname,
|
|
15
|
-
const parentTSConfigFile = path.join(packagesFolder,
|
|
16
|
+
const packagesFolder = path.join(__dirname, "..", "..");
|
|
17
|
+
const parentTSConfigFile = path.join(packagesFolder, "tsconfig.json");
|
|
16
18
|
console.log(`Updating parent tsconfig.json file: ${parentTSConfigFile}`);
|
|
17
|
-
const content = await readFile(parentTSConfigFile,
|
|
19
|
+
const content = await readFile(parentTSConfigFile, "utf8");
|
|
18
20
|
// Strip out comments to avoid JSON parsing error
|
|
19
|
-
const contentWithoutComments = content.replace(/\/\*.+?\*\//g,
|
|
20
|
-
.replace(/\/\/.+?$/g, '');
|
|
21
|
+
const contentWithoutComments = content.replace(/\/\*.+?\*\//g, "").replace(/\/\/.+?$/g, "");
|
|
21
22
|
// TODO: Preserve comments automatically
|
|
22
|
-
|
|
23
|
+
interface TSConfigJson {
|
|
24
|
+
references: { path: string }[];
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
let parentTSConfig: TSConfigJson;
|
|
23
28
|
try {
|
|
24
29
|
parentTSConfig = JSON.parse(contentWithoutComments);
|
|
25
30
|
} catch (err) {
|
|
26
31
|
console.log(`Error parsing JSON from ${parentTSConfigFile}:`, err);
|
|
27
|
-
console.log(
|
|
32
|
+
console.log("Content without comments:", contentWithoutComments);
|
|
28
33
|
|
|
29
34
|
throw err;
|
|
30
35
|
}
|
|
@@ -44,8 +49,12 @@ export async function updateParentTSConfig() {
|
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
function compareByPath(a: TSConfigReference, b: TSConfigReference) {
|
|
47
|
-
if (a.path < b.path) {
|
|
48
|
-
|
|
52
|
+
if (a.path < b.path) {
|
|
53
|
+
return -1;
|
|
54
|
+
}
|
|
55
|
+
if (a.path > b.path) {
|
|
56
|
+
return 1;
|
|
57
|
+
}
|
|
49
58
|
return 0;
|
|
50
59
|
}
|
|
51
60
|
|
|
@@ -54,11 +63,13 @@ export async function updateParentTSConfig() {
|
|
|
54
63
|
parentTSConfig.references.sort(compareByPath);
|
|
55
64
|
// Maintain the compact style `{ "path": "node-opcua-X" }` in references section
|
|
56
65
|
// Also add the comment about Istanbul back
|
|
57
|
-
const newJSON = JSON.stringify(parentTSConfig, null, " ")
|
|
58
|
-
.replace(
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
const newJSON = `${JSON.stringify(parentTSConfig, null, " ")
|
|
67
|
+
.replace(
|
|
68
|
+
'"removeComments": false',
|
|
69
|
+
'"removeComments": false /* to prevent Istanbul ignore statements in comments from disappearing */'
|
|
70
|
+
)
|
|
71
|
+
.replace(/{\s*"path":\s*"([^"]+)"\s*}/g, '{ "path": "$1" }')}\n`;
|
|
61
72
|
//console.log('Writing updated tsconfig.json file:', newJSON);
|
|
62
|
-
await writeFile(parentTSConfigFile, newJSON,
|
|
73
|
+
await writeFile(parentTSConfigFile, newJSON, "utf8");
|
|
63
74
|
}
|
|
64
75
|
}
|
package/source/walk_through.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AttributeIds, BrowseDirection, NodeClass, QualifiedName } from "node-opcua-data-model";
|
|
2
|
-
import { ExpandedNodeId, NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
3
|
-
import { IBasicSessionAsync } from "node-opcua-pseudo-session";
|
|
1
|
+
import { AttributeIds, BrowseDirection, type NodeClass, type QualifiedName } from "node-opcua-data-model";
|
|
2
|
+
import { type ExpandedNodeId, type NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
3
|
+
import type { IBasicSessionAsync } from "node-opcua-pseudo-session";
|
|
4
4
|
import { ReferenceDescription } from "node-opcua-types";
|
|
5
5
|
|
|
6
6
|
export interface ReferenceDescriptionEx extends ReferenceDescription {
|