@emeryld/rrroutes-contract 2.1.11 → 2.1.12

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.
@@ -1,2 +1,6 @@
1
1
  import { AnyLeaf } from "../core/routesV3.core";
2
- export declare function renderLeafDocsHTML(leaves: AnyLeaf[]): string;
2
+ interface RenderOptions {
3
+ cspNonce?: string;
4
+ }
5
+ export declare function renderLeafDocsHTML(leaves: AnyLeaf[], options?: RenderOptions): string;
6
+ export {};
package/dist/index.cjs CHANGED
@@ -325,16 +325,7 @@ function serializeLeaf(leaf) {
325
325
  }
326
326
 
327
327
  // src/docs/docs.ts
328
- function renderLeafDocsHTML(leaves) {
329
- const docsLeaves = leaves.map(serializeLeaf);
330
- const leafJson = JSON.stringify(docsLeaves).replace(/</g, "\\u003c");
331
- return `<!DOCTYPE html>
332
- <html lang="en">
333
- <head>
334
- <meta charset="utf-8" />
335
- <title>API Routes</title>
336
- <meta name="viewport" content="width=device-width, initial-scale=1" />
337
- <style>
328
+ var styles = `
338
329
  :root {
339
330
  --bg: #020617;
340
331
  --bg-elevated: #020617;
@@ -363,6 +354,7 @@ function renderLeafDocsHTML(leaves) {
363
354
  -webkit-font-smoothing: antialiased;
364
355
  }
365
356
 
357
+
366
358
  .page {
367
359
  min-height: 100vh;
368
360
  padding: 24px;
@@ -726,13 +718,25 @@ function renderLeafDocsHTML(leaves) {
726
718
  border-radius: 10px;
727
719
  border: 1px dashed rgba(148, 163, 184, 0.5);
728
720
  background: rgba(15, 23, 42, 0.9);
729
- }
721
+ }`;
722
+ function renderLeafDocsHTML(leaves, options = {}) {
723
+ const docsLeaves = leaves.map(serializeLeaf);
724
+ const leafJson = JSON.stringify(docsLeaves).replace(/</g, "\\u003c");
725
+ const nonceAttr = options.cspNonce ? ` nonce="${options.cspNonce}"` : "";
726
+ return `<!DOCTYPE html>
727
+ <html lang="en">
728
+ <head>
729
+ <meta charset="utf-8" />
730
+ <title>API Routes</title>
731
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
732
+ <style${nonceAttr}>
733
+ ${styles}
730
734
  </style>
731
735
  </head>
732
736
  <body>
733
737
  <div class="page">
734
738
  <div class="shell">
735
- <header class="header">
739
+ <header class="header">
736
740
  <div class="header-main">
737
741
  <div class="title-row">
738
742
  <div class="title">
@@ -746,8 +750,7 @@ function renderLeafDocsHTML(leaves) {
746
750
  </div>
747
751
  <div id="stats" class="stats"></div>
748
752
  </header>
749
-
750
- <div class="layout">
753
+ <div class="layout">
751
754
  <aside class="sidebar">
752
755
  <h2>Filters</h2>
753
756
 
@@ -784,8 +787,8 @@ function renderLeafDocsHTML(leaves) {
784
787
  </div>
785
788
  </div>
786
789
 
787
- <script id="leaf-data" type="application/json">${leafJson}</script>
788
- <script>
790
+ <script id="leaf-data" type="application/json"${nonceAttr}>${leafJson}</script>
791
+ <script${nonceAttr}>
789
792
  (function () {
790
793
  function escapeHtml(str) {
791
794
  return String(str)
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/core/routesV3.builder.ts","../src/core/routesV3.core.ts","../src/core/routesV3.finalize.ts","../src/crud/routesV3.crud.ts","../src/sockets/socket.index.ts","../src/docs/serializer.ts","../src/docs/docs.ts"],"sourcesContent":["export * from './core/routesV3.builder';\nexport * from './core/routesV3.core';\nexport * from './core/routesV3.finalize';\nexport * from './crud/routesV3.crud';\nexport * from './sockets/socket.index';\nexport * from './docs/docs';","import { z } from 'zod';\nimport {\n AnyLeaf,\n Append,\n HttpMethod,\n Leaf,\n Merge,\n MergeArray,\n MethodCfg,\n NodeCfg,\n Prettify,\n} from './routesV3.core';\n\nconst defaultFeedQuerySchema = z.object({\n cursor: z.string().optional(),\n limit: z.coerce.number().min(1).max(100).default(20),\n});\n\nconst paginationField = defaultFeedQuerySchema.optional().default(defaultFeedQuerySchema.parse({}));\ntype PaginationField = typeof paginationField;\n\ntype ZodTypeAny = z.ZodTypeAny;\ntype ParamZod<Name extends string, S extends ZodTypeAny> = z.ZodObject<{ [K in Name]: S }>;\ntype ZodArrayAny = z.ZodArray<ZodTypeAny>;\ntype ZodObjectAny = z.ZodObject<any>;\ntype AnyZodObject = z.ZodObject<any>;\ntype MergedParamsResult<PS, Name extends string, P extends ZodTypeAny> = PS extends ZodTypeAny\n ? z.ZodIntersection<PS, ParamZod<Name, P>>\n : ParamZod<Name, P>;\n\nconst defaultFeedOutputSchema = z.object({\n items: z.array(z.unknown()),\n nextCursor: z.string().optional(),\n});\n\nfunction augmentFeedQuerySchema<Q extends ZodTypeAny | undefined>(schema: Q) {\n if (schema && !(schema instanceof z.ZodObject)) {\n console.warn('Feed queries must be a ZodObject; default pagination applied.');\n return z.object({\n pagination: paginationField,\n });\n }\n\n const base = (schema as ZodObjectAny) ?? z.object({});\n return base.extend({\n pagination: paginationField,\n });\n}\n\nfunction augmentFeedOutputSchema<O extends ZodTypeAny | undefined>(schema: O) {\n if (!schema) return defaultFeedOutputSchema;\n if (schema instanceof z.ZodArray) {\n return z.object({\n items: schema,\n nextCursor: z.string().optional(),\n });\n }\n if (schema instanceof z.ZodObject) {\n const shape = (schema as any).shape ? (schema as any).shape : (schema as any)._def?.shape?.();\n const hasItems = Boolean(shape?.items);\n if (hasItems) {\n return schema.extend({ nextCursor: z.string().optional() });\n }\n return z.object({\n items: z.array(schema as ZodTypeAny),\n nextCursor: z.string().optional(),\n });\n }\n return z.object({\n items: z.array(schema as ZodTypeAny),\n nextCursor: z.string().optional(),\n });\n}\n\n/**\n * Runtime helper that mirrors the typed merge used by the builder.\n * @param a Previously merged params schema inherited from parent segments.\n * @param b Newly introduced params schema.\n * @returns Intersection of schemas when both exist, otherwise whichever is defined.\n */\nfunction mergeSchemas<A extends ZodTypeAny, B extends ZodTypeAny>(a: A, b: B): ZodTypeAny;\nfunction mergeSchemas<A extends ZodTypeAny>(a: A, b: undefined): A;\nfunction mergeSchemas<B extends ZodTypeAny>(a: undefined, b: B): B;\nfunction mergeSchemas(a: ZodTypeAny | undefined, b: ZodTypeAny | undefined): ZodTypeAny | undefined;\nfunction mergeSchemas(a: ZodTypeAny | undefined, b: ZodTypeAny | undefined) {\n if (a && b) return z.intersection(a as any, b as any);\n return (a ?? b) as ZodTypeAny | undefined;\n}\n\ntype FeedQuerySchema<C extends MethodCfg> = z.ZodObject<any>;\n\ntype FeedOutputSchema<C extends MethodCfg> = C['outputSchema'] extends ZodArrayAny\n ? z.ZodObject<{\n items: C['outputSchema'];\n nextCursor: z.ZodOptional<z.ZodString>;\n }>\n : C['outputSchema'] extends ZodTypeAny\n ? z.ZodObject<{\n items: z.ZodArray<C['outputSchema']>;\n nextCursor: z.ZodOptional<z.ZodString>;\n }>\n : typeof defaultFeedOutputSchema;\n\ntype BaseMethodCfg<C extends MethodCfg> = Merge<\n Omit<MethodCfg, 'querySchema' | 'outputSchema' | 'feed'>,\n Omit<C, 'querySchema' | 'outputSchema' | 'feed'>\n>;\n\ntype FeedField<C extends MethodCfg> = C['feed'] extends true ? { feed: true } : { feed?: boolean };\n\ntype AddPaginationToQuery<Q extends AnyZodObject | undefined> = Q extends z.ZodObject<\n infer Shape\n>\n ? z.ZodObject<Shape & { pagination: PaginationField }>\n : z.ZodObject<{ pagination: PaginationField }>;\n\ntype FeedQueryField<C extends MethodCfg> = {\n querySchema: AddPaginationToQuery<\n C['querySchema'] extends AnyZodObject ? C['querySchema'] : undefined\n >;\n};\n\ntype NonFeedQueryField<C extends MethodCfg> = C['querySchema'] extends ZodTypeAny\n ? { querySchema: C['querySchema'] }\n : { querySchema?: undefined };\n\ntype FeedOutputField<C extends MethodCfg> = { outputSchema: FeedOutputSchema<C> };\n\ntype NonFeedOutputField<C extends MethodCfg> = C['outputSchema'] extends ZodTypeAny\n ? { outputSchema: C['outputSchema'] }\n : { outputSchema?: undefined };\n\ntype ParamsField<C extends MethodCfg, PS> = C['paramsSchema'] extends ZodTypeAny\n ? { paramsSchema: C['paramsSchema'] }\n : { paramsSchema: PS };\n\ntype EffectiveFeedFields<C extends MethodCfg, PS> = C['feed'] extends true\n ? FeedField<C> & FeedQueryField<C> & FeedOutputField<C> & ParamsField<C, PS>\n : FeedField<C> & NonFeedQueryField<C> & NonFeedOutputField<C> & ParamsField<C, PS>;\n\ntype EffectiveCfg<C extends MethodCfg, PS> = Prettify<\n Merge<MethodCfg, BaseMethodCfg<C> & EffectiveFeedFields<C, PS>>\n>;\n\ntype BuiltLeaf<\n M extends HttpMethod,\n Base extends string,\n I extends NodeCfg,\n C extends MethodCfg,\n PS,\n> = Leaf<M, Base, Merge<I, EffectiveCfg<C, PS>>>;\n\n/** Builder surface used by `resource(...)` to accumulate leaves. */\nexport interface Branch<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodTypeAny | undefined,\n> {\n // --- structure ---\n /**\n * Enter or define a static child segment.\n * Optionally accepts extra config and/or a builder to populate nested routes.\n * @param name Child segment literal (no leading slash).\n * @param cfg Optional node configuration to merge for descendants.\n * @param builder Callback to produce leaves for the child branch.\n */\n sub<Name extends string, J extends NodeCfg>(\n name: Name,\n cfg?: J,\n ): Branch<`${Base}/${Name}`, Acc, Merge<I, NonNullable<J>>, PS>;\n\n sub<Name extends string, J extends NodeCfg | undefined, R extends readonly AnyLeaf[]>(\n name: Name,\n cfg: J,\n builder: (r: Branch<`${Base}/${Name}`, readonly [], Merge<I, NonNullable<J>>, PS>) => R,\n ): Branch<Base, Append<Acc, R[number]>, Merge<I, NonNullable<J>>, PS>;\n\n sub<Name extends string, R extends readonly AnyLeaf[]>(\n name: Name,\n builder: (r: Branch<`${Base}/${Name}`, readonly [], I, PS>) => R,\n ): Branch<Base, MergeArray<Acc, R>, I, PS>;\n\n // --- parameterized segment (single signature) ---\n /**\n * Introduce a `:param` segment and merge its schema into downstream leaves.\n * @param name Parameter key (without leading colon).\n * @param paramsSchema Zod schema for the parameter value.\n * @param builder Callback that produces leaves beneath the parameterized segment.\n */\n routeParameter<Name extends string, P extends ZodTypeAny, R extends readonly AnyLeaf[]>(\n name: Name,\n paramsSchema: P,\n builder: (\n r: Branch<\n `${Base}/:${Name}`,\n readonly [],\n I,\n MergedParamsResult<PS, Name, P>\n >,\n ) => R,\n ): Branch<Base, MergeArray<Acc, R>, I, MergedParamsResult<PS, Name, P>>;\n\n // --- flags inheritance ---\n /**\n * Merge additional node configuration that subsequent leaves will inherit.\n * @param cfg Partial node configuration.\n */\n with<J extends NodeCfg>(cfg: J): Branch<Base, Acc, Merge<I, J>, PS>;\n\n // --- methods (return Branch to keep chaining) ---\n /**\n * Register a GET leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n get<C extends MethodCfg>(\n cfg: C,\n ): Branch<\n Base,\n Append<Acc, Prettify<BuiltLeaf<'get', Base, I, C, PS>>>,\n I,\n PS\n >;\n\n /**\n * Register a POST leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n post<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'post', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n /**\n * Register a PUT leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n put<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'put', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n /**\n * Register a PATCH leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n patch<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'patch', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n /**\n * Register a DELETE leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n delete<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'delete', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n // --- finalize this subtree ---\n /**\n * Finish the branch and return the collected leaves.\n * @returns Readonly tuple of accumulated leaves.\n */\n done(): Readonly<Acc>;\n}\n\n/**\n * Start building a resource at the given base path.\n * @param base Root path for the resource (e.g. `/v1`).\n * @param inherited Optional node configuration applied to all descendants.\n * @returns Root `Branch` instance used to compose the route tree.\n */\nexport function resource<Base extends string, I extends NodeCfg = {}>(\n base: Base,\n inherited?: I,\n): Branch<Base, readonly [], I, undefined> {\n const rootBase = base;\n const rootInherited: NodeCfg = { ...(inherited as NodeCfg) };\n\n function makeBranch<Base2 extends string, I2 extends NodeCfg, PS2 extends ZodTypeAny | undefined>(\n base2: Base2,\n inherited2: I2,\n mergedParamsSchema?: PS2,\n ) {\n const stack: AnyLeaf[] = [];\n let currentBase: string = base2;\n let inheritedCfg: NodeCfg = { ...(inherited2 as NodeCfg) };\n let currentParamsSchema: PS2 = mergedParamsSchema as PS2;\n\n function add<M extends HttpMethod, C extends MethodCfg>(method: M, cfg: C) {\n // If the method didn’t provide a paramsSchema, inject the active merged one.\n const effectiveParamsSchema = (cfg.paramsSchema ?? currentParamsSchema) as PS2 | undefined;\n const effectiveQuerySchema =\n cfg.feed === true ? augmentFeedQuerySchema(cfg.querySchema) : cfg.querySchema;\n const effectiveOutputSchema =\n cfg.feed === true ? augmentFeedOutputSchema(cfg.outputSchema) : cfg.outputSchema;\n\n const fullCfg = (\n effectiveParamsSchema\n ? {\n ...inheritedCfg,\n ...cfg,\n paramsSchema: effectiveParamsSchema,\n ...(effectiveQuerySchema ? { querySchema: effectiveQuerySchema } : {}),\n ...(effectiveOutputSchema ? { outputSchema: effectiveOutputSchema } : {}),\n }\n : {\n ...inheritedCfg,\n ...cfg,\n ...(effectiveQuerySchema ? { querySchema: effectiveQuerySchema } : {}),\n ...(effectiveOutputSchema ? { outputSchema: effectiveOutputSchema } : {}),\n }\n ) as any;\n\n const leaf = {\n method,\n path: currentBase as Base2,\n cfg: fullCfg,\n } as const;\n\n stack.push(leaf as unknown as AnyLeaf);\n\n // Return same runtime obj, but with Acc including this new leaf\n return api as unknown as Branch<Base2, Append<readonly [], typeof leaf>, I2, PS2>;\n }\n\n const api: any = {\n // compose a plain subpath (optional cfg) with optional builder\n sub<Name extends string, J extends NodeCfg | undefined = undefined>(\n name: Name,\n cfgOrBuilder?: J | ((r: any) => readonly AnyLeaf[]),\n maybeBuilder?: (r: any) => readonly AnyLeaf[],\n ) {\n let cfg: NodeCfg | undefined;\n let builder: ((r: any) => readonly AnyLeaf[]) | undefined;\n\n if (typeof cfgOrBuilder === 'function') {\n builder = cfgOrBuilder as any;\n } else {\n cfg = cfgOrBuilder as NodeCfg | undefined;\n builder = maybeBuilder;\n }\n\n const childBase = `${currentBase}/${name}` as const;\n const childInherited = { ...inheritedCfg, ...(cfg ?? {}) } as Merge<I2, NonNullable<J>>;\n\n if (builder) {\n // params schema PS2 flows through unchanged on plain sub\n const child = makeBranch(childBase, childInherited, currentParamsSchema);\n const leaves = builder(child) as readonly AnyLeaf[];\n for (const l of leaves) stack.push(l);\n return api as Branch<\n Base2,\n Append<readonly [], (typeof leaves)[number]>,\n typeof childInherited,\n PS2\n >;\n } else {\n currentBase = childBase;\n inheritedCfg = childInherited;\n return api as Branch<`${Base2}/${Name}`, readonly [], typeof childInherited, PS2>;\n }\n },\n\n // the single param function: name + schema + builder\n routeParameter<Name extends string, P extends ZodTypeAny, R extends readonly AnyLeaf[]>(\n name: Name,\n paramsSchema: P,\n builder: (\n r: Branch<\n `${Base2}/:${Name}`,\n readonly [],\n I2,\n MergedParamsResult<PS2, Name, P>\n >,\n ) => R,\n ) {\n const childBase = `${currentBase}/:${name}` as const;\n // Wrap the value schema under the param name before merging with inherited params schema\n const paramObj: ParamZod<Name, P> = z.object({ [name]: paramsSchema } as Record<Name, P>);\n const childParams = (currentParamsSchema\n ? mergeSchemas(currentParamsSchema, paramObj)\n : paramObj) as MergedParamsResult<PS2, Name, P>;\n const child = makeBranch(childBase, inheritedCfg as I2, childParams);\n const leaves = builder(child) as readonly AnyLeaf[];\n for (const l of leaves) stack.push(l);\n return api as Branch<\n Base2,\n Append<readonly [], (typeof leaves)[number]>,\n I2,\n MergedParamsResult<PS2, Name, P>\n >;\n },\n\n with<J extends NodeCfg>(cfg: J) {\n inheritedCfg = { ...inheritedCfg, ...cfg };\n return api as Branch<Base2, readonly [], Merge<I2, J>, PS2>;\n },\n\n // methods (inject current params schema if missing)\n get<C extends MethodCfg>(cfg: C) {\n return add('get', cfg);\n },\n post<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('post', { ...cfg, feed: false });\n },\n put<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('put', { ...cfg, feed: false });\n },\n patch<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('patch', { ...cfg, feed: false });\n },\n delete<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('delete', { ...cfg, feed: false });\n },\n\n done() {\n return stack;\n },\n };\n\n return api as Branch<Base2, readonly [], I2, PS2>;\n }\n\n // Root branch starts with no params schema (PS = undefined)\n return makeBranch(rootBase, rootInherited, undefined);\n}\n\n/**\n * Merge two readonly tuples (preserves literal tuple information).\n * @param arr1 First tuple.\n * @param arr2 Second tuple.\n * @returns New tuple containing values from both inputs.\n */\nexport const mergeArrays = <T extends readonly any[], S extends readonly any[]>(\n arr1: T,\n arr2: S,\n) => {\n return [...arr1, ...arr2] as [...T, ...S];\n};\n","import { z, ZodTypeAny } from 'zod';\n\n/** Supported HTTP verbs for the routes DSL. */\nexport type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';\n\n/** Declarative description of a multipart upload field. */\nexport type FileField = {\n /** Form field name used for uploads. */\n name: string;\n /** Maximum number of files accepted for this field. */\n maxCount: number;\n};\n\n/** Configuration that applies to an entire branch of the route tree. */\nexport type NodeCfg = {\n /** @deprecated. Does nothing. */\n authenticated?: boolean;\n};\n\n/** Per-method configuration merged with inherited node config. */\nexport type MethodCfg = {\n /** Zod schema describing the request body. */\n bodySchema?: ZodTypeAny;\n /** Zod schema describing the query string. */\n querySchema?: ZodTypeAny;\n /** Zod schema describing path params (overrides inferred params). */\n paramsSchema?: ZodTypeAny;\n /** Zod schema describing the response payload. */\n outputSchema?: ZodTypeAny;\n /** Multipart upload definitions for the route. */\n bodyFiles?: FileField[];\n /** Marks the route as an infinite feed (enables cursor helpers). */\n feed?: boolean;\n\n /** Optional human-readable description for docs/debugging. */\n description?: string;\n /**\n * Short one-line summary for docs list views.\n * Shown in navigation / tables instead of the full description.\n */\n summary?: string;\n /**\n * Group name used for navigation sections in docs UIs.\n * e.g. \"Users\", \"Billing\", \"Auth\".\n */\n docsGroup?: string;\n /**\n * Tags that can be used to filter / facet in interactive docs.\n * e.g. [\"users\", \"admin\", \"internal\"].\n */\n tags?: string[];\n /**\n * Mark the route as deprecated in docs.\n * Renderers can badge this and/or hide by default.\n */\n deprecated?: boolean;\n /**\n * Optional stability information for the route.\n * Renderers can surface this prominently.\n */\n stability?: 'experimental' | 'beta' | 'stable' | 'deprecated';\n /**\n * Hide this route from public docs while keeping it usable in code.\n */\n docsHidden?: boolean;\n /**\n * Arbitrary extra metadata for docs renderers.\n * Can be used for auth requirements, rate limits, feature flags, etc.\n */\n docsMeta?: Record<string, unknown>;\n};\n\n/** Immutable representation of a single HTTP route in the tree. */\nexport type Leaf<M extends HttpMethod, P extends string, C extends MethodCfg> = {\n /** Lowercase HTTP method (get/post/...). */\n readonly method: M;\n /** Concrete path for the route (e.g. `/v1/users/:userId`). */\n readonly path: P;\n /** Readonly snapshot of route configuration. */\n readonly cfg: Readonly<C>;\n};\n\n/** Convenience union covering all generated leaves. */\nexport type AnyLeaf = Leaf<HttpMethod, string, MethodCfg>;\n\n/** Merge two object types while keeping nice IntelliSense output. */\nexport type Merge<A, B> = Prettify<Omit<A, keyof B> & B>;\n\n/** Append a new element to a readonly tuple type. */\nexport type Append<T extends readonly unknown[], X> = [...T, X];\n\n/** Concatenate two readonly tuple types. */\nexport type MergeArray<A extends readonly unknown[], B extends readonly unknown[]> = [\n ...A,\n ...B,\n];\n\n// helpers (optional)\ntype SegmentParams<S extends string> = S extends `:${infer P}` ? P : never;\ntype Split<S extends string> = S extends ''\n ? []\n : S extends `${infer A}/${infer B}`\n ? [A, ...Split<B>]\n : [S];\ntype ExtractParamNames<Path extends string> = SegmentParams<Split<Path>[number]>;\n\n/** Derive a params object type from a literal route string. */\nexport type ExtractParamsFromPath<Path extends string> =\n ExtractParamNames<Path> extends never ? never : Record<ExtractParamNames<Path>, string | number>;\n\n/**\n * Interpolate `:params` in a path using the given values.\n * @param path Literal route string containing `:param` segments.\n * @param params Object of parameter values to interpolate.\n * @returns Path string with parameters substituted.\n */\nexport function compilePath<Path extends string>(path: Path, params: ExtractParamsFromPath<Path>) {\n if (!params) return path;\n return path.replace(/:([A-Za-z0-9_]+)/g, (_, k) => {\n const v = (params as any)[k];\n if (v === undefined || v === null) throw new Error(`Missing param :${k}`);\n return String(v);\n });\n}\n\n/**\n * Build a deterministic cache key for the given leaf.\n * The key matches the shape consumed by React Query helpers.\n * @param args.leaf Leaf describing the endpoint.\n * @param args.params Optional params used to build the path.\n * @param args.query Optional query payload.\n * @returns Tuple suitable for React Query cache keys.\n */\ntype SplitPath<P extends string> = P extends ''\n ? []\n : P extends `${infer A}/${infer B}`\n ? [A, ...SplitPath<B>]\n : [P];\nexport function buildCacheKey<L extends AnyLeaf>(args: {\n leaf: L;\n params?: ExtractParamsFromPath<L['path']>;\n query?: InferQuery<L>;\n}) {\n let p = args.leaf.path;\n if (args.params) {\n p = compilePath<L['path']>(p, args.params);\n }\n return [args.leaf.method, ...(p.split('/').filter(Boolean) as SplitPath<typeof p>), args.query ?? {}] as const;\n}\n\n/** Infer params either from the explicit params schema or from the path literal. */\nexport type InferParams<L extends AnyLeaf> = L['cfg']['paramsSchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['paramsSchema']>\n : ExtractParamsFromPath<L['path']>;\n\n/** Infer query shape from a Zod schema when present. */\nexport type InferQuery<L extends AnyLeaf> = L['cfg']['querySchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['querySchema']>\n : never;\n\n/** Infer request body shape from a Zod schema when present. */\nexport type InferBody<L extends AnyLeaf> = L['cfg']['bodySchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['bodySchema']>\n : never;\n\n/** Infer handler output shape from a Zod schema. Defaults to unknown. */\nexport type InferOutput<L extends AnyLeaf> = L['cfg']['outputSchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['outputSchema']>\n : unknown;\n\n/** Render a type as if it were a simple object literal. */\nexport type Prettify<T> = { [K in keyof T]: T[K] } & {};\n","// TODO:\n// * use this as a transform that infers the types from Zod, to only pass the types around instead of the full schemas -> make converters that go both ways (data to schema, schema to data)\n// * consider moving to core package\n// * update server and client side to use this type instead of raw zod schemas \nimport { AnyLeaf, HttpMethod, Prettify } from './routesV3.core';\n\n/** Build the key type for a leaf — distributive so method/path stay paired. */\nexport type KeyOf<L extends AnyLeaf> = L extends AnyLeaf\n ? `${Uppercase<L['method']>} ${L['path']}`\n : never;\n\n// From a tuple of leaves, get the union of keys (pairwise, no cartesian blow-up)\ntype KeysOf<Leaves extends readonly AnyLeaf[]> = KeyOf<Leaves[number]>;\n\n// Parse method & path out of a key\ntype MethodFromKey<K extends string> = K extends `${infer M} ${string}` ? Lowercase<M> : never;\ntype PathFromKey<K extends string> = K extends `${string} ${infer P}` ? P : never;\n\n// Given Leaves and a Key, pick the exact leaf that matches method+path\ntype LeafForKey<Leaves extends readonly AnyLeaf[], K extends string> = Extract<\n Leaves[number],\n { method: MethodFromKey<K> & HttpMethod; path: PathFromKey<K> }\n>;\n\n/**\n * Freeze a leaf tuple into a registry with typed key lookups.\n * @param leaves Readonly tuple of leaves produced by the builder DSL.\n * @returns Registry containing the leaves array and a `byKey` lookup map.\n */\nexport function finalize<const L extends readonly AnyLeaf[]>(leaves: L) {\n type Keys = KeysOf<L>;\n type MapByKey = { [K in Keys]: Prettify<LeafForKey<L, K>> };\n\n const byKey = Object.fromEntries(\n leaves.map((l) => [`${l.method.toUpperCase()} ${l.path}`, l] as const),\n ) as unknown as MapByKey;\n\n const log = (logger: { system: (...args: unknown[]) => void }) => {\n logger.system('Finalized routes:');\n (Object.keys(byKey) as Keys[]).forEach((k) => {\n const leaf = byKey[k];\n logger.system(`- ${k}`);\n });\n };\n\n return { all: leaves, byKey, log };\n}\n\n/** Nominal type alias for a finalized registry. */\nexport type Registry<R extends ReturnType<typeof finalize>> = R;\n\ntype FilterRoute<\n T extends readonly AnyLeaf[],\n F extends string,\n Acc extends readonly AnyLeaf[] = [],\n> = T extends readonly [infer First extends AnyLeaf, ...infer Rest extends AnyLeaf[]]\n ? First extends { path: `${string}${F}${string}` }\n ? FilterRoute<Rest, F, [...Acc, First]>\n : FilterRoute<Rest, F, Acc>\n : Acc;\n\ntype UpperCase<S extends string> = S extends `${infer First}${infer Rest}`\n ? `${Uppercase<First>}${UpperCase<Rest>}`\n : S;\n\ntype Routes<T extends readonly AnyLeaf[], F extends string> = FilterRoute<T, F>;\ntype ByKey<\n T extends readonly AnyLeaf[],\n Acc extends Record<string, AnyLeaf> = {},\n> = T extends readonly [infer First extends AnyLeaf, ...infer Rest extends AnyLeaf[]]\n ? ByKey<Rest, Acc & { [K in `${UpperCase<First['method']>} ${First['path']}`]: First }>\n : Acc;\n\n/**\n * Convenience helper for extracting a subset of routes by path fragment.\n * @param T Tuple of leaves produced by the DSL.\n * @param F String fragment to match against the route path.\n */\nexport type SubsetRoutes<T extends readonly AnyLeaf[], F extends string> = {\n byKey: ByKey<Routes<T, F>>;\n all: Routes<T, F>;\n};\n","// routesV3.crud.ts\n// -----------------------------------------------------------------------------\n// Add a first-class .crud() helper to the routesV3 DSL, without touching the\n// core builder. This file:\n// 1) Declares types + module augmentation to extend Branch<...> with .crud\n// 2) Provides a runtime decorator `withCrud(...)` that installs the method\n// 3) Exports a convenience `resourceWithCrud(...)` wrapper (optional)\n// -----------------------------------------------------------------------------\n\nimport { z, ZodType } from 'zod';\nimport {\n resource as baseResource,\n type Branch as _Branch, // import type so we can augment it\n} from '../core/routesV3.builder';\nimport { type AnyLeaf, type Leaf, type NodeCfg } from '../core/routesV3.core';\n\n// -----------------------------------------------------------------------------\n// Small utilities (runtime + types)\n// -----------------------------------------------------------------------------\n/** Default cursor pagination used by list (GET collection). */\nexport const CrudDefaultPagination = z.object({\n limit: z.coerce.number().min(1).max(100).default(20),\n cursor: z.string().optional(),\n});\nconst CrudPaginationField = CrudDefaultPagination.optional().default(CrudDefaultPagination.parse({}));\ntype CrudPaginationField = typeof CrudPaginationField;\ntype AnyCrudZodObject = z.ZodObject<any>;\ntype AddCrudPagination<Q extends AnyCrudZodObject | undefined> = Q extends z.ZodObject<infer Shape>\n ? z.ZodObject<Shape & { pagination: CrudPaginationField }>\n : z.ZodObject<{ pagination: CrudPaginationField }>;\n\n/**\n * Merge two Zod schemas at runtime; matches the typing pattern used in builder.\n * @param a Existing params schema inherited from parent branches.\n * @param b Schema introduced at the current branch.\n * @returns Intersection of schemas when both exist, otherwise whichever is defined.\n */\nexport function mergeSchemas<A extends ZodType | undefined, B extends ZodType | undefined>(\n a: A,\n b: B,\n): A extends ZodType ? (B extends ZodType ? ReturnType<typeof z.intersection<A, B>> : A) : B {\n if (a && b) return z.intersection(a as any, b as any) as any;\n return (a ?? b) as any;\n}\n\n/** Build { [Name]: S } Zod object at the type-level. */\nexport type ParamSchema<Name extends string, S extends ZodType> = z.ZodObject<{\n [K in Name]: S;\n}>;\n\n/** Inject active params schema into a leaf cfg (to match your Leaf typing). */\ntype WithParams<I, P> = P extends ZodType ? Omit<I, 'paramsSchema'> & { paramsSchema: P } : I;\n\n/** Resolve boolean flag: default D unless explicitly false. */\ntype Flag<E, D extends boolean> = E extends false ? false : D;\n\n// -----------------------------------------------------------------------------\n// CRUD config (few knobs, with DX comments)\n// -----------------------------------------------------------------------------\n\n/** Toggle individual CRUD methods; defaults enable all (create/update require body). */\nexport type CrudEnable = {\n /** GET /collection (feed). Defaults to true. */ list?: boolean;\n /** POST /collection. Defaults to true if `create` provided. */ create?: boolean;\n /** GET /collection/:id. Defaults to true. */ read?: boolean;\n /** PATCH /collection/:id. Defaults to true if `update` provided. */ update?: boolean;\n /** DELETE /collection/:id. Defaults to true. */ remove?: boolean;\n};\n\n/** Collection GET config. */\nexport type CrudListCfg = {\n /** Query schema (defaults to cursor pagination). */\n querySchema?: ZodType;\n /** Output schema (defaults to { items: Item[], nextCursor? }). */\n outputSchema?: ZodType;\n /** Optional description string. */\n description?: string;\n};\n\n/** Collection POST config. */\nexport type CrudCreateCfg = {\n /** Body schema for creating an item. */\n bodySchema: ZodType;\n /** Output schema (defaults to itemOutputSchema). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/** Item GET config. */\nexport type CrudReadCfg = {\n /** Output schema (defaults to itemOutputSchema). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/** Item PATCH config. */\nexport type CrudUpdateCfg = {\n /** Body schema for partial updates. */\n bodySchema: ZodType;\n /** Output schema (defaults to itemOutputSchema). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/** Item DELETE config. */\nexport type CrudRemoveCfg = {\n /** Output schema (defaults to { ok: true }). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/**\n * CRUD config for `.crud(\"resource\", cfg, extras?)`.\n *\n * It synthesizes `:[resourceName]Id` as the param key and uses `paramSchema` for the value.\n * Prefer passing a **value schema** (e.g. `z.string().uuid()`).\n * As a convenience, a ZodObject of shape `{ [resourceName]Id: schema }` is accepted at runtime too.\n */\nexport type CrudCfg<Name extends string = string> = {\n /**\n * Zod schema for the ID *value* (e.g. `z.string().uuid()`).\n * The parameter key is always `:${name}Id`.\n * (If you pass `z.object({ [name]Id: ... })`, it's accepted at runtime.)\n */\n paramSchema: ZodType;\n\n /**\n * The single-item output shape used by read/create/update by default.\n * List defaults to `{ items: z.array(itemOutputSchema), nextCursor? }`.\n */\n itemOutputSchema: ZodType;\n\n /** Per-method toggles (all enabled by default; create/update require bodies). */\n enable?: CrudEnable;\n\n /** GET /collection configuration. */ list?: CrudListCfg;\n /** POST /collection configuration (enables create). */ create?: CrudCreateCfg;\n /** GET /collection/:id configuration. */ read?: CrudReadCfg;\n /** PATCH /collection/:id configuration (enables update). */ update?: CrudUpdateCfg;\n /** DELETE /collection/:id configuration. */ remove?: CrudRemoveCfg;\n};\n\n// -----------------------------------------------------------------------------\n// Type plumbing to expose generated leaves (so finalize().byKey sees them)\n// -----------------------------------------------------------------------------\n\ntype CrudLeavesTuple<\n Base extends string,\n I extends NodeCfg,\n PS extends ZodType | undefined,\n Name extends string,\n C extends CrudCfg<Name>,\n> = `${Name}Id` extends infer IdName extends string\n ? ParamSchema<IdName, C['paramSchema']> extends infer IdParamZ extends ZodType\n ? [\n // GET /collection\n ...(Flag<\n C['enable'] extends CrudEnable ? C['enable']['list'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'get',\n `${Base}/${Name}`,\n WithParams<\n Omit<I, never> & {\n feed: true;\n querySchema: C['list'] extends CrudListCfg\n ? AddCrudPagination<\n C['list']['querySchema'] extends AnyCrudZodObject\n ? C['list']['querySchema']\n : undefined\n >\n : AddCrudPagination<undefined>;\n outputSchema: C['list'] extends CrudListCfg\n ? C['list']['outputSchema'] extends ZodType\n ? C['list']['outputSchema']\n : z.ZodObject<{\n items: z.ZodArray<C['itemOutputSchema']>;\n nextCursor: z.ZodOptional<z.ZodString>;\n }>\n : z.ZodObject<{\n items: z.ZodArray<C['itemOutputSchema']>;\n nextCursor: z.ZodOptional<z.ZodString>;\n }>;\n description?: string;\n },\n PS\n >\n >,\n ]\n : []),\n\n // POST /collection\n ...((C['create'] extends CrudCreateCfg ? true : false) extends true\n ? Flag<\n C['enable'] extends CrudEnable ? C['enable']['create'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'post',\n `${Base}/${Name}`,\n WithParams<\n Omit<I, never> & {\n bodySchema: C['create'] extends CrudCreateCfg\n ? C['create']['bodySchema']\n : never;\n outputSchema: C['create'] extends CrudCreateCfg\n ? C['create']['outputSchema'] extends ZodType\n ? C['create']['outputSchema']\n : C['itemOutputSchema']\n : never;\n description?: string;\n },\n PS\n >\n >,\n ]\n : []\n : []),\n\n // GET /collection/:id\n ...(Flag<\n C['enable'] extends CrudEnable ? C['enable']['read'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'get',\n `${Base}/${Name}/:${IdName}`,\n WithParams<\n Omit<I, never> & {\n outputSchema: C['read'] extends CrudReadCfg\n ? C['read']['outputSchema'] extends ZodType\n ? C['read']['outputSchema']\n : C['itemOutputSchema']\n : C['itemOutputSchema'];\n description?: string;\n },\n ReturnType<typeof mergeSchemas<PS, IdParamZ>>\n >\n >,\n ]\n : []),\n\n // PATCH /collection/:id\n ...((C['update'] extends CrudUpdateCfg ? true : false) extends true\n ? Flag<\n C['enable'] extends CrudEnable ? C['enable']['update'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'patch',\n `${Base}/${Name}/:${IdName}`,\n WithParams<\n Omit<I, never> & {\n bodySchema: C['update'] extends CrudUpdateCfg\n ? C['update']['bodySchema']\n : never;\n outputSchema: C['update'] extends CrudUpdateCfg\n ? C['update']['outputSchema'] extends ZodType\n ? C['update']['outputSchema']\n : C['itemOutputSchema']\n : never;\n description?: string;\n },\n ReturnType<typeof mergeSchemas<PS, IdParamZ>>\n >\n >,\n ]\n : []\n : []),\n\n // DELETE /collection/:id\n ...(Flag<\n C['enable'] extends CrudEnable ? C['enable']['remove'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'delete',\n `${Base}/${Name}/:${IdName}`,\n WithParams<\n Omit<I, never> & {\n outputSchema: C['remove'] extends CrudRemoveCfg\n ? C['remove']['outputSchema'] extends ZodType\n ? C['remove']['outputSchema']\n : z.ZodObject<{ ok: z.ZodLiteral<true> }>\n : z.ZodObject<{ ok: z.ZodLiteral<true> }>;\n description?: string;\n },\n ReturnType<typeof mergeSchemas<PS, IdParamZ>>\n >\n >,\n ]\n : []),\n ]\n : never\n : never;\n\n/** Merge generated leaves + extras into the branch accumulator. */\ntype CrudResultAcc<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodType | undefined,\n Name extends string,\n C extends CrudCfg<Name>,\n Extras extends readonly AnyLeaf[],\n> = [...Acc, ...CrudLeavesTuple<Base, I, PS, Name, C>, ...Extras];\n\n// -----------------------------------------------------------------------------\n// Module augmentation: add the typed `.crud(...)` to Branch<...>\n// -----------------------------------------------------------------------------\n\ndeclare module './../core/routesV3.builder' {\n interface Branch<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodType | undefined,\n > {\n /**\n * Generate opinionated CRUD endpoints for a collection at `/.../<name>`\n * with an item at `/.../<name>/:<name>Id`.\n *\n * Creates (subject to `enable` + presence of create/update bodies):\n * - GET /<name> (feed list)\n * - POST /<name> (create)\n * - GET /<name>/:<name>Id (read item)\n * - PATCH /<name>/:<name>Id (update item)\n * - DELETE /<name>/:<name>Id (remove item)\n *\n * The `extras` callback receives live builders at both collection and item\n * levels so you can add custom subroutes; their leaves are included in the\n * returned Branch type.\n */\n crud<\n Name extends string,\n C extends CrudCfg<Name>,\n Extras extends readonly AnyLeaf[] = readonly [],\n >(\n name: Name,\n cfg: C,\n extras?: (ctx: {\n /** Builder at `/.../<name>` (collection scope). */\n collection: _Branch<`${Base}/${Name}`, readonly [], I, PS>;\n /** Builder at `/.../<name>/:<name>Id` (item scope). */\n item: _Branch<\n `${Base}/${Name}/:${`${Name}Id`}`,\n readonly [],\n I,\n ReturnType<typeof mergeSchemas<PS, ParamSchema<`${Name}Id`, C['paramSchema']>>>\n >;\n }) => Extras,\n ): _Branch<Base, CrudResultAcc<Base, Acc, I, PS, Name, C, Extras>, I, PS>;\n }\n}\n\n// -----------------------------------------------------------------------------\n// Runtime: install .crud on any Branch via decorator\n// -----------------------------------------------------------------------------\n\n/**\n * Decorate a Branch instance so `.crud(...)` is available at runtime.\n * Tip: wrap the root: `withCrud(resource('/v1'))`.\n * @param branch Branch returned by `resource(...)`.\n * @returns Same branch with `.crud(...)` installed.\n */\nexport function withCrud<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodType | undefined,\n>(branch: _Branch<Base, Acc, I, PS>): _Branch<Base, Acc, I, PS> {\n const b = branch as any;\n if (typeof b.crud === 'function') return branch;\n\n b.crud = function <\n Name extends string,\n C extends CrudCfg<Name>,\n Extras extends readonly AnyLeaf[] = readonly [],\n >(this: any, name: Name, cfg: C, extras?: (ctx: { collection: any; item: any }) => Extras) {\n // Build inside a sub-branch at `/.../<name>` and harvest its leaves.\n return this.sub(name, (collection: any) => {\n const idKey = `${name}Id`;\n\n // Accept a value schema (preferred); but if a z.object({[name]Id: ...}) is provided, use it.\n const s = cfg.paramSchema;\n const isObj =\n s &&\n typeof (s as any)._def === 'object' &&\n (s as any)._def.typeName === 'ZodObject' &&\n typeof (s as any).shape === 'function';\n\n const paramValueSchema =\n isObj && (s as any).shape()[idKey] ? ((s as any).shape()[idKey] as ZodType) : (s as ZodType);\n\n const itemOut = cfg.itemOutputSchema;\n const listOut =\n cfg.list?.outputSchema ??\n z.object({\n items: z.array(itemOut),\n nextCursor: z.string().optional(),\n });\n\n const want = {\n list: cfg.enable?.list !== false,\n create: cfg.enable?.create !== false && !!cfg.create?.bodySchema,\n read: cfg.enable?.read !== false,\n update: cfg.enable?.update !== false && !!cfg.update?.bodySchema,\n remove: cfg.enable?.remove !== false,\n } as const;\n\n // Collection routes\n if (want.list) {\n collection.get({\n feed: true,\n querySchema: cfg.list?.querySchema ?? CrudDefaultPagination,\n outputSchema: listOut,\n description: cfg.list?.description ?? 'List',\n });\n }\n\n if (want.create) {\n collection.post({\n bodySchema: cfg.create!.bodySchema,\n outputSchema: cfg.create?.outputSchema ?? itemOut,\n description: cfg.create?.description ?? 'Create',\n });\n }\n\n // Item routes via :<name>Id\n collection.routeParameter(idKey as any, paramValueSchema as any, (item: any) => {\n if (want.read) {\n item.get({\n outputSchema: cfg.read?.outputSchema ?? itemOut,\n description: cfg.read?.description ?? 'Read',\n });\n }\n if (want.update) {\n item.patch({\n bodySchema: cfg.update!.bodySchema,\n outputSchema: cfg.update?.outputSchema ?? itemOut,\n description: cfg.update?.description ?? 'Update',\n });\n }\n if (want.remove) {\n item.delete({\n outputSchema: cfg.remove?.outputSchema ?? z.object({ ok: z.literal(true) }),\n description: cfg.remove?.description ?? 'Delete',\n });\n }\n\n // Give extras fully-capable builders (decorate so extras can call .crud again)\n if (extras) extras({ collection: withCrud(collection), item: withCrud(item) });\n\n return item.done();\n });\n\n return collection.done();\n });\n };\n\n return branch;\n}\n\n// -----------------------------------------------------------------------------\n// Optional convenience: re-export a resource() that already has .crud installed\n// -----------------------------------------------------------------------------\n\n/**\n * Drop-in replacement for `resource(...)` that returns a Branch with `.crud()` installed.\n * You can either use this or call `withCrud(resource(...))`.\n * @param base Root path for the resource (e.g. `/v1`).\n * @param inherited Node configuration merged into every leaf.\n * @returns Branch builder that already includes the CRUD helper.\n */\nexport function resourceWithCrud<Base extends string, I extends NodeCfg = {}>(\n base: Base,\n inherited: I,\n) {\n return withCrud(baseResource(base, inherited));\n}\n\n// Re-export the original in case you want both styles from this module\nexport { baseResource as resource };\n","// socket.index.ts (shared client/server)\n\nimport { z } from 'zod';\n\nexport type SocketSchema<Output =unknown> = z.ZodType & {\n __out: Output;\n};\n\nexport type SocketSchemaOutput<Schema extends z.ZodTypeAny> = Schema extends {\n __out: infer Out;\n} ? Out : z.output<Schema>;\n\nexport type SocketEvent<Out = unknown> = {\n message: z.ZodTypeAny;\n /** phantom field, only for typing; not meant to be used at runtime */\n __out: Out;\n};\n\nexport type EventMap = Record<string, SocketEvent<any>>;\n\n/**\n * System event names – shared so server and client\n * don't drift on naming.\n */\nexport type SysEventName = 'sys:connect' | 'sys:disconnect' | 'sys:reconnect' | 'sys:connect_error' | 'sys:ping' | 'sys:pong' | 'sys:room_join' | 'sys:room_leave';\nexport function defineSocketEvents<const C extends SocketConnectionConfig, const Schemas extends Record<string, {\n message: z.ZodTypeAny;\n}>>(config: C, events: Schemas): {\n config: {\n [K in keyof C]: SocketSchema<z.output<C[K]>>;\n };\n events: {\n [K in keyof Schemas]: SocketEvent<z.output<Schemas[K]['message']>>;\n };\n};\n\nexport function defineSocketEvents(config: any, events: any) {\n return { config, events };\n}\n\n\n\nexport type Payload<T extends EventMap, K extends keyof T> = T[K] extends SocketEvent<infer Out> ? Out : never;\nexport type SocketConnectionConfig = {\n joinMetaMessage: z.ZodTypeAny;\n leaveMetaMessage: z.ZodTypeAny;\n pingPayload: z.ZodTypeAny;\n pongPayload: z.ZodTypeAny;\n};\n\nexport type SocketConnectionConfigOutput = {\n joinMetaMessage: SocketSchema<any>;\n leaveMetaMessage: SocketSchema<any>;\n pingPayload: SocketSchema<any>;\n pongPayload: SocketSchema<any>;\n}","import { AnyLeaf, MethodCfg } from \"../core/routesV3.core\";\n\ntype SerializableMethodCfg = Pick<\n MethodCfg,\n | 'description'\n | 'summary'\n | 'docsGroup'\n | 'tags'\n | 'deprecated'\n | 'stability'\n | 'feed'\n | 'docsMeta'\n> & {\n hasBody: boolean;\n hasQuery: boolean;\n hasParams: boolean;\n hasOutput: boolean;\n};\n\nexport type SerializableLeaf = {\n method: string;\n path: string;\n cfg: SerializableMethodCfg;\n};\n\nexport function serializeLeaf(leaf: AnyLeaf): SerializableLeaf {\n const cfg = leaf.cfg;\n\n const tags = Array.isArray(cfg.tags) ? cfg.tags.slice() : [];\n\n return {\n method: leaf.method, // 'get' | 'post' | ...\n path: leaf.path,\n cfg: {\n description: cfg.description,\n summary: cfg.summary,\n docsGroup: cfg.docsGroup,\n tags,\n deprecated: cfg.deprecated,\n stability: cfg.stability,\n feed: !!cfg.feed,\n docsMeta: cfg.docsMeta,\n hasBody: !!cfg.bodySchema || !!cfg.bodyFiles?.length,\n hasQuery: !!cfg.querySchema,\n hasParams: !!cfg.paramsSchema,\n hasOutput: !!cfg.outputSchema,\n },\n };\n}\n","import { AnyLeaf } from \"../core/routesV3.core\";\nimport { SerializableLeaf, serializeLeaf } from \"./serializer\";\n\nexport function renderLeafDocsHTML(leaves: AnyLeaf[]): string {\n const docsLeaves: SerializableLeaf[] = leaves.map(serializeLeaf);\n\n // Safe embedding into <script> / <script type=\"application/json\">\n const leafJson = JSON.stringify(docsLeaves).replace(/</g, '\\\\u003c');\n\n return `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\" />\n <title>API Routes</title>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <style>\n :root {\n --bg: #020617;\n --bg-elevated: #020617;\n --border-subtle: rgba(148, 163, 184, 0.35);\n --border-strong: rgba(148, 163, 184, 0.65);\n --text: #e5e7eb;\n --text-muted: #9ca3af;\n --accent: #38bdf8;\n --accent-soft: rgba(56, 189, 248, 0.12);\n --radius-lg: 12px;\n --radius-sm: 6px;\n --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.7);\n }\n\n * {\n box-sizing: border-box;\n }\n\n body {\n margin: 0;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"SF Pro Text\",\n \"Segoe UI\", sans-serif;\n background: radial-gradient(circle at top left, #0f172a, #020617 50%)\n radial-gradient(circle at bottom right, #020617, #020617 50%);\n color: var(--text);\n -webkit-font-smoothing: antialiased;\n }\n\n .page {\n min-height: 100vh;\n padding: 24px;\n background:\n radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 60%),\n radial-gradient(circle at bottom right, rgba(168, 85, 247, 0.18), transparent 60%);\n }\n\n @media (max-width: 768px) {\n .page {\n padding: 16px;\n }\n }\n\n .shell {\n max-width: 1200px;\n margin: 0 auto;\n background: rgba(15, 23, 42, 0.96);\n border-radius: 18px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n box-shadow: var(--shadow-soft);\n padding: 20px 22px 24px;\n backdrop-filter: blur(28px);\n }\n\n @media (max-width: 768px) {\n .shell {\n padding: 14px 14px 18px;\n }\n }\n\n .header {\n display: flex;\n justify-content: space-between;\n gap: 16px;\n align-items: center;\n margin-bottom: 16px;\n }\n\n .header-main {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .title-row {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n\n .title {\n font-size: 18px;\n font-weight: 600;\n letter-spacing: 0.02em;\n display: inline-flex;\n align-items: center;\n gap: 10px;\n }\n\n .title-pill {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.16em;\n padding: 2px 8px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n color: var(--text-muted);\n background: radial-gradient(circle at top, rgba(148, 163, 184, 0.22), transparent);\n }\n\n .subtitle {\n font-size: 12px;\n color: var(--text-muted);\n }\n\n .stats {\n font-size: 12px;\n color: var(--text-muted);\n white-space: nowrap;\n }\n\n .layout {\n display: grid;\n grid-template-columns: 260px minmax(0, 1fr);\n gap: 18px;\n margin-top: 12px;\n }\n\n @media (max-width: 960px) {\n .layout {\n grid-template-columns: minmax(0, 1fr);\n }\n }\n\n .sidebar {\n padding: 12px;\n border-radius: 14px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n background: radial-gradient(circle at top, rgba(30, 64, 175, 0.45), transparent 55%),\n radial-gradient(circle at bottom, rgba(30, 64, 175, 0.2), transparent 55%),\n rgba(15, 23, 42, 0.92);\n }\n\n .sidebar h2 {\n font-size: 12px;\n text-transform: uppercase;\n letter-spacing: 0.16em;\n color: var(--text-muted);\n margin: 0 0 8px;\n }\n\n .filter-section {\n margin-bottom: 10px;\n }\n\n .filter-section-title {\n font-size: 11px;\n text-transform: uppercase;\n letter-spacing: 0.08em;\n color: var(--text-muted);\n margin-bottom: 6px;\n }\n\n .search-input {\n width: 100%;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n padding: 7px 10px;\n font-size: 12px;\n color: var(--text);\n background: rgba(15, 23, 42, 0.9);\n outline: none;\n }\n\n .search-input::placeholder {\n color: rgba(148, 163, 184, 0.8);\n }\n\n .search-input:focus {\n border-color: var(--accent);\n box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);\n }\n\n .filter-pill-group {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n }\n\n .filter-pill {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n font-size: 11px;\n padding: 3px 6px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.4);\n background: rgba(15, 23, 42, 0.9);\n cursor: pointer;\n user-select: none;\n color: var(--text-muted);\n }\n\n .filter-pill input {\n accent-color: var(--accent);\n }\n\n .group-select {\n width: 100%;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n padding: 6px 10px;\n font-size: 11px;\n background: rgba(15, 23, 42, 0.95);\n color: var(--text);\n outline: none;\n }\n\n .group-select:focus {\n border-color: var(--accent);\n box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);\n }\n\n .main {\n padding: 10px 10px 2px;\n border-radius: 14px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.16), transparent 55%),\n radial-gradient(circle at bottom right, rgba(168, 85, 247, 0.16), transparent 55%),\n rgba(15, 23, 42, 0.95);\n }\n\n .route-list {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n\n .route-card {\n border-radius: 12px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.98));\n padding: 9px 10px;\n box-shadow: 0 10px 30px rgba(15, 23, 42, 0.5);\n }\n\n .route-header {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n align-items: center;\n margin-bottom: 4px;\n }\n\n .method-pill {\n font-size: 10px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.12em;\n padding: 3px 8px;\n border-radius: 999px;\n border: 1px solid transparent;\n background: rgba(30, 64, 175, 0.18);\n color: #e5e7eb;\n }\n\n .method-get {\n background: rgba(22, 163, 74, 0.22);\n border-color: rgba(22, 163, 74, 0.7);\n }\n .method-post {\n background: rgba(59, 130, 246, 0.22);\n border-color: rgba(59, 130, 246, 0.7);\n }\n .method-put {\n background: rgba(234, 179, 8, 0.22);\n border-color: rgba(234, 179, 8, 0.7);\n }\n .method-patch {\n background: rgba(56, 189, 248, 0.22);\n border-color: rgba(56, 189, 248, 0.7);\n }\n .method-delete {\n background: rgba(220, 38, 38, 0.22);\n border-color: rgba(220, 38, 38, 0.7);\n }\n\n .route-path {\n font-family: \"JetBrains Mono\", ui-monospace, SFMono-Regular, Menlo, Monaco,\n Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n font-size: 12px;\n padding: 3px 7px;\n border-radius: 999px;\n background: rgba(15, 23, 42, 0.9);\n border: 1px solid rgba(148, 163, 184, 0.7);\n color: #e5e7eb;\n }\n\n .group-label {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.16em;\n padding: 2px 8px;\n border-radius: 999px;\n background: rgba(15, 23, 42, 0.9);\n border: 1px solid rgba(148, 163, 184, 0.5);\n color: var(--text-muted);\n margin-left: auto;\n }\n\n .route-tags {\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n margin-bottom: 4px;\n margin-top: 2px;\n }\n\n .tag {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.14em;\n padding: 2px 7px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.4);\n color: var(--text-muted);\n background: rgba(15, 23, 42, 0.9);\n }\n\n .tag-not-impl {\n border-color: rgba(248, 113, 113, 0.9);\n background: rgba(239, 68, 68, 0.14);\n color: #fecaca;\n }\n\n .badge {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.14em;\n padding: 2px 7px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n background: rgba(15, 23, 42, 0.9);\n color: var(--text-muted);\n }\n\n .badge-feed {\n border-color: rgba(56, 189, 248, 0.8);\n background: rgba(56, 189, 248, 0.16);\n color: #e0f2fe;\n }\n\n .badge-deprecated {\n border-color: rgba(220, 38, 38, 0.9);\n background: rgba(220, 38, 38, 0.18);\n color: #fee2e2;\n }\n\n .badge-experimental,\n .badge-beta {\n border-color: rgba(168, 85, 247, 0.9);\n background: rgba(168, 85, 247, 0.18);\n color: #f3e8ff;\n }\n\n .route-summary {\n font-size: 12px;\n margin: 2px 0;\n color: var(--text);\n }\n\n .route-description {\n font-size: 11px;\n margin: 0;\n color: var(--text-muted);\n }\n\n .schema-row {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-top: 6px;\n }\n\n .schema-pill {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.14em;\n padding: 2px 7px;\n border-radius: 999px;\n border: 1px dashed rgba(148, 163, 184, 0.7);\n color: rgba(148, 163, 184, 0.9);\n background: rgba(15, 23, 42, 0.95);\n }\n\n .empty-state {\n font-size: 12px;\n color: var(--text-muted);\n padding: 16px 12px;\n border-radius: 10px;\n border: 1px dashed rgba(148, 163, 184, 0.5);\n background: rgba(15, 23, 42, 0.9);\n }\n </style>\n</head>\n<body>\n <div class=\"page\">\n <div class=\"shell\">\n <header class=\"header\">\n <div class=\"header-main\">\n <div class=\"title-row\">\n <div class=\"title\">\n API routes\n <span class=\"title-pill\">Interactive docs</span>\n </div>\n </div>\n <div class=\"subtitle\">\n Introspected from your runtime route leaves.\n </div>\n </div>\n <div id=\"stats\" class=\"stats\"></div>\n </header>\n\n <div class=\"layout\">\n <aside class=\"sidebar\">\n <h2>Filters</h2>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Search</div>\n <input\n id=\"searchInput\"\n class=\"search-input\"\n type=\"search\"\n placeholder=\"Filter by path, group, tag…\"\n />\n </div>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Method</div>\n <div id=\"methodFilters\" class=\"filter-pill-group\"></div>\n </div>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Group</div>\n <select id=\"groupSelect\" class=\"group-select\"></select>\n </div>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Tags</div>\n <div id=\"tagFilters\" class=\"filter-pill-group\"></div>\n </div>\n </aside>\n\n <main class=\"main\">\n <div id=\"routeList\" class=\"route-list\"></div>\n </main>\n </div>\n </div>\n </div>\n\n <script id=\"leaf-data\" type=\"application/json\">${leafJson}</script>\n <script>\n (function () {\n function escapeHtml(str) {\n return String(str)\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#39;');\n }\n\n var raw = document.getElementById('leaf-data').textContent;\n var leaves = raw ? JSON.parse(raw) : [];\n\n var searchInput = document.getElementById('searchInput');\n var methodFiltersEl = document.getElementById('methodFilters');\n var groupSelect = document.getElementById('groupSelect');\n var tagFiltersEl = document.getElementById('tagFilters');\n var routeList = document.getElementById('routeList');\n var statsEl = document.getElementById('stats');\n\n if (!Array.isArray(leaves)) leaves = [];\n\n var allMethods = Array.from(\n new Set(\n leaves.map(function (r) {\n return String(r.method || '').toUpperCase();\n })\n )\n ).sort();\n\n var allGroups = Array.from(\n new Set(\n leaves.map(function (r) {\n return r.cfg && r.cfg.docsGroup ? String(r.cfg.docsGroup) : 'Ungrouped';\n })\n )\n ).sort();\n\n var allTags = Array.from(\n new Set(\n leaves.reduce(function (acc, r) {\n var tags = (r.cfg && r.cfg.tags) || [];\n if (Array.isArray(tags)) {\n for (var i = 0; i < tags.length; i++) acc.push(String(tags[i]));\n }\n return acc;\n }, [])\n )\n ).sort();\n\n function buildFilterUI() {\n // Methods\n methodFiltersEl.innerHTML = '';\n allMethods.forEach(function (m) {\n var label = document.createElement('label');\n label.className = 'filter-pill';\n var cb = document.createElement('input');\n cb.type = 'checkbox';\n cb.value = m;\n cb.checked = true;\n cb.addEventListener('change', applyFilters);\n label.appendChild(cb);\n label.appendChild(document.createTextNode(' ' + m));\n methodFiltersEl.appendChild(label);\n });\n\n // Groups\n groupSelect.innerHTML = '';\n var allOption = document.createElement('option');\n allOption.value = '__all';\n allOption.textContent = 'All groups';\n groupSelect.appendChild(allOption);\n allGroups.forEach(function (g) {\n var opt = document.createElement('option');\n opt.value = g;\n opt.textContent = g;\n groupSelect.appendChild(opt);\n });\n groupSelect.addEventListener('change', applyFilters);\n\n // Tags\n tagFiltersEl.innerHTML = '';\n allTags.forEach(function (t) {\n var label = document.createElement('label');\n label.className = 'filter-pill';\n var cb = document.createElement('input');\n cb.type = 'checkbox';\n cb.value = t;\n cb.addEventListener('change', applyFilters);\n label.appendChild(cb);\n label.appendChild(document.createTextNode(' ' + t));\n tagFiltersEl.appendChild(label);\n });\n }\n\n function routeToHTML(route) {\n var method = String(route.method || '').toUpperCase();\n var methodClass = 'method-' + String(route.method || '').toLowerCase();\n\n var cfg = route.cfg || {};\n var group = cfg.docsGroup || 'Ungrouped';\n\n var summary = cfg.summary || cfg.description || '';\n var description =\n cfg.description && cfg.summary !== cfg.description\n ? cfg.description\n : '';\n\n var tags = Array.isArray(cfg.tags) ? cfg.tags : [];\n var tagHtml = tags\n .map(function (tag) {\n var t = String(tag);\n var extraClass = t === 'not-implemented' ? ' tag-not-impl' : '';\n return '<span class=\"tag' + extraClass + '\">' + escapeHtml(t) + '</span>';\n })\n .join('');\n\n var metaBadges = '';\n if (cfg.feed) {\n metaBadges += '<span class=\"badge badge-feed\">Feed</span>';\n }\n if (cfg.deprecated || cfg.stability === 'deprecated') {\n metaBadges += '<span class=\"badge badge-deprecated\">Deprecated</span>';\n } else if (cfg.stability && cfg.stability !== 'stable') {\n metaBadges +=\n '<span class=\"badge badge-' +\n escapeHtml(cfg.stability) +\n '\">' +\n escapeHtml(String(cfg.stability)) +\n '</span>';\n }\n\n var schemaPills = [];\n if (cfg.hasBody) schemaPills.push('<span class=\"schema-pill\">Body</span>');\n if (cfg.hasQuery) schemaPills.push('<span class=\"schema-pill\">Query</span>');\n if (cfg.hasParams) schemaPills.push('<span class=\"schema-pill\">Params</span>');\n if (cfg.hasOutput) schemaPills.push('<span class=\"schema-pill\">Response</span>');\n\n var schemaHtml =\n schemaPills.length > 0\n ? '<div class=\"schema-row\">' + schemaPills.join('') + '</div>'\n : '';\n\n return (\n '<article class=\"route-card\">' +\n '<header class=\"route-header\">' +\n '<span class=\"method-pill ' +\n methodClass +\n '\">' +\n method +\n '</span>' +\n '<code class=\"route-path\">' +\n escapeHtml(route.path || '') +\n '</code>' +\n (group\n ? '<span class=\"group-label\">' + escapeHtml(String(group)) + '</span>'\n : '') +\n '</header>' +\n '<div class=\"route-tags\">' +\n tagHtml +\n metaBadges +\n '</div>' +\n (summary\n ? '<p class=\"route-summary\">' + escapeHtml(String(summary)) + '</p>'\n : '') +\n (description\n ? '<p class=\"route-description\">' +\n escapeHtml(String(description)) +\n '</p>'\n : '') +\n schemaHtml +\n '</article>'\n );\n }\n\n function applyFilters() {\n var query = searchInput.value.toLowerCase().trim();\n\n var activeMethods = Array.prototype.slice\n .call(methodFiltersEl.querySelectorAll('input[type=\"checkbox\"]:checked'))\n .map(function (cb) {\n return cb.value;\n });\n\n var groupValue = groupSelect.value;\n var activeTags = Array.prototype.slice\n .call(tagFiltersEl.querySelectorAll('input[type=\"checkbox\"]:checked'))\n .map(function (cb) {\n return cb.value;\n });\n\n var filtered = leaves.filter(function (route) {\n var cfg = route.cfg || {};\n\n if (\n activeMethods.length &&\n activeMethods.indexOf(String(route.method || '').toUpperCase()) === -1\n ) {\n return false;\n }\n\n if (groupValue && groupValue !== '__all') {\n var g = cfg.docsGroup || 'Ungrouped';\n if (g !== groupValue) return false;\n }\n\n if (activeTags.length) {\n var tags = Array.isArray(cfg.tags) ? cfg.tags : [];\n var hasAny = activeTags.some(function (t) {\n return tags.indexOf(t) !== -1;\n });\n if (!hasAny) return false;\n }\n\n if (query) {\n var haystack =\n String(route.path || '') +\n ' ' +\n String(cfg.summary || '') +\n ' ' +\n String(cfg.description || '') +\n ' ' +\n (Array.isArray(cfg.tags) ? cfg.tags.join(' ') : '') +\n ' ' +\n String(cfg.docsGroup || '');\n if (haystack.toLowerCase().indexOf(query) === -1) return false;\n }\n\n return true;\n });\n\n if (statsEl) {\n statsEl.textContent = filtered.length + ' routes';\n }\n\n if (!filtered.length) {\n routeList.innerHTML =\n '<div class=\"empty-state\">No routes match the current filters.</div>';\n } else {\n routeList.innerHTML = filtered.map(routeToHTML).join('');\n }\n }\n\n buildFilterUI();\n searchInput.addEventListener('input', applyFilters);\n\n // Initial render\n statsEl.textContent = leaves.length + ' routes';\n applyFilters();\n })();\n </script>\n</body>\n</html>`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkB;AAalB,IAAM,yBAAyB,aAAE,OAAO;AAAA,EACtC,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,OAAO,aAAE,OAAO,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,QAAQ,EAAE;AACrD,CAAC;AAED,IAAM,kBAAkB,uBAAuB,SAAS,EAAE,QAAQ,uBAAuB,MAAM,CAAC,CAAC,CAAC;AAYlG,IAAM,0BAA0B,aAAE,OAAO;AAAA,EACvC,OAAO,aAAE,MAAM,aAAE,QAAQ,CAAC;AAAA,EAC1B,YAAY,aAAE,OAAO,EAAE,SAAS;AAClC,CAAC;AAED,SAAS,uBAAyD,QAAW;AAC3E,MAAI,UAAU,EAAE,kBAAkB,aAAE,YAAY;AAC9C,YAAQ,KAAK,+DAA+D;AAC5E,WAAO,aAAE,OAAO;AAAA,MACd,YAAY;AAAA,IACd,CAAC;AAAA,EACH;AAEA,QAAM,OAAQ,UAA2B,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+P3D;","names":["mergeSchemas","import_zod","mergeSchemas"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/core/routesV3.builder.ts","../src/core/routesV3.core.ts","../src/core/routesV3.finalize.ts","../src/crud/routesV3.crud.ts","../src/sockets/socket.index.ts","../src/docs/serializer.ts","../src/docs/docs.ts"],"sourcesContent":["export * from './core/routesV3.builder';\nexport * from './core/routesV3.core';\nexport * from './core/routesV3.finalize';\nexport * from './crud/routesV3.crud';\nexport * from './sockets/socket.index';\nexport * from './docs/docs';","import { z } from 'zod';\nimport {\n AnyLeaf,\n Append,\n HttpMethod,\n Leaf,\n Merge,\n MergeArray,\n MethodCfg,\n NodeCfg,\n Prettify,\n} from './routesV3.core';\n\nconst defaultFeedQuerySchema = z.object({\n cursor: z.string().optional(),\n limit: z.coerce.number().min(1).max(100).default(20),\n});\n\nconst paginationField = defaultFeedQuerySchema.optional().default(defaultFeedQuerySchema.parse({}));\ntype PaginationField = typeof paginationField;\n\ntype ZodTypeAny = z.ZodTypeAny;\ntype ParamZod<Name extends string, S extends ZodTypeAny> = z.ZodObject<{ [K in Name]: S }>;\ntype ZodArrayAny = z.ZodArray<ZodTypeAny>;\ntype ZodObjectAny = z.ZodObject<any>;\ntype AnyZodObject = z.ZodObject<any>;\ntype MergedParamsResult<PS, Name extends string, P extends ZodTypeAny> = PS extends ZodTypeAny\n ? z.ZodIntersection<PS, ParamZod<Name, P>>\n : ParamZod<Name, P>;\n\nconst defaultFeedOutputSchema = z.object({\n items: z.array(z.unknown()),\n nextCursor: z.string().optional(),\n});\n\nfunction augmentFeedQuerySchema<Q extends ZodTypeAny | undefined>(schema: Q) {\n if (schema && !(schema instanceof z.ZodObject)) {\n console.warn('Feed queries must be a ZodObject; default pagination applied.');\n return z.object({\n pagination: paginationField,\n });\n }\n\n const base = (schema as ZodObjectAny) ?? z.object({});\n return base.extend({\n pagination: paginationField,\n });\n}\n\nfunction augmentFeedOutputSchema<O extends ZodTypeAny | undefined>(schema: O) {\n if (!schema) return defaultFeedOutputSchema;\n if (schema instanceof z.ZodArray) {\n return z.object({\n items: schema,\n nextCursor: z.string().optional(),\n });\n }\n if (schema instanceof z.ZodObject) {\n const shape = (schema as any).shape ? (schema as any).shape : (schema as any)._def?.shape?.();\n const hasItems = Boolean(shape?.items);\n if (hasItems) {\n return schema.extend({ nextCursor: z.string().optional() });\n }\n return z.object({\n items: z.array(schema as ZodTypeAny),\n nextCursor: z.string().optional(),\n });\n }\n return z.object({\n items: z.array(schema as ZodTypeAny),\n nextCursor: z.string().optional(),\n });\n}\n\n/**\n * Runtime helper that mirrors the typed merge used by the builder.\n * @param a Previously merged params schema inherited from parent segments.\n * @param b Newly introduced params schema.\n * @returns Intersection of schemas when both exist, otherwise whichever is defined.\n */\nfunction mergeSchemas<A extends ZodTypeAny, B extends ZodTypeAny>(a: A, b: B): ZodTypeAny;\nfunction mergeSchemas<A extends ZodTypeAny>(a: A, b: undefined): A;\nfunction mergeSchemas<B extends ZodTypeAny>(a: undefined, b: B): B;\nfunction mergeSchemas(a: ZodTypeAny | undefined, b: ZodTypeAny | undefined): ZodTypeAny | undefined;\nfunction mergeSchemas(a: ZodTypeAny | undefined, b: ZodTypeAny | undefined) {\n if (a && b) return z.intersection(a as any, b as any);\n return (a ?? b) as ZodTypeAny | undefined;\n}\n\ntype FeedQuerySchema<C extends MethodCfg> = z.ZodObject<any>;\n\ntype FeedOutputSchema<C extends MethodCfg> = C['outputSchema'] extends ZodArrayAny\n ? z.ZodObject<{\n items: C['outputSchema'];\n nextCursor: z.ZodOptional<z.ZodString>;\n }>\n : C['outputSchema'] extends ZodTypeAny\n ? z.ZodObject<{\n items: z.ZodArray<C['outputSchema']>;\n nextCursor: z.ZodOptional<z.ZodString>;\n }>\n : typeof defaultFeedOutputSchema;\n\ntype BaseMethodCfg<C extends MethodCfg> = Merge<\n Omit<MethodCfg, 'querySchema' | 'outputSchema' | 'feed'>,\n Omit<C, 'querySchema' | 'outputSchema' | 'feed'>\n>;\n\ntype FeedField<C extends MethodCfg> = C['feed'] extends true ? { feed: true } : { feed?: boolean };\n\ntype AddPaginationToQuery<Q extends AnyZodObject | undefined> = Q extends z.ZodObject<\n infer Shape\n>\n ? z.ZodObject<Shape & { pagination: PaginationField }>\n : z.ZodObject<{ pagination: PaginationField }>;\n\ntype FeedQueryField<C extends MethodCfg> = {\n querySchema: AddPaginationToQuery<\n C['querySchema'] extends AnyZodObject ? C['querySchema'] : undefined\n >;\n};\n\ntype NonFeedQueryField<C extends MethodCfg> = C['querySchema'] extends ZodTypeAny\n ? { querySchema: C['querySchema'] }\n : { querySchema?: undefined };\n\ntype FeedOutputField<C extends MethodCfg> = { outputSchema: FeedOutputSchema<C> };\n\ntype NonFeedOutputField<C extends MethodCfg> = C['outputSchema'] extends ZodTypeAny\n ? { outputSchema: C['outputSchema'] }\n : { outputSchema?: undefined };\n\ntype ParamsField<C extends MethodCfg, PS> = C['paramsSchema'] extends ZodTypeAny\n ? { paramsSchema: C['paramsSchema'] }\n : { paramsSchema: PS };\n\ntype EffectiveFeedFields<C extends MethodCfg, PS> = C['feed'] extends true\n ? FeedField<C> & FeedQueryField<C> & FeedOutputField<C> & ParamsField<C, PS>\n : FeedField<C> & NonFeedQueryField<C> & NonFeedOutputField<C> & ParamsField<C, PS>;\n\ntype EffectiveCfg<C extends MethodCfg, PS> = Prettify<\n Merge<MethodCfg, BaseMethodCfg<C> & EffectiveFeedFields<C, PS>>\n>;\n\ntype BuiltLeaf<\n M extends HttpMethod,\n Base extends string,\n I extends NodeCfg,\n C extends MethodCfg,\n PS,\n> = Leaf<M, Base, Merge<I, EffectiveCfg<C, PS>>>;\n\n/** Builder surface used by `resource(...)` to accumulate leaves. */\nexport interface Branch<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodTypeAny | undefined,\n> {\n // --- structure ---\n /**\n * Enter or define a static child segment.\n * Optionally accepts extra config and/or a builder to populate nested routes.\n * @param name Child segment literal (no leading slash).\n * @param cfg Optional node configuration to merge for descendants.\n * @param builder Callback to produce leaves for the child branch.\n */\n sub<Name extends string, J extends NodeCfg>(\n name: Name,\n cfg?: J,\n ): Branch<`${Base}/${Name}`, Acc, Merge<I, NonNullable<J>>, PS>;\n\n sub<Name extends string, J extends NodeCfg | undefined, R extends readonly AnyLeaf[]>(\n name: Name,\n cfg: J,\n builder: (r: Branch<`${Base}/${Name}`, readonly [], Merge<I, NonNullable<J>>, PS>) => R,\n ): Branch<Base, Append<Acc, R[number]>, Merge<I, NonNullable<J>>, PS>;\n\n sub<Name extends string, R extends readonly AnyLeaf[]>(\n name: Name,\n builder: (r: Branch<`${Base}/${Name}`, readonly [], I, PS>) => R,\n ): Branch<Base, MergeArray<Acc, R>, I, PS>;\n\n // --- parameterized segment (single signature) ---\n /**\n * Introduce a `:param` segment and merge its schema into downstream leaves.\n * @param name Parameter key (without leading colon).\n * @param paramsSchema Zod schema for the parameter value.\n * @param builder Callback that produces leaves beneath the parameterized segment.\n */\n routeParameter<Name extends string, P extends ZodTypeAny, R extends readonly AnyLeaf[]>(\n name: Name,\n paramsSchema: P,\n builder: (\n r: Branch<\n `${Base}/:${Name}`,\n readonly [],\n I,\n MergedParamsResult<PS, Name, P>\n >,\n ) => R,\n ): Branch<Base, MergeArray<Acc, R>, I, MergedParamsResult<PS, Name, P>>;\n\n // --- flags inheritance ---\n /**\n * Merge additional node configuration that subsequent leaves will inherit.\n * @param cfg Partial node configuration.\n */\n with<J extends NodeCfg>(cfg: J): Branch<Base, Acc, Merge<I, J>, PS>;\n\n // --- methods (return Branch to keep chaining) ---\n /**\n * Register a GET leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n get<C extends MethodCfg>(\n cfg: C,\n ): Branch<\n Base,\n Append<Acc, Prettify<BuiltLeaf<'get', Base, I, C, PS>>>,\n I,\n PS\n >;\n\n /**\n * Register a POST leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n post<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'post', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n /**\n * Register a PUT leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n put<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'put', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n /**\n * Register a PATCH leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n patch<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'patch', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n /**\n * Register a DELETE leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n delete<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'delete', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n // --- finalize this subtree ---\n /**\n * Finish the branch and return the collected leaves.\n * @returns Readonly tuple of accumulated leaves.\n */\n done(): Readonly<Acc>;\n}\n\n/**\n * Start building a resource at the given base path.\n * @param base Root path for the resource (e.g. `/v1`).\n * @param inherited Optional node configuration applied to all descendants.\n * @returns Root `Branch` instance used to compose the route tree.\n */\nexport function resource<Base extends string, I extends NodeCfg = {}>(\n base: Base,\n inherited?: I,\n): Branch<Base, readonly [], I, undefined> {\n const rootBase = base;\n const rootInherited: NodeCfg = { ...(inherited as NodeCfg) };\n\n function makeBranch<Base2 extends string, I2 extends NodeCfg, PS2 extends ZodTypeAny | undefined>(\n base2: Base2,\n inherited2: I2,\n mergedParamsSchema?: PS2,\n ) {\n const stack: AnyLeaf[] = [];\n let currentBase: string = base2;\n let inheritedCfg: NodeCfg = { ...(inherited2 as NodeCfg) };\n let currentParamsSchema: PS2 = mergedParamsSchema as PS2;\n\n function add<M extends HttpMethod, C extends MethodCfg>(method: M, cfg: C) {\n // If the method didn’t provide a paramsSchema, inject the active merged one.\n const effectiveParamsSchema = (cfg.paramsSchema ?? currentParamsSchema) as PS2 | undefined;\n const effectiveQuerySchema =\n cfg.feed === true ? augmentFeedQuerySchema(cfg.querySchema) : cfg.querySchema;\n const effectiveOutputSchema =\n cfg.feed === true ? augmentFeedOutputSchema(cfg.outputSchema) : cfg.outputSchema;\n\n const fullCfg = (\n effectiveParamsSchema\n ? {\n ...inheritedCfg,\n ...cfg,\n paramsSchema: effectiveParamsSchema,\n ...(effectiveQuerySchema ? { querySchema: effectiveQuerySchema } : {}),\n ...(effectiveOutputSchema ? { outputSchema: effectiveOutputSchema } : {}),\n }\n : {\n ...inheritedCfg,\n ...cfg,\n ...(effectiveQuerySchema ? { querySchema: effectiveQuerySchema } : {}),\n ...(effectiveOutputSchema ? { outputSchema: effectiveOutputSchema } : {}),\n }\n ) as any;\n\n const leaf = {\n method,\n path: currentBase as Base2,\n cfg: fullCfg,\n } as const;\n\n stack.push(leaf as unknown as AnyLeaf);\n\n // Return same runtime obj, but with Acc including this new leaf\n return api as unknown as Branch<Base2, Append<readonly [], typeof leaf>, I2, PS2>;\n }\n\n const api: any = {\n // compose a plain subpath (optional cfg) with optional builder\n sub<Name extends string, J extends NodeCfg | undefined = undefined>(\n name: Name,\n cfgOrBuilder?: J | ((r: any) => readonly AnyLeaf[]),\n maybeBuilder?: (r: any) => readonly AnyLeaf[],\n ) {\n let cfg: NodeCfg | undefined;\n let builder: ((r: any) => readonly AnyLeaf[]) | undefined;\n\n if (typeof cfgOrBuilder === 'function') {\n builder = cfgOrBuilder as any;\n } else {\n cfg = cfgOrBuilder as NodeCfg | undefined;\n builder = maybeBuilder;\n }\n\n const childBase = `${currentBase}/${name}` as const;\n const childInherited = { ...inheritedCfg, ...(cfg ?? {}) } as Merge<I2, NonNullable<J>>;\n\n if (builder) {\n // params schema PS2 flows through unchanged on plain sub\n const child = makeBranch(childBase, childInherited, currentParamsSchema);\n const leaves = builder(child) as readonly AnyLeaf[];\n for (const l of leaves) stack.push(l);\n return api as Branch<\n Base2,\n Append<readonly [], (typeof leaves)[number]>,\n typeof childInherited,\n PS2\n >;\n } else {\n currentBase = childBase;\n inheritedCfg = childInherited;\n return api as Branch<`${Base2}/${Name}`, readonly [], typeof childInherited, PS2>;\n }\n },\n\n // the single param function: name + schema + builder\n routeParameter<Name extends string, P extends ZodTypeAny, R extends readonly AnyLeaf[]>(\n name: Name,\n paramsSchema: P,\n builder: (\n r: Branch<\n `${Base2}/:${Name}`,\n readonly [],\n I2,\n MergedParamsResult<PS2, Name, P>\n >,\n ) => R,\n ) {\n const childBase = `${currentBase}/:${name}` as const;\n // Wrap the value schema under the param name before merging with inherited params schema\n const paramObj: ParamZod<Name, P> = z.object({ [name]: paramsSchema } as Record<Name, P>);\n const childParams = (currentParamsSchema\n ? mergeSchemas(currentParamsSchema, paramObj)\n : paramObj) as MergedParamsResult<PS2, Name, P>;\n const child = makeBranch(childBase, inheritedCfg as I2, childParams);\n const leaves = builder(child) as readonly AnyLeaf[];\n for (const l of leaves) stack.push(l);\n return api as Branch<\n Base2,\n Append<readonly [], (typeof leaves)[number]>,\n I2,\n MergedParamsResult<PS2, Name, P>\n >;\n },\n\n with<J extends NodeCfg>(cfg: J) {\n inheritedCfg = { ...inheritedCfg, ...cfg };\n return api as Branch<Base2, readonly [], Merge<I2, J>, PS2>;\n },\n\n // methods (inject current params schema if missing)\n get<C extends MethodCfg>(cfg: C) {\n return add('get', cfg);\n },\n post<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('post', { ...cfg, feed: false });\n },\n put<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('put', { ...cfg, feed: false });\n },\n patch<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('patch', { ...cfg, feed: false });\n },\n delete<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('delete', { ...cfg, feed: false });\n },\n\n done() {\n return stack;\n },\n };\n\n return api as Branch<Base2, readonly [], I2, PS2>;\n }\n\n // Root branch starts with no params schema (PS = undefined)\n return makeBranch(rootBase, rootInherited, undefined);\n}\n\n/**\n * Merge two readonly tuples (preserves literal tuple information).\n * @param arr1 First tuple.\n * @param arr2 Second tuple.\n * @returns New tuple containing values from both inputs.\n */\nexport const mergeArrays = <T extends readonly any[], S extends readonly any[]>(\n arr1: T,\n arr2: S,\n) => {\n return [...arr1, ...arr2] as [...T, ...S];\n};\n","import { z, ZodTypeAny } from 'zod';\n\n/** Supported HTTP verbs for the routes DSL. */\nexport type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';\n\n/** Declarative description of a multipart upload field. */\nexport type FileField = {\n /** Form field name used for uploads. */\n name: string;\n /** Maximum number of files accepted for this field. */\n maxCount: number;\n};\n\n/** Configuration that applies to an entire branch of the route tree. */\nexport type NodeCfg = {\n /** @deprecated. Does nothing. */\n authenticated?: boolean;\n};\n\n/** Per-method configuration merged with inherited node config. */\nexport type MethodCfg = {\n /** Zod schema describing the request body. */\n bodySchema?: ZodTypeAny;\n /** Zod schema describing the query string. */\n querySchema?: ZodTypeAny;\n /** Zod schema describing path params (overrides inferred params). */\n paramsSchema?: ZodTypeAny;\n /** Zod schema describing the response payload. */\n outputSchema?: ZodTypeAny;\n /** Multipart upload definitions for the route. */\n bodyFiles?: FileField[];\n /** Marks the route as an infinite feed (enables cursor helpers). */\n feed?: boolean;\n\n /** Optional human-readable description for docs/debugging. */\n description?: string;\n /**\n * Short one-line summary for docs list views.\n * Shown in navigation / tables instead of the full description.\n */\n summary?: string;\n /**\n * Group name used for navigation sections in docs UIs.\n * e.g. \"Users\", \"Billing\", \"Auth\".\n */\n docsGroup?: string;\n /**\n * Tags that can be used to filter / facet in interactive docs.\n * e.g. [\"users\", \"admin\", \"internal\"].\n */\n tags?: string[];\n /**\n * Mark the route as deprecated in docs.\n * Renderers can badge this and/or hide by default.\n */\n deprecated?: boolean;\n /**\n * Optional stability information for the route.\n * Renderers can surface this prominently.\n */\n stability?: 'experimental' | 'beta' | 'stable' | 'deprecated';\n /**\n * Hide this route from public docs while keeping it usable in code.\n */\n docsHidden?: boolean;\n /**\n * Arbitrary extra metadata for docs renderers.\n * Can be used for auth requirements, rate limits, feature flags, etc.\n */\n docsMeta?: Record<string, unknown>;\n};\n\n/** Immutable representation of a single HTTP route in the tree. */\nexport type Leaf<M extends HttpMethod, P extends string, C extends MethodCfg> = {\n /** Lowercase HTTP method (get/post/...). */\n readonly method: M;\n /** Concrete path for the route (e.g. `/v1/users/:userId`). */\n readonly path: P;\n /** Readonly snapshot of route configuration. */\n readonly cfg: Readonly<C>;\n};\n\n/** Convenience union covering all generated leaves. */\nexport type AnyLeaf = Leaf<HttpMethod, string, MethodCfg>;\n\n/** Merge two object types while keeping nice IntelliSense output. */\nexport type Merge<A, B> = Prettify<Omit<A, keyof B> & B>;\n\n/** Append a new element to a readonly tuple type. */\nexport type Append<T extends readonly unknown[], X> = [...T, X];\n\n/** Concatenate two readonly tuple types. */\nexport type MergeArray<A extends readonly unknown[], B extends readonly unknown[]> = [\n ...A,\n ...B,\n];\n\n// helpers (optional)\ntype SegmentParams<S extends string> = S extends `:${infer P}` ? P : never;\ntype Split<S extends string> = S extends ''\n ? []\n : S extends `${infer A}/${infer B}`\n ? [A, ...Split<B>]\n : [S];\ntype ExtractParamNames<Path extends string> = SegmentParams<Split<Path>[number]>;\n\n/** Derive a params object type from a literal route string. */\nexport type ExtractParamsFromPath<Path extends string> =\n ExtractParamNames<Path> extends never ? never : Record<ExtractParamNames<Path>, string | number>;\n\n/**\n * Interpolate `:params` in a path using the given values.\n * @param path Literal route string containing `:param` segments.\n * @param params Object of parameter values to interpolate.\n * @returns Path string with parameters substituted.\n */\nexport function compilePath<Path extends string>(path: Path, params: ExtractParamsFromPath<Path>) {\n if (!params) return path;\n return path.replace(/:([A-Za-z0-9_]+)/g, (_, k) => {\n const v = (params as any)[k];\n if (v === undefined || v === null) throw new Error(`Missing param :${k}`);\n return String(v);\n });\n}\n\n/**\n * Build a deterministic cache key for the given leaf.\n * The key matches the shape consumed by React Query helpers.\n * @param args.leaf Leaf describing the endpoint.\n * @param args.params Optional params used to build the path.\n * @param args.query Optional query payload.\n * @returns Tuple suitable for React Query cache keys.\n */\ntype SplitPath<P extends string> = P extends ''\n ? []\n : P extends `${infer A}/${infer B}`\n ? [A, ...SplitPath<B>]\n : [P];\nexport function buildCacheKey<L extends AnyLeaf>(args: {\n leaf: L;\n params?: ExtractParamsFromPath<L['path']>;\n query?: InferQuery<L>;\n}) {\n let p = args.leaf.path;\n if (args.params) {\n p = compilePath<L['path']>(p, args.params);\n }\n return [args.leaf.method, ...(p.split('/').filter(Boolean) as SplitPath<typeof p>), args.query ?? {}] as const;\n}\n\n/** Infer params either from the explicit params schema or from the path literal. */\nexport type InferParams<L extends AnyLeaf> = L['cfg']['paramsSchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['paramsSchema']>\n : ExtractParamsFromPath<L['path']>;\n\n/** Infer query shape from a Zod schema when present. */\nexport type InferQuery<L extends AnyLeaf> = L['cfg']['querySchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['querySchema']>\n : never;\n\n/** Infer request body shape from a Zod schema when present. */\nexport type InferBody<L extends AnyLeaf> = L['cfg']['bodySchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['bodySchema']>\n : never;\n\n/** Infer handler output shape from a Zod schema. Defaults to unknown. */\nexport type InferOutput<L extends AnyLeaf> = L['cfg']['outputSchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['outputSchema']>\n : unknown;\n\n/** Render a type as if it were a simple object literal. */\nexport type Prettify<T> = { [K in keyof T]: T[K] } & {};\n","// TODO:\n// * use this as a transform that infers the types from Zod, to only pass the types around instead of the full schemas -> make converters that go both ways (data to schema, schema to data)\n// * consider moving to core package\n// * update server and client side to use this type instead of raw zod schemas \nimport { AnyLeaf, HttpMethod, Prettify } from './routesV3.core';\n\n/** Build the key type for a leaf — distributive so method/path stay paired. */\nexport type KeyOf<L extends AnyLeaf> = L extends AnyLeaf\n ? `${Uppercase<L['method']>} ${L['path']}`\n : never;\n\n// From a tuple of leaves, get the union of keys (pairwise, no cartesian blow-up)\ntype KeysOf<Leaves extends readonly AnyLeaf[]> = KeyOf<Leaves[number]>;\n\n// Parse method & path out of a key\ntype MethodFromKey<K extends string> = K extends `${infer M} ${string}` ? Lowercase<M> : never;\ntype PathFromKey<K extends string> = K extends `${string} ${infer P}` ? P : never;\n\n// Given Leaves and a Key, pick the exact leaf that matches method+path\ntype LeafForKey<Leaves extends readonly AnyLeaf[], K extends string> = Extract<\n Leaves[number],\n { method: MethodFromKey<K> & HttpMethod; path: PathFromKey<K> }\n>;\n\n/**\n * Freeze a leaf tuple into a registry with typed key lookups.\n * @param leaves Readonly tuple of leaves produced by the builder DSL.\n * @returns Registry containing the leaves array and a `byKey` lookup map.\n */\nexport function finalize<const L extends readonly AnyLeaf[]>(leaves: L) {\n type Keys = KeysOf<L>;\n type MapByKey = { [K in Keys]: Prettify<LeafForKey<L, K>> };\n\n const byKey = Object.fromEntries(\n leaves.map((l) => [`${l.method.toUpperCase()} ${l.path}`, l] as const),\n ) as unknown as MapByKey;\n\n const log = (logger: { system: (...args: unknown[]) => void }) => {\n logger.system('Finalized routes:');\n (Object.keys(byKey) as Keys[]).forEach((k) => {\n const leaf = byKey[k];\n logger.system(`- ${k}`);\n });\n };\n\n return { all: leaves, byKey, log };\n}\n\n/** Nominal type alias for a finalized registry. */\nexport type Registry<R extends ReturnType<typeof finalize>> = R;\n\ntype FilterRoute<\n T extends readonly AnyLeaf[],\n F extends string,\n Acc extends readonly AnyLeaf[] = [],\n> = T extends readonly [infer First extends AnyLeaf, ...infer Rest extends AnyLeaf[]]\n ? First extends { path: `${string}${F}${string}` }\n ? FilterRoute<Rest, F, [...Acc, First]>\n : FilterRoute<Rest, F, Acc>\n : Acc;\n\ntype UpperCase<S extends string> = S extends `${infer First}${infer Rest}`\n ? `${Uppercase<First>}${UpperCase<Rest>}`\n : S;\n\ntype Routes<T extends readonly AnyLeaf[], F extends string> = FilterRoute<T, F>;\ntype ByKey<\n T extends readonly AnyLeaf[],\n Acc extends Record<string, AnyLeaf> = {},\n> = T extends readonly [infer First extends AnyLeaf, ...infer Rest extends AnyLeaf[]]\n ? ByKey<Rest, Acc & { [K in `${UpperCase<First['method']>} ${First['path']}`]: First }>\n : Acc;\n\n/**\n * Convenience helper for extracting a subset of routes by path fragment.\n * @param T Tuple of leaves produced by the DSL.\n * @param F String fragment to match against the route path.\n */\nexport type SubsetRoutes<T extends readonly AnyLeaf[], F extends string> = {\n byKey: ByKey<Routes<T, F>>;\n all: Routes<T, F>;\n};\n","// routesV3.crud.ts\n// -----------------------------------------------------------------------------\n// Add a first-class .crud() helper to the routesV3 DSL, without touching the\n// core builder. This file:\n// 1) Declares types + module augmentation to extend Branch<...> with .crud\n// 2) Provides a runtime decorator `withCrud(...)` that installs the method\n// 3) Exports a convenience `resourceWithCrud(...)` wrapper (optional)\n// -----------------------------------------------------------------------------\n\nimport { z, ZodType } from 'zod';\nimport {\n resource as baseResource,\n type Branch as _Branch, // import type so we can augment it\n} from '../core/routesV3.builder';\nimport { type AnyLeaf, type Leaf, type NodeCfg } from '../core/routesV3.core';\n\n// -----------------------------------------------------------------------------\n// Small utilities (runtime + types)\n// -----------------------------------------------------------------------------\n/** Default cursor pagination used by list (GET collection). */\nexport const CrudDefaultPagination = z.object({\n limit: z.coerce.number().min(1).max(100).default(20),\n cursor: z.string().optional(),\n});\nconst CrudPaginationField = CrudDefaultPagination.optional().default(CrudDefaultPagination.parse({}));\ntype CrudPaginationField = typeof CrudPaginationField;\ntype AnyCrudZodObject = z.ZodObject<any>;\ntype AddCrudPagination<Q extends AnyCrudZodObject | undefined> = Q extends z.ZodObject<infer Shape>\n ? z.ZodObject<Shape & { pagination: CrudPaginationField }>\n : z.ZodObject<{ pagination: CrudPaginationField }>;\n\n/**\n * Merge two Zod schemas at runtime; matches the typing pattern used in builder.\n * @param a Existing params schema inherited from parent branches.\n * @param b Schema introduced at the current branch.\n * @returns Intersection of schemas when both exist, otherwise whichever is defined.\n */\nexport function mergeSchemas<A extends ZodType | undefined, B extends ZodType | undefined>(\n a: A,\n b: B,\n): A extends ZodType ? (B extends ZodType ? ReturnType<typeof z.intersection<A, B>> : A) : B {\n if (a && b) return z.intersection(a as any, b as any) as any;\n return (a ?? b) as any;\n}\n\n/** Build { [Name]: S } Zod object at the type-level. */\nexport type ParamSchema<Name extends string, S extends ZodType> = z.ZodObject<{\n [K in Name]: S;\n}>;\n\n/** Inject active params schema into a leaf cfg (to match your Leaf typing). */\ntype WithParams<I, P> = P extends ZodType ? Omit<I, 'paramsSchema'> & { paramsSchema: P } : I;\n\n/** Resolve boolean flag: default D unless explicitly false. */\ntype Flag<E, D extends boolean> = E extends false ? false : D;\n\n// -----------------------------------------------------------------------------\n// CRUD config (few knobs, with DX comments)\n// -----------------------------------------------------------------------------\n\n/** Toggle individual CRUD methods; defaults enable all (create/update require body). */\nexport type CrudEnable = {\n /** GET /collection (feed). Defaults to true. */ list?: boolean;\n /** POST /collection. Defaults to true if `create` provided. */ create?: boolean;\n /** GET /collection/:id. Defaults to true. */ read?: boolean;\n /** PATCH /collection/:id. Defaults to true if `update` provided. */ update?: boolean;\n /** DELETE /collection/:id. Defaults to true. */ remove?: boolean;\n};\n\n/** Collection GET config. */\nexport type CrudListCfg = {\n /** Query schema (defaults to cursor pagination). */\n querySchema?: ZodType;\n /** Output schema (defaults to { items: Item[], nextCursor? }). */\n outputSchema?: ZodType;\n /** Optional description string. */\n description?: string;\n};\n\n/** Collection POST config. */\nexport type CrudCreateCfg = {\n /** Body schema for creating an item. */\n bodySchema: ZodType;\n /** Output schema (defaults to itemOutputSchema). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/** Item GET config. */\nexport type CrudReadCfg = {\n /** Output schema (defaults to itemOutputSchema). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/** Item PATCH config. */\nexport type CrudUpdateCfg = {\n /** Body schema for partial updates. */\n bodySchema: ZodType;\n /** Output schema (defaults to itemOutputSchema). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/** Item DELETE config. */\nexport type CrudRemoveCfg = {\n /** Output schema (defaults to { ok: true }). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/**\n * CRUD config for `.crud(\"resource\", cfg, extras?)`.\n *\n * It synthesizes `:[resourceName]Id` as the param key and uses `paramSchema` for the value.\n * Prefer passing a **value schema** (e.g. `z.string().uuid()`).\n * As a convenience, a ZodObject of shape `{ [resourceName]Id: schema }` is accepted at runtime too.\n */\nexport type CrudCfg<Name extends string = string> = {\n /**\n * Zod schema for the ID *value* (e.g. `z.string().uuid()`).\n * The parameter key is always `:${name}Id`.\n * (If you pass `z.object({ [name]Id: ... })`, it's accepted at runtime.)\n */\n paramSchema: ZodType;\n\n /**\n * The single-item output shape used by read/create/update by default.\n * List defaults to `{ items: z.array(itemOutputSchema), nextCursor? }`.\n */\n itemOutputSchema: ZodType;\n\n /** Per-method toggles (all enabled by default; create/update require bodies). */\n enable?: CrudEnable;\n\n /** GET /collection configuration. */ list?: CrudListCfg;\n /** POST /collection configuration (enables create). */ create?: CrudCreateCfg;\n /** GET /collection/:id configuration. */ read?: CrudReadCfg;\n /** PATCH /collection/:id configuration (enables update). */ update?: CrudUpdateCfg;\n /** DELETE /collection/:id configuration. */ remove?: CrudRemoveCfg;\n};\n\n// -----------------------------------------------------------------------------\n// Type plumbing to expose generated leaves (so finalize().byKey sees them)\n// -----------------------------------------------------------------------------\n\ntype CrudLeavesTuple<\n Base extends string,\n I extends NodeCfg,\n PS extends ZodType | undefined,\n Name extends string,\n C extends CrudCfg<Name>,\n> = `${Name}Id` extends infer IdName extends string\n ? ParamSchema<IdName, C['paramSchema']> extends infer IdParamZ extends ZodType\n ? [\n // GET /collection\n ...(Flag<\n C['enable'] extends CrudEnable ? C['enable']['list'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'get',\n `${Base}/${Name}`,\n WithParams<\n Omit<I, never> & {\n feed: true;\n querySchema: C['list'] extends CrudListCfg\n ? AddCrudPagination<\n C['list']['querySchema'] extends AnyCrudZodObject\n ? C['list']['querySchema']\n : undefined\n >\n : AddCrudPagination<undefined>;\n outputSchema: C['list'] extends CrudListCfg\n ? C['list']['outputSchema'] extends ZodType\n ? C['list']['outputSchema']\n : z.ZodObject<{\n items: z.ZodArray<C['itemOutputSchema']>;\n nextCursor: z.ZodOptional<z.ZodString>;\n }>\n : z.ZodObject<{\n items: z.ZodArray<C['itemOutputSchema']>;\n nextCursor: z.ZodOptional<z.ZodString>;\n }>;\n description?: string;\n },\n PS\n >\n >,\n ]\n : []),\n\n // POST /collection\n ...((C['create'] extends CrudCreateCfg ? true : false) extends true\n ? Flag<\n C['enable'] extends CrudEnable ? C['enable']['create'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'post',\n `${Base}/${Name}`,\n WithParams<\n Omit<I, never> & {\n bodySchema: C['create'] extends CrudCreateCfg\n ? C['create']['bodySchema']\n : never;\n outputSchema: C['create'] extends CrudCreateCfg\n ? C['create']['outputSchema'] extends ZodType\n ? C['create']['outputSchema']\n : C['itemOutputSchema']\n : never;\n description?: string;\n },\n PS\n >\n >,\n ]\n : []\n : []),\n\n // GET /collection/:id\n ...(Flag<\n C['enable'] extends CrudEnable ? C['enable']['read'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'get',\n `${Base}/${Name}/:${IdName}`,\n WithParams<\n Omit<I, never> & {\n outputSchema: C['read'] extends CrudReadCfg\n ? C['read']['outputSchema'] extends ZodType\n ? C['read']['outputSchema']\n : C['itemOutputSchema']\n : C['itemOutputSchema'];\n description?: string;\n },\n ReturnType<typeof mergeSchemas<PS, IdParamZ>>\n >\n >,\n ]\n : []),\n\n // PATCH /collection/:id\n ...((C['update'] extends CrudUpdateCfg ? true : false) extends true\n ? Flag<\n C['enable'] extends CrudEnable ? C['enable']['update'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'patch',\n `${Base}/${Name}/:${IdName}`,\n WithParams<\n Omit<I, never> & {\n bodySchema: C['update'] extends CrudUpdateCfg\n ? C['update']['bodySchema']\n : never;\n outputSchema: C['update'] extends CrudUpdateCfg\n ? C['update']['outputSchema'] extends ZodType\n ? C['update']['outputSchema']\n : C['itemOutputSchema']\n : never;\n description?: string;\n },\n ReturnType<typeof mergeSchemas<PS, IdParamZ>>\n >\n >,\n ]\n : []\n : []),\n\n // DELETE /collection/:id\n ...(Flag<\n C['enable'] extends CrudEnable ? C['enable']['remove'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'delete',\n `${Base}/${Name}/:${IdName}`,\n WithParams<\n Omit<I, never> & {\n outputSchema: C['remove'] extends CrudRemoveCfg\n ? C['remove']['outputSchema'] extends ZodType\n ? C['remove']['outputSchema']\n : z.ZodObject<{ ok: z.ZodLiteral<true> }>\n : z.ZodObject<{ ok: z.ZodLiteral<true> }>;\n description?: string;\n },\n ReturnType<typeof mergeSchemas<PS, IdParamZ>>\n >\n >,\n ]\n : []),\n ]\n : never\n : never;\n\n/** Merge generated leaves + extras into the branch accumulator. */\ntype CrudResultAcc<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodType | undefined,\n Name extends string,\n C extends CrudCfg<Name>,\n Extras extends readonly AnyLeaf[],\n> = [...Acc, ...CrudLeavesTuple<Base, I, PS, Name, C>, ...Extras];\n\n// -----------------------------------------------------------------------------\n// Module augmentation: add the typed `.crud(...)` to Branch<...>\n// -----------------------------------------------------------------------------\n\ndeclare module './../core/routesV3.builder' {\n interface Branch<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodType | undefined,\n > {\n /**\n * Generate opinionated CRUD endpoints for a collection at `/.../<name>`\n * with an item at `/.../<name>/:<name>Id`.\n *\n * Creates (subject to `enable` + presence of create/update bodies):\n * - GET /<name> (feed list)\n * - POST /<name> (create)\n * - GET /<name>/:<name>Id (read item)\n * - PATCH /<name>/:<name>Id (update item)\n * - DELETE /<name>/:<name>Id (remove item)\n *\n * The `extras` callback receives live builders at both collection and item\n * levels so you can add custom subroutes; their leaves are included in the\n * returned Branch type.\n */\n crud<\n Name extends string,\n C extends CrudCfg<Name>,\n Extras extends readonly AnyLeaf[] = readonly [],\n >(\n name: Name,\n cfg: C,\n extras?: (ctx: {\n /** Builder at `/.../<name>` (collection scope). */\n collection: _Branch<`${Base}/${Name}`, readonly [], I, PS>;\n /** Builder at `/.../<name>/:<name>Id` (item scope). */\n item: _Branch<\n `${Base}/${Name}/:${`${Name}Id`}`,\n readonly [],\n I,\n ReturnType<typeof mergeSchemas<PS, ParamSchema<`${Name}Id`, C['paramSchema']>>>\n >;\n }) => Extras,\n ): _Branch<Base, CrudResultAcc<Base, Acc, I, PS, Name, C, Extras>, I, PS>;\n }\n}\n\n// -----------------------------------------------------------------------------\n// Runtime: install .crud on any Branch via decorator\n// -----------------------------------------------------------------------------\n\n/**\n * Decorate a Branch instance so `.crud(...)` is available at runtime.\n * Tip: wrap the root: `withCrud(resource('/v1'))`.\n * @param branch Branch returned by `resource(...)`.\n * @returns Same branch with `.crud(...)` installed.\n */\nexport function withCrud<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodType | undefined,\n>(branch: _Branch<Base, Acc, I, PS>): _Branch<Base, Acc, I, PS> {\n const b = branch as any;\n if (typeof b.crud === 'function') return branch;\n\n b.crud = function <\n Name extends string,\n C extends CrudCfg<Name>,\n Extras extends readonly AnyLeaf[] = readonly [],\n >(this: any, name: Name, cfg: C, extras?: (ctx: { collection: any; item: any }) => Extras) {\n // Build inside a sub-branch at `/.../<name>` and harvest its leaves.\n return this.sub(name, (collection: any) => {\n const idKey = `${name}Id`;\n\n // Accept a value schema (preferred); but if a z.object({[name]Id: ...}) is provided, use it.\n const s = cfg.paramSchema;\n const isObj =\n s &&\n typeof (s as any)._def === 'object' &&\n (s as any)._def.typeName === 'ZodObject' &&\n typeof (s as any).shape === 'function';\n\n const paramValueSchema =\n isObj && (s as any).shape()[idKey] ? ((s as any).shape()[idKey] as ZodType) : (s as ZodType);\n\n const itemOut = cfg.itemOutputSchema;\n const listOut =\n cfg.list?.outputSchema ??\n z.object({\n items: z.array(itemOut),\n nextCursor: z.string().optional(),\n });\n\n const want = {\n list: cfg.enable?.list !== false,\n create: cfg.enable?.create !== false && !!cfg.create?.bodySchema,\n read: cfg.enable?.read !== false,\n update: cfg.enable?.update !== false && !!cfg.update?.bodySchema,\n remove: cfg.enable?.remove !== false,\n } as const;\n\n // Collection routes\n if (want.list) {\n collection.get({\n feed: true,\n querySchema: cfg.list?.querySchema ?? CrudDefaultPagination,\n outputSchema: listOut,\n description: cfg.list?.description ?? 'List',\n });\n }\n\n if (want.create) {\n collection.post({\n bodySchema: cfg.create!.bodySchema,\n outputSchema: cfg.create?.outputSchema ?? itemOut,\n description: cfg.create?.description ?? 'Create',\n });\n }\n\n // Item routes via :<name>Id\n collection.routeParameter(idKey as any, paramValueSchema as any, (item: any) => {\n if (want.read) {\n item.get({\n outputSchema: cfg.read?.outputSchema ?? itemOut,\n description: cfg.read?.description ?? 'Read',\n });\n }\n if (want.update) {\n item.patch({\n bodySchema: cfg.update!.bodySchema,\n outputSchema: cfg.update?.outputSchema ?? itemOut,\n description: cfg.update?.description ?? 'Update',\n });\n }\n if (want.remove) {\n item.delete({\n outputSchema: cfg.remove?.outputSchema ?? z.object({ ok: z.literal(true) }),\n description: cfg.remove?.description ?? 'Delete',\n });\n }\n\n // Give extras fully-capable builders (decorate so extras can call .crud again)\n if (extras) extras({ collection: withCrud(collection), item: withCrud(item) });\n\n return item.done();\n });\n\n return collection.done();\n });\n };\n\n return branch;\n}\n\n// -----------------------------------------------------------------------------\n// Optional convenience: re-export a resource() that already has .crud installed\n// -----------------------------------------------------------------------------\n\n/**\n * Drop-in replacement for `resource(...)` that returns a Branch with `.crud()` installed.\n * You can either use this or call `withCrud(resource(...))`.\n * @param base Root path for the resource (e.g. `/v1`).\n * @param inherited Node configuration merged into every leaf.\n * @returns Branch builder that already includes the CRUD helper.\n */\nexport function resourceWithCrud<Base extends string, I extends NodeCfg = {}>(\n base: Base,\n inherited: I,\n) {\n return withCrud(baseResource(base, inherited));\n}\n\n// Re-export the original in case you want both styles from this module\nexport { baseResource as resource };\n","// socket.index.ts (shared client/server)\n\nimport { z } from 'zod';\n\nexport type SocketSchema<Output =unknown> = z.ZodType & {\n __out: Output;\n};\n\nexport type SocketSchemaOutput<Schema extends z.ZodTypeAny> = Schema extends {\n __out: infer Out;\n} ? Out : z.output<Schema>;\n\nexport type SocketEvent<Out = unknown> = {\n message: z.ZodTypeAny;\n /** phantom field, only for typing; not meant to be used at runtime */\n __out: Out;\n};\n\nexport type EventMap = Record<string, SocketEvent<any>>;\n\n/**\n * System event names – shared so server and client\n * don't drift on naming.\n */\nexport type SysEventName = 'sys:connect' | 'sys:disconnect' | 'sys:reconnect' | 'sys:connect_error' | 'sys:ping' | 'sys:pong' | 'sys:room_join' | 'sys:room_leave';\nexport function defineSocketEvents<const C extends SocketConnectionConfig, const Schemas extends Record<string, {\n message: z.ZodTypeAny;\n}>>(config: C, events: Schemas): {\n config: {\n [K in keyof C]: SocketSchema<z.output<C[K]>>;\n };\n events: {\n [K in keyof Schemas]: SocketEvent<z.output<Schemas[K]['message']>>;\n };\n};\n\nexport function defineSocketEvents(config: any, events: any) {\n return { config, events };\n}\n\n\n\nexport type Payload<T extends EventMap, K extends keyof T> = T[K] extends SocketEvent<infer Out> ? Out : never;\nexport type SocketConnectionConfig = {\n joinMetaMessage: z.ZodTypeAny;\n leaveMetaMessage: z.ZodTypeAny;\n pingPayload: z.ZodTypeAny;\n pongPayload: z.ZodTypeAny;\n};\n\nexport type SocketConnectionConfigOutput = {\n joinMetaMessage: SocketSchema<any>;\n leaveMetaMessage: SocketSchema<any>;\n pingPayload: SocketSchema<any>;\n pongPayload: SocketSchema<any>;\n}","import { AnyLeaf, MethodCfg } from \"../core/routesV3.core\";\n\ntype SerializableMethodCfg = Pick<\n MethodCfg,\n | 'description'\n | 'summary'\n | 'docsGroup'\n | 'tags'\n | 'deprecated'\n | 'stability'\n | 'feed'\n | 'docsMeta'\n> & {\n hasBody: boolean;\n hasQuery: boolean;\n hasParams: boolean;\n hasOutput: boolean;\n};\n\nexport type SerializableLeaf = {\n method: string;\n path: string;\n cfg: SerializableMethodCfg;\n};\n\nexport function serializeLeaf(leaf: AnyLeaf): SerializableLeaf {\n const cfg = leaf.cfg;\n\n const tags = Array.isArray(cfg.tags) ? cfg.tags.slice() : [];\n\n return {\n method: leaf.method, // 'get' | 'post' | ...\n path: leaf.path,\n cfg: {\n description: cfg.description,\n summary: cfg.summary,\n docsGroup: cfg.docsGroup,\n tags,\n deprecated: cfg.deprecated,\n stability: cfg.stability,\n feed: !!cfg.feed,\n docsMeta: cfg.docsMeta,\n hasBody: !!cfg.bodySchema || !!cfg.bodyFiles?.length,\n hasQuery: !!cfg.querySchema,\n hasParams: !!cfg.paramsSchema,\n hasOutput: !!cfg.outputSchema,\n },\n };\n}\n","import { AnyLeaf } from \"../core/routesV3.core\";\nimport { SerializableLeaf, serializeLeaf } from \"./serializer\";\n\ninterface RenderOptions {\n cspNonce?: string;\n}\n\nconst styles = `\n :root {\n --bg: #020617;\n --bg-elevated: #020617;\n --border-subtle: rgba(148, 163, 184, 0.35);\n --border-strong: rgba(148, 163, 184, 0.65);\n --text: #e5e7eb;\n --text-muted: #9ca3af;\n --accent: #38bdf8;\n --accent-soft: rgba(56, 189, 248, 0.12);\n --radius-lg: 12px;\n --radius-sm: 6px;\n --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.7);\n }\n\n * {\n box-sizing: border-box;\n }\n\n body {\n margin: 0;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"SF Pro Text\",\n \"Segoe UI\", sans-serif;\n background: radial-gradient(circle at top left, #0f172a, #020617 50%)\n radial-gradient(circle at bottom right, #020617, #020617 50%);\n color: var(--text);\n -webkit-font-smoothing: antialiased;\n }\n\n \n .page {\n min-height: 100vh;\n padding: 24px;\n background:\n radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 60%),\n radial-gradient(circle at bottom right, rgba(168, 85, 247, 0.18), transparent 60%);\n }\n\n @media (max-width: 768px) {\n .page {\n padding: 16px;\n }\n }\n\n .shell {\n max-width: 1200px;\n margin: 0 auto;\n background: rgba(15, 23, 42, 0.96);\n border-radius: 18px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n box-shadow: var(--shadow-soft);\n padding: 20px 22px 24px;\n backdrop-filter: blur(28px);\n }\n\n @media (max-width: 768px) {\n .shell {\n padding: 14px 14px 18px;\n }\n }\n\n .header {\n display: flex;\n justify-content: space-between;\n gap: 16px;\n align-items: center;\n margin-bottom: 16px;\n }\n\n .header-main {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .title-row {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n\n .title {\n font-size: 18px;\n font-weight: 600;\n letter-spacing: 0.02em;\n display: inline-flex;\n align-items: center;\n gap: 10px;\n }\n\n .title-pill {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.16em;\n padding: 2px 8px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n color: var(--text-muted);\n background: radial-gradient(circle at top, rgba(148, 163, 184, 0.22), transparent);\n }\n\n .subtitle {\n font-size: 12px;\n color: var(--text-muted);\n }\n\n .stats {\n font-size: 12px;\n color: var(--text-muted);\n white-space: nowrap;\n }\n\n .layout {\n display: grid;\n grid-template-columns: 260px minmax(0, 1fr);\n gap: 18px;\n margin-top: 12px;\n }\n\n @media (max-width: 960px) {\n .layout {\n grid-template-columns: minmax(0, 1fr);\n }\n }\n\n .sidebar {\n padding: 12px;\n border-radius: 14px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n background: radial-gradient(circle at top, rgba(30, 64, 175, 0.45), transparent 55%),\n radial-gradient(circle at bottom, rgba(30, 64, 175, 0.2), transparent 55%),\n rgba(15, 23, 42, 0.92);\n }\n\n .sidebar h2 {\n font-size: 12px;\n text-transform: uppercase;\n letter-spacing: 0.16em;\n color: var(--text-muted);\n margin: 0 0 8px;\n }\n\n .filter-section {\n margin-bottom: 10px;\n }\n\n .filter-section-title {\n font-size: 11px;\n text-transform: uppercase;\n letter-spacing: 0.08em;\n color: var(--text-muted);\n margin-bottom: 6px;\n }\n\n .search-input {\n width: 100%;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n padding: 7px 10px;\n font-size: 12px;\n color: var(--text);\n background: rgba(15, 23, 42, 0.9);\n outline: none;\n }\n\n .search-input::placeholder {\n color: rgba(148, 163, 184, 0.8);\n }\n\n .search-input:focus {\n border-color: var(--accent);\n box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);\n }\n\n .filter-pill-group {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n }\n\n .filter-pill {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n font-size: 11px;\n padding: 3px 6px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.4);\n background: rgba(15, 23, 42, 0.9);\n cursor: pointer;\n user-select: none;\n color: var(--text-muted);\n }\n\n .filter-pill input {\n accent-color: var(--accent);\n }\n\n .group-select {\n width: 100%;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n padding: 6px 10px;\n font-size: 11px;\n background: rgba(15, 23, 42, 0.95);\n color: var(--text);\n outline: none;\n }\n\n .group-select:focus {\n border-color: var(--accent);\n box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);\n }\n\n .main {\n padding: 10px 10px 2px;\n border-radius: 14px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.16), transparent 55%),\n radial-gradient(circle at bottom right, rgba(168, 85, 247, 0.16), transparent 55%),\n rgba(15, 23, 42, 0.95);\n }\n\n .route-list {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n\n .route-card {\n border-radius: 12px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.98));\n padding: 9px 10px;\n box-shadow: 0 10px 30px rgba(15, 23, 42, 0.5);\n }\n\n .route-header {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n align-items: center;\n margin-bottom: 4px;\n }\n\n .method-pill {\n font-size: 10px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.12em;\n padding: 3px 8px;\n border-radius: 999px;\n border: 1px solid transparent;\n background: rgba(30, 64, 175, 0.18);\n color: #e5e7eb;\n }\n\n .method-get {\n background: rgba(22, 163, 74, 0.22);\n border-color: rgba(22, 163, 74, 0.7);\n }\n .method-post {\n background: rgba(59, 130, 246, 0.22);\n border-color: rgba(59, 130, 246, 0.7);\n }\n .method-put {\n background: rgba(234, 179, 8, 0.22);\n border-color: rgba(234, 179, 8, 0.7);\n }\n .method-patch {\n background: rgba(56, 189, 248, 0.22);\n border-color: rgba(56, 189, 248, 0.7);\n }\n .method-delete {\n background: rgba(220, 38, 38, 0.22);\n border-color: rgba(220, 38, 38, 0.7);\n }\n\n .route-path {\n font-family: \"JetBrains Mono\", ui-monospace, SFMono-Regular, Menlo, Monaco,\n Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n font-size: 12px;\n padding: 3px 7px;\n border-radius: 999px;\n background: rgba(15, 23, 42, 0.9);\n border: 1px solid rgba(148, 163, 184, 0.7);\n color: #e5e7eb;\n }\n\n .group-label {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.16em;\n padding: 2px 8px;\n border-radius: 999px;\n background: rgba(15, 23, 42, 0.9);\n border: 1px solid rgba(148, 163, 184, 0.5);\n color: var(--text-muted);\n margin-left: auto;\n }\n\n .route-tags {\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n margin-bottom: 4px;\n margin-top: 2px;\n }\n\n .tag {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.14em;\n padding: 2px 7px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.4);\n color: var(--text-muted);\n background: rgba(15, 23, 42, 0.9);\n }\n\n .tag-not-impl {\n border-color: rgba(248, 113, 113, 0.9);\n background: rgba(239, 68, 68, 0.14);\n color: #fecaca;\n }\n\n .badge {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.14em;\n padding: 2px 7px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n background: rgba(15, 23, 42, 0.9);\n color: var(--text-muted);\n }\n\n .badge-feed {\n border-color: rgba(56, 189, 248, 0.8);\n background: rgba(56, 189, 248, 0.16);\n color: #e0f2fe;\n }\n\n .badge-deprecated {\n border-color: rgba(220, 38, 38, 0.9);\n background: rgba(220, 38, 38, 0.18);\n color: #fee2e2;\n }\n\n .badge-experimental,\n .badge-beta {\n border-color: rgba(168, 85, 247, 0.9);\n background: rgba(168, 85, 247, 0.18);\n color: #f3e8ff;\n }\n\n .route-summary {\n font-size: 12px;\n margin: 2px 0;\n color: var(--text);\n }\n\n .route-description {\n font-size: 11px;\n margin: 0;\n color: var(--text-muted);\n }\n\n .schema-row {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-top: 6px;\n }\n\n .schema-pill {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.14em;\n padding: 2px 7px;\n border-radius: 999px;\n border: 1px dashed rgba(148, 163, 184, 0.7);\n color: rgba(148, 163, 184, 0.9);\n background: rgba(15, 23, 42, 0.95);\n }\n\n .empty-state {\n font-size: 12px;\n color: var(--text-muted);\n padding: 16px 12px;\n border-radius: 10px;\n border: 1px dashed rgba(148, 163, 184, 0.5);\n background: rgba(15, 23, 42, 0.9);\n }`\n\nexport function renderLeafDocsHTML(\n leaves: AnyLeaf[],\n options: RenderOptions = {}\n): string {\n const docsLeaves: SerializableLeaf[] = leaves.map(serializeLeaf);\n\n // Safe embedding into <script> / <script type=\"application/json\">\n const leafJson = JSON.stringify(docsLeaves).replace(/</g, '\\\\u003c');\n\n const nonceAttr = options.cspNonce ? ` nonce=\"${options.cspNonce}\"` : \"\";\n\n return `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\" />\n <title>API Routes</title>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <style${nonceAttr}>\n${styles}\n </style>\n</head>\n<body>\n <div class=\"page\">\n <div class=\"shell\">\n <header class=\"header\">\n <div class=\"header-main\">\n <div class=\"title-row\">\n <div class=\"title\">\n API routes\n <span class=\"title-pill\">Interactive docs</span>\n </div>\n </div>\n <div class=\"subtitle\">\n Introspected from your runtime route leaves.\n </div>\n </div>\n <div id=\"stats\" class=\"stats\"></div>\n </header>\n<div class=\"layout\">\n <aside class=\"sidebar\">\n <h2>Filters</h2>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Search</div>\n <input\n id=\"searchInput\"\n class=\"search-input\"\n type=\"search\"\n placeholder=\"Filter by path, group, tag…\"\n />\n </div>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Method</div>\n <div id=\"methodFilters\" class=\"filter-pill-group\"></div>\n </div>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Group</div>\n <select id=\"groupSelect\" class=\"group-select\"></select>\n </div>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Tags</div>\n <div id=\"tagFilters\" class=\"filter-pill-group\"></div>\n </div>\n </aside>\n\n <main class=\"main\">\n <div id=\"routeList\" class=\"route-list\"></div>\n </main>\n </div>\n </div>\n </div>\n\n <script id=\"leaf-data\" type=\"application/json\"${nonceAttr}>${leafJson}</script>\n <script${nonceAttr}>\n (function () {\n function escapeHtml(str) {\n return String(str)\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#39;');\n }\n\n var raw = document.getElementById('leaf-data').textContent;\n var leaves = raw ? JSON.parse(raw) : [];\n\n var searchInput = document.getElementById('searchInput');\n var methodFiltersEl = document.getElementById('methodFilters');\n var groupSelect = document.getElementById('groupSelect');\n var tagFiltersEl = document.getElementById('tagFilters');\n var routeList = document.getElementById('routeList');\n var statsEl = document.getElementById('stats');\n\n if (!Array.isArray(leaves)) leaves = [];\n\n var allMethods = Array.from(\n new Set(\n leaves.map(function (r) {\n return String(r.method || '').toUpperCase();\n })\n )\n ).sort();\n\n var allGroups = Array.from(\n new Set(\n leaves.map(function (r) {\n return r.cfg && r.cfg.docsGroup ? String(r.cfg.docsGroup) : 'Ungrouped';\n })\n )\n ).sort();\n\n var allTags = Array.from(\n new Set(\n leaves.reduce(function (acc, r) {\n var tags = (r.cfg && r.cfg.tags) || [];\n if (Array.isArray(tags)) {\n for (var i = 0; i < tags.length; i++) acc.push(String(tags[i]));\n }\n return acc;\n }, [])\n )\n ).sort();\n\n function buildFilterUI() {\n // Methods\n methodFiltersEl.innerHTML = '';\n allMethods.forEach(function (m) {\n var label = document.createElement('label');\n label.className = 'filter-pill';\n var cb = document.createElement('input');\n cb.type = 'checkbox';\n cb.value = m;\n cb.checked = true;\n cb.addEventListener('change', applyFilters);\n label.appendChild(cb);\n label.appendChild(document.createTextNode(' ' + m));\n methodFiltersEl.appendChild(label);\n });\n\n // Groups\n groupSelect.innerHTML = '';\n var allOption = document.createElement('option');\n allOption.value = '__all';\n allOption.textContent = 'All groups';\n groupSelect.appendChild(allOption);\n allGroups.forEach(function (g) {\n var opt = document.createElement('option');\n opt.value = g;\n opt.textContent = g;\n groupSelect.appendChild(opt);\n });\n groupSelect.addEventListener('change', applyFilters);\n\n // Tags\n tagFiltersEl.innerHTML = '';\n allTags.forEach(function (t) {\n var label = document.createElement('label');\n label.className = 'filter-pill';\n var cb = document.createElement('input');\n cb.type = 'checkbox';\n cb.value = t;\n cb.addEventListener('change', applyFilters);\n label.appendChild(cb);\n label.appendChild(document.createTextNode(' ' + t));\n tagFiltersEl.appendChild(label);\n });\n }\n\n function routeToHTML(route) {\n var method = String(route.method || '').toUpperCase();\n var methodClass = 'method-' + String(route.method || '').toLowerCase();\n\n var cfg = route.cfg || {};\n var group = cfg.docsGroup || 'Ungrouped';\n\n var summary = cfg.summary || cfg.description || '';\n var description =\n cfg.description && cfg.summary !== cfg.description\n ? cfg.description\n : '';\n\n var tags = Array.isArray(cfg.tags) ? cfg.tags : [];\n var tagHtml = tags\n .map(function (tag) {\n var t = String(tag);\n var extraClass = t === 'not-implemented' ? ' tag-not-impl' : '';\n return '<span class=\"tag' + extraClass + '\">' + escapeHtml(t) + '</span>';\n })\n .join('');\n\n var metaBadges = '';\n if (cfg.feed) {\n metaBadges += '<span class=\"badge badge-feed\">Feed</span>';\n }\n if (cfg.deprecated || cfg.stability === 'deprecated') {\n metaBadges += '<span class=\"badge badge-deprecated\">Deprecated</span>';\n } else if (cfg.stability && cfg.stability !== 'stable') {\n metaBadges +=\n '<span class=\"badge badge-' +\n escapeHtml(cfg.stability) +\n '\">' +\n escapeHtml(String(cfg.stability)) +\n '</span>';\n }\n\n var schemaPills = [];\n if (cfg.hasBody) schemaPills.push('<span class=\"schema-pill\">Body</span>');\n if (cfg.hasQuery) schemaPills.push('<span class=\"schema-pill\">Query</span>');\n if (cfg.hasParams) schemaPills.push('<span class=\"schema-pill\">Params</span>');\n if (cfg.hasOutput) schemaPills.push('<span class=\"schema-pill\">Response</span>');\n\n var schemaHtml =\n schemaPills.length > 0\n ? '<div class=\"schema-row\">' + schemaPills.join('') + '</div>'\n : '';\n\n return (\n '<article class=\"route-card\">' +\n '<header class=\"route-header\">' +\n '<span class=\"method-pill ' +\n methodClass +\n '\">' +\n method +\n '</span>' +\n '<code class=\"route-path\">' +\n escapeHtml(route.path || '') +\n '</code>' +\n (group\n ? '<span class=\"group-label\">' + escapeHtml(String(group)) + '</span>'\n : '') +\n '</header>' +\n '<div class=\"route-tags\">' +\n tagHtml +\n metaBadges +\n '</div>' +\n (summary\n ? '<p class=\"route-summary\">' + escapeHtml(String(summary)) + '</p>'\n : '') +\n (description\n ? '<p class=\"route-description\">' +\n escapeHtml(String(description)) +\n '</p>'\n : '') +\n schemaHtml +\n '</article>'\n );\n }\n\n function applyFilters() {\n var query = searchInput.value.toLowerCase().trim();\n\n var activeMethods = Array.prototype.slice\n .call(methodFiltersEl.querySelectorAll('input[type=\"checkbox\"]:checked'))\n .map(function (cb) {\n return cb.value;\n });\n\n var groupValue = groupSelect.value;\n var activeTags = Array.prototype.slice\n .call(tagFiltersEl.querySelectorAll('input[type=\"checkbox\"]:checked'))\n .map(function (cb) {\n return cb.value;\n });\n\n var filtered = leaves.filter(function (route) {\n var cfg = route.cfg || {};\n\n if (\n activeMethods.length &&\n activeMethods.indexOf(String(route.method || '').toUpperCase()) === -1\n ) {\n return false;\n }\n\n if (groupValue && groupValue !== '__all') {\n var g = cfg.docsGroup || 'Ungrouped';\n if (g !== groupValue) return false;\n }\n\n if (activeTags.length) {\n var tags = Array.isArray(cfg.tags) ? cfg.tags : [];\n var hasAny = activeTags.some(function (t) {\n return tags.indexOf(t) !== -1;\n });\n if (!hasAny) return false;\n }\n\n if (query) {\n var haystack =\n String(route.path || '') +\n ' ' +\n String(cfg.summary || '') +\n ' ' +\n String(cfg.description || '') +\n ' ' +\n (Array.isArray(cfg.tags) ? cfg.tags.join(' ') : '') +\n ' ' +\n String(cfg.docsGroup || '');\n if (haystack.toLowerCase().indexOf(query) === -1) return false;\n }\n\n return true;\n });\n\n if (statsEl) {\n statsEl.textContent = filtered.length + ' routes';\n }\n\n if (!filtered.length) {\n routeList.innerHTML =\n '<div class=\"empty-state\">No routes match the current filters.</div>';\n } else {\n routeList.innerHTML = filtered.map(routeToHTML).join('');\n }\n }\n\n buildFilterUI();\n searchInput.addEventListener('input', applyFilters);\n\n // Initial render\n statsEl.textContent = leaves.length + ' routes';\n applyFilters();\n })();\n </script>\n</body>\n</html>`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkB;AAalB,IAAM,yBAAyB,aAAE,OAAO;AAAA,EACtC,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,OAAO,aAAE,OA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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8PpB;","names":["mergeSchemas","import_zod","mergeSchemas"]}
package/dist/index.mjs CHANGED
@@ -289,16 +289,7 @@ function serializeLeaf(leaf) {
289
289
  }
290
290
 
291
291
  // src/docs/docs.ts
292
- function renderLeafDocsHTML(leaves) {
293
- const docsLeaves = leaves.map(serializeLeaf);
294
- const leafJson = JSON.stringify(docsLeaves).replace(/</g, "\\u003c");
295
- return `<!DOCTYPE html>
296
- <html lang="en">
297
- <head>
298
- <meta charset="utf-8" />
299
- <title>API Routes</title>
300
- <meta name="viewport" content="width=device-width, initial-scale=1" />
301
- <style>
292
+ var styles = `
302
293
  :root {
303
294
  --bg: #020617;
304
295
  --bg-elevated: #020617;
@@ -327,6 +318,7 @@ function renderLeafDocsHTML(leaves) {
327
318
  -webkit-font-smoothing: antialiased;
328
319
  }
329
320
 
321
+
330
322
  .page {
331
323
  min-height: 100vh;
332
324
  padding: 24px;
@@ -690,13 +682,25 @@ function renderLeafDocsHTML(leaves) {
690
682
  border-radius: 10px;
691
683
  border: 1px dashed rgba(148, 163, 184, 0.5);
692
684
  background: rgba(15, 23, 42, 0.9);
693
- }
685
+ }`;
686
+ function renderLeafDocsHTML(leaves, options = {}) {
687
+ const docsLeaves = leaves.map(serializeLeaf);
688
+ const leafJson = JSON.stringify(docsLeaves).replace(/</g, "\\u003c");
689
+ const nonceAttr = options.cspNonce ? ` nonce="${options.cspNonce}"` : "";
690
+ return `<!DOCTYPE html>
691
+ <html lang="en">
692
+ <head>
693
+ <meta charset="utf-8" />
694
+ <title>API Routes</title>
695
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
696
+ <style${nonceAttr}>
697
+ ${styles}
694
698
  </style>
695
699
  </head>
696
700
  <body>
697
701
  <div class="page">
698
702
  <div class="shell">
699
- <header class="header">
703
+ <header class="header">
700
704
  <div class="header-main">
701
705
  <div class="title-row">
702
706
  <div class="title">
@@ -710,8 +714,7 @@ function renderLeafDocsHTML(leaves) {
710
714
  </div>
711
715
  <div id="stats" class="stats"></div>
712
716
  </header>
713
-
714
- <div class="layout">
717
+ <div class="layout">
715
718
  <aside class="sidebar">
716
719
  <h2>Filters</h2>
717
720
 
@@ -748,8 +751,8 @@ function renderLeafDocsHTML(leaves) {
748
751
  </div>
749
752
  </div>
750
753
 
751
- <script id="leaf-data" type="application/json">${leafJson}</script>
752
- <script>
754
+ <script id="leaf-data" type="application/json"${nonceAttr}>${leafJson}</script>
755
+ <script${nonceAttr}>
753
756
  (function () {
754
757
  function escapeHtml(str) {
755
758
  return String(str)
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/routesV3.builder.ts","../src/core/routesV3.core.ts","../src/core/routesV3.finalize.ts","../src/crud/routesV3.crud.ts","../src/sockets/socket.index.ts","../src/docs/serializer.ts","../src/docs/docs.ts"],"sourcesContent":["import { z } from 'zod';\nimport {\n AnyLeaf,\n Append,\n HttpMethod,\n Leaf,\n Merge,\n MergeArray,\n MethodCfg,\n NodeCfg,\n Prettify,\n} from './routesV3.core';\n\nconst defaultFeedQuerySchema = z.object({\n cursor: z.string().optional(),\n limit: z.coerce.number().min(1).max(100).default(20),\n});\n\nconst paginationField = defaultFeedQuerySchema.optional().default(defaultFeedQuerySchema.parse({}));\ntype PaginationField = typeof paginationField;\n\ntype ZodTypeAny = z.ZodTypeAny;\ntype ParamZod<Name extends string, S extends ZodTypeAny> = z.ZodObject<{ [K in Name]: S }>;\ntype ZodArrayAny = z.ZodArray<ZodTypeAny>;\ntype ZodObjectAny = z.ZodObject<any>;\ntype AnyZodObject = z.ZodObject<any>;\ntype MergedParamsResult<PS, Name extends string, P extends ZodTypeAny> = PS extends ZodTypeAny\n ? z.ZodIntersection<PS, ParamZod<Name, P>>\n : ParamZod<Name, P>;\n\nconst defaultFeedOutputSchema = z.object({\n items: z.array(z.unknown()),\n nextCursor: z.string().optional(),\n});\n\nfunction augmentFeedQuerySchema<Q extends ZodTypeAny | undefined>(schema: Q) {\n if (schema && !(schema instanceof z.ZodObject)) {\n console.warn('Feed queries must be a ZodObject; default pagination applied.');\n return z.object({\n pagination: paginationField,\n });\n }\n\n const base = (schema as ZodObjectAny) ?? z.object({});\n return base.extend({\n pagination: paginationField,\n });\n}\n\nfunction augmentFeedOutputSchema<O extends ZodTypeAny | undefined>(schema: O) {\n if (!schema) return defaultFeedOutputSchema;\n if (schema instanceof z.ZodArray) {\n return z.object({\n items: schema,\n nextCursor: z.string().optional(),\n });\n }\n if (schema instanceof z.ZodObject) {\n const shape = (schema as any).shape ? (schema as any).shape : (schema as any)._def?.shape?.();\n const hasItems = Boolean(shape?.items);\n if (hasItems) {\n return schema.extend({ nextCursor: z.string().optional() });\n }\n return z.object({\n items: z.array(schema as ZodTypeAny),\n nextCursor: z.string().optional(),\n });\n }\n return z.object({\n items: z.array(schema as ZodTypeAny),\n nextCursor: z.string().optional(),\n });\n}\n\n/**\n * Runtime helper that mirrors the typed merge used by the builder.\n * @param a Previously merged params schema inherited from parent segments.\n * @param b Newly introduced params schema.\n * @returns Intersection of schemas when both exist, otherwise whichever is defined.\n */\nfunction mergeSchemas<A extends ZodTypeAny, B extends ZodTypeAny>(a: A, b: B): ZodTypeAny;\nfunction mergeSchemas<A extends ZodTypeAny>(a: A, b: undefined): A;\nfunction mergeSchemas<B extends ZodTypeAny>(a: undefined, b: B): B;\nfunction mergeSchemas(a: ZodTypeAny | undefined, b: ZodTypeAny | undefined): ZodTypeAny | undefined;\nfunction mergeSchemas(a: ZodTypeAny | undefined, b: ZodTypeAny | undefined) {\n if (a && b) return z.intersection(a as any, b as any);\n return (a ?? b) as ZodTypeAny | undefined;\n}\n\ntype FeedQuerySchema<C extends MethodCfg> = z.ZodObject<any>;\n\ntype FeedOutputSchema<C extends MethodCfg> = C['outputSchema'] extends ZodArrayAny\n ? z.ZodObject<{\n items: C['outputSchema'];\n nextCursor: z.ZodOptional<z.ZodString>;\n }>\n : C['outputSchema'] extends ZodTypeAny\n ? z.ZodObject<{\n items: z.ZodArray<C['outputSchema']>;\n nextCursor: z.ZodOptional<z.ZodString>;\n }>\n : typeof defaultFeedOutputSchema;\n\ntype BaseMethodCfg<C extends MethodCfg> = Merge<\n Omit<MethodCfg, 'querySchema' | 'outputSchema' | 'feed'>,\n Omit<C, 'querySchema' | 'outputSchema' | 'feed'>\n>;\n\ntype FeedField<C extends MethodCfg> = C['feed'] extends true ? { feed: true } : { feed?: boolean };\n\ntype AddPaginationToQuery<Q extends AnyZodObject | undefined> = Q extends z.ZodObject<\n infer Shape\n>\n ? z.ZodObject<Shape & { pagination: PaginationField }>\n : z.ZodObject<{ pagination: PaginationField }>;\n\ntype FeedQueryField<C extends MethodCfg> = {\n querySchema: AddPaginationToQuery<\n C['querySchema'] extends AnyZodObject ? C['querySchema'] : undefined\n >;\n};\n\ntype NonFeedQueryField<C extends MethodCfg> = C['querySchema'] extends ZodTypeAny\n ? { querySchema: C['querySchema'] }\n : { querySchema?: undefined };\n\ntype FeedOutputField<C extends MethodCfg> = { outputSchema: FeedOutputSchema<C> };\n\ntype NonFeedOutputField<C extends MethodCfg> = C['outputSchema'] extends ZodTypeAny\n ? { outputSchema: C['outputSchema'] }\n : { outputSchema?: undefined };\n\ntype ParamsField<C extends MethodCfg, PS> = C['paramsSchema'] extends ZodTypeAny\n ? { paramsSchema: C['paramsSchema'] }\n : { paramsSchema: PS };\n\ntype EffectiveFeedFields<C extends MethodCfg, PS> = C['feed'] extends true\n ? FeedField<C> & FeedQueryField<C> & FeedOutputField<C> & ParamsField<C, PS>\n : FeedField<C> & NonFeedQueryField<C> & NonFeedOutputField<C> & ParamsField<C, PS>;\n\ntype EffectiveCfg<C extends MethodCfg, PS> = Prettify<\n Merge<MethodCfg, BaseMethodCfg<C> & EffectiveFeedFields<C, PS>>\n>;\n\ntype BuiltLeaf<\n M extends HttpMethod,\n Base extends string,\n I extends NodeCfg,\n C extends MethodCfg,\n PS,\n> = Leaf<M, Base, Merge<I, EffectiveCfg<C, PS>>>;\n\n/** Builder surface used by `resource(...)` to accumulate leaves. */\nexport interface Branch<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodTypeAny | undefined,\n> {\n // --- structure ---\n /**\n * Enter or define a static child segment.\n * Optionally accepts extra config and/or a builder to populate nested routes.\n * @param name Child segment literal (no leading slash).\n * @param cfg Optional node configuration to merge for descendants.\n * @param builder Callback to produce leaves for the child branch.\n */\n sub<Name extends string, J extends NodeCfg>(\n name: Name,\n cfg?: J,\n ): Branch<`${Base}/${Name}`, Acc, Merge<I, NonNullable<J>>, PS>;\n\n sub<Name extends string, J extends NodeCfg | undefined, R extends readonly AnyLeaf[]>(\n name: Name,\n cfg: J,\n builder: (r: Branch<`${Base}/${Name}`, readonly [], Merge<I, NonNullable<J>>, PS>) => R,\n ): Branch<Base, Append<Acc, R[number]>, Merge<I, NonNullable<J>>, PS>;\n\n sub<Name extends string, R extends readonly AnyLeaf[]>(\n name: Name,\n builder: (r: Branch<`${Base}/${Name}`, readonly [], I, PS>) => R,\n ): Branch<Base, MergeArray<Acc, R>, I, PS>;\n\n // --- parameterized segment (single signature) ---\n /**\n * Introduce a `:param` segment and merge its schema into downstream leaves.\n * @param name Parameter key (without leading colon).\n * @param paramsSchema Zod schema for the parameter value.\n * @param builder Callback that produces leaves beneath the parameterized segment.\n */\n routeParameter<Name extends string, P extends ZodTypeAny, R extends readonly AnyLeaf[]>(\n name: Name,\n paramsSchema: P,\n builder: (\n r: Branch<\n `${Base}/:${Name}`,\n readonly [],\n I,\n MergedParamsResult<PS, Name, P>\n >,\n ) => R,\n ): Branch<Base, MergeArray<Acc, R>, I, MergedParamsResult<PS, Name, P>>;\n\n // --- flags inheritance ---\n /**\n * Merge additional node configuration that subsequent leaves will inherit.\n * @param cfg Partial node configuration.\n */\n with<J extends NodeCfg>(cfg: J): Branch<Base, Acc, Merge<I, J>, PS>;\n\n // --- methods (return Branch to keep chaining) ---\n /**\n * Register a GET leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n get<C extends MethodCfg>(\n cfg: C,\n ): Branch<\n Base,\n Append<Acc, Prettify<BuiltLeaf<'get', Base, I, C, PS>>>,\n I,\n PS\n >;\n\n /**\n * Register a POST leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n post<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'post', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n /**\n * Register a PUT leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n put<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'put', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n /**\n * Register a PATCH leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n patch<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'patch', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n /**\n * Register a DELETE leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n delete<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'delete', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n // --- finalize this subtree ---\n /**\n * Finish the branch and return the collected leaves.\n * @returns Readonly tuple of accumulated leaves.\n */\n done(): Readonly<Acc>;\n}\n\n/**\n * Start building a resource at the given base path.\n * @param base Root path for the resource (e.g. `/v1`).\n * @param inherited Optional node configuration applied to all descendants.\n * @returns Root `Branch` instance used to compose the route tree.\n */\nexport function resource<Base extends string, I extends NodeCfg = {}>(\n base: Base,\n inherited?: I,\n): Branch<Base, readonly [], I, undefined> {\n const rootBase = base;\n const rootInherited: NodeCfg = { ...(inherited as NodeCfg) };\n\n function makeBranch<Base2 extends string, I2 extends NodeCfg, PS2 extends ZodTypeAny | undefined>(\n base2: Base2,\n inherited2: I2,\n mergedParamsSchema?: PS2,\n ) {\n const stack: AnyLeaf[] = [];\n let currentBase: string = base2;\n let inheritedCfg: NodeCfg = { ...(inherited2 as NodeCfg) };\n let currentParamsSchema: PS2 = mergedParamsSchema as PS2;\n\n function add<M extends HttpMethod, C extends MethodCfg>(method: M, cfg: C) {\n // If the method didn’t provide a paramsSchema, inject the active merged one.\n const effectiveParamsSchema = (cfg.paramsSchema ?? currentParamsSchema) as PS2 | undefined;\n const effectiveQuerySchema =\n cfg.feed === true ? augmentFeedQuerySchema(cfg.querySchema) : cfg.querySchema;\n const effectiveOutputSchema =\n cfg.feed === true ? augmentFeedOutputSchema(cfg.outputSchema) : cfg.outputSchema;\n\n const fullCfg = (\n effectiveParamsSchema\n ? {\n ...inheritedCfg,\n ...cfg,\n paramsSchema: effectiveParamsSchema,\n ...(effectiveQuerySchema ? { querySchema: effectiveQuerySchema } : {}),\n ...(effectiveOutputSchema ? { outputSchema: effectiveOutputSchema } : {}),\n }\n : {\n ...inheritedCfg,\n ...cfg,\n ...(effectiveQuerySchema ? { querySchema: effectiveQuerySchema } : {}),\n ...(effectiveOutputSchema ? { outputSchema: effectiveOutputSchema } : {}),\n }\n ) as any;\n\n const leaf = {\n method,\n path: currentBase as Base2,\n cfg: fullCfg,\n } as const;\n\n stack.push(leaf as unknown as AnyLeaf);\n\n // Return same runtime obj, but with Acc including this new leaf\n return api as unknown as Branch<Base2, Append<readonly [], typeof leaf>, I2, PS2>;\n }\n\n const api: any = {\n // compose a plain subpath (optional cfg) with optional builder\n sub<Name extends string, J extends NodeCfg | undefined = undefined>(\n name: Name,\n cfgOrBuilder?: J | ((r: any) => readonly AnyLeaf[]),\n maybeBuilder?: (r: any) => readonly AnyLeaf[],\n ) {\n let cfg: NodeCfg | undefined;\n let builder: ((r: any) => readonly AnyLeaf[]) | undefined;\n\n if (typeof cfgOrBuilder === 'function') {\n builder = cfgOrBuilder as any;\n } else {\n cfg = cfgOrBuilder as NodeCfg | undefined;\n builder = maybeBuilder;\n }\n\n const childBase = `${currentBase}/${name}` as const;\n const childInherited = { ...inheritedCfg, ...(cfg ?? {}) } as Merge<I2, NonNullable<J>>;\n\n if (builder) {\n // params schema PS2 flows through unchanged on plain sub\n const child = makeBranch(childBase, childInherited, currentParamsSchema);\n const leaves = builder(child) as readonly AnyLeaf[];\n for (const l of leaves) stack.push(l);\n return api as Branch<\n Base2,\n Append<readonly [], (typeof leaves)[number]>,\n typeof childInherited,\n PS2\n >;\n } else {\n currentBase = childBase;\n inheritedCfg = childInherited;\n return api as Branch<`${Base2}/${Name}`, readonly [], typeof childInherited, PS2>;\n }\n },\n\n // the single param function: name + schema + builder\n routeParameter<Name extends string, P extends ZodTypeAny, R extends readonly AnyLeaf[]>(\n name: Name,\n paramsSchema: P,\n builder: (\n r: Branch<\n `${Base2}/:${Name}`,\n readonly [],\n I2,\n MergedParamsResult<PS2, Name, P>\n >,\n ) => R,\n ) {\n const childBase = `${currentBase}/:${name}` as const;\n // Wrap the value schema under the param name before merging with inherited params schema\n const paramObj: ParamZod<Name, P> = z.object({ [name]: paramsSchema } as Record<Name, P>);\n const childParams = (currentParamsSchema\n ? mergeSchemas(currentParamsSchema, paramObj)\n : paramObj) as MergedParamsResult<PS2, Name, P>;\n const child = makeBranch(childBase, inheritedCfg as I2, childParams);\n const leaves = builder(child) as readonly AnyLeaf[];\n for (const l of leaves) stack.push(l);\n return api as Branch<\n Base2,\n Append<readonly [], (typeof leaves)[number]>,\n I2,\n MergedParamsResult<PS2, Name, P>\n >;\n },\n\n with<J extends NodeCfg>(cfg: J) {\n inheritedCfg = { ...inheritedCfg, ...cfg };\n return api as Branch<Base2, readonly [], Merge<I2, J>, PS2>;\n },\n\n // methods (inject current params schema if missing)\n get<C extends MethodCfg>(cfg: C) {\n return add('get', cfg);\n },\n post<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('post', { ...cfg, feed: false });\n },\n put<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('put', { ...cfg, feed: false });\n },\n patch<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('patch', { ...cfg, feed: false });\n },\n delete<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('delete', { ...cfg, feed: false });\n },\n\n done() {\n return stack;\n },\n };\n\n return api as Branch<Base2, readonly [], I2, PS2>;\n }\n\n // Root branch starts with no params schema (PS = undefined)\n return makeBranch(rootBase, rootInherited, undefined);\n}\n\n/**\n * Merge two readonly tuples (preserves literal tuple information).\n * @param arr1 First tuple.\n * @param arr2 Second tuple.\n * @returns New tuple containing values from both inputs.\n */\nexport const mergeArrays = <T extends readonly any[], S extends readonly any[]>(\n arr1: T,\n arr2: S,\n) => {\n return [...arr1, ...arr2] as [...T, ...S];\n};\n","import { z, ZodTypeAny } from 'zod';\n\n/** Supported HTTP verbs for the routes DSL. */\nexport type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';\n\n/** Declarative description of a multipart upload field. */\nexport type FileField = {\n /** Form field name used for uploads. */\n name: string;\n /** Maximum number of files accepted for this field. */\n maxCount: number;\n};\n\n/** Configuration that applies to an entire branch of the route tree. */\nexport type NodeCfg = {\n /** @deprecated. Does nothing. */\n authenticated?: boolean;\n};\n\n/** Per-method configuration merged with inherited node config. */\nexport type MethodCfg = {\n /** Zod schema describing the request body. */\n bodySchema?: ZodTypeAny;\n /** Zod schema describing the query string. */\n querySchema?: ZodTypeAny;\n /** Zod schema describing path params (overrides inferred params). */\n paramsSchema?: ZodTypeAny;\n /** Zod schema describing the response payload. */\n outputSchema?: ZodTypeAny;\n /** Multipart upload definitions for the route. */\n bodyFiles?: FileField[];\n /** Marks the route as an infinite feed (enables cursor helpers). */\n feed?: boolean;\n\n /** Optional human-readable description for docs/debugging. */\n description?: string;\n /**\n * Short one-line summary for docs list views.\n * Shown in navigation / tables instead of the full description.\n */\n summary?: string;\n /**\n * Group name used for navigation sections in docs UIs.\n * e.g. \"Users\", \"Billing\", \"Auth\".\n */\n docsGroup?: string;\n /**\n * Tags that can be used to filter / facet in interactive docs.\n * e.g. [\"users\", \"admin\", \"internal\"].\n */\n tags?: string[];\n /**\n * Mark the route as deprecated in docs.\n * Renderers can badge this and/or hide by default.\n */\n deprecated?: boolean;\n /**\n * Optional stability information for the route.\n * Renderers can surface this prominently.\n */\n stability?: 'experimental' | 'beta' | 'stable' | 'deprecated';\n /**\n * Hide this route from public docs while keeping it usable in code.\n */\n docsHidden?: boolean;\n /**\n * Arbitrary extra metadata for docs renderers.\n * Can be used for auth requirements, rate limits, feature flags, etc.\n */\n docsMeta?: Record<string, unknown>;\n};\n\n/** Immutable representation of a single HTTP route in the tree. */\nexport type Leaf<M extends HttpMethod, P extends string, C extends MethodCfg> = {\n /** Lowercase HTTP method (get/post/...). */\n readonly method: M;\n /** Concrete path for the route (e.g. `/v1/users/:userId`). */\n readonly path: P;\n /** Readonly snapshot of route configuration. */\n readonly cfg: Readonly<C>;\n};\n\n/** Convenience union covering all generated leaves. */\nexport type AnyLeaf = Leaf<HttpMethod, string, MethodCfg>;\n\n/** Merge two object types while keeping nice IntelliSense output. */\nexport type Merge<A, B> = Prettify<Omit<A, keyof B> & B>;\n\n/** Append a new element to a readonly tuple type. */\nexport type Append<T extends readonly unknown[], X> = [...T, X];\n\n/** Concatenate two readonly tuple types. */\nexport type MergeArray<A extends readonly unknown[], B extends readonly unknown[]> = [\n ...A,\n ...B,\n];\n\n// helpers (optional)\ntype SegmentParams<S extends string> = S extends `:${infer P}` ? P : never;\ntype Split<S extends string> = S extends ''\n ? []\n : S extends `${infer A}/${infer B}`\n ? [A, ...Split<B>]\n : [S];\ntype ExtractParamNames<Path extends string> = SegmentParams<Split<Path>[number]>;\n\n/** Derive a params object type from a literal route string. */\nexport type ExtractParamsFromPath<Path extends string> =\n ExtractParamNames<Path> extends never ? never : Record<ExtractParamNames<Path>, string | number>;\n\n/**\n * Interpolate `:params` in a path using the given values.\n * @param path Literal route string containing `:param` segments.\n * @param params Object of parameter values to interpolate.\n * @returns Path string with parameters substituted.\n */\nexport function compilePath<Path extends string>(path: Path, params: ExtractParamsFromPath<Path>) {\n if (!params) return path;\n return path.replace(/:([A-Za-z0-9_]+)/g, (_, k) => {\n const v = (params as any)[k];\n if (v === undefined || v === null) throw new Error(`Missing param :${k}`);\n return String(v);\n });\n}\n\n/**\n * Build a deterministic cache key for the given leaf.\n * The key matches the shape consumed by React Query helpers.\n * @param args.leaf Leaf describing the endpoint.\n * @param args.params Optional params used to build the path.\n * @param args.query Optional query payload.\n * @returns Tuple suitable for React Query cache keys.\n */\ntype SplitPath<P extends string> = P extends ''\n ? []\n : P extends `${infer A}/${infer B}`\n ? [A, ...SplitPath<B>]\n : [P];\nexport function buildCacheKey<L extends AnyLeaf>(args: {\n leaf: L;\n params?: ExtractParamsFromPath<L['path']>;\n query?: InferQuery<L>;\n}) {\n let p = args.leaf.path;\n if (args.params) {\n p = compilePath<L['path']>(p, args.params);\n }\n return [args.leaf.method, ...(p.split('/').filter(Boolean) as SplitPath<typeof p>), args.query ?? {}] as const;\n}\n\n/** Infer params either from the explicit params schema or from the path literal. */\nexport type InferParams<L extends AnyLeaf> = L['cfg']['paramsSchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['paramsSchema']>\n : ExtractParamsFromPath<L['path']>;\n\n/** Infer query shape from a Zod schema when present. */\nexport type InferQuery<L extends AnyLeaf> = L['cfg']['querySchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['querySchema']>\n : never;\n\n/** Infer request body shape from a Zod schema when present. */\nexport type InferBody<L extends AnyLeaf> = L['cfg']['bodySchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['bodySchema']>\n : never;\n\n/** Infer handler output shape from a Zod schema. Defaults to unknown. */\nexport type InferOutput<L extends AnyLeaf> = L['cfg']['outputSchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['outputSchema']>\n : unknown;\n\n/** Render a type as if it were a simple object literal. */\nexport type Prettify<T> = { [K in keyof T]: T[K] } & {};\n","// TODO:\n// * use this as a transform that infers the types from Zod, to only pass the types around instead of the full schemas -> make converters that go both ways (data to schema, schema to data)\n// * consider moving to core package\n// * update server and client side to use this type instead of raw zod schemas \nimport { AnyLeaf, HttpMethod, Prettify } from './routesV3.core';\n\n/** Build the key type for a leaf — distributive so method/path stay paired. */\nexport type KeyOf<L extends AnyLeaf> = L extends AnyLeaf\n ? `${Uppercase<L['method']>} ${L['path']}`\n : never;\n\n// From a tuple of leaves, get the union of keys (pairwise, no cartesian blow-up)\ntype KeysOf<Leaves extends readonly AnyLeaf[]> = KeyOf<Leaves[number]>;\n\n// Parse method & path out of a key\ntype MethodFromKey<K extends string> = K extends `${infer M} ${string}` ? Lowercase<M> : never;\ntype PathFromKey<K extends string> = K extends `${string} ${infer P}` ? P : never;\n\n// Given Leaves and a Key, pick the exact leaf that matches method+path\ntype LeafForKey<Leaves extends readonly AnyLeaf[], K extends string> = Extract<\n Leaves[number],\n { method: MethodFromKey<K> & HttpMethod; path: PathFromKey<K> }\n>;\n\n/**\n * Freeze a leaf tuple into a registry with typed key lookups.\n * @param leaves Readonly tuple of leaves produced by the builder DSL.\n * @returns Registry containing the leaves array and a `byKey` lookup map.\n */\nexport function finalize<const L extends readonly AnyLeaf[]>(leaves: L) {\n type Keys = KeysOf<L>;\n type MapByKey = { [K in Keys]: Prettify<LeafForKey<L, K>> };\n\n const byKey = Object.fromEntries(\n leaves.map((l) => [`${l.method.toUpperCase()} ${l.path}`, l] as const),\n ) as unknown as MapByKey;\n\n const log = (logger: { system: (...args: unknown[]) => void }) => {\n logger.system('Finalized routes:');\n (Object.keys(byKey) as Keys[]).forEach((k) => {\n const leaf = byKey[k];\n logger.system(`- ${k}`);\n });\n };\n\n return { all: leaves, byKey, log };\n}\n\n/** Nominal type alias for a finalized registry. */\nexport type Registry<R extends ReturnType<typeof finalize>> = R;\n\ntype FilterRoute<\n T extends readonly AnyLeaf[],\n F extends string,\n Acc extends readonly AnyLeaf[] = [],\n> = T extends readonly [infer First extends AnyLeaf, ...infer Rest extends AnyLeaf[]]\n ? First extends { path: `${string}${F}${string}` }\n ? FilterRoute<Rest, F, [...Acc, First]>\n : FilterRoute<Rest, F, Acc>\n : Acc;\n\ntype UpperCase<S extends string> = S extends `${infer First}${infer Rest}`\n ? `${Uppercase<First>}${UpperCase<Rest>}`\n : S;\n\ntype Routes<T extends readonly AnyLeaf[], F extends string> = FilterRoute<T, F>;\ntype ByKey<\n T extends readonly AnyLeaf[],\n Acc extends Record<string, AnyLeaf> = {},\n> = T extends readonly [infer First extends AnyLeaf, ...infer Rest extends AnyLeaf[]]\n ? ByKey<Rest, Acc & { [K in `${UpperCase<First['method']>} ${First['path']}`]: First }>\n : Acc;\n\n/**\n * Convenience helper for extracting a subset of routes by path fragment.\n * @param T Tuple of leaves produced by the DSL.\n * @param F String fragment to match against the route path.\n */\nexport type SubsetRoutes<T extends readonly AnyLeaf[], F extends string> = {\n byKey: ByKey<Routes<T, F>>;\n all: Routes<T, F>;\n};\n","// routesV3.crud.ts\n// -----------------------------------------------------------------------------\n// Add a first-class .crud() helper to the routesV3 DSL, without touching the\n// core builder. This file:\n// 1) Declares types + module augmentation to extend Branch<...> with .crud\n// 2) Provides a runtime decorator `withCrud(...)` that installs the method\n// 3) Exports a convenience `resourceWithCrud(...)` wrapper (optional)\n// -----------------------------------------------------------------------------\n\nimport { z, ZodType } from 'zod';\nimport {\n resource as baseResource,\n type Branch as _Branch, // import type so we can augment it\n} from '../core/routesV3.builder';\nimport { type AnyLeaf, type Leaf, type NodeCfg } from '../core/routesV3.core';\n\n// -----------------------------------------------------------------------------\n// Small utilities (runtime + types)\n// -----------------------------------------------------------------------------\n/** Default cursor pagination used by list (GET collection). */\nexport const CrudDefaultPagination = z.object({\n limit: z.coerce.number().min(1).max(100).default(20),\n cursor: z.string().optional(),\n});\nconst CrudPaginationField = CrudDefaultPagination.optional().default(CrudDefaultPagination.parse({}));\ntype CrudPaginationField = typeof CrudPaginationField;\ntype AnyCrudZodObject = z.ZodObject<any>;\ntype AddCrudPagination<Q extends AnyCrudZodObject | undefined> = Q extends z.ZodObject<infer Shape>\n ? z.ZodObject<Shape & { pagination: CrudPaginationField }>\n : z.ZodObject<{ pagination: CrudPaginationField }>;\n\n/**\n * Merge two Zod schemas at runtime; matches the typing pattern used in builder.\n * @param a Existing params schema inherited from parent branches.\n * @param b Schema introduced at the current branch.\n * @returns Intersection of schemas when both exist, otherwise whichever is defined.\n */\nexport function mergeSchemas<A extends ZodType | undefined, B extends ZodType | undefined>(\n a: A,\n b: B,\n): A extends ZodType ? (B extends ZodType ? ReturnType<typeof z.intersection<A, B>> : A) : B {\n if (a && b) return z.intersection(a as any, b as any) as any;\n return (a ?? b) as any;\n}\n\n/** Build { [Name]: S } Zod object at the type-level. */\nexport type ParamSchema<Name extends string, S extends ZodType> = z.ZodObject<{\n [K in Name]: S;\n}>;\n\n/** Inject active params schema into a leaf cfg (to match your Leaf typing). */\ntype WithParams<I, P> = P extends ZodType ? Omit<I, 'paramsSchema'> & { paramsSchema: P } : I;\n\n/** Resolve boolean flag: default D unless explicitly false. */\ntype Flag<E, D extends boolean> = E extends false ? false : D;\n\n// -----------------------------------------------------------------------------\n// CRUD config (few knobs, with DX comments)\n// -----------------------------------------------------------------------------\n\n/** Toggle individual CRUD methods; defaults enable all (create/update require body). */\nexport type CrudEnable = {\n /** GET /collection (feed). Defaults to true. */ list?: boolean;\n /** POST /collection. Defaults to true if `create` provided. */ create?: boolean;\n /** GET /collection/:id. Defaults to true. */ read?: boolean;\n /** PATCH /collection/:id. Defaults to true if `update` provided. */ update?: boolean;\n /** DELETE /collection/:id. Defaults to true. */ remove?: boolean;\n};\n\n/** Collection GET config. */\nexport type CrudListCfg = {\n /** Query schema (defaults to cursor pagination). */\n querySchema?: ZodType;\n /** Output schema (defaults to { items: Item[], nextCursor? }). */\n outputSchema?: ZodType;\n /** Optional description string. */\n description?: string;\n};\n\n/** Collection POST config. */\nexport type CrudCreateCfg = {\n /** Body schema for creating an item. */\n bodySchema: ZodType;\n /** Output schema (defaults to itemOutputSchema). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/** Item GET config. */\nexport type CrudReadCfg = {\n /** Output schema (defaults to itemOutputSchema). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/** Item PATCH config. */\nexport type CrudUpdateCfg = {\n /** Body schema for partial updates. */\n bodySchema: ZodType;\n /** Output schema (defaults to itemOutputSchema). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/** Item DELETE config. */\nexport type CrudRemoveCfg = {\n /** Output schema (defaults to { ok: true }). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/**\n * CRUD config for `.crud(\"resource\", cfg, extras?)`.\n *\n * It synthesizes `:[resourceName]Id` as the param key and uses `paramSchema` for the value.\n * Prefer passing a **value schema** (e.g. `z.string().uuid()`).\n * As a convenience, a ZodObject of shape `{ [resourceName]Id: schema }` is accepted at runtime too.\n */\nexport type CrudCfg<Name extends string = string> = {\n /**\n * Zod schema for the ID *value* (e.g. `z.string().uuid()`).\n * The parameter key is always `:${name}Id`.\n * (If you pass `z.object({ [name]Id: ... })`, it's accepted at runtime.)\n */\n paramSchema: ZodType;\n\n /**\n * The single-item output shape used by read/create/update by default.\n * List defaults to `{ items: z.array(itemOutputSchema), nextCursor? }`.\n */\n itemOutputSchema: ZodType;\n\n /** Per-method toggles (all enabled by default; create/update require bodies). */\n enable?: CrudEnable;\n\n /** GET /collection configuration. */ list?: CrudListCfg;\n /** POST /collection configuration (enables create). */ create?: CrudCreateCfg;\n /** GET /collection/:id configuration. */ read?: CrudReadCfg;\n /** PATCH /collection/:id configuration (enables update). */ update?: CrudUpdateCfg;\n /** DELETE /collection/:id configuration. */ remove?: CrudRemoveCfg;\n};\n\n// -----------------------------------------------------------------------------\n// Type plumbing to expose generated leaves (so finalize().byKey sees them)\n// -----------------------------------------------------------------------------\n\ntype CrudLeavesTuple<\n Base extends string,\n I extends NodeCfg,\n PS extends ZodType | undefined,\n Name extends string,\n C extends CrudCfg<Name>,\n> = `${Name}Id` extends infer IdName extends string\n ? ParamSchema<IdName, C['paramSchema']> extends infer IdParamZ extends ZodType\n ? [\n // GET /collection\n ...(Flag<\n C['enable'] extends CrudEnable ? C['enable']['list'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'get',\n `${Base}/${Name}`,\n WithParams<\n Omit<I, never> & {\n feed: true;\n querySchema: C['list'] extends CrudListCfg\n ? AddCrudPagination<\n C['list']['querySchema'] extends AnyCrudZodObject\n ? C['list']['querySchema']\n : undefined\n >\n : AddCrudPagination<undefined>;\n outputSchema: C['list'] extends CrudListCfg\n ? C['list']['outputSchema'] extends ZodType\n ? C['list']['outputSchema']\n : z.ZodObject<{\n items: z.ZodArray<C['itemOutputSchema']>;\n nextCursor: z.ZodOptional<z.ZodString>;\n }>\n : z.ZodObject<{\n items: z.ZodArray<C['itemOutputSchema']>;\n nextCursor: z.ZodOptional<z.ZodString>;\n }>;\n description?: string;\n },\n PS\n >\n >,\n ]\n : []),\n\n // POST /collection\n ...((C['create'] extends CrudCreateCfg ? true : false) extends true\n ? Flag<\n C['enable'] extends CrudEnable ? C['enable']['create'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'post',\n `${Base}/${Name}`,\n WithParams<\n Omit<I, never> & {\n bodySchema: C['create'] extends CrudCreateCfg\n ? C['create']['bodySchema']\n : never;\n outputSchema: C['create'] extends CrudCreateCfg\n ? C['create']['outputSchema'] extends ZodType\n ? C['create']['outputSchema']\n : C['itemOutputSchema']\n : never;\n description?: string;\n },\n PS\n >\n >,\n ]\n : []\n : []),\n\n // GET /collection/:id\n ...(Flag<\n C['enable'] extends CrudEnable ? C['enable']['read'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'get',\n `${Base}/${Name}/:${IdName}`,\n WithParams<\n Omit<I, never> & {\n outputSchema: C['read'] extends CrudReadCfg\n ? C['read']['outputSchema'] extends ZodType\n ? C['read']['outputSchema']\n : C['itemOutputSchema']\n : C['itemOutputSchema'];\n description?: string;\n },\n ReturnType<typeof mergeSchemas<PS, IdParamZ>>\n >\n >,\n ]\n : []),\n\n // PATCH /collection/:id\n ...((C['update'] extends CrudUpdateCfg ? true : false) extends true\n ? Flag<\n C['enable'] extends CrudEnable ? C['enable']['update'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'patch',\n `${Base}/${Name}/:${IdName}`,\n WithParams<\n Omit<I, never> & {\n bodySchema: C['update'] extends CrudUpdateCfg\n ? C['update']['bodySchema']\n : never;\n outputSchema: C['update'] extends CrudUpdateCfg\n ? C['update']['outputSchema'] extends ZodType\n ? C['update']['outputSchema']\n : C['itemOutputSchema']\n : never;\n description?: string;\n },\n ReturnType<typeof mergeSchemas<PS, IdParamZ>>\n >\n >,\n ]\n : []\n : []),\n\n // DELETE /collection/:id\n ...(Flag<\n C['enable'] extends CrudEnable ? C['enable']['remove'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'delete',\n `${Base}/${Name}/:${IdName}`,\n WithParams<\n Omit<I, never> & {\n outputSchema: C['remove'] extends CrudRemoveCfg\n ? C['remove']['outputSchema'] extends ZodType\n ? C['remove']['outputSchema']\n : z.ZodObject<{ ok: z.ZodLiteral<true> }>\n : z.ZodObject<{ ok: z.ZodLiteral<true> }>;\n description?: string;\n },\n ReturnType<typeof mergeSchemas<PS, IdParamZ>>\n >\n >,\n ]\n : []),\n ]\n : never\n : never;\n\n/** Merge generated leaves + extras into the branch accumulator. */\ntype CrudResultAcc<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodType | undefined,\n Name extends string,\n C extends CrudCfg<Name>,\n Extras extends readonly AnyLeaf[],\n> = [...Acc, ...CrudLeavesTuple<Base, I, PS, Name, C>, ...Extras];\n\n// -----------------------------------------------------------------------------\n// Module augmentation: add the typed `.crud(...)` to Branch<...>\n// -----------------------------------------------------------------------------\n\ndeclare module './../core/routesV3.builder' {\n interface Branch<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodType | undefined,\n > {\n /**\n * Generate opinionated CRUD endpoints for a collection at `/.../<name>`\n * with an item at `/.../<name>/:<name>Id`.\n *\n * Creates (subject to `enable` + presence of create/update bodies):\n * - GET /<name> (feed list)\n * - POST /<name> (create)\n * - GET /<name>/:<name>Id (read item)\n * - PATCH /<name>/:<name>Id (update item)\n * - DELETE /<name>/:<name>Id (remove item)\n *\n * The `extras` callback receives live builders at both collection and item\n * levels so you can add custom subroutes; their leaves are included in the\n * returned Branch type.\n */\n crud<\n Name extends string,\n C extends CrudCfg<Name>,\n Extras extends readonly AnyLeaf[] = readonly [],\n >(\n name: Name,\n cfg: C,\n extras?: (ctx: {\n /** Builder at `/.../<name>` (collection scope). */\n collection: _Branch<`${Base}/${Name}`, readonly [], I, PS>;\n /** Builder at `/.../<name>/:<name>Id` (item scope). */\n item: _Branch<\n `${Base}/${Name}/:${`${Name}Id`}`,\n readonly [],\n I,\n ReturnType<typeof mergeSchemas<PS, ParamSchema<`${Name}Id`, C['paramSchema']>>>\n >;\n }) => Extras,\n ): _Branch<Base, CrudResultAcc<Base, Acc, I, PS, Name, C, Extras>, I, PS>;\n }\n}\n\n// -----------------------------------------------------------------------------\n// Runtime: install .crud on any Branch via decorator\n// -----------------------------------------------------------------------------\n\n/**\n * Decorate a Branch instance so `.crud(...)` is available at runtime.\n * Tip: wrap the root: `withCrud(resource('/v1'))`.\n * @param branch Branch returned by `resource(...)`.\n * @returns Same branch with `.crud(...)` installed.\n */\nexport function withCrud<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodType | undefined,\n>(branch: _Branch<Base, Acc, I, PS>): _Branch<Base, Acc, I, PS> {\n const b = branch as any;\n if (typeof b.crud === 'function') return branch;\n\n b.crud = function <\n Name extends string,\n C extends CrudCfg<Name>,\n Extras extends readonly AnyLeaf[] = readonly [],\n >(this: any, name: Name, cfg: C, extras?: (ctx: { collection: any; item: any }) => Extras) {\n // Build inside a sub-branch at `/.../<name>` and harvest its leaves.\n return this.sub(name, (collection: any) => {\n const idKey = `${name}Id`;\n\n // Accept a value schema (preferred); but if a z.object({[name]Id: ...}) is provided, use it.\n const s = cfg.paramSchema;\n const isObj =\n s &&\n typeof (s as any)._def === 'object' &&\n (s as any)._def.typeName === 'ZodObject' &&\n typeof (s as any).shape === 'function';\n\n const paramValueSchema =\n isObj && (s as any).shape()[idKey] ? ((s as any).shape()[idKey] as ZodType) : (s as ZodType);\n\n const itemOut = cfg.itemOutputSchema;\n const listOut =\n cfg.list?.outputSchema ??\n z.object({\n items: z.array(itemOut),\n nextCursor: z.string().optional(),\n });\n\n const want = {\n list: cfg.enable?.list !== false,\n create: cfg.enable?.create !== false && !!cfg.create?.bodySchema,\n read: cfg.enable?.read !== false,\n update: cfg.enable?.update !== false && !!cfg.update?.bodySchema,\n remove: cfg.enable?.remove !== false,\n } as const;\n\n // Collection routes\n if (want.list) {\n collection.get({\n feed: true,\n querySchema: cfg.list?.querySchema ?? CrudDefaultPagination,\n outputSchema: listOut,\n description: cfg.list?.description ?? 'List',\n });\n }\n\n if (want.create) {\n collection.post({\n bodySchema: cfg.create!.bodySchema,\n outputSchema: cfg.create?.outputSchema ?? itemOut,\n description: cfg.create?.description ?? 'Create',\n });\n }\n\n // Item routes via :<name>Id\n collection.routeParameter(idKey as any, paramValueSchema as any, (item: any) => {\n if (want.read) {\n item.get({\n outputSchema: cfg.read?.outputSchema ?? itemOut,\n description: cfg.read?.description ?? 'Read',\n });\n }\n if (want.update) {\n item.patch({\n bodySchema: cfg.update!.bodySchema,\n outputSchema: cfg.update?.outputSchema ?? itemOut,\n description: cfg.update?.description ?? 'Update',\n });\n }\n if (want.remove) {\n item.delete({\n outputSchema: cfg.remove?.outputSchema ?? z.object({ ok: z.literal(true) }),\n description: cfg.remove?.description ?? 'Delete',\n });\n }\n\n // Give extras fully-capable builders (decorate so extras can call .crud again)\n if (extras) extras({ collection: withCrud(collection), item: withCrud(item) });\n\n return item.done();\n });\n\n return collection.done();\n });\n };\n\n return branch;\n}\n\n// -----------------------------------------------------------------------------\n// Optional convenience: re-export a resource() that already has .crud installed\n// -----------------------------------------------------------------------------\n\n/**\n * Drop-in replacement for `resource(...)` that returns a Branch with `.crud()` installed.\n * You can either use this or call `withCrud(resource(...))`.\n * @param base Root path for the resource (e.g. `/v1`).\n * @param inherited Node configuration merged into every leaf.\n * @returns Branch builder that already includes the CRUD helper.\n */\nexport function resourceWithCrud<Base extends string, I extends NodeCfg = {}>(\n base: Base,\n inherited: I,\n) {\n return withCrud(baseResource(base, inherited));\n}\n\n// Re-export the original in case you want both styles from this module\nexport { baseResource as resource };\n","// socket.index.ts (shared client/server)\n\nimport { z } from 'zod';\n\nexport type SocketSchema<Output =unknown> = z.ZodType & {\n __out: Output;\n};\n\nexport type SocketSchemaOutput<Schema extends z.ZodTypeAny> = Schema extends {\n __out: infer Out;\n} ? Out : z.output<Schema>;\n\nexport type SocketEvent<Out = unknown> = {\n message: z.ZodTypeAny;\n /** phantom field, only for typing; not meant to be used at runtime */\n __out: Out;\n};\n\nexport type EventMap = Record<string, SocketEvent<any>>;\n\n/**\n * System event names – shared so server and client\n * don't drift on naming.\n */\nexport type SysEventName = 'sys:connect' | 'sys:disconnect' | 'sys:reconnect' | 'sys:connect_error' | 'sys:ping' | 'sys:pong' | 'sys:room_join' | 'sys:room_leave';\nexport function defineSocketEvents<const C extends SocketConnectionConfig, const Schemas extends Record<string, {\n message: z.ZodTypeAny;\n}>>(config: C, events: Schemas): {\n config: {\n [K in keyof C]: SocketSchema<z.output<C[K]>>;\n };\n events: {\n [K in keyof Schemas]: SocketEvent<z.output<Schemas[K]['message']>>;\n };\n};\n\nexport function defineSocketEvents(config: any, events: any) {\n return { config, events };\n}\n\n\n\nexport type Payload<T extends EventMap, K extends keyof T> = T[K] extends SocketEvent<infer Out> ? Out : never;\nexport type SocketConnectionConfig = {\n joinMetaMessage: z.ZodTypeAny;\n leaveMetaMessage: z.ZodTypeAny;\n pingPayload: z.ZodTypeAny;\n pongPayload: z.ZodTypeAny;\n};\n\nexport type SocketConnectionConfigOutput = {\n joinMetaMessage: SocketSchema<any>;\n leaveMetaMessage: SocketSchema<any>;\n pingPayload: SocketSchema<any>;\n pongPayload: SocketSchema<any>;\n}","import { AnyLeaf, MethodCfg } from \"../core/routesV3.core\";\n\ntype SerializableMethodCfg = Pick<\n MethodCfg,\n | 'description'\n | 'summary'\n | 'docsGroup'\n | 'tags'\n | 'deprecated'\n | 'stability'\n | 'feed'\n | 'docsMeta'\n> & {\n hasBody: boolean;\n hasQuery: boolean;\n hasParams: boolean;\n hasOutput: boolean;\n};\n\nexport type SerializableLeaf = {\n method: string;\n path: string;\n cfg: SerializableMethodCfg;\n};\n\nexport function serializeLeaf(leaf: AnyLeaf): SerializableLeaf {\n const cfg = leaf.cfg;\n\n const tags = Array.isArray(cfg.tags) ? cfg.tags.slice() : [];\n\n return {\n method: leaf.method, // 'get' | 'post' | ...\n path: leaf.path,\n cfg: {\n description: cfg.description,\n summary: cfg.summary,\n docsGroup: cfg.docsGroup,\n tags,\n deprecated: cfg.deprecated,\n stability: cfg.stability,\n feed: !!cfg.feed,\n docsMeta: cfg.docsMeta,\n hasBody: !!cfg.bodySchema || !!cfg.bodyFiles?.length,\n hasQuery: !!cfg.querySchema,\n hasParams: !!cfg.paramsSchema,\n hasOutput: !!cfg.outputSchema,\n },\n };\n}\n","import { AnyLeaf } from \"../core/routesV3.core\";\nimport { SerializableLeaf, serializeLeaf } from \"./serializer\";\n\nexport function renderLeafDocsHTML(leaves: AnyLeaf[]): string {\n const docsLeaves: SerializableLeaf[] = leaves.map(serializeLeaf);\n\n // Safe embedding into <script> / <script type=\"application/json\">\n const leafJson = JSON.stringify(docsLeaves).replace(/</g, '\\\\u003c');\n\n return `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\" />\n <title>API Routes</title>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <style>\n :root {\n --bg: #020617;\n --bg-elevated: #020617;\n --border-subtle: rgba(148, 163, 184, 0.35);\n --border-strong: rgba(148, 163, 184, 0.65);\n --text: #e5e7eb;\n --text-muted: #9ca3af;\n --accent: #38bdf8;\n --accent-soft: rgba(56, 189, 248, 0.12);\n --radius-lg: 12px;\n --radius-sm: 6px;\n --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.7);\n }\n\n * {\n box-sizing: border-box;\n }\n\n body {\n margin: 0;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"SF Pro Text\",\n \"Segoe UI\", sans-serif;\n background: radial-gradient(circle at top left, #0f172a, #020617 50%)\n radial-gradient(circle at bottom right, #020617, #020617 50%);\n color: var(--text);\n -webkit-font-smoothing: antialiased;\n }\n\n .page {\n min-height: 100vh;\n padding: 24px;\n background:\n radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 60%),\n radial-gradient(circle at bottom right, rgba(168, 85, 247, 0.18), transparent 60%);\n }\n\n @media (max-width: 768px) {\n .page {\n padding: 16px;\n }\n }\n\n .shell {\n max-width: 1200px;\n margin: 0 auto;\n background: rgba(15, 23, 42, 0.96);\n border-radius: 18px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n box-shadow: var(--shadow-soft);\n padding: 20px 22px 24px;\n backdrop-filter: blur(28px);\n }\n\n @media (max-width: 768px) {\n .shell {\n padding: 14px 14px 18px;\n }\n }\n\n .header {\n display: flex;\n justify-content: space-between;\n gap: 16px;\n align-items: center;\n margin-bottom: 16px;\n }\n\n .header-main {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .title-row {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n\n .title {\n font-size: 18px;\n font-weight: 600;\n letter-spacing: 0.02em;\n display: inline-flex;\n align-items: center;\n gap: 10px;\n }\n\n .title-pill {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.16em;\n padding: 2px 8px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n color: var(--text-muted);\n background: radial-gradient(circle at top, rgba(148, 163, 184, 0.22), transparent);\n }\n\n .subtitle {\n font-size: 12px;\n color: var(--text-muted);\n }\n\n .stats {\n font-size: 12px;\n color: var(--text-muted);\n white-space: nowrap;\n }\n\n .layout {\n display: grid;\n grid-template-columns: 260px minmax(0, 1fr);\n gap: 18px;\n margin-top: 12px;\n }\n\n @media (max-width: 960px) {\n .layout {\n grid-template-columns: minmax(0, 1fr);\n }\n }\n\n .sidebar {\n padding: 12px;\n border-radius: 14px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n background: radial-gradient(circle at top, rgba(30, 64, 175, 0.45), transparent 55%),\n radial-gradient(circle at bottom, rgba(30, 64, 175, 0.2), transparent 55%),\n rgba(15, 23, 42, 0.92);\n }\n\n .sidebar h2 {\n font-size: 12px;\n text-transform: uppercase;\n letter-spacing: 0.16em;\n color: var(--text-muted);\n margin: 0 0 8px;\n }\n\n .filter-section {\n margin-bottom: 10px;\n }\n\n .filter-section-title {\n font-size: 11px;\n text-transform: uppercase;\n letter-spacing: 0.08em;\n color: var(--text-muted);\n margin-bottom: 6px;\n }\n\n .search-input {\n width: 100%;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n padding: 7px 10px;\n font-size: 12px;\n color: var(--text);\n background: rgba(15, 23, 42, 0.9);\n outline: none;\n }\n\n .search-input::placeholder {\n color: rgba(148, 163, 184, 0.8);\n }\n\n .search-input:focus {\n border-color: var(--accent);\n box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);\n }\n\n .filter-pill-group {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n }\n\n .filter-pill {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n font-size: 11px;\n padding: 3px 6px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.4);\n background: rgba(15, 23, 42, 0.9);\n cursor: pointer;\n user-select: none;\n color: var(--text-muted);\n }\n\n .filter-pill input {\n accent-color: var(--accent);\n }\n\n .group-select {\n width: 100%;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n padding: 6px 10px;\n font-size: 11px;\n background: rgba(15, 23, 42, 0.95);\n color: var(--text);\n outline: none;\n }\n\n .group-select:focus {\n border-color: var(--accent);\n box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);\n }\n\n .main {\n padding: 10px 10px 2px;\n border-radius: 14px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.16), transparent 55%),\n radial-gradient(circle at bottom right, rgba(168, 85, 247, 0.16), transparent 55%),\n rgba(15, 23, 42, 0.95);\n }\n\n .route-list {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n\n .route-card {\n border-radius: 12px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.98));\n padding: 9px 10px;\n box-shadow: 0 10px 30px rgba(15, 23, 42, 0.5);\n }\n\n .route-header {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n align-items: center;\n margin-bottom: 4px;\n }\n\n .method-pill {\n font-size: 10px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.12em;\n padding: 3px 8px;\n border-radius: 999px;\n border: 1px solid transparent;\n background: rgba(30, 64, 175, 0.18);\n color: #e5e7eb;\n }\n\n .method-get {\n background: rgba(22, 163, 74, 0.22);\n border-color: rgba(22, 163, 74, 0.7);\n }\n .method-post {\n background: rgba(59, 130, 246, 0.22);\n border-color: rgba(59, 130, 246, 0.7);\n }\n .method-put {\n background: rgba(234, 179, 8, 0.22);\n border-color: rgba(234, 179, 8, 0.7);\n }\n .method-patch {\n background: rgba(56, 189, 248, 0.22);\n border-color: rgba(56, 189, 248, 0.7);\n }\n .method-delete {\n background: rgba(220, 38, 38, 0.22);\n border-color: rgba(220, 38, 38, 0.7);\n }\n\n .route-path {\n font-family: \"JetBrains Mono\", ui-monospace, SFMono-Regular, Menlo, Monaco,\n Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n font-size: 12px;\n padding: 3px 7px;\n border-radius: 999px;\n background: rgba(15, 23, 42, 0.9);\n border: 1px solid rgba(148, 163, 184, 0.7);\n color: #e5e7eb;\n }\n\n .group-label {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.16em;\n padding: 2px 8px;\n border-radius: 999px;\n background: rgba(15, 23, 42, 0.9);\n border: 1px solid rgba(148, 163, 184, 0.5);\n color: var(--text-muted);\n margin-left: auto;\n }\n\n .route-tags {\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n margin-bottom: 4px;\n margin-top: 2px;\n }\n\n .tag {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.14em;\n padding: 2px 7px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.4);\n color: var(--text-muted);\n background: rgba(15, 23, 42, 0.9);\n }\n\n .tag-not-impl {\n border-color: rgba(248, 113, 113, 0.9);\n background: rgba(239, 68, 68, 0.14);\n color: #fecaca;\n }\n\n .badge {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.14em;\n padding: 2px 7px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n background: rgba(15, 23, 42, 0.9);\n color: var(--text-muted);\n }\n\n .badge-feed {\n border-color: rgba(56, 189, 248, 0.8);\n background: rgba(56, 189, 248, 0.16);\n color: #e0f2fe;\n }\n\n .badge-deprecated {\n border-color: rgba(220, 38, 38, 0.9);\n background: rgba(220, 38, 38, 0.18);\n color: #fee2e2;\n }\n\n .badge-experimental,\n .badge-beta {\n border-color: rgba(168, 85, 247, 0.9);\n background: rgba(168, 85, 247, 0.18);\n color: #f3e8ff;\n }\n\n .route-summary {\n font-size: 12px;\n margin: 2px 0;\n color: var(--text);\n }\n\n .route-description {\n font-size: 11px;\n margin: 0;\n color: var(--text-muted);\n }\n\n .schema-row {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-top: 6px;\n }\n\n .schema-pill {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.14em;\n padding: 2px 7px;\n border-radius: 999px;\n border: 1px dashed rgba(148, 163, 184, 0.7);\n color: rgba(148, 163, 184, 0.9);\n background: rgba(15, 23, 42, 0.95);\n }\n\n .empty-state {\n font-size: 12px;\n color: var(--text-muted);\n padding: 16px 12px;\n border-radius: 10px;\n border: 1px dashed rgba(148, 163, 184, 0.5);\n background: rgba(15, 23, 42, 0.9);\n }\n </style>\n</head>\n<body>\n <div class=\"page\">\n <div class=\"shell\">\n <header class=\"header\">\n <div class=\"header-main\">\n <div class=\"title-row\">\n <div class=\"title\">\n API routes\n <span class=\"title-pill\">Interactive docs</span>\n </div>\n </div>\n <div class=\"subtitle\">\n Introspected from your runtime route leaves.\n </div>\n </div>\n <div id=\"stats\" class=\"stats\"></div>\n </header>\n\n <div class=\"layout\">\n <aside class=\"sidebar\">\n <h2>Filters</h2>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Search</div>\n <input\n id=\"searchInput\"\n class=\"search-input\"\n type=\"search\"\n placeholder=\"Filter by path, group, tag…\"\n />\n </div>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Method</div>\n <div id=\"methodFilters\" class=\"filter-pill-group\"></div>\n </div>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Group</div>\n <select id=\"groupSelect\" class=\"group-select\"></select>\n </div>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Tags</div>\n <div id=\"tagFilters\" class=\"filter-pill-group\"></div>\n </div>\n </aside>\n\n <main class=\"main\">\n <div id=\"routeList\" class=\"route-list\"></div>\n </main>\n </div>\n </div>\n </div>\n\n <script id=\"leaf-data\" type=\"application/json\">${leafJson}</script>\n <script>\n (function () {\n function escapeHtml(str) {\n return String(str)\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#39;');\n }\n\n var raw = document.getElementById('leaf-data').textContent;\n var leaves = raw ? JSON.parse(raw) : [];\n\n var searchInput = document.getElementById('searchInput');\n var methodFiltersEl = document.getElementById('methodFilters');\n var groupSelect = document.getElementById('groupSelect');\n var tagFiltersEl = document.getElementById('tagFilters');\n var routeList = document.getElementById('routeList');\n var statsEl = document.getElementById('stats');\n\n if (!Array.isArray(leaves)) leaves = [];\n\n var allMethods = Array.from(\n new Set(\n leaves.map(function (r) {\n return String(r.method || '').toUpperCase();\n })\n )\n ).sort();\n\n var allGroups = Array.from(\n new Set(\n leaves.map(function (r) {\n return r.cfg && r.cfg.docsGroup ? String(r.cfg.docsGroup) : 'Ungrouped';\n })\n )\n ).sort();\n\n var allTags = Array.from(\n new Set(\n leaves.reduce(function (acc, r) {\n var tags = (r.cfg && r.cfg.tags) || [];\n if (Array.isArray(tags)) {\n for (var i = 0; i < tags.length; i++) acc.push(String(tags[i]));\n }\n return acc;\n }, [])\n )\n ).sort();\n\n function buildFilterUI() {\n // Methods\n methodFiltersEl.innerHTML = '';\n allMethods.forEach(function (m) {\n var label = document.createElement('label');\n label.className = 'filter-pill';\n var cb = document.createElement('input');\n cb.type = 'checkbox';\n cb.value = m;\n cb.checked = true;\n cb.addEventListener('change', applyFilters);\n label.appendChild(cb);\n label.appendChild(document.createTextNode(' ' + m));\n methodFiltersEl.appendChild(label);\n });\n\n // Groups\n groupSelect.innerHTML = '';\n var allOption = document.createElement('option');\n allOption.value = '__all';\n allOption.textContent = 'All groups';\n groupSelect.appendChild(allOption);\n allGroups.forEach(function (g) {\n var opt = document.createElement('option');\n opt.value = g;\n opt.textContent = g;\n groupSelect.appendChild(opt);\n });\n groupSelect.addEventListener('change', applyFilters);\n\n // Tags\n tagFiltersEl.innerHTML = '';\n allTags.forEach(function (t) {\n var label = document.createElement('label');\n label.className = 'filter-pill';\n var cb = document.createElement('input');\n cb.type = 'checkbox';\n cb.value = t;\n cb.addEventListener('change', applyFilters);\n label.appendChild(cb);\n label.appendChild(document.createTextNode(' ' + t));\n tagFiltersEl.appendChild(label);\n });\n }\n\n function routeToHTML(route) {\n var method = String(route.method || '').toUpperCase();\n var methodClass = 'method-' + String(route.method || '').toLowerCase();\n\n var cfg = route.cfg || {};\n var group = cfg.docsGroup || 'Ungrouped';\n\n var summary = cfg.summary || cfg.description || '';\n var description =\n cfg.description && cfg.summary !== cfg.description\n ? cfg.description\n : '';\n\n var tags = Array.isArray(cfg.tags) ? cfg.tags : [];\n var tagHtml = tags\n .map(function (tag) {\n var t = String(tag);\n var extraClass = t === 'not-implemented' ? ' tag-not-impl' : '';\n return '<span class=\"tag' + extraClass + '\">' + escapeHtml(t) + '</span>';\n })\n .join('');\n\n var metaBadges = '';\n if (cfg.feed) {\n metaBadges += '<span class=\"badge badge-feed\">Feed</span>';\n }\n if (cfg.deprecated || cfg.stability === 'deprecated') {\n metaBadges += '<span class=\"badge badge-deprecated\">Deprecated</span>';\n } else if (cfg.stability && cfg.stability !== 'stable') {\n metaBadges +=\n '<span class=\"badge badge-' +\n escapeHtml(cfg.stability) +\n '\">' +\n escapeHtml(String(cfg.stability)) +\n '</span>';\n }\n\n var schemaPills = [];\n if (cfg.hasBody) schemaPills.push('<span class=\"schema-pill\">Body</span>');\n if (cfg.hasQuery) schemaPills.push('<span class=\"schema-pill\">Query</span>');\n if (cfg.hasParams) schemaPills.push('<span class=\"schema-pill\">Params</span>');\n if (cfg.hasOutput) schemaPills.push('<span class=\"schema-pill\">Response</span>');\n\n var schemaHtml =\n schemaPills.length > 0\n ? '<div class=\"schema-row\">' + schemaPills.join('') + '</div>'\n : '';\n\n return (\n '<article class=\"route-card\">' +\n '<header class=\"route-header\">' +\n '<span class=\"method-pill ' +\n methodClass +\n '\">' +\n method +\n '</span>' +\n '<code class=\"route-path\">' +\n escapeHtml(route.path || '') +\n '</code>' +\n (group\n ? '<span class=\"group-label\">' + escapeHtml(String(group)) + '</span>'\n : '') +\n '</header>' +\n '<div class=\"route-tags\">' +\n tagHtml +\n metaBadges +\n '</div>' +\n (summary\n ? '<p class=\"route-summary\">' + escapeHtml(String(summary)) + '</p>'\n : '') +\n (description\n ? '<p class=\"route-description\">' +\n escapeHtml(String(description)) +\n '</p>'\n : '') +\n schemaHtml +\n '</article>'\n );\n }\n\n function applyFilters() {\n var query = searchInput.value.toLowerCase().trim();\n\n var activeMethods = Array.prototype.slice\n .call(methodFiltersEl.querySelectorAll('input[type=\"checkbox\"]:checked'))\n .map(function (cb) {\n return cb.value;\n });\n\n var groupValue = groupSelect.value;\n var activeTags = Array.prototype.slice\n .call(tagFiltersEl.querySelectorAll('input[type=\"checkbox\"]:checked'))\n .map(function (cb) {\n return cb.value;\n });\n\n var filtered = leaves.filter(function (route) {\n var cfg = route.cfg || {};\n\n if (\n activeMethods.length &&\n activeMethods.indexOf(String(route.method || '').toUpperCase()) === -1\n ) {\n return false;\n }\n\n if (groupValue && groupValue !== '__all') {\n var g = cfg.docsGroup || 'Ungrouped';\n if (g !== groupValue) return false;\n }\n\n if (activeTags.length) {\n var tags = Array.isArray(cfg.tags) ? cfg.tags : [];\n var hasAny = activeTags.some(function (t) {\n return tags.indexOf(t) !== -1;\n });\n if (!hasAny) return false;\n }\n\n if (query) {\n var haystack =\n String(route.path || '') +\n ' ' +\n String(cfg.summary || '') +\n ' ' +\n String(cfg.description || '') +\n ' ' +\n (Array.isArray(cfg.tags) ? cfg.tags.join(' ') : '') +\n ' ' +\n String(cfg.docsGroup || '');\n if (haystack.toLowerCase().indexOf(query) === -1) return false;\n }\n\n return true;\n });\n\n if (statsEl) {\n statsEl.textContent = filtered.length + ' routes';\n }\n\n if (!filtered.length) {\n routeList.innerHTML =\n '<div class=\"empty-state\">No routes match the current filters.</div>';\n } else {\n routeList.innerHTML = filtered.map(routeToHTML).join('');\n }\n }\n\n buildFilterUI();\n searchInput.addEventListener('input', applyFilters);\n\n // Initial render\n statsEl.textContent = leaves.length + ' routes';\n applyFilters();\n })();\n </script>\n</body>\n</html>`;\n}\n"],"mappings":";AAAA,SAAS,SAAS;AAalB,IAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,OAAO,EAAE,OAAO,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,QAAQ,EAAE;AACrD,CAAC;AAED,IAAM,kBAAkB,uBAAuB,SAAS,EAAE,QAAQ,uBAAuB,MAAM,CAAC,CAAC,CAAC;AAYlG,IAAM,0BAA0B,EAAE,OAAO;AAAA,EACvC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC;AAAA,EAC1B,YAAY,EAAE,OAAO,EAAE,SAAS;AAClC,CAAC;AAED,SAAS,uBAAyD,QAAW;AAC3E,MAAI,UAAU,EAAE,kBAAkB,EAAE,YAAY;AAC9C,YAAQ,KAAK,+DAA+D;AAC5E,WAAO,EAAE,OAAO;AAAA,MACd,YAAY;AAAA,IACd,CAAC;AAAA,EACH;AAEA,QAAM,OAAQ,UAA2B,EAAE,OAAO,CAAC,CAAC;AACpD,SAAO,KAAK,OAAO;AAAA,IACjB,YAAY;AAAA,EACd,CAAC;AACH;AAEA,SAAS,wBAA0D,QAAW;AAC5E,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,kBAAkB,EAAE,UAAU;AAChC,WAAO,EAAE,OAAO;AAAA,MACd,OAAO;AAAA,M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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+P3D;","names":["z","z","mergeSchemas"]}
1
+ {"version":3,"sources":["../src/core/routesV3.builder.ts","../src/core/routesV3.core.ts","../src/core/routesV3.finalize.ts","../src/crud/routesV3.crud.ts","../src/sockets/socket.index.ts","../src/docs/serializer.ts","../src/docs/docs.ts"],"sourcesContent":["import { z } from 'zod';\nimport {\n AnyLeaf,\n Append,\n HttpMethod,\n Leaf,\n Merge,\n MergeArray,\n MethodCfg,\n NodeCfg,\n Prettify,\n} from './routesV3.core';\n\nconst defaultFeedQuerySchema = z.object({\n cursor: z.string().optional(),\n limit: z.coerce.number().min(1).max(100).default(20),\n});\n\nconst paginationField = defaultFeedQuerySchema.optional().default(defaultFeedQuerySchema.parse({}));\ntype PaginationField = typeof paginationField;\n\ntype ZodTypeAny = z.ZodTypeAny;\ntype ParamZod<Name extends string, S extends ZodTypeAny> = z.ZodObject<{ [K in Name]: S }>;\ntype ZodArrayAny = z.ZodArray<ZodTypeAny>;\ntype ZodObjectAny = z.ZodObject<any>;\ntype AnyZodObject = z.ZodObject<any>;\ntype MergedParamsResult<PS, Name extends string, P extends ZodTypeAny> = PS extends ZodTypeAny\n ? z.ZodIntersection<PS, ParamZod<Name, P>>\n : ParamZod<Name, P>;\n\nconst defaultFeedOutputSchema = z.object({\n items: z.array(z.unknown()),\n nextCursor: z.string().optional(),\n});\n\nfunction augmentFeedQuerySchema<Q extends ZodTypeAny | undefined>(schema: Q) {\n if (schema && !(schema instanceof z.ZodObject)) {\n console.warn('Feed queries must be a ZodObject; default pagination applied.');\n return z.object({\n pagination: paginationField,\n });\n }\n\n const base = (schema as ZodObjectAny) ?? z.object({});\n return base.extend({\n pagination: paginationField,\n });\n}\n\nfunction augmentFeedOutputSchema<O extends ZodTypeAny | undefined>(schema: O) {\n if (!schema) return defaultFeedOutputSchema;\n if (schema instanceof z.ZodArray) {\n return z.object({\n items: schema,\n nextCursor: z.string().optional(),\n });\n }\n if (schema instanceof z.ZodObject) {\n const shape = (schema as any).shape ? (schema as any).shape : (schema as any)._def?.shape?.();\n const hasItems = Boolean(shape?.items);\n if (hasItems) {\n return schema.extend({ nextCursor: z.string().optional() });\n }\n return z.object({\n items: z.array(schema as ZodTypeAny),\n nextCursor: z.string().optional(),\n });\n }\n return z.object({\n items: z.array(schema as ZodTypeAny),\n nextCursor: z.string().optional(),\n });\n}\n\n/**\n * Runtime helper that mirrors the typed merge used by the builder.\n * @param a Previously merged params schema inherited from parent segments.\n * @param b Newly introduced params schema.\n * @returns Intersection of schemas when both exist, otherwise whichever is defined.\n */\nfunction mergeSchemas<A extends ZodTypeAny, B extends ZodTypeAny>(a: A, b: B): ZodTypeAny;\nfunction mergeSchemas<A extends ZodTypeAny>(a: A, b: undefined): A;\nfunction mergeSchemas<B extends ZodTypeAny>(a: undefined, b: B): B;\nfunction mergeSchemas(a: ZodTypeAny | undefined, b: ZodTypeAny | undefined): ZodTypeAny | undefined;\nfunction mergeSchemas(a: ZodTypeAny | undefined, b: ZodTypeAny | undefined) {\n if (a && b) return z.intersection(a as any, b as any);\n return (a ?? b) as ZodTypeAny | undefined;\n}\n\ntype FeedQuerySchema<C extends MethodCfg> = z.ZodObject<any>;\n\ntype FeedOutputSchema<C extends MethodCfg> = C['outputSchema'] extends ZodArrayAny\n ? z.ZodObject<{\n items: C['outputSchema'];\n nextCursor: z.ZodOptional<z.ZodString>;\n }>\n : C['outputSchema'] extends ZodTypeAny\n ? z.ZodObject<{\n items: z.ZodArray<C['outputSchema']>;\n nextCursor: z.ZodOptional<z.ZodString>;\n }>\n : typeof defaultFeedOutputSchema;\n\ntype BaseMethodCfg<C extends MethodCfg> = Merge<\n Omit<MethodCfg, 'querySchema' | 'outputSchema' | 'feed'>,\n Omit<C, 'querySchema' | 'outputSchema' | 'feed'>\n>;\n\ntype FeedField<C extends MethodCfg> = C['feed'] extends true ? { feed: true } : { feed?: boolean };\n\ntype AddPaginationToQuery<Q extends AnyZodObject | undefined> = Q extends z.ZodObject<\n infer Shape\n>\n ? z.ZodObject<Shape & { pagination: PaginationField }>\n : z.ZodObject<{ pagination: PaginationField }>;\n\ntype FeedQueryField<C extends MethodCfg> = {\n querySchema: AddPaginationToQuery<\n C['querySchema'] extends AnyZodObject ? C['querySchema'] : undefined\n >;\n};\n\ntype NonFeedQueryField<C extends MethodCfg> = C['querySchema'] extends ZodTypeAny\n ? { querySchema: C['querySchema'] }\n : { querySchema?: undefined };\n\ntype FeedOutputField<C extends MethodCfg> = { outputSchema: FeedOutputSchema<C> };\n\ntype NonFeedOutputField<C extends MethodCfg> = C['outputSchema'] extends ZodTypeAny\n ? { outputSchema: C['outputSchema'] }\n : { outputSchema?: undefined };\n\ntype ParamsField<C extends MethodCfg, PS> = C['paramsSchema'] extends ZodTypeAny\n ? { paramsSchema: C['paramsSchema'] }\n : { paramsSchema: PS };\n\ntype EffectiveFeedFields<C extends MethodCfg, PS> = C['feed'] extends true\n ? FeedField<C> & FeedQueryField<C> & FeedOutputField<C> & ParamsField<C, PS>\n : FeedField<C> & NonFeedQueryField<C> & NonFeedOutputField<C> & ParamsField<C, PS>;\n\ntype EffectiveCfg<C extends MethodCfg, PS> = Prettify<\n Merge<MethodCfg, BaseMethodCfg<C> & EffectiveFeedFields<C, PS>>\n>;\n\ntype BuiltLeaf<\n M extends HttpMethod,\n Base extends string,\n I extends NodeCfg,\n C extends MethodCfg,\n PS,\n> = Leaf<M, Base, Merge<I, EffectiveCfg<C, PS>>>;\n\n/** Builder surface used by `resource(...)` to accumulate leaves. */\nexport interface Branch<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodTypeAny | undefined,\n> {\n // --- structure ---\n /**\n * Enter or define a static child segment.\n * Optionally accepts extra config and/or a builder to populate nested routes.\n * @param name Child segment literal (no leading slash).\n * @param cfg Optional node configuration to merge for descendants.\n * @param builder Callback to produce leaves for the child branch.\n */\n sub<Name extends string, J extends NodeCfg>(\n name: Name,\n cfg?: J,\n ): Branch<`${Base}/${Name}`, Acc, Merge<I, NonNullable<J>>, PS>;\n\n sub<Name extends string, J extends NodeCfg | undefined, R extends readonly AnyLeaf[]>(\n name: Name,\n cfg: J,\n builder: (r: Branch<`${Base}/${Name}`, readonly [], Merge<I, NonNullable<J>>, PS>) => R,\n ): Branch<Base, Append<Acc, R[number]>, Merge<I, NonNullable<J>>, PS>;\n\n sub<Name extends string, R extends readonly AnyLeaf[]>(\n name: Name,\n builder: (r: Branch<`${Base}/${Name}`, readonly [], I, PS>) => R,\n ): Branch<Base, MergeArray<Acc, R>, I, PS>;\n\n // --- parameterized segment (single signature) ---\n /**\n * Introduce a `:param` segment and merge its schema into downstream leaves.\n * @param name Parameter key (without leading colon).\n * @param paramsSchema Zod schema for the parameter value.\n * @param builder Callback that produces leaves beneath the parameterized segment.\n */\n routeParameter<Name extends string, P extends ZodTypeAny, R extends readonly AnyLeaf[]>(\n name: Name,\n paramsSchema: P,\n builder: (\n r: Branch<\n `${Base}/:${Name}`,\n readonly [],\n I,\n MergedParamsResult<PS, Name, P>\n >,\n ) => R,\n ): Branch<Base, MergeArray<Acc, R>, I, MergedParamsResult<PS, Name, P>>;\n\n // --- flags inheritance ---\n /**\n * Merge additional node configuration that subsequent leaves will inherit.\n * @param cfg Partial node configuration.\n */\n with<J extends NodeCfg>(cfg: J): Branch<Base, Acc, Merge<I, J>, PS>;\n\n // --- methods (return Branch to keep chaining) ---\n /**\n * Register a GET leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n get<C extends MethodCfg>(\n cfg: C,\n ): Branch<\n Base,\n Append<Acc, Prettify<BuiltLeaf<'get', Base, I, C, PS>>>,\n I,\n PS\n >;\n\n /**\n * Register a POST leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n post<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'post', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n /**\n * Register a PUT leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n put<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'put', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n /**\n * Register a PATCH leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n patch<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'patch', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n /**\n * Register a DELETE leaf at the current path.\n * @param cfg Method configuration (schemas, flags, descriptions, etc).\n */\n delete<C extends Omit<MethodCfg, 'feed'>>(\n cfg: C,\n ): Branch<\n Base,\n Append<\n Acc,\n Prettify<BuiltLeaf<'delete', Base, I, Merge<C, { feed: false }>, PS>>\n >,\n I,\n PS\n >;\n\n // --- finalize this subtree ---\n /**\n * Finish the branch and return the collected leaves.\n * @returns Readonly tuple of accumulated leaves.\n */\n done(): Readonly<Acc>;\n}\n\n/**\n * Start building a resource at the given base path.\n * @param base Root path for the resource (e.g. `/v1`).\n * @param inherited Optional node configuration applied to all descendants.\n * @returns Root `Branch` instance used to compose the route tree.\n */\nexport function resource<Base extends string, I extends NodeCfg = {}>(\n base: Base,\n inherited?: I,\n): Branch<Base, readonly [], I, undefined> {\n const rootBase = base;\n const rootInherited: NodeCfg = { ...(inherited as NodeCfg) };\n\n function makeBranch<Base2 extends string, I2 extends NodeCfg, PS2 extends ZodTypeAny | undefined>(\n base2: Base2,\n inherited2: I2,\n mergedParamsSchema?: PS2,\n ) {\n const stack: AnyLeaf[] = [];\n let currentBase: string = base2;\n let inheritedCfg: NodeCfg = { ...(inherited2 as NodeCfg) };\n let currentParamsSchema: PS2 = mergedParamsSchema as PS2;\n\n function add<M extends HttpMethod, C extends MethodCfg>(method: M, cfg: C) {\n // If the method didn’t provide a paramsSchema, inject the active merged one.\n const effectiveParamsSchema = (cfg.paramsSchema ?? currentParamsSchema) as PS2 | undefined;\n const effectiveQuerySchema =\n cfg.feed === true ? augmentFeedQuerySchema(cfg.querySchema) : cfg.querySchema;\n const effectiveOutputSchema =\n cfg.feed === true ? augmentFeedOutputSchema(cfg.outputSchema) : cfg.outputSchema;\n\n const fullCfg = (\n effectiveParamsSchema\n ? {\n ...inheritedCfg,\n ...cfg,\n paramsSchema: effectiveParamsSchema,\n ...(effectiveQuerySchema ? { querySchema: effectiveQuerySchema } : {}),\n ...(effectiveOutputSchema ? { outputSchema: effectiveOutputSchema } : {}),\n }\n : {\n ...inheritedCfg,\n ...cfg,\n ...(effectiveQuerySchema ? { querySchema: effectiveQuerySchema } : {}),\n ...(effectiveOutputSchema ? { outputSchema: effectiveOutputSchema } : {}),\n }\n ) as any;\n\n const leaf = {\n method,\n path: currentBase as Base2,\n cfg: fullCfg,\n } as const;\n\n stack.push(leaf as unknown as AnyLeaf);\n\n // Return same runtime obj, but with Acc including this new leaf\n return api as unknown as Branch<Base2, Append<readonly [], typeof leaf>, I2, PS2>;\n }\n\n const api: any = {\n // compose a plain subpath (optional cfg) with optional builder\n sub<Name extends string, J extends NodeCfg | undefined = undefined>(\n name: Name,\n cfgOrBuilder?: J | ((r: any) => readonly AnyLeaf[]),\n maybeBuilder?: (r: any) => readonly AnyLeaf[],\n ) {\n let cfg: NodeCfg | undefined;\n let builder: ((r: any) => readonly AnyLeaf[]) | undefined;\n\n if (typeof cfgOrBuilder === 'function') {\n builder = cfgOrBuilder as any;\n } else {\n cfg = cfgOrBuilder as NodeCfg | undefined;\n builder = maybeBuilder;\n }\n\n const childBase = `${currentBase}/${name}` as const;\n const childInherited = { ...inheritedCfg, ...(cfg ?? {}) } as Merge<I2, NonNullable<J>>;\n\n if (builder) {\n // params schema PS2 flows through unchanged on plain sub\n const child = makeBranch(childBase, childInherited, currentParamsSchema);\n const leaves = builder(child) as readonly AnyLeaf[];\n for (const l of leaves) stack.push(l);\n return api as Branch<\n Base2,\n Append<readonly [], (typeof leaves)[number]>,\n typeof childInherited,\n PS2\n >;\n } else {\n currentBase = childBase;\n inheritedCfg = childInherited;\n return api as Branch<`${Base2}/${Name}`, readonly [], typeof childInherited, PS2>;\n }\n },\n\n // the single param function: name + schema + builder\n routeParameter<Name extends string, P extends ZodTypeAny, R extends readonly AnyLeaf[]>(\n name: Name,\n paramsSchema: P,\n builder: (\n r: Branch<\n `${Base2}/:${Name}`,\n readonly [],\n I2,\n MergedParamsResult<PS2, Name, P>\n >,\n ) => R,\n ) {\n const childBase = `${currentBase}/:${name}` as const;\n // Wrap the value schema under the param name before merging with inherited params schema\n const paramObj: ParamZod<Name, P> = z.object({ [name]: paramsSchema } as Record<Name, P>);\n const childParams = (currentParamsSchema\n ? mergeSchemas(currentParamsSchema, paramObj)\n : paramObj) as MergedParamsResult<PS2, Name, P>;\n const child = makeBranch(childBase, inheritedCfg as I2, childParams);\n const leaves = builder(child) as readonly AnyLeaf[];\n for (const l of leaves) stack.push(l);\n return api as Branch<\n Base2,\n Append<readonly [], (typeof leaves)[number]>,\n I2,\n MergedParamsResult<PS2, Name, P>\n >;\n },\n\n with<J extends NodeCfg>(cfg: J) {\n inheritedCfg = { ...inheritedCfg, ...cfg };\n return api as Branch<Base2, readonly [], Merge<I2, J>, PS2>;\n },\n\n // methods (inject current params schema if missing)\n get<C extends MethodCfg>(cfg: C) {\n return add('get', cfg);\n },\n post<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('post', { ...cfg, feed: false });\n },\n put<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('put', { ...cfg, feed: false });\n },\n patch<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('patch', { ...cfg, feed: false });\n },\n delete<C extends Omit<MethodCfg, 'feed'>>(cfg: C) {\n return add('delete', { ...cfg, feed: false });\n },\n\n done() {\n return stack;\n },\n };\n\n return api as Branch<Base2, readonly [], I2, PS2>;\n }\n\n // Root branch starts with no params schema (PS = undefined)\n return makeBranch(rootBase, rootInherited, undefined);\n}\n\n/**\n * Merge two readonly tuples (preserves literal tuple information).\n * @param arr1 First tuple.\n * @param arr2 Second tuple.\n * @returns New tuple containing values from both inputs.\n */\nexport const mergeArrays = <T extends readonly any[], S extends readonly any[]>(\n arr1: T,\n arr2: S,\n) => {\n return [...arr1, ...arr2] as [...T, ...S];\n};\n","import { z, ZodTypeAny } from 'zod';\n\n/** Supported HTTP verbs for the routes DSL. */\nexport type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';\n\n/** Declarative description of a multipart upload field. */\nexport type FileField = {\n /** Form field name used for uploads. */\n name: string;\n /** Maximum number of files accepted for this field. */\n maxCount: number;\n};\n\n/** Configuration that applies to an entire branch of the route tree. */\nexport type NodeCfg = {\n /** @deprecated. Does nothing. */\n authenticated?: boolean;\n};\n\n/** Per-method configuration merged with inherited node config. */\nexport type MethodCfg = {\n /** Zod schema describing the request body. */\n bodySchema?: ZodTypeAny;\n /** Zod schema describing the query string. */\n querySchema?: ZodTypeAny;\n /** Zod schema describing path params (overrides inferred params). */\n paramsSchema?: ZodTypeAny;\n /** Zod schema describing the response payload. */\n outputSchema?: ZodTypeAny;\n /** Multipart upload definitions for the route. */\n bodyFiles?: FileField[];\n /** Marks the route as an infinite feed (enables cursor helpers). */\n feed?: boolean;\n\n /** Optional human-readable description for docs/debugging. */\n description?: string;\n /**\n * Short one-line summary for docs list views.\n * Shown in navigation / tables instead of the full description.\n */\n summary?: string;\n /**\n * Group name used for navigation sections in docs UIs.\n * e.g. \"Users\", \"Billing\", \"Auth\".\n */\n docsGroup?: string;\n /**\n * Tags that can be used to filter / facet in interactive docs.\n * e.g. [\"users\", \"admin\", \"internal\"].\n */\n tags?: string[];\n /**\n * Mark the route as deprecated in docs.\n * Renderers can badge this and/or hide by default.\n */\n deprecated?: boolean;\n /**\n * Optional stability information for the route.\n * Renderers can surface this prominently.\n */\n stability?: 'experimental' | 'beta' | 'stable' | 'deprecated';\n /**\n * Hide this route from public docs while keeping it usable in code.\n */\n docsHidden?: boolean;\n /**\n * Arbitrary extra metadata for docs renderers.\n * Can be used for auth requirements, rate limits, feature flags, etc.\n */\n docsMeta?: Record<string, unknown>;\n};\n\n/** Immutable representation of a single HTTP route in the tree. */\nexport type Leaf<M extends HttpMethod, P extends string, C extends MethodCfg> = {\n /** Lowercase HTTP method (get/post/...). */\n readonly method: M;\n /** Concrete path for the route (e.g. `/v1/users/:userId`). */\n readonly path: P;\n /** Readonly snapshot of route configuration. */\n readonly cfg: Readonly<C>;\n};\n\n/** Convenience union covering all generated leaves. */\nexport type AnyLeaf = Leaf<HttpMethod, string, MethodCfg>;\n\n/** Merge two object types while keeping nice IntelliSense output. */\nexport type Merge<A, B> = Prettify<Omit<A, keyof B> & B>;\n\n/** Append a new element to a readonly tuple type. */\nexport type Append<T extends readonly unknown[], X> = [...T, X];\n\n/** Concatenate two readonly tuple types. */\nexport type MergeArray<A extends readonly unknown[], B extends readonly unknown[]> = [\n ...A,\n ...B,\n];\n\n// helpers (optional)\ntype SegmentParams<S extends string> = S extends `:${infer P}` ? P : never;\ntype Split<S extends string> = S extends ''\n ? []\n : S extends `${infer A}/${infer B}`\n ? [A, ...Split<B>]\n : [S];\ntype ExtractParamNames<Path extends string> = SegmentParams<Split<Path>[number]>;\n\n/** Derive a params object type from a literal route string. */\nexport type ExtractParamsFromPath<Path extends string> =\n ExtractParamNames<Path> extends never ? never : Record<ExtractParamNames<Path>, string | number>;\n\n/**\n * Interpolate `:params` in a path using the given values.\n * @param path Literal route string containing `:param` segments.\n * @param params Object of parameter values to interpolate.\n * @returns Path string with parameters substituted.\n */\nexport function compilePath<Path extends string>(path: Path, params: ExtractParamsFromPath<Path>) {\n if (!params) return path;\n return path.replace(/:([A-Za-z0-9_]+)/g, (_, k) => {\n const v = (params as any)[k];\n if (v === undefined || v === null) throw new Error(`Missing param :${k}`);\n return String(v);\n });\n}\n\n/**\n * Build a deterministic cache key for the given leaf.\n * The key matches the shape consumed by React Query helpers.\n * @param args.leaf Leaf describing the endpoint.\n * @param args.params Optional params used to build the path.\n * @param args.query Optional query payload.\n * @returns Tuple suitable for React Query cache keys.\n */\ntype SplitPath<P extends string> = P extends ''\n ? []\n : P extends `${infer A}/${infer B}`\n ? [A, ...SplitPath<B>]\n : [P];\nexport function buildCacheKey<L extends AnyLeaf>(args: {\n leaf: L;\n params?: ExtractParamsFromPath<L['path']>;\n query?: InferQuery<L>;\n}) {\n let p = args.leaf.path;\n if (args.params) {\n p = compilePath<L['path']>(p, args.params);\n }\n return [args.leaf.method, ...(p.split('/').filter(Boolean) as SplitPath<typeof p>), args.query ?? {}] as const;\n}\n\n/** Infer params either from the explicit params schema or from the path literal. */\nexport type InferParams<L extends AnyLeaf> = L['cfg']['paramsSchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['paramsSchema']>\n : ExtractParamsFromPath<L['path']>;\n\n/** Infer query shape from a Zod schema when present. */\nexport type InferQuery<L extends AnyLeaf> = L['cfg']['querySchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['querySchema']>\n : never;\n\n/** Infer request body shape from a Zod schema when present. */\nexport type InferBody<L extends AnyLeaf> = L['cfg']['bodySchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['bodySchema']>\n : never;\n\n/** Infer handler output shape from a Zod schema. Defaults to unknown. */\nexport type InferOutput<L extends AnyLeaf> = L['cfg']['outputSchema'] extends ZodTypeAny\n ? z.infer<L['cfg']['outputSchema']>\n : unknown;\n\n/** Render a type as if it were a simple object literal. */\nexport type Prettify<T> = { [K in keyof T]: T[K] } & {};\n","// TODO:\n// * use this as a transform that infers the types from Zod, to only pass the types around instead of the full schemas -> make converters that go both ways (data to schema, schema to data)\n// * consider moving to core package\n// * update server and client side to use this type instead of raw zod schemas \nimport { AnyLeaf, HttpMethod, Prettify } from './routesV3.core';\n\n/** Build the key type for a leaf — distributive so method/path stay paired. */\nexport type KeyOf<L extends AnyLeaf> = L extends AnyLeaf\n ? `${Uppercase<L['method']>} ${L['path']}`\n : never;\n\n// From a tuple of leaves, get the union of keys (pairwise, no cartesian blow-up)\ntype KeysOf<Leaves extends readonly AnyLeaf[]> = KeyOf<Leaves[number]>;\n\n// Parse method & path out of a key\ntype MethodFromKey<K extends string> = K extends `${infer M} ${string}` ? Lowercase<M> : never;\ntype PathFromKey<K extends string> = K extends `${string} ${infer P}` ? P : never;\n\n// Given Leaves and a Key, pick the exact leaf that matches method+path\ntype LeafForKey<Leaves extends readonly AnyLeaf[], K extends string> = Extract<\n Leaves[number],\n { method: MethodFromKey<K> & HttpMethod; path: PathFromKey<K> }\n>;\n\n/**\n * Freeze a leaf tuple into a registry with typed key lookups.\n * @param leaves Readonly tuple of leaves produced by the builder DSL.\n * @returns Registry containing the leaves array and a `byKey` lookup map.\n */\nexport function finalize<const L extends readonly AnyLeaf[]>(leaves: L) {\n type Keys = KeysOf<L>;\n type MapByKey = { [K in Keys]: Prettify<LeafForKey<L, K>> };\n\n const byKey = Object.fromEntries(\n leaves.map((l) => [`${l.method.toUpperCase()} ${l.path}`, l] as const),\n ) as unknown as MapByKey;\n\n const log = (logger: { system: (...args: unknown[]) => void }) => {\n logger.system('Finalized routes:');\n (Object.keys(byKey) as Keys[]).forEach((k) => {\n const leaf = byKey[k];\n logger.system(`- ${k}`);\n });\n };\n\n return { all: leaves, byKey, log };\n}\n\n/** Nominal type alias for a finalized registry. */\nexport type Registry<R extends ReturnType<typeof finalize>> = R;\n\ntype FilterRoute<\n T extends readonly AnyLeaf[],\n F extends string,\n Acc extends readonly AnyLeaf[] = [],\n> = T extends readonly [infer First extends AnyLeaf, ...infer Rest extends AnyLeaf[]]\n ? First extends { path: `${string}${F}${string}` }\n ? FilterRoute<Rest, F, [...Acc, First]>\n : FilterRoute<Rest, F, Acc>\n : Acc;\n\ntype UpperCase<S extends string> = S extends `${infer First}${infer Rest}`\n ? `${Uppercase<First>}${UpperCase<Rest>}`\n : S;\n\ntype Routes<T extends readonly AnyLeaf[], F extends string> = FilterRoute<T, F>;\ntype ByKey<\n T extends readonly AnyLeaf[],\n Acc extends Record<string, AnyLeaf> = {},\n> = T extends readonly [infer First extends AnyLeaf, ...infer Rest extends AnyLeaf[]]\n ? ByKey<Rest, Acc & { [K in `${UpperCase<First['method']>} ${First['path']}`]: First }>\n : Acc;\n\n/**\n * Convenience helper for extracting a subset of routes by path fragment.\n * @param T Tuple of leaves produced by the DSL.\n * @param F String fragment to match against the route path.\n */\nexport type SubsetRoutes<T extends readonly AnyLeaf[], F extends string> = {\n byKey: ByKey<Routes<T, F>>;\n all: Routes<T, F>;\n};\n","// routesV3.crud.ts\n// -----------------------------------------------------------------------------\n// Add a first-class .crud() helper to the routesV3 DSL, without touching the\n// core builder. This file:\n// 1) Declares types + module augmentation to extend Branch<...> with .crud\n// 2) Provides a runtime decorator `withCrud(...)` that installs the method\n// 3) Exports a convenience `resourceWithCrud(...)` wrapper (optional)\n// -----------------------------------------------------------------------------\n\nimport { z, ZodType } from 'zod';\nimport {\n resource as baseResource,\n type Branch as _Branch, // import type so we can augment it\n} from '../core/routesV3.builder';\nimport { type AnyLeaf, type Leaf, type NodeCfg } from '../core/routesV3.core';\n\n// -----------------------------------------------------------------------------\n// Small utilities (runtime + types)\n// -----------------------------------------------------------------------------\n/** Default cursor pagination used by list (GET collection). */\nexport const CrudDefaultPagination = z.object({\n limit: z.coerce.number().min(1).max(100).default(20),\n cursor: z.string().optional(),\n});\nconst CrudPaginationField = CrudDefaultPagination.optional().default(CrudDefaultPagination.parse({}));\ntype CrudPaginationField = typeof CrudPaginationField;\ntype AnyCrudZodObject = z.ZodObject<any>;\ntype AddCrudPagination<Q extends AnyCrudZodObject | undefined> = Q extends z.ZodObject<infer Shape>\n ? z.ZodObject<Shape & { pagination: CrudPaginationField }>\n : z.ZodObject<{ pagination: CrudPaginationField }>;\n\n/**\n * Merge two Zod schemas at runtime; matches the typing pattern used in builder.\n * @param a Existing params schema inherited from parent branches.\n * @param b Schema introduced at the current branch.\n * @returns Intersection of schemas when both exist, otherwise whichever is defined.\n */\nexport function mergeSchemas<A extends ZodType | undefined, B extends ZodType | undefined>(\n a: A,\n b: B,\n): A extends ZodType ? (B extends ZodType ? ReturnType<typeof z.intersection<A, B>> : A) : B {\n if (a && b) return z.intersection(a as any, b as any) as any;\n return (a ?? b) as any;\n}\n\n/** Build { [Name]: S } Zod object at the type-level. */\nexport type ParamSchema<Name extends string, S extends ZodType> = z.ZodObject<{\n [K in Name]: S;\n}>;\n\n/** Inject active params schema into a leaf cfg (to match your Leaf typing). */\ntype WithParams<I, P> = P extends ZodType ? Omit<I, 'paramsSchema'> & { paramsSchema: P } : I;\n\n/** Resolve boolean flag: default D unless explicitly false. */\ntype Flag<E, D extends boolean> = E extends false ? false : D;\n\n// -----------------------------------------------------------------------------\n// CRUD config (few knobs, with DX comments)\n// -----------------------------------------------------------------------------\n\n/** Toggle individual CRUD methods; defaults enable all (create/update require body). */\nexport type CrudEnable = {\n /** GET /collection (feed). Defaults to true. */ list?: boolean;\n /** POST /collection. Defaults to true if `create` provided. */ create?: boolean;\n /** GET /collection/:id. Defaults to true. */ read?: boolean;\n /** PATCH /collection/:id. Defaults to true if `update` provided. */ update?: boolean;\n /** DELETE /collection/:id. Defaults to true. */ remove?: boolean;\n};\n\n/** Collection GET config. */\nexport type CrudListCfg = {\n /** Query schema (defaults to cursor pagination). */\n querySchema?: ZodType;\n /** Output schema (defaults to { items: Item[], nextCursor? }). */\n outputSchema?: ZodType;\n /** Optional description string. */\n description?: string;\n};\n\n/** Collection POST config. */\nexport type CrudCreateCfg = {\n /** Body schema for creating an item. */\n bodySchema: ZodType;\n /** Output schema (defaults to itemOutputSchema). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/** Item GET config. */\nexport type CrudReadCfg = {\n /** Output schema (defaults to itemOutputSchema). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/** Item PATCH config. */\nexport type CrudUpdateCfg = {\n /** Body schema for partial updates. */\n bodySchema: ZodType;\n /** Output schema (defaults to itemOutputSchema). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/** Item DELETE config. */\nexport type CrudRemoveCfg = {\n /** Output schema (defaults to { ok: true }). */\n outputSchema?: ZodType;\n /** Optional description. */\n description?: string;\n};\n\n/**\n * CRUD config for `.crud(\"resource\", cfg, extras?)`.\n *\n * It synthesizes `:[resourceName]Id` as the param key and uses `paramSchema` for the value.\n * Prefer passing a **value schema** (e.g. `z.string().uuid()`).\n * As a convenience, a ZodObject of shape `{ [resourceName]Id: schema }` is accepted at runtime too.\n */\nexport type CrudCfg<Name extends string = string> = {\n /**\n * Zod schema for the ID *value* (e.g. `z.string().uuid()`).\n * The parameter key is always `:${name}Id`.\n * (If you pass `z.object({ [name]Id: ... })`, it's accepted at runtime.)\n */\n paramSchema: ZodType;\n\n /**\n * The single-item output shape used by read/create/update by default.\n * List defaults to `{ items: z.array(itemOutputSchema), nextCursor? }`.\n */\n itemOutputSchema: ZodType;\n\n /** Per-method toggles (all enabled by default; create/update require bodies). */\n enable?: CrudEnable;\n\n /** GET /collection configuration. */ list?: CrudListCfg;\n /** POST /collection configuration (enables create). */ create?: CrudCreateCfg;\n /** GET /collection/:id configuration. */ read?: CrudReadCfg;\n /** PATCH /collection/:id configuration (enables update). */ update?: CrudUpdateCfg;\n /** DELETE /collection/:id configuration. */ remove?: CrudRemoveCfg;\n};\n\n// -----------------------------------------------------------------------------\n// Type plumbing to expose generated leaves (so finalize().byKey sees them)\n// -----------------------------------------------------------------------------\n\ntype CrudLeavesTuple<\n Base extends string,\n I extends NodeCfg,\n PS extends ZodType | undefined,\n Name extends string,\n C extends CrudCfg<Name>,\n> = `${Name}Id` extends infer IdName extends string\n ? ParamSchema<IdName, C['paramSchema']> extends infer IdParamZ extends ZodType\n ? [\n // GET /collection\n ...(Flag<\n C['enable'] extends CrudEnable ? C['enable']['list'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'get',\n `${Base}/${Name}`,\n WithParams<\n Omit<I, never> & {\n feed: true;\n querySchema: C['list'] extends CrudListCfg\n ? AddCrudPagination<\n C['list']['querySchema'] extends AnyCrudZodObject\n ? C['list']['querySchema']\n : undefined\n >\n : AddCrudPagination<undefined>;\n outputSchema: C['list'] extends CrudListCfg\n ? C['list']['outputSchema'] extends ZodType\n ? C['list']['outputSchema']\n : z.ZodObject<{\n items: z.ZodArray<C['itemOutputSchema']>;\n nextCursor: z.ZodOptional<z.ZodString>;\n }>\n : z.ZodObject<{\n items: z.ZodArray<C['itemOutputSchema']>;\n nextCursor: z.ZodOptional<z.ZodString>;\n }>;\n description?: string;\n },\n PS\n >\n >,\n ]\n : []),\n\n // POST /collection\n ...((C['create'] extends CrudCreateCfg ? true : false) extends true\n ? Flag<\n C['enable'] extends CrudEnable ? C['enable']['create'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'post',\n `${Base}/${Name}`,\n WithParams<\n Omit<I, never> & {\n bodySchema: C['create'] extends CrudCreateCfg\n ? C['create']['bodySchema']\n : never;\n outputSchema: C['create'] extends CrudCreateCfg\n ? C['create']['outputSchema'] extends ZodType\n ? C['create']['outputSchema']\n : C['itemOutputSchema']\n : never;\n description?: string;\n },\n PS\n >\n >,\n ]\n : []\n : []),\n\n // GET /collection/:id\n ...(Flag<\n C['enable'] extends CrudEnable ? C['enable']['read'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'get',\n `${Base}/${Name}/:${IdName}`,\n WithParams<\n Omit<I, never> & {\n outputSchema: C['read'] extends CrudReadCfg\n ? C['read']['outputSchema'] extends ZodType\n ? C['read']['outputSchema']\n : C['itemOutputSchema']\n : C['itemOutputSchema'];\n description?: string;\n },\n ReturnType<typeof mergeSchemas<PS, IdParamZ>>\n >\n >,\n ]\n : []),\n\n // PATCH /collection/:id\n ...((C['update'] extends CrudUpdateCfg ? true : false) extends true\n ? Flag<\n C['enable'] extends CrudEnable ? C['enable']['update'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'patch',\n `${Base}/${Name}/:${IdName}`,\n WithParams<\n Omit<I, never> & {\n bodySchema: C['update'] extends CrudUpdateCfg\n ? C['update']['bodySchema']\n : never;\n outputSchema: C['update'] extends CrudUpdateCfg\n ? C['update']['outputSchema'] extends ZodType\n ? C['update']['outputSchema']\n : C['itemOutputSchema']\n : never;\n description?: string;\n },\n ReturnType<typeof mergeSchemas<PS, IdParamZ>>\n >\n >,\n ]\n : []\n : []),\n\n // DELETE /collection/:id\n ...(Flag<\n C['enable'] extends CrudEnable ? C['enable']['remove'] : undefined,\n true\n > extends true\n ? [\n Leaf<\n 'delete',\n `${Base}/${Name}/:${IdName}`,\n WithParams<\n Omit<I, never> & {\n outputSchema: C['remove'] extends CrudRemoveCfg\n ? C['remove']['outputSchema'] extends ZodType\n ? C['remove']['outputSchema']\n : z.ZodObject<{ ok: z.ZodLiteral<true> }>\n : z.ZodObject<{ ok: z.ZodLiteral<true> }>;\n description?: string;\n },\n ReturnType<typeof mergeSchemas<PS, IdParamZ>>\n >\n >,\n ]\n : []),\n ]\n : never\n : never;\n\n/** Merge generated leaves + extras into the branch accumulator. */\ntype CrudResultAcc<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodType | undefined,\n Name extends string,\n C extends CrudCfg<Name>,\n Extras extends readonly AnyLeaf[],\n> = [...Acc, ...CrudLeavesTuple<Base, I, PS, Name, C>, ...Extras];\n\n// -----------------------------------------------------------------------------\n// Module augmentation: add the typed `.crud(...)` to Branch<...>\n// -----------------------------------------------------------------------------\n\ndeclare module './../core/routesV3.builder' {\n interface Branch<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodType | undefined,\n > {\n /**\n * Generate opinionated CRUD endpoints for a collection at `/.../<name>`\n * with an item at `/.../<name>/:<name>Id`.\n *\n * Creates (subject to `enable` + presence of create/update bodies):\n * - GET /<name> (feed list)\n * - POST /<name> (create)\n * - GET /<name>/:<name>Id (read item)\n * - PATCH /<name>/:<name>Id (update item)\n * - DELETE /<name>/:<name>Id (remove item)\n *\n * The `extras` callback receives live builders at both collection and item\n * levels so you can add custom subroutes; their leaves are included in the\n * returned Branch type.\n */\n crud<\n Name extends string,\n C extends CrudCfg<Name>,\n Extras extends readonly AnyLeaf[] = readonly [],\n >(\n name: Name,\n cfg: C,\n extras?: (ctx: {\n /** Builder at `/.../<name>` (collection scope). */\n collection: _Branch<`${Base}/${Name}`, readonly [], I, PS>;\n /** Builder at `/.../<name>/:<name>Id` (item scope). */\n item: _Branch<\n `${Base}/${Name}/:${`${Name}Id`}`,\n readonly [],\n I,\n ReturnType<typeof mergeSchemas<PS, ParamSchema<`${Name}Id`, C['paramSchema']>>>\n >;\n }) => Extras,\n ): _Branch<Base, CrudResultAcc<Base, Acc, I, PS, Name, C, Extras>, I, PS>;\n }\n}\n\n// -----------------------------------------------------------------------------\n// Runtime: install .crud on any Branch via decorator\n// -----------------------------------------------------------------------------\n\n/**\n * Decorate a Branch instance so `.crud(...)` is available at runtime.\n * Tip: wrap the root: `withCrud(resource('/v1'))`.\n * @param branch Branch returned by `resource(...)`.\n * @returns Same branch with `.crud(...)` installed.\n */\nexport function withCrud<\n Base extends string,\n Acc extends readonly AnyLeaf[],\n I extends NodeCfg,\n PS extends ZodType | undefined,\n>(branch: _Branch<Base, Acc, I, PS>): _Branch<Base, Acc, I, PS> {\n const b = branch as any;\n if (typeof b.crud === 'function') return branch;\n\n b.crud = function <\n Name extends string,\n C extends CrudCfg<Name>,\n Extras extends readonly AnyLeaf[] = readonly [],\n >(this: any, name: Name, cfg: C, extras?: (ctx: { collection: any; item: any }) => Extras) {\n // Build inside a sub-branch at `/.../<name>` and harvest its leaves.\n return this.sub(name, (collection: any) => {\n const idKey = `${name}Id`;\n\n // Accept a value schema (preferred); but if a z.object({[name]Id: ...}) is provided, use it.\n const s = cfg.paramSchema;\n const isObj =\n s &&\n typeof (s as any)._def === 'object' &&\n (s as any)._def.typeName === 'ZodObject' &&\n typeof (s as any).shape === 'function';\n\n const paramValueSchema =\n isObj && (s as any).shape()[idKey] ? ((s as any).shape()[idKey] as ZodType) : (s as ZodType);\n\n const itemOut = cfg.itemOutputSchema;\n const listOut =\n cfg.list?.outputSchema ??\n z.object({\n items: z.array(itemOut),\n nextCursor: z.string().optional(),\n });\n\n const want = {\n list: cfg.enable?.list !== false,\n create: cfg.enable?.create !== false && !!cfg.create?.bodySchema,\n read: cfg.enable?.read !== false,\n update: cfg.enable?.update !== false && !!cfg.update?.bodySchema,\n remove: cfg.enable?.remove !== false,\n } as const;\n\n // Collection routes\n if (want.list) {\n collection.get({\n feed: true,\n querySchema: cfg.list?.querySchema ?? CrudDefaultPagination,\n outputSchema: listOut,\n description: cfg.list?.description ?? 'List',\n });\n }\n\n if (want.create) {\n collection.post({\n bodySchema: cfg.create!.bodySchema,\n outputSchema: cfg.create?.outputSchema ?? itemOut,\n description: cfg.create?.description ?? 'Create',\n });\n }\n\n // Item routes via :<name>Id\n collection.routeParameter(idKey as any, paramValueSchema as any, (item: any) => {\n if (want.read) {\n item.get({\n outputSchema: cfg.read?.outputSchema ?? itemOut,\n description: cfg.read?.description ?? 'Read',\n });\n }\n if (want.update) {\n item.patch({\n bodySchema: cfg.update!.bodySchema,\n outputSchema: cfg.update?.outputSchema ?? itemOut,\n description: cfg.update?.description ?? 'Update',\n });\n }\n if (want.remove) {\n item.delete({\n outputSchema: cfg.remove?.outputSchema ?? z.object({ ok: z.literal(true) }),\n description: cfg.remove?.description ?? 'Delete',\n });\n }\n\n // Give extras fully-capable builders (decorate so extras can call .crud again)\n if (extras) extras({ collection: withCrud(collection), item: withCrud(item) });\n\n return item.done();\n });\n\n return collection.done();\n });\n };\n\n return branch;\n}\n\n// -----------------------------------------------------------------------------\n// Optional convenience: re-export a resource() that already has .crud installed\n// -----------------------------------------------------------------------------\n\n/**\n * Drop-in replacement for `resource(...)` that returns a Branch with `.crud()` installed.\n * You can either use this or call `withCrud(resource(...))`.\n * @param base Root path for the resource (e.g. `/v1`).\n * @param inherited Node configuration merged into every leaf.\n * @returns Branch builder that already includes the CRUD helper.\n */\nexport function resourceWithCrud<Base extends string, I extends NodeCfg = {}>(\n base: Base,\n inherited: I,\n) {\n return withCrud(baseResource(base, inherited));\n}\n\n// Re-export the original in case you want both styles from this module\nexport { baseResource as resource };\n","// socket.index.ts (shared client/server)\n\nimport { z } from 'zod';\n\nexport type SocketSchema<Output =unknown> = z.ZodType & {\n __out: Output;\n};\n\nexport type SocketSchemaOutput<Schema extends z.ZodTypeAny> = Schema extends {\n __out: infer Out;\n} ? Out : z.output<Schema>;\n\nexport type SocketEvent<Out = unknown> = {\n message: z.ZodTypeAny;\n /** phantom field, only for typing; not meant to be used at runtime */\n __out: Out;\n};\n\nexport type EventMap = Record<string, SocketEvent<any>>;\n\n/**\n * System event names – shared so server and client\n * don't drift on naming.\n */\nexport type SysEventName = 'sys:connect' | 'sys:disconnect' | 'sys:reconnect' | 'sys:connect_error' | 'sys:ping' | 'sys:pong' | 'sys:room_join' | 'sys:room_leave';\nexport function defineSocketEvents<const C extends SocketConnectionConfig, const Schemas extends Record<string, {\n message: z.ZodTypeAny;\n}>>(config: C, events: Schemas): {\n config: {\n [K in keyof C]: SocketSchema<z.output<C[K]>>;\n };\n events: {\n [K in keyof Schemas]: SocketEvent<z.output<Schemas[K]['message']>>;\n };\n};\n\nexport function defineSocketEvents(config: any, events: any) {\n return { config, events };\n}\n\n\n\nexport type Payload<T extends EventMap, K extends keyof T> = T[K] extends SocketEvent<infer Out> ? Out : never;\nexport type SocketConnectionConfig = {\n joinMetaMessage: z.ZodTypeAny;\n leaveMetaMessage: z.ZodTypeAny;\n pingPayload: z.ZodTypeAny;\n pongPayload: z.ZodTypeAny;\n};\n\nexport type SocketConnectionConfigOutput = {\n joinMetaMessage: SocketSchema<any>;\n leaveMetaMessage: SocketSchema<any>;\n pingPayload: SocketSchema<any>;\n pongPayload: SocketSchema<any>;\n}","import { AnyLeaf, MethodCfg } from \"../core/routesV3.core\";\n\ntype SerializableMethodCfg = Pick<\n MethodCfg,\n | 'description'\n | 'summary'\n | 'docsGroup'\n | 'tags'\n | 'deprecated'\n | 'stability'\n | 'feed'\n | 'docsMeta'\n> & {\n hasBody: boolean;\n hasQuery: boolean;\n hasParams: boolean;\n hasOutput: boolean;\n};\n\nexport type SerializableLeaf = {\n method: string;\n path: string;\n cfg: SerializableMethodCfg;\n};\n\nexport function serializeLeaf(leaf: AnyLeaf): SerializableLeaf {\n const cfg = leaf.cfg;\n\n const tags = Array.isArray(cfg.tags) ? cfg.tags.slice() : [];\n\n return {\n method: leaf.method, // 'get' | 'post' | ...\n path: leaf.path,\n cfg: {\n description: cfg.description,\n summary: cfg.summary,\n docsGroup: cfg.docsGroup,\n tags,\n deprecated: cfg.deprecated,\n stability: cfg.stability,\n feed: !!cfg.feed,\n docsMeta: cfg.docsMeta,\n hasBody: !!cfg.bodySchema || !!cfg.bodyFiles?.length,\n hasQuery: !!cfg.querySchema,\n hasParams: !!cfg.paramsSchema,\n hasOutput: !!cfg.outputSchema,\n },\n };\n}\n","import { AnyLeaf } from \"../core/routesV3.core\";\nimport { SerializableLeaf, serializeLeaf } from \"./serializer\";\n\ninterface RenderOptions {\n cspNonce?: string;\n}\n\nconst styles = `\n :root {\n --bg: #020617;\n --bg-elevated: #020617;\n --border-subtle: rgba(148, 163, 184, 0.35);\n --border-strong: rgba(148, 163, 184, 0.65);\n --text: #e5e7eb;\n --text-muted: #9ca3af;\n --accent: #38bdf8;\n --accent-soft: rgba(56, 189, 248, 0.12);\n --radius-lg: 12px;\n --radius-sm: 6px;\n --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.7);\n }\n\n * {\n box-sizing: border-box;\n }\n\n body {\n margin: 0;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"SF Pro Text\",\n \"Segoe UI\", sans-serif;\n background: radial-gradient(circle at top left, #0f172a, #020617 50%)\n radial-gradient(circle at bottom right, #020617, #020617 50%);\n color: var(--text);\n -webkit-font-smoothing: antialiased;\n }\n\n \n .page {\n min-height: 100vh;\n padding: 24px;\n background:\n radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 60%),\n radial-gradient(circle at bottom right, rgba(168, 85, 247, 0.18), transparent 60%);\n }\n\n @media (max-width: 768px) {\n .page {\n padding: 16px;\n }\n }\n\n .shell {\n max-width: 1200px;\n margin: 0 auto;\n background: rgba(15, 23, 42, 0.96);\n border-radius: 18px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n box-shadow: var(--shadow-soft);\n padding: 20px 22px 24px;\n backdrop-filter: blur(28px);\n }\n\n @media (max-width: 768px) {\n .shell {\n padding: 14px 14px 18px;\n }\n }\n\n .header {\n display: flex;\n justify-content: space-between;\n gap: 16px;\n align-items: center;\n margin-bottom: 16px;\n }\n\n .header-main {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .title-row {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n\n .title {\n font-size: 18px;\n font-weight: 600;\n letter-spacing: 0.02em;\n display: inline-flex;\n align-items: center;\n gap: 10px;\n }\n\n .title-pill {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.16em;\n padding: 2px 8px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n color: var(--text-muted);\n background: radial-gradient(circle at top, rgba(148, 163, 184, 0.22), transparent);\n }\n\n .subtitle {\n font-size: 12px;\n color: var(--text-muted);\n }\n\n .stats {\n font-size: 12px;\n color: var(--text-muted);\n white-space: nowrap;\n }\n\n .layout {\n display: grid;\n grid-template-columns: 260px minmax(0, 1fr);\n gap: 18px;\n margin-top: 12px;\n }\n\n @media (max-width: 960px) {\n .layout {\n grid-template-columns: minmax(0, 1fr);\n }\n }\n\n .sidebar {\n padding: 12px;\n border-radius: 14px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n background: radial-gradient(circle at top, rgba(30, 64, 175, 0.45), transparent 55%),\n radial-gradient(circle at bottom, rgba(30, 64, 175, 0.2), transparent 55%),\n rgba(15, 23, 42, 0.92);\n }\n\n .sidebar h2 {\n font-size: 12px;\n text-transform: uppercase;\n letter-spacing: 0.16em;\n color: var(--text-muted);\n margin: 0 0 8px;\n }\n\n .filter-section {\n margin-bottom: 10px;\n }\n\n .filter-section-title {\n font-size: 11px;\n text-transform: uppercase;\n letter-spacing: 0.08em;\n color: var(--text-muted);\n margin-bottom: 6px;\n }\n\n .search-input {\n width: 100%;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n padding: 7px 10px;\n font-size: 12px;\n color: var(--text);\n background: rgba(15, 23, 42, 0.9);\n outline: none;\n }\n\n .search-input::placeholder {\n color: rgba(148, 163, 184, 0.8);\n }\n\n .search-input:focus {\n border-color: var(--accent);\n box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);\n }\n\n .filter-pill-group {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n }\n\n .filter-pill {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n font-size: 11px;\n padding: 3px 6px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.4);\n background: rgba(15, 23, 42, 0.9);\n cursor: pointer;\n user-select: none;\n color: var(--text-muted);\n }\n\n .filter-pill input {\n accent-color: var(--accent);\n }\n\n .group-select {\n width: 100%;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n padding: 6px 10px;\n font-size: 11px;\n background: rgba(15, 23, 42, 0.95);\n color: var(--text);\n outline: none;\n }\n\n .group-select:focus {\n border-color: var(--accent);\n box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);\n }\n\n .main {\n padding: 10px 10px 2px;\n border-radius: 14px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.16), transparent 55%),\n radial-gradient(circle at bottom right, rgba(168, 85, 247, 0.16), transparent 55%),\n rgba(15, 23, 42, 0.95);\n }\n\n .route-list {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n\n .route-card {\n border-radius: 12px;\n border: 1px solid rgba(148, 163, 184, 0.3);\n background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.98));\n padding: 9px 10px;\n box-shadow: 0 10px 30px rgba(15, 23, 42, 0.5);\n }\n\n .route-header {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n align-items: center;\n margin-bottom: 4px;\n }\n\n .method-pill {\n font-size: 10px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.12em;\n padding: 3px 8px;\n border-radius: 999px;\n border: 1px solid transparent;\n background: rgba(30, 64, 175, 0.18);\n color: #e5e7eb;\n }\n\n .method-get {\n background: rgba(22, 163, 74, 0.22);\n border-color: rgba(22, 163, 74, 0.7);\n }\n .method-post {\n background: rgba(59, 130, 246, 0.22);\n border-color: rgba(59, 130, 246, 0.7);\n }\n .method-put {\n background: rgba(234, 179, 8, 0.22);\n border-color: rgba(234, 179, 8, 0.7);\n }\n .method-patch {\n background: rgba(56, 189, 248, 0.22);\n border-color: rgba(56, 189, 248, 0.7);\n }\n .method-delete {\n background: rgba(220, 38, 38, 0.22);\n border-color: rgba(220, 38, 38, 0.7);\n }\n\n .route-path {\n font-family: \"JetBrains Mono\", ui-monospace, SFMono-Regular, Menlo, Monaco,\n Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n font-size: 12px;\n padding: 3px 7px;\n border-radius: 999px;\n background: rgba(15, 23, 42, 0.9);\n border: 1px solid rgba(148, 163, 184, 0.7);\n color: #e5e7eb;\n }\n\n .group-label {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.16em;\n padding: 2px 8px;\n border-radius: 999px;\n background: rgba(15, 23, 42, 0.9);\n border: 1px solid rgba(148, 163, 184, 0.5);\n color: var(--text-muted);\n margin-left: auto;\n }\n\n .route-tags {\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n margin-bottom: 4px;\n margin-top: 2px;\n }\n\n .tag {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.14em;\n padding: 2px 7px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.4);\n color: var(--text-muted);\n background: rgba(15, 23, 42, 0.9);\n }\n\n .tag-not-impl {\n border-color: rgba(248, 113, 113, 0.9);\n background: rgba(239, 68, 68, 0.14);\n color: #fecaca;\n }\n\n .badge {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.14em;\n padding: 2px 7px;\n border-radius: 999px;\n border: 1px solid rgba(148, 163, 184, 0.5);\n background: rgba(15, 23, 42, 0.9);\n color: var(--text-muted);\n }\n\n .badge-feed {\n border-color: rgba(56, 189, 248, 0.8);\n background: rgba(56, 189, 248, 0.16);\n color: #e0f2fe;\n }\n\n .badge-deprecated {\n border-color: rgba(220, 38, 38, 0.9);\n background: rgba(220, 38, 38, 0.18);\n color: #fee2e2;\n }\n\n .badge-experimental,\n .badge-beta {\n border-color: rgba(168, 85, 247, 0.9);\n background: rgba(168, 85, 247, 0.18);\n color: #f3e8ff;\n }\n\n .route-summary {\n font-size: 12px;\n margin: 2px 0;\n color: var(--text);\n }\n\n .route-description {\n font-size: 11px;\n margin: 0;\n color: var(--text-muted);\n }\n\n .schema-row {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-top: 6px;\n }\n\n .schema-pill {\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.14em;\n padding: 2px 7px;\n border-radius: 999px;\n border: 1px dashed rgba(148, 163, 184, 0.7);\n color: rgba(148, 163, 184, 0.9);\n background: rgba(15, 23, 42, 0.95);\n }\n\n .empty-state {\n font-size: 12px;\n color: var(--text-muted);\n padding: 16px 12px;\n border-radius: 10px;\n border: 1px dashed rgba(148, 163, 184, 0.5);\n background: rgba(15, 23, 42, 0.9);\n }`\n\nexport function renderLeafDocsHTML(\n leaves: AnyLeaf[],\n options: RenderOptions = {}\n): string {\n const docsLeaves: SerializableLeaf[] = leaves.map(serializeLeaf);\n\n // Safe embedding into <script> / <script type=\"application/json\">\n const leafJson = JSON.stringify(docsLeaves).replace(/</g, '\\\\u003c');\n\n const nonceAttr = options.cspNonce ? ` nonce=\"${options.cspNonce}\"` : \"\";\n\n return `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\" />\n <title>API Routes</title>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <style${nonceAttr}>\n${styles}\n </style>\n</head>\n<body>\n <div class=\"page\">\n <div class=\"shell\">\n <header class=\"header\">\n <div class=\"header-main\">\n <div class=\"title-row\">\n <div class=\"title\">\n API routes\n <span class=\"title-pill\">Interactive docs</span>\n </div>\n </div>\n <div class=\"subtitle\">\n Introspected from your runtime route leaves.\n </div>\n </div>\n <div id=\"stats\" class=\"stats\"></div>\n </header>\n<div class=\"layout\">\n <aside class=\"sidebar\">\n <h2>Filters</h2>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Search</div>\n <input\n id=\"searchInput\"\n class=\"search-input\"\n type=\"search\"\n placeholder=\"Filter by path, group, tag…\"\n />\n </div>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Method</div>\n <div id=\"methodFilters\" class=\"filter-pill-group\"></div>\n </div>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Group</div>\n <select id=\"groupSelect\" class=\"group-select\"></select>\n </div>\n\n <div class=\"filter-section\">\n <div class=\"filter-section-title\">Tags</div>\n <div id=\"tagFilters\" class=\"filter-pill-group\"></div>\n </div>\n </aside>\n\n <main class=\"main\">\n <div id=\"routeList\" class=\"route-list\"></div>\n </main>\n </div>\n </div>\n </div>\n\n <script id=\"leaf-data\" type=\"application/json\"${nonceAttr}>${leafJson}</script>\n <script${nonceAttr}>\n (function () {\n function escapeHtml(str) {\n return String(str)\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#39;');\n }\n\n var raw = document.getElementById('leaf-data').textContent;\n var leaves = raw ? JSON.parse(raw) : [];\n\n var searchInput = document.getElementById('searchInput');\n var methodFiltersEl = document.getElementById('methodFilters');\n var groupSelect = document.getElementById('groupSelect');\n var tagFiltersEl = document.getElementById('tagFilters');\n var routeList = document.getElementById('routeList');\n var statsEl = document.getElementById('stats');\n\n if (!Array.isArray(leaves)) leaves = [];\n\n var allMethods = Array.from(\n new Set(\n leaves.map(function (r) {\n return String(r.method || '').toUpperCase();\n })\n )\n ).sort();\n\n var allGroups = Array.from(\n new Set(\n leaves.map(function (r) {\n return r.cfg && r.cfg.docsGroup ? String(r.cfg.docsGroup) : 'Ungrouped';\n })\n )\n ).sort();\n\n var allTags = Array.from(\n new Set(\n leaves.reduce(function (acc, r) {\n var tags = (r.cfg && r.cfg.tags) || [];\n if (Array.isArray(tags)) {\n for (var i = 0; i < tags.length; i++) acc.push(String(tags[i]));\n }\n return acc;\n }, [])\n )\n ).sort();\n\n function buildFilterUI() {\n // Methods\n methodFiltersEl.innerHTML = '';\n allMethods.forEach(function (m) {\n var label = document.createElement('label');\n label.className = 'filter-pill';\n var cb = document.createElement('input');\n cb.type = 'checkbox';\n cb.value = m;\n cb.checked = true;\n cb.addEventListener('change', applyFilters);\n label.appendChild(cb);\n label.appendChild(document.createTextNode(' ' + m));\n methodFiltersEl.appendChild(label);\n });\n\n // Groups\n groupSelect.innerHTML = '';\n var allOption = document.createElement('option');\n allOption.value = '__all';\n allOption.textContent = 'All groups';\n groupSelect.appendChild(allOption);\n allGroups.forEach(function (g) {\n var opt = document.createElement('option');\n opt.value = g;\n opt.textContent = g;\n groupSelect.appendChild(opt);\n });\n groupSelect.addEventListener('change', applyFilters);\n\n // Tags\n tagFiltersEl.innerHTML = '';\n allTags.forEach(function (t) {\n var label = document.createElement('label');\n label.className = 'filter-pill';\n var cb = document.createElement('input');\n cb.type = 'checkbox';\n cb.value = t;\n cb.addEventListener('change', applyFilters);\n label.appendChild(cb);\n label.appendChild(document.createTextNode(' ' + t));\n tagFiltersEl.appendChild(label);\n });\n }\n\n function routeToHTML(route) {\n var method = String(route.method || '').toUpperCase();\n var methodClass = 'method-' + String(route.method || '').toLowerCase();\n\n var cfg = route.cfg || {};\n var group = cfg.docsGroup || 'Ungrouped';\n\n var summary = cfg.summary || cfg.description || '';\n var description =\n cfg.description && cfg.summary !== cfg.description\n ? cfg.description\n : '';\n\n var tags = Array.isArray(cfg.tags) ? cfg.tags : [];\n var tagHtml = tags\n .map(function (tag) {\n var t = String(tag);\n var extraClass = t === 'not-implemented' ? ' tag-not-impl' : '';\n return '<span class=\"tag' + extraClass + '\">' + escapeHtml(t) + '</span>';\n })\n .join('');\n\n var metaBadges = '';\n if (cfg.feed) {\n metaBadges += '<span class=\"badge badge-feed\">Feed</span>';\n }\n if (cfg.deprecated || cfg.stability === 'deprecated') {\n metaBadges += '<span class=\"badge badge-deprecated\">Deprecated</span>';\n } else if (cfg.stability && cfg.stability !== 'stable') {\n metaBadges +=\n '<span class=\"badge badge-' +\n escapeHtml(cfg.stability) +\n '\">' +\n escapeHtml(String(cfg.stability)) +\n '</span>';\n }\n\n var schemaPills = [];\n if (cfg.hasBody) schemaPills.push('<span class=\"schema-pill\">Body</span>');\n if (cfg.hasQuery) schemaPills.push('<span class=\"schema-pill\">Query</span>');\n if (cfg.hasParams) schemaPills.push('<span class=\"schema-pill\">Params</span>');\n if (cfg.hasOutput) schemaPills.push('<span class=\"schema-pill\">Response</span>');\n\n var schemaHtml =\n schemaPills.length > 0\n ? '<div class=\"schema-row\">' + schemaPills.join('') + '</div>'\n : '';\n\n return (\n '<article class=\"route-card\">' +\n '<header class=\"route-header\">' +\n '<span class=\"method-pill ' +\n methodClass +\n '\">' +\n method +\n '</span>' +\n '<code class=\"route-path\">' +\n escapeHtml(route.path || '') +\n '</code>' +\n (group\n ? '<span class=\"group-label\">' + escapeHtml(String(group)) + '</span>'\n : '') +\n '</header>' +\n '<div class=\"route-tags\">' +\n tagHtml +\n metaBadges +\n '</div>' +\n (summary\n ? '<p class=\"route-summary\">' + escapeHtml(String(summary)) + '</p>'\n : '') +\n (description\n ? '<p class=\"route-description\">' +\n escapeHtml(String(description)) +\n '</p>'\n : '') +\n schemaHtml +\n '</article>'\n );\n }\n\n function applyFilters() {\n var query = searchInput.value.toLowerCase().trim();\n\n var activeMethods = Array.prototype.slice\n .call(methodFiltersEl.querySelectorAll('input[type=\"checkbox\"]:checked'))\n .map(function (cb) {\n return cb.value;\n });\n\n var groupValue = groupSelect.value;\n var activeTags = Array.prototype.slice\n .call(tagFiltersEl.querySelectorAll('input[type=\"checkbox\"]:checked'))\n .map(function (cb) {\n return cb.value;\n });\n\n var filtered = leaves.filter(function (route) {\n var cfg = route.cfg || {};\n\n if (\n activeMethods.length &&\n activeMethods.indexOf(String(route.method || '').toUpperCase()) === -1\n ) {\n return false;\n }\n\n if (groupValue && groupValue !== '__all') {\n var g = cfg.docsGroup || 'Ungrouped';\n if (g !== groupValue) return false;\n }\n\n if (activeTags.length) {\n var tags = Array.isArray(cfg.tags) ? cfg.tags : [];\n var hasAny = activeTags.some(function (t) {\n return tags.indexOf(t) !== -1;\n });\n if (!hasAny) return false;\n }\n\n if (query) {\n var haystack =\n String(route.path || '') +\n ' ' +\n String(cfg.summary || '') +\n ' ' +\n String(cfg.description || '') +\n ' ' +\n (Array.isArray(cfg.tags) ? cfg.tags.join(' ') : '') +\n ' ' +\n String(cfg.docsGroup || '');\n if (haystack.toLowerCase().indexOf(query) === -1) return false;\n }\n\n return true;\n });\n\n if (statsEl) {\n statsEl.textContent = filtered.length + ' routes';\n }\n\n if (!filtered.length) {\n routeList.innerHTML =\n '<div class=\"empty-state\">No routes match the current filters.</div>';\n } else {\n routeList.innerHTML = filtered.map(routeToHTML).join('');\n }\n }\n\n buildFilterUI();\n searchInput.addEventListener('input', applyFilters);\n\n // Initial render\n statsEl.textContent = leaves.length + ' routes';\n applyFilters();\n })();\n </script>\n</body>\n</html>`;\n}\n"],"mappings":";AAAA,SAAS,SAAS;AAalB,IAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,OAAO,EAAE,OAAO,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,QAAQ,EAAE;AACrD,CAAC;AAED,IAAM,kBAAkB,uBAAuB,SAAS,EAAE,QAAQ,uBAAuB,MAAM,CAAC,CAAC,CAAC;AAYlG,IAAM,0BAA0B,EAAE,OAAO;AAAA,EACvC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC;AAAA,EAC1B,YAAY,EAAE,OAAO,EAAE,SAAS;AAClC,CAAC;AAED,SAAS,uBAAyD,QAAW;AAC3E,MAAI,UAAU,EAAE,kBAAkB,EAAE,YAAY;AAC9C,YAAQ,KAAK,+DAA+D;AAC5E,WAAO,EAAE,OAAO;AAAA,MACd,YAAY;AAAA,IACd,CAAC;AAAA,EACH;AAEA,QAA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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8PpB;","names":["z","z","mergeSchemas"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@emeryld/rrroutes-contract",
3
3
  "description": "TypeScript contract definitions for RRRoutes",
4
- "version": "2.1.11",
4
+ "version": "2.1.12",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "main": "dist/index.cjs",