@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/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FaapiMiddleware, A as AppRegistries, R as RouteManifest, a as FaapiContext, C as CorsOptions, T as TaskClient, H as HelmetOptions, L as LogConfig, I as InjectorMap, b as TaskFailedHandler, c as TaskQueueDeps, d as TaskQueue, e as TaskDriver, f as TaskRegistry, g as TaskManifest, h as ToolMetadata, i as AgentCore, j as AgentMetadata, k as CreateLoggerOptions, l as Logger, W as WsRouteManifest } from './routeTypes-
|
|
2
|
-
export { m as AgentHandleFactory, n as AgentHandleStore, o as AgentPathMeta, p as AgentRegistry, q as AgentToolDescriptor, r as FaapiContextConfig, s as FaapiTaskMeta, t as FailOptions, u as Injector, v as LogEntry, w as LogLevel, x as LogSink, y as RouteInfo, z as RouteInputSchema, B as RouteOutputSchema, D as RouteParamSchema, S as SkillRegistry, E as SseEvent, G as SseWriter, J as TaskContext, K as TaskDriverJob, M as TaskDriverProcess, N as TaskDriverRecord, O as TaskFailedInfo, P as TaskJob, Q as TaskJobStatus, U as TaskMetadata, V as TaskModule, X as TaskRegistriesSnapshot, Y as TaskRegistriesView, Z as ToolCore, _ as ToolPathMeta, $ as ToolRegistry, a0 as cors, a1 as createAppRegistries, a2 as createTaskRegistriesView, a3 as createTaskRegistry, a4 as helmet } from './routeTypes-
|
|
1
|
+
import { F as FaapiMiddleware, A as AppRegistries, R as RouteManifest, a as FaapiContext, C as CorsOptions, T as TaskClient, H as HelmetOptions, L as LogConfig, I as InjectorMap, b as TaskFailedHandler, c as TaskQueueDeps, d as TaskQueue, e as TaskDriver, f as TaskRegistry, g as TaskManifest, h as ToolMetadata, i as AgentCore, j as AgentMetadata, k as CreateLoggerOptions, l as Logger, W as WsRouteManifest } from './routeTypes-DTqdo28V.js';
|
|
2
|
+
export { m as AgentHandleFactory, n as AgentHandleStore, o as AgentPathMeta, p as AgentRegistry, q as AgentToolDescriptor, r as FaapiContextConfig, s as FaapiTaskMeta, t as FailOptions, u as Injector, v as LogEntry, w as LogLevel, x as LogSink, y as RouteInfo, z as RouteInputSchema, B as RouteOutputSchema, D as RouteParamSchema, S as SkillRegistry, E as SseEvent, G as SseWriter, J as TaskContext, K as TaskDriverJob, M as TaskDriverProcess, N as TaskDriverRecord, O as TaskFailedInfo, P as TaskJob, Q as TaskJobStatus, U as TaskMetadata, V as TaskModule, X as TaskRegistriesSnapshot, Y as TaskRegistriesView, Z as ToolCore, _ as ToolPathMeta, $ as ToolRegistry, a0 as cors, a1 as createAppRegistries, a2 as createTaskRegistriesView, a3 as createTaskRegistry, a4 as helmet } from './routeTypes-DTqdo28V.js';
|
|
3
3
|
import * as node_http from 'node:http';
|
|
4
4
|
import { Server, IncomingMessage, ServerResponse } from 'node:http';
|
|
5
5
|
import { Socket } from 'node:net';
|
package/dist/index.js
CHANGED
|
@@ -1219,6 +1219,37 @@ function collectRouteSchemaSources(routes, rootDir) {
|
|
|
1219
1219
|
typeInfo,
|
|
1220
1220
|
coerce: isForm || void 0
|
|
1221
1221
|
});
|
|
1222
|
+
const paramsArg = meta.params.find((p) => p.type === "params");
|
|
1223
|
+
if (paramsArg?.typeName) {
|
|
1224
|
+
sources.push({
|
|
1225
|
+
urlPath: entry.urlPath,
|
|
1226
|
+
filePath,
|
|
1227
|
+
schemaName: getSchemaName(method, "params"),
|
|
1228
|
+
typeInfo: resolver.resolve(paramsArg.typeName) ?? null
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
if (inputType === "body") {
|
|
1232
|
+
const queryArg = meta.params.find((p) => p.type === "query");
|
|
1233
|
+
if (queryArg?.typeName) {
|
|
1234
|
+
sources.push({
|
|
1235
|
+
urlPath: entry.urlPath,
|
|
1236
|
+
filePath,
|
|
1237
|
+
schemaName: getSchemaName(method, "query"),
|
|
1238
|
+
typeInfo: resolver.resolve(queryArg.typeName) ?? null
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
} else if (hasBody(method)) {
|
|
1242
|
+
const bodyArg = meta.params.find((p) => p.type === "body") ?? meta.params.find((p) => p.type === "form");
|
|
1243
|
+
if (bodyArg?.typeName) {
|
|
1244
|
+
sources.push({
|
|
1245
|
+
urlPath: entry.urlPath,
|
|
1246
|
+
filePath,
|
|
1247
|
+
schemaName: getSchemaName(method, "body"),
|
|
1248
|
+
typeInfo: resolver.resolve(bodyArg.typeName) ?? null,
|
|
1249
|
+
coerce: bodyArg.type === "form" || void 0
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1222
1253
|
}
|
|
1223
1254
|
}
|
|
1224
1255
|
return { sources, resolversByFile };
|
|
@@ -5270,8 +5301,10 @@ function markBuffered(response) {
|
|
|
5270
5301
|
init_resolveInjection();
|
|
5271
5302
|
function getBuiltinInjectionValue(type, ctx, body) {
|
|
5272
5303
|
switch (type) {
|
|
5273
|
-
case "query":
|
|
5274
|
-
|
|
5304
|
+
case "query": {
|
|
5305
|
+
const validated = ctx.__validatedQuery;
|
|
5306
|
+
return validated ?? queryToObject(ctx.query);
|
|
5307
|
+
}
|
|
5275
5308
|
case "params":
|
|
5276
5309
|
return ctx.params;
|
|
5277
5310
|
case "headers":
|
|
@@ -6316,7 +6349,48 @@ function createRoutePipeline(opts) {
|
|
|
6316
6349
|
if (!result.valid) {
|
|
6317
6350
|
throw new ValidationError("\u53C2\u6570\u6821\u9A8C\u5931\u8D25", result.issues);
|
|
6318
6351
|
}
|
|
6319
|
-
|
|
6352
|
+
if (inputType === "query" && result.data !== input && typeof result.data === "object" && result.data !== null) {
|
|
6353
|
+
ctx.__validatedQuery = {
|
|
6354
|
+
...input,
|
|
6355
|
+
...result.data
|
|
6356
|
+
};
|
|
6357
|
+
}
|
|
6358
|
+
const paramsResult = await validateInput(schemaPath, route.method, "params", match.params);
|
|
6359
|
+
if (!paramsResult.valid) {
|
|
6360
|
+
throw new ValidationError("\u53C2\u6570\u6821\u9A8C\u5931\u8D25", paramsResult.issues);
|
|
6361
|
+
}
|
|
6362
|
+
if (paramsResult.data !== match.params) {
|
|
6363
|
+
ctx.params = typeof paramsResult.data === "object" && paramsResult.data !== null ? {
|
|
6364
|
+
...match.params,
|
|
6365
|
+
...paramsResult.data
|
|
6366
|
+
} : match.params;
|
|
6367
|
+
}
|
|
6368
|
+
if (inputType === "body") {
|
|
6369
|
+
const rawQuery = queryToObject(url.searchParams);
|
|
6370
|
+
const queryResult = await validateInput(schemaPath, route.method, "query", rawQuery);
|
|
6371
|
+
if (!queryResult.valid) {
|
|
6372
|
+
throw new ValidationError("\u53C2\u6570\u6821\u9A8C\u5931\u8D25", queryResult.issues);
|
|
6373
|
+
}
|
|
6374
|
+
if (queryResult.data !== rawQuery && typeof queryResult.data === "object" && queryResult.data !== null) {
|
|
6375
|
+
ctx.__validatedQuery = {
|
|
6376
|
+
...rawQuery,
|
|
6377
|
+
...queryResult.data
|
|
6378
|
+
};
|
|
6379
|
+
}
|
|
6380
|
+
}
|
|
6381
|
+
let body;
|
|
6382
|
+
if (inputType === "query" && hasBody(route.method)) {
|
|
6383
|
+
const parsed = await resolveBodyForQueryMethod(request);
|
|
6384
|
+
if (parsed !== void 0) {
|
|
6385
|
+
const bodyResult = await validateInput(schemaPath, route.method, "body", parsed);
|
|
6386
|
+
if (!bodyResult.valid) {
|
|
6387
|
+
throw new ValidationError("\u53C2\u6570\u6821\u9A8C\u5931\u8D25", bodyResult.issues);
|
|
6388
|
+
}
|
|
6389
|
+
body = bodyResult.data;
|
|
6390
|
+
}
|
|
6391
|
+
} else if (hasBody(route.method)) {
|
|
6392
|
+
body = result.data;
|
|
6393
|
+
}
|
|
6320
6394
|
if (route.middlewares === void 0 && route.injectors === void 0 && route.middlewarePaths) {
|
|
6321
6395
|
await ensureMiddlewaresCompiled(route.middlewarePaths, rootDir);
|
|
6322
6396
|
const bundle = await loadMergedMiddlewares(route.middlewarePaths);
|