node-opcua-modeler 2.98.1 → 2.99.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-modeler",
3
- "version": "2.98.1",
3
+ "version": "2.99.0",
4
4
  "description": "pure nodejs OPCUA SDK - module modeler",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,26 +14,26 @@
14
14
  "dependencies": {
15
15
  "cli-table3": "^0.6.3",
16
16
  "csv-parse": "5.3.6",
17
- "node-opcua-address-space": "2.98.1",
17
+ "node-opcua-address-space": "2.99.0",
18
18
  "node-opcua-assert": "2.98.1",
19
- "node-opcua-basic-types": "2.98.1",
20
- "node-opcua-client-dynamic-extension-object": "2.98.1",
19
+ "node-opcua-basic-types": "2.99.0",
20
+ "node-opcua-client-dynamic-extension-object": "2.99.0",
21
21
  "node-opcua-constants": "2.98.1",
22
- "node-opcua-data-model": "2.98.1",
23
- "node-opcua-debug": "2.98.1",
24
- "node-opcua-factory": "2.98.1",
25
- "node-opcua-nodeid": "2.98.1",
26
- "node-opcua-nodesets": "2.98.1",
27
- "node-opcua-numeric-range": "2.98.1",
28
- "node-opcua-schemas": "2.98.1",
29
- "node-opcua-service-translate-browse-path": "2.98.1",
22
+ "node-opcua-data-model": "2.99.0",
23
+ "node-opcua-debug": "2.99.0",
24
+ "node-opcua-factory": "2.99.0",
25
+ "node-opcua-nodeid": "2.99.0",
26
+ "node-opcua-nodesets": "2.99.0",
27
+ "node-opcua-numeric-range": "2.99.0",
28
+ "node-opcua-schemas": "2.99.0",
29
+ "node-opcua-service-translate-browse-path": "2.99.0",
30
30
  "node-opcua-status-code": "2.98.1",
31
- "node-opcua-types": "2.98.1",
32
- "node-opcua-variant": "2.98.1",
31
+ "node-opcua-types": "2.99.0",
32
+ "node-opcua-variant": "2.99.0",
33
33
  "yargs": "15.4.1"
34
34
  },
35
35
  "devDependencies": {
36
- "node-opcua-leak-detector": "2.98.1",
36
+ "node-opcua-leak-detector": "2.99.0",
37
37
  "should": "^13.2.3",
38
38
  "sinon": "^15.0.3"
39
39
  },
@@ -50,12 +50,13 @@
50
50
  "internet of things"
51
51
  ],
52
52
  "homepage": "http://node-opcua.github.io/",
53
- "gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c",
53
+ "gitHead": "90ce9f5b44d74198d84a384de622dfa94fd05c0c",
54
54
  "files": [
55
55
  "dist",
56
56
  "distNodeJS",
57
57
  "source",
58
58
  "nodeJS.d.ts",
59
- "nodeJS.js"
59
+ "nodeJS.js",
60
+ "source_nodejs"
60
61
  ]
61
62
  }
@@ -0,0 +1,13 @@
1
+ import * as fs from "fs";
2
+ import { Namespace } from "node-opcua-address-space";
3
+ import { BuildDocumentationOptions, buildDocumentationToString } from "..";
4
+
5
+ export async function buildDocumentationToFile(namespace: Namespace, filename: string, options?: BuildDocumentationOptions) {
6
+ const str = await buildDocumentationToString(namespace, options);
7
+ const stream = fs.createWriteStream("documentation.md");
8
+ stream.write(str);
9
+ await new Promise((resolve) => {
10
+ stream.on("finish", resolve);
11
+ stream.end();
12
+ });
13
+ }
@@ -0,0 +1,12 @@
1
+ import { readNodeSet2XmlFile } from "node-opcua-address-space/nodeJS";
2
+
3
+ import { buildModelInner, BuildModelOptionsBase } from "..";
4
+ import { Symbols } from "..";
5
+
6
+ export async function buildModel(data: BuildModelOptionsBase): Promise<{ markdown: string; xmlModel: string; symbols: Symbols }> {
7
+ const option1 = {
8
+ ...data,
9
+ xmlLoader: readNodeSet2XmlFile
10
+ };
11
+ return buildModelInner(option1);
12
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./symbol_cvs";
2
+ export * from "./build_model";
3
+ export * from "./build_documentation_to_file";
4
+ export * from "..";
5
+ export { generateAddressSpace } from "node-opcua-address-space/nodeJS"
@@ -0,0 +1,50 @@
1
+ import * as fs from "fs";
2
+ import { Parser, parse } from "csv-parse";
3
+
4
+ import { Symbols } from "..";
5
+ import { toCSV } from "..";
6
+
7
+ // node 14 onward : import { readFile, writeFile } from "fs/promises";
8
+ const { readFile, writeFile } = fs.promises;
9
+
10
+ export async function saveSymbolsToCSV(csvFilename: string, symbols: Symbols): Promise<void> {
11
+ await writeFile(csvFilename, toCSV(symbols), "utf-8");
12
+ }
13
+
14
+ export async function getPresetSymbolsFromCSV(csvFilename: string): Promise<Symbols> {
15
+ if (!fs.existsSync(csvFilename)) {
16
+ return [];
17
+ }
18
+ try {
19
+ const data = await readFile(csvFilename, "utf-8");
20
+
21
+ const records = await new Promise((resolve) => {
22
+ const output: any[] = [];
23
+ parse(data, {
24
+ cast: (value, context) => {
25
+ if (context.index === 1) {
26
+ return parseInt(value, 10);
27
+ }
28
+ return value;
29
+ }
30
+ })
31
+ .on("readable", function (this: Parser) {
32
+ let record = this.read();
33
+ while (record) {
34
+ output.push(record);
35
+ record = this.read();
36
+ }
37
+ })
38
+ .on("end", () => {
39
+ resolve(output);
40
+ });
41
+ });
42
+ return records as Symbols;
43
+ } catch (err) {
44
+ if (err instanceof Error) {
45
+ // tslint:disable-next-line: no-console
46
+ console.log("getPresetSymbols err = ", err.message);
47
+ }
48
+ return [];
49
+ }
50
+ }