node-opcua-convert-nodeset-to-javascript 2.102.0 → 2.104.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 +31 -3
- package/dist/convert_namespace_to_typescript.js.map +1 -1
- package/dist/convert_to_typescript.js +14 -10
- package/dist/convert_to_typescript.js.map +1 -1
- package/dist/main.js +28 -75
- package/dist/main.js.map +1 -1
- package/dist/options.d.ts +1 -0
- package/dist/private/cache.js +28 -2
- package/dist/private/cache.js.map +1 -1
- package/dist/private/get_corresponding_data_type.d.ts +2 -2
- package/dist/private/get_corresponding_data_type.js +6 -6
- package/dist/private/get_corresponding_data_type.js.map +1 -1
- package/dist/update_parent_tsconfig.d.ts +1 -0
- package/dist/update_parent_tsconfig.js +91 -0
- package/dist/update_parent_tsconfig.js.map +1 -0
- package/dist/utils2.js +7 -4
- package/dist/utils2.js.map +1 -1
- package/dist/walk_through.js +4 -4
- package/dist/walk_through.js.map +1 -1
- package/package.json +18 -18
- package/source/_dataType.ts +2 -2
- package/source/convert_namespace_to_typescript.ts +6 -1
- package/source/convert_to_typescript.ts +8 -8
- package/source/main.ts +10 -76
- package/source/options.ts +1 -0
- package/source/private/get_corresponding_data_type.ts +3 -3
- package/source/update_parent_tsconfig.ts +56 -0
- package/source/utils2.ts +3 -3
- package/source/walk_through.ts +5 -4
- package/source/official_namespaces.ts +0 -98
|
@@ -9,20 +9,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.getCorrespondingJavascriptType = exports.getCorrespondingJavascriptType2 = void 0;
|
|
13
13
|
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
14
14
|
const cache_1 = require("./cache");
|
|
15
15
|
const utils_1 = require("./utils");
|
|
16
|
-
function
|
|
16
|
+
function getCorrespondingJavascriptType2(session, nodeId, dataTypeNodeId, cache, importCollect) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const q = yield
|
|
18
|
+
const q = yield getCorrespondingJavascriptType(session, dataTypeNodeId, cache, importCollect);
|
|
19
19
|
const valueRank = yield (0, utils_1.getValueRank)(session, nodeId);
|
|
20
20
|
return { dataType: q.dataType, jtype: q.jtype + (valueRank >= 1 ? "[]" : "") };
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
exports.
|
|
23
|
+
exports.getCorrespondingJavascriptType2 = getCorrespondingJavascriptType2;
|
|
24
24
|
// eslint-disable-next-line complexity
|
|
25
|
-
function
|
|
25
|
+
function getCorrespondingJavascriptType(session, dataTypeNodeId, cache, importCollect) {
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
const { dataType, enumerationType } = yield (0, utils_1._convertNodeIdToDataTypeAsync)(session, dataTypeNodeId);
|
|
28
28
|
if (enumerationType) {
|
|
@@ -100,5 +100,5 @@ function getCorrepondingJavascriptType(session, dataTypeNodeId, cache, importCol
|
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
exports.
|
|
103
|
+
exports.getCorrespondingJavascriptType = getCorrespondingJavascriptType;
|
|
104
104
|
//# sourceMappingURL=get_corresponding_data_type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_corresponding_data_type.js","sourceRoot":"","sources":["../../source/private/get_corresponding_data_type.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,2DAA8C;AAC9C,mCAAiF;AACjF,mCAAsE;AAGtE,SAAsB,
|
|
1
|
+
{"version":3,"file":"get_corresponding_data_type.js","sourceRoot":"","sources":["../../source/private/get_corresponding_data_type.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,2DAA8C;AAC9C,mCAAiF;AACjF,mCAAsE;AAG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CAAC;YACrE,KAAK,6BAAQ,CAAC,aAAa;gBACvB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,kBAAkB,CAAC,eAAe,CAAC,EAAE,CAAC;YACpE,KAAK,6BAAQ,CAAC,KAAK;gBACf,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5D,KAAK,6BAAQ,CAAC,UAAU;gBACpB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC;YACjE,KAAK,6BAAQ,CAAC,MAAM;gBAChB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/D,KAAK,6BAAQ,CAAC,OAAO;gBACjB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,kBAAkB,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9D,KAAK,6BAAQ,CAAC,UAAU;gBACpB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7D;gBACI,MAAM,IAAI,KAAK,CAAC,cAAc,GAAG,QAAQ,GAAG,GAAG,GAAG,6BAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;SAC7E;IACL,CAAC;CAAA;AAnFD,wEAmFC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function updateParentTSConfig(): Promise<void>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Purpose of this script is to help ensure that "references" array in packages/tsconfig.json
|
|
3
|
+
// stays up-to-date with nodeset package list.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
28
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
29
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
30
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
31
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
32
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
33
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.updateParentTSConfig = void 0;
|
|
38
|
+
const fs_1 = require("fs");
|
|
39
|
+
const { readFile, writeFile } = fs_1.promises;
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
// Uncomment the following to get __dirname equivalent when compiling to ESM
|
|
42
|
+
//import { fileURLToPath } from 'url';
|
|
43
|
+
//const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
44
|
+
const node_opcua_nodesets_1 = require("node-opcua-nodesets");
|
|
45
|
+
function updateParentTSConfig() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const packagesFolder = path.join(__dirname, '..', '..');
|
|
48
|
+
const parentTSConfigFile = path.join(packagesFolder, 'tsconfig.json');
|
|
49
|
+
const parentTSConfig = JSON.parse(
|
|
50
|
+
// Strip out comments to avoid JSON parsing error
|
|
51
|
+
// TODO: Preserve comments automatically
|
|
52
|
+
(yield readFile(parentTSConfigFile, 'utf8'))
|
|
53
|
+
.replace(/\/\*.+?\*\//g, '')
|
|
54
|
+
.replace(/\/\/.+?$/g, ''));
|
|
55
|
+
const unlistedReferences = [];
|
|
56
|
+
for (const meta of node_opcua_nodesets_1.allNodesetMeta) {
|
|
57
|
+
const nodesetPackageFolder = path.join(packagesFolder, meta.packageName);
|
|
58
|
+
if (!(0, fs_1.existsSync)(nodesetPackageFolder)) {
|
|
59
|
+
console.log(`Ignoring ${meta.packageName} since package folder does not exist (${nodesetPackageFolder})`);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (!parentTSConfig.references.some((ref) => ref.path === meta.packageName)) {
|
|
63
|
+
console.log(`Found nodeset package that was not listed in tsconfig.json: ${meta.packageName}`);
|
|
64
|
+
unlistedReferences.push({ path: meta.packageName });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function compareByPath(a, b) {
|
|
68
|
+
if (a.path < b.path) {
|
|
69
|
+
return -1;
|
|
70
|
+
}
|
|
71
|
+
if (a.path > b.path) {
|
|
72
|
+
return 1;
|
|
73
|
+
}
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
76
|
+
if (unlistedReferences.length > 0) {
|
|
77
|
+
parentTSConfig.references.push(...unlistedReferences);
|
|
78
|
+
parentTSConfig.references.sort(compareByPath);
|
|
79
|
+
// Maintain the compact style `{ "path": "node-opcua-X" }` in references section
|
|
80
|
+
// Also add the comment about Istanbul back
|
|
81
|
+
const newJSON = JSON.stringify(parentTSConfig, null, " ")
|
|
82
|
+
.replace('"removeComments": false', '"removeComments": false /* to prevent Istanbul ignore statements in comments from disappearing */')
|
|
83
|
+
.replace(/{\s*"path":\s*"([^"]+)"\s*}/g, '{ "path": "$1" }')
|
|
84
|
+
+ '\n';
|
|
85
|
+
//console.log('Writing updated tsconfig.json file:', newJSON);
|
|
86
|
+
yield writeFile(parentTSConfigFile, newJSON, 'utf8');
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
exports.updateParentTSConfig = updateParentTSConfig;
|
|
91
|
+
//# sourceMappingURL=update_parent_tsconfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update_parent_tsconfig.js","sourceRoot":"","sources":["../source/update_parent_tsconfig.ts"],"names":[],"mappings":";AAAA,6FAA6F;AAC7F,8CAA8C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9C,2BAAwD;AACxD,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,aAAU,CAAC;AAC3C,2CAA6B;AAC7B,4EAA4E;AAC5E,sCAAsC;AACtC,iEAAiE;AAEjE,6DAAqD;AAErD,SAAsB,oBAAoB;;QACtC,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACxD,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;QACtE,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK;QAC7B,iDAAiD;QACjD,wCAAwC;QACxC,CAAC,MAAM,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;aACvC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;aAC3B,OAAO,CAAC,WAA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IAAI,EAAE,MAAM,CAAC;iBACnD,OAAO,CAAC,yBAAyB,EAAE,mGAAmG,CAAC;iBACvI,OAAO,CAAC,8BAA8B,EAAE,kBAAkB,CAAC;kBAC9D,IAAI,CAAC;YACX,8DAA8D;YAC9D,MAAM,SAAS,CAAC,kBAAkB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;SACxD;IACL,CAAC;CAAA;AA3CD,oDA2CC"}
|
package/dist/utils2.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.f1 = exports.f2 = exports.quotifyIfNecessary = exports.toJavascritPropertyName = exports.toComment = void 0;
|
|
4
7
|
const node_opcua_utils_1 = require("node-opcua-utils");
|
|
5
|
-
const
|
|
6
|
-
const wrapText =
|
|
8
|
+
const wordwrap_1 = __importDefault(require("wordwrap"));
|
|
9
|
+
const wrapText = (0, wordwrap_1.default)(0, 50);
|
|
7
10
|
function toComment(prefix, description) {
|
|
8
11
|
const d = wrapText(description);
|
|
9
12
|
return d
|
|
@@ -51,8 +54,8 @@ function quotifyIfNecessary(s) {
|
|
|
51
54
|
return s;
|
|
52
55
|
}
|
|
53
56
|
exports.quotifyIfNecessary = quotifyIfNecessary;
|
|
54
|
-
const f2 = (str) => str.padEnd(
|
|
57
|
+
const f2 = (str) => str.padEnd(60, "-");
|
|
55
58
|
exports.f2 = f2;
|
|
56
|
-
const f1 = (str) => str.padEnd(
|
|
59
|
+
const f1 = (str) => str.padEnd(60, " ");
|
|
57
60
|
exports.f1 = f1;
|
|
58
61
|
//# sourceMappingURL=utils2.js.map
|
package/dist/utils2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils2.js","sourceRoot":"","sources":["../source/utils2.ts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CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACpG,CAAC;AA3BD,0DA2BC;AAED,SAAgB,kBAAkB,CAAC,CAAS;IACxC,IAAI,CAAC,CAAC,KAAK,CAAC,8BAA8B,CAAC,EAAE;QACzC,OAAO,IAAI,CAAC,GAAG,CAAC;KACnB;IACD,IAAI,CAAC,KAAK,WAAW,EAAE;QACnB,OAAO,gBAAgB,CAAC;KAC3B;IACD,OAAO,CAAC,CAAC;AACb,CAAC;AARD,gDAQC;AAEM,MAAM,EAAE,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAA1C,QAAA,EAAE,MAAwC;AAChD,MAAM,EAAE,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAA1C,QAAA,EAAE,MAAwC"}
|
package/dist/walk_through.js
CHANGED
|
@@ -72,15 +72,15 @@ function walkThroughInterfaceTypes(session, nodeVisitor) {
|
|
|
72
72
|
exports.walkThroughInterfaceTypes = walkThroughInterfaceTypes;
|
|
73
73
|
function walkThroughObjectTypes(session, nodeVisitor) {
|
|
74
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
const
|
|
76
|
-
yield _walkThroughTypes(session,
|
|
75
|
+
const baseObjectTypeNodeId = (0, node_opcua_nodeid_1.resolveNodeId)("BaseObjectType");
|
|
76
|
+
yield _walkThroughTypes(session, baseObjectTypeNodeId, nodeVisitor);
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
exports.walkThroughObjectTypes = walkThroughObjectTypes;
|
|
80
80
|
function walkThroughVariableTypes(session, nodeVisitor) {
|
|
81
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
const
|
|
83
|
-
yield _walkThroughTypes(session,
|
|
82
|
+
const baseObjectTypeNodeId = (0, node_opcua_nodeid_1.resolveNodeId)("BaseVariableType");
|
|
83
|
+
yield _walkThroughTypes(session, baseObjectTypeNodeId, nodeVisitor);
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
exports.walkThroughVariableTypes = walkThroughVariableTypes;
|
package/dist/walk_through.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walk_through.js","sourceRoot":"","sources":["../source/walk_through.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAAgG;AAChG,yDAA0E;AAE1E,uDAAwD;AAQxD,SAAe,iBAAiB,CAC5B,OAAsB,EACtB,MAAc,EACd,OAAqB,EACrB,KAAc,EACd,MAA6B;;QAE7B,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC;QAEnB,IAAI,CAAC,MAAM,EAAE;YACT,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;gBAClC,EAAE,MAAM,EAAE,WAAW,EAAE,oCAAY,CAAC,UAAU,EAAE;gBAChD,EAAE,MAAM,EAAE,WAAW,EAAE,oCAAY,CAAC,SAAS,EAAE;aAClD,CAAC,CAAC;YACH,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAsB,CAAC;YAC9D,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAkB,CAAC;YACzD,MAAM,GAAG,IAAI,uCAAoB,CAAC;gBAC9B,SAAS,EAAE,IAAI;gBACf,MAAM,EAAE,MAAwB;gBAChC,UAAU;gBACV,SAAS;gBACT,eAAe,EAAE,IAAA,iCAAa,EAAC,YAAY,CAAC;gBAC5C,kBAAkB;aACrB,CAAC,CAAC;SACN;QACD,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC;YACtC,eAAe,EAAE,uCAAe,CAAC,OAAO;YACxC,MAAM;YACN,eAAe,EAAE,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EAAC,YAAY,CAAC,CAAC;QAC5D,MAAM,iBAAiB,CAAC,OAAO,EAAE,uBAAuB,EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC;CAAA;AAHD,8DAGC;AACD,SAAsB,oBAAoB,CAAC,OAAsB,EAAE,WAAyB;;QACxF,MAAM,sBAAsB,GAAG,IAAA,iCAAa,EAAC,cAAc,CAAC,CAAC;QAC7D,MAAM,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,EAAE,WAAW,CAAC,CAAC;IAC1E,CAAC;CAAA;AAHD,oDAGC;AAED,SAAsB,yBAAyB,CAAC,OAAsB,EAAE,WAAyB;;QAC7F,MAAM,uBAAuB,GAAG,IAAA,iCAAa,EAAC,mBAAmB,CAAC,CAAC;QACnE,MAAM,iBAAiB,CAAC,OAAO,EAAE,uBAAuB,EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC;CAAA;AAHD,8DAGC;AACD,SAAsB,sBAAsB,CAAC,OAAsB,EAAE,WAAyB;;QAC1F,MAAM,oBAAoB,GAAG,IAAA,iCAAa,EAAC,gBAAgB,CAAC,CAAC;QAC7D,MAAM,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,EAAE,WAAW,CAAC,CAAC;IACxE,CAAC;CAAA;AAHD,wDAGC;AACD,SAAsB,wBAAwB,CAAC,OAAsB,EAAE,WAAyB;;QAC5F,MAAM,oBAAoB,GAAG,IAAA,iCAAa,EAAC,kBAAkB,CAAC,CAAC;QAC/D,MAAM,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,EAAE,WAAW,CAAC,CAAC;IACxE,CAAC;CAAA;AAHD,4DAGC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-convert-nodeset-to-javascript",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.104.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",
|
|
@@ -15,26 +15,26 @@
|
|
|
15
15
|
"@types/wordwrap": "^1.0.1",
|
|
16
16
|
"case-anything": "1.1.5",
|
|
17
17
|
"chalk": "4.1.2",
|
|
18
|
-
"node-opcua-address-space": "2.
|
|
19
|
-
"node-opcua-address-space-base": "2.
|
|
20
|
-
"node-opcua-assert": "2.
|
|
18
|
+
"node-opcua-address-space": "2.104.0",
|
|
19
|
+
"node-opcua-address-space-base": "2.104.0",
|
|
20
|
+
"node-opcua-assert": "2.104.0",
|
|
21
21
|
"node-opcua-constants": "2.98.1",
|
|
22
|
-
"node-opcua-data-model": "2.
|
|
23
|
-
"node-opcua-debug": "2.
|
|
24
|
-
"node-opcua-extension-object": "2.
|
|
25
|
-
"node-opcua-nodeid": "2.
|
|
26
|
-
"node-opcua-nodesets": "2.
|
|
27
|
-
"node-opcua-pseudo-session": "2.
|
|
28
|
-
"node-opcua-status-code": "2.
|
|
29
|
-
"node-opcua-types": "2.
|
|
30
|
-
"node-opcua-utils": "2.
|
|
31
|
-
"node-opcua-variant": "2.
|
|
22
|
+
"node-opcua-data-model": "2.104.0",
|
|
23
|
+
"node-opcua-debug": "2.104.0",
|
|
24
|
+
"node-opcua-extension-object": "2.104.0",
|
|
25
|
+
"node-opcua-nodeid": "2.104.0",
|
|
26
|
+
"node-opcua-nodesets": "2.103.0",
|
|
27
|
+
"node-opcua-pseudo-session": "2.104.0",
|
|
28
|
+
"node-opcua-status-code": "2.104.0",
|
|
29
|
+
"node-opcua-types": "2.104.0",
|
|
30
|
+
"node-opcua-utils": "2.104.0",
|
|
31
|
+
"node-opcua-variant": "2.104.0",
|
|
32
32
|
"wordwrap": "^1.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"node-opcua-leak-detector": "2.
|
|
36
|
-
"node-opcua-packet-analyzer": "2.
|
|
37
|
-
"node-opcua-service-translate-browse-path": "2.
|
|
35
|
+
"node-opcua-leak-detector": "2.104.0",
|
|
36
|
+
"node-opcua-packet-analyzer": "2.104.0",
|
|
37
|
+
"node-opcua-service-translate-browse-path": "2.104.0",
|
|
38
38
|
"should": "^13.2.3"
|
|
39
39
|
},
|
|
40
40
|
"author": "Etienne Rossignon",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"internet of things"
|
|
53
53
|
],
|
|
54
54
|
"homepage": "http://node-opcua.github.io/",
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "3cd6d355e8b3c66822d08a3ca682659ea5d1a55d",
|
|
56
56
|
"files": [
|
|
57
57
|
"dist",
|
|
58
58
|
"source"
|
package/source/_dataType.ts
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
getSubtypeNodeId
|
|
16
16
|
} from "./private-stuff";
|
|
17
17
|
import { Cache, makeName2 } from "./private/cache";
|
|
18
|
-
import {
|
|
18
|
+
import { getCorrespondingJavascriptType } from "./private/get_corresponding_data_type";
|
|
19
19
|
import { f1, f2, quotifyIfNecessary, toComment, toJavascritPropertyName } from "./utils2";
|
|
20
20
|
|
|
21
21
|
// eslint-disable-next-line max-statements, complexity
|
|
@@ -154,7 +154,7 @@ export async function _exportDataTypeToTypescript(
|
|
|
154
154
|
}
|
|
155
155
|
const opt = field.isOptional ? "?" : "";
|
|
156
156
|
const arrayMarker = field.valueRank >= 1 ? "[]" : "";
|
|
157
|
-
const { dataType, jtype } = await
|
|
157
|
+
const { dataType, jtype } = await getCorrespondingJavascriptType(session, field.dataType, cache, importCollector);
|
|
158
158
|
f.write(
|
|
159
159
|
` ${quotifyIfNecessary(fieldName)}${opt}: ${jtype}${arrayMarker}; // ${
|
|
160
160
|
DataType[dataType]
|
|
@@ -204,7 +204,12 @@ async function _output_tsconfig_json(info: Info, options: Options): Promise<void
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
async function outputFiles(infos: { [key: string]: Info }, options: Options) {
|
|
207
|
-
|
|
207
|
+
const values = Object.values(infos) as Info[];
|
|
208
|
+
if (values.length < 1) {
|
|
209
|
+
console.log(`There is no type information to generate for ${options.nsName}`)
|
|
210
|
+
}
|
|
211
|
+
console.log("generating files for ", options.nsName);
|
|
212
|
+
for (const info of values) {
|
|
208
213
|
// create indexes
|
|
209
214
|
await _output_index_ts_file(info);
|
|
210
215
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable max-depth */
|
|
2
|
-
import
|
|
2
|
+
import chalk from "chalk";
|
|
3
3
|
import { LocalizedText, NodeClass, QualifiedName } from "node-opcua-data-model";
|
|
4
4
|
import { NodeId } from "node-opcua-nodeid";
|
|
5
5
|
import { IBasicSession } from "node-opcua-pseudo-session";
|
|
@@ -46,7 +46,7 @@ import { Options } from "./options";
|
|
|
46
46
|
import { toFilename } from "./private/to_filename";
|
|
47
47
|
import { f1, f2, quotifyIfNecessary, toComment, toJavascritPropertyName } from "./utils2";
|
|
48
48
|
import { _exportDataTypeToTypescript } from "./_dataType";
|
|
49
|
-
import {
|
|
49
|
+
import { getCorrespondingJavascriptType2 } from "./private/get_corresponding_data_type";
|
|
50
50
|
const warningLog = make_warningLog("typescript");
|
|
51
51
|
const doDebug = false;
|
|
52
52
|
const baseExtension = "_Base";
|
|
@@ -137,7 +137,7 @@ export async function extractClassDefinition(session: IBasicSession, nodeId: Nod
|
|
|
137
137
|
extraImports.push(i);
|
|
138
138
|
cache.ensureImported(i);
|
|
139
139
|
};
|
|
140
|
-
const { jtype } = await
|
|
140
|
+
const { jtype } = await getCorrespondingJavascriptType2(session, nodeId, dataTypeNodeId!, cache, importCollector);
|
|
141
141
|
dataTypeName = jtype; // with decoration
|
|
142
142
|
if (!dataTypeNodeId?.isEmpty()) {
|
|
143
143
|
// "DT" + (await getBrowseName(session, dataTypeNodeId!))?.name! || "";
|
|
@@ -445,7 +445,7 @@ async function extractVariableExtra(session: IBasicSession, nodeId: NodeId, cach
|
|
|
445
445
|
if (nodeClass === NodeClass.Variable) {
|
|
446
446
|
const dataTypeNodeId = await getDataTypeNodeId(session, nodeId);
|
|
447
447
|
|
|
448
|
-
const { dataType, jtype } = await
|
|
448
|
+
const { dataType, jtype } = await getCorrespondingJavascriptType2(session, nodeId, dataTypeNodeId!, cache, importCollector);
|
|
449
449
|
|
|
450
450
|
cache && cache.referenceBasicType("DataType");
|
|
451
451
|
importCollector({ name: "DataType", namespace: -1, module: "BasicType" });
|
|
@@ -749,7 +749,6 @@ function dumpUsedExport(currentType: string, namespaceIndex: number, cache: Cach
|
|
|
749
749
|
return f.toString();
|
|
750
750
|
}
|
|
751
751
|
|
|
752
|
-
|
|
753
752
|
export type Type = "enum" | "basic" | "structure" | "ua";
|
|
754
753
|
|
|
755
754
|
function calculateChevrons(classDef: ClassDefinition, classDefDerived?: { dataType: DataType }) {
|
|
@@ -868,6 +867,7 @@ export async function _convertTypeToTypescript(
|
|
|
868
867
|
|
|
869
868
|
await preDumpChildren(" ", classDef, f, cache);
|
|
870
869
|
|
|
870
|
+
const n =(n?: NodeId |null)=> n?.toString().replace(/ns=([0-9]+);/, "");
|
|
871
871
|
// f.write(superType.toString());
|
|
872
872
|
f.write(`/**`);
|
|
873
873
|
if (description.text) {
|
|
@@ -878,10 +878,10 @@ export async function _convertTypeToTypescript(
|
|
|
878
878
|
f.write(` * |----------------|${f2("-")}|`);
|
|
879
879
|
f.write(` * |namespace |${f1(cache.namespace[nodeId.namespace].namespaceUri)}|`);
|
|
880
880
|
f.write(` * |nodeClass |${f1(NodeClass[nodeClass])}|`);
|
|
881
|
-
f.write(` * |typedDefinition |${f1(browseName.toString() + " " + nodeId
|
|
881
|
+
f.write(` * |typedDefinition |${f1(browseName.name!.toString() + " " + n(nodeId))}|`);
|
|
882
882
|
if (nodeClass === NodeClass.VariableType) {
|
|
883
883
|
f.write(` * |dataType |${f1(DataType[dataType])}|`);
|
|
884
|
-
f.write(` * |dataType Name |${f1(dataTypeName + " " + dataTypeNodeId
|
|
884
|
+
f.write(` * |dataType Name |${f1(dataTypeName + " " + n(dataTypeNodeId))}|`);
|
|
885
885
|
}
|
|
886
886
|
f.write(` * |isAbstract |${f1(isAbstract.toString())}|`);
|
|
887
887
|
f.write(` */`);
|
|
@@ -914,7 +914,7 @@ export async function _convertTypeToTypescript(
|
|
|
914
914
|
//
|
|
915
915
|
const baseName = `${baseInterfaceName?.name}${baseExtension}${chevronsBase.chevronsExtend}`;
|
|
916
916
|
f.write(`export type ${classBaseName} = ${baseName};`);
|
|
917
|
-
}
|
|
917
|
+
} else {
|
|
918
918
|
if (baseInterfaceName?.name === "UAVariableT") {
|
|
919
919
|
f.write(`export interface ${classBaseName} {`);
|
|
920
920
|
} else {
|
package/source/main.ts
CHANGED
|
@@ -1,91 +1,25 @@
|
|
|
1
1
|
import * as 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 { allNodesetMeta } from "node-opcua-nodesets";
|
|
5
5
|
import { convertNamespaceTypeToTypescript } from "./convert_namespace_to_typescript";
|
|
6
|
+
import { updateParentTSConfig } from './update_parent_tsconfig';
|
|
6
7
|
|
|
7
8
|
async function main() {
|
|
8
9
|
const addressSpace = AddressSpace.create();
|
|
9
|
-
await generateAddressSpace(addressSpace,
|
|
10
|
-
nodesets.standard,
|
|
11
|
-
nodesets.di,
|
|
12
|
-
nodesets.adi,
|
|
13
|
-
nodesets.autoId,
|
|
14
|
-
nodesets.machineVision,
|
|
15
|
-
nodesets.commercialKitchenEquipment,
|
|
16
|
-
nodesets.gds,
|
|
17
|
-
nodesets.robotics,
|
|
18
|
-
nodesets.machinery,
|
|
19
|
-
nodesets.ia,
|
|
20
|
-
nodesets.machineTool,
|
|
21
|
-
nodesets.cnc,
|
|
22
|
-
nodesets.woodWorking,
|
|
23
|
-
nodesets.glass,
|
|
24
|
-
nodesets.tightening,
|
|
25
|
-
nodesets.packML,
|
|
26
|
-
nodesets.eumabois,
|
|
27
|
-
nodesets.iolink,
|
|
28
|
-
nodesets.iolinkIODD,
|
|
29
|
-
nodesets.irdi,
|
|
30
|
-
nodesets.padim,
|
|
31
|
-
nodesets.machineryProcessValues,
|
|
32
|
-
nodesets.machineryResult,
|
|
33
|
-
]);
|
|
34
|
-
const nsUA = 0;
|
|
35
|
-
const nsDI = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/DI/");
|
|
36
|
-
const nsADI = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/ADI/");
|
|
37
|
-
const nsMachineVision = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/MachineVision");
|
|
38
|
-
const nsAutoId = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/AutoID/");
|
|
39
|
-
const nsGds = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/GDS/");
|
|
40
|
-
const nsRobotics = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/Robotics/");
|
|
41
|
-
const nsMachinery = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/Machinery/");
|
|
42
|
-
const nsIA = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/IA/");
|
|
43
|
-
const nsMachineTool = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/MachineTool/");
|
|
44
|
-
const ncCNC = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/CNC");
|
|
45
|
-
const nsCommercialKitchenEquipment = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/CommercialKitchenEquipment/");
|
|
46
|
-
const nsWW = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/Woodworking/");
|
|
47
|
-
const nsGlass = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/Glass/Flat/");
|
|
48
|
-
const nsTightening = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/IJT/");
|
|
49
|
-
const nsPackML = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/PackML/");
|
|
50
|
-
const nsEumabois = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/Eumabois/");
|
|
51
|
-
const nsIOLink = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/IOLink/");
|
|
52
|
-
const nsIOLinkIODD = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/IOLink/IODD/");
|
|
53
|
-
const nsIRDI = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/Dictionary/IRDI");
|
|
54
|
-
const nsPADIM = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/PADIM/");
|
|
55
|
-
const nsMachineryProcessValues = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/Machinery/ProcessValues/");
|
|
56
|
-
const nsMachineryResult = addressSpace.getNamespaceIndex("http://opcfoundation.org/UA/Machinery/Result/");
|
|
10
|
+
await generateAddressSpace(addressSpace, allNodesetMeta.map((set) => set.xmlFile));
|
|
57
11
|
|
|
58
12
|
const session = new PseudoSession(addressSpace);
|
|
59
13
|
const options = {
|
|
60
14
|
baseFolder: path.join(__dirname, "../../"),
|
|
61
15
|
prefix: "node-opcua-nodeset-"
|
|
62
16
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
convertNamespaceTypeToTypescript(session, nsGds, options),
|
|
71
|
-
convertNamespaceTypeToTypescript(session, nsRobotics, options),
|
|
72
|
-
convertNamespaceTypeToTypescript(session, nsMachinery, options),
|
|
73
|
-
convertNamespaceTypeToTypescript(session, nsIA, options),
|
|
74
|
-
convertNamespaceTypeToTypescript(session, nsMachineTool, options),
|
|
75
|
-
convertNamespaceTypeToTypescript(session, ncCNC, options),
|
|
76
|
-
convertNamespaceTypeToTypescript(session, nsCommercialKitchenEquipment, options),
|
|
77
|
-
convertNamespaceTypeToTypescript(session, nsWW, options),
|
|
78
|
-
convertNamespaceTypeToTypescript(session, nsGlass, options),
|
|
79
|
-
convertNamespaceTypeToTypescript(session, nsTightening, options),
|
|
80
|
-
convertNamespaceTypeToTypescript(session, nsPackML, options),
|
|
81
|
-
convertNamespaceTypeToTypescript(session, nsEumabois, options),
|
|
82
|
-
convertNamespaceTypeToTypescript(session, nsIOLink, options),
|
|
83
|
-
convertNamespaceTypeToTypescript(session, nsIOLinkIODD, options),
|
|
84
|
-
convertNamespaceTypeToTypescript(session, nsIRDI, options),
|
|
85
|
-
convertNamespaceTypeToTypescript(session, nsPADIM, options),
|
|
86
|
-
convertNamespaceTypeToTypescript(session, nsMachineryProcessValues, options),
|
|
87
|
-
convertNamespaceTypeToTypescript(session, nsMachineryResult, options),
|
|
88
|
-
];
|
|
89
|
-
await Promise.all(promises);
|
|
17
|
+
await Promise.all(allNodesetMeta.map((meta) =>
|
|
18
|
+
convertNamespaceTypeToTypescript(session, addressSpace.getNamespaceIndex(meta.uri), {
|
|
19
|
+
...options,
|
|
20
|
+
nsName: meta.name,
|
|
21
|
+
})
|
|
22
|
+
));
|
|
23
|
+
await updateParentTSConfig();
|
|
90
24
|
}
|
|
91
25
|
void main();
|
package/source/options.ts
CHANGED
|
@@ -5,20 +5,20 @@ import { Import, referenceEnumeration, referenceExtensionObject } from "./cache"
|
|
|
5
5
|
import { getValueRank, _convertNodeIdToDataTypeAsync } from "./utils";
|
|
6
6
|
import { Cache } from "./cache";
|
|
7
7
|
|
|
8
|
-
export async function
|
|
8
|
+
export async function getCorrespondingJavascriptType2(
|
|
9
9
|
session: IBasicSession,
|
|
10
10
|
nodeId: NodeId,
|
|
11
11
|
dataTypeNodeId: NodeId,
|
|
12
12
|
cache: Cache,
|
|
13
13
|
importCollect?: (t: Import) => void
|
|
14
14
|
): Promise<{ dataType: DataType; jtype: string }> {
|
|
15
|
-
const q = await
|
|
15
|
+
const q = await getCorrespondingJavascriptType(session, dataTypeNodeId, cache, importCollect);
|
|
16
16
|
const valueRank = await getValueRank(session, nodeId);
|
|
17
17
|
return { dataType: q.dataType, jtype: q.jtype + (valueRank >= 1 ? "[]" : "") };
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
// eslint-disable-next-line complexity
|
|
21
|
-
export async function
|
|
21
|
+
export async function getCorrespondingJavascriptType(
|
|
22
22
|
session: IBasicSession,
|
|
23
23
|
dataTypeNodeId: NodeId,
|
|
24
24
|
cache: Cache,
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Purpose of this script is to help ensure that "references" array in packages/tsconfig.json
|
|
2
|
+
// stays up-to-date with nodeset package list.
|
|
3
|
+
|
|
4
|
+
import { existsSync, promises as fsPromises } from 'fs';
|
|
5
|
+
const { readFile, writeFile } = fsPromises;
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
// Uncomment the following to get __dirname equivalent when compiling to ESM
|
|
8
|
+
//import { fileURLToPath } from 'url';
|
|
9
|
+
//const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
import { allNodesetMeta } from "node-opcua-nodesets";
|
|
12
|
+
|
|
13
|
+
export async function updateParentTSConfig() {
|
|
14
|
+
const packagesFolder = path.join(__dirname, '..', '..');
|
|
15
|
+
const parentTSConfigFile = path.join(packagesFolder, 'tsconfig.json');
|
|
16
|
+
const parentTSConfig = JSON.parse(
|
|
17
|
+
// Strip out comments to avoid JSON parsing error
|
|
18
|
+
// TODO: Preserve comments automatically
|
|
19
|
+
(await readFile(parentTSConfigFile, 'utf8'))
|
|
20
|
+
.replace(/\/\*.+?\*\//g, '')
|
|
21
|
+
.replace(/\/\/.+?$/g, '')
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
type TSConfigReference = { path: string };
|
|
25
|
+
const unlistedReferences: TSConfigReference[] = [];
|
|
26
|
+
for (const meta of allNodesetMeta) {
|
|
27
|
+
const nodesetPackageFolder = path.join(packagesFolder, meta.packageName);
|
|
28
|
+
if (!existsSync(nodesetPackageFolder)) {
|
|
29
|
+
console.log(`Ignoring ${meta.packageName} since package folder does not exist (${nodesetPackageFolder})`);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (!parentTSConfig.references.some((ref: TSConfigReference) => ref.path === meta.packageName)) {
|
|
33
|
+
console.log(`Found nodeset package that was not listed in tsconfig.json: ${meta.packageName}`);
|
|
34
|
+
unlistedReferences.push({ path: meta.packageName });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function compareByPath(a: TSConfigReference, b: TSConfigReference) {
|
|
39
|
+
if (a.path < b.path) { return -1; }
|
|
40
|
+
if (a.path > b.path) { return 1; }
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (unlistedReferences.length > 0) {
|
|
45
|
+
parentTSConfig.references.push(...unlistedReferences);
|
|
46
|
+
parentTSConfig.references.sort(compareByPath);
|
|
47
|
+
// Maintain the compact style `{ "path": "node-opcua-X" }` in references section
|
|
48
|
+
// Also add the comment about Istanbul back
|
|
49
|
+
const newJSON = JSON.stringify(parentTSConfig, null, " ")
|
|
50
|
+
.replace('"removeComments": false', '"removeComments": false /* to prevent Istanbul ignore statements in comments from disappearing */')
|
|
51
|
+
.replace(/{\s*"path":\s*"([^"]+)"\s*}/g, '{ "path": "$1" }')
|
|
52
|
+
+ '\n';
|
|
53
|
+
//console.log('Writing updated tsconfig.json file:', newJSON);
|
|
54
|
+
await writeFile(parentTSConfigFile, newJSON, 'utf8');
|
|
55
|
+
}
|
|
56
|
+
}
|
package/source/utils2.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { lowerFirstLetter } from "node-opcua-utils";
|
|
2
|
-
import
|
|
2
|
+
import wrap from "wordwrap";
|
|
3
3
|
|
|
4
4
|
const wrapText = wrap(0, 50);
|
|
5
5
|
|
|
@@ -51,5 +51,5 @@ export function quotifyIfNecessary(s: string): string {
|
|
|
51
51
|
return s;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export const f2 = (str: string) => str.padEnd(
|
|
55
|
-
export const f1 = (str: string) => str.padEnd(
|
|
54
|
+
export const f2 = (str: string) => str.padEnd(60, "-");
|
|
55
|
+
export const f1 = (str: string) => str.padEnd(60, " ");
|
package/source/walk_through.ts
CHANGED
|
@@ -59,15 +59,16 @@ export async function walkThroughDataTypes(session: IBasicSession, nodeVisitor?:
|
|
|
59
59
|
const baseDataTypeTypeNodeId = resolveNodeId("BaseDataType");
|
|
60
60
|
await _walkThroughTypes(session, baseDataTypeTypeNodeId, nodeVisitor);
|
|
61
61
|
}
|
|
62
|
+
|
|
62
63
|
export async function walkThroughInterfaceTypes(session: IBasicSession, nodeVisitor?: NodeVisitor): Promise<void> {
|
|
63
64
|
const baseInterfaceTypeNodeId = resolveNodeId("BaseInterfaceType");
|
|
64
65
|
await _walkThroughTypes(session, baseInterfaceTypeNodeId, nodeVisitor);
|
|
65
66
|
}
|
|
66
67
|
export async function walkThroughObjectTypes(session: IBasicSession, nodeVisitor?: NodeVisitor): Promise<void> {
|
|
67
|
-
const
|
|
68
|
-
await _walkThroughTypes(session,
|
|
68
|
+
const baseObjectTypeNodeId = resolveNodeId("BaseObjectType");
|
|
69
|
+
await _walkThroughTypes(session, baseObjectTypeNodeId, nodeVisitor);
|
|
69
70
|
}
|
|
70
71
|
export async function walkThroughVariableTypes(session: IBasicSession, nodeVisitor?: NodeVisitor): Promise<void> {
|
|
71
|
-
const
|
|
72
|
-
await _walkThroughTypes(session,
|
|
72
|
+
const baseObjectTypeNodeId = resolveNodeId("BaseVariableType");
|
|
73
|
+
await _walkThroughTypes(session, baseObjectTypeNodeId, nodeVisitor);
|
|
73
74
|
}
|