node-opcua-modeler 2.62.7 → 2.64.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.
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dumpTypeDiagram = exports.graphVizToPlantUml = exports.dumpClassHierachry = exports.opcuaToDot = void 0;
4
+ const node_opcua_address_space_1 = require("node-opcua-address-space");
5
+ const node_opcua_constants_1 = require("node-opcua-constants");
6
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
7
+ function e(str) {
8
+ return str.replace(/</g, "&lt;").replace(/>/g, "&gt;");
9
+ }
10
+ function innerText(node) {
11
+ var _a, _b;
12
+ const browseName = node.browseName.name;
13
+ const typeDefinition = (_b = (_a = node.typeDefinitionObj) === null || _a === void 0 ? void 0 : _a.browseName) === null || _b === void 0 ? void 0 : _b.name;
14
+ if (typeDefinition) {
15
+ return `[ label =< <FONT point-size="8" ><I>${typeDefinition}</I></FONT><BR/>${e(browseName)} >]`;
16
+ }
17
+ else {
18
+ return `[label =< ${e(browseName)} >]`;
19
+ }
20
+ }
21
+ function arrowHeadAttribute(reference) {
22
+ switch (reference.referenceType.value) {
23
+ case node_opcua_constants_1.ReferenceTypeIds.HasTypeDefinition:
24
+ return "normalnormal";
25
+ case node_opcua_constants_1.ReferenceTypeIds.HasComponent:
26
+ return "noneteetee";
27
+ case node_opcua_constants_1.ReferenceTypeIds.HasProperty:
28
+ return "nonetee";
29
+ case node_opcua_constants_1.ReferenceTypeIds.HasSubtype:
30
+ return "onormalonormal";
31
+ case node_opcua_constants_1.ReferenceTypeIds.HasModellingRule:
32
+ return "none";
33
+ default:
34
+ return "normal";
35
+ }
36
+ }
37
+ function arrowHead(reference) {
38
+ return `[arrowhead = ${arrowHeadAttribute(reference)}]`;
39
+ }
40
+ const regularShapes = {
41
+ ObjectType: '[shape=rectangle, style="filled" fillcolor="#e8edf7;0.75:#d2def0" gradientangle=275]',
42
+ VariableType: '[shape=rectangle, style="rounded,filled" fillcolor="#e8edf7;0.75:#d2def0" gradientangle=275]',
43
+ Object: ' [shape=rectangle, style="filled" fillcolor="#e8edf7"]',
44
+ Variable: '[shape=rectangle, style="filled,rounded" fillcolor="#e8edf7"]',
45
+ Method: '[shape=oval, style="filled" fillcolor="#e8edf7"]'
46
+ };
47
+ const regularShapesOptionals = {
48
+ ObjectType: '[shape=rectangle, style="filled,dashed" fillcolor="#e8edf7;0.75:#d2def0" gradientangle=275]',
49
+ VariableType: '[shape=rectangle, style="rounded,filled,dashed" fillcolor="#e8edf7;0.75:#d2def0" gradientangle=275]',
50
+ Object: ' [shape=rectangle, style="filled,dashed" fillcolor="#e8edf7"]',
51
+ Variable: '[shape=rectangle, style="filled,rounded,dashed" fillcolor="#e8edf7"]',
52
+ Method: '[shape=oval, style="filled,dashed" fillcolor="#e8edf7"]'
53
+ };
54
+ class NodeRegistry {
55
+ constructor() {
56
+ this.m = {};
57
+ this.invisibleNodes = [];
58
+ this.duplicated = {};
59
+ }
60
+ add(name, node) {
61
+ if (this.duplicated[name]) {
62
+ return; //throw new Error("Already included");
63
+ }
64
+ this.duplicated[name] = name;
65
+ const nodeClass = node_opcua_data_model_1.NodeClass[node.nodeClass];
66
+ this.m[nodeClass] = this.m[nodeClass] || [];
67
+ this.m[nodeClass].push({ name, node });
68
+ }
69
+ addInvisibleNode(name) {
70
+ this.invisibleNodes.push(name);
71
+ }
72
+ }
73
+ function dumpNodeByNodeClass(str, nodeRegistry) {
74
+ for (const [className, listNode] of Object.entries(nodeRegistry.m)) {
75
+ if (listNode.length === 0) {
76
+ continue;
77
+ }
78
+ str.push(` ## -> ${className}`);
79
+ const mandatoryNodes = listNode.filter(({ name, node }) => !node.modellingRule || node.modellingRule.match(/Mandatory/));
80
+ const optionalNodes = listNode.filter(({ name, node }) => node.modellingRule && node.modellingRule.match(/Optional/));
81
+ if (mandatoryNodes.length > 0) {
82
+ str.push(` node [];`);
83
+ const decoration = regularShapes[className];
84
+ str.push(` node ${decoration};`);
85
+ for (const { name, node } of mandatoryNodes) {
86
+ str.push(` ${name} ${innerText(node)}`);
87
+ }
88
+ }
89
+ if (optionalNodes.length > 0) {
90
+ const decoration2 = regularShapesOptionals[className];
91
+ str.push(` node [];`);
92
+ str.push(` node ${decoration2};`);
93
+ for (const { name, node } of listNode) {
94
+ str.push(` ${name} ${innerText(node)}`);
95
+ }
96
+ }
97
+ }
98
+ if (nodeRegistry.invisibleNodes.length) {
99
+ str.push(" # invisible nodes");
100
+ str.push(" node []");
101
+ str.push(" node [width=0,height=0,shape=point,style=invis];");
102
+ str.push(` ${nodeRegistry.invisibleNodes.join("\n ")};`);
103
+ }
104
+ }
105
+ const dump_state_machine_to_graphviz_1 = require("./dump_state_machine_to_graphviz");
106
+ function opcuaToDot(node, options) {
107
+ if (node.nodeClass === node_opcua_data_model_1.NodeClass.ObjectType) {
108
+ const finitieStateMachineType = node.addressSpace.findObjectType("FiniteStateMachineType");
109
+ if (finitieStateMachineType) {
110
+ if (node.isSupertypeOf(finitieStateMachineType)) {
111
+ const stateMachine = node.instantiate({ browseName: "StateMachine" });
112
+ (0, node_opcua_address_space_1.promoteToStateMachine)(stateMachine);
113
+ return (0, dump_state_machine_to_graphviz_1.dumpStateMachineToPlantUML)(stateMachine);
114
+ }
115
+ }
116
+ }
117
+ options = options || { naked: false };
118
+ const nodeRegistry = new NodeRegistry();
119
+ const str = [];
120
+ const str2 = [];
121
+ str.push("digraph G {");
122
+ if (!options.naked) {
123
+ str.push(" rankdir=TB;");
124
+ str.push(" nodesep=0.5;");
125
+ str.push(" node [];");
126
+ }
127
+ function makeId(p, c) {
128
+ return `${p}_${c}`.replace(" ", "_").replace(/<|>/g, "_");
129
+ }
130
+ // eslint-disable-next-line max-params
131
+ // eslint-disable-next-line max-statements
132
+ function typeMemberAndSubTypeMember(str, parentNode, node, parent, offset, prefix, joinWithCaller, visitorMap) {
133
+ let innerDepth = 0;
134
+ const browseName = (parent || node).browseName.name.toString();
135
+ const r = [];
136
+ const r2 = [];
137
+ const references = (parent || node).findReferencesEx("Aggregates", node_opcua_data_model_1.BrowseDirection.Forward);
138
+ const folderElements = (parent || node).findReferencesEx("Organizes", node_opcua_data_model_1.BrowseDirection.Forward);
139
+ const childReferences = [...references, ...folderElements];
140
+ const id = makeId(parentNode, browseName);
141
+ nodeRegistry.add(id, node);
142
+ function addInvisibleNode(prefix, index) {
143
+ const breakNode = `${prefix}${index}`;
144
+ r2.push(breakNode);
145
+ nodeRegistry.addInvisibleNode(breakNode);
146
+ return breakNode;
147
+ }
148
+ for (let i = 0; i < childReferences.length; i++) {
149
+ const isLast = i === childReferences.length - 1;
150
+ const reference = childReferences[i];
151
+ const childNode = reference.node;
152
+ const childName = childNode.browseName.name.toString();
153
+ const fullChildName = makeId(id, childName);
154
+ // avoid member duplication
155
+ if (visitorMap[fullChildName]) {
156
+ continue;
157
+ }
158
+ else {
159
+ visitorMap[fullChildName] = 1;
160
+ }
161
+ innerDepth++;
162
+ nodeRegistry.add(fullChildName, childNode);
163
+ const edgeAttributes = arrowHead(reference);
164
+ const breakNode = addInvisibleNode(prefix, i + offset);
165
+ const horizontalPart = `{ rank=same ${breakNode} -> ${fullChildName} ${edgeAttributes} }`;
166
+ r.push(horizontalPart);
167
+ // push children on same level
168
+ const [depth] = typeMemberAndSubTypeMember(str, id, childNode, null, 0, `${prefix}${i + offset}_`, false, visitorMap);
169
+ // add invisible nodes
170
+ {
171
+ for (let d = 0; d < depth; d++) {
172
+ offset++;
173
+ if (!isLast) {
174
+ addInvisibleNode(prefix, i + offset);
175
+ }
176
+ }
177
+ innerDepth += depth;
178
+ }
179
+ }
180
+ if (node.nodeClass == node_opcua_data_model_1.NodeClass.ObjectType || node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
181
+ if (node.subtypeOfObj && node.subtypeOfObj.nodeId.namespace === node.nodeId.namespace) {
182
+ const [depth, rr2] = typeMemberAndSubTypeMember(str, parentNode, node.subtypeOfObj, node, r.length + offset + 1, prefix, true, visitorMap);
183
+ innerDepth += depth + 1;
184
+ r2.push(...rr2);
185
+ }
186
+ }
187
+ if (r.length) {
188
+ str.push(...r.map((x) => " " + x));
189
+ }
190
+ if (!joinWithCaller) {
191
+ if (r2.length) {
192
+ str.push(` ${id} -> ${r2.join(" -> ")} [arrowhead=none];`);
193
+ }
194
+ }
195
+ return [innerDepth, r2];
196
+ }
197
+ const visitorMap = {};
198
+ typeMemberAndSubTypeMember(str2, "", node, null, 0, "r", false, visitorMap);
199
+ if (!options.naked) {
200
+ dumpNodeByNodeClass(str, nodeRegistry);
201
+ }
202
+ str.push(...str2);
203
+ str.push("}");
204
+ //
205
+ const dot = str.join("\n");
206
+ return dot;
207
+ }
208
+ exports.opcuaToDot = opcuaToDot;
209
+ function dumpClassHierachry(typeNode, options) {
210
+ options = options || { naked: false, showBaseType: true, showSubType: true };
211
+ const level = options.depth || 50;
212
+ const str = [];
213
+ const nodeRegistry = new NodeRegistry();
214
+ nodeRegistry.add(typeNode.browseName.name, typeNode);
215
+ str.push("digraph G {");
216
+ if (!options.naked) {
217
+ // str.push(" splines=ortho;");
218
+ str.push(" rankdir=BT;");
219
+ str.push(" nodesep=0.5;");
220
+ str.push(" node [];");
221
+ }
222
+ function dumpSubtypes(str, typeNode, level) {
223
+ const parentName = typeNode.browseName.name.toString();
224
+ const references = typeNode.findReferencesEx("HasSubtype", node_opcua_data_model_1.BrowseDirection.Forward);
225
+ for (let i = 0; i < references.length; i++) {
226
+ const reference = references[i];
227
+ const childNode = reference.node;
228
+ const nodeClass = node_opcua_data_model_1.NodeClass[childNode.nodeClass];
229
+ const childName = childNode.browseName.name.toString();
230
+ nodeRegistry.add(childName, childNode);
231
+ const edgeAttributes = arrowHead(reference);
232
+ str.push(` ${childName} -> ${parentName} ${edgeAttributes};`);
233
+ if (level > 0) {
234
+ dumpSubtypes(str, childNode, level - 1);
235
+ }
236
+ }
237
+ }
238
+ function dumpBaseTypes(str, typeNode, level) {
239
+ const parentName = typeNode.browseName.name.toString();
240
+ const references = typeNode.findReferencesEx("HasSubtype", node_opcua_data_model_1.BrowseDirection.Inverse);
241
+ for (let i = 0; i < references.length; i++) {
242
+ const reference = references[i];
243
+ const childNode = reference.node;
244
+ const nodeClass = node_opcua_data_model_1.NodeClass[childNode.nodeClass];
245
+ const childName = childNode.browseName.name.toString();
246
+ nodeRegistry.add(childName, childNode);
247
+ const edgeAttributes = arrowHead(reference);
248
+ str.push(` ${parentName} -> ${childName} ${edgeAttributes};`);
249
+ if (level > 0) {
250
+ dumpBaseTypes(str, childNode, level - 1);
251
+ }
252
+ }
253
+ }
254
+ const str2 = [];
255
+ if (options.showBaseType) {
256
+ dumpBaseTypes(str2, typeNode, level);
257
+ }
258
+ /** */
259
+ if (options.showSubType) {
260
+ dumpSubtypes(str2, typeNode, level);
261
+ }
262
+ if (!options.naked) {
263
+ dumpNodeByNodeClass(str, nodeRegistry);
264
+ }
265
+ str.push(...str2);
266
+ str.push("}");
267
+ return str.join("\n");
268
+ }
269
+ exports.dumpClassHierachry = dumpClassHierachry;
270
+ function graphVizToPlantUml(str) {
271
+ const ttt = "```";
272
+ return `${ttt}plantuml\n@startuml\n${str}\n@enduml\n${ttt}`;
273
+ }
274
+ exports.graphVizToPlantUml = graphVizToPlantUml;
275
+ function dumpTypeDiagram(namespace) {
276
+ const objectTypes = [...namespace._objectTypeIterator()];
277
+ const variableTypes = [...namespace._variableTypeIterator()];
278
+ const dataTypes = [...namespace._dataTypeIterator()];
279
+ const referenceTypes = [...namespace._referenceTypeIterator()];
280
+ const addressSpace = namespace.addressSpace;
281
+ const str = [];
282
+ for (const type of [...objectTypes, ...variableTypes]) {
283
+ const d = opcuaToDot(type);
284
+ str.push(graphVizToPlantUml(d));
285
+ const d2 = dumpClassHierachry(type);
286
+ str.push(graphVizToPlantUml(d2));
287
+ }
288
+ for (const dataType of dataTypes) {
289
+ const d = opcuaToDot(dataType);
290
+ str.push(graphVizToPlantUml(d));
291
+ }
292
+ return str.join("\n");
293
+ }
294
+ exports.dumpTypeDiagram = dumpTypeDiagram;
295
+ //# sourceMappingURL=to_graphivz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to_graphivz.js","sourceRoot":"","sources":["../source/to_graphivz.ts"],"names":[],"mappings":";;;AAAA,uEAYkC;AAElC,+DAAwD;AACxD,iEAAmE;AAGnE,SAAS,CAAC,CAAC,GAAW;IAClB,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC3D,CAAC;AACD,SAAS,SAAS,CAAC,IAA2B;;IAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IACxC,MAAM,cAAc,GAAG,MAAA,MAAA,IAAI,CAAC,iBAAiB,0CAAE,UAAU,0CAAE,IAAI,CAAC;IAEhE,IAAI,cAAc,EAAE;QAChB,OAAO,uCAAuC,cAAc,mBAAmB,CAAC,CAAC,UAAW,CAAC,KAAK,CAAC;KACtG;SAAM;QACH,OAAO,aAAa,CAAC,CAAC,UAAW,CAAC,KAAK,CAAC;KAC3C;AACL,CAAC;AACD,SAAS,kBAAkB,CAAC,SAAsB;IAC9C,QAAQ,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE;QACnC,KAAK,uCAAgB,CAAC,iBAAiB;YACnC,OAAO,cAAc,CAAC;QAC1B,KAAK,uCAAgB,CAAC,YAAY;YAC9B,OAAO,YAAY,CAAC;QACxB,KAAK,uCAAgB,CAAC,WAAW;YAC7B,OAAO,SAAS,CAAC;QACrB,KAAK,uCAAgB,CAAC,UAAU;YAC5B,OAAO,gBAAgB,CAAC;QAC5B,KAAK,uCAAgB,CAAC,gBAAgB;YAClC,OAAO,MAAM,CAAC;QAClB;YACI,OAAO,QAAQ,CAAC;KACvB;AACL,CAAC;AACD,SAAS,SAAS,CAAC,SAAsB;IACrC,OAAO,gBAAgB,kBAAkB,CAAC,SAA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AAmB,EAAE,CAAC,CAAC;IACzD,MAAM,aAAa,GAAG,CAAC,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAC7D,MAAM,SAAS,GAAG,CAAC,GAAG,SAAS,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,CAAC,GAAG,SAAS,CAAC,sBAAsB,EAAE,CAAC,CAAC;IAC/D,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC;IAE5C,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,WAAW,EAAE,GAAG,aAAa,CAAC,EAAE;QACnD,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;QAEhC,MAAM,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACpC,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAC;KACpC;IACD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAC9B,MAAM,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC/B,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;KACnC;IACD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AApBD,0CAoBC"}
@@ -1,6 +1,10 @@
1
1
  // tslint:disable:no-console
