node-opcua-convert-nodeset-to-javascript 2.178.0 → 2.179.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 (47) hide show
  1. package/dist/_dataType.d.ts +4 -4
  2. package/dist/_dataType.js +33 -14
  3. package/dist/_dataType.js.map +1 -1
  4. package/dist/convert_namespace_to_typescript.d.ts +2 -2
  5. package/dist/convert_namespace_to_typescript.js +50 -52
  6. package/dist/convert_namespace_to_typescript.js.map +1 -1
  7. package/dist/convert_to_typescript.d.ts +16 -8
  8. package/dist/convert_to_typescript.js +122 -90
  9. package/dist/convert_to_typescript.js.map +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/main.js +4 -3
  14. package/dist/main.js.map +1 -1
  15. package/dist/private/cache.d.ts +4 -4
  16. package/dist/private/cache.js +16 -11
  17. package/dist/private/cache.js.map +1 -1
  18. package/dist/private/fs_retry.js +3 -1
  19. package/dist/private/fs_retry.js.map +1 -1
  20. package/dist/private/get_corresponding_data_type.d.ts +4 -4
  21. package/dist/private/get_corresponding_data_type.js +9 -10
  22. package/dist/private/get_corresponding_data_type.js.map +1 -1
  23. package/dist/private/to_filename.js.map +1 -1
  24. package/dist/private/utils.d.ts +5 -5
  25. package/dist/private/utils.js +28 -10
  26. package/dist/private/utils.js.map +1 -1
  27. package/dist/remove_unused.js +36 -7
  28. package/dist/remove_unused.js.map +1 -1
  29. package/dist/update_parent_tsconfig.js +14 -17
  30. package/dist/update_parent_tsconfig.js.map +1 -1
  31. package/dist/walk_through.d.ts +1 -1
  32. package/dist/walk_through.js.map +1 -1
  33. package/package.json +17 -17
  34. package/source/_dataType.ts +47 -27
  35. package/source/convert_namespace_to_typescript.ts +20 -25
  36. package/source/convert_to_typescript.ts +166 -138
  37. package/source/index.ts +2 -2
  38. package/source/main.ts +4 -3
  39. package/source/private/cache.ts +23 -16
  40. package/source/private/fs_retry.ts +3 -1
  41. package/source/private/get_corresponding_data_type.ts +29 -26
  42. package/source/private/to_filename.ts +1 -1
  43. package/source/private/utils.ts +41 -19
  44. package/source/private-stuff.ts +0 -2
  45. package/source/remove_unused.ts +38 -8
  46. package/source/update_parent_tsconfig.ts +27 -16
  47. package/source/walk_through.ts +3 -3
@@ -6,36 +6,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  };
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.updateParentTSConfig = updateParentTSConfig;
9
- const fs_1 = require("fs");
10
- const { readFile, writeFile } = fs_1.promises;
11
- const path_1 = __importDefault(require("path"));
9
+ const node_fs_1 = require("node:fs");
10
+ const { readFile, writeFile } = node_fs_1.promises;
11
+ const node_path_1 = __importDefault(require("node:path"));
12
12
  // Uncomment the following to get __dirname equivalent when compiling to ESM
13
13
  //import { fileURLToPath } from 'url';
14
14
  //const __dirname = path.dirname(fileURLToPath(import.meta.url));
15
15
  const node_opcua_nodesets_1 = require("node-opcua-nodesets");
