@t0.labs/daxta 1.1.4 → 1.1.5
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/fields/dto-fields.js +42 -22
- package/package.json +2 -2
|
@@ -43,6 +43,7 @@ exports.dtoRequired = dtoRequired;
|
|
|
43
43
|
* only to read reflect-metadata / class-validator / class-transformer.
|
|
44
44
|
*/
|
|
45
45
|
const fs_1 = require("fs");
|
|
46
|
+
const module_1 = require("module");
|
|
46
47
|
const path = __importStar(require("path"));
|
|
47
48
|
require("reflect-metadata");
|
|
48
49
|
const storage_1 = require("class-transformer/cjs/storage");
|
|
@@ -50,31 +51,48 @@ const class_validator_1 = require("class-validator");
|
|
|
50
51
|
const tsImport = __importStar(require("typescript"));
|
|
51
52
|
const config_1 = require("../config");
|
|
52
53
|
const path_util_1 = require("../path.util");
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
let ts;
|
|
55
|
+
let tsResolved;
|
|
56
|
+
function withCompilerApi(candidate) {
|
|
57
|
+
const mod = candidate;
|
|
58
|
+
if (mod && typeof mod.createSourceFile === 'function')
|
|
59
|
+
return mod;
|
|
60
|
+
if (mod?.default && typeof mod.default.createSourceFile === 'function')
|
|
61
|
+
return mod.default;
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
function resolveTypescript() {
|
|
65
|
+
const direct = withCompilerApi(tsImport);
|
|
66
|
+
if (direct)
|
|
67
|
+
return direct;
|
|
68
|
+
// A hoisted copy can be the native TS 7 build, which ships a reduced JS surface
|
|
69
|
+
// without createSourceFile. Fall back to whatever the host project installed.
|
|
70
|
+
for (const from of [process.cwd(), __dirname]) {
|
|
71
|
+
try {
|
|
72
|
+
const loaded = (0, module_1.createRequire)(path.join(from, 'index.js'))('typescript');
|
|
73
|
+
const usable = withCompilerApi(loaded);
|
|
74
|
+
if (usable)
|
|
75
|
+
return usable;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// keep looking
|
|
79
|
+
}
|
|
71
80
|
}
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
/** Controller parsing is best-effort: without a usable compiler API we skip it. */
|
|
84
|
+
function ensureTypescript() {
|
|
85
|
+
if (tsResolved === undefined) {
|
|
86
|
+
tsResolved = resolveTypescript();
|
|
87
|
+
if (!tsResolved) {
|
|
88
|
+
console.warn('DAxTA: TypeScript compiler API unavailable (needs typescript >=4.9 <7) — skipping controller parsing; required/optional flags will be omitted.');
|
|
89
|
+
}
|
|
74
90
|
}
|
|
75
|
-
|
|
91
|
+
if (!tsResolved)
|
|
92
|
+
return false;
|
|
93
|
+
ts = tsResolved;
|
|
94
|
+
return true;
|
|
76
95
|
}
|
|
77
|
-
const ts = loadTypescript();
|
|
78
96
|
function controllerRoot() {
|
|
79
97
|
return (0, config_1.getConfig)().controllersRoot;
|
|
80
98
|
}
|
|
@@ -292,6 +310,8 @@ function parseController(filePath) {
|
|
|
292
310
|
function getRoutes() {
|
|
293
311
|
if (routeCache)
|
|
294
312
|
return routeCache;
|
|
313
|
+
if (!ensureTypescript())
|
|
314
|
+
return (routeCache = []);
|
|
295
315
|
const files = walkFiles(controllerRoot(), '.controller.ts');
|
|
296
316
|
routeCache = files.flatMap((file) => {
|
|
297
317
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t0.labs/daxta",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "DAxTA — Tested behavior. Trusted API docs. Generate API documentation from observed test execution.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"class-transformer": ">=0.5.0",
|
|
79
79
|
"class-validator": ">=0.14.0",
|
|
80
80
|
"reflect-metadata": ">=0.1.13",
|
|
81
|
-
"typescript": ">=4.9.0",
|
|
81
|
+
"typescript": ">=4.9.0 <7",
|
|
82
82
|
"jest": ">=27"
|
|
83
83
|
},
|
|
84
84
|
"peerDependenciesMeta": {
|