@faapi/faapi 6.18.1 → 6.20.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/cli/index.js +78 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +77 -3
- package/dist/index.js.map +1 -1
- package/dist/{routeTypes-BAhPIzcG.d.ts → routeTypes-DTqdo28V.d.ts} +8 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +77 -3
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -2608,6 +2608,37 @@ function collectRouteSchemaSources(routes, rootDir) {
|
|
|
2608
2608
|
typeInfo,
|
|
2609
2609
|
coerce: isForm || void 0
|
|
2610
2610
|
});
|
|
2611
|
+
const paramsArg = meta.params.find((p) => p.type === "params");
|
|
2612
|
+
if (paramsArg?.typeName) {
|
|
2613
|
+
sources.push({
|
|
2614
|
+
urlPath: entry.urlPath,
|
|
2615
|
+
filePath,
|
|
2616
|
+
schemaName: getSchemaName(method, "params"),
|
|
2617
|
+
typeInfo: resolver.resolve(paramsArg.typeName) ?? null
|
|
2618
|
+
});
|
|
2619
|
+
}
|
|
2620
|
+
if (inputType === "body") {
|
|
2621
|
+
const queryArg = meta.params.find((p) => p.type === "query");
|
|
2622
|
+
if (queryArg?.typeName) {
|
|
2623
|
+
sources.push({
|
|
2624
|
+
urlPath: entry.urlPath,
|
|
2625
|
+
filePath,
|
|
2626
|
+
schemaName: getSchemaName(method, "query"),
|
|
2627
|
+
typeInfo: resolver.resolve(queryArg.typeName) ?? null
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2630
|
+
} else if (hasBody(method)) {
|
|
2631
|
+
const bodyArg = meta.params.find((p) => p.type === "body") ?? meta.params.find((p) => p.type === "form");
|
|
2632
|
+
if (bodyArg?.typeName) {
|
|
2633
|
+
sources.push({
|
|
2634
|
+
urlPath: entry.urlPath,
|
|
2635
|
+
filePath,
|
|
2636
|
+
schemaName: getSchemaName(method, "body"),
|
|
2637
|
+
typeInfo: resolver.resolve(bodyArg.typeName) ?? null,
|
|
2638
|
+
coerce: bodyArg.type === "form" || void 0
|
|
2639
|
+
});
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2611
2642
|
}
|
|
2612
2643
|
}
|
|
2613
2644
|
return { sources, resolversByFile };
|
|
@@ -7474,8 +7505,10 @@ var init_agentHandle = __esm({
|
|
|
7474
7505
|
// src/injection/injectParams.ts
|
|
7475
7506
|
function getBuiltinInjectionValue(type, ctx, body) {
|
|
7476
7507
|
switch (type) {
|
|
7477
|
-
case "query":
|
|
7478
|
-
|
|
7508
|
+
case "query": {
|
|
7509
|
+
const validated = ctx.__validatedQuery;
|
|
7510
|
+
return validated ?? queryToObject(ctx.query);
|
|
7511
|
+
}
|
|
7479
7512
|
case "params":
|
|
7480
7513
|
return ctx.params;
|
|
7481
7514
|
case "headers":
|
|
@@ -8738,7 +8771,48 @@ function createRoutePipeline(opts) {
|
|
|
8738
8771
|
if (!result.valid) {
|
|
8739
8772
|
throw new ValidationError("\u53C2\u6570\u6821\u9A8C\u5931\u8D25", result.issues);
|
|
8740
8773
|
}
|
|
8741
|
-
|
|
8774
|
+
if (inputType === "query" && result.data !== input && typeof result.data === "object" && result.data !== null) {
|
|
8775
|
+
ctx.__validatedQuery = {
|
|
8776
|
+
...input,
|
|
8777
|
+
...result.data
|
|
8778
|
+
};
|
|
8779
|
+
}
|
|
8780
|
+
const paramsResult = await validateInput(schemaPath, route.method, "params", match.params);
|
|
8781
|
+
if (!paramsResult.valid) {
|
|
8782
|
+
throw new ValidationError("\u53C2\u6570\u6821\u9A8C\u5931\u8D25", paramsResult.issues);
|
|
8783
|
+
}
|
|
8784
|
+
if (paramsResult.data !== match.params) {
|
|
8785
|
+
ctx.params = typeof paramsResult.data === "object" && paramsResult.data !== null ? {
|
|
8786
|
+
...match.params,
|
|
8787
|
+
...paramsResult.data
|
|
8788
|
+
} : match.params;
|
|
8789
|
+
}
|
|
8790
|
+
if (inputType === "body") {
|
|
8791
|
+
const rawQuery = queryToObject(url.searchParams);
|
|
8792
|
+
const queryResult = await validateInput(schemaPath, route.method, "query", rawQuery);
|
|
8793
|
+
if (!queryResult.valid) {
|
|
8794
|
+
throw new ValidationError("\u53C2\u6570\u6821\u9A8C\u5931\u8D25", queryResult.issues);
|
|
8795
|
+
}
|
|
8796
|
+
if (queryResult.data !== rawQuery && typeof queryResult.data === "object" && queryResult.data !== null) {
|
|
8797
|
+
ctx.__validatedQuery = {
|
|
8798
|
+
...rawQuery,
|
|
8799
|
+
...queryResult.data
|
|
8800
|
+
};
|
|
8801
|
+
}
|
|
8802
|
+
}
|
|
8803
|
+
let body;
|
|
8804
|
+
if (inputType === "query" && hasBody(route.method)) {
|
|
8805
|
+
const parsed = await resolveBodyForQueryMethod(request);
|
|
8806
|
+
if (parsed !== void 0) {
|
|
8807
|
+
const bodyResult = await validateInput(schemaPath, route.method, "body", parsed);
|
|
8808
|
+
if (!bodyResult.valid) {
|
|
8809
|
+
throw new ValidationError("\u53C2\u6570\u6821\u9A8C\u5931\u8D25", bodyResult.issues);
|
|
8810
|
+
}
|
|
8811
|
+
body = bodyResult.data;
|
|
8812
|
+
}
|
|
8813
|
+
} else if (hasBody(route.method)) {
|
|
8814
|
+
body = result.data;
|
|
8815
|
+
}
|
|
8742
8816
|
if (route.middlewares === void 0 && route.injectors === void 0 && route.middlewarePaths) {
|
|
8743
8817
|
await ensureMiddlewaresCompiled(route.middlewarePaths, rootDir);
|
|
8744
8818
|
const bundle = await loadMergedMiddlewares(route.middlewarePaths);
|
|
@@ -8828,6 +8902,7 @@ var init_createServer = __esm({
|
|
|
8828
8902
|
init_httpErrors();
|
|
8829
8903
|
init_validateInput();
|
|
8830
8904
|
init_inputType();
|
|
8905
|
+
init_queryToObject();
|
|
8831
8906
|
init_getClientIp();
|
|
8832
8907
|
init_cors();
|
|
8833
8908
|
init_helmet();
|