kizunajs 2.0.0-beta.12 → 2.0.0-beta.14
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 +2 -2
- package/dist/{adapter-CJcrTrYh.mjs → adapter-Bp3CIsRc.mjs} +7 -4
- package/dist/{adapter-B3WkZY0Q.cjs → adapter-CGKgrfQy.cjs} +7 -4
- package/dist/adapter.cjs +3 -3
- package/dist/adapter.mjs +3 -3
- package/dist/{error-response-Dn5Ci5UP.cjs → error-response-C9ymqSU4.cjs} +13 -0
- package/dist/{error-response-rsiMhmJP.mjs → error-response-CNQaKVYd.mjs} +8 -1
- package/dist/generator.cjs +3 -2
- package/dist/generator.d.cts +7 -1
- package/dist/generator.d.mts +7 -1
- package/dist/generator.mjs +3 -3
- package/dist/index.cjs +31 -4
- package/dist/index.d.cts +18 -2
- package/dist/index.d.mts +18 -2
- package/dist/index.mjs +31 -4
- package/dist/jobs-entry.cjs +2 -2
- package/dist/jobs-entry.mjs +2 -2
- package/dist/{plugin-server-De3duJbH.mjs → plugin-server-C0CyVED-.mjs} +1 -1
- package/dist/{plugin-server-IPwgFgPq.cjs → plugin-server-DrDIPl6R.cjs} +1 -1
- package/dist/{schemas-CpMb2KEw.cjs → schemas-7y2XV1if.cjs} +1 -1
- package/dist/{schemas-DttyKxw1.mjs → schemas-_W2cLAVl.mjs} +1 -1
- package/dist/schemas.cjs +2 -2
- package/dist/schemas.mjs +2 -2
- package/package.json +1 -1
- package/src/brand.ts +29 -0
- package/src/generator.ts +1 -0
- package/src/kizuna.ts +6 -0
- package/src/tool-definitions.ts +3 -0
- package/src/zod-internals.ts +10 -0
- package/src/zod-meta.ts +7 -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.14)
|
|
8
8
|

|
|
9
9
|
|
|
10
10
|
[Documentation](https://kizunajs.com)
|
|
@@ -53,7 +53,7 @@ Follow the [quickstart](https://kizunajs.com/docs/quickstart), which goes from a
|
|
|
53
53
|
| Package | Description |
|
|
54
54
|
| -------------------------- | -------------------------------------------------- |
|
|
55
55
|
| `kizunajs` | Route declaration, validation, and the adapter API |
|
|
56
|
-
| `@kizunajs/fetch` |
|
|
56
|
+
| `@kizunajs/fetch` | Fetch client generation |
|
|
57
57
|
| `@kizunajs/tanstack-query` | TanStack Query client |
|
|
58
58
|
| `@kizunajs/express` | Express adapter |
|
|
59
59
|
| `@kizunajs/fastify` | Fastify adapter |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { g as ROUTES_TAG, n as PLUGIN_SERVERS_META_KEY, o as pluginRouteTree, p as HANDLER, t as PLUGIN_ROUTES_META_KEY } from "./plugin-CFpv8XTz.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { A as EVENT_STREAM_MEDIA_TYPE, H as isStreamResponse, I as streamContentType, J as resolveResponseCache, M as encodeStreamBody, O as deriveToolNames, P as routeStreams, R as streamSchemas, U as isSuccessStatus, V as isJsonMediaType, W as isZodSchema, X as resolveResponseEtag, Y as resolveResponseContentType, c as cacheHeaders, ct as flattenRoutes, dt as validateRequest, ft as resolveCoercionPlans, g as jobAt, j as assertValidStreams, lt as formatValidationError, m as isCompiledJob, ot as parsePath, p as flattenJobs, q as resolveResponseBody, st as allowedMethodsForPath, u as deprecationHeaders, ut as isRouteDefinition, v as toJobResponse, x as dueSchedules } from "./plugin-server-
|
|
4
|
-
import { l as authenticationChallenge, p as resolveSecurityRequirements } from "./schemas-
|
|
2
|
+
import { E as resolveBaseType, T as readObjectShape, c as isBinarySchema, o as findCoercedSchemaPath, p as isVoidSchema, t as ProblemDetailsSchema } from "./error-response-CNQaKVYd.mjs";
|
|
3
|
+
import { A as EVENT_STREAM_MEDIA_TYPE, H as isStreamResponse, I as streamContentType, J as resolveResponseCache, M as encodeStreamBody, O as deriveToolNames, P as routeStreams, R as streamSchemas, U as isSuccessStatus, V as isJsonMediaType, W as isZodSchema, X as resolveResponseEtag, Y as resolveResponseContentType, c as cacheHeaders, ct as flattenRoutes, dt as validateRequest, ft as resolveCoercionPlans, g as jobAt, j as assertValidStreams, lt as formatValidationError, m as isCompiledJob, ot as parsePath, p as flattenJobs, q as resolveResponseBody, st as allowedMethodsForPath, u as deprecationHeaders, ut as isRouteDefinition, v as toJobResponse, x as dueSchedules } from "./plugin-server-C0CyVED-.mjs";
|
|
4
|
+
import { l as authenticationChallenge, p as resolveSecurityRequirements } from "./schemas-_W2cLAVl.mjs";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
//#region src/tags.ts
|
|
7
7
|
const isTagSet = (value) => typeof value === "object" && value !== null && "__brand" in value && value.__brand === "TagSet";
|
|
@@ -111,7 +111,10 @@ const toJsonSchema = (route) => {
|
|
|
111
111
|
const { shape } = buildToolInputSchema(route);
|
|
112
112
|
const { $schema: _, ...schema } = z.toJSONSchema(z.object(shape ?? {}), {
|
|
113
113
|
io: "input",
|
|
114
|
-
unrepresentable: "any"
|
|
114
|
+
unrepresentable: "any",
|
|
115
|
+
override: ({ jsonSchema }) => {
|
|
116
|
+
delete jsonSchema.brand;
|
|
117
|
+
}
|
|
115
118
|
});
|
|
116
119
|
return schema;
|
|
117
120
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_plugin = require("./plugin-D_WJ2GBf.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-C9ymqSU4.cjs");
|
|
3
|
+
const require_plugin_server = require("./plugin-server-DrDIPl6R.cjs");
|
|
4
|
+
const require_schemas = require("./schemas-7y2XV1if.cjs");
|
|
5
5
|
let zod = require("zod");
|
|
6
6
|
//#region src/tags.ts
|
|
7
7
|
const isTagSet = (value) => typeof value === "object" && value !== null && "__brand" in value && value.__brand === "TagSet";
|
|
@@ -111,7 +111,10 @@ const toJsonSchema = (route) => {
|
|
|
111
111
|
const { shape } = buildToolInputSchema(route);
|
|
112
112
|
const { $schema: _, ...schema } = zod.z.toJSONSchema(zod.z.object(shape ?? {}), {
|
|
113
113
|
io: "input",
|
|
114
|
-
unrepresentable: "any"
|
|
114
|
+
unrepresentable: "any",
|
|
115
|
+
override: ({ jsonSchema }) => {
|
|
116
|
+
delete jsonSchema.brand;
|
|
117
|
+
}
|
|
115
118
|
});
|
|
116
119
|
return schema;
|
|
117
120
|
};
|
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-D_WJ2GBf.cjs");
|
|
3
|
-
const require_plugin_server = require("./plugin-server-
|
|
4
|
-
const require_adapter = require("./adapter-
|
|
5
|
-
const require_schemas = require("./schemas-
|
|
3
|
+
const require_plugin_server = require("./plugin-server-DrDIPl6R.cjs");
|
|
4
|
+
const require_adapter = require("./adapter-CGKgrfQy.cjs");
|
|
5
|
+
const require_schemas = require("./schemas-7y2XV1if.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_TAG, l as AUTO_GUARD_BRAND, m as HANDLER_CONTEXT_BRAND, o as pluginRouteTree } from "./plugin-CFpv8XTz.mjs";
|
|
2
|
-
import { H as isStreamResponse, M as encodeStreamBody, a as pluginRoutesOf, at as buildPath, ct as flattenRoutes, dt as validateRequest, g as jobAt, i as pluginRouterOf, lt as formatValidationError, m as isCompiledJob, o as resolvePlugins, ot as parsePath, p as flattenJobs, r as pluginExportsOf, st as allowedMethodsForPath, t as createApiReference, ut as isRouteDefinition } from "./plugin-server-
|
|
3
|
-
import { A as renderJsonResult, B as sortFlattenedRoutes, C as headersToObject, D as jobRunnerFrom, E as jobRoutes, F as isRawResponse, G as defineJobTransport, H as requiresDenial, I as rawResponse, J as jobFnAt, K as JobInputError, M as runHandler, N as runRoute, O as parseBodyText, P as warnUnsupportedJobOptions, S as guardDenyFor, T as jobRouter, U as withPermissions, V as insufficientScope, W as JobDispatchError, Y as ResponseError, _ as defineAdapter, _t as selectToolRoutes, a as HANDLER_ARG_KEYS, b as extractCredential, c as ROUTER_META, d as SCHEMES_META, dt as tagRoutes, f as adapterContextOf, g as contractOf, gt as describeTool, h as boundJobKeys, ht as buildToolInputSchema, i as GUARD_SCHEMA_META, j as routerFromRoutes, k as parseFetchBody, l as RUN_ROUTE_KEY, m as bearerChallenge, mt as buildToolDefinitions, n as DISPATCH_ROUTE_KEY, nt as problemDetails, o as JOBS_META, p as assembleApi, q as createJobRunner, r as GUARDS_META, s as REQUEST_CONTEXT_META, t as API_META, u as ResponseValidationError, v as dispatchHandler, vt as toolOptionsOf, w as isGuardDenial, x as getHeaderValue, xt as isTagSet, y as dispatchRoute, yt as toolRefusal, z as matchRoute } from "./adapter-
|
|
4
|
-
import { l as authenticationChallenge, p as resolveSecurityRequirements } from "./schemas-
|
|
2
|
+
import { H as isStreamResponse, M as encodeStreamBody, a as pluginRoutesOf, at as buildPath, ct as flattenRoutes, dt as validateRequest, g as jobAt, i as pluginRouterOf, lt as formatValidationError, m as isCompiledJob, o as resolvePlugins, ot as parsePath, p as flattenJobs, r as pluginExportsOf, st as allowedMethodsForPath, t as createApiReference, ut as isRouteDefinition } from "./plugin-server-C0CyVED-.mjs";
|
|
3
|
+
import { A as renderJsonResult, B as sortFlattenedRoutes, C as headersToObject, D as jobRunnerFrom, E as jobRoutes, F as isRawResponse, G as defineJobTransport, H as requiresDenial, I as rawResponse, J as jobFnAt, K as JobInputError, M as runHandler, N as runRoute, O as parseBodyText, P as warnUnsupportedJobOptions, S as guardDenyFor, T as jobRouter, U as withPermissions, V as insufficientScope, W as JobDispatchError, Y as ResponseError, _ as defineAdapter, _t as selectToolRoutes, a as HANDLER_ARG_KEYS, b as extractCredential, c as ROUTER_META, d as SCHEMES_META, dt as tagRoutes, f as adapterContextOf, g as contractOf, gt as describeTool, h as boundJobKeys, ht as buildToolInputSchema, i as GUARD_SCHEMA_META, j as routerFromRoutes, k as parseFetchBody, l as RUN_ROUTE_KEY, m as bearerChallenge, mt as buildToolDefinitions, n as DISPATCH_ROUTE_KEY, nt as problemDetails, o as JOBS_META, p as assembleApi, q as createJobRunner, r as GUARDS_META, s as REQUEST_CONTEXT_META, t as API_META, u as ResponseValidationError, v as dispatchHandler, vt as toolOptionsOf, w as isGuardDenial, x as getHeaderValue, xt as isTagSet, y as dispatchRoute, yt as toolRefusal, z as matchRoute } from "./adapter-Bp3CIsRc.mjs";
|
|
4
|
+
import { l as authenticationChallenge, p as resolveSecurityRequirements } from "./schemas-_W2cLAVl.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_TAG, 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, guardDenyFor, headersToObject, insufficientScope, isCompiledJob, isGuardDenial, isRawResponse, isRouteDefinition, isStreamResponse, isTagSet, jobAt, jobFnAt, jobRouter, jobRoutes, jobRunnerFrom, matchRoute, parseBodyText, parseFetchBody, parsePath, pluginExportsOf, pluginRouteTree, pluginRouterOf, pluginRoutesOf, problemDetails, rawResponse, renderJsonResult, requiresDenial, resolvePlugins, resolveSecurityRequirements, routerFromRoutes, runHandler, runRoute, selectToolRoutes, sortFlattenedRoutes, tagRoutes, toolOptionsOf, toolRefusal, validateRequest, warnUnsupportedJobOptions, withPermissions };
|
|
@@ -237,6 +237,13 @@ const readMetaDescription = (schema) => {
|
|
|
237
237
|
return typeof description === "string" ? description : void 0;
|
|
238
238
|
};
|
|
239
239
|
/**
|
|
240
|
+
* Returns a schema's `brand` metadata, set by `Kizuna.brand`, or undefined.
|
|
241
|
+
*/
|
|
242
|
+
const readMetaBrand = (schema) => {
|
|
243
|
+
const brand = readMeta(schema)?.brand;
|
|
244
|
+
return typeof brand === "string" ? brand : void 0;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
240
247
|
* The `Kizuna.model` schemas in the global registry, keyed by their `id`.
|
|
241
248
|
*/
|
|
242
249
|
const globalRegistrySchemas = () => {
|
|
@@ -467,6 +474,12 @@ Object.defineProperty(exports, "readMeta", {
|
|
|
467
474
|
return readMeta;
|
|
468
475
|
}
|
|
469
476
|
});
|
|
477
|
+
Object.defineProperty(exports, "readMetaBrand", {
|
|
478
|
+
enumerable: true,
|
|
479
|
+
get: function() {
|
|
480
|
+
return readMetaBrand;
|
|
481
|
+
}
|
|
482
|
+
});
|
|
470
483
|
Object.defineProperty(exports, "readMetaDescription", {
|
|
471
484
|
enumerable: true,
|
|
472
485
|
get: function() {
|
|
@@ -237,6 +237,13 @@ const readMetaDescription = (schema) => {
|
|
|
237
237
|
return typeof description === "string" ? description : void 0;
|
|
238
238
|
};
|
|
239
239
|
/**
|
|
240
|
+
* Returns a schema's `brand` metadata, set by `Kizuna.brand`, or undefined.
|
|
241
|
+
*/
|
|
242
|
+
const readMetaBrand = (schema) => {
|
|
243
|
+
const brand = readMeta(schema)?.brand;
|
|
244
|
+
return typeof brand === "string" ? brand : void 0;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
240
247
|
* The `Kizuna.model` schemas in the global registry, keyed by their `id`.
|
|
241
248
|
*/
|
|
242
249
|
const globalRegistrySchemas = () => {
|
|
@@ -347,4 +354,4 @@ function isProblemDetails(body) {
|
|
|
347
354
|
return typeof candidate.type === "string" && typeof candidate.title === "string" && typeof candidate.status === "number" && typeof candidate.detail === "string";
|
|
348
355
|
}
|
|
349
356
|
//#endregion
|
|
350
|
-
export {
|
|
357
|
+
export { readMetaExamples as C, unwrapOptionalWrappers as D, resolveBaseType as E, readMetaDescription as S, readObjectShape 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 };
|
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-C9ymqSU4.cjs");
|
|
3
|
+
const require_plugin_server = require("./plugin-server-DrDIPl6R.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,
|
|
@@ -203,6 +203,7 @@ exports.readDiscriminatedUnion = require_error_response.readDiscriminatedUnion;
|
|
|
203
203
|
exports.readDiscriminatorLiteral = require_error_response.readDiscriminatorLiteral;
|
|
204
204
|
exports.readDiscriminatorStringLiteral = require_error_response.readDiscriminatorStringLiteral;
|
|
205
205
|
exports.readMeta = require_error_response.readMeta;
|
|
206
|
+
exports.readMetaBrand = require_error_response.readMetaBrand;
|
|
206
207
|
exports.readMetaDescription = require_error_response.readMetaDescription;
|
|
207
208
|
exports.readMetaExamples = require_error_response.readMetaExamples;
|
|
208
209
|
exports.readMetaId = require_error_response.readMetaId;
|
package/dist/generator.d.cts
CHANGED
|
@@ -11,6 +11,8 @@ interface ZodDef {
|
|
|
11
11
|
coerce?: boolean;
|
|
12
12
|
innerType?: z.core.$ZodType;
|
|
13
13
|
element?: z.core.$ZodType;
|
|
14
|
+
items?: z.core.$ZodType[];
|
|
15
|
+
rest?: z.core.$ZodType | null;
|
|
14
16
|
in?: z.core.$ZodType;
|
|
15
17
|
out?: z.core.$ZodType;
|
|
16
18
|
shape?: Record<string, z.core.$ZodType>;
|
|
@@ -129,6 +131,10 @@ declare const readMetaExamples: (schema: z.core.$ZodType) => readonly unknown[];
|
|
|
129
131
|
* Returns a schema's `description` metadata, or undefined.
|
|
130
132
|
*/
|
|
131
133
|
declare const readMetaDescription: (schema: z.core.$ZodType) => string | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* Returns a schema's `brand` metadata, set by `Kizuna.brand`, or undefined.
|
|
136
|
+
*/
|
|
137
|
+
declare const readMetaBrand: (schema: z.core.$ZodType) => string | undefined;
|
|
132
138
|
/**
|
|
133
139
|
* The `Kizuna.model` schemas in the global registry, keyed by their `id`.
|
|
134
140
|
*/
|
|
@@ -367,4 +373,4 @@ interface GeneratorDefinition<Schema extends z.ZodType | undefined> {
|
|
|
367
373
|
*/
|
|
368
374
|
declare const defineGenerator: <Schema extends z.ZodType | undefined = undefined>(definition: GeneratorDefinition<Schema>) => ((options: OptionsInput<Schema> & GeneratedFileOptions) => GeneratedFile);
|
|
369
375
|
//#endregion
|
|
370
|
-
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, readMetaDescription, readMetaExamples, readMetaId, readObjectShape, resolveResponseBody, resolveResponseCache, resolveResponseContentType, resolveResponseEtag, resolveResponseHeaders, resolveResponseStream, routeStreams, sanitizeFieldName, sanitizeIdentifier, shortTypeName, soleStreamResponse, statusToCamelCase, streamContentType, streamMode, streamSchemas, streamStatuses, toCamelCase, toPascalCase, toToolName, unwrapOptionalWrappers, walkApi };
|
|
376
|
+
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, 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
|
@@ -11,6 +11,8 @@ interface ZodDef {
|
|
|
11
11
|
coerce?: boolean;
|
|
12
12
|
innerType?: z.core.$ZodType;
|
|
13
13
|
element?: z.core.$ZodType;
|
|
14
|
+
items?: z.core.$ZodType[];
|
|
15
|
+
rest?: z.core.$ZodType | null;
|
|
14
16
|
in?: z.core.$ZodType;
|
|
15
17
|
out?: z.core.$ZodType;
|
|
16
18
|
shape?: Record<string, z.core.$ZodType>;
|
|
@@ -129,6 +131,10 @@ declare const readMetaExamples: (schema: z.core.$ZodType) => readonly unknown[];
|
|
|
129
131
|
* Returns a schema's `description` metadata, or undefined.
|
|
130
132
|
*/
|
|
131
133
|
declare const readMetaDescription: (schema: z.core.$ZodType) => string | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* Returns a schema's `brand` metadata, set by `Kizuna.brand`, or undefined.
|
|
136
|
+
*/
|
|
137
|
+
declare const readMetaBrand: (schema: z.core.$ZodType) => string | undefined;
|
|
132
138
|
/**
|
|
133
139
|
* The `Kizuna.model` schemas in the global registry, keyed by their `id`.
|
|
134
140
|
*/
|
|
@@ -367,4 +373,4 @@ interface GeneratorDefinition<Schema extends z.ZodType | undefined> {
|
|
|
367
373
|
*/
|
|
368
374
|
declare const defineGenerator: <Schema extends z.ZodType | undefined = undefined>(definition: GeneratorDefinition<Schema>) => ((options: OptionsInput<Schema> & GeneratedFileOptions) => GeneratedFile);
|
|
369
375
|
//#endregion
|
|
370
|
-
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, readMetaDescription, readMetaExamples, readMetaId, readObjectShape, resolveResponseBody, resolveResponseCache, resolveResponseContentType, resolveResponseEtag, resolveResponseHeaders, resolveResponseStream, routeStreams, sanitizeFieldName, sanitizeIdentifier, shortTypeName, soleStreamResponse, statusToCamelCase, streamContentType, streamMode, streamSchemas, streamStatuses, toCamelCase, toPascalCase, toToolName, unwrapOptionalWrappers, walkApi };
|
|
376
|
+
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, 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
|
-
import { C as
|
|
2
|
-
import { $ as sanitizeFieldName, A as EVENT_STREAM_MEDIA_TYPE, B as isHintPrefix, F as soleStreamResponse, G as localTypeName, H as isStreamResponse, I as streamContentType, J as resolveResponseCache, K as mergeHeaderFields, L as streamMode, N as isNamedStream, O as deriveToolNames, P as routeStreams, Q as resolveResponseStream, R as streamSchemas, U as isSuccessStatus, V as isJsonMediaType, W as isZodSchema, X as resolveResponseEtag, Y as resolveResponseContentType, Z as resolveResponseHeaders, a as pluginRoutesOf, c as cacheHeaders, ct as flattenRoutes, et as sanitizeIdentifier, g as jobAt, it as toPascalCase, k as toToolName, m as isCompiledJob, n as describeIssue, nt as statusToCamelCase, ot as parsePath, p as flattenJobs, q as resolveResponseBody, rt as toCamelCase, tt as shortTypeName, u as deprecationHeaders, ut as isRouteDefinition, z as streamStatuses } from "./plugin-server-
|
|
1
|
+
import { C as readMetaExamples, D as unwrapOptionalWrappers, S as readMetaDescription, T as readObjectShape, _ 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-CNQaKVYd.mjs";
|
|
2
|
+
import { $ as sanitizeFieldName, A as EVENT_STREAM_MEDIA_TYPE, B as isHintPrefix, F as soleStreamResponse, G as localTypeName, H as isStreamResponse, I as streamContentType, J as resolveResponseCache, K as mergeHeaderFields, L as streamMode, N as isNamedStream, O as deriveToolNames, P as routeStreams, Q as resolveResponseStream, R as streamSchemas, U as isSuccessStatus, V as isJsonMediaType, W as isZodSchema, X as resolveResponseEtag, Y as resolveResponseContentType, Z as resolveResponseHeaders, a as pluginRoutesOf, c as cacheHeaders, ct as flattenRoutes, et as sanitizeIdentifier, g as jobAt, it as toPascalCase, k as toToolName, m as isCompiledJob, n as describeIssue, nt as statusToCamelCase, ot as parsePath, p as flattenJobs, q as resolveResponseBody, rt as toCamelCase, tt as shortTypeName, u as deprecationHeaders, ut as isRouteDefinition, z as streamStatuses } from "./plugin-server-C0CyVED-.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,
|
|
@@ -168,4 +168,4 @@ const defineGenerator = (definition) => (input) => {
|
|
|
168
168
|
};
|
|
169
169
|
};
|
|
170
170
|
//#endregion
|
|
171
|
-
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, readMetaDescription, readMetaExamples, readMetaId, readObjectShape, resolveResponseBody, resolveResponseCache, resolveResponseContentType, resolveResponseEtag, resolveResponseHeaders, resolveResponseStream, routeStreams, sanitizeFieldName, sanitizeIdentifier, shortTypeName, soleStreamResponse, statusToCamelCase, streamContentType, streamMode, streamSchemas, streamStatuses, toCamelCase, toPascalCase, toToolName, unwrapOptionalWrappers, walkApi };
|
|
171
|
+
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, 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-D_WJ2GBf.cjs");
|
|
3
|
-
const require_error_response = require("./error-response-
|
|
4
|
-
const require_plugin_server = require("./plugin-server-
|
|
5
|
-
const require_adapter = require("./adapter-
|
|
6
|
-
const require_schemas = require("./schemas-
|
|
3
|
+
const require_error_response = require("./error-response-C9ymqSU4.cjs");
|
|
4
|
+
const require_plugin_server = require("./plugin-server-DrDIPl6R.cjs");
|
|
5
|
+
const require_adapter = require("./adapter-CGKgrfQy.cjs");
|
|
6
|
+
const require_schemas = require("./schemas-7y2XV1if.cjs");
|
|
7
7
|
let zod = require("zod");
|
|
8
8
|
//#region src/coded-issue.ts
|
|
9
9
|
/**
|
|
@@ -165,6 +165,28 @@ const identityFactories = {
|
|
|
165
165
|
custom: (config) => buildable(createIdentity.custom(config))
|
|
166
166
|
};
|
|
167
167
|
//#endregion
|
|
168
|
+
//#region src/brand.ts
|
|
169
|
+
const BRANDABLE_TYPES = new Set([
|
|
170
|
+
"string",
|
|
171
|
+
"number",
|
|
172
|
+
"bigint",
|
|
173
|
+
"boolean",
|
|
174
|
+
"date"
|
|
175
|
+
]);
|
|
176
|
+
/**
|
|
177
|
+
* Brand a Zod schema, so the server and every generated client type its values
|
|
178
|
+
* as that brand. The schema is a string, number, bigint, boolean or date.
|
|
179
|
+
*
|
|
180
|
+
* ```ts
|
|
181
|
+
* const UserId = Kizuna.brand('UserId', z.string());
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
const createBrand = (brand, schema) => {
|
|
185
|
+
const type = require_error_response.readDef(schema).type;
|
|
186
|
+
if (type === void 0 || !BRANDABLE_TYPES.has(type)) throw new Error(`Kizuna.brand('${brand}') takes a string, number, bigint, boolean or date schema, not \`${type ?? "unknown"}\`. Put .optional() or .nullable() on the brand instead.`);
|
|
187
|
+
return schema.meta({ brand });
|
|
188
|
+
};
|
|
189
|
+
//#endregion
|
|
168
190
|
//#region src/job.ts
|
|
169
191
|
const createJob = (definition) => ({
|
|
170
192
|
...definition,
|
|
@@ -211,6 +233,11 @@ var Kizuna = class {
|
|
|
211
233
|
*/
|
|
212
234
|
static model = require_error_response.createModel;
|
|
213
235
|
/**
|
|
236
|
+
* Brand a schema, so the server and every generated client type its values
|
|
237
|
+
* as that brand.
|
|
238
|
+
*/
|
|
239
|
+
static brand = createBrand;
|
|
240
|
+
/**
|
|
214
241
|
* Declare the permissions callers hold, as a catalog of resources and the
|
|
215
242
|
* verbs each allows.
|
|
216
243
|
*/
|
package/dist/index.d.cts
CHANGED
|
@@ -2,11 +2,16 @@ import { $ as SecurityRequirement, A as AutoResponsesBrand, C as isPermissions,
|
|
|
2
2
|
import { $i as StreamMode, $n as JobFn, $r as GuardAnswer, Aa as CustomConfig, An as SchemesOf, Ar as RequestContextConfig, Ba as RolesOf, Bn as JobHandlers, Bt as PluginArgs, Ca as ApiKeyCredential, Ci as ToolAnswer, Cn as apiEntries, Cr as dueSchedules, Da as BearerCredential, Di as ToolRunResult, Dn as JobsOf, Dr as parseCron, E as MountedOf, Ea as BearerConfig, Ei as ToolRunOptions, En as GuardSchemaOf, Er as nextRuns, Fa as IdentityRole, Fn as FlattenedJob, Fr as TagKeysOf, Ft as ApiPlugins, Gn as JobsArg, Gt as PluginFactory, Hi as buildPath, Hn as JobRunnerConfig, Ht as PluginDefinition, Ia as NoCredential, Ii as ExtractPathParams, In as JobDefinition, Ir as TagOptions, Ji as StreamChunk, Jn as flattenJobs, Jt as PluginRoutes, Ki as StreamBody, Kn as JobsConfig, Kt as PluginList, La as OAuth2Config, Li as HasPathParams, Ln as JobHandler, Lr as TagSet, Ma as GuardHoldings, Mn as AuthoredJobs, Mr as RequestContextHeaderValues, Na as Identity, Nn as CompiledJob, Nr as RequestContextSchema, Oa as Credential, Oi as ToolDefinition, On as RequestContextOf, Or as scheduleExpression, Pa as IdentityParamsOf, Pn as CompiledJobs, Pr as NormalizeTags, Pt as AnyPlugin, Qi as StreamMessageOf, Qn as JobErrorHandler, Qt as PluginsBySlug, Ra as OpenIdConnectConfig, Ri as PathParamName, Rn as JobHandlerArgs, Rr as createTags, Sa as ApiKeyConfig, Si as StreamTools, Sn as GeneratedFile, Sr as cron, T as MountArgsOf, Ta as BasicCredential, Ti as ToolRunCall, Tn as ApiPluginsOf, Tr as nextRun, Ui as parsePath, Un as JobVoidReturn, Ur as RouteBuilder, Ut as PluginExportValues, Vi as RoutePathParamsCheck, Vn as JobResponses, Vt as PluginDeclaration, Wi as EVENT_STREAM_MEDIA_TYPE, Wn as Jobs, Wr as RouteWithHandler, Wt as PluginExportsOf, Xi as StreamContext, Xn as isJobDefinition, Xr as BrandedHandlerContext, Xt as PluginSetup, Yi as StreamComment, Yn as isCompiledJob, Yr as AuthContextOf, Yt as PluginRoutesOf, Zi as StreamMessage, Zn as jobAt, Zr as ContextFromAuth, Zt as PluginSetupContext, _ as GuardDeny, _a as toolEvents, _n as JobFnOf, _r as ScheduledJob, _t as isStreamResponse, aa as streamContentType, ai as HandlerReturn, ar as JobRunner, bn as ApiEntry, br as ParsedCron, ca as streamStatuses, cn as ConfiguredAdapterValue, cr as jobFnAt, ct as ResponseError, da as ToolCall, dn as ConfiguredIdentities, dr as JobMessage, ea as StreamYield, er as JobFnByKey, fa as ToolError, fi as RoutesWithHandlerContext, fn as ConfiguredJobs, fr as JobTransport, ga as expandStreamTools, gn as ConfiguredTags, gr as JobWorkerContext, h as GuardDenial, ha as ToolResult, hn as ConfiguredRequestContextSchemas, hr as JobWorker, ia as soleStreamResponse, ii as HandlerArgs, ir as JobRunArgs, ja as GrantsOf, jn as AuthoredJobDefinition, jr as RequestContextHeaderInputs, ka as CredentialOf, kn as RoutesOf, kr as scheduleTimezone, la as StreamWithTools, li as RouteGuardBrandOf, ln as ConfiguredCodes, lr as JobDescriptor, ma as ToolKeys, mn as ConfiguredRequestContext, mr as JobTransportSupports, na as isNamedStream, ni as GuardSuccess, nr as JobQueueArgs, oa as streamMode, or as JobRunnerOptions, pa as ToolEvents, pi as ThrowableReturn, pn as ConfiguredPlugins, pr as JobTransportDefinition, q as getHeaderValue, qi as StreamBodyOf, qn as NoJobs, ra as routeStreams, rn as definePlugin, rr as JobQueueOptions, s as AnyAdapter, sn as ConfiguredAdapterContext, sr as createJobRunner, ti as GuardReturn, tr as JobInputError, u as ApiWithRouter, ua as ToolAt, un as ConfiguredGuardSchema, ur as JobDispatchError, vn as JobsOfTree, vr as defineJobTransport, wa as BasicConfig, wi as ToolEventYield, wn as ApiDefinition, wr as firesBetween, xi as ModelToolCall, xn as DiffSettings, xr as assertValidSchedule, yi as isRouteDefinition, yn as KizunaConfigShape, yr as JobSchedule, yt as isZodSchema, za as RoleOf, zi as PathParamsCheck, zn as JobHandlerReturn, zt as PluginApi } from "./adapter-Ca2YCENa.cjs";
|
|
3
3
|
import { a as buildProtectedResourceMetadata, c as ValidationErrorFor, d as isValidationError, i as assertCanonicalResourceUri, n as ProtectedResourceMetadata, o as BuiltinIssueCode, s as ValidationError, t as ProtectedResourceConfig, u as ValidationIssueCode } from "./protected-resource-metadata-03dcSdwj.cjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { $output } from "zod/v4/core";
|
|
5
|
+
import { $input, $output } from "zod/v4/core";
|
|
6
6
|
|
|
7
7
|
//#region src/zod-meta.d.ts
|
|
8
8
|
declare module 'zod/v4/core' {
|
|
9
9
|
interface GlobalMeta {
|
|
10
|
+
/**
|
|
11
|
+
* The brand generated clients give this schema's values. Set by
|
|
12
|
+
* `Kizuna.brand`.
|
|
13
|
+
*/
|
|
14
|
+
brand?: string;
|
|
10
15
|
/**
|
|
11
16
|
* Deprecates the schema. Pass a message to tell callers what to use
|
|
12
17
|
* instead.
|
|
@@ -21,7 +26,7 @@ declare module 'zod/v4/core' {
|
|
|
21
26
|
* example: 'ada@example.com',
|
|
22
27
|
* });
|
|
23
28
|
*/
|
|
24
|
-
example?: $output | $output
|
|
29
|
+
example?: $input | $output | Array<$input | $output>;
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
//#endregion
|
|
@@ -44,6 +49,12 @@ interface ModelOptions<T extends z.ZodType> {
|
|
|
44
49
|
schema: T;
|
|
45
50
|
}
|
|
46
51
|
//#endregion
|
|
52
|
+
//#region src/brand.d.ts
|
|
53
|
+
/**
|
|
54
|
+
* What a brand wraps. Every client can give a scalar a type of its own.
|
|
55
|
+
*/
|
|
56
|
+
type BrandableSchema = z.ZodType<string | number | bigint | boolean | Date>;
|
|
57
|
+
//#endregion
|
|
47
58
|
//#region src/coded-issue.d.ts
|
|
48
59
|
/**
|
|
49
60
|
* A validation issue carrying a custom machine-readable {@link code}.
|
|
@@ -522,6 +533,11 @@ declare class Kizuna<Config extends KizunaConfigShape = Record<string, never>> i
|
|
|
522
533
|
* the one type rather than inlining it.
|
|
523
534
|
*/
|
|
524
535
|
static readonly model: <T extends z.ZodType>(options: ModelOptions<T>) => T;
|
|
536
|
+
/**
|
|
537
|
+
* Brand a schema, so the server and every generated client type its values
|
|
538
|
+
* as that brand.
|
|
539
|
+
*/
|
|
540
|
+
static readonly brand: <Brand extends string, T extends BrandableSchema>(brand: Brand, schema: T) => z.core.$ZodBranded<T, Brand>;
|
|
525
541
|
/**
|
|
526
542
|
* Declare the permissions callers hold, as a catalog of resources and the
|
|
527
543
|
* verbs each allows.
|
package/dist/index.d.mts
CHANGED
|
@@ -2,11 +2,16 @@ import { $ as SecurityRequirement, A as AutoResponsesBrand, C as isPermissions,
|
|
|
2
2
|
import { $i as StreamMode, $n as JobFn, $r as GuardAnswer, Aa as CustomConfig, An as SchemesOf, Ar as RequestContextConfig, Ba as RolesOf, Bn as JobHandlers, Bt as PluginArgs, Ca as ApiKeyCredential, Ci as ToolAnswer, Cn as apiEntries, Cr as dueSchedules, Da as BearerCredential, Di as ToolRunResult, Dn as JobsOf, Dr as parseCron, E as MountedOf, Ea as BearerConfig, Ei as ToolRunOptions, En as GuardSchemaOf, Er as nextRuns, Fa as IdentityRole, Fn as FlattenedJob, Fr as TagKeysOf, Ft as ApiPlugins, Gn as JobsArg, Gt as PluginFactory, Hi as buildPath, Hn as JobRunnerConfig, Ht as PluginDefinition, Ia as NoCredential, Ii as ExtractPathParams, In as JobDefinition, Ir as TagOptions, Ji as StreamChunk, Jn as flattenJobs, Jt as PluginRoutes, Ki as StreamBody, Kn as JobsConfig, Kt as PluginList, La as OAuth2Config, Li as HasPathParams, Ln as JobHandler, Lr as TagSet, Ma as GuardHoldings, Mn as AuthoredJobs, Mr as RequestContextHeaderValues, Na as Identity, Nn as CompiledJob, Nr as RequestContextSchema, Oa as Credential, Oi as ToolDefinition, On as RequestContextOf, Or as scheduleExpression, Pa as IdentityParamsOf, Pn as CompiledJobs, Pr as NormalizeTags, Pt as AnyPlugin, Qi as StreamMessageOf, Qn as JobErrorHandler, Qt as PluginsBySlug, Ra as OpenIdConnectConfig, Ri as PathParamName, Rn as JobHandlerArgs, Rr as createTags, Sa as ApiKeyConfig, Si as StreamTools, Sn as GeneratedFile, Sr as cron, T as MountArgsOf, Ta as BasicCredential, Ti as ToolRunCall, Tn as ApiPluginsOf, Tr as nextRun, Ui as parsePath, Un as JobVoidReturn, Ur as RouteBuilder, Ut as PluginExportValues, Vi as RoutePathParamsCheck, Vn as JobResponses, Vt as PluginDeclaration, Wi as EVENT_STREAM_MEDIA_TYPE, Wn as Jobs, Wr as RouteWithHandler, Wt as PluginExportsOf, Xi as StreamContext, Xn as isJobDefinition, Xr as BrandedHandlerContext, Xt as PluginSetup, Yi as StreamComment, Yn as isCompiledJob, Yr as AuthContextOf, Yt as PluginRoutesOf, Zi as StreamMessage, Zn as jobAt, Zr as ContextFromAuth, Zt as PluginSetupContext, _ as GuardDeny, _a as toolEvents, _n as JobFnOf, _r as ScheduledJob, _t as isStreamResponse, aa as streamContentType, ai as HandlerReturn, ar as JobRunner, bn as ApiEntry, br as ParsedCron, ca as streamStatuses, cn as ConfiguredAdapterValue, cr as jobFnAt, ct as ResponseError, da as ToolCall, dn as ConfiguredIdentities, dr as JobMessage, ea as StreamYield, er as JobFnByKey, fa as ToolError, fi as RoutesWithHandlerContext, fn as ConfiguredJobs, fr as JobTransport, ga as expandStreamTools, gn as ConfiguredTags, gr as JobWorkerContext, h as GuardDenial, ha as ToolResult, hn as ConfiguredRequestContextSchemas, hr as JobWorker, ia as soleStreamResponse, ii as HandlerArgs, ir as JobRunArgs, ja as GrantsOf, jn as AuthoredJobDefinition, jr as RequestContextHeaderInputs, ka as CredentialOf, kn as RoutesOf, kr as scheduleTimezone, la as StreamWithTools, li as RouteGuardBrandOf, ln as ConfiguredCodes, lr as JobDescriptor, ma as ToolKeys, mn as ConfiguredRequestContext, mr as JobTransportSupports, na as isNamedStream, ni as GuardSuccess, nr as JobQueueArgs, oa as streamMode, or as JobRunnerOptions, pa as ToolEvents, pi as ThrowableReturn, pn as ConfiguredPlugins, pr as JobTransportDefinition, q as getHeaderValue, qi as StreamBodyOf, qn as NoJobs, ra as routeStreams, rn as definePlugin, rr as JobQueueOptions, s as AnyAdapter, sn as ConfiguredAdapterContext, sr as createJobRunner, ti as GuardReturn, tr as JobInputError, u as ApiWithRouter, ua as ToolAt, un as ConfiguredGuardSchema, ur as JobDispatchError, vn as JobsOfTree, vr as defineJobTransport, wa as BasicConfig, wi as ToolEventYield, wn as ApiDefinition, wr as firesBetween, xi as ModelToolCall, xn as DiffSettings, xr as assertValidSchedule, yi as isRouteDefinition, yn as KizunaConfigShape, yr as JobSchedule, yt as isZodSchema, za as RoleOf, zi as PathParamsCheck, zn as JobHandlerReturn, zt as PluginApi } from "./adapter-BiPct09t.mjs";
|
|
3
3
|
import { a as buildProtectedResourceMetadata, c as ValidationErrorFor, d as isValidationError, i as assertCanonicalResourceUri, n as ProtectedResourceMetadata, o as BuiltinIssueCode, s as ValidationError, t as ProtectedResourceConfig, u as ValidationIssueCode } from "./protected-resource-metadata-By4Un6Oc.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { $output } from "zod/v4/core";
|
|
5
|
+
import { $input, $output } from "zod/v4/core";
|
|
6
6
|
|
|
7
7
|
//#region src/zod-meta.d.ts
|
|
8
8
|
declare module 'zod/v4/core' {
|
|
9
9
|
interface GlobalMeta {
|
|
10
|
+
/**
|
|
11
|
+
* The brand generated clients give this schema's values. Set by
|
|
12
|
+
* `Kizuna.brand`.
|
|
13
|
+
*/
|
|
14
|
+
brand?: string;
|
|
10
15
|
/**
|
|
11
16
|
* Deprecates the schema. Pass a message to tell callers what to use
|
|
12
17
|
* instead.
|
|
@@ -21,7 +26,7 @@ declare module 'zod/v4/core' {
|
|
|
21
26
|
* example: 'ada@example.com',
|
|
22
27
|
* });
|
|
23
28
|
*/
|
|
24
|
-
example?: $output | $output
|
|
29
|
+
example?: $input | $output | Array<$input | $output>;
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
//#endregion
|
|
@@ -44,6 +49,12 @@ interface ModelOptions<T extends z.ZodType> {
|
|
|
44
49
|
schema: T;
|
|
45
50
|
}
|
|
46
51
|
//#endregion
|
|
52
|
+
//#region src/brand.d.ts
|
|
53
|
+
/**
|
|
54
|
+
* What a brand wraps. Every client can give a scalar a type of its own.
|
|
55
|
+
*/
|
|
56
|
+
type BrandableSchema = z.ZodType<string | number | bigint | boolean | Date>;
|
|
57
|
+
//#endregion
|
|
47
58
|
//#region src/coded-issue.d.ts
|
|
48
59
|
/**
|
|
49
60
|
* A validation issue carrying a custom machine-readable {@link code}.
|
|
@@ -522,6 +533,11 @@ declare class Kizuna<Config extends KizunaConfigShape = Record<string, never>> i
|
|
|
522
533
|
* the one type rather than inlining it.
|
|
523
534
|
*/
|
|
524
535
|
static readonly model: <T extends z.ZodType>(options: ModelOptions<T>) => T;
|
|
536
|
+
/**
|
|
537
|
+
* Brand a schema, so the server and every generated client type its values
|
|
538
|
+
* as that brand.
|
|
539
|
+
*/
|
|
540
|
+
static readonly brand: <Brand extends string, T extends BrandableSchema>(brand: Brand, schema: T) => z.core.$ZodBranded<T, Brand>;
|
|
525
541
|
/**
|
|
526
542
|
* Declare the permissions callers hold, as a catalog of resources and the
|
|
527
543
|
* verbs each allows.
|
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, 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-CFpv8XTz.mjs";
|
|
2
|
-
import { n as isProblemDetails, r as createModel, t as ProblemDetailsSchema
|
|
3
|
-
import { A as EVENT_STREAM_MEDIA_TYPE, C as nextRun, D as scheduleTimezone, E as scheduleExpression, F as soleStreamResponse, H as isStreamResponse, I as streamContentType, L as streamMode, N as isNamedStream, P as routeStreams, S as firesBetween, T as parseCron, W as isZodSchema, _ as jobClaims, at as buildPath, b as cron, ct as flattenRoutes, f as buildJobs, g as jobAt, h as isJobDefinition, l as assertValidDeprecationDates, m as isCompiledJob, o as resolvePlugins, ot as parsePath, p as flattenJobs, q as resolveResponseBody, r as pluginExportsOf, s as assertValidCache, t as createApiReference, ut as isRouteDefinition, w as nextRuns, x as dueSchedules, y as assertValidSchedule, z as streamStatuses } from "./plugin-server-
|
|
4
|
-
import { $ as dispatchSucceeded, G as defineJobTransport, J as jobFnAt, K as JobInputError, L as assertNoPathCollisions, P as warnUnsupportedJobOptions, Q as dispatchDueJobs, R as routeClaims, W as JobDispatchError, X as DispatchFailedSchema, Y as ResponseError, Z as DispatchResultSchema, at as getStatusText, bt as createTags, ct as isPermissions, dt as tagRoutes, et as dueJobs, ft as expandStreamTools, it as STATUS_TITLES, j as routerFromRoutes, lt as isRoles, nt as problemDetails, o as JOBS_META, ot as createPermissions, p as assembleApi, pt as toolEvents, q as createJobRunner, rt as problemFromBody, st as createRoles, tt as failedJobs, ut as permissionNames, x as getHeaderValue } from "./adapter-
|
|
5
|
-
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-
|
|
2
|
+
import { T as readObjectShape, m as readDef, n as isProblemDetails, r as createModel, t as ProblemDetailsSchema } from "./error-response-CNQaKVYd.mjs";
|
|
3
|
+
import { A as EVENT_STREAM_MEDIA_TYPE, C as nextRun, D as scheduleTimezone, E as scheduleExpression, F as soleStreamResponse, H as isStreamResponse, I as streamContentType, L as streamMode, N as isNamedStream, P as routeStreams, S as firesBetween, T as parseCron, W as isZodSchema, _ as jobClaims, at as buildPath, b as cron, ct as flattenRoutes, f as buildJobs, g as jobAt, h as isJobDefinition, l as assertValidDeprecationDates, m as isCompiledJob, o as resolvePlugins, ot as parsePath, p as flattenJobs, q as resolveResponseBody, r as pluginExportsOf, s as assertValidCache, t as createApiReference, ut as isRouteDefinition, w as nextRuns, x as dueSchedules, y as assertValidSchedule, z as streamStatuses } from "./plugin-server-C0CyVED-.mjs";
|
|
4
|
+
import { $ as dispatchSucceeded, G as defineJobTransport, J as jobFnAt, K as JobInputError, L as assertNoPathCollisions, P as warnUnsupportedJobOptions, Q as dispatchDueJobs, R as routeClaims, W as JobDispatchError, X as DispatchFailedSchema, Y as ResponseError, Z as DispatchResultSchema, at as getStatusText, bt as createTags, ct as isPermissions, dt as tagRoutes, et as dueJobs, ft as expandStreamTools, it as STATUS_TITLES, j as routerFromRoutes, lt as isRoles, nt as problemDetails, o as JOBS_META, ot as createPermissions, p as assembleApi, pt as toolEvents, q as createJobRunner, rt as problemFromBody, st as createRoles, tt as failedJobs, ut as permissionNames, x as getHeaderValue } from "./adapter-Bp3CIsRc.mjs";
|
|
5
|
+
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-_W2cLAVl.mjs";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
//#region src/coded-issue.ts
|
|
8
8
|
/**
|
|
@@ -164,6 +164,28 @@ const identityFactories = {
|
|
|
164
164
|
custom: (config) => buildable(createIdentity.custom(config))
|
|
165
165
|
};
|
|
166
166
|
//#endregion
|
|
167
|
+
//#region src/brand.ts
|
|
168
|
+
const BRANDABLE_TYPES = new Set([
|
|
169
|
+
"string",
|
|
170
|
+
"number",
|
|
171
|
+
"bigint",
|
|
172
|
+
"boolean",
|
|
173
|
+
"date"
|
|
174
|
+
]);
|
|
175
|
+
/**
|
|
176
|
+
* Brand a Zod schema, so the server and every generated client type its values
|
|
177
|
+
* as that brand. The schema is a string, number, bigint, boolean or date.
|
|
178
|
+
*
|
|
179
|
+
* ```ts
|
|
180
|
+
* const UserId = Kizuna.brand('UserId', z.string());
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
const createBrand = (brand, schema) => {
|
|
184
|
+
const type = readDef(schema).type;
|
|
185
|
+
if (type === void 0 || !BRANDABLE_TYPES.has(type)) throw new Error(`Kizuna.brand('${brand}') takes a string, number, bigint, boolean or date schema, not \`${type ?? "unknown"}\`. Put .optional() or .nullable() on the brand instead.`);
|
|
186
|
+
return schema.meta({ brand });
|
|
187
|
+
};
|
|
188
|
+
//#endregion
|
|
167
189
|
//#region src/job.ts
|
|
168
190
|
const createJob = (definition) => ({
|
|
169
191
|
...definition,
|
|
@@ -210,6 +232,11 @@ var Kizuna = class {
|
|
|
210
232
|
*/
|
|
211
233
|
static model = createModel;
|
|
212
234
|
/**
|
|
235
|
+
* Brand a schema, so the server and every generated client type its values
|
|
236
|
+
* as that brand.
|
|
237
|
+
*/
|
|
238
|
+
static brand = createBrand;
|
|
239
|
+
/**
|
|
213
240
|
* Declare the permissions callers hold, as a catalog of resources and the
|
|
214
241
|
* verbs each allows.
|
|
215
242
|
*/
|
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-DrDIPl6R.cjs");
|
|
3
|
+
const require_adapter = require("./adapter-CGKgrfQy.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 { C as nextRun, D as scheduleTimezone, E as scheduleExpression, p as flattenJobs } from "./plugin-server-
|
|
2
|
-
import { D as jobRunnerFrom, J as jobFnAt, h as boundJobKeys, o as JOBS_META } from "./adapter-
|
|
1
|
+
import { C as nextRun, D as scheduleTimezone, E as scheduleExpression, p as flattenJobs } from "./plugin-server-C0CyVED-.mjs";
|
|
2
|
+
import { D as jobRunnerFrom, J as jobFnAt, h as boundJobKeys, o as JOBS_META } from "./adapter-Bp3CIsRc.mjs";
|
|
3
3
|
//#region src/start-jobs.ts
|
|
4
4
|
/**
|
|
5
5
|
* The dedupe key an occurrence gets. Every instance ticking the same minute
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as ROUTES_TAG, n as PLUGIN_SERVERS_META_KEY, t as PLUGIN_ROUTES_META_KEY } from "./plugin-CFpv8XTz.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { E as resolveBaseType, T as readObjectShape, a as WRAPPER_TYPES, c as isBinarySchema, m as readDef, t as ProblemDetailsSchema } from "./error-response-CNQaKVYd.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/coercion.ts
|
|
5
5
|
/**
|
package/dist/schemas.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_schemas = require("./schemas-
|
|
2
|
+
const require_error_response = require("./error-response-C9ymqSU4.cjs");
|
|
3
|
+
const require_schemas = require("./schemas-7y2XV1if.cjs");
|
|
4
4
|
exports.BinarySchema = require_schemas.BinarySchema;
|
|
5
5
|
exports.FileSchema = require_schemas.FileSchema;
|
|
6
6
|
exports.ProblemDetailsSchema = require_error_response.ProblemDetailsSchema;
|
package/dist/schemas.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as ProblemDetailsSchema } from "./error-response-
|
|
2
|
-
import { i as ProtectedResourceMetadataSchema, n as BinarySchema, r as FileSchema, s as ValidationErrorSchema, t as ToolAnswerSchema } from "./schemas-
|
|
1
|
+
import { t as ProblemDetailsSchema } from "./error-response-CNQaKVYd.mjs";
|
|
2
|
+
import { i as ProtectedResourceMetadataSchema, n as BinarySchema, r as FileSchema, s as ValidationErrorSchema, t as ToolAnswerSchema } from "./schemas-_W2cLAVl.mjs";
|
|
3
3
|
export { BinarySchema, FileSchema, ProblemDetailsSchema, ProtectedResourceMetadataSchema, ToolAnswerSchema, ValidationErrorSchema };
|
package/package.json
CHANGED
package/src/brand.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import { readDef } from './zod-internals.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What a brand wraps. Every client can give a scalar a type of its own.
|
|
6
|
+
*/
|
|
7
|
+
export type BrandableSchema = z.ZodType<string | number | bigint | boolean | Date>;
|
|
8
|
+
|
|
9
|
+
const BRANDABLE_TYPES = new Set(['string', 'number', 'bigint', 'boolean', 'date']);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Brand a Zod schema, so the server and every generated client type its values
|
|
13
|
+
* as that brand. The schema is a string, number, bigint, boolean or date.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const UserId = Kizuna.brand('UserId', z.string());
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export const createBrand = <Brand extends string, T extends BrandableSchema>(brand: Brand, schema: T): z.core.$ZodBranded<T, Brand> => {
|
|
20
|
+
const type = readDef(schema).type;
|
|
21
|
+
if (type === undefined || !BRANDABLE_TYPES.has(type)) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`Kizuna.brand('${brand}') takes a string, number, bigint, boolean or date schema, not \`${type ?? 'unknown'}\`. Put .optional() or .nullable() on the brand instead.`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return schema.meta({
|
|
27
|
+
brand,
|
|
28
|
+
}) as z.core.$ZodBranded<T, Brand>;
|
|
29
|
+
};
|
package/src/generator.ts
CHANGED
package/src/kizuna.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { createRequestContext, type RequestContextConfig } from './request-conte
|
|
|
9
9
|
import { createRequestContextBuilder, type RequestContextBuilder } from './request-context-builder.js';
|
|
10
10
|
import { identityFactories, type IdentityFactories } from './identity-builder.js';
|
|
11
11
|
import { createModel } from './model.js';
|
|
12
|
+
import { createBrand } from './brand.js';
|
|
12
13
|
import { type GuardBody, type GuardOutput } from './problem-details.js';
|
|
13
14
|
import type { Routes, AuthoredRoutes, AuthoredRouteDefinition, RouteHiddenToolCheck } from './types.js';
|
|
14
15
|
import type { SecurityScheme } from './security-scheme.js';
|
|
@@ -350,6 +351,11 @@ export class Kizuna<Config extends KizunaConfigShape = Record<string, never>> im
|
|
|
350
351
|
* the one type rather than inlining it.
|
|
351
352
|
*/
|
|
352
353
|
static readonly model = createModel;
|
|
354
|
+
/**
|
|
355
|
+
* Brand a schema, so the server and every generated client type its values
|
|
356
|
+
* as that brand.
|
|
357
|
+
*/
|
|
358
|
+
static readonly brand = createBrand;
|
|
353
359
|
/**
|
|
354
360
|
* Declare the permissions callers hold, as a catalog of resources and the
|
|
355
361
|
* verbs each allows.
|
package/src/tool-definitions.ts
CHANGED
|
@@ -138,6 +138,9 @@ const toJsonSchema = (route: RouteDefinition): Record<string, unknown> => {
|
|
|
138
138
|
const { $schema: _, ...schema } = z.toJSONSchema(z.object(shape ?? {}), {
|
|
139
139
|
io: 'input',
|
|
140
140
|
unrepresentable: 'any',
|
|
141
|
+
override: ({ jsonSchema }) => {
|
|
142
|
+
delete jsonSchema.brand;
|
|
143
|
+
},
|
|
141
144
|
}) as Record<string, unknown>;
|
|
142
145
|
return schema;
|
|
143
146
|
};
|
package/src/zod-internals.ts
CHANGED
|
@@ -8,6 +8,8 @@ export interface ZodDef {
|
|
|
8
8
|
coerce?: boolean;
|
|
9
9
|
innerType?: z.core.$ZodType;
|
|
10
10
|
element?: z.core.$ZodType;
|
|
11
|
+
items?: z.core.$ZodType[];
|
|
12
|
+
rest?: z.core.$ZodType | null;
|
|
11
13
|
in?: z.core.$ZodType;
|
|
12
14
|
out?: z.core.$ZodType;
|
|
13
15
|
shape?: Record<string, z.core.$ZodType>;
|
|
@@ -303,6 +305,14 @@ export const readMetaDescription = (schema: z.core.$ZodType): string | undefined
|
|
|
303
305
|
return typeof description === 'string' ? description : undefined;
|
|
304
306
|
};
|
|
305
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Returns a schema's `brand` metadata, set by `Kizuna.brand`, or undefined.
|
|
310
|
+
*/
|
|
311
|
+
export const readMetaBrand = (schema: z.core.$ZodType): string | undefined => {
|
|
312
|
+
const brand = readMeta(schema)?.brand;
|
|
313
|
+
return typeof brand === 'string' ? brand : undefined;
|
|
314
|
+
};
|
|
315
|
+
|
|
306
316
|
/**
|
|
307
317
|
* The `Kizuna.model` schemas in the global registry, keyed by their `id`.
|
|
308
318
|
*/
|
package/src/zod-meta.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import type { $output } from 'zod/v4/core';
|
|
1
|
+
import type { $input, $output } from 'zod/v4/core';
|
|
2
2
|
|
|
3
3
|
declare module 'zod/v4/core' {
|
|
4
4
|
interface GlobalMeta {
|
|
5
|
+
/**
|
|
6
|
+
* The brand generated clients give this schema's values. Set by
|
|
7
|
+
* `Kizuna.brand`.
|
|
8
|
+
*/
|
|
9
|
+
brand?: string;
|
|
5
10
|
/**
|
|
6
11
|
* Deprecates the schema. Pass a message to tell callers what to use
|
|
7
12
|
* instead.
|
|
@@ -16,7 +21,7 @@ declare module 'zod/v4/core' {
|
|
|
16
21
|
* example: 'ada@example.com',
|
|
17
22
|
* });
|
|
18
23
|
*/
|
|
19
|
-
example?: $output | $output
|
|
24
|
+
example?: $input | $output | Array<$input | $output>;
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
27
|
|