kizunajs 2.0.0-beta.23 → 2.0.0-beta.24
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-CK8ccDOC.cjs → adapter-CWSs910w.cjs} +4 -3
- package/dist/{adapter-DU3Ljl0P.mjs → adapter-DW1ixy_N.mjs} +4 -3
- package/dist/adapter.cjs +2 -2
- package/dist/adapter.mjs +2 -2
- package/dist/generator.cjs +2 -1
- package/dist/generator.d.cts +14 -1
- package/dist/generator.d.mts +14 -1
- package/dist/generator.mjs +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/jobs-entry.cjs +2 -2
- package/dist/jobs-entry.mjs +2 -2
- package/dist/{plugin-server-CfF82yZL.cjs → plugin-server-7pkhltOp.cjs} +28 -0
- package/dist/{plugin-server-DNQ9_DL7.mjs → plugin-server-B-JDZ7GV.mjs} +24 -2
- package/package.json +1 -1
- package/src/generator.ts +1 -0
- package/src/json-encoding.ts +26 -0
- package/src/tool-definitions.ts +4 -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.24)
|
|
8
8
|

|
|
9
9
|
|
|
10
10
|
[Documentation](https://kizunajs.com)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_plugin = require("./plugin-Dw-yCjTY.cjs");
|
|
2
2
|
const require_error_response = require("./error-response-DN5Dsf8b.cjs");
|
|
3
|
-
const require_plugin_server = require("./plugin-server-
|
|
3
|
+
const require_plugin_server = require("./plugin-server-7pkhltOp.cjs");
|
|
4
4
|
const require_schemas = require("./schemas-Bre1FVHq.cjs");
|
|
5
5
|
let zod = require("zod");
|
|
6
6
|
//#region src/tool-definitions.ts
|
|
@@ -87,8 +87,9 @@ const toJsonSchema = (route) => {
|
|
|
87
87
|
const { $schema: _, ...schema } = zod.z.toJSONSchema(zod.z.object(shape ?? {}), {
|
|
88
88
|
io: "input",
|
|
89
89
|
unrepresentable: "any",
|
|
90
|
-
override: (
|
|
91
|
-
|
|
90
|
+
override: (context) => {
|
|
91
|
+
require_plugin_server.encodeForWire(context);
|
|
92
|
+
delete context.jsonSchema.brand;
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
95
|
return schema;
|
|
@@ -1,6 +1,6 @@
|
|
|
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
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 {
|
|
3
|
+
import { A as deriveToolNames, B as streamSchemas, G as isSuccessStatus, I as routeStreams, K as isZodSchema, M as EVENT_STREAM_MEDIA_TYPE, N as assertValidStreams, P as encodeStreamBody, Q as resolveResponseEtag, R as streamContentType, S as dueSchedules, U as isJsonMediaType, W as isStreamResponse, X as resolveResponseCache, Y as resolveResponseBody, Z as resolveResponseContentType, _ as jobAt, c as cacheHeaders, ct as parsePath, dt as formatValidationError, ft as isRouteDefinition, h as isCompiledJob, k as encodeForWire, lt as allowedMethodsForPath, m as flattenJobs, mt as resolveCoercionPlans, pt as validateRequest, u as deprecationHeaders, ut as flattenRoutes, y as toJobResponse } from "./plugin-server-B-JDZ7GV.mjs";
|
|
4
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
|
|
@@ -87,8 +87,9 @@ const toJsonSchema = (route) => {
|
|
|
87
87
|
const { $schema: _, ...schema } = z.toJSONSchema(z.object(shape ?? {}), {
|
|
88
88
|
io: "input",
|
|
89
89
|
unrepresentable: "any",
|
|
90
|
-
override: (
|
|
91
|
-
|
|
90
|
+
override: (context) => {
|
|
91
|
+
encodeForWire(context);
|
|
92
|
+
delete context.jsonSchema.brand;
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
95
|
return schema;
|
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-
|
|
3
|
+
const require_plugin_server = require("./plugin-server-7pkhltOp.cjs");
|
|
4
4
|
const require_schemas = require("./schemas-Bre1FVHq.cjs");
|
|
5
|
-
const require_adapter = require("./adapter-
|
|
5
|
+
const require_adapter = require("./adapter-CWSs910w.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;
|
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 {
|
|
2
|
+
import { P as encodeStreamBody, W as isStreamResponse, _ as jobAt, a as pluginRoutesOf, ct as parsePath, dt as formatValidationError, ft as isRouteDefinition, h as isCompiledJob, i as pluginRouterOf, lt as allowedMethodsForPath, m as flattenJobs, o as resolvePlugins, pt as validateRequest, r as pluginExportsOf, st as buildPath, t as createApiReference, ut as flattenRoutes } from "./plugin-server-B-JDZ7GV.mjs";
|
|
3
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-
|
|
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-DW1ixy_N.mjs";
|
|
5
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 };
|
package/dist/generator.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_error_response = require("./error-response-DN5Dsf8b.cjs");
|
|
3
|
-
const require_plugin_server = require("./plugin-server-
|
|
3
|
+
const require_plugin_server = require("./plugin-server-7pkhltOp.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,
|
|
@@ -177,6 +177,7 @@ exports.defineClient = defineClient;
|
|
|
177
177
|
exports.defineGenerator = defineGenerator;
|
|
178
178
|
exports.deprecationHeaders = require_plugin_server.deprecationHeaders;
|
|
179
179
|
exports.deriveToolNames = require_plugin_server.deriveToolNames;
|
|
180
|
+
exports.encodeForWire = require_plugin_server.encodeForWire;
|
|
180
181
|
exports.flattenJobs = require_plugin_server.flattenJobs;
|
|
181
182
|
exports.globalRegistrySchemas = require_error_response.globalRegistrySchemas;
|
|
182
183
|
exports.isBinarySchema = require_error_response.isBinarySchema;
|
package/dist/generator.d.cts
CHANGED
|
@@ -152,6 +152,19 @@ declare const globalRegistrySchemas: () => Map<string, z.core.$ZodType>;
|
|
|
152
152
|
*/
|
|
153
153
|
declare const deprecationHeaders: (route: RouteDefinition) => ResponseHeaders;
|
|
154
154
|
//#endregion
|
|
155
|
+
//#region src/json-encoding.d.ts
|
|
156
|
+
/**
|
|
157
|
+
* An `override` for `z.toJSONSchema` that gives a date or bigint its wire form,
|
|
158
|
+
* where `unrepresentable: 'any'` would otherwise leave an empty schema.
|
|
159
|
+
*/
|
|
160
|
+
declare const encodeForWire: ({
|
|
161
|
+
zodSchema,
|
|
162
|
+
jsonSchema
|
|
163
|
+
}: {
|
|
164
|
+
zodSchema: z.core.$ZodType;
|
|
165
|
+
jsonSchema: Record<string, unknown>;
|
|
166
|
+
}) => void;
|
|
167
|
+
//#endregion
|
|
155
168
|
//#region src/tool-name.d.ts
|
|
156
169
|
/**
|
|
157
170
|
* `users.listUsers` becomes `users_list_users`, the shape MCP servers publish
|
|
@@ -380,4 +393,4 @@ interface GeneratorDefinition<Schema extends z.ZodType | undefined> {
|
|
|
380
393
|
*/
|
|
381
394
|
declare const defineGenerator: <Schema extends z.ZodType | undefined = undefined>(definition: GeneratorDefinition<Schema>) => ((options: OptionsInput<Schema> & GeneratedFileOptions) => GeneratedFile);
|
|
382
395
|
//#endregion
|
|
383
|
-
export { ClientDefinition, type CompiledJob, type DiscriminatedUnion, EVENT_STREAM_MEDIA_TYPE, FILE_PROBE, type FlattenedJob, GenerateContext, type GeneratedFile, GeneratedFileOptions, GeneratorDefinition, GeneratorModelContext, GeneratorPluginInfo, GeneratorRouteContext, GeneratorWalk, type Jobs, type RouteDefinition, type Routes, type StreamMode, type ToolNameEntry, type ToolOrigin, WalkApiOptions, type ZodDef, cacheHeaders, defineClient, defineGenerator, deprecationHeaders, deriveToolNames, flattenJobs, globalRegistrySchemas, isBinarySchema, isCompiledJob, isDiscriminatedUnionSchema, isFileSchema, isHintPrefix, isIntegerSchema, isJsonMediaType, isNamedStream, isObjectSchema, isStreamResponse, isSuccessStatus, isVoidSchema, isZodSchema, jobAt, listedRoutes, localTypeName, mergeHeaderFields, parsePath, readDef, readDefType, readDeprecation, readDiscriminatedUnion, readDiscriminatorLiteral, readDiscriminatorStringLiteral, readMeta, readMetaBrand, readMetaDescription, readMetaExamples, readMetaId, readModelSchema, readObjectShape, resolveResponseBody, resolveResponseCache, resolveResponseContentType, resolveResponseEtag, resolveResponseHeaders, resolveResponseStream, routeStreams, sanitizeFieldName, sanitizeIdentifier, shortTypeName, soleStreamResponse, statusToCamelCase, streamContentType, streamMode, streamSchemas, streamStatuses, toCamelCase, toPascalCase, toToolName, unwrapOptionalWrappers, walkApi };
|
|
396
|
+
export { ClientDefinition, type CompiledJob, type DiscriminatedUnion, EVENT_STREAM_MEDIA_TYPE, FILE_PROBE, type FlattenedJob, GenerateContext, type GeneratedFile, GeneratedFileOptions, GeneratorDefinition, GeneratorModelContext, GeneratorPluginInfo, GeneratorRouteContext, GeneratorWalk, type Jobs, type RouteDefinition, type Routes, type StreamMode, type ToolNameEntry, type ToolOrigin, WalkApiOptions, type ZodDef, cacheHeaders, defineClient, defineGenerator, deprecationHeaders, deriveToolNames, encodeForWire, flattenJobs, globalRegistrySchemas, isBinarySchema, isCompiledJob, isDiscriminatedUnionSchema, isFileSchema, isHintPrefix, isIntegerSchema, isJsonMediaType, isNamedStream, isObjectSchema, isStreamResponse, isSuccessStatus, isVoidSchema, isZodSchema, jobAt, listedRoutes, localTypeName, mergeHeaderFields, parsePath, readDef, readDefType, readDeprecation, readDiscriminatedUnion, readDiscriminatorLiteral, readDiscriminatorStringLiteral, readMeta, readMetaBrand, readMetaDescription, readMetaExamples, readMetaId, readModelSchema, readObjectShape, resolveResponseBody, resolveResponseCache, resolveResponseContentType, resolveResponseEtag, resolveResponseHeaders, resolveResponseStream, routeStreams, sanitizeFieldName, sanitizeIdentifier, shortTypeName, soleStreamResponse, statusToCamelCase, streamContentType, streamMode, streamSchemas, streamStatuses, toCamelCase, toPascalCase, toToolName, unwrapOptionalWrappers, walkApi };
|
package/dist/generator.d.mts
CHANGED
|
@@ -152,6 +152,19 @@ declare const globalRegistrySchemas: () => Map<string, z.core.$ZodType>;
|
|
|
152
152
|
*/
|
|
153
153
|
declare const deprecationHeaders: (route: RouteDefinition) => ResponseHeaders;
|
|
154
154
|
//#endregion
|
|
155
|
+
//#region src/json-encoding.d.ts
|
|
156
|
+
/**
|
|
157
|
+
* An `override` for `z.toJSONSchema` that gives a date or bigint its wire form,
|
|
158
|
+
* where `unrepresentable: 'any'` would otherwise leave an empty schema.
|
|
159
|
+
*/
|
|
160
|
+
declare const encodeForWire: ({
|
|
161
|
+
zodSchema,
|
|
162
|
+
jsonSchema
|
|
163
|
+
}: {
|
|
164
|
+
zodSchema: z.core.$ZodType;
|
|
165
|
+
jsonSchema: Record<string, unknown>;
|
|
166
|
+
}) => void;
|
|
167
|
+
//#endregion
|
|
155
168
|
//#region src/tool-name.d.ts
|
|
156
169
|
/**
|
|
157
170
|
* `users.listUsers` becomes `users_list_users`, the shape MCP servers publish
|
|
@@ -380,4 +393,4 @@ interface GeneratorDefinition<Schema extends z.ZodType | undefined> {
|
|
|
380
393
|
*/
|
|
381
394
|
declare const defineGenerator: <Schema extends z.ZodType | undefined = undefined>(definition: GeneratorDefinition<Schema>) => ((options: OptionsInput<Schema> & GeneratedFileOptions) => GeneratedFile);
|
|
382
395
|
//#endregion
|
|
383
|
-
export { ClientDefinition, type CompiledJob, type DiscriminatedUnion, EVENT_STREAM_MEDIA_TYPE, FILE_PROBE, type FlattenedJob, GenerateContext, type GeneratedFile, GeneratedFileOptions, GeneratorDefinition, GeneratorModelContext, GeneratorPluginInfo, GeneratorRouteContext, GeneratorWalk, type Jobs, type RouteDefinition, type Routes, type StreamMode, type ToolNameEntry, type ToolOrigin, WalkApiOptions, type ZodDef, cacheHeaders, defineClient, defineGenerator, deprecationHeaders, deriveToolNames, flattenJobs, globalRegistrySchemas, isBinarySchema, isCompiledJob, isDiscriminatedUnionSchema, isFileSchema, isHintPrefix, isIntegerSchema, isJsonMediaType, isNamedStream, isObjectSchema, isStreamResponse, isSuccessStatus, isVoidSchema, isZodSchema, jobAt, listedRoutes, localTypeName, mergeHeaderFields, parsePath, readDef, readDefType, readDeprecation, readDiscriminatedUnion, readDiscriminatorLiteral, readDiscriminatorStringLiteral, readMeta, readMetaBrand, readMetaDescription, readMetaExamples, readMetaId, readModelSchema, readObjectShape, resolveResponseBody, resolveResponseCache, resolveResponseContentType, resolveResponseEtag, resolveResponseHeaders, resolveResponseStream, routeStreams, sanitizeFieldName, sanitizeIdentifier, shortTypeName, soleStreamResponse, statusToCamelCase, streamContentType, streamMode, streamSchemas, streamStatuses, toCamelCase, toPascalCase, toToolName, unwrapOptionalWrappers, walkApi };
|
|
396
|
+
export { ClientDefinition, type CompiledJob, type DiscriminatedUnion, EVENT_STREAM_MEDIA_TYPE, FILE_PROBE, type FlattenedJob, GenerateContext, type GeneratedFile, GeneratedFileOptions, GeneratorDefinition, GeneratorModelContext, GeneratorPluginInfo, GeneratorRouteContext, GeneratorWalk, type Jobs, type RouteDefinition, type Routes, type StreamMode, type ToolNameEntry, type ToolOrigin, WalkApiOptions, type ZodDef, cacheHeaders, defineClient, defineGenerator, deprecationHeaders, deriveToolNames, encodeForWire, flattenJobs, globalRegistrySchemas, isBinarySchema, isCompiledJob, isDiscriminatedUnionSchema, isFileSchema, isHintPrefix, isIntegerSchema, isJsonMediaType, isNamedStream, isObjectSchema, isStreamResponse, isSuccessStatus, isVoidSchema, isZodSchema, jobAt, listedRoutes, localTypeName, mergeHeaderFields, parsePath, readDef, readDefType, readDeprecation, readDiscriminatedUnion, readDiscriminatorLiteral, readDiscriminatorStringLiteral, readMeta, readMetaBrand, readMetaDescription, readMetaExamples, readMetaId, readModelSchema, readObjectShape, resolveResponseBody, resolveResponseCache, resolveResponseContentType, resolveResponseEtag, resolveResponseHeaders, resolveResponseStream, routeStreams, sanitizeFieldName, sanitizeIdentifier, shortTypeName, soleStreamResponse, statusToCamelCase, streamContentType, streamMode, streamSchemas, streamStatuses, toCamelCase, toPascalCase, toToolName, unwrapOptionalWrappers, walkApi };
|
package/dist/generator.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { C as readMetaExamples, E as readObjectShape, O as unwrapOptionalWrappers, S as readMetaDescription, T as readModelSchema, _ as readDiscriminatedUnion, b as readMeta, c as isBinarySchema, d as isIntegerSchema, f as isObjectSchema, g as readDeprecation, h as readDefType, i as FILE_PROBE, l as isDiscriminatedUnionSchema, m as readDef, p as isVoidSchema, s as globalRegistrySchemas, u as isFileSchema, v as readDiscriminatorLiteral, w as readMetaId, x as readMetaBrand, y as readDiscriminatorStringLiteral } from "./error-response-D7urgxeq.mjs";
|
|
2
|
-
import { $ as
|
|
2
|
+
import { $ as resolveResponseHeaders, A as deriveToolNames, B as streamSchemas, F as isNamedStream, G as isSuccessStatus, H as isHintPrefix, I as routeStreams, J as mergeHeaderFields, K as isZodSchema, L as soleStreamResponse, M as EVENT_STREAM_MEDIA_TYPE, Q as resolveResponseEtag, R as streamContentType, U as isJsonMediaType, V as streamStatuses, W as isStreamResponse, X as resolveResponseCache, Y as resolveResponseBody, Z as resolveResponseContentType, _ as jobAt, a as pluginRoutesOf, at as toCamelCase, c as cacheHeaders, ct as parsePath, et as resolveResponseStream, ft as isRouteDefinition, h as isCompiledJob, it as statusToCamelCase, j as toToolName, k as encodeForWire, m as flattenJobs, n as describeIssue, nt as sanitizeIdentifier, ot as toPascalCase, q as localTypeName, rt as shortTypeName, tt as sanitizeFieldName, u as deprecationHeaders, ut as flattenRoutes, z as streamMode } from "./plugin-server-B-JDZ7GV.mjs";
|
|
3
3
|
//#region src/generator.ts
|
|
4
4
|
/**
|
|
5
5
|
* Every route the api serves, the app's and the plugins' under their slugs,
|
|
@@ -169,4 +169,4 @@ const defineGenerator = (definition) => (input) => {
|
|
|
169
169
|
};
|
|
170
170
|
};
|
|
171
171
|
//#endregion
|
|
172
|
-
export { EVENT_STREAM_MEDIA_TYPE, FILE_PROBE, cacheHeaders, defineClient, defineGenerator, deprecationHeaders, deriveToolNames, flattenJobs, globalRegistrySchemas, isBinarySchema, isCompiledJob, isDiscriminatedUnionSchema, isFileSchema, isHintPrefix, isIntegerSchema, isJsonMediaType, isNamedStream, isObjectSchema, isStreamResponse, isSuccessStatus, isVoidSchema, isZodSchema, jobAt, listedRoutes, localTypeName, mergeHeaderFields, parsePath, readDef, readDefType, readDeprecation, readDiscriminatedUnion, readDiscriminatorLiteral, readDiscriminatorStringLiteral, readMeta, readMetaBrand, readMetaDescription, readMetaExamples, readMetaId, readModelSchema, readObjectShape, resolveResponseBody, resolveResponseCache, resolveResponseContentType, resolveResponseEtag, resolveResponseHeaders, resolveResponseStream, routeStreams, sanitizeFieldName, sanitizeIdentifier, shortTypeName, soleStreamResponse, statusToCamelCase, streamContentType, streamMode, streamSchemas, streamStatuses, toCamelCase, toPascalCase, toToolName, unwrapOptionalWrappers, walkApi };
|
|
172
|
+
export { EVENT_STREAM_MEDIA_TYPE, FILE_PROBE, cacheHeaders, defineClient, defineGenerator, deprecationHeaders, deriveToolNames, encodeForWire, flattenJobs, globalRegistrySchemas, isBinarySchema, isCompiledJob, isDiscriminatedUnionSchema, isFileSchema, isHintPrefix, isIntegerSchema, isJsonMediaType, isNamedStream, isObjectSchema, isStreamResponse, isSuccessStatus, isVoidSchema, isZodSchema, jobAt, listedRoutes, localTypeName, mergeHeaderFields, parsePath, readDef, readDefType, readDeprecation, readDiscriminatedUnion, readDiscriminatorLiteral, readDiscriminatorStringLiteral, readMeta, readMetaBrand, readMetaDescription, readMetaExamples, readMetaId, readModelSchema, readObjectShape, resolveResponseBody, resolveResponseCache, resolveResponseContentType, resolveResponseEtag, resolveResponseHeaders, resolveResponseStream, routeStreams, sanitizeFieldName, sanitizeIdentifier, shortTypeName, soleStreamResponse, statusToCamelCase, streamContentType, streamMode, streamSchemas, streamStatuses, toCamelCase, toPascalCase, toToolName, unwrapOptionalWrappers, walkApi };
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_plugin = require("./plugin-Dw-yCjTY.cjs");
|
|
3
3
|
const require_error_response = require("./error-response-DN5Dsf8b.cjs");
|
|
4
|
-
const require_plugin_server = require("./plugin-server-
|
|
4
|
+
const require_plugin_server = require("./plugin-server-7pkhltOp.cjs");
|
|
5
5
|
const require_schemas = require("./schemas-Bre1FVHq.cjs");
|
|
6
|
-
const require_adapter = require("./adapter-
|
|
6
|
+
const require_adapter = require("./adapter-CWSs910w.cjs");
|
|
7
7
|
let zod = require("zod");
|
|
8
8
|
//#region src/group-routes.ts
|
|
9
9
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as definePlugin, c as createRoute, d as AUTO_RESPONSES_BRAND, f as DECLARATION, g as ROUTES_GROUP, h as METHODS, l as AUTO_GUARD_BRAND, m as HANDLER_CONTEXT_BRAND, o as pluginRouteTree, p as HANDLER, u as AUTO_GUARD_WRITTEN_BRAND } from "./plugin-xxCxibmu.mjs";
|
|
2
2
|
import { E as readObjectShape, m as readDef, n as isProblemDetails, r as createModel, t as ProblemDetailsSchema } from "./error-response-D7urgxeq.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { C as firesBetween, D as scheduleExpression, E as parseCron, F as isNamedStream, I as routeStreams, K as isZodSchema, L as soleStreamResponse, M as EVENT_STREAM_MEDIA_TYPE, O as scheduleTimezone, R as streamContentType, S as dueSchedules, T as nextRuns, V as streamStatuses, W as isStreamResponse, Y as resolveResponseBody, _ as jobAt, b as assertValidSchedule, ct as parsePath, f as assertJobRunner, ft as isRouteDefinition, g as isJobDefinition, h as isCompiledJob, l as assertValidDeprecationDates, m as flattenJobs, o as resolvePlugins, p as buildJobs, r as pluginExportsOf, s as assertValidCache, st as buildPath, t as createApiReference, ut as flattenRoutes, v as jobClaims, w as nextRun, x as cron, z as streamMode } from "./plugin-server-B-JDZ7GV.mjs";
|
|
4
4
|
import { a as assertCanonicalResourceUri, c as isValidationError, d as declaredScopes, f as isSecurityScheme, l as authenticationChallenge, o as buildProtectedResourceMetadata, p as resolveSecurityRequirements, u as authorizationServerIssuer } from "./schemas-DBX8DwFb.mjs";
|
|
5
|
-
import { $ as dispatchDueJobs, F as warnUnsupportedJobOptions, G as JobDispatchError, J as createJobRunner, K as defineJobTransport, M as routerFromRoutes, Q as DispatchResultSchema, R as assertNoPathCollisions, S as getHeaderValue, X as ResponseError, Y as jobFnAt, Z as DispatchFailedSchema, _t as toolEvents, at as STATUS_TITLES, ct as createRoles, dt as permissionNames, et as dispatchSucceeded, ft as createGroups, gt as expandStreamTools, ht as groupRoutes, it as problemFromBody, lt as isPermissions, mt as assembleRoutes, nt as failedJobs, o as JOBS_META, ot as getStatusText, p as assembleApi, q as JobInputError, rt as problemDetails, st as createPermissions, tt as dueJobs, ut as isRoles, z as routeClaims } from "./adapter-
|
|
5
|
+
import { $ as dispatchDueJobs, F as warnUnsupportedJobOptions, G as JobDispatchError, J as createJobRunner, K as defineJobTransport, M as routerFromRoutes, Q as DispatchResultSchema, R as assertNoPathCollisions, S as getHeaderValue, X as ResponseError, Y as jobFnAt, Z as DispatchFailedSchema, _t as toolEvents, at as STATUS_TITLES, ct as createRoles, dt as permissionNames, et as dispatchSucceeded, ft as createGroups, gt as expandStreamTools, ht as groupRoutes, it as problemFromBody, lt as isPermissions, mt as assembleRoutes, nt as failedJobs, o as JOBS_META, ot as getStatusText, p as assembleApi, q as JobInputError, rt as problemDetails, st as createPermissions, tt as dueJobs, ut as isRoles, z as routeClaims } from "./adapter-DW1ixy_N.mjs";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
//#region src/group-routes.ts
|
|
8
8
|
/**
|
package/dist/jobs-entry.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_plugin_server = require("./plugin-server-
|
|
3
|
-
const require_adapter = require("./adapter-
|
|
2
|
+
const require_plugin_server = require("./plugin-server-7pkhltOp.cjs");
|
|
3
|
+
const require_adapter = require("./adapter-CWSs910w.cjs");
|
|
4
4
|
//#region src/start-jobs.ts
|
|
5
5
|
/**
|
|
6
6
|
* The dedupe key an occurrence gets. Every instance ticking the same minute
|
package/dist/jobs-entry.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as scheduleExpression, O as scheduleTimezone, m as flattenJobs, w as nextRun } from "./plugin-server-
|
|
2
|
-
import { O as jobRunnerFrom, Y as jobFnAt, h as boundJobKeys, o as JOBS_META } from "./adapter-
|
|
1
|
+
import { D as scheduleExpression, O as scheduleTimezone, m as flattenJobs, w as nextRun } from "./plugin-server-B-JDZ7GV.mjs";
|
|
2
|
+
import { O as jobRunnerFrom, Y as jobFnAt, h as boundJobKeys, o as JOBS_META } from "./adapter-DW1ixy_N.mjs";
|
|
3
3
|
//#region src/start-jobs.ts
|
|
4
4
|
/**
|
|
5
5
|
* The dedupe key an occurrence gets. Every instance ticking the same minute
|
|
@@ -554,6 +554,28 @@ const deriveToolNames = (entries) => {
|
|
|
554
554
|
return names;
|
|
555
555
|
};
|
|
556
556
|
//#endregion
|
|
557
|
+
//#region src/json-encoding.ts
|
|
558
|
+
/**
|
|
559
|
+
* What the wire carries for a type JSON Schema has no keyword for. A route's
|
|
560
|
+
* query, path and headers arrive as text that kizuna coerces, and JSON writes
|
|
561
|
+
* a `Date` as its ISO string.
|
|
562
|
+
*/
|
|
563
|
+
const JSON_ENCODING = {
|
|
564
|
+
date: {
|
|
565
|
+
type: "string",
|
|
566
|
+
format: "date-time"
|
|
567
|
+
},
|
|
568
|
+
bigint: { type: "string" }
|
|
569
|
+
};
|
|
570
|
+
/**
|
|
571
|
+
* An `override` for `z.toJSONSchema` that gives a date or bigint its wire form,
|
|
572
|
+
* where `unrepresentable: 'any'` would otherwise leave an empty schema.
|
|
573
|
+
*/
|
|
574
|
+
const encodeForWire = ({ zodSchema, jsonSchema }) => {
|
|
575
|
+
const encoding = JSON_ENCODING[require_error_response.readDefType(zodSchema) ?? ""];
|
|
576
|
+
if (encoding && Object.keys(jsonSchema).length === 0) Object.assign(jsonSchema, encoding);
|
|
577
|
+
};
|
|
578
|
+
//#endregion
|
|
557
579
|
//#region src/schedule.ts
|
|
558
580
|
/**
|
|
559
581
|
* The cron expression of a {@link JobSchedule}, whichever form it was written in.
|
|
@@ -1415,6 +1437,12 @@ Object.defineProperty(exports, "dueSchedules", {
|
|
|
1415
1437
|
return dueSchedules;
|
|
1416
1438
|
}
|
|
1417
1439
|
});
|
|
1440
|
+
Object.defineProperty(exports, "encodeForWire", {
|
|
1441
|
+
enumerable: true,
|
|
1442
|
+
get: function() {
|
|
1443
|
+
return encodeForWire;
|
|
1444
|
+
}
|
|
1445
|
+
});
|
|
1418
1446
|
Object.defineProperty(exports, "encodeStreamBody", {
|
|
1419
1447
|
enumerable: true,
|
|
1420
1448
|
get: function() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as ROUTES_GROUP, n as PLUGIN_SERVERS_META_KEY, t as PLUGIN_ROUTES_META_KEY } from "./plugin-xxCxibmu.mjs";
|
|
2
|
-
import { D as resolveBaseType, E as readObjectShape, a as WRAPPER_TYPES, c as isBinarySchema, m as readDef, t as ProblemDetailsSchema } from "./error-response-D7urgxeq.mjs";
|
|
2
|
+
import { D as resolveBaseType, E as readObjectShape, a as WRAPPER_TYPES, c as isBinarySchema, h as readDefType, m as readDef, t as ProblemDetailsSchema } from "./error-response-D7urgxeq.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/coercion.ts
|
|
5
5
|
/**
|
|
@@ -554,6 +554,28 @@ const deriveToolNames = (entries) => {
|
|
|
554
554
|
return names;
|
|
555
555
|
};
|
|
556
556
|
//#endregion
|
|
557
|
+
//#region src/json-encoding.ts
|
|
558
|
+
/**
|
|
559
|
+
* What the wire carries for a type JSON Schema has no keyword for. A route's
|
|
560
|
+
* query, path and headers arrive as text that kizuna coerces, and JSON writes
|
|
561
|
+
* a `Date` as its ISO string.
|
|
562
|
+
*/
|
|
563
|
+
const JSON_ENCODING = {
|
|
564
|
+
date: {
|
|
565
|
+
type: "string",
|
|
566
|
+
format: "date-time"
|
|
567
|
+
},
|
|
568
|
+
bigint: { type: "string" }
|
|
569
|
+
};
|
|
570
|
+
/**
|
|
571
|
+
* An `override` for `z.toJSONSchema` that gives a date or bigint its wire form,
|
|
572
|
+
* where `unrepresentable: 'any'` would otherwise leave an empty schema.
|
|
573
|
+
*/
|
|
574
|
+
const encodeForWire = ({ zodSchema, jsonSchema }) => {
|
|
575
|
+
const encoding = JSON_ENCODING[readDefType(zodSchema) ?? ""];
|
|
576
|
+
if (encoding && Object.keys(jsonSchema).length === 0) Object.assign(jsonSchema, encoding);
|
|
577
|
+
};
|
|
578
|
+
//#endregion
|
|
557
579
|
//#region src/schedule.ts
|
|
558
580
|
/**
|
|
559
581
|
* The cron expression of a {@link JobSchedule}, whichever form it was written in.
|
|
@@ -1313,4 +1335,4 @@ const createApiReference = () => {
|
|
|
1313
1335
|
};
|
|
1314
1336
|
};
|
|
1315
1337
|
//#endregion
|
|
1316
|
-
export {
|
|
1338
|
+
export { resolveResponseHeaders as $, deriveToolNames as A, streamSchemas as B, firesBetween as C, scheduleExpression as D, parseCron as E, isNamedStream as F, isSuccessStatus as G, isHintPrefix as H, routeStreams as I, mergeHeaderFields as J, isZodSchema as K, soleStreamResponse as L, EVENT_STREAM_MEDIA_TYPE as M, assertValidStreams as N, scheduleTimezone as O, encodeStreamBody as P, resolveResponseEtag as Q, streamContentType as R, dueSchedules as S, nextRuns as T, isJsonMediaType as U, streamStatuses as V, isStreamResponse as W, resolveResponseCache as X, resolveResponseBody as Y, resolveResponseContentType as Z, jobAt as _, pluginRoutesOf as a, toCamelCase as at, assertValidSchedule as b, cacheHeaders as c, parsePath as ct, DEFAULT_JOBS_PATH as d, formatValidationError as dt, resolveResponseStream as et, assertJobRunner as f, isRouteDefinition as ft, isJobDefinition as g, isCompiledJob as h, pluginRouterOf as i, statusToCamelCase as it, toToolName as j, encodeForWire as k, assertValidDeprecationDates as l, allowedMethodsForPath as lt, flattenJobs as m, resolveCoercionPlans as mt, describeIssue as n, sanitizeIdentifier as nt, resolvePlugins as o, toPascalCase as ot, buildJobs as p, validateRequest as pt, localTypeName as q, pluginExportsOf as r, shortTypeName as rt, assertValidCache as s, buildPath as st, createApiReference as t, sanitizeFieldName as tt, deprecationHeaders as u, flattenRoutes as ut, jobClaims as v, nextRun as w, cron as x, toJobResponse as y, streamMode as z };
|
package/package.json
CHANGED
package/src/generator.ts
CHANGED
|
@@ -42,6 +42,7 @@ export {
|
|
|
42
42
|
} from './zod-internals.js';
|
|
43
43
|
|
|
44
44
|
export { deprecationHeaders } from './deprecation.js';
|
|
45
|
+
export { encodeForWire } from './json-encoding.js';
|
|
45
46
|
export { toToolName, deriveToolNames, type ToolOrigin, type ToolNameEntry } from './tool-name.js';
|
|
46
47
|
export {
|
|
47
48
|
streamMode,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import { readDefType } from './zod-internals.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What the wire carries for a type JSON Schema has no keyword for. A route's
|
|
6
|
+
* query, path and headers arrive as text that kizuna coerces, and JSON writes
|
|
7
|
+
* a `Date` as its ISO string.
|
|
8
|
+
*/
|
|
9
|
+
const JSON_ENCODING: Record<string, Record<string, unknown>> = {
|
|
10
|
+
date: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
format: 'date-time',
|
|
13
|
+
},
|
|
14
|
+
bigint: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* An `override` for `z.toJSONSchema` that gives a date or bigint its wire form,
|
|
21
|
+
* where `unrepresentable: 'any'` would otherwise leave an empty schema.
|
|
22
|
+
*/
|
|
23
|
+
export const encodeForWire = ({ zodSchema, jsonSchema }: { zodSchema: z.core.$ZodType; jsonSchema: Record<string, unknown> }): void => {
|
|
24
|
+
const encoding = JSON_ENCODING[readDefType(zodSchema) ?? ''];
|
|
25
|
+
if (encoding && Object.keys(jsonSchema).length === 0) Object.assign(jsonSchema, encoding);
|
|
26
|
+
};
|
package/src/tool-definitions.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { resolveSecurityRequirements } from './security-scheme.js';
|
|
|
6
6
|
import { routeStreams } from './stream.js';
|
|
7
7
|
import { deriveToolNames } from './tool-name.js';
|
|
8
8
|
import { isVoidSchema, readObjectShape } from './zod-internals.js';
|
|
9
|
+
import { encodeForWire } from './json-encoding.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* What a route says about publishing itself, or `undefined` when it says
|
|
@@ -138,8 +139,9 @@ const toJsonSchema = (route: RouteDefinition): Record<string, unknown> => {
|
|
|
138
139
|
const { $schema: _, ...schema } = z.toJSONSchema(z.object(shape ?? {}), {
|
|
139
140
|
io: 'input',
|
|
140
141
|
unrepresentable: 'any',
|
|
141
|
-
override: (
|
|
142
|
-
|
|
142
|
+
override: (context) => {
|
|
143
|
+
encodeForWire(context);
|
|
144
|
+
delete context.jsonSchema.brand;
|
|
143
145
|
},
|
|
144
146
|
}) as Record<string, unknown>;
|
|
145
147
|
return schema;
|