@adonisjs/assembler 8.0.0-next.21 → 8.0.0-next.23
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/build/helpers-DDurYRsZ.js +72 -0
- package/build/index.js +916 -1665
- package/build/main-1eXSE5Xo.js +185 -0
- package/build/main-Byxt3AdL.js +240 -0
- package/build/src/code_scanners/routes_scanner/main.js +4 -8
- package/build/src/code_transformer/main.js +276 -622
- package/build/src/debug.d.ts +1 -1
- package/build/src/helpers.js +2 -16
- package/build/src/index_generator/main.js +3 -7
- package/build/src/types/main.js +1 -0
- package/build/virtual_file_system-DM1KRNbk.js +283 -0
- package/package.json +28 -25
- package/build/chunk-JFBQ4OEM.js +0 -434
- package/build/chunk-NAASGAFO.js +0 -478
- package/build/chunk-NR7VMFWO.js +0 -468
- package/build/chunk-TIKQQRMX.js +0 -116
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { f as throttle, l as removeExtension, m as debug_default, t as VirtualFileSystem } from "./virtual_file_system-DM1KRNbk.js";
|
|
2
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import string from "@poppinss/utils/string";
|
|
4
|
+
import { dirname, join, relative } from "node:path/posix";
|
|
5
|
+
import StringBuilder from "@poppinss/utils/string_builder";
|
|
6
|
+
var FileBuffer = class FileBuffer {
|
|
7
|
+
#eol = false;
|
|
8
|
+
#buffer = [];
|
|
9
|
+
#identationSize = 0;
|
|
10
|
+
#compiledOutput;
|
|
11
|
+
create() {
|
|
12
|
+
return new FileBuffer();
|
|
13
|
+
}
|
|
14
|
+
get size() {
|
|
15
|
+
return this.#buffer.length;
|
|
16
|
+
}
|
|
17
|
+
eol(enabled) {
|
|
18
|
+
this.#eol = enabled;
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
writeLine(text) {
|
|
22
|
+
if (typeof text === "string") this.#buffer.push(`${" ".repeat(this.#identationSize)}${text}\n`);
|
|
23
|
+
else {
|
|
24
|
+
this.#buffer.push(text);
|
|
25
|
+
this.#buffer.push("");
|
|
26
|
+
}
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
write(text) {
|
|
30
|
+
if (typeof text === "string") this.#buffer.push(`${" ".repeat(this.#identationSize)}${text}`);
|
|
31
|
+
else this.#buffer.push(text);
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
indent() {
|
|
35
|
+
this.#identationSize += 2;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
dedent() {
|
|
39
|
+
this.#identationSize -= 2;
|
|
40
|
+
if (this.#identationSize < 0) this.#identationSize = 0;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
toString() {
|
|
44
|
+
return this.flush();
|
|
45
|
+
}
|
|
46
|
+
flush() {
|
|
47
|
+
if (this.#compiledOutput !== void 0) return this.#compiledOutput;
|
|
48
|
+
this.#compiledOutput = this.#buffer.join("\n");
|
|
49
|
+
return this.#eol ? `${this.#compiledOutput}\n` : this.#compiledOutput;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var IndexGeneratorSource = class {
|
|
53
|
+
#appRoot;
|
|
54
|
+
#output;
|
|
55
|
+
#source;
|
|
56
|
+
#outputDirname;
|
|
57
|
+
#vfs;
|
|
58
|
+
#config;
|
|
59
|
+
#cliLogger;
|
|
60
|
+
#generateOutput = throttle(async () => {
|
|
61
|
+
const buffer = new FileBuffer().eol(true);
|
|
62
|
+
if (this.#config.as === "barrelFile") this.#asBarrelFile(this.#vfs, buffer, this.#config.exportName, this.#config.disableLazyImports);
|
|
63
|
+
else this.#config.as(this.#vfs, buffer, this.#config, { toImportPath: this.#createBarrelFileImportGenerator(this.#source, this.#outputDirname, this.#config) });
|
|
64
|
+
await mkdir(dirname(this.#output), { recursive: true });
|
|
65
|
+
await writeFile(this.#output, buffer.flush());
|
|
66
|
+
});
|
|
67
|
+
name;
|
|
68
|
+
constructor(name, appRoot, cliLogger, config) {
|
|
69
|
+
this.name = name;
|
|
70
|
+
this.#config = config;
|
|
71
|
+
this.#appRoot = appRoot;
|
|
72
|
+
this.#cliLogger = cliLogger;
|
|
73
|
+
this.#source = join(this.#appRoot, this.#config.source);
|
|
74
|
+
this.#output = join(this.#appRoot, this.#config.output);
|
|
75
|
+
this.#outputDirname = dirname(this.#output);
|
|
76
|
+
this.#vfs = new VirtualFileSystem(this.#source, { glob: this.#config.glob });
|
|
77
|
+
}
|
|
78
|
+
#treeToString(input, buffer) {
|
|
79
|
+
Object.keys(input).forEach((key) => {
|
|
80
|
+
const value = input[key];
|
|
81
|
+
if (typeof value === "string") buffer.write(`${key}: ${value},`);
|
|
82
|
+
else {
|
|
83
|
+
buffer.write(`${key}: {`).indent();
|
|
84
|
+
this.#treeToString(value, buffer);
|
|
85
|
+
buffer.dedent().write(`},`);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
#createBarrelFileKeyGenerator(config) {
|
|
90
|
+
return function(key) {
|
|
91
|
+
let paths = key.split("/");
|
|
92
|
+
let baseName = new StringBuilder(paths.pop());
|
|
93
|
+
if (config.skipSegments?.length) paths = paths.filter((p) => !config.skipSegments.includes(p));
|
|
94
|
+
if (config.computeBaseName) baseName = config.computeBaseName(baseName);
|
|
95
|
+
else baseName = baseName.removeSuffix(config.removeSuffix ?? "").pascalCase();
|
|
96
|
+
return [...paths.map((p) => string.camelCase(p)), baseName.toString()].join("/");
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
#createBarrelFileImportGenerator(source, outputDirname, config) {
|
|
100
|
+
return function(filePath) {
|
|
101
|
+
if (config.importAlias) {
|
|
102
|
+
debug_default("converting \"%s\" to import alias, source \"%s\"", filePath, source);
|
|
103
|
+
return removeExtension(filePath.replace(source, config.importAlias));
|
|
104
|
+
}
|
|
105
|
+
debug_default("converting \"%s\" to relative import, source \"%s\"", filePath, outputDirname);
|
|
106
|
+
return relative(outputDirname, filePath);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
#asBarrelFile(vfs, buffer, exportName, disableLazyImports) {
|
|
110
|
+
const useEagerImports = disableLazyImports === true ? true : false;
|
|
111
|
+
const keyGenerator = this.#createBarrelFileKeyGenerator(this.#config);
|
|
112
|
+
const importsBuffer = buffer.create();
|
|
113
|
+
const importGenerator = this.#createBarrelFileImportGenerator(this.#source, this.#outputDirname, this.#config);
|
|
114
|
+
const tree = vfs.asTree({
|
|
115
|
+
transformKey: keyGenerator,
|
|
116
|
+
transformValue: (filePath, key) => {
|
|
117
|
+
if (useEagerImports) {
|
|
118
|
+
const importKey = new StringBuilder(key).pascalCase().toString();
|
|
119
|
+
importsBuffer.write(`import ${importKey} from '${importGenerator(filePath)}'`);
|
|
120
|
+
return importKey;
|
|
121
|
+
}
|
|
122
|
+
return `() => import('${importGenerator(filePath)}')`;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
if (!Object.keys(tree).length) {
|
|
126
|
+
buffer.write(`export const ${exportName} = {}`);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (useEagerImports) buffer.writeLine(importsBuffer);
|
|
130
|
+
buffer.write(`export const ${exportName} = {`).indent();
|
|
131
|
+
this.#treeToString(tree, buffer);
|
|
132
|
+
buffer.dedent().write(`}`);
|
|
133
|
+
}
|
|
134
|
+
#logCreation(startTime) {
|
|
135
|
+
this.#cliLogger.info(`created ${this.#config.output}`, { startTime });
|
|
136
|
+
}
|
|
137
|
+
async addFile(filePath) {
|
|
138
|
+
if (this.#vfs.add(filePath)) {
|
|
139
|
+
debug_default("file added, re-generating \"%s\" index", this.name);
|
|
140
|
+
const startTime = process.hrtime();
|
|
141
|
+
await this.#generateOutput();
|
|
142
|
+
this.#logCreation(startTime);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async removeFile(filePath) {
|
|
146
|
+
if (this.#vfs.remove(filePath)) {
|
|
147
|
+
debug_default("file removed, re-generating \"%s\" index", this.name);
|
|
148
|
+
const startTime = process.hrtime();
|
|
149
|
+
await this.#generateOutput();
|
|
150
|
+
this.#logCreation(startTime);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async generate() {
|
|
154
|
+
const startTime = process.hrtime();
|
|
155
|
+
await this.#vfs.scan();
|
|
156
|
+
await this.#generateOutput();
|
|
157
|
+
this.#logCreation(startTime);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
var IndexGenerator = class {
|
|
161
|
+
appRoot;
|
|
162
|
+
#sources = {};
|
|
163
|
+
#cliLogger;
|
|
164
|
+
constructor(appRoot, cliLogger) {
|
|
165
|
+
this.appRoot = appRoot;
|
|
166
|
+
this.#cliLogger = cliLogger;
|
|
167
|
+
}
|
|
168
|
+
add(name, config) {
|
|
169
|
+
this.#sources[name] = new IndexGeneratorSource(name, this.appRoot, this.#cliLogger, config);
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
async addFile(filePath) {
|
|
173
|
+
const sources = Object.values(this.#sources);
|
|
174
|
+
for (let source of sources) await source.addFile(filePath);
|
|
175
|
+
}
|
|
176
|
+
async removeFile(filePath) {
|
|
177
|
+
const sources = Object.values(this.#sources);
|
|
178
|
+
for (let source of sources) await source.removeFile(filePath);
|
|
179
|
+
}
|
|
180
|
+
async generate() {
|
|
181
|
+
const sources = Object.values(this.#sources);
|
|
182
|
+
for (let source of sources) await source.generate();
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
export { FileBuffer as n, IndexGenerator as t };
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { i as isRelative, m as debug_default, t as VirtualFileSystem } from "./virtual_file_system-DM1KRNbk.js";
|
|
2
|
+
import { a as nodeToPlainText, i as inspectMethodArguments, n as inspectClass, o as searchValidatorDirectUsage, r as inspectClassMethods, t as findImport } from "./helpers-DDurYRsZ.js";
|
|
3
|
+
import { cliui } from "@poppinss/cliui";
|
|
4
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
|
+
import string from "@poppinss/utils/string";
|
|
6
|
+
import { join, relative } from "node:path";
|
|
7
|
+
import StringBuilder from "@poppinss/utils/string_builder";
|
|
8
|
+
import { parseImports } from "parse-imports";
|
|
9
|
+
import { resolve } from "import-meta-resolve";
|
|
10
|
+
var PathsResolver = class {
|
|
11
|
+
#appRoot;
|
|
12
|
+
#resolvedPaths = {};
|
|
13
|
+
#resolver = (specifier, parentPath) => resolve(specifier, parentPath);
|
|
14
|
+
constructor(appRoot) {
|
|
15
|
+
this.#appRoot = pathToFileURL(join(appRoot, "index.js")).href;
|
|
16
|
+
}
|
|
17
|
+
use(resolver) {
|
|
18
|
+
this.#resolver = resolver;
|
|
19
|
+
}
|
|
20
|
+
resolve(specifier, rewriteAliasImportExtension = false) {
|
|
21
|
+
if (isRelative(specifier)) throw new Error("Cannot resolve relative paths using PathsResolver");
|
|
22
|
+
const cacheKey = specifier;
|
|
23
|
+
const cached = this.#resolvedPaths[cacheKey];
|
|
24
|
+
if (cached) return cached;
|
|
25
|
+
let resolvedPath = fileURLToPath(this.#resolver(specifier, this.#appRoot));
|
|
26
|
+
if (rewriteAliasImportExtension && specifier.startsWith("#") && resolvedPath.endsWith(".js")) resolvedPath = resolvedPath.replace(/\.js$/, ".ts");
|
|
27
|
+
this.#resolvedPaths[cacheKey] = resolvedPath;
|
|
28
|
+
return this.#resolvedPaths[cacheKey];
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
async function extractValidators(appRoot, vfs, controller) {
|
|
32
|
+
const root = await vfs.get(controller.path);
|
|
33
|
+
const fileContents = root.text();
|
|
34
|
+
const controllerClass = inspectClass(root);
|
|
35
|
+
if (!controllerClass) {
|
|
36
|
+
debug_default(`No class defined within the "%s"`, controller.import.specifier);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const method = inspectClassMethods(controllerClass).find((methodNode) => {
|
|
40
|
+
return methodNode.find({ rule: { kind: "property_identifier" } })?.text() === controller.method;
|
|
41
|
+
});
|
|
42
|
+
if (!method) {
|
|
43
|
+
debug_default(`Unable to find "%s" method in "%s"`, controller.method, controller.import.specifier);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const validationCalls = inspectMethodArguments(method, ["request.validateUsing", "vine.validate"]).map((node) => {
|
|
47
|
+
const firstArg = node.find({ rule: { any: [{ kind: "identifier" }, { kind: "member_expression" }] } });
|
|
48
|
+
if (!firstArg) return;
|
|
49
|
+
return nodeToPlainText(firstArg);
|
|
50
|
+
}).filter((node) => node !== void 0).concat(searchValidatorDirectUsage(method).map((node) => nodeToPlainText(node)));
|
|
51
|
+
if (!validationCalls.length) {
|
|
52
|
+
debug_default(`Unable to detect any validation calls in "%s.%s" method`, controller.import.specifier, controller.method);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const controllerName = controllerClass.find({ rule: { kind: "type_identifier" } }).text();
|
|
56
|
+
const controllerURL = pathToFileURL(controller.path);
|
|
57
|
+
return (await Promise.all(validationCalls.map(async (validationCall) => {
|
|
58
|
+
if (validationCall.split(".")[0] === controllerName) return {
|
|
59
|
+
name: validationCall,
|
|
60
|
+
import: {
|
|
61
|
+
specifier: controller.import.specifier,
|
|
62
|
+
type: "default",
|
|
63
|
+
value: controllerName
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const importCall = await findImport(fileContents, validationCall);
|
|
67
|
+
if (!importCall) {
|
|
68
|
+
debug_default("Unable to find import for \"%s\" used by \"%s.%s\" method", validationCall, controller.import.specifier, controller.method);
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
name: validationCall,
|
|
73
|
+
import: {
|
|
74
|
+
specifier: isRelative(importCall.specifier) ? string.toUnixSlash(relative(appRoot, fileURLToPath(new URL(importCall.specifier, controllerURL)))) : importCall.specifier,
|
|
75
|
+
type: importCall.clause.type,
|
|
76
|
+
value: importCall.clause.value
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}))).filter((value) => !!value);
|
|
80
|
+
}
|
|
81
|
+
var RoutesScanner = class {
|
|
82
|
+
#appRoot;
|
|
83
|
+
#controllerRoutes = {};
|
|
84
|
+
#scannedRoutes = [];
|
|
85
|
+
#computeResponseTypes;
|
|
86
|
+
#computeRequestTypes;
|
|
87
|
+
#extractValidators;
|
|
88
|
+
ui = cliui();
|
|
89
|
+
pathsResolver;
|
|
90
|
+
rules = {
|
|
91
|
+
skip: [],
|
|
92
|
+
request: {},
|
|
93
|
+
response: {}
|
|
94
|
+
};
|
|
95
|
+
constructor(appRoot, rulesCollection) {
|
|
96
|
+
this.#appRoot = appRoot;
|
|
97
|
+
this.pathsResolver = new PathsResolver(appRoot);
|
|
98
|
+
rulesCollection.forEach((rules) => {
|
|
99
|
+
this.rules.skip = this.rules.skip.concat(rules.skip);
|
|
100
|
+
Object.assign(this.rules.request, rules.request);
|
|
101
|
+
Object.assign(this.rules.response, rules.response);
|
|
102
|
+
});
|
|
103
|
+
this.rules.skip = Array.from(new Set([...this.rules.skip]));
|
|
104
|
+
}
|
|
105
|
+
#prepareRequestTypes(route) {
|
|
106
|
+
if (!route.validators) return;
|
|
107
|
+
return {
|
|
108
|
+
type: route.validators.reduce((result, validator) => {
|
|
109
|
+
const validatorExport = validator.import.type === "default" ? ".default" : validator.import.type === "named" ? `.${validator.import.value}` : "";
|
|
110
|
+
const [, ...segments] = validator.name.split(".");
|
|
111
|
+
const namespace = segments.map((segment) => `['${segment}']`).join("");
|
|
112
|
+
result.push(`Infer<(typeof import('${validator.import.specifier}')${validatorExport})${namespace}>`);
|
|
113
|
+
return result;
|
|
114
|
+
}, []).join("|"),
|
|
115
|
+
imports: [`import { Infer } from '@vinejs/vine/types'`]
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async #inspectControllerSpecifier(importExpression, method) {
|
|
119
|
+
const importedModule = [...await parseImports(importExpression)].find(($import) => $import.isDynamicImport && $import.moduleSpecifier.value);
|
|
120
|
+
if (!importedModule || importedModule.moduleSpecifier.type !== "package" || !importedModule.moduleSpecifier.value) return null;
|
|
121
|
+
const specifier = importedModule.moduleSpecifier.value;
|
|
122
|
+
const name = new StringBuilder(specifier.split("/").pop()).removeSuffix("Controller").pascalCase().suffix("Controller").toString();
|
|
123
|
+
return {
|
|
124
|
+
name,
|
|
125
|
+
method: method ?? "handle",
|
|
126
|
+
path: string.toUnixSlash(this.pathsResolver.resolve(specifier, true)),
|
|
127
|
+
import: {
|
|
128
|
+
specifier,
|
|
129
|
+
type: "default",
|
|
130
|
+
value: name
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
async #setResponse(route, controller) {
|
|
135
|
+
route.response = await this.#computeResponseTypes?.(route, controller, this) ?? {
|
|
136
|
+
type: `ReturnType<import('${controller.import.specifier}').default['${controller.method}']>`,
|
|
137
|
+
imports: []
|
|
138
|
+
};
|
|
139
|
+
debug_default("computed route \"%s\" response %O", route.name, route.response);
|
|
140
|
+
}
|
|
141
|
+
async #setRequest(route, controller, vfs) {
|
|
142
|
+
route.validators = await this.#extractValidators?.(route, controller, this) ?? await extractValidators(this.#appRoot, vfs, controller);
|
|
143
|
+
debug_default("computed route \"%s\" validators %O", route.name, route.validators);
|
|
144
|
+
route.request = await this.#computeRequestTypes?.(route, controller, this) ?? this.#prepareRequestTypes(route);
|
|
145
|
+
debug_default("computed route \"%s\" request input %O", route.name, route.request);
|
|
146
|
+
}
|
|
147
|
+
#processRouteWithoutController(route) {
|
|
148
|
+
if (!route.name) {
|
|
149
|
+
debug_default(`skipping route "%s" as it does not have a name`, route.pattern);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const scannedRoute = {
|
|
153
|
+
name: route.name,
|
|
154
|
+
domain: route.domain,
|
|
155
|
+
methods: route.methods,
|
|
156
|
+
pattern: route.pattern,
|
|
157
|
+
tokens: route.tokens,
|
|
158
|
+
request: this.rules.request[route.name],
|
|
159
|
+
response: this.rules.response[route.name]
|
|
160
|
+
};
|
|
161
|
+
debug_default("scanned route without controller %O", scannedRoute);
|
|
162
|
+
this.#scannedRoutes.push(scannedRoute);
|
|
163
|
+
}
|
|
164
|
+
async #processRouteWithController(route, vfs) {
|
|
165
|
+
if (!route.handler || !route.handler.importExpression) return this.#processRouteWithoutController(route);
|
|
166
|
+
const controller = await this.#inspectControllerSpecifier(route.handler.importExpression, route.handler.method);
|
|
167
|
+
if (!controller) return this.#processRouteWithoutController(route);
|
|
168
|
+
debug_default("processing route \"%s\" with inspected controller %O", route.name, controller);
|
|
169
|
+
const routeName = route.name ?? new StringBuilder(controller.name).removeSuffix("Controller").snakeCase().suffix(`.${string.snakeCase(controller.method)}`).toString();
|
|
170
|
+
if (this.rules.skip.includes(routeName)) return;
|
|
171
|
+
const scannedRoute = {
|
|
172
|
+
name: routeName,
|
|
173
|
+
domain: route.domain,
|
|
174
|
+
methods: route.methods,
|
|
175
|
+
pattern: route.pattern,
|
|
176
|
+
tokens: route.tokens,
|
|
177
|
+
request: this.rules.request[routeName],
|
|
178
|
+
response: this.rules.response[routeName],
|
|
179
|
+
controller
|
|
180
|
+
};
|
|
181
|
+
debug_default("scanned route %O", scannedRoute);
|
|
182
|
+
this.#scannedRoutes.push(scannedRoute);
|
|
183
|
+
if (!scannedRoute.request || !scannedRoute.response) {
|
|
184
|
+
debug_default("tracking controller for rescanning %O", scannedRoute);
|
|
185
|
+
this.#controllerRoutes[controller.path] ??= [];
|
|
186
|
+
this.#controllerRoutes[controller.path].push(scannedRoute);
|
|
187
|
+
if (!scannedRoute.response) await this.#setResponse(scannedRoute, controller);
|
|
188
|
+
if (!scannedRoute.request) await this.#setRequest(scannedRoute, controller, vfs);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async #processRoute(route, vfs) {
|
|
192
|
+
if (route.name && this.rules.skip.includes(route.name)) {
|
|
193
|
+
debug_default("route skipped route: %O, rules: %O", route, this.rules);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (typeof route.handler === "function") {
|
|
197
|
+
this.#processRouteWithoutController(route);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
await this.#processRouteWithController(route, vfs);
|
|
201
|
+
}
|
|
202
|
+
defineResponse(callback) {
|
|
203
|
+
this.#computeResponseTypes = callback;
|
|
204
|
+
return this;
|
|
205
|
+
}
|
|
206
|
+
defineRequest(callback) {
|
|
207
|
+
this.#computeRequestTypes = callback;
|
|
208
|
+
return this;
|
|
209
|
+
}
|
|
210
|
+
extractValidators(callback) {
|
|
211
|
+
this.#extractValidators = callback;
|
|
212
|
+
return this;
|
|
213
|
+
}
|
|
214
|
+
getScannedRoutes() {
|
|
215
|
+
return this.#scannedRoutes;
|
|
216
|
+
}
|
|
217
|
+
getControllers() {
|
|
218
|
+
return Object.keys(this.#controllerRoutes);
|
|
219
|
+
}
|
|
220
|
+
async invalidate(controllerPath) {
|
|
221
|
+
const controllerRoutes = this.#controllerRoutes[controllerPath];
|
|
222
|
+
if (!controllerRoutes || !controllerRoutes.length) {
|
|
223
|
+
debug_default("\"%s\" controllers is not part of scanned controllers %O", controllerPath, this.#controllerRoutes);
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
for (let scannedRoute of controllerRoutes) if (scannedRoute.controller) {
|
|
227
|
+
debug_default("invalidating route %O", scannedRoute);
|
|
228
|
+
const vfs = new VirtualFileSystem(this.#appRoot);
|
|
229
|
+
await this.#setResponse(scannedRoute, scannedRoute.controller);
|
|
230
|
+
await this.#setRequest(scannedRoute, scannedRoute.controller, vfs);
|
|
231
|
+
}
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
async scan(routes) {
|
|
235
|
+
const vfs = new VirtualFileSystem(this.#appRoot);
|
|
236
|
+
for (const route of routes) await this.#processRoute(route, vfs);
|
|
237
|
+
vfs.invalidate();
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
export { RoutesScanner as t };
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import "../../../chunk-JFBQ4OEM.js";
|
|
6
|
-
export {
|
|
7
|
-
RoutesScanner
|
|
8
|
-
};
|
|
1
|
+
import "../../../virtual_file_system-DM1KRNbk.js";
|
|
2
|
+
import { t as RoutesScanner } from "../../../main-Byxt3AdL.js";
|
|
3
|
+
import "../../../helpers-DDurYRsZ.js";
|
|
4
|
+
export { RoutesScanner };
|