16
16
  async function updateParentTSConfig() {
17
- const packagesFolder = path_1.default.join(__dirname, '..', '..');
18
- const parentTSConfigFile = path_1.default.join(packagesFolder, 'tsconfig.json');
17
+ const packagesFolder = node_path_1.default.join(__dirname, "..", "..");
18
+ const parentTSConfigFile = node_path_1.default.join(packagesFolder, "tsconfig.json");
19
19
  console.log(`Updating parent tsconfig.json file: ${parentTSConfigFile}`);
20
- const content = await readFile(parentTSConfigFile, 'utf8');
20
+ const content = await readFile(parentTSConfigFile, "utf8");
21
21
  // Strip out comments to avoid JSON parsing error
22
- const contentWithoutComments = content.replace(/\/\*.+?\*\//g, '')
23
- .replace(/\/\/.+?$/g, '');
24
- // TODO: Preserve comments automatically
25
- let parentTSConfig = "";
22
+ const contentWithoutComments = content.replace(/\/\*.+?\*\//g, "").replace(/\/\/.+?$/g, "");
23
+ let parentTSConfig;
26
24
  try {
27
25
  parentTSConfig = JSON.parse(contentWithoutComments);
28
26
  }
29
27
  catch (err) {
30
28
  console.log(`Error parsing JSON from ${parentTSConfigFile}:`, err);
31
- console.log('Content without comments:', contentWithoutComments);
29
+ console.log("Content without comments:", contentWithoutComments);
32
30
  throw err;
33
31
  }
34
32
  const unlistedReferences = [];
35
33
  for (const meta of node_opcua_nodesets_1.nodesetCatalog) {
36
34
  const packageName = `node-opcua-nodeset-${meta.packageName}`;
37
- const nodesetPackageFolder = path_1.default.join(packagesFolder, packageName);
38
- if (!(0, fs_1.existsSync)(nodesetPackageFolder)) {
35
+ const nodesetPackageFolder = node_path_1.default.join(packagesFolder, packageName);
36
+ if (!(0, node_fs_1.existsSync)(nodesetPackageFolder)) {
39
37
  console.log(`Ignoring ${meta.packageName} since package folder does not exist (${nodesetPackageFolder})`);
40
38
  continue;
41
39
  }
@@ -58,12 +56,11 @@ async function updateParentTSConfig() {
58
56
  parentTSConfig.references.sort(compareByPath);
59
57
  // Maintain the compact style `{ "path": "node-opcua-X" }` in references section
60
58
  // Also add the comment about Istanbul back
61
- const newJSON = JSON.stringify(parentTSConfig, null, " ")
59
+ const newJSON = `${JSON.stringify(parentTSConfig, null, " ")
62
60
  .replace('"removeComments": false', '"removeComments": false /* to prevent Istanbul ignore statements in comments from disappearing */')
63
- .replace(/{\s*"path":\s*"([^"]+)"\s*}/g, '{ "path": "$1" }')
64
- + '\n';
61
+ .replace(/{\s*"path":\s*"([^"]+)"\s*}/g, '{ "path": "$1" }')}\n`;
65
62
  //console.log('Writing updated tsconfig.json file:', newJSON);
66
- await writeFile(parentTSConfigFile, newJSON, 'utf8');
63
+ await writeFile(parentTSConfigFile, newJSON, "utf8");
67
64
  }
68
65
  }
69
66
  //# sourceMappingURL=update_parent_tsconfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"update_parent_tsconfig.js","sourceRoot":"","sources":["../source/update_parent_tsconfig.ts"],"names":[],"mappings":";AAAA,6FAA6F;AAC7F,8CAA8C;;;;;AAW9C,oDAmDC;AA5DD,2BAAwD;AACxD,MAAM,EAAE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AE,kBAAkB,CAAC,IAAI,CAAC;QACrE,8DAA8D;QAC9D,MAAM,SAAS,CAAC,kBAAkB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;AACL,CAAC"}
@@ -1,4 +1,4 @@
1
- import { IBasicSessionAsync } from "node-opcua-pseudo-session";
1
+ import type { IBasicSessionAsync } from "node-opcua-pseudo-session";
2
2
  import { ReferenceDescription } from "node-opcua-types";
3
3
  export interface ReferenceDescriptionEx extends ReferenceDescription {
4
4
  parent: ReferenceDescriptionEx;
@@ -1 +1 @@
1
- {"version":3,"file":"walk_through.js","sourceRoot":"","sources":["../source/walk_through.ts"],"names":[],"mappings":";;AAqDA,8DAGC;AACD,oDAGC;AAED,8DAGC;AACD,wDAGC;AACD,4DAGC;AAzED,iEAAgG;AAChG,yDAA0E;AAE1E,uDAAwD;AAQxD,KAAK,UAAU,iBAAiB,CAC5B,OAA2B,EAC3B,MAAc,EACd,OAAqB,EACrB,KAAc,EACd,MAA6B;IAE7B,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC;IAEnB,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;YAClC,EAAE,MAAM,EAAE,WAAW,EAAE,oCAAY,CAAC,UAAU,EAAE;YAChD,EAAE,MAAM,EAAE,WAAW,EAAE,oCAAY,CAAC,SAAS,EAAE;SAClD,CAAC,CAAC;QACH,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAsB,CAAC;QAC9D,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAkB,CAAC;QACzD,MAAM,GAAG,IAAI,uCAAoB,CAAC;YAC9B,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,MAAwB;YAChC,UAAU;YACV,SAAS;YACT,eAAe,EAAE,IAAA,iCAAa,EAAC,YAAY,CAAC;YAC5C,kBAAkB;SACrB,C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AAC;IACnE,MAAM,iBAAiB,CAAC,OAAO,EAAE,uBAAuB,EAAE,WAAW,CAAC,CAAC;AAC3E,CAAC;AACM,KAAK,UAAU,sBAAsB,CAAC,OAA2B,EAAE,WAAyB;IAC/F,MAAM,oBAAoB,GAAG,IAAA,iCAAa,EAAC,gBAAgB,CAAC,CAAC;IAC7D,MAAM,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,EAAE,WAAW,CAAC,CAAC;AACxE,CAAC;AACM,KAAK,UAAU,wBAAwB,CAAC,OAA2B,EAAE,WAAyB;IACjG,MAAM,oBAAoB,GAAG,IAAA,iCAAa,EAAC,kBAAkB,CAAC,CAAC;IAC/D,MAAM,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,EAAE,WAAW,CAAC,CAAC;AACxE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-convert-nodeset-to-javascript",
3
- "version": "2.178.0",
3
+ "version": "2.179.0",
4
4
  "description": "pure nodejs OPCUA SDK - module convert-nodeset-to-javascript",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -16,26 +16,26 @@
16
16
  "dependencies": {
17
17
  "case-anything": "1.1.5",
18
18
  "chalk": "4.1.2",
19
- "node-opcua-address-space": "2.178.0",
20
- "node-opcua-address-space-base": "2.178.0",
21
- "node-opcua-assert": "2.175.6",
22
- "node-opcua-constants": "2.176.0",
23
- "node-opcua-data-model": "2.177.0",
24
- "node-opcua-debug": "2.175.6",
25
- "node-opcua-nodeid": "2.177.0",
26
- "node-opcua-nodesets": "2.175.3",
27
- "node-opcua-pseudo-session": "2.178.0",
28
- "node-opcua-types": "2.177.0",
29
- "node-opcua-utils": "2.176.0",
30
- "node-opcua-variant": "2.177.0",
19
+ "node-opcua-address-space": "2.179.0",
20
+ "node-opcua-address-space-base": "2.179.0",
21
+ "node-opcua-assert": "2.179.0",
22
+ "node-opcua-constants": "2.179.0",
23
+ "node-opcua-data-model": "2.179.0",
24
+ "node-opcua-debug": "2.179.0",
25
+ "node-opcua-nodeid": "2.179.0",
26
+ "node-opcua-nodesets": "2.179.0",
27
+ "node-opcua-pseudo-session": "2.179.0",
28
+ "node-opcua-types": "2.179.0",
29
+ "node-opcua-utils": "2.179.0",
30
+ "node-opcua-variant": "2.179.0",
31
31
  "ts-morph": "28.0.0",
32
32
  "typescript": "5.9.3",
33
33
  "wordwrap": "^1.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "node-opcua-leak-detector": "2.175.6",
37
- "node-opcua-packet-analyzer": "2.177.0",
38
- "node-opcua-service-translate-browse-path": "2.177.0"
36
+ "node-opcua-leak-detector": "2.179.0",
37
+ "node-opcua-packet-analyzer": "2.179.0",
38
+ "node-opcua-service-translate-browse-path": "2.179.0"
39
39
  },
40
40
  "author": "Etienne Rossignon",
41
41
  "license": "MIT",
@@ -52,7 +52,7 @@
52
52
  "internet of things"
53
53
  ],
54
54
  "homepage": "http://node-opcua.github.io/",
55
- "gitHead": "d0e850e5f7df80e14ceb6d8e092e793472965301",
55
+ "gitHead": "c78c6ee424bae3c6e851fabd8e144390e2941f8a",
56
56
  "files": [
57
57
  "dist",
58
58
  "source"
@@ -1,34 +1,38 @@
1
1
  import { NodeClass } from "node-opcua-data-model";
2
- import { NodeId } from "node-opcua-nodeid";
3
- import { IBasicSessionBrowseAsyncSimple, IBasicSessionReadAsyncSimple } from "node-opcua-pseudo-session";
4
- import { EnumDefinition, StructureDefinition, StructureField } from "node-opcua-types";
2
+ import type { NodeId } from "node-opcua-nodeid";
3
+ import type { IBasicSessionBrowseAsyncSimple, IBasicSessionReadAsyncSimple } from "node-opcua-pseudo-session";
4
+ import { EnumDefinition, StructureDefinition, type StructureField } from "node-opcua-types";
5
5
  import { LineFile } from "node-opcua-utils";
6
6
  import { DataType } from "node-opcua-variant";
7
- import { Type } from "./convert_to_typescript";
7
+ import type { Type } from "./convert_to_typescript";
8
+ import { type Cache, makeName2 } from "./private/cache";
9
+ import { getCorrespondingJavascriptType } from "./private/get_corresponding_data_type";
8
10
  import {
9
- Import,
10
- getDescription,
11
- getDefinition,
12
11
  getBrowseName,
12
+ getDefinition,
13
+ getDescription,
13
14
  getIsAbstract,
14
- makeTypeNameNew,
15
- getSubtypeNodeId
15
+ getSubtypeNodeId,
16
+ type Import,
17
+ makeTypeNameNew
16
18
  } from "./private-stuff";
17
- import { Cache, makeName2 } from "./private/cache";
18
- import { getCorrespondingJavascriptType } from "./private/get_corresponding_data_type";
19
19
  import { f1, f2, quotifyIfNecessary, toComment, toJavascritPropertyName } from "./utils2";
20
20
 
21
- // eslint-disable-next-line max-statements, complexity
21
+ function requireFieldName(field: { name?: string | null }): string {
22
+ if (!field.name) {
23
+ throw new Error("field is expected to have a name");
24
+ }
25
+ return field.name;
26
+ }
27
+
22
28
  export async function _exportDataTypeToTypescript(
23
29
  session: IBasicSessionReadAsyncSimple & IBasicSessionBrowseAsyncSimple,
24
30
  nodeId: NodeId,
25
31
  cache: Cache,
26
32
  f?: LineFile
27
33
  ): Promise<{ type: Type; content: string; typeName: string }> {
28
- const importCollect: any = undefined;
29
34
  const referenceBasicType = (name: string): string => {
30
35
  const t = { name, namespace: -1, module: "BasicType" };
31
- importCollect && importCollect(t);
32
36
  cache.ensureImported(t);
33
37
  return t.name;
34
38
  };
@@ -53,6 +57,9 @@ export async function _exportDataTypeToTypescript(
53
57
  cache.ensureImported(baseInterfaceImport);
54
58
 
55
59
  const baseInterfaceName = baseInterfaceImport.name;
60
+ if (!browseName.name) {
61
+ throw new Error(`Expecting a browseName.name for node ${nodeId.toString()}`);
62
+ }
56
63
  // f.write(superType.toString());
57
64
  f.write(`/**`);
58
65
  if (description.text) {
@@ -63,7 +70,7 @@ export async function _exportDataTypeToTypescript(
63
70
  f.write(` * |-----------|${f2("-")}|`);
64
71
  f.write(` * | namespace |${f1(cache.namespace[nodeId.namespace].namespaceUri)}|`);
65
72
  f.write(` * | nodeClass |${f1(NodeClass[nodeClass])}|`);
66
- f.write(` * | name |${f1(browseName.name!.toString())}|`);
73
+ f.write(` * | name |${f1(browseName.name.toString())}|`);
67
74
  f.write(` * | isAbstract|${f1(isAbstract.toString())}|`);
68
75
  f.write(` */`);
69
76
 
@@ -71,23 +78,33 @@ export async function _exportDataTypeToTypescript(
71
78
  if (definition instanceof EnumDefinition) {
72
79
  type = "enum";
73
80
  f.write(`export enum ${interfaceName} {`);
74
- for (const field of definition.fields!) {
81
+ if (!definition.fields) {
82
+ throw new Error(`EnumDefinition is expected to have fields for ${interfaceName}`);
83
+ }
84
+ for (const field of definition.fields) {
75
85
  if (field.description.text) {
76
86
  f.write(` /**`);
77
87
  f.write(toComment(" * ", field.description.text || ""));
78
88
  f.write(` */`);
79
89
  }
80
- f.write(` ${quotifyIfNecessary(field.name!)} = ${field.value[1]},`);
90
+ f.write(` ${quotifyIfNecessary(requireFieldName(field))} = ${field.value[1]},`);
81
91
  }
82
92
  f.write(`}`);
83
93
  } else if (definition instanceof StructureDefinition) {
84
94
  if (baseInterfaceName === "DTUnion") {
85
95
  type = "structure";
86
- for (let i = 0; i < definition.fields!.length; i++) {
96
+ if (!definition.fields) {
97
+ throw new Error(`StructureDefinition (Union) is expected to have fields for ${interfaceName}`);
98
+ }
99
+ const unionFields = definition.fields;
100
+ for (let i = 0; i < unionFields.length; i++) {
87
101
  f.write(`export interface ${interfaceName}_${i} extends ${baseInterfaceName} {`);
88
- for (let j = 0; j < definition.fields!.length; j++) {
89
- const field = definition.fields![j];
90
- const fieldName = toJavascritPropertyName(field.name!, { ignoreConflictingName: false });
102
+ for (let j = 0; j < unionFields.length; j++) {
103
+ const field = unionFields[j];
104
+ if (!field) {
105
+ throw new Error(`StructureDefinition is expected to have a field at index ${j} for ${interfaceName}`);
106
+ }
107
+ const fieldName = toJavascritPropertyName(requireFieldName(field), { ignoreConflictingName: false });
91
108
  if (j === i) {
92
109
  await outputStructureField(f, field);
93
110
  } else {
@@ -97,13 +114,13 @@ export async function _exportDataTypeToTypescript(
97
114
  f.write(`}`);
98
115
  }
99
116
  f.write(`export type ${interfaceName} = `);
100
- for (let i = 0; i < definition.fields!.length; i++) {
117
+ for (let i = 0; i < unionFields.length; i++) {
101
118
  f.write(` | ${interfaceName}_${i}`);
102
119
  }
103
120
  f.write(` ;`);
104
121
  } else {
105
122
  type = "structure";
106
- if (!definition.fields!.length && interfaceName !== "DTStructure") {
123
+ if (!definition.fields?.length && interfaceName !== "DTStructure") {
107
124
  f.write(`export type ${interfaceName} = ${baseInterfaceName};`);
108
125
  } else {
109
126
  if (interfaceName === "DTStructure") {
@@ -111,7 +128,10 @@ export async function _exportDataTypeToTypescript(
111
128
  } else {
112
129
  f.write(`export interface ${interfaceName} extends ${baseInterfaceName} {`);
113
130
  }
114
- for (const field of definition.fields!) {
131
+ if (!definition.fields) {
132
+ throw new Error(`StructureDefinition is expected to have fields for ${interfaceName}`);
133
+ }
134
+ for (const field of definition.fields) {
115
135
  await outputStructureField(f, field);
116
136
  }
117
137
  f.write(`}`);
@@ -126,8 +146,8 @@ export async function _exportDataTypeToTypescript(
126
146
  // filter issue with UDTOpticalVerifierScanResult that has a decode:Uint32 conflicting with the ExtensionObject decode method
127
147
 
128
148
  const toAvoid = ["decode", "encode"];
129
- const collidingNames = definition
130
- .fields!.map((a) => toJavascritPropertyName(a.name!, { ignoreConflictingName: false }))
149
+ const collidingNames = definition.fields
150
+ ?.map((a) => toJavascritPropertyName(requireFieldName(a), { ignoreConflictingName: false }))
131
151
  .filter((d) => toAvoid.indexOf(d.toLowerCase()) !== -1);
132
152
 
133
153
  const adpatedIntefaceName =
@@ -147,7 +167,7 @@ export async function _exportDataTypeToTypescript(
147
167
  return { type, content: f.toString(), typeName: interfaceName };
148
168
 
149
169
  async function outputStructureField(f: LineFile, field: StructureField) {
150
- const fieldName = toJavascritPropertyName(field.name!, { ignoreConflictingName: false });
170
+ const fieldName = toJavascritPropertyName(requireFieldName(field), { ignoreConflictingName: false });
151
171
  // special case ! fieldName=
152
172
  if (field.description.text) {
153
173
  f.write(` /** ${field.description.text}*/`);
@@ -1,20 +1,23 @@
1
- /* eslint-disable max-statements */
2
- import path from "path";
3
- import fs from "fs";
4
-
5
- import { IBasicSessionAsync } from "node-opcua-pseudo-session";
1
+ import fs from "node:fs";
2
+ import path from "node:path";
6
3
  import { DataTypeIds } from "node-opcua-constants";
7
- import { ReferenceDescriptionEx, walkThroughDataTypes, walkThroughObjectTypes, walkThroughVariableTypes } from "./walk_through";
4
+ import type { IBasicSessionAsync } from "node-opcua-pseudo-session";
8
5
  import { convertTypeToTypescript } from "./convert_to_typescript";
6
+ import type { Options } from "./options";
9
7
  import { constructCache } from "./private/cache";
10
8
  import { writeFileSyncRetry } from "./private/fs_retry";
11
- import { Options } from "./options";
9
+ import {
10
+ type ReferenceDescriptionEx,
11
+ walkThroughDataTypes,
12
+ walkThroughObjectTypes,
13
+ walkThroughVariableTypes
14
+ } from "./walk_through";
12
15
 
13
16
  function findPackageJson(dependency: string, options: Options): string | undefined {
14
17
  const l = [...(options.lookupFolders || [])];
15
18
  l.push(path.join(__dirname, "../../"));
16
19
  for (const folder of l) {
17
- const d = path.join(folder, dependency + "/package.json");
20
+ const d = path.join(folder, `${dependency}/package.json`);
18
21
  if (!fs.existsSync(d)) {
19
22
  continue;
20
23
  }
@@ -36,16 +39,13 @@ function getPackageFolder(dependency: string, options: Options) {
36
39
  }
37
40
  const packageJson = path.join(packageoFolder, "package.json");
38
41
  if (!fs.existsSync(packageJson)) {
39
- fs.writeFileSync(packageJson, "{\n \"name\": \"" + dependency + "\"\n}");
42
+ fs.writeFileSync(packageJson, `{\n "name": "${dependency}"\n}`);
40
43
  }
41
44
  const sourceFolder = path.join(packageoFolder, "source");
42
45
  if (!fs.existsSync(sourceFolder)) {
43
46
  fs.mkdirSync(sourceFolder);
44
47
  }
45
48
  return packageJson;
46
-
47
-
48
- throw new Error("cannot find package.json for " + dependency);
49
49
  }
50
50
  function getPackageInfo(dependency: string, options: Options) {
51
51
  const d = getPackageFolder(dependency, options);
@@ -71,7 +71,7 @@ function getGeneratedPackageVersion(info: Info, options: Options): string {
71
71
  if (version) {
72
72
  return version;
73
73
  }
74
- } catch (err) {
74
+ } catch (_err) {
75
75
  // malformed package.json: fall through and seed a fresh version
76
76
  }
77
77
  }
@@ -139,11 +139,11 @@ export async function convertNamespaceTypeToTypescript(
139
139
  const infos: { [key: string]: Info } = {};
140
140
  // walk through all Types:
141
141
  const nodeVisitor = {
142
- async visit(reference: ReferenceDescriptionEx, level: number): Promise<void> {
142
+ async visit(reference: ReferenceDescriptionEx, _level: number): Promise<void> {
143
143
  if (reference.nodeId.namespace !== namespaceIndex) {
144
144
  return;
145
145
  }
146
- cache!.resetRequire();
146
+ cache?.resetRequire();
147
147
 
148
148
  if (reference.nodeId.namespace === 0 && reference.nodeId.value === DataTypeIds.Enumeration) {
149
149
  return; // ignore enumeration
@@ -152,7 +152,7 @@ export async function convertNamespaceTypeToTypescript(
152
152
  session,
153
153
  reference.nodeId,
154
154
  options,
155
- cache!
155
+ cache
156
156
  );
157
157
 
158
158
  if (type === "basic") {
@@ -170,9 +170,9 @@ export async function convertNamespaceTypeToTypescript(
170
170
  if (!fs.existsSync(sourceFolder)) {
171
171
  fs.mkdirSync(sourceFolder);
172
172
  }
173
- writeFileSyncRetry(path.join(sourceFolder, filename + ".ts"), content);
173
+ writeFileSyncRetry(path.join(sourceFolder, `${filename}.ts`), content);
174
174
  infos[module] = infos[module] || { folder, dependencies: [], module, files: [] };
175
- infos[module].files.push(filename + ".ts");
175
+ infos[module].files.push(`${filename}.ts`);
176
176
  infos[module].dependencies = [...new Set([...infos[module].dependencies, ...dependencies])];
177
177
  }
178
178
  };
@@ -293,8 +293,7 @@ async function _output_tsconfig_json(info: Info, options: Options): Promise<void
293
293
  return !!c.match(/node_modules/);
294
294
  }
295
295
  }
296
- async function _output_licence(info: Info, options: Options): Promise<void> {
297
-
296
+ async function _output_licence(info: Info, _options: Options): Promise<void> {
298
297
  if (info.module === "node-opcua-nodeset-ua") {
299
298
  return;
300
299
  }
@@ -327,17 +326,13 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
327
326
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
328
327
  `);
329
328
 
330
-
331
329
  // content3.push(fs.readFileSync(path.join(__dirname, "../source/licences/agpl_v3.md"), "utf8"));
332
330
  fs.writeFileSync(licenseFile, content3.join("\n"));
333
-
334
-
335
-
336
331
  }
337
332
  async function outputFiles(infos: { [key: string]: Info }, options: Options) {
338
333
  const values = Object.values(infos) as Info[];
339
334
  if (values.length < 1) {
340
- console.log(`There is no type information to generate for ${options.nsName}`)
335
+ console.log(`There is no type information to generate for ${options.nsName}`);
341
336
  }
342
337
  console.log("generating files for ", options.nsName);
343
338
  for (const info of values) {