kizunajs 2.0.0-beta.21 → 2.0.0-beta.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/README.md +1 -1
- package/dist/{adapter-D4bTPElA.d.mts → adapter-BdkB6ql9.d.mts} +5 -1
- package/dist/{adapter-ClaFZoab.cjs → adapter-CK8ccDOC.cjs} +78 -8
- package/dist/{adapter-BSqNrxhq.mjs → adapter-DU3Ljl0P.mjs} +73 -9
- package/dist/{adapter-C3WYdSfx.d.cts → adapter-nQIkQwsM.d.cts} +5 -1
- package/dist/adapter.cjs +4 -3
- package/dist/adapter.d.cts +2 -2
- package/dist/adapter.d.mts +2 -2
- package/dist/adapter.mjs +4 -4
- package/dist/{error-response-CNQaKVYd.mjs → error-response-D7urgxeq.mjs} +16 -3
- package/dist/{error-response-C9ymqSU4.cjs → error-response-DN5Dsf8b.cjs} +21 -2
- package/dist/generator.cjs +5 -3
- package/dist/generator.d.cts +6 -2
- package/dist/generator.d.mts +6 -2
- package/dist/generator.mjs +5 -4
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +4 -4
- package/dist/jobs-entry.cjs +2 -2
- package/dist/jobs-entry.d.cts +1 -1
- package/dist/jobs-entry.d.mts +1 -1
- package/dist/jobs-entry.mjs +2 -2
- package/dist/{plugin-server-kUsK7thV.cjs → plugin-server-CfF82yZL.cjs} +11 -6
- package/dist/{plugin-server-BztlE1fz.mjs → plugin-server-DNQ9_DL7.mjs} +11 -6
- package/dist/plugin.d.cts +1 -1
- package/dist/plugin.d.mts +1 -1
- package/dist/{schemas-DNPVDvkd.cjs → schemas-Bre1FVHq.cjs} +1 -1
- package/dist/{schemas-HW2FDsvz.mjs → schemas-DBX8DwFb.mjs} +1 -1
- package/dist/schemas.cjs +2 -2
- package/dist/schemas.mjs +2 -2
- package/package.json +1 -1
- package/src/adapter.ts +8 -5
- package/src/coercion.ts +25 -16
- package/src/generator.ts +4 -2
- package/src/routes.ts +97 -1
- package/src/zod-internals.ts +17 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
A spec-driven framework for building fully typed REST APIs in TypeScript, where your route declarations produce the validation, the documentation, the clients, and the AI tools.
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/kizunajs/v/2.0.0-beta.
|
|
7
|
+
[](https://www.npmjs.com/package/kizunajs/v/2.0.0-beta.23)
|
|
8
8
|

|
|
9
9
|
|
|
10
10
|
[Documentation](https://kizunajs.com)
|
|
@@ -2737,6 +2737,10 @@ interface RenderedResult {
|
|
|
2737
2737
|
declare const renderJsonResult: (result: Exclude<AdapterResult, {
|
|
2738
2738
|
kind: "raw-response";
|
|
2739
2739
|
}>, formatError?: ErrorFormatter, request?: unknown, requestMethod?: string) => RenderedResult;
|
|
2740
|
+
/**
|
|
2741
|
+
* A query string or form as an object. A repeated key collects every value into a list.
|
|
2742
|
+
*/
|
|
2743
|
+
declare const entriesToObject: (source: URLSearchParams | FormData) => Record<string, unknown>;
|
|
2740
2744
|
/**
|
|
2741
2745
|
* Parse a body from its text, the way {@link parseFetchBody} would, for a route
|
|
2742
2746
|
* whose text core already read.
|
|
@@ -2751,4 +2755,4 @@ declare const parseBodyText: (text: string, route: RouteDefinition) => unknown;
|
|
|
2751
2755
|
declare const parseFetchBody: (request: Request, route: RouteDefinition) => Promise<unknown>;
|
|
2752
2756
|
declare const headersToObject: (headers: Headers) => ResponseHeaders;
|
|
2753
2757
|
//#endregion
|
|
2754
|
-
export {
|
|
2758
|
+
export { jobRoutes as $, StreamComment as $i, isJobDefinition as $n, AuthContextOf as $r, PluginsBySlug as $t, RenderedResult as A, BearerConfig as Aa, ToolRunOptions as Ai, RoutesOf as An, parseCron as Ar, sanitizeIdentifier as At, bearerChallenge as B, NoCredential as Ba, ExtractPathParams as Bi, JobHandler as Bn, GroupSet as Br, PluginApi as Bt, JOBS_META as C, insufficientScope as Ca, isRouteDefinition as Ci, GeneratedFile as Cn, ParsedCron as Cr, resolveResponseBody as Ct, REQUEST_CONTEXT_META as D, ApiKeyCredential as Da, ToolAnswer as Di, GuardSchemaOf as Dn, firesBetween as Dr, resolveResponseHeaders as Dt, MountedOf as E, ApiKeyConfig as Ea, StreamTools as Ei, ApiPluginsOf as En, dueSchedules as Er, resolveResponseEtag as Et, RouteMatcher as F, GrantsOf as Fa, buildToolInputSchema as Fi, CompiledJobs as Fn, RequestContextHeaderValues as Fr, AnyPlugin as Ft, dispatchRoute as G, RoutePathParamsCheck as Gi, JobRunnerConfig as Gn, isRawResponse as Gr, PluginExportsOf as Gt, contractOf as H, OpenIdConnectConfig as Ha, PathParamName as Hi, JobHandlerReturn as Hn, createGroups as Hr, PluginDeclaration as Ht, SCHEMES_META as I, GuardHoldings as Ia, describeTool as Ii, FlattenedJob as In, RequestContextSchema as Ir, ApiPlugins as It, getHeaderValue as J, EVENT_STREAM_MEDIA_TYPE as Ji, JobsArg as Jn, RouteWithHandler as Jr, PluginRouteBuilder as Jt, entriesToObject as K, buildPath as Ki, JobVoidReturn as Kn, rawResponse as Kr, PluginFactory as Kt, ServerOptions as L, Identity as La, selectToolRoutes as Li, HttpJobsConfig as Ln, GroupOptions as Lr, InstallOptions as Lt, RequestContextRun as M, Credential as Ma, ToolDefinition as Mi, AuthoredJobDefinition as Mn, scheduleTimezone as Mr, statusToCamelCase as Mt, RequestPipeline as N, CredentialOf as Na, ToolInputSchema as Ni, AuthoredJobs as Nn, RequestContextConfig as Nr, toCamelCase as Nt, ROUTER_META as O, BasicConfig as Oa, ToolEventYield as Oi, JobsOf as On, nextRun as Or, resolveResponseStream as Ot, ResponseValidationError as P, CustomConfig as Pa, buildToolDefinitions as Pi, CompiledJob as Pn, RequestContextHeaderInputs as Pr, toPascalCase as Pt, jobRouter as Q, StreamChunk as Qi, isCompiledJob as Qn, sortFlattenedRoutes as Qr, PluginSetupContext as Qt, adapterContextOf as R, IdentityParamsOf as Ra, toolOptionsOf as Ri, InProcessJobsConfig as Rn, GroupPaths as Rr, PLUGIN_ROUTES_META_KEY as Rt, HandlerContextOf as S, AccessCheckInput as Sa, formatValidationError as Si, DiffSettings as Sn, JobSchedule as Sr, mergeHeaderFields as St, MountArgsOf as T, withPermissions as Ta, ModelToolCall as Ti, ApiDefinition as Tn, cron as Tr, resolveResponseContentType as Tt, defineAdapter as U, RoleOf as Ua, PathParamsCheck as Ui, JobHandlers as Un, isGroupSet as Ur, PluginDefinition as Ut, boundJobKeys as V, OAuth2Config as Va, HasPathParams as Vi, JobHandlerArgs as Vn, ResolvedGroup as Vr, PluginArgs as Vt, dispatchHandler as W, RolesOf as Wa, PathSegment as Wi, JobResponses as Wn, RawResponse as Wr, PluginExportValues as Wt, headersToObject as X, StreamBody as Xi, NoJobs as Xn, RouteMatch as Xr, PluginRoutesOf as Xt, guardDenyFor as Y, EncodeStreamOptions as Yi, JobsConfig as Yn, MatchResult as Yr, PluginRoutes as Yt, isGuardDenial as Z, StreamBodyOf as Zi, flattenJobs as Zn, matchRoute as Zr, PluginSetup as Zt, GuardDeny as _, ToolEvents as _a, ThrowableReturn as _i, ConfiguredRequestContextSchemas as _n, JobTransportSupports as _r, isJsonMediaType as _t, AdapterRequest as a, encodeStreamBody as aa, GuardReturn as ai, pluginRouteTree as an, JobQueueArgs as ar, runHandler as at, HANDLER_ARG_KEYS as b, expandStreamTools as ba, allowedMethodsForPath as bi, KizunaConfigShape as bn, ScheduledJob as br, isZodSchema as bt, ApiBrand as c, soleStreamResponse as ca, HandlerArgs as ci, ConfiguredAdapterContext as cn, JobRunner as cr, ApiRouter as ct, DISPATCH_ROUTE_KEY as d, streamSchemas as da, RawInputs as di, ConfiguredGroups as dn, jobFnAt as dr, createApiReference as dt, StreamContext as ea, BrandedHandlerContext as ei, ResolvedPlugin as en, jobAt as er, jobRunnerFrom as et, ErrorFormatter as f, streamStatuses as fa, RequestContextValues as fi, ConfiguredGuardSchema as fn, JobDescriptor as fr, pluginExportsOf as ft, GuardDenialBody as g, ToolError as ga, RoutesWithHandlerContext as gi, ConfiguredRequestContext as gn, JobTransportDefinition as gr, isHintPrefix as gt, GuardDenial as h, ToolCall as ha, Router as hi, ConfiguredPlugins as hn, JobTransport as hr, resolvePlugins as ht, AdapterDefinition as i, StreamYield as ia, GuardParams as ii, definePlugin as in, JobInputError as ir, routerFromRoutes as it, RequestContextMap as j, BearerCredential as ja, ToolRunResult as ji, SchemesOf as jn, scheduleExpression as jr, shortTypeName as jt, RUN_ROUTE_KEY as k, BasicCredential as ka, ToolRunCall as ki, RequestContextOf as kn, nextRuns as kr, sanitizeFieldName as kt, ApiParts as l, streamContentType as la, HandlerReturn as li, ConfiguredAdapterValue as ln, JobRunnerOptions as lr, ResponseError as lt, GUARD_SCHEMA_META as m, ToolAt as ma, RouteHandler as mi, ConfiguredJobs as mn, JobMessage as mr, pluginRoutesOf as mt, API_META as n, StreamMessageOf as na, FlattenedRoute as ni, RoutePathSchema as nn, JobFn as nr, parseFetchBody as nt, AdapterResult as o, isNamedStream as oa, GuardSuccess as oi, route as on, JobQueueOptions as or, runRoute as ot, GUARDS_META as p, StreamWithTools as pa, RouteGuardBrandOf as pi, ConfiguredIdentities as pn, JobDispatchError as pr, pluginRouterOf as pt, extractCredential as q, parsePath as qi, Jobs as qn, RouteBuilder as qr, PluginList as qt, Adapter as r, StreamMode as ra, GuardAnswer as ri, SlugOption as rn, JobFnByKey as rr, renderJsonResult as rt, AnyAdapter as s, routeStreams as sa, GuardedParamNames as si, ApiContext as sn, JobRunArgs as sr, warnUnsupportedJobOptions as st, ADAPTER_CONTEXT as t, StreamMessage as ta, ContextFromAuth as ti, RouteAuthSchema as tn, JobErrorHandler as tr, parseBodyText as tt, ApiWithRouter as u, streamMode as ua, HandlersFromRoutes as ui, ConfiguredCodes as un, createJobRunner as ur, groupRoutes as ut, GuardMap as v, ToolKeys as va, ValidationFailure as vi, JobFnOf as vn, JobWorker as vr, isStreamResponse as vt, JobsMeta as w, requiresDenial as wa, validateRequest as wi, apiEntries as wn, assertValidSchedule as wr, resolveResponseCache as wt, HandleArgs as x, toolEvents as xa, flattenRoutes as xi, ApiEntry as xn, defineJobTransport as xr, localTypeName as xt, GuardRun as y, ToolResult as ya, ValidationStage as yi, JobsOfTree as yn, JobWorkerContext as yr, isSuccessStatus as yt, assembleApi as z, IdentityRole as za, toolRefusal as zi, JobDefinition as zn, GroupPathsOf as zr, PLUGIN_SERVERS_META_KEY as zt };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_plugin = require("./plugin-Dw-yCjTY.cjs");
|
|
2
|
-
const require_error_response = require("./error-response-
|
|
3
|
-
const require_plugin_server = require("./plugin-server-
|
|
4
|
-
const require_schemas = require("./schemas-
|
|
2
|
+
const require_error_response = require("./error-response-DN5Dsf8b.cjs");
|
|
3
|
+
const require_plugin_server = require("./plugin-server-CfF82yZL.cjs");
|
|
4
|
+
const require_schemas = require("./schemas-Bre1FVHq.cjs");
|
|
5
5
|
let zod = require("zod");
|
|
6
6
|
//#region src/tool-definitions.ts
|
|
7
7
|
/**
|
|
@@ -312,6 +312,64 @@ const assertPathParamsAreScalar = (route, routeKey) => {
|
|
|
312
312
|
}
|
|
313
313
|
};
|
|
314
314
|
/**
|
|
315
|
+
* What a field holds once optional and default wrappers are peeled away: a schema kind, or a file or bytes.
|
|
316
|
+
*/
|
|
317
|
+
const fieldKind = (schema) => {
|
|
318
|
+
const { inner } = require_error_response.unwrapOptionalWrappers(schema);
|
|
319
|
+
if (require_error_response.isFileSchema(inner)) return "file";
|
|
320
|
+
if (require_error_response.isBinarySchema(inner)) return "BinarySchema";
|
|
321
|
+
return require_error_response.resolveBaseType(inner);
|
|
322
|
+
};
|
|
323
|
+
const listElement = (schema) => {
|
|
324
|
+
const def = require_error_response.readDef(require_error_response.unwrapOptionalWrappers(schema).inner);
|
|
325
|
+
return def.type === "array" ? def.element : void 0;
|
|
326
|
+
};
|
|
327
|
+
const isValue = (kind) => !STRUCTURED_TYPES.has(kind) && kind !== "file" && kind !== "BinarySchema";
|
|
328
|
+
/**
|
|
329
|
+
* Names a field the way an error shows it: its kind, or what a list holds.
|
|
330
|
+
*/
|
|
331
|
+
const describeField = (schema) => {
|
|
332
|
+
const element = listElement(schema);
|
|
333
|
+
return element === void 0 ? fieldKind(schema) : `array of ${fieldKind(element)}`;
|
|
334
|
+
};
|
|
335
|
+
const fieldsOf = (schema) => Object.entries((schema && require_error_response.readObjectShape(schema)) ?? {});
|
|
336
|
+
/**
|
|
337
|
+
* A query string carries values and lists of values, the way OpenAPI's default `form` style sends them.
|
|
338
|
+
*/
|
|
339
|
+
const assertQuerySendable = (route, routeKey) => {
|
|
340
|
+
for (const [name, field] of fieldsOf(route.query)) {
|
|
341
|
+
const element = listElement(field);
|
|
342
|
+
if (element === void 0 ? isValue(fieldKind(field)) : isValue(fieldKind(element))) continue;
|
|
343
|
+
throw new Error(`Route "${routeKey}" declares query field "${name}" as ${describeField(field)}. A query string carries values and lists of values, so this cannot be sent.
|
|
344
|
+
Split it into fields of their own, or move it to a body.`);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
/**
|
|
348
|
+
* A header carries one value.
|
|
349
|
+
*/
|
|
350
|
+
const assertHeadersSendable = (route, routeKey) => {
|
|
351
|
+
for (const [name, field] of fieldsOf(route.headers)) {
|
|
352
|
+
if (listElement(field) === void 0 && isValue(fieldKind(field))) continue;
|
|
353
|
+
throw new Error(`Route "${routeKey}" declares header "${name}" as ${describeField(field)}. A header carries one value, so this cannot be sent.
|
|
354
|
+
Use a scalar schema (z.string(), z.int(), z.enum([...])), or split it into headers of their own.`);
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* A form carries values and lists of values, and a multipart one carries files too (RFC 7578).
|
|
359
|
+
*/
|
|
360
|
+
const assertFormFieldsSendable = (route, routeKey) => {
|
|
361
|
+
if (route.contentType !== "multipart/form-data" && route.contentType !== "application/x-www-form-urlencoded") return;
|
|
362
|
+
const multipart = route.contentType === "multipart/form-data";
|
|
363
|
+
for (const [name, field] of fieldsOf(route.body)) {
|
|
364
|
+
const kind = fieldKind(listElement(field) ?? field);
|
|
365
|
+
if (kind === "BinarySchema") throw new Error(`Route "${routeKey}" declares form field "${name}" as BinarySchema, but a form sends a file part as a File. Declare it with FileSchema.`);
|
|
366
|
+
if (kind === "file" && !multipart) throw new Error(`Route "${routeKey}" declares form field "${name}" as a file, which a urlencoded body cannot carry. Send it as contentType: 'multipart/form-data'.`);
|
|
367
|
+
if (kind === "file" || isValue(kind)) continue;
|
|
368
|
+
throw new Error(`Route "${routeKey}" declares form field "${name}" as ${describeField(field)}. A form carries values, lists of values and files, so this cannot be sent.
|
|
369
|
+
Split it into fields of their own, or take the body as JSON.`);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
/**
|
|
315
373
|
* A tool's description is the one thing a model reads before choosing it, so a
|
|
316
374
|
* route that publishes as one has to carry it.
|
|
317
375
|
*/
|
|
@@ -328,6 +386,9 @@ const validateRoutes = (routes, prefix) => {
|
|
|
328
386
|
expandStreamTools(value, fullKey);
|
|
329
387
|
assertPathParamsMatchPath(value, fullKey);
|
|
330
388
|
assertPathParamsAreScalar(value, fullKey);
|
|
389
|
+
assertQuerySendable(value, fullKey);
|
|
390
|
+
assertHeadersSendable(value, fullKey);
|
|
391
|
+
assertFormFieldsSendable(value, fullKey);
|
|
331
392
|
assertNoCoercion(value, fullKey);
|
|
332
393
|
require_plugin_server.assertValidStreams(value, fullKey);
|
|
333
394
|
assertToolDescribed(value, fullKey);
|
|
@@ -2226,9 +2287,12 @@ const renderResult = (result, formatError, request) => {
|
|
|
2226
2287
|
case "handler-error": return renderError(500, "Internal Server Error", void 0, result.headers);
|
|
2227
2288
|
}
|
|
2228
2289
|
};
|
|
2229
|
-
|
|
2290
|
+
/**
|
|
2291
|
+
* A query string or form as an object. A repeated key collects every value into a list.
|
|
2292
|
+
*/
|
|
2293
|
+
const entriesToObject = (source) => {
|
|
2230
2294
|
const result = {};
|
|
2231
|
-
for (const [key, value] of
|
|
2295
|
+
for (const [key, value] of source.entries()) {
|
|
2232
2296
|
const existing = result[key];
|
|
2233
2297
|
if (existing === void 0) result[key] = value;
|
|
2234
2298
|
else if (Array.isArray(existing)) existing.push(value);
|
|
@@ -2241,7 +2305,7 @@ const formDataToObject = (form) => {
|
|
|
2241
2305
|
* whose text core already read.
|
|
2242
2306
|
*/
|
|
2243
2307
|
const parseBodyText = (text, route) => {
|
|
2244
|
-
if (route.contentType === "application/x-www-form-urlencoded") return
|
|
2308
|
+
if (route.contentType === "application/x-www-form-urlencoded") return entriesToObject(new URLSearchParams(text));
|
|
2245
2309
|
return text.length > 0 ? JSON.parse(text) : void 0;
|
|
2246
2310
|
};
|
|
2247
2311
|
/**
|
|
@@ -2252,8 +2316,8 @@ const parseBodyText = (text, route) => {
|
|
|
2252
2316
|
* */
|
|
2253
2317
|
const parseFetchBody = async (request, route) => {
|
|
2254
2318
|
switch (route.contentType) {
|
|
2255
|
-
case "multipart/form-data": return
|
|
2256
|
-
case "application/x-www-form-urlencoded": return
|
|
2319
|
+
case "multipart/form-data": return entriesToObject(await request.formData());
|
|
2320
|
+
case "application/x-www-form-urlencoded": return entriesToObject(new URLSearchParams(await request.text()));
|
|
2257
2321
|
default: {
|
|
2258
2322
|
const text = await request.text();
|
|
2259
2323
|
return text.length > 0 ? JSON.parse(text) : void 0;
|
|
@@ -2496,6 +2560,12 @@ Object.defineProperty(exports, "dueJobs", {
|
|
|
2496
2560
|
return dueJobs;
|
|
2497
2561
|
}
|
|
2498
2562
|
});
|
|
2563
|
+
Object.defineProperty(exports, "entriesToObject", {
|
|
2564
|
+
enumerable: true,
|
|
2565
|
+
get: function() {
|
|
2566
|
+
return entriesToObject;
|
|
2567
|
+
}
|
|
2568
|
+
});
|
|
2499
2569
|
Object.defineProperty(exports, "expandStreamTools", {
|
|
2500
2570
|
enumerable: true,
|
|
2501
2571
|
get: function() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { g as ROUTES_GROUP, n as PLUGIN_SERVERS_META_KEY, o as pluginRouteTree, p as HANDLER, t as PLUGIN_ROUTES_META_KEY } from "./plugin-xxCxibmu.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { F as routeStreams, G as isZodSchema, H as isJsonMediaType, J as resolveResponseBody, L as streamContentType, M as assertValidStreams, N as encodeStreamBody, S as dueSchedules, U as isStreamResponse, W as isSuccessStatus, X as resolveResponseContentType, Y as resolveResponseCache, Z as resolveResponseEtag, _ as jobAt, c as cacheHeaders, ct as allowedMethodsForPath, dt as isRouteDefinition, ft as validateRequest, h as isCompiledJob, j as EVENT_STREAM_MEDIA_TYPE, k as deriveToolNames, lt as flattenRoutes, m as flattenJobs, pt as resolveCoercionPlans, st as parsePath, u as deprecationHeaders, ut as formatValidationError, y as toJobResponse, z as streamSchemas } from "./plugin-server-
|
|
4
|
-
import { l as authenticationChallenge, p as resolveSecurityRequirements } from "./schemas-
|
|
2
|
+
import { D as resolveBaseType, E as readObjectShape, O as unwrapOptionalWrappers, c as isBinarySchema, m as readDef, o as findCoercedSchemaPath, p as isVoidSchema, t as ProblemDetailsSchema, u as isFileSchema } from "./error-response-D7urgxeq.mjs";
|
|
3
|
+
import { F as routeStreams, G as isZodSchema, H as isJsonMediaType, J as resolveResponseBody, L as streamContentType, M as assertValidStreams, N as encodeStreamBody, S as dueSchedules, U as isStreamResponse, W as isSuccessStatus, X as resolveResponseContentType, Y as resolveResponseCache, Z as resolveResponseEtag, _ as jobAt, c as cacheHeaders, ct as allowedMethodsForPath, dt as isRouteDefinition, ft as validateRequest, h as isCompiledJob, j as EVENT_STREAM_MEDIA_TYPE, k as deriveToolNames, lt as flattenRoutes, m as flattenJobs, pt as resolveCoercionPlans, st as parsePath, u as deprecationHeaders, ut as formatValidationError, y as toJobResponse, z as streamSchemas } from "./plugin-server-DNQ9_DL7.mjs";
|
|
4
|
+
import { l as authenticationChallenge, p as resolveSecurityRequirements } from "./schemas-DBX8DwFb.mjs";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
//#region src/tool-definitions.ts
|
|
7
7
|
/**
|
|
@@ -312,6 +312,64 @@ const assertPathParamsAreScalar = (route, routeKey) => {
|
|
|
312
312
|
}
|
|
313
313
|
};
|
|
314
314
|
/**
|
|
315
|
+
* What a field holds once optional and default wrappers are peeled away: a schema kind, or a file or bytes.
|
|
316
|
+
*/
|
|
317
|
+
const fieldKind = (schema) => {
|
|
318
|
+
const { inner } = unwrapOptionalWrappers(schema);
|
|
319
|
+
if (isFileSchema(inner)) return "file";
|
|
320
|
+
if (isBinarySchema(inner)) return "BinarySchema";
|
|
321
|
+
return resolveBaseType(inner);
|
|
322
|
+
};
|
|
323
|
+
const listElement = (schema) => {
|
|
324
|
+
const def = readDef(unwrapOptionalWrappers(schema).inner);
|
|
325
|
+
return def.type === "array" ? def.element : void 0;
|
|
326
|
+
};
|
|
327
|
+
const isValue = (kind) => !STRUCTURED_TYPES.has(kind) && kind !== "file" && kind !== "BinarySchema";
|
|
328
|
+
/**
|
|
329
|
+
* Names a field the way an error shows it: its kind, or what a list holds.
|
|
330
|
+
*/
|
|
331
|
+
const describeField = (schema) => {
|
|
332
|
+
const element = listElement(schema);
|
|
333
|
+
return element === void 0 ? fieldKind(schema) : `array of ${fieldKind(element)}`;
|
|
334
|
+
};
|
|
335
|
+
const fieldsOf = (schema) => Object.entries((schema && readObjectShape(schema)) ?? {});
|
|
336
|
+
/**
|
|
337
|
+
* A query string carries values and lists of values, the way OpenAPI's default `form` style sends them.
|
|
338
|
+
*/
|
|
339
|
+
const assertQuerySendable = (route, routeKey) => {
|
|
340
|
+
for (const [name, field] of fieldsOf(route.query)) {
|
|
341
|
+
const element = listElement(field);
|
|
342
|
+
if (element === void 0 ? isValue(fieldKind(field)) : isValue(fieldKind(element))) continue;
|
|
343
|
+
throw new Error(`Route "${routeKey}" declares query field "${name}" as ${describeField(field)}. A query string carries values and lists of values, so this cannot be sent.
|
|
344
|
+
Split it into fields of their own, or move it to a body.`);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
/**
|
|
348
|
+
* A header carries one value.
|
|
349
|
+
*/
|
|
350
|
+
const assertHeadersSendable = (route, routeKey) => {
|
|
351
|
+
for (const [name, field] of fieldsOf(route.headers)) {
|
|
352
|
+
if (listElement(field) === void 0 && isValue(fieldKind(field))) continue;
|
|
353
|
+
throw new Error(`Route "${routeKey}" declares header "${name}" as ${describeField(field)}. A header carries one value, so this cannot be sent.
|
|
354
|
+
Use a scalar schema (z.string(), z.int(), z.enum([...])), or split it into headers of their own.`);
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* A form carries values and lists of values, and a multipart one carries files too (RFC 7578).
|
|
359
|
+
*/
|
|
360
|
+
const assertFormFieldsSendable = (route, routeKey) => {
|
|
361
|
+
if (route.contentType !== "multipart/form-data" && route.contentType !== "application/x-www-form-urlencoded") return;
|
|
362
|
+
const multipart = route.contentType === "multipart/form-data";
|
|
363
|
+
for (const [name, field] of fieldsOf(route.body)) {
|
|
364
|
+
const kind = fieldKind(listElement(field) ?? field);
|
|
365
|
+
if (kind === "BinarySchema") throw new Error(`Route "${routeKey}" declares form field "${name}" as BinarySchema, but a form sends a file part as a File. Declare it with FileSchema.`);
|
|
366
|
+
if (kind === "file" && !multipart) throw new Error(`Route "${routeKey}" declares form field "${name}" as a file, which a urlencoded body cannot carry. Send it as contentType: 'multipart/form-data'.`);
|
|
367
|
+
if (kind === "file" || isValue(kind)) continue;
|
|
368
|
+
throw new Error(`Route "${routeKey}" declares form field "${name}" as ${describeField(field)}. A form carries values, lists of values and files, so this cannot be sent.
|
|
369
|
+
Split it into fields of their own, or take the body as JSON.`);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
/**
|
|
315
373
|
* A tool's description is the one thing a model reads before choosing it, so a
|
|
316
374
|
* route that publishes as one has to carry it.
|
|
317
375
|
*/
|
|
@@ -328,6 +386,9 @@ const validateRoutes = (routes, prefix) => {
|
|
|
328
386
|
expandStreamTools(value, fullKey);
|
|
329
387
|
assertPathParamsMatchPath(value, fullKey);
|
|
330
388
|
assertPathParamsAreScalar(value, fullKey);
|
|
389
|
+
assertQuerySendable(value, fullKey);
|
|
390
|
+
assertHeadersSendable(value, fullKey);
|
|
391
|
+
assertFormFieldsSendable(value, fullKey);
|
|
331
392
|
assertNoCoercion(value, fullKey);
|
|
332
393
|
assertValidStreams(value, fullKey);
|
|
333
394
|
assertToolDescribed(value, fullKey);
|
|
@@ -2226,9 +2287,12 @@ const renderResult = (result, formatError, request) => {
|
|
|
2226
2287
|
case "handler-error": return renderError(500, "Internal Server Error", void 0, result.headers);
|
|
2227
2288
|
}
|
|
2228
2289
|
};
|
|
2229
|
-
|
|
2290
|
+
/**
|
|
2291
|
+
* A query string or form as an object. A repeated key collects every value into a list.
|
|
2292
|
+
*/
|
|
2293
|
+
const entriesToObject = (source) => {
|
|
2230
2294
|
const result = {};
|
|
2231
|
-
for (const [key, value] of
|
|
2295
|
+
for (const [key, value] of source.entries()) {
|
|
2232
2296
|
const existing = result[key];
|
|
2233
2297
|
if (existing === void 0) result[key] = value;
|
|
2234
2298
|
else if (Array.isArray(existing)) existing.push(value);
|
|
@@ -2241,7 +2305,7 @@ const formDataToObject = (form) => {
|
|
|
2241
2305
|
* whose text core already read.
|
|
2242
2306
|
*/
|
|
2243
2307
|
const parseBodyText = (text, route) => {
|
|
2244
|
-
if (route.contentType === "application/x-www-form-urlencoded") return
|
|
2308
|
+
if (route.contentType === "application/x-www-form-urlencoded") return entriesToObject(new URLSearchParams(text));
|
|
2245
2309
|
return text.length > 0 ? JSON.parse(text) : void 0;
|
|
2246
2310
|
};
|
|
2247
2311
|
/**
|
|
@@ -2252,8 +2316,8 @@ const parseBodyText = (text, route) => {
|
|
|
2252
2316
|
* */
|
|
2253
2317
|
const parseFetchBody = async (request, route) => {
|
|
2254
2318
|
switch (route.contentType) {
|
|
2255
|
-
case "multipart/form-data": return
|
|
2256
|
-
case "application/x-www-form-urlencoded": return
|
|
2319
|
+
case "multipart/form-data": return entriesToObject(await request.formData());
|
|
2320
|
+
case "application/x-www-form-urlencoded": return entriesToObject(new URLSearchParams(await request.text()));
|
|
2257
2321
|
default: {
|
|
2258
2322
|
const text = await request.text();
|
|
2259
2323
|
return text.length > 0 ? JSON.parse(text) : void 0;
|
|
@@ -2268,4 +2332,4 @@ const headersToObject = (headers) => {
|
|
|
2268
2332
|
return result;
|
|
2269
2333
|
};
|
|
2270
2334
|
//#endregion
|
|
2271
|
-
export {
|
|
2335
|
+
export { dispatchDueJobs as $, parseFetchBody as A, matchRoute as B, guardDenyFor as C, toolRefusal as Ct, jobRoutes as D, jobRouter as E, warnUnsupportedJobOptions as F, JobDispatchError as G, insufficientScope as H, isRawResponse as I, createJobRunner as J, defineJobTransport as K, rawResponse as L, routerFromRoutes as M, runHandler as N, jobRunnerFrom as O, runRoute as P, DispatchResultSchema as Q, assertNoPathCollisions as R, getHeaderValue as S, toolOptionsOf as St, isGuardDenial as T, requiresDenial as U, sortFlattenedRoutes as V, withPermissions as W, ResponseError as X, jobFnAt as Y, DispatchFailedSchema as Z, defineAdapter as _, toolEvents as _t, HANDLER_ARG_KEYS as a, STATUS_TITLES as at, entriesToObject as b, describeTool as bt, ROUTER_META as c, createRoles as ct, SCHEMES_META as d, permissionNames as dt, dispatchSucceeded as et, adapterContextOf as f, createGroups as ft, contractOf as g, expandStreamTools as gt, boundJobKeys as h, groupRoutes as ht, GUARD_SCHEMA_META as i, problemFromBody as it, renderJsonResult as j, parseBodyText as k, RUN_ROUTE_KEY as l, isPermissions as lt, bearerChallenge as m, assembleRoutes as mt, DISPATCH_ROUTE_KEY as n, failedJobs as nt, JOBS_META as o, getStatusText as ot, assembleApi as p, isGroupSet as pt, JobInputError as q, GUARDS_META as r, problemDetails as rt, REQUEST_CONTEXT_META as s, createPermissions as st, API_META as t, dueJobs as tt, ResponseValidationError as u, isRoles as ut, dispatchHandler as v, buildToolDefinitions as vt, headersToObject as w, extractCredential as x, selectToolRoutes as xt, dispatchRoute as y, buildToolInputSchema as yt, routeClaims as z };
|
|
@@ -2737,6 +2737,10 @@ interface RenderedResult {
|
|
|
2737
2737
|
declare const renderJsonResult: (result: Exclude<AdapterResult, {
|
|
2738
2738
|
kind: "raw-response";
|
|
2739
2739
|
}>, formatError?: ErrorFormatter, request?: unknown, requestMethod?: string) => RenderedResult;
|
|
2740
|
+
/**
|
|
2741
|
+
* A query string or form as an object. A repeated key collects every value into a list.
|
|
2742
|
+
*/
|
|
2743
|
+
declare const entriesToObject: (source: URLSearchParams | FormData) => Record<string, unknown>;
|
|
2740
2744
|
/**
|
|
2741
2745
|
* Parse a body from its text, the way {@link parseFetchBody} would, for a route
|
|
2742
2746
|
* whose text core already read.
|
|
@@ -2751,4 +2755,4 @@ declare const parseBodyText: (text: string, route: RouteDefinition) => unknown;
|
|
|
2751
2755
|
declare const parseFetchBody: (request: Request, route: RouteDefinition) => Promise<unknown>;
|
|
2752
2756
|
declare const headersToObject: (headers: Headers) => ResponseHeaders;
|
|
2753
2757
|
//#endregion
|
|
2754
|
-
export {
|
|
2758
|
+
export { jobRoutes as $, StreamComment as $i, isJobDefinition as $n, AuthContextOf as $r, PluginsBySlug as $t, RenderedResult as A, BearerConfig as Aa, ToolRunOptions as Ai, RoutesOf as An, parseCron as Ar, sanitizeIdentifier as At, bearerChallenge as B, NoCredential as Ba, ExtractPathParams as Bi, JobHandler as Bn, GroupSet as Br, PluginApi as Bt, JOBS_META as C, insufficientScope as Ca, isRouteDefinition as Ci, GeneratedFile as Cn, ParsedCron as Cr, resolveResponseBody as Ct, REQUEST_CONTEXT_META as D, ApiKeyCredential as Da, ToolAnswer as Di, GuardSchemaOf as Dn, firesBetween as Dr, resolveResponseHeaders as Dt, MountedOf as E, ApiKeyConfig as Ea, StreamTools as Ei, ApiPluginsOf as En, dueSchedules as Er, resolveResponseEtag as Et, RouteMatcher as F, GrantsOf as Fa, buildToolInputSchema as Fi, CompiledJobs as Fn, RequestContextHeaderValues as Fr, AnyPlugin as Ft, dispatchRoute as G, RoutePathParamsCheck as Gi, JobRunnerConfig as Gn, isRawResponse as Gr, PluginExportsOf as Gt, contractOf as H, OpenIdConnectConfig as Ha, PathParamName as Hi, JobHandlerReturn as Hn, createGroups as Hr, PluginDeclaration as Ht, SCHEMES_META as I, GuardHoldings as Ia, describeTool as Ii, FlattenedJob as In, RequestContextSchema as Ir, ApiPlugins as It, getHeaderValue as J, EVENT_STREAM_MEDIA_TYPE as Ji, JobsArg as Jn, RouteWithHandler as Jr, PluginRouteBuilder as Jt, entriesToObject as K, buildPath as Ki, JobVoidReturn as Kn, rawResponse as Kr, PluginFactory as Kt, ServerOptions as L, Identity as La, selectToolRoutes as Li, HttpJobsConfig as Ln, GroupOptions as Lr, InstallOptions as Lt, RequestContextRun as M, Credential as Ma, ToolDefinition as Mi, AuthoredJobDefinition as Mn, scheduleTimezone as Mr, statusToCamelCase as Mt, RequestPipeline as N, CredentialOf as Na, ToolInputSchema as Ni, AuthoredJobs as Nn, RequestContextConfig as Nr, toCamelCase as Nt, ROUTER_META as O, BasicConfig as Oa, ToolEventYield as Oi, JobsOf as On, nextRun as Or, resolveResponseStream as Ot, ResponseValidationError as P, CustomConfig as Pa, buildToolDefinitions as Pi, CompiledJob as Pn, RequestContextHeaderInputs as Pr, toPascalCase as Pt, jobRouter as Q, StreamChunk as Qi, isCompiledJob as Qn, sortFlattenedRoutes as Qr, PluginSetupContext as Qt, adapterContextOf as R, IdentityParamsOf as Ra, toolOptionsOf as Ri, InProcessJobsConfig as Rn, GroupPaths as Rr, PLUGIN_ROUTES_META_KEY as Rt, HandlerContextOf as S, AccessCheckInput as Sa, formatValidationError as Si, DiffSettings as Sn, JobSchedule as Sr, mergeHeaderFields as St, MountArgsOf as T, withPermissions as Ta, ModelToolCall as Ti, ApiDefinition as Tn, cron as Tr, resolveResponseContentType as Tt, defineAdapter as U, RoleOf as Ua, PathParamsCheck as Ui, JobHandlers as Un, isGroupSet as Ur, PluginDefinition as Ut, boundJobKeys as V, OAuth2Config as Va, HasPathParams as Vi, JobHandlerArgs as Vn, ResolvedGroup as Vr, PluginArgs as Vt, dispatchHandler as W, RolesOf as Wa, PathSegment as Wi, JobResponses as Wn, RawResponse as Wr, PluginExportValues as Wt, headersToObject as X, StreamBody as Xi, NoJobs as Xn, RouteMatch as Xr, PluginRoutesOf as Xt, guardDenyFor as Y, EncodeStreamOptions as Yi, JobsConfig as Yn, MatchResult as Yr, PluginRoutes as Yt, isGuardDenial as Z, StreamBodyOf as Zi, flattenJobs as Zn, matchRoute as Zr, PluginSetup as Zt, GuardDeny as _, ToolEvents as _a, ThrowableReturn as _i, ConfiguredRequestContextSchemas as _n, JobTransportSupports as _r, isJsonMediaType as _t, AdapterRequest as a, encodeStreamBody as aa, GuardReturn as ai, pluginRouteTree as an, JobQueueArgs as ar, runHandler as at, HANDLER_ARG_KEYS as b, expandStreamTools as ba, allowedMethodsForPath as bi, KizunaConfigShape as bn, ScheduledJob as br, isZodSchema as bt, ApiBrand as c, soleStreamResponse as ca, HandlerArgs as ci, ConfiguredAdapterContext as cn, JobRunner as cr, ApiRouter as ct, DISPATCH_ROUTE_KEY as d, streamSchemas as da, RawInputs as di, ConfiguredGroups as dn, jobFnAt as dr, createApiReference as dt, StreamContext as ea, BrandedHandlerContext as ei, ResolvedPlugin as en, jobAt as er, jobRunnerFrom as et, ErrorFormatter as f, streamStatuses as fa, RequestContextValues as fi, ConfiguredGuardSchema as fn, JobDescriptor as fr, pluginExportsOf as ft, GuardDenialBody as g, ToolError as ga, RoutesWithHandlerContext as gi, ConfiguredRequestContext as gn, JobTransportDefinition as gr, isHintPrefix as gt, GuardDenial as h, ToolCall as ha, Router as hi, ConfiguredPlugins as hn, JobTransport as hr, resolvePlugins as ht, AdapterDefinition as i, StreamYield as ia, GuardParams as ii, definePlugin as in, JobInputError as ir, routerFromRoutes as it, RequestContextMap as j, BearerCredential as ja, ToolRunResult as ji, SchemesOf as jn, scheduleExpression as jr, shortTypeName as jt, RUN_ROUTE_KEY as k, BasicCredential as ka, ToolRunCall as ki, RequestContextOf as kn, nextRuns as kr, sanitizeFieldName as kt, ApiParts as l, streamContentType as la, HandlerReturn as li, ConfiguredAdapterValue as ln, JobRunnerOptions as lr, ResponseError as lt, GUARD_SCHEMA_META as m, ToolAt as ma, RouteHandler as mi, ConfiguredJobs as mn, JobMessage as mr, pluginRoutesOf as mt, API_META as n, StreamMessageOf as na, FlattenedRoute as ni, RoutePathSchema as nn, JobFn as nr, parseFetchBody as nt, AdapterResult as o, isNamedStream as oa, GuardSuccess as oi, route as on, JobQueueOptions as or, runRoute as ot, GUARDS_META as p, StreamWithTools as pa, RouteGuardBrandOf as pi, ConfiguredIdentities as pn, JobDispatchError as pr, pluginRouterOf as pt, extractCredential as q, parsePath as qi, Jobs as qn, RouteBuilder as qr, PluginList as qt, Adapter as r, StreamMode as ra, GuardAnswer as ri, SlugOption as rn, JobFnByKey as rr, renderJsonResult as rt, AnyAdapter as s, routeStreams as sa, GuardedParamNames as si, ApiContext as sn, JobRunArgs as sr, warnUnsupportedJobOptions as st, ADAPTER_CONTEXT as t, StreamMessage as ta, ContextFromAuth as ti, RouteAuthSchema as tn, JobErrorHandler as tr, parseBodyText as tt, ApiWithRouter as u, streamMode as ua, HandlersFromRoutes as ui, ConfiguredCodes as un, createJobRunner as ur, groupRoutes as ut, GuardMap as v, ToolKeys as va, ValidationFailure as vi, JobFnOf as vn, JobWorker as vr, isStreamResponse as vt, JobsMeta as w, requiresDenial as wa, validateRequest as wi, apiEntries as wn, assertValidSchedule as wr, resolveResponseCache as wt, HandleArgs as x, toolEvents as xa, flattenRoutes as xi, ApiEntry as xn, defineJobTransport as xr, localTypeName as xt, GuardRun as y, ToolResult as ya, ValidationStage as yi, JobsOfTree as yn, JobWorkerContext as yr, isSuccessStatus as yt, assembleApi as z, IdentityRole as za, toolRefusal as zi, JobDefinition as zn, GroupPathsOf as zr, PLUGIN_SERVERS_META_KEY as zt };
|
package/dist/adapter.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_plugin = require("./plugin-Dw-yCjTY.cjs");
|
|
3
|
-
const require_plugin_server = require("./plugin-server-
|
|
4
|
-
const require_schemas = require("./schemas-
|
|
5
|
-
const require_adapter = require("./adapter-
|
|
3
|
+
const require_plugin_server = require("./plugin-server-CfF82yZL.cjs");
|
|
4
|
+
const require_schemas = require("./schemas-Bre1FVHq.cjs");
|
|
5
|
+
const require_adapter = require("./adapter-CK8ccDOC.cjs");
|
|
6
6
|
exports.API_META = require_adapter.API_META;
|
|
7
7
|
exports.AUTO_GUARD_BRAND = require_plugin.AUTO_GUARD_BRAND;
|
|
8
8
|
exports.AUTO_RESPONSES_BRAND = require_plugin.AUTO_RESPONSES_BRAND;
|
|
@@ -40,6 +40,7 @@ exports.describeTool = require_adapter.describeTool;
|
|
|
40
40
|
exports.dispatchHandler = require_adapter.dispatchHandler;
|
|
41
41
|
exports.dispatchRoute = require_adapter.dispatchRoute;
|
|
42
42
|
exports.encodeStreamBody = require_plugin_server.encodeStreamBody;
|
|
43
|
+
exports.entriesToObject = require_adapter.entriesToObject;
|
|
43
44
|
exports.extractCredential = require_adapter.extractCredential;
|
|
44
45
|
exports.flattenJobs = require_plugin_server.flattenJobs;
|
|
45
46
|
exports.flattenRoutes = require_plugin_server.flattenRoutes;
|
package/dist/adapter.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { A as AutoResponsesBrand, B as ROUTES_GROUP, D as AUTO_RESPONSES_BRAND, I as HANDLER_CONTEXT_BRAND, K as RouteDefinition, L as HandlerContextBrand, T as AUTO_GUARD_BRAND, W as ResponseHeaders, Y as RoutePath, Z as Routes, at as ProblemDetails, c as authenticationChallenge, f as resolveSecurityRequirements, st as problemDetails, z as Method } from "./error-response-YbkRMKno.cjs";
|
|
2
|
-
import { $ as
|
|
3
|
-
export { ADAPTER_CONTEXT, API_META, AUTO_GUARD_BRAND, AUTO_RESPONSES_BRAND, AccessCheckInput, Adapter, AdapterDefinition, AdapterRequest, AdapterResult, AnyAdapter, ApiBrand, ApiParts, ApiPlugins, ApiRouter, ApiWithRouter, AutoResponsesBrand, BrandedHandlerContext, CompiledJob, ContextFromAuth, DISPATCH_ROUTE_KEY, EncodeStreamOptions, ErrorFormatter, FlattenedJob, FlattenedRoute, GUARDS_META, GUARD_SCHEMA_META, GuardDenial, GuardDenialBody, GuardDeny, GuardMap, GuardParams, GuardRun, GuardedParamNames, HANDLER_ARG_KEYS, HANDLER_CONTEXT_BRAND, HandleArgs, HandlerContextBrand, HandlerContextOf, HandlersFromRoutes, JOBS_META, JobDescriptor, JobDispatchError, JobErrorHandler, JobFnByKey, JobHandler, JobHandlers, JobInputError, JobMessage, JobRunner, JobRunnerOptions, JobTransport, JobWorker, JobWorkerContext, Jobs, JobsMeta, MatchResult, Method, MountArgsOf, MountedOf, PathSegment, PluginArgs, PluginDeclaration, PluginDefinition, PluginExportValues, PluginExportsOf, PluginRoutes, PluginRoutesOf, ProblemDetails, REQUEST_CONTEXT_META, ROUTER_META, ROUTES_GROUP, RUN_ROUTE_KEY, RawInputs, RawResponse, RenderedResult, RequestContextMap, RequestContextRun, RequestContextValues, RequestPipeline, ResolvedPlugin, ResponseError, ResponseHeaders, ResponseValidationError, RouteDefinition, RouteHandler, RouteMatch, RouteMatcher, RoutePath, Router, Routes, RoutesWithHandlerContext, SCHEMES_META, ScheduledJob, ServerOptions, StreamContext, ToolDefinition, ToolInputSchema, ValidationFailure, ValidationStage, adapterContextOf, allowedMethodsForPath, assembleApi, authenticationChallenge, bearerChallenge, boundJobKeys, buildPath, buildToolDefinitions, buildToolInputSchema, contractOf, createApiReference, createJobRunner, defineAdapter, defineJobTransport, definePlugin, describeTool, dispatchHandler, dispatchRoute, encodeStreamBody, extractCredential, flattenJobs, flattenRoutes, formatValidationError, getHeaderValue, groupRoutes, guardDenyFor, headersToObject, insufficientScope, isCompiledJob, isGroupSet, isGuardDenial, isRawResponse, isRouteDefinition, isStreamResponse, jobAt, jobFnAt, jobRouter, jobRoutes, jobRunnerFrom, matchRoute, parseBodyText, parseFetchBody, parsePath, pluginExportsOf, pluginRouteTree, pluginRouterOf, pluginRoutesOf, problemDetails, rawResponse, renderJsonResult, requiresDenial, resolvePlugins, resolveSecurityRequirements, routerFromRoutes, runHandler, runRoute, selectToolRoutes, sortFlattenedRoutes, toolOptionsOf, toolRefusal, validateRequest, warnUnsupportedJobOptions, withPermissions };
|
|
2
|
+
import { $ as jobRoutes, A as RenderedResult, B as bearerChallenge, Bn as JobHandler, C as JOBS_META, Ca as insufficientScope, Ci as isRouteDefinition, D as REQUEST_CONTEXT_META, E as MountedOf, F as RouteMatcher, Fi as buildToolInputSchema, G as dispatchRoute, Gr as isRawResponse, Gt as PluginExportsOf, H as contractOf, Ht as PluginDeclaration, I as SCHEMES_META, Ii as describeTool, In as FlattenedJob, It as ApiPlugins, J as getHeaderValue, K as entriesToObject, Ki as buildPath, Kr as rawResponse, L as ServerOptions, Li as selectToolRoutes, M as RequestContextRun, Mi as ToolDefinition, N as RequestPipeline, Ni as ToolInputSchema, O as ROUTER_META, P as ResponseValidationError, Pi as buildToolDefinitions, Pn as CompiledJob, Q as jobRouter, Qn as isCompiledJob, Qr as sortFlattenedRoutes, R as adapterContextOf, Ri as toolOptionsOf, S as HandlerContextOf, Sa as AccessCheckInput, Si as formatValidationError, T as MountArgsOf, Ta as withPermissions, U as defineAdapter, Un as JobHandlers, Ur as isGroupSet, Ut as PluginDefinition, V as boundJobKeys, Vt as PluginArgs, W as dispatchHandler, Wi as PathSegment, Wr as RawResponse, Wt as PluginExportValues, X as headersToObject, Xr as RouteMatch, Xt as PluginRoutesOf, Y as guardDenyFor, Yi as EncodeStreamOptions, Yr as MatchResult, Yt as PluginRoutes, Z as isGuardDenial, Zn as flattenJobs, Zr as matchRoute, _ as GuardDeny, a as AdapterRequest, aa as encodeStreamBody, an as pluginRouteTree, at as runHandler, b as HANDLER_ARG_KEYS, bi as allowedMethodsForPath, br as ScheduledJob, c as ApiBrand, cr as JobRunner, ct as ApiRouter, d as DISPATCH_ROUTE_KEY, di as RawInputs, dr as jobFnAt, dt as createApiReference, ea as StreamContext, ei as BrandedHandlerContext, en as ResolvedPlugin, er as jobAt, et as jobRunnerFrom, f as ErrorFormatter, fi as RequestContextValues, fr as JobDescriptor, ft as pluginExportsOf, g as GuardDenialBody, gi as RoutesWithHandlerContext, h as GuardDenial, hi as Router, hr as JobTransport, ht as resolvePlugins, i as AdapterDefinition, ii as GuardParams, in as definePlugin, ir as JobInputError, it as routerFromRoutes, j as RequestContextMap, k as RUN_ROUTE_KEY, l as ApiParts, lr as JobRunnerOptions, lt as ResponseError, m as GUARD_SCHEMA_META, mi as RouteHandler, mr as JobMessage, mt as pluginRoutesOf, n as API_META, ni as FlattenedRoute, nt as parseFetchBody, o as AdapterResult, ot as runRoute, p as GUARDS_META, pr as JobDispatchError, pt as pluginRouterOf, q as extractCredential, qi as parsePath, qn as Jobs, r as Adapter, rr as JobFnByKey, rt as renderJsonResult, s as AnyAdapter, si as GuardedParamNames, st as warnUnsupportedJobOptions, t as ADAPTER_CONTEXT, ti as ContextFromAuth, tr as JobErrorHandler, tt as parseBodyText, u as ApiWithRouter, ui as HandlersFromRoutes, ur as createJobRunner, ut as groupRoutes, v as GuardMap, vi as ValidationFailure, vr as JobWorker, vt as isStreamResponse, w as JobsMeta, wa as requiresDenial, wi as validateRequest, x as HandleArgs, xi as flattenRoutes, xr as defineJobTransport, y as GuardRun, yi as ValidationStage, yr as JobWorkerContext, z as assembleApi, zi as toolRefusal } from "./adapter-nQIkQwsM.cjs";
|
|
3
|
+
export { ADAPTER_CONTEXT, API_META, AUTO_GUARD_BRAND, AUTO_RESPONSES_BRAND, AccessCheckInput, Adapter, AdapterDefinition, AdapterRequest, AdapterResult, AnyAdapter, ApiBrand, ApiParts, ApiPlugins, ApiRouter, ApiWithRouter, AutoResponsesBrand, BrandedHandlerContext, CompiledJob, ContextFromAuth, DISPATCH_ROUTE_KEY, EncodeStreamOptions, ErrorFormatter, FlattenedJob, FlattenedRoute, GUARDS_META, GUARD_SCHEMA_META, GuardDenial, GuardDenialBody, GuardDeny, GuardMap, GuardParams, GuardRun, GuardedParamNames, HANDLER_ARG_KEYS, HANDLER_CONTEXT_BRAND, HandleArgs, HandlerContextBrand, HandlerContextOf, HandlersFromRoutes, JOBS_META, JobDescriptor, JobDispatchError, JobErrorHandler, JobFnByKey, JobHandler, JobHandlers, JobInputError, JobMessage, JobRunner, JobRunnerOptions, JobTransport, JobWorker, JobWorkerContext, Jobs, JobsMeta, MatchResult, Method, MountArgsOf, MountedOf, PathSegment, PluginArgs, PluginDeclaration, PluginDefinition, PluginExportValues, PluginExportsOf, PluginRoutes, PluginRoutesOf, ProblemDetails, REQUEST_CONTEXT_META, ROUTER_META, ROUTES_GROUP, RUN_ROUTE_KEY, RawInputs, RawResponse, RenderedResult, RequestContextMap, RequestContextRun, RequestContextValues, RequestPipeline, ResolvedPlugin, ResponseError, ResponseHeaders, ResponseValidationError, RouteDefinition, RouteHandler, RouteMatch, RouteMatcher, RoutePath, Router, Routes, RoutesWithHandlerContext, SCHEMES_META, ScheduledJob, ServerOptions, StreamContext, ToolDefinition, ToolInputSchema, ValidationFailure, ValidationStage, adapterContextOf, allowedMethodsForPath, assembleApi, authenticationChallenge, bearerChallenge, boundJobKeys, buildPath, buildToolDefinitions, buildToolInputSchema, contractOf, createApiReference, createJobRunner, defineAdapter, defineJobTransport, definePlugin, describeTool, dispatchHandler, dispatchRoute, encodeStreamBody, entriesToObject, extractCredential, flattenJobs, flattenRoutes, formatValidationError, getHeaderValue, groupRoutes, guardDenyFor, headersToObject, insufficientScope, isCompiledJob, isGroupSet, isGuardDenial, isRawResponse, isRouteDefinition, isStreamResponse, jobAt, jobFnAt, jobRouter, jobRoutes, jobRunnerFrom, matchRoute, parseBodyText, parseFetchBody, parsePath, pluginExportsOf, pluginRouteTree, pluginRouterOf, pluginRoutesOf, problemDetails, rawResponse, renderJsonResult, requiresDenial, resolvePlugins, resolveSecurityRequirements, routerFromRoutes, runHandler, runRoute, selectToolRoutes, sortFlattenedRoutes, toolOptionsOf, toolRefusal, validateRequest, warnUnsupportedJobOptions, withPermissions };
|
package/dist/adapter.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { A as AutoResponsesBrand, B as ROUTES_GROUP, D as AUTO_RESPONSES_BRAND, I as HANDLER_CONTEXT_BRAND, K as RouteDefinition, L as HandlerContextBrand, T as AUTO_GUARD_BRAND, W as ResponseHeaders, Y as RoutePath, Z as Routes, at as ProblemDetails, c as authenticationChallenge, f as resolveSecurityRequirements, st as problemDetails, z as Method } from "./error-response-NoOGdh8H.mjs";
|
|
2
|
-
import { $ as
|
|
3
|
-
export { ADAPTER_CONTEXT, API_META, AUTO_GUARD_BRAND, AUTO_RESPONSES_BRAND, AccessCheckInput, Adapter, AdapterDefinition, AdapterRequest, AdapterResult, AnyAdapter, ApiBrand, ApiParts, ApiPlugins, ApiRouter, ApiWithRouter, AutoResponsesBrand, BrandedHandlerContext, CompiledJob, ContextFromAuth, DISPATCH_ROUTE_KEY, EncodeStreamOptions, ErrorFormatter, FlattenedJob, FlattenedRoute, GUARDS_META, GUARD_SCHEMA_META, GuardDenial, GuardDenialBody, GuardDeny, GuardMap, GuardParams, GuardRun, GuardedParamNames, HANDLER_ARG_KEYS, HANDLER_CONTEXT_BRAND, HandleArgs, HandlerContextBrand, HandlerContextOf, HandlersFromRoutes, JOBS_META, JobDescriptor, JobDispatchError, JobErrorHandler, JobFnByKey, JobHandler, JobHandlers, JobInputError, JobMessage, JobRunner, JobRunnerOptions, JobTransport, JobWorker, JobWorkerContext, Jobs, JobsMeta, MatchResult, Method, MountArgsOf, MountedOf, PathSegment, PluginArgs, PluginDeclaration, PluginDefinition, PluginExportValues, PluginExportsOf, PluginRoutes, PluginRoutesOf, ProblemDetails, REQUEST_CONTEXT_META, ROUTER_META, ROUTES_GROUP, RUN_ROUTE_KEY, RawInputs, RawResponse, RenderedResult, RequestContextMap, RequestContextRun, RequestContextValues, RequestPipeline, ResolvedPlugin, ResponseError, ResponseHeaders, ResponseValidationError, RouteDefinition, RouteHandler, RouteMatch, RouteMatcher, RoutePath, Router, Routes, RoutesWithHandlerContext, SCHEMES_META, ScheduledJob, ServerOptions, StreamContext, ToolDefinition, ToolInputSchema, ValidationFailure, ValidationStage, adapterContextOf, allowedMethodsForPath, assembleApi, authenticationChallenge, bearerChallenge, boundJobKeys, buildPath, buildToolDefinitions, buildToolInputSchema, contractOf, createApiReference, createJobRunner, defineAdapter, defineJobTransport, definePlugin, describeTool, dispatchHandler, dispatchRoute, encodeStreamBody, extractCredential, flattenJobs, flattenRoutes, formatValidationError, getHeaderValue, groupRoutes, guardDenyFor, headersToObject, insufficientScope, isCompiledJob, isGroupSet, isGuardDenial, isRawResponse, isRouteDefinition, isStreamResponse, jobAt, jobFnAt, jobRouter, jobRoutes, jobRunnerFrom, matchRoute, parseBodyText, parseFetchBody, parsePath, pluginExportsOf, pluginRouteTree, pluginRouterOf, pluginRoutesOf, problemDetails, rawResponse, renderJsonResult, requiresDenial, resolvePlugins, resolveSecurityRequirements, routerFromRoutes, runHandler, runRoute, selectToolRoutes, sortFlattenedRoutes, toolOptionsOf, toolRefusal, validateRequest, warnUnsupportedJobOptions, withPermissions };
|
|
2
|
+
import { $ as jobRoutes, A as RenderedResult, B as bearerChallenge, Bn as JobHandler, C as JOBS_META, Ca as insufficientScope, Ci as isRouteDefinition, D as REQUEST_CONTEXT_META, E as MountedOf, F as RouteMatcher, Fi as buildToolInputSchema, G as dispatchRoute, Gr as isRawResponse, Gt as PluginExportsOf, H as contractOf, Ht as PluginDeclaration, I as SCHEMES_META, Ii as describeTool, In as FlattenedJob, It as ApiPlugins, J as getHeaderValue, K as entriesToObject, Ki as buildPath, Kr as rawResponse, L as ServerOptions, Li as selectToolRoutes, M as RequestContextRun, Mi as ToolDefinition, N as RequestPipeline, Ni as ToolInputSchema, O as ROUTER_META, P as ResponseValidationError, Pi as buildToolDefinitions, Pn as CompiledJob, Q as jobRouter, Qn as isCompiledJob, Qr as sortFlattenedRoutes, R as adapterContextOf, Ri as toolOptionsOf, S as HandlerContextOf, Sa as AccessCheckInput, Si as formatValidationError, T as MountArgsOf, Ta as withPermissions, U as defineAdapter, Un as JobHandlers, Ur as isGroupSet, Ut as PluginDefinition, V as boundJobKeys, Vt as PluginArgs, W as dispatchHandler, Wi as PathSegment, Wr as RawResponse, Wt as PluginExportValues, X as headersToObject, Xr as RouteMatch, Xt as PluginRoutesOf, Y as guardDenyFor, Yi as EncodeStreamOptions, Yr as MatchResult, Yt as PluginRoutes, Z as isGuardDenial, Zn as flattenJobs, Zr as matchRoute, _ as GuardDeny, a as AdapterRequest, aa as encodeStreamBody, an as pluginRouteTree, at as runHandler, b as HANDLER_ARG_KEYS, bi as allowedMethodsForPath, br as ScheduledJob, c as ApiBrand, cr as JobRunner, ct as ApiRouter, d as DISPATCH_ROUTE_KEY, di as RawInputs, dr as jobFnAt, dt as createApiReference, ea as StreamContext, ei as BrandedHandlerContext, en as ResolvedPlugin, er as jobAt, et as jobRunnerFrom, f as ErrorFormatter, fi as RequestContextValues, fr as JobDescriptor, ft as pluginExportsOf, g as GuardDenialBody, gi as RoutesWithHandlerContext, h as GuardDenial, hi as Router, hr as JobTransport, ht as resolvePlugins, i as AdapterDefinition, ii as GuardParams, in as definePlugin, ir as JobInputError, it as routerFromRoutes, j as RequestContextMap, k as RUN_ROUTE_KEY, l as ApiParts, lr as JobRunnerOptions, lt as ResponseError, m as GUARD_SCHEMA_META, mi as RouteHandler, mr as JobMessage, mt as pluginRoutesOf, n as API_META, ni as FlattenedRoute, nt as parseFetchBody, o as AdapterResult, ot as runRoute, p as GUARDS_META, pr as JobDispatchError, pt as pluginRouterOf, q as extractCredential, qi as parsePath, qn as Jobs, r as Adapter, rr as JobFnByKey, rt as renderJsonResult, s as AnyAdapter, si as GuardedParamNames, st as warnUnsupportedJobOptions, t as ADAPTER_CONTEXT, ti as ContextFromAuth, tr as JobErrorHandler, tt as parseBodyText, u as ApiWithRouter, ui as HandlersFromRoutes, ur as createJobRunner, ut as groupRoutes, v as GuardMap, vi as ValidationFailure, vr as JobWorker, vt as isStreamResponse, w as JobsMeta, wa as requiresDenial, wi as validateRequest, x as HandleArgs, xi as flattenRoutes, xr as defineJobTransport, y as GuardRun, yi as ValidationStage, yr as JobWorkerContext, z as assembleApi, zi as toolRefusal } from "./adapter-BdkB6ql9.mjs";
|
|
3
|
+
export { ADAPTER_CONTEXT, API_META, AUTO_GUARD_BRAND, AUTO_RESPONSES_BRAND, AccessCheckInput, Adapter, AdapterDefinition, AdapterRequest, AdapterResult, AnyAdapter, ApiBrand, ApiParts, ApiPlugins, ApiRouter, ApiWithRouter, AutoResponsesBrand, BrandedHandlerContext, CompiledJob, ContextFromAuth, DISPATCH_ROUTE_KEY, EncodeStreamOptions, ErrorFormatter, FlattenedJob, FlattenedRoute, GUARDS_META, GUARD_SCHEMA_META, GuardDenial, GuardDenialBody, GuardDeny, GuardMap, GuardParams, GuardRun, GuardedParamNames, HANDLER_ARG_KEYS, HANDLER_CONTEXT_BRAND, HandleArgs, HandlerContextBrand, HandlerContextOf, HandlersFromRoutes, JOBS_META, JobDescriptor, JobDispatchError, JobErrorHandler, JobFnByKey, JobHandler, JobHandlers, JobInputError, JobMessage, JobRunner, JobRunnerOptions, JobTransport, JobWorker, JobWorkerContext, Jobs, JobsMeta, MatchResult, Method, MountArgsOf, MountedOf, PathSegment, PluginArgs, PluginDeclaration, PluginDefinition, PluginExportValues, PluginExportsOf, PluginRoutes, PluginRoutesOf, ProblemDetails, REQUEST_CONTEXT_META, ROUTER_META, ROUTES_GROUP, RUN_ROUTE_KEY, RawInputs, RawResponse, RenderedResult, RequestContextMap, RequestContextRun, RequestContextValues, RequestPipeline, ResolvedPlugin, ResponseError, ResponseHeaders, ResponseValidationError, RouteDefinition, RouteHandler, RouteMatch, RouteMatcher, RoutePath, Router, Routes, RoutesWithHandlerContext, SCHEMES_META, ScheduledJob, ServerOptions, StreamContext, ToolDefinition, ToolInputSchema, ValidationFailure, ValidationStage, adapterContextOf, allowedMethodsForPath, assembleApi, authenticationChallenge, bearerChallenge, boundJobKeys, buildPath, buildToolDefinitions, buildToolInputSchema, contractOf, createApiReference, createJobRunner, defineAdapter, defineJobTransport, definePlugin, describeTool, dispatchHandler, dispatchRoute, encodeStreamBody, entriesToObject, extractCredential, flattenJobs, flattenRoutes, formatValidationError, getHeaderValue, groupRoutes, guardDenyFor, headersToObject, insufficientScope, isCompiledJob, isGroupSet, isGuardDenial, isRawResponse, isRouteDefinition, isStreamResponse, jobAt, jobFnAt, jobRouter, jobRoutes, jobRunnerFrom, matchRoute, parseBodyText, parseFetchBody, parsePath, pluginExportsOf, pluginRouteTree, pluginRouterOf, pluginRoutesOf, problemDetails, rawResponse, renderJsonResult, requiresDenial, resolvePlugins, resolveSecurityRequirements, routerFromRoutes, runHandler, runRoute, selectToolRoutes, sortFlattenedRoutes, toolOptionsOf, toolRefusal, validateRequest, warnUnsupportedJobOptions, withPermissions };
|
package/dist/adapter.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as definePlugin, d as AUTO_RESPONSES_BRAND, g as ROUTES_GROUP, l as AUTO_GUARD_BRAND, m as HANDLER_CONTEXT_BRAND, o as pluginRouteTree } from "./plugin-xxCxibmu.mjs";
|
|
2
|
-
import { N as encodeStreamBody, U as isStreamResponse, _ as jobAt, a as pluginRoutesOf, ct as allowedMethodsForPath, dt as isRouteDefinition, ft as validateRequest, h as isCompiledJob, i as pluginRouterOf, lt as flattenRoutes, m as flattenJobs, o as resolvePlugins, ot as buildPath, r as pluginExportsOf, st as parsePath, t as createApiReference, ut as formatValidationError } from "./plugin-server-
|
|
3
|
-
import { l as authenticationChallenge, p as resolveSecurityRequirements } from "./schemas-
|
|
4
|
-
import { A as
|
|
5
|
-
export { API_META, AUTO_GUARD_BRAND, AUTO_RESPONSES_BRAND, DISPATCH_ROUTE_KEY, GUARDS_META, GUARD_SCHEMA_META, HANDLER_ARG_KEYS, HANDLER_CONTEXT_BRAND, JOBS_META, JobDispatchError, JobInputError, REQUEST_CONTEXT_META, ROUTER_META, ROUTES_GROUP, RUN_ROUTE_KEY, ResponseError, ResponseValidationError, SCHEMES_META, adapterContextOf, allowedMethodsForPath, assembleApi, authenticationChallenge, bearerChallenge, boundJobKeys, buildPath, buildToolDefinitions, buildToolInputSchema, contractOf, createApiReference, createJobRunner, defineAdapter, defineJobTransport, definePlugin, describeTool, dispatchHandler, dispatchRoute, encodeStreamBody, extractCredential, flattenJobs, flattenRoutes, formatValidationError, getHeaderValue, groupRoutes, guardDenyFor, headersToObject, insufficientScope, isCompiledJob, isGroupSet, isGuardDenial, isRawResponse, isRouteDefinition, isStreamResponse, jobAt, jobFnAt, jobRouter, jobRoutes, jobRunnerFrom, matchRoute, parseBodyText, parseFetchBody, parsePath, pluginExportsOf, pluginRouteTree, pluginRouterOf, pluginRoutesOf, problemDetails, rawResponse, renderJsonResult, requiresDenial, resolvePlugins, resolveSecurityRequirements, routerFromRoutes, runHandler, runRoute, selectToolRoutes, sortFlattenedRoutes, toolOptionsOf, toolRefusal, validateRequest, warnUnsupportedJobOptions, withPermissions };
|
|
2
|
+
import { N as encodeStreamBody, U as isStreamResponse, _ as jobAt, a as pluginRoutesOf, ct as allowedMethodsForPath, dt as isRouteDefinition, ft as validateRequest, h as isCompiledJob, i as pluginRouterOf, lt as flattenRoutes, m as flattenJobs, o as resolvePlugins, ot as buildPath, r as pluginExportsOf, st as parsePath, t as createApiReference, ut as formatValidationError } from "./plugin-server-DNQ9_DL7.mjs";
|
|
3
|
+
import { l as authenticationChallenge, p as resolveSecurityRequirements } from "./schemas-DBX8DwFb.mjs";
|
|
4
|
+
import { A as parseFetchBody, B as matchRoute, C as guardDenyFor, Ct as toolRefusal, D as jobRoutes, E as jobRouter, F as warnUnsupportedJobOptions, G as JobDispatchError, H as insufficientScope, I as isRawResponse, J as createJobRunner, K as defineJobTransport, L as rawResponse, M as routerFromRoutes, N as runHandler, O as jobRunnerFrom, P as runRoute, S as getHeaderValue, St as toolOptionsOf, T as isGuardDenial, U as requiresDenial, V as sortFlattenedRoutes, W as withPermissions, X as ResponseError, Y as jobFnAt, _ as defineAdapter, a as HANDLER_ARG_KEYS, b as entriesToObject, bt as describeTool, c as ROUTER_META, d as SCHEMES_META, f as adapterContextOf, g as contractOf, h as boundJobKeys, ht as groupRoutes, i as GUARD_SCHEMA_META, j as renderJsonResult, k as parseBodyText, l as RUN_ROUTE_KEY, m as bearerChallenge, n as DISPATCH_ROUTE_KEY, o as JOBS_META, p as assembleApi, pt as isGroupSet, q as JobInputError, r as GUARDS_META, rt as problemDetails, s as REQUEST_CONTEXT_META, t as API_META, u as ResponseValidationError, v as dispatchHandler, vt as buildToolDefinitions, w as headersToObject, x as extractCredential, xt as selectToolRoutes, y as dispatchRoute, yt as buildToolInputSchema } from "./adapter-DU3Ljl0P.mjs";
|
|
5
|
+
export { API_META, AUTO_GUARD_BRAND, AUTO_RESPONSES_BRAND, DISPATCH_ROUTE_KEY, GUARDS_META, GUARD_SCHEMA_META, HANDLER_ARG_KEYS, HANDLER_CONTEXT_BRAND, JOBS_META, JobDispatchError, JobInputError, REQUEST_CONTEXT_META, ROUTER_META, ROUTES_GROUP, RUN_ROUTE_KEY, ResponseError, ResponseValidationError, SCHEMES_META, adapterContextOf, allowedMethodsForPath, assembleApi, authenticationChallenge, bearerChallenge, boundJobKeys, buildPath, buildToolDefinitions, buildToolInputSchema, contractOf, createApiReference, createJobRunner, defineAdapter, defineJobTransport, definePlugin, describeTool, dispatchHandler, dispatchRoute, encodeStreamBody, entriesToObject, extractCredential, flattenJobs, flattenRoutes, formatValidationError, getHeaderValue, groupRoutes, guardDenyFor, headersToObject, insufficientScope, isCompiledJob, isGroupSet, isGuardDenial, isRawResponse, isRouteDefinition, isStreamResponse, jobAt, jobFnAt, jobRouter, jobRoutes, jobRunnerFrom, matchRoute, parseBodyText, parseFetchBody, parsePath, pluginExportsOf, pluginRouteTree, pluginRouterOf, pluginRoutesOf, problemDetails, rawResponse, renderJsonResult, requiresDenial, resolvePlugins, resolveSecurityRequirements, routerFromRoutes, runHandler, runRoute, selectToolRoutes, sortFlattenedRoutes, toolOptionsOf, toolRefusal, validateRequest, warnUnsupportedJobOptions, withPermissions };
|
|
@@ -193,11 +193,24 @@ const markModelSchema = (schema) => {
|
|
|
193
193
|
modelSchemas.add(schema);
|
|
194
194
|
};
|
|
195
195
|
/**
|
|
196
|
+
* Returns the `Kizuna.model` a schema is, or was copied from by `.describe()` or `.meta()`.
|
|
197
|
+
*/
|
|
198
|
+
const readModelSchema = (schema) => {
|
|
199
|
+
let current = schema;
|
|
200
|
+
while (current !== void 0) {
|
|
201
|
+
if (modelSchemas.has(current)) return current;
|
|
202
|
+
const parent = current._zod.parent;
|
|
203
|
+
if (parent === void 0 || parent._zod.def !== current._zod.def) return void 0;
|
|
204
|
+
current = parent;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
196
208
|
* Returns a `Kizuna.model` schema's `id` metadata, or undefined.
|
|
197
209
|
*/
|
|
198
210
|
const readMetaId = (schema) => {
|
|
199
|
-
|
|
200
|
-
|
|
211
|
+
const model = readModelSchema(schema);
|
|
212
|
+
if (model === void 0) return void 0;
|
|
213
|
+
const id = readMeta(model)?.id;
|
|
201
214
|
return typeof id === "string" ? id : void 0;
|
|
202
215
|
};
|
|
203
216
|
/**
|
|
@@ -354,4 +367,4 @@ function isProblemDetails(body) {
|
|
|
354
367
|
return typeof candidate.type === "string" && typeof candidate.title === "string" && typeof candidate.status === "number" && typeof candidate.detail === "string";
|
|
355
368
|
}
|
|
356
369
|
//#endregion
|
|
357
|
-
export { readMetaExamples as C,
|
|
370
|
+
export { readMetaExamples as C, resolveBaseType as D, readObjectShape as E, unwrapOptionalWrappers as O, readMetaDescription as S, readModelSchema as T, readDiscriminatedUnion as _, WRAPPER_TYPES as a, readMeta as b, isBinarySchema as c, isIntegerSchema as d, isObjectSchema as f, readDeprecation as g, readDefType as h, FILE_PROBE as i, isDiscriminatedUnionSchema as l, readDef as m, isProblemDetails as n, findCoercedSchemaPath as o, isVoidSchema as p, createModel as r, globalRegistrySchemas as s, ProblemDetailsSchema as t, isFileSchema as u, readDiscriminatorLiteral as v, readMetaId as w, readMetaBrand as x, readDiscriminatorStringLiteral as y };
|
|
@@ -193,11 +193,24 @@ const markModelSchema = (schema) => {
|
|
|
193
193
|
modelSchemas.add(schema);
|
|
194
194
|
};
|
|
195
195
|
/**
|
|
196
|
+
* Returns the `Kizuna.model` a schema is, or was copied from by `.describe()` or `.meta()`.
|
|
197
|
+
*/
|
|
198
|
+
const readModelSchema = (schema) => {
|
|
199
|
+
let current = schema;
|
|
200
|
+
while (current !== void 0) {
|
|
201
|
+
if (modelSchemas.has(current)) return current;
|
|
202
|
+
const parent = current._zod.parent;
|
|
203
|
+
if (parent === void 0 || parent._zod.def !== current._zod.def) return void 0;
|
|
204
|
+
current = parent;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
196
208
|
* Returns a `Kizuna.model` schema's `id` metadata, or undefined.
|
|
197
209
|
*/
|
|
198
210
|
const readMetaId = (schema) => {
|
|
199
|
-
|
|
200
|
-
|
|
211
|
+
const model = readModelSchema(schema);
|
|
212
|
+
if (model === void 0) return void 0;
|
|
213
|
+
const id = readMeta(model)?.id;
|
|
201
214
|
return typeof id === "string" ? id : void 0;
|
|
202
215
|
};
|
|
203
216
|
/**
|
|
@@ -498,6 +511,12 @@ Object.defineProperty(exports, "readMetaId", {
|
|
|
498
511
|
return readMetaId;
|
|
499
512
|
}
|
|
500
513
|
});
|
|
514
|
+
Object.defineProperty(exports, "readModelSchema", {
|
|
515
|
+
enumerable: true,
|
|
516
|
+
get: function() {
|
|
517
|
+
return readModelSchema;
|
|
518
|
+
}
|
|
519
|
+
});
|
|
501
520
|
Object.defineProperty(exports, "readObjectShape", {
|
|
502
521
|
enumerable: true,
|
|
503
522
|
get: function() {
|
package/dist/generator.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_error_response = require("./error-response-
|
|
3
|
-
const require_plugin_server = require("./plugin-server-
|
|
2
|
+
const require_error_response = require("./error-response-DN5Dsf8b.cjs");
|
|
3
|
+
const require_plugin_server = require("./plugin-server-CfF82yZL.cjs");
|
|
4
4
|
//#region src/generator.ts
|
|
5
5
|
/**
|
|
6
6
|
* Every route the api serves, the app's and the plugins' under their slugs,
|
|
@@ -42,7 +42,8 @@ const reachModels = (value, models, found, seen) => {
|
|
|
42
42
|
if (typeof value !== "object" || value === null || seen.has(value)) return;
|
|
43
43
|
seen.add(value);
|
|
44
44
|
if (isSchema(value)) {
|
|
45
|
-
|
|
45
|
+
const model = require_error_response.readModelSchema(value);
|
|
46
|
+
if (model !== void 0 && models.has(model)) found.add(model);
|
|
46
47
|
const def = value._zod.def;
|
|
47
48
|
for (const [key, child] of Object.entries(def)) {
|
|
48
49
|
if (key === "checks") continue;
|
|
@@ -207,6 +208,7 @@ exports.readMetaBrand = require_error_response.readMetaBrand;
|
|
|
207
208
|
exports.readMetaDescription = require_error_response.readMetaDescription;
|
|
208
209
|
exports.readMetaExamples = require_error_response.readMetaExamples;
|
|
209
210
|
exports.readMetaId = require_error_response.readMetaId;
|
|
211
|
+
exports.readModelSchema = require_error_response.readModelSchema;
|
|
210
212
|
exports.readObjectShape = require_error_response.readObjectShape;
|
|
211
213
|
exports.resolveResponseBody = require_plugin_server.resolveResponseBody;
|
|
212
214
|
exports.resolveResponseCache = require_plugin_server.resolveResponseCache;
|