2
2
  import * as fs from "fs";
3
3
  import { promisify } from "util";
4
+
5
+
6
+ import { generateAddressSpace } from "node-opcua-address-space/nodeJS";
7
+ import { createBoilerType } from "node-opcua-address-space/testHelpers";
4
8
  import {
5
9
  AddressSpace,
6
10
  DataType,
@@ -15,9 +19,6 @@ import {
15
19
  } from "..";
16
20
 
17
21
  import { getPresetSymbolsFromCSV, saveSymbolsToCSV, buildModel } from "../nodeJS";
18
- import { generateAddressSpace } from "node-opcua-address-space/nodeJS";
19
-
20
- import { createBoilerType } from "node-opcua-address-space/testHelpers";
21
22
 
22
23
  // node 14 onward : import { writeFile } from "fs/promises";
23
24
  const { writeFile } = fs.promises;
package/package.json CHANGED
@@ -1,53 +1,54 @@
1
1
  {
2
- "name": "node-opcua-modeler",
3
- "version": "2.62.7",
4
- "description": "pure nodejs OPCUA SDK - module - model",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "scripts": {
8
- "build": "tsc -b",
9
- "clean": "node -e \"require('rimraf').sync('dist');\"",
10
- "test": "mocha"
11
- },
12
- "author": "Etienne Rossignon",
13
- "license": "MIT",
14
- "dependencies": {
15
- "chalk": "4.1.2",
16
- "cli-table3": "^0.6.0",
17
- "csv-parse": "5.0.3",
18
- "node-opcua-address-space": "2.62.7",
19
- "node-opcua-assert": "2.55.0",
20
- "node-opcua-basic-types": "2.62.7",
21
- "node-opcua-client-dynamic-extension-object": "2.62.7",
22
- "node-opcua-constants": "2.62.7",
23
- "node-opcua-data-model": "2.62.7",
24
- "node-opcua-factory": "2.62.7",
25
- "node-opcua-nodeid": "2.62.7",
26
- "node-opcua-nodesets": "2.62.7",
27
- "node-opcua-numeric-range": "2.62.7",
28
- "node-opcua-schemas": "2.62.7",
29
- "node-opcua-service-translate-browse-path": "2.62.7",
30
- "node-opcua-status-code": "2.62.7",
31
- "node-opcua-types": "2.62.7",
32
- "node-opcua-variant": "2.62.7",
33
- "node-opcua-xml2json": "2.62.7"
34
- },
35
- "devDependencies": {
36
- "node-opcua-leak-detector": "2.62.7",
37
- "should": "^13.2.3"
38
- },
39
- "repository": {
40
- "type": "git",
41
- "url": "git://github.com/node-opcua/node-opcua.git"
42
- },
43
- "keywords": [
44
- "OPCUA",
45
- "opcua",
46
- "m2m",
47
- "iot",
48
- "opc ua",
49
- "internet of things"
50
- ],
51
- "homepage": "http://node-opcua.github.io/",
52
- "gitHead": "90bb9139261a0edbb531081afcc6904c74e9ee52"
53
- }
2
+ "name": "node-opcua-modeler",
3
+ "version": "2.64.0",
4
+ "description": "pure nodejs OPCUA SDK - module - model",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "author": "Etienne Rossignon",
8
+ "license": "MIT",
9
+ "dependencies": {
10
+ "chalk": "4.1.2",
11
+ "cli-table3": "^0.6.1",
12
+ "csv-parse": "5.0.4",
13
+ "node-opcua-address-space": "2.64.0",
14
+ "node-opcua-assert": "2.64.0",
15
+ "node-opcua-basic-types": "2.64.0",
16
+ "node-opcua-client-dynamic-extension-object": "2.64.0",
17
+ "node-opcua-constants": "2.64.0",
18
+ "node-opcua-data-model": "2.64.0",
19
+ "node-opcua-factory": "2.64.0",
20
+ "node-opcua-nodeid": "2.64.0",
21
+ "node-opcua-nodesets": "2.64.0",
22
+ "node-opcua-numeric-range": "2.64.0",
23
+ "node-opcua-schemas": "2.64.0",
24
+ "node-opcua-service-translate-browse-path": "2.64.0",
25
+ "node-opcua-status-code": "2.64.0",
26
+ "node-opcua-types": "2.64.0",
27
+ "node-opcua-variant": "2.64.0",
28
+ "node-opcua-xml2json": "2.64.0"
29
+ },
30
+ "devDependencies": {
31
+ "node-opcua-leak-detector": "2.64.0",
32
+ "should": "^13.2.3"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git://github.com/node-opcua/node-opcua.git"
37
+ },
38
+ "keywords": [
39
+ "OPCUA",
40
+ "opcua",
41
+ "m2m",
42
+ "iot",
43
+ "opc ua",
44
+ "internet of things"
45
+ ],
46
+ "homepage": "http://node-opcua.github.io/",
47
+ "gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c",
48
+ "scripts": {
49
+ "build": "tsc -b",
50
+ "clean": "node -e \"require('rimraf').sync('dist');\"",
51
+ "test": "mocha"
52
+ },
53
+ "readme": "## Node-OPCUA Modeler\n\nNode-opcua-modeler provides a programatic way to conveniently create OPCUA model and nodeset files.\n\n```typescript\nimport {\n AddressSpace,\n buildModel,\n nodesets\n} from \"node-opcua-modeler\";\nimport * as fs from \"fs\";\n\n// the namespaceUri\nconst namespaceUri = \"http://acme.com/Boiler/V0\";\nconst version= \"1.0.0\";\n\n// the nodeset file required by your model\nconst xmlFiles: string[] = [\n nodesets.standard,\n nodesets.di\n];\n \nasync function createModel(addressSpace: AddressSpace): Promise<void> {\n // create your model here !\n}\n\n(async () => {\n try {\n const { markdown, xmlModel, symbols } = await buildModel({\n namespaceUri,\n version,\n xmlFiles,\n createModel\n });\n // save model to a file\n const nodesetFiename = \"./MyModel.NodeSet2.xml\";\n await fs.promises.writeFile(nodesetFiename, xmlModel, \"utf-8\");\n\n } catch (err) {\n console.log(\"Error\", err);\n }\n})();\n```\n"
54
+ }