kizunajs 2.0.0-beta.22 → 2.0.0-beta.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md 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
- [![npm](https://img.shields.io/npm/v/kizunajs/beta?color=blue&label=npm)](https://www.npmjs.com/package/kizunajs/v/2.0.0-beta.22)
7
+ [![npm](https://img.shields.io/npm/v/kizunajs/beta?color=blue&label=npm)](https://www.npmjs.com/package/kizunajs/v/2.0.0-beta.23)
8
8
  ![license](https://img.shields.io/badge/license-MIT-blue)
9
9
 
10
10
  [Documentation](https://kizunajs.com)
@@ -1,7 +1,7 @@
1
1
  const require_plugin = require("./plugin-Dw-yCjTY.cjs");
2
- const require_error_response = require("./error-response-C9ymqSU4.cjs");
3
- const require_plugin_server = require("./plugin-server-D6-b-Sw8.cjs");
4
- const require_schemas = require("./schemas-DNPVDvkd.cjs");
2
+ const require_error_response = require("./error-response-DN5Dsf8b.cjs");
3
+ const require_plugin_server = require("./plugin-server-CfF82yZL.cjs");
4
+ const require_schemas = require("./schemas-Bre1FVHq.cjs");
5
5
  let zod = require("zod");
6
6
  //#region src/tool-definitions.ts
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import { g as ROUTES_GROUP, n as PLUGIN_SERVERS_META_KEY, o as pluginRouteTree, p as HANDLER, t as PLUGIN_ROUTES_META_KEY } from "./plugin-xxCxibmu.mjs";
2
- import { D as unwrapOptionalWrappers, E as resolveBaseType, T as readObjectShape, c as isBinarySchema, m as readDef, o as findCoercedSchemaPath, p as isVoidSchema, t as ProblemDetailsSchema, u as isFileSchema } from "./error-response-CNQaKVYd.mjs";
3
- import { F as routeStreams, G as isZodSchema, H as isJsonMediaType, J as resolveResponseBody, L as streamContentType, M as assertValidStreams, N as encodeStreamBody, S as dueSchedules, U as isStreamResponse, W as isSuccessStatus, X as resolveResponseContentType, Y as resolveResponseCache, Z as resolveResponseEtag, _ as jobAt, c as cacheHeaders, ct as allowedMethodsForPath, dt as isRouteDefinition, ft as validateRequest, h as isCompiledJob, j as EVENT_STREAM_MEDIA_TYPE, k as deriveToolNames, lt as flattenRoutes, m as flattenJobs, pt as resolveCoercionPlans, st as parsePath, u as deprecationHeaders, ut as formatValidationError, y as toJobResponse, z as streamSchemas } from "./plugin-server-DZx4-wXx.mjs";
4
- import { l as authenticationChallenge, p as resolveSecurityRequirements } from "./schemas-HW2FDsvz.mjs";
2
+ import { D as resolveBaseType, E as readObjectShape, O as unwrapOptionalWrappers, c as isBinarySchema, m as readDef, o as findCoercedSchemaPath, p as isVoidSchema, t as ProblemDetailsSchema, u as isFileSchema } from "./error-response-D7urgxeq.mjs";
3
+ import { F as routeStreams, G as isZodSchema, H as isJsonMediaType, J as resolveResponseBody, L as streamContentType, M as assertValidStreams, N as encodeStreamBody, S as dueSchedules, U as isStreamResponse, W as isSuccessStatus, X as resolveResponseContentType, Y as resolveResponseCache, Z as resolveResponseEtag, _ as jobAt, c as cacheHeaders, ct as allowedMethodsForPath, dt as isRouteDefinition, ft as validateRequest, h as isCompiledJob, j as EVENT_STREAM_MEDIA_TYPE, k as deriveToolNames, lt as flattenRoutes, m as flattenJobs, pt as resolveCoercionPlans, st as parsePath, u as deprecationHeaders, ut as formatValidationError, y as toJobResponse, z as streamSchemas } from "./plugin-server-DNQ9_DL7.mjs";
4
+ import { l as authenticationChallenge, p as resolveSecurityRequirements } from "./schemas-DBX8DwFb.mjs";
5
5
  import { z } from "zod";
6
6
  //#region src/tool-definitions.ts
7
7
  /**
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-D6-b-Sw8.cjs");
4
- const require_schemas = require("./schemas-DNPVDvkd.cjs");
5
- const require_adapter = require("./adapter-D7KXowQc.cjs");
3
+ const require_plugin_server = require("./plugin-server-CfF82yZL.cjs");
4
+ const require_schemas = require("./schemas-Bre1FVHq.cjs");
5
+ const require_adapter = require("./adapter-CK8ccDOC.cjs");
6
6
  exports.API_META = require_adapter.API_META;
7
7
  exports.AUTO_GUARD_BRAND = require_plugin.AUTO_GUARD_BRAND;
8
8
  exports.AUTO_RESPONSES_BRAND = require_plugin.AUTO_RESPONSES_BRAND;
package/dist/adapter.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as definePlugin, d as AUTO_RESPONSES_BRAND, g as ROUTES_GROUP, l as AUTO_GUARD_BRAND, m as HANDLER_CONTEXT_BRAND, o as pluginRouteTree } from "./plugin-xxCxibmu.mjs";
2
- import { N as encodeStreamBody, U as isStreamResponse, _ as jobAt, a as pluginRoutesOf, ct as allowedMethodsForPath, dt as isRouteDefinition, ft as validateRequest, h as isCompiledJob, i as pluginRouterOf, lt as flattenRoutes, m as flattenJobs, o as resolvePlugins, ot as buildPath, r as pluginExportsOf, st as parsePath, t as createApiReference, ut as formatValidationError } from "./plugin-server-DZx4-wXx.mjs";
3
- import { l as authenticationChallenge, p as resolveSecurityRequirements } from "./schemas-HW2FDsvz.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-_R9w_PZc.mjs";
2
+ import { N as encodeStreamBody, U as isStreamResponse, _ as jobAt, a as pluginRoutesOf, ct as allowedMethodsForPath, dt as isRouteDefinition, ft as validateRequest, h as isCompiledJob, i as pluginRouterOf, lt as flattenRoutes, m as flattenJobs, o as resolvePlugins, ot as buildPath, r as pluginExportsOf, st as parsePath, t as createApiReference, ut as formatValidationError } from "./plugin-server-DNQ9_DL7.mjs";
3
+ import { l as authenticationChallenge, p as resolveSecurityRequirements } from "./schemas-DBX8DwFb.mjs";
4
+ import { A as parseFetchBody, B as matchRoute, C as guardDenyFor, Ct as toolRefusal, D as jobRoutes, E as jobRouter, F as warnUnsupportedJobOptions, G as JobDispatchError, H as insufficientScope, I as isRawResponse, J as createJobRunner, K as defineJobTransport, L as rawResponse, M as routerFromRoutes, N as runHandler, O as jobRunnerFrom, P as runRoute, S as getHeaderValue, St as toolOptionsOf, T as isGuardDenial, U as requiresDenial, V as sortFlattenedRoutes, W as withPermissions, X as ResponseError, Y as jobFnAt, _ as defineAdapter, a as HANDLER_ARG_KEYS, b as entriesToObject, bt as describeTool, c as ROUTER_META, d as SCHEMES_META, f as adapterContextOf, g as contractOf, h as boundJobKeys, ht as groupRoutes, i as GUARD_SCHEMA_META, j as renderJsonResult, k as parseBodyText, l as RUN_ROUTE_KEY, m as bearerChallenge, n as DISPATCH_ROUTE_KEY, o as JOBS_META, p as assembleApi, pt as isGroupSet, q as JobInputError, r as GUARDS_META, rt as problemDetails, s as REQUEST_CONTEXT_META, t as API_META, u as ResponseValidationError, v as dispatchHandler, vt as buildToolDefinitions, w as headersToObject, x as extractCredential, xt as selectToolRoutes, y as dispatchRoute, yt as buildToolInputSchema } from "./adapter-DU3Ljl0P.mjs";
5
5
  export { API_META, AUTO_GUARD_BRAND, AUTO_RESPONSES_BRAND, DISPATCH_ROUTE_KEY, GUARDS_META, GUARD_SCHEMA_META, HANDLER_ARG_KEYS, HANDLER_CONTEXT_BRAND, JOBS_META, JobDispatchError, JobInputError, REQUEST_CONTEXT_META, ROUTER_META, ROUTES_GROUP, RUN_ROUTE_KEY, ResponseError, ResponseValidationError, SCHEMES_META, adapterContextOf, allowedMethodsForPath, assembleApi, authenticationChallenge, bearerChallenge, boundJobKeys, buildPath, buildToolDefinitions, buildToolInputSchema, contractOf, createApiReference, createJobRunner, defineAdapter, defineJobTransport, definePlugin, describeTool, dispatchHandler, dispatchRoute, encodeStreamBody, entriesToObject, extractCredential, flattenJobs, flattenRoutes, formatValidationError, getHeaderValue, groupRoutes, guardDenyFor, headersToObject, insufficientScope, isCompiledJob, isGroupSet, isGuardDenial, isRawResponse, isRouteDefinition, isStreamResponse, jobAt, jobFnAt, jobRouter, jobRoutes, jobRunnerFrom, matchRoute, parseBodyText, parseFetchBody, parsePath, pluginExportsOf, pluginRouteTree, pluginRouterOf, pluginRoutesOf, problemDetails, rawResponse, renderJsonResult, requiresDenial, resolvePlugins, resolveSecurityRequirements, routerFromRoutes, runHandler, runRoute, selectToolRoutes, sortFlattenedRoutes, toolOptionsOf, toolRefusal, validateRequest, warnUnsupportedJobOptions, withPermissions };
@@ -193,11 +193,24 @@ const markModelSchema = (schema) => {
193
193
  modelSchemas.add(schema);
194
194
  };
195
195
  /**
196
+ * Returns the `Kizuna.model` a schema is, or was copied from by `.describe()` or `.meta()`.
197
+ */
198
+ const readModelSchema = (schema) => {
199
+ let current = schema;
200
+ while (current !== void 0) {
201
+ if (modelSchemas.has(current)) return current;
202
+ const parent = current._zod.parent;
203
+ if (parent === void 0 || parent._zod.def !== current._zod.def) return void 0;
204
+ current = parent;
205
+ }
206
+ };
207
+ /**
196
208
  * Returns a `Kizuna.model` schema's `id` metadata, or undefined.
197
209
  */
198
210
  const readMetaId = (schema) => {
199
- if (!modelSchemas.has(schema)) return void 0;
200
- const id = readMeta(schema)?.id;
211
+ const model = readModelSchema(schema);
212
+ if (model === void 0) return void 0;
213
+ const id = readMeta(model)?.id;
201
214
  return typeof id === "string" ? id : void 0;
202
215
  };
203
216
  /**
@@ -354,4 +367,4 @@ function isProblemDetails(body) {
354
367
  return typeof candidate.type === "string" && typeof candidate.title === "string" && typeof candidate.status === "number" && typeof candidate.detail === "string";
355
368
  }
356
369
  //#endregion
357
- export { readMetaExamples as C, 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 };
370
+ export { readMetaExamples as C, resolveBaseType as D, readObjectShape as E, unwrapOptionalWrappers as O, readMetaDescription as S, readModelSchema as T, readDiscriminatedUnion as _, WRAPPER_TYPES as a, readMeta as b, isBinarySchema as c, isIntegerSchema as d, isObjectSchema as f, readDeprecation as g, readDefType as h, FILE_PROBE as i, isDiscriminatedUnionSchema as l, readDef as m, isProblemDetails as n, findCoercedSchemaPath as o, isVoidSchema as p, createModel as r, globalRegistrySchemas as s, ProblemDetailsSchema as t, isFileSchema as u, readDiscriminatorLiteral as v, readMetaId as w, readMetaBrand as x, readDiscriminatorStringLiteral as y };
@@ -193,11 +193,24 @@ const markModelSchema = (schema) => {
193
193
  modelSchemas.add(schema);
194
194
  };
195
195
  /**
196
+ * Returns the `Kizuna.model` a schema is, or was copied from by `.describe()` or `.meta()`.
197
+ */
198
+ const readModelSchema = (schema) => {
199
+ let current = schema;
200
+ while (current !== void 0) {
201
+ if (modelSchemas.has(current)) return current;
202
+ const parent = current._zod.parent;
203
+ if (parent === void 0 || parent._zod.def !== current._zod.def) return void 0;
204
+ current = parent;
205
+ }
206
+ };
207
+ /**
196
208
  * Returns a `Kizuna.model` schema's `id` metadata, or undefined.
197
209
  */
198
210
  const readMetaId = (schema) => {
199
- if (!modelSchemas.has(schema)) return void 0;
200
- const id = readMeta(schema)?.id;
211
+ const model = readModelSchema(schema);
212
+ if (model === void 0) return void 0;
213
+ const id = readMeta(model)?.id;
201
214
  return typeof id === "string" ? id : void 0;
202
215
  };
203
216
  /**
@@ -498,6 +511,12 @@ Object.defineProperty(exports, "readMetaId", {
498
511
  return readMetaId;
499
512
  }
500
513
  });
514
+ Object.defineProperty(exports, "readModelSchema", {
515
+ enumerable: true,
516
+ get: function() {
517
+ return readModelSchema;
518
+ }
519
+ });
501
520
  Object.defineProperty(exports, "readObjectShape", {
502
521
  enumerable: true,
503
522
  get: function() {
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_error_response = require("./error-response-C9ymqSU4.cjs");
3
- const require_plugin_server = require("./plugin-server-D6-b-Sw8.cjs");
2
+ const require_error_response = require("./error-response-DN5Dsf8b.cjs");
3
+ const require_plugin_server = require("./plugin-server-CfF82yZL.cjs");
4
4
  //#region src/generator.ts
5
5
  /**
6
6
  * Every route the api serves, the app's and the plugins' under their slugs,
@@ -42,7 +42,8 @@ const reachModels = (value, models, found, seen) => {
42
42
  if (typeof value !== "object" || value === null || seen.has(value)) return;
43
43
  seen.add(value);
44
44
  if (isSchema(value)) {
45
- if (models.has(value)) found.add(value);
45
+ const model = require_error_response.readModelSchema(value);
46
+ if (model !== void 0 && models.has(model)) found.add(model);
46
47
  const def = value._zod.def;
47
48
  for (const [key, child] of Object.entries(def)) {
48
49
  if (key === "checks") continue;
@@ -207,6 +208,7 @@ exports.readMetaBrand = require_error_response.readMetaBrand;
207
208
  exports.readMetaDescription = require_error_response.readMetaDescription;
208
209
  exports.readMetaExamples = require_error_response.readMetaExamples;
209
210
  exports.readMetaId = require_error_response.readMetaId;
211
+ exports.readModelSchema = require_error_response.readModelSchema;
210
212
  exports.readObjectShape = require_error_response.readObjectShape;
211
213
  exports.resolveResponseBody = require_plugin_server.resolveResponseBody;
212
214
  exports.resolveResponseCache = require_plugin_server.resolveResponseCache;
@@ -107,6 +107,10 @@ declare const isBinarySchema: (schema: z.core.$ZodType) => boolean;
107
107
  * Returns a schema's metadata (set via `.meta()`), or undefined.
108
108
  */
109
109
  declare const readMeta: (schema: z.core.$ZodType) => Record<string, unknown> | undefined;
110
+ /**
111
+ * Returns the `Kizuna.model` a schema is, or was copied from by `.describe()` or `.meta()`.
112
+ */
113
+ declare const readModelSchema: (schema: z.core.$ZodType) => z.core.$ZodType | undefined;
110
114
  /**
111
115
  * Returns a `Kizuna.model` schema's `id` metadata, or undefined.
112
116
  */
@@ -376,4 +380,4 @@ interface GeneratorDefinition<Schema extends z.ZodType | undefined> {
376
380
  */
377
381
  declare const defineGenerator: <Schema extends z.ZodType | undefined = undefined>(definition: GeneratorDefinition<Schema>) => ((options: OptionsInput<Schema> & GeneratedFileOptions) => GeneratedFile);
378
382
  //#endregion
379
- 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 };
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 };
@@ -107,6 +107,10 @@ declare const isBinarySchema: (schema: z.core.$ZodType) => boolean;
107
107
  * Returns a schema's metadata (set via `.meta()`), or undefined.
108
108
  */
109
109
  declare const readMeta: (schema: z.core.$ZodType) => Record<string, unknown> | undefined;
110
+ /**
111
+ * Returns the `Kizuna.model` a schema is, or was copied from by `.describe()` or `.meta()`.
112
+ */
113
+ declare const readModelSchema: (schema: z.core.$ZodType) => z.core.$ZodType | undefined;
110
114
  /**
111
115
  * Returns a `Kizuna.model` schema's `id` metadata, or undefined.
112
116
  */
@@ -376,4 +380,4 @@ interface GeneratorDefinition<Schema extends z.ZodType | undefined> {
376
380
  */
377
381
  declare const defineGenerator: <Schema extends z.ZodType | undefined = undefined>(definition: GeneratorDefinition<Schema>) => ((options: OptionsInput<Schema> & GeneratedFileOptions) => GeneratedFile);
378
382
  //#endregion
379
- 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 };
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 };
@@ -1,5 +1,5 @@
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 resolveResponseStream, A as toToolName, B as streamStatuses, F as routeStreams, G as isZodSchema, H as isJsonMediaType, I as soleStreamResponse, J as resolveResponseBody, K as localTypeName, L as streamContentType, P as isNamedStream, Q as resolveResponseHeaders, R as streamMode, U as isStreamResponse, V as isHintPrefix, W as isSuccessStatus, X as resolveResponseContentType, Y as resolveResponseCache, Z as resolveResponseEtag, _ as jobAt, a as pluginRoutesOf, at as toPascalCase, c as cacheHeaders, dt as isRouteDefinition, et as sanitizeFieldName, h as isCompiledJob, it as toCamelCase, j as EVENT_STREAM_MEDIA_TYPE, k as deriveToolNames, lt as flattenRoutes, m as flattenJobs, n as describeIssue, nt as shortTypeName, q as mergeHeaderFields, rt as statusToCamelCase, st as parsePath, tt as sanitizeIdentifier, u as deprecationHeaders, z as streamSchemas } from "./plugin-server-DZx4-wXx.mjs";
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 resolveResponseStream, A as toToolName, B as streamStatuses, F as routeStreams, G as isZodSchema, H as isJsonMediaType, I as soleStreamResponse, J as resolveResponseBody, K as localTypeName, L as streamContentType, P as isNamedStream, Q as resolveResponseHeaders, R as streamMode, U as isStreamResponse, V as isHintPrefix, W as isSuccessStatus, X as resolveResponseContentType, Y as resolveResponseCache, Z as resolveResponseEtag, _ as jobAt, a as pluginRoutesOf, at as toPascalCase, c as cacheHeaders, dt as isRouteDefinition, et as sanitizeFieldName, h as isCompiledJob, it as toCamelCase, j as EVENT_STREAM_MEDIA_TYPE, k as deriveToolNames, lt as flattenRoutes, m as flattenJobs, n as describeIssue, nt as shortTypeName, q as mergeHeaderFields, rt as statusToCamelCase, st as parsePath, tt as sanitizeIdentifier, u as deprecationHeaders, z as streamSchemas } from "./plugin-server-DNQ9_DL7.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,
@@ -41,7 +41,8 @@ const reachModels = (value, models, found, seen) => {
41
41
  if (typeof value !== "object" || value === null || seen.has(value)) return;
42
42
  seen.add(value);
43
43
  if (isSchema(value)) {
44
- if (models.has(value)) found.add(value);
44
+ const model = readModelSchema(value);
45
+ if (model !== void 0 && models.has(model)) found.add(model);
45
46
  const def = value._zod.def;
46
47
  for (const [key, child] of Object.entries(def)) {
47
48
  if (key === "checks") continue;
@@ -168,4 +169,4 @@ const defineGenerator = (definition) => (input) => {
168
169
  };
169
170
  };
170
171
  //#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, 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 };
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 };
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
- const require_error_response = require("./error-response-C9ymqSU4.cjs");
4
- const require_plugin_server = require("./plugin-server-D6-b-Sw8.cjs");
5
- const require_schemas = require("./schemas-DNPVDvkd.cjs");
6
- const require_adapter = require("./adapter-D7KXowQc.cjs");
3
+ const require_error_response = require("./error-response-DN5Dsf8b.cjs");
4
+ const require_plugin_server = require("./plugin-server-CfF82yZL.cjs");
5
+ const require_schemas = require("./schemas-Bre1FVHq.cjs");
6
+ const require_adapter = require("./adapter-CK8ccDOC.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
- import { T as readObjectShape, m as readDef, n as isProblemDetails, r as createModel, t as ProblemDetailsSchema } from "./error-response-CNQaKVYd.mjs";
3
- import { B as streamStatuses, C as firesBetween, D as scheduleExpression, E as parseCron, F as routeStreams, G as isZodSchema, I as soleStreamResponse, J as resolveResponseBody, L as streamContentType, O as scheduleTimezone, P as isNamedStream, R as streamMode, S as dueSchedules, T as nextRuns, U as isStreamResponse, _ as jobAt, b as assertValidSchedule, dt as isRouteDefinition, f as assertJobRunner, g as isJobDefinition, h as isCompiledJob, j as EVENT_STREAM_MEDIA_TYPE, l as assertValidDeprecationDates, lt as flattenRoutes, m as flattenJobs, o as resolvePlugins, ot as buildPath, p as buildJobs, r as pluginExportsOf, s as assertValidCache, st as parsePath, t as createApiReference, v as jobClaims, w as nextRun, x as cron } from "./plugin-server-DZx4-wXx.mjs";
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-HW2FDsvz.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-_R9w_PZc.mjs";
2
+ import { E as readObjectShape, m as readDef, n as isProblemDetails, r as createModel, t as ProblemDetailsSchema } from "./error-response-D7urgxeq.mjs";
3
+ import { B as streamStatuses, C as firesBetween, D as scheduleExpression, E as parseCron, F as routeStreams, G as isZodSchema, I as soleStreamResponse, J as resolveResponseBody, L as streamContentType, O as scheduleTimezone, P as isNamedStream, R as streamMode, S as dueSchedules, T as nextRuns, U as isStreamResponse, _ as jobAt, b as assertValidSchedule, dt as isRouteDefinition, f as assertJobRunner, g as isJobDefinition, h as isCompiledJob, j as EVENT_STREAM_MEDIA_TYPE, l as assertValidDeprecationDates, lt as flattenRoutes, m as flattenJobs, o as resolvePlugins, ot as buildPath, p as buildJobs, r as pluginExportsOf, s as assertValidCache, st as parsePath, t as createApiReference, v as jobClaims, w as nextRun, x as cron } from "./plugin-server-DNQ9_DL7.mjs";
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-DU3Ljl0P.mjs";
6
6
  import { z } from "zod";
7
7
  //#region src/group-routes.ts
8
8
  /**
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_plugin_server = require("./plugin-server-D6-b-Sw8.cjs");
3
- const require_adapter = require("./adapter-D7KXowQc.cjs");
2
+ const require_plugin_server = require("./plugin-server-CfF82yZL.cjs");
3
+ const require_adapter = require("./adapter-CK8ccDOC.cjs");
4
4
  //#region src/start-jobs.ts
5
5
  /**
6
6
  * The dedupe key an occurrence gets. Every instance ticking the same minute
@@ -1,5 +1,5 @@
1
- import { D as scheduleExpression, O as scheduleTimezone, m as flattenJobs, w as nextRun } from "./plugin-server-DZx4-wXx.mjs";
2
- import { O as jobRunnerFrom, Y as jobFnAt, h as boundJobKeys, o as JOBS_META } from "./adapter-_R9w_PZc.mjs";
1
+ import { D as scheduleExpression, O as scheduleTimezone, m as flattenJobs, w as nextRun } from "./plugin-server-DNQ9_DL7.mjs";
2
+ import { O as jobRunnerFrom, Y as jobFnAt, h as boundJobKeys, o as JOBS_META } from "./adapter-DU3Ljl0P.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
  const require_plugin = require("./plugin-Dw-yCjTY.cjs");
2
- const require_error_response = require("./error-response-C9ymqSU4.cjs");
2
+ const require_error_response = require("./error-response-DN5Dsf8b.cjs");
3
3
  let zod = require("zod");
4
4
  //#region src/coercion.ts
5
5
  /**
@@ -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 { E as resolveBaseType, T as readObjectShape, a as WRAPPER_TYPES, c as isBinarySchema, m as readDef, t as ProblemDetailsSchema } from "./error-response-CNQaKVYd.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";
3
3
  import { z } from "zod";
4
4
  //#region src/coercion.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- const require_error_response = require("./error-response-C9ymqSU4.cjs");
1
+ const require_error_response = require("./error-response-DN5Dsf8b.cjs");
2
2
  let zod = require("zod");
3
3
  //#region src/security-scheme.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { r as createModel, t as ProblemDetailsSchema } from "./error-response-CNQaKVYd.mjs";
1
+ import { r as createModel, t as ProblemDetailsSchema } from "./error-response-D7urgxeq.mjs";
2
2
  import { z } from "zod";
3
3
  //#region src/security-scheme.ts
4
4
  /**
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-C9ymqSU4.cjs");
3
- const require_schemas = require("./schemas-DNPVDvkd.cjs");
2
+ const require_error_response = require("./error-response-DN5Dsf8b.cjs");
3
+ const require_schemas = require("./schemas-Bre1FVHq.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-CNQaKVYd.mjs";
2
- import { i as ProtectedResourceMetadataSchema, n as BinarySchema, r as FileSchema, s as ValidationErrorSchema, t as ToolAnswerSchema } from "./schemas-HW2FDsvz.mjs";
1
+ import { t as ProblemDetailsSchema } from "./error-response-D7urgxeq.mjs";
2
+ import { i as ProtectedResourceMetadataSchema, n as BinarySchema, r as FileSchema, s as ValidationErrorSchema, t as ToolAnswerSchema } from "./schemas-DBX8DwFb.mjs";
3
3
  export { BinarySchema, FileSchema, ProblemDetailsSchema, ProtectedResourceMetadataSchema, ToolAnswerSchema, ValidationErrorSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kizunajs",
3
- "version": "2.0.0-beta.22",
3
+ "version": "2.0.0-beta.23",
4
4
  "description": "Route declaration, validation, and the adapter API for Kizuna.js",
5
5
  "keywords": [
6
6
  "kizunajs",
package/src/generator.ts CHANGED
@@ -5,7 +5,7 @@ import type { Routes, RouteDefinition } from './types.js';
5
5
  import type { ApiDefinition } from './api-definition.js';
6
6
  import { isRouteDefinition } from './handler-pipeline.js';
7
7
  import { describeIssue, pluginRoutesOf } from './plugin-server.js';
8
- import { globalRegistrySchemas, readMetaDescription } from './zod-internals.js';
8
+ import { globalRegistrySchemas, readMetaDescription, readModelSchema } from './zod-internals.js';
9
9
  import type { GeneratedFile } from './config.js';
10
10
  import type { z } from 'zod';
11
11
 
@@ -28,6 +28,7 @@ export {
28
28
  readDiscriminatedUnion,
29
29
  readMeta,
30
30
  readMetaId,
31
+ readModelSchema,
31
32
  readMetaDescription,
32
33
  readMetaBrand,
33
34
  readMetaExamples,
@@ -222,7 +223,8 @@ const reachModels = (value: unknown, models: Map<z.core.$ZodType, string>, found
222
223
  if (typeof value !== 'object' || value === null || seen.has(value)) return;
223
224
  seen.add(value);
224
225
  if (isSchema(value)) {
225
- if (models.has(value)) found.add(value);
226
+ const model = readModelSchema(value);
227
+ if (model !== undefined && models.has(model)) found.add(model);
226
228
  const def = value._zod.def as unknown as Record<string, unknown>;
227
229
  for (const [key, child] of Object.entries(def)) {
228
230
  if (key === 'checks') continue;
@@ -248,12 +248,27 @@ export const markModelSchema = (schema: z.core.$ZodType): void => {
248
248
  modelSchemas.add(schema);
249
249
  };
250
250
 
251
+ /**
252
+ * Returns the `Kizuna.model` a schema is, or was copied from by `.describe()` or `.meta()`.
253
+ */
254
+ export const readModelSchema = (schema: z.core.$ZodType): z.core.$ZodType | undefined => {
255
+ let current: z.core.$ZodType | undefined = schema;
256
+ while (current !== undefined) {
257
+ if (modelSchemas.has(current)) return current;
258
+ const parent: z.core.$ZodType | undefined = current._zod.parent;
259
+ if (parent === undefined || parent._zod.def !== current._zod.def) return undefined;
260
+ current = parent;
261
+ }
262
+ return undefined;
263
+ };
264
+
251
265
  /**
252
266
  * Returns a `Kizuna.model` schema's `id` metadata, or undefined.
253
267
  */
254
268
  export const readMetaId = (schema: z.core.$ZodType): string | undefined => {
255
- if (!modelSchemas.has(schema)) return undefined;
256
- const id = readMeta(schema)?.id;
269
+ const model = readModelSchema(schema);
270
+ if (model === undefined) return undefined;
271
+ const id = readMeta(model)?.id;
257
272
  return typeof id === 'string' ? id : undefined;
258
273
  };
259
274