@emeryld/rrroutes-openapi 2.2.24 → 2.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/LeafDocsPage.d.ts +4 -1
- package/dist/index.cjs +12 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +12 -3
- package/dist/index.mjs.map +1 -1
- package/dist/public/assets/docs.js +11 -11
- package/dist/web/app.d.ts +2 -1
- package/dist/web/components/PlaygroundOverlay.d.ts +5 -3
- package/dist/web/components/PresetsView.d.ts +2 -1
- package/dist/web/historyStore.d.ts +2 -1
- package/package.json +1 -1
|
@@ -8,6 +8,8 @@ export interface RenderOptions {
|
|
|
8
8
|
assetBasePath?: string;
|
|
9
9
|
/** Root path where the docs are mounted (e.g. `/__rrroutes/docs`). Used for client routing. */
|
|
10
10
|
docsBasePath?: string;
|
|
11
|
+
/** Optional suffix appended to the window origin when building default playground base URLs. */
|
|
12
|
+
baseUrlSuffix?: string;
|
|
11
13
|
/** Preset collections rendered into the docs UI. */
|
|
12
14
|
presets?: SerializablePreset[];
|
|
13
15
|
/** Optional seed history entries to pre-populate the UI (useful in dev). */
|
|
@@ -19,9 +21,10 @@ type DocsDocumentProps = {
|
|
|
19
21
|
assetBase: string;
|
|
20
22
|
docsBase: string;
|
|
21
23
|
historyJson: string;
|
|
24
|
+
baseUrlSuffix?: string;
|
|
22
25
|
cspNonce?: string;
|
|
23
26
|
};
|
|
24
|
-
export declare const DocsDocument: ({ leavesJson, presetsJson, assetBase, docsBase, historyJson, cspNonce, }: DocsDocumentProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare const DocsDocument: ({ leavesJson, presetsJson, assetBase, docsBase, historyJson, baseUrlSuffix, cspNonce, }: DocsDocumentProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
28
|
export declare function createLeafDocsDocument(leaves: AnyLeaf[], options?: RenderOptions): ReactElement;
|
|
26
29
|
export declare function renderLeafDocsHTML(leaves: AnyLeaf[], options?: RenderOptions): string;
|
|
27
30
|
export type SerializableHistoryEntry = {
|
package/dist/index.cjs
CHANGED
|
@@ -210,17 +210,23 @@ function normalizeDocsBase(base) {
|
|
|
210
210
|
if (base === "/") return "/";
|
|
211
211
|
return base.endsWith("/") && base.length > 1 ? base.slice(0, -1) : base;
|
|
212
212
|
}
|
|
213
|
+
function normalizeBaseUrlSuffix(suffix) {
|
|
214
|
+
if (!suffix) return "";
|
|
215
|
+
const trimmed = suffix.endsWith("/") && suffix.length > 1 ? suffix.slice(0, -1) : suffix;
|
|
216
|
+
return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
217
|
+
}
|
|
213
218
|
var DocsDocument = ({
|
|
214
219
|
leavesJson,
|
|
215
220
|
presetsJson,
|
|
216
221
|
assetBase,
|
|
217
222
|
docsBase,
|
|
218
223
|
historyJson,
|
|
224
|
+
baseUrlSuffix,
|
|
219
225
|
cspNonce
|
|
220
226
|
}) => {
|
|
221
227
|
const cssHref = `${assetBase}/docs.css`;
|
|
222
228
|
const jsSrc = `${assetBase}/docs.js`;
|
|
223
|
-
const configJson = serializeConfig(docsBase);
|
|
229
|
+
const configJson = serializeConfig({ docsBasePath: docsBase, baseUrlSuffix });
|
|
224
230
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("html", { lang: "en", children: [
|
|
225
231
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("head", { children: [
|
|
226
232
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { charSet: "UTF-8" }),
|
|
@@ -279,8 +285,8 @@ function serializePresets(presets) {
|
|
|
279
285
|
function serializeHistorySeeds(historySeeds) {
|
|
280
286
|
return JSON.stringify(Array.isArray(historySeeds) ? historySeeds : []).replace(/<\//g, "<\\/");
|
|
281
287
|
}
|
|
282
|
-
function serializeConfig(
|
|
283
|
-
return JSON.stringify(
|
|
288
|
+
function serializeConfig(config) {
|
|
289
|
+
return JSON.stringify(config).replace(/<\//g, "<\\/");
|
|
284
290
|
}
|
|
285
291
|
function createLeafDocsDocument(leaves, options = {}) {
|
|
286
292
|
const assetBase = normalizeBase(options.assetBasePath ?? DEFAULT_ASSET_BASE);
|
|
@@ -288,6 +294,7 @@ function createLeafDocsDocument(leaves, options = {}) {
|
|
|
288
294
|
const presetsJson = serializePresets(options.presets);
|
|
289
295
|
const docsBase = normalizeDocsBase(options.docsBasePath);
|
|
290
296
|
const historyJson = serializeHistorySeeds(options.historySeeds);
|
|
297
|
+
const baseUrlSuffix = normalizeBaseUrlSuffix(options.baseUrlSuffix);
|
|
291
298
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
292
299
|
DocsDocument,
|
|
293
300
|
{
|
|
@@ -296,6 +303,7 @@ function createLeafDocsDocument(leaves, options = {}) {
|
|
|
296
303
|
assetBase,
|
|
297
304
|
docsBase,
|
|
298
305
|
historyJson,
|
|
306
|
+
baseUrlSuffix,
|
|
299
307
|
cspNonce: options.cspNonce
|
|
300
308
|
}
|
|
301
309
|
);
|
|
@@ -345,6 +353,7 @@ function mountRRRoutesDocs({
|
|
|
345
353
|
cspNonce: nonce,
|
|
346
354
|
assetBasePath: `${prefix}${assetsMountPath}`,
|
|
347
355
|
docsBasePath: `${prefix}${normalizedDocsPath}`,
|
|
356
|
+
baseUrlSuffix: prefix,
|
|
348
357
|
historySeeds: options.historySeeds,
|
|
349
358
|
presets: normalizePresets(finalPresets)
|
|
350
359
|
});
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/docs/LeafDocsPage.tsx","../src/docs/schemaIntrospection.ts","../src/docs/serializer.ts","../src/docs/docs.ts"],"sourcesContent":["/**\n * dry styles\nfake history logs data for testing\ngraphs for history data\nlogs webhook\nsecurity -> gated access + give environment and if environment='production' -> extra \"Are you sure you want to do this\" pop-up for each non-get action\n */\n\nimport type { AnyLeaf } from '@emeryld/rrroutes-contract';\nimport { randomBytes } from 'crypto';\nimport type { Request, Response, Router } from 'express';\nimport { static as expressStatic } from 'express';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport z from 'zod';\nimport type { SerializableHistoryEntry } from './docs/docs.js';\nimport { renderLeafDocsHTML } from './docs/docs.js';\nimport type { SerializablePreset } from './docs/presets.js';\n\nexport type DocsRequestContext = {\n req: Request;\n res: Response;\n leaves: AnyLeaf[];\n presets: PresetGroup<AnyLeaf>[];\n};\n\nexport type DocsOnRequestResult = {\n leaves?: AnyLeaf[];\n presets?: PresetGroup<AnyLeaf>[];\n nonce?: string;\n html?: string;\n};\n\nexport type OpenApiDocsOptions = {\n /** Path where docs are mounted. Defaults to `/__rrroutes/docs`. */\n path?: string;\n prefix?: string;\n /** Whether to emit a CSP header + nonce. Defaults to true. */\n csp?: boolean;\n /** Override where static assets are served from. Defaults to `${path}/assets`. */\n assetBasePath?: string;\n /** Optional seed history entries that will pre-populate the docs UI history. */\n historySeeds?: SerializableHistoryEntry[];\n /**\n * Hook that runs on every request. Use it to adjust leaves, override nonce, or\n * provide a fully custom HTML response.\n */\n onRequest?: (ctx: DocsRequestContext) => DocsOnRequestResult | void;\n};\n\nexport type Preset<L extends AnyLeaf> = L extends infer A extends AnyLeaf? {\n method: A['method'];\n path: A['path'];\n // pre-set values for schemas. Does not have to be complete.\n body: z.input<A['cfg']['bodySchema']>;\n query: z.input<A['cfg']['querySchema']>;\n params: z.input<A['cfg']['paramsSchema']>;\n}:never;\n\nexport type PresetGroup<L extends AnyLeaf> = {\n name: string;\n description?: string;\n tags: string[];\n docsGroup?: string;\n\n ops: Preset<L>[];\n};\n\nexport type MountDocsArgs<L extends AnyLeaf> = {\n router: Router;\n leaves: L[];\n presets?: PresetGroup<L>[];\n options?: OpenApiDocsOptions;\n};\n\nconst trimTrailingSlash = (value: string) =>\n value.endsWith('/') && value.length > 1 ? value.slice(0, -1) : value;\n\nexport function mountRRRoutesDocs<L extends AnyLeaf>({\n router,\n leaves,\n presets = [],\n options = {},\n}: MountDocsArgs<L>) {\n const prefix = options.prefix ? trimTrailingSlash(options.prefix) : '';\n const docsPath = options.path ?? '/__rrroutes/docs';\n const normalizedDocsPath = trimTrailingSlash(docsPath);\n const assetsMountPath = trimTrailingSlash(\n options.assetBasePath ?? `${normalizedDocsPath}/assets`,\n );\n const publicDir = resolvePublicDir();\n const assetsDir = path.join(publicDir, 'assets');\n const cspEnabled = options.csp !== false;\n\n router.use(assetsMountPath, expressStatic(assetsDir, { immutable: true, maxAge: '365d' }));\n\n const docsRoutePaths = [normalizedDocsPath, `${normalizedDocsPath}/`, `${normalizedDocsPath}/*id`];\n\n router.get(docsRoutePaths, (req, res) => {\n const preparedLeaves = Array.isArray(leaves)\n ? leaves.filter((leaf) => leaf.cfg.docsHidden !== true)\n : [];\n const preparedPresets = Array.isArray(presets) ? presets : [];\n const onRequestResult =\n options.onRequest?.({ req, res, leaves: preparedLeaves, presets: preparedPresets }) ?? {};\n const finalLeaves = onRequestResult.leaves ?? preparedLeaves;\n const finalPresets = onRequestResult.presets ?? preparedPresets;\n\n const hasCustomHtml = typeof onRequestResult.html === 'string';\n\n let nonce = onRequestResult.nonce;\n if (!nonce && cspEnabled && !hasCustomHtml) {\n nonce = randomBytes(16).toString('base64');\n }\n\n const html = hasCustomHtml\n ? (onRequestResult.html as string)\n : renderLeafDocsHTML(finalLeaves, {\n cspNonce: nonce,\n assetBasePath: `${prefix}${assetsMountPath}`,\n docsBasePath: `${prefix}${normalizedDocsPath}`,\n historySeeds: options.historySeeds,\n presets: normalizePresets(finalPresets),\n });\n\n if (cspEnabled && nonce) {\n res.setHeader(\n 'Content-Security-Policy',\n [\n \"default-src 'self'\",\n `script-src 'self' 'nonce-${nonce}'`,\n `style-src 'self' 'nonce-${nonce}'`,\n \"img-src 'self' data:\",\n \"connect-src 'self'\",\n \"font-src 'self'\",\n \"frame-ancestors 'self'\",\n ].join('; '),\n );\n }\n\n res.send(html);\n });\n\n return { path: docsPath };\n}\n\nfunction resolvePublicDir() {\n const moduleDir =\n typeof __dirname !== 'undefined'\n ? __dirname\n : path.dirname(fileURLToPath(import.meta.url));\n const fromModule = path.resolve(moduleDir, '../public');\n if (fs.existsSync(fromModule)) return fromModule;\n\n // When running from source (ts-node), fall back to the built output path.\n const fallback = path.resolve(moduleDir, '../dist/public');\n if (fs.existsSync(fallback)) return fallback;\n\n return fromModule; // fallback; express static will 404 if missing\n}\n\nfunction normalizePresets(presets: PresetGroup<AnyLeaf>[]): SerializablePreset[] {\n if (!Array.isArray(presets)) return [];\n return presets.map((preset) => ({\n name: preset.name,\n description: preset.description,\n tags: Array.isArray(preset.tags) ? preset.tags.slice() : [],\n docsGroup: preset.docsGroup,\n ops: Array.isArray(preset.ops)\n ? preset.ops.map((op) => ({\n method: typeof op.method === 'string' ? op.method.toUpperCase() : '',\n path: typeof op.path === 'string' ? op.path : '',\n body: op.body,\n query: op.query,\n params: op.params,\n }))\n : [],\n }));\n}\n\nexport { renderLeafDocsHTML } from './docs/docs.js';\nexport { serializeLeaf } from './docs/serializer.js';\nexport type { SerializableLeaf } from './docs/serializer.js';\n","import type { AnyLeaf } from '@emeryld/rrroutes-contract';\nimport type { ReactElement } from 'react';\nimport { renderToStaticMarkup } from 'react-dom/server';\nimport type { SerializablePreset } from './presets.js';\nimport { serializeLeaf } from './serializer.js';\n\nexport interface RenderOptions {\n /** CSP nonce applied to data + script tags. */\n cspNonce?: string;\n /** Base URL where static assets are served (e.g. `/__rrroutes/docs/assets`). */\n assetBasePath?: string;\n /** Root path where the docs are mounted (e.g. `/__rrroutes/docs`). Used for client routing. */\n docsBasePath?: string;\n /** Preset collections rendered into the docs UI. */\n presets?: SerializablePreset[];\n /** Optional seed history entries to pre-populate the UI (useful in dev). */\n historySeeds?: SerializableHistoryEntry[];\n}\n\nconst DEFAULT_ASSET_BASE = '/__rrroutes/docs/assets';\n\nfunction normalizeBase(base: string) {\n if (!base) return DEFAULT_ASSET_BASE;\n return base.endsWith('/') ? base.slice(0, -1) : base;\n}\n\nfunction normalizeDocsBase(base: string | undefined) {\n if (!base) return '';\n if (base === '/') return '/';\n return base.endsWith('/') && base.length > 1 ? base.slice(0, -1) : base;\n}\n\ntype DocsDocumentProps = {\n leavesJson: string;\n presetsJson: string;\n assetBase: string;\n docsBase: string;\n historyJson: string;\n cspNonce?: string;\n};\n\nexport const DocsDocument = ({\n leavesJson,\n presetsJson,\n assetBase,\n docsBase,\n historyJson,\n cspNonce,\n}: DocsDocumentProps) => {\n const cssHref = `${assetBase}/docs.css`;\n const jsSrc = `${assetBase}/docs.js`;\n const configJson = serializeConfig(docsBase);\n\n return (\n <html lang=\"en\">\n <head>\n <meta charSet=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>API Reference</title>\n <link rel=\"stylesheet\" href={cssHref} />\n </head>\n <body>\n <div id=\"docs-root\"></div>\n <script\n id=\"leaf-data\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: leavesJson }}\n />\n <script\n id=\"preset-data\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: presetsJson }}\n />\n <script\n id=\"history-data\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: historyJson }}\n />\n <script\n id=\"docs-config\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: configJson }}\n />\n <script type=\"module\" src={jsSrc} nonce={cspNonce} />\n </body>\n </html>\n );\n};\n\nfunction serializeLeaves(leaves: AnyLeaf[]) {\n return JSON.stringify(leaves.map(serializeLeaf)).replace(/<\\//g, '<\\\\/');\n}\n\nfunction serializePresets(presets: SerializablePreset[] | undefined) {\n return JSON.stringify(Array.isArray(presets) ? presets : []).replace(/<\\//g, '<\\\\/');\n}\n\nfunction serializeHistorySeeds(historySeeds: SerializableHistoryEntry[] | undefined) {\n return JSON.stringify(Array.isArray(historySeeds) ? historySeeds : []).replace(/<\\//g, '<\\\\/');\n}\n\nfunction serializeConfig(docsBase: string) {\n return JSON.stringify({ docsBasePath: docsBase }).replace(/<\\//g, '<\\\\/');\n}\n\nexport function createLeafDocsDocument(\n leaves: AnyLeaf[],\n options: RenderOptions = {},\n): ReactElement {\n const assetBase = normalizeBase(options.assetBasePath ?? DEFAULT_ASSET_BASE);\n const leavesJson = serializeLeaves(leaves);\n const presetsJson = serializePresets(options.presets);\n const docsBase = normalizeDocsBase(options.docsBasePath);\n const historyJson = serializeHistorySeeds(options.historySeeds);\n\n return (\n <DocsDocument\n leavesJson={leavesJson}\n presetsJson={presetsJson}\n assetBase={assetBase}\n docsBase={docsBase}\n historyJson={historyJson}\n cspNonce={options.cspNonce}\n />\n );\n}\n\nexport function renderLeafDocsHTML(leaves: AnyLeaf[], options: RenderOptions = {}): string {\n const doc = createLeafDocsDocument(leaves, options);\n const html = renderToStaticMarkup(doc);\n return `<!DOCTYPE html>${html}`;\n}\n\nexport type SerializableHistoryEntry = {\n id?: string;\n timestamp: number;\n method: string;\n path: string;\n fullUrl: string;\n params?: Record<string, string>;\n query?: Record<string, string>;\n body?: string;\n output?: string;\n status?: number;\n durationMs: number;\n error?: string;\n};\n","// schemaIntrospection.ts\nimport * as z from \"zod\";\n\nexport type SerializableSchemaNode = {\n kind: string; // \"object\" | \"string\" | \"number\" | ...\n optional?: boolean;\n nullable?: boolean;\n description?: string;\n\n // object\n properties?: Record<string, SerializableSchemaNode>;\n // array\n element?: SerializableSchemaNode;\n // union\n union?: SerializableSchemaNode[];\n // literal\n literal?: unknown;\n // enum\n enumValues?: string[];\n};\n\ntype ZodAny = z.ZodTypeAny;\n\n/**\n * Zod 3 uses `schema._def`, Zod 4 uses `schema._zod.def`.\n */\nfunction getDef(schema: unknown): any | undefined {\n if (!schema || typeof schema !== \"object\") return undefined;\n const anySchema = schema as any;\n return anySchema._zod?.def ?? anySchema._def;\n}\n\n/**\n * Try to get a human-readable description.\n * Zod 4: use metadata/registry; fallback to internal def.description.\n * Zod 3: only internal def.description exists.\n */\nfunction getDescription(schema: ZodAny): string | undefined {\n const anyZ: any = z as any;\n\n // Zod 4 global registry metadata, if present\n const registry = anyZ.globalRegistry?.get\n ? anyZ.globalRegistry.get(schema)\n : undefined;\n if (registry && typeof registry.description === \"string\") {\n return registry.description;\n }\n\n // Legacy / internal description\n const def = getDef(schema);\n if (def && typeof def.description === \"string\") {\n return def.description;\n }\n\n return undefined;\n}\n\n/**\n * Peel off wrappers (effects, optional, nullable, default) and\n * return the inner schema + flags.\n *\n * Supports:\n * - Zod 3: ZodEffects, ZodOptional, ZodNullable, ZodDefault\n * - Zod 4: ZodOptional, ZodNullable, ZodDefault\n */\nfunction unwrap(schema: ZodAny): {\n base: ZodAny;\n optional: boolean;\n nullable: boolean;\n} {\n let s: ZodAny = schema;\n let optional = false;\n let nullable = false;\n\n // Zod 3 only (undefined in Zod 4)\n const ZodEffectsCtor: any = (z as any).ZodEffects;\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n // Zod 3: ZodEffects wrapper\n if (ZodEffectsCtor && s instanceof ZodEffectsCtor) {\n const def = getDef(s) || {};\n const sourceType =\n typeof (s as any).sourceType === \"function\"\n ? (s as any).sourceType()\n : def.schema;\n if (!sourceType) break;\n s = sourceType;\n continue;\n }\n\n // Zod 3 + 4: optional/nullable/default wrappers\n if (s instanceof z.ZodOptional) {\n optional = true;\n const def = getDef(s);\n s = (def && def.innerType) || s; // innerType exists in both 3 & 4\n continue;\n }\n\n if (s instanceof z.ZodNullable) {\n nullable = true;\n const def = getDef(s);\n s = (def && def.innerType) || s;\n continue;\n }\n\n if (s instanceof z.ZodDefault) {\n const def = getDef(s);\n s = (def && def.innerType) || s;\n continue;\n }\n\n break;\n }\n\n return { base: s, optional, nullable };\n}\n\nexport function introspectSchema(\n schema: ZodAny | undefined\n): SerializableSchemaNode | undefined {\n if (!schema) return undefined;\n\n const { base, optional, nullable } = unwrap(schema);\n const def = getDef(base);\n\n const node: SerializableSchemaNode = {\n kind: inferKind(base),\n optional: optional || undefined,\n nullable: nullable || undefined,\n description: getDescription(base),\n };\n\n // OBJECT\n if (base instanceof z.ZodObject) {\n // Zod 3: _def.shape() (function)\n // Zod 4: .shape getter returns an object\n const rawShape: any =\n (base as any).shape ?? (def && typeof def.shape === \"function\"\n ? def.shape()\n : def?.shape);\n\n const shape =\n typeof rawShape === \"function\" ? rawShape() : rawShape ?? {};\n\n const props: Record<string, SerializableSchemaNode> = {};\n for (const key of Object.keys(shape)) {\n const child = shape[key] as ZodAny;\n const childNode = introspectSchema(child);\n if (childNode) props[key] = childNode;\n }\n node.properties = props;\n }\n\n // ARRAY\n if (base instanceof z.ZodArray) {\n // Zod 3: def.type is inner schema\n // Zod 4: def.element is inner schema\n const inner =\n (def && (def.element as ZodAny)) ||\n (def && (def.type as ZodAny)) ||\n undefined;\n if (inner) {\n node.element = introspectSchema(inner);\n }\n }\n\n // UNION\n if (base instanceof z.ZodUnion) {\n const options: ZodAny[] = (def && def.options) || [];\n node.union = options\n .map((opt) => introspectSchema(opt))\n .filter(Boolean) as SerializableSchemaNode[];\n }\n\n // LITERAL\n if (base instanceof z.ZodLiteral) {\n if (def) {\n // Zod 4: def.values (multi-literal)\n if (Array.isArray(def.values)) {\n node.literal =\n def.values.length === 1 ? def.values[0] : def.values.slice();\n } else {\n // Zod 3: def.value\n node.literal = def.value;\n }\n }\n }\n\n // ENUM\n if (base instanceof z.ZodEnum) {\n if (def) {\n if (Array.isArray(def.values)) {\n // Zod 3\n node.enumValues = def.values.slice();\n } else if (def.entries && typeof def.entries === \"object\") {\n // Zod 4: entries is a { key: value } map\n node.enumValues = Object.values(def.entries).map((v: unknown) =>\n String(v)\n );\n }\n }\n }\n\n return node;\n}\n\nfunction inferKind(schema: ZodAny): string {\n // This path still uses instanceof; it works with Zod 4 Classic\n // (importing from \"zod\"). Anything unknown falls back to \"unknown\".\n if (schema instanceof z.ZodString) return \"string\";\n if (schema instanceof z.ZodNumber) return \"number\";\n if (schema instanceof z.ZodBoolean) return \"boolean\";\n if (schema instanceof z.ZodBigInt) return \"bigint\";\n if (schema instanceof z.ZodDate) return \"date\";\n if (schema instanceof z.ZodArray) return \"array\";\n if (schema instanceof z.ZodObject) return \"object\";\n if (schema instanceof z.ZodUnion) return \"union\";\n if (schema instanceof z.ZodLiteral) return \"literal\";\n if (schema instanceof z.ZodEnum) return \"enum\";\n if (schema instanceof z.ZodRecord) return \"record\";\n if (schema instanceof z.ZodTuple) return \"tuple\";\n if (schema instanceof z.ZodUnknown) return \"unknown\";\n if (schema instanceof z.ZodAny) return \"any\";\n\n return \"unknown\";\n}\n","// serializer.ts\nimport type { AnyLeaf, MethodCfg } from \"@emeryld/rrroutes-contract\";\nimport { introspectSchema, SerializableSchemaNode } from \"./schemaIntrospection.js\";\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 // NEW: full Zod ASTs\n bodySchema?: SerializableSchemaNode;\n querySchema?: SerializableSchemaNode;\n paramsSchema?: SerializableSchemaNode;\n outputSchema?: SerializableSchemaNode;\n};\n\nexport type SerializableLeaf = {\n method: string;\n path: string;\n cfg: SerializableMethodCfg;\n};\n\nexport type { SerializableSchemaNode } from \"./schemaIntrospection.js\";\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 bodySchema: introspectSchema(cfg.bodySchema),\n querySchema: introspectSchema(cfg.querySchema),\n paramsSchema: introspectSchema(cfg.paramsSchema),\n outputSchema: introspectSchema(cfg.outputSchema),\n },\n };\n}\n","// renderLeafDocsHTML.ts\nimport type { AnyLeaf } from \"@emeryld/rrroutes-contract\";\nimport {\n createLeafDocsDocument,\n renderLeafDocsHTML as LeafDocsPage,\n RenderOptions,\n} from \"./LeafDocsPage.js\";\n\nexport function renderLeafDocsHTML(leaves: AnyLeaf[], options: RenderOptions = {}): string {\n return LeafDocsPage(leaves, options);\n}\n\nexport type { RenderOptions, SerializableHistoryEntry } from \"./LeafDocsPage.js\";\nexport { createLeafDocsDocument } from \"./LeafDocsPage.js\";\nexport type { SerializablePreset, SerializablePresetOperation } from \"./presets.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,4BAAAA;AAAA,EAAA;AAAA;AAAA;AASA,oBAA4B;AAE5B,qBAAwC;AACxC,qBAAe;AACf,uBAAiB;AACjB,sBAA8B;;;ACZ9B,oBAAqC;;;ACDrC,QAAmB;AAyBnB,SAAS,OAAO,QAAkC;AAChD,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,QAAM,YAAY;AAClB,SAAO,UAAU,MAAM,OAAO,UAAU;AAC1C;AAOA,SAAS,eAAe,QAAoC;AAC1D,QAAM,OAAY;AAGlB,QAAM,WAAW,KAAK,gBAAgB,MAClC,KAAK,eAAe,IAAI,MAAM,IAC9B;AACJ,MAAI,YAAY,OAAO,SAAS,gBAAgB,UAAU;AACxD,WAAO,SAAS;AAAA,EAClB;AAGA,QAAM,MAAM,OAAO,MAAM;AACzB,MAAI,OAAO,OAAO,IAAI,gBAAgB,UAAU;AAC9C,WAAO,IAAI;AAAA,EACb;AAEA,SAAO;AACT;A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ClE,MAAM,OAAO,GAAG,SAAS,WAAW,GAAG,OAAO;AAAA,MAC9C,MAAM,GAAG;AAAA,MACT,OAAO,GAAG;AAAA,MACV,QAAQ,GAAG;AAAA,IACb,EAAE,IACF,CAAC;AAAA,EACP,EAAE;AACJ;","names":["renderLeafDocsHTML","renderLeafDocsHTML","path","expressStatic","renderLeafDocsHTML","fs"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/docs/LeafDocsPage.tsx","../src/docs/schemaIntrospection.ts","../src/docs/serializer.ts","../src/docs/docs.ts"],"sourcesContent":["/**\n * dry styles\nfake history logs data for testing\ngraphs for history data\nlogs webhook\nsecurity -> gated access + give environment and if environment='production' -> extra \"Are you sure you want to do this\" pop-up for each non-get action\n */\n\nimport type { AnyLeaf } from '@emeryld/rrroutes-contract';\nimport { randomBytes } from 'crypto';\nimport type { Request, Response, Router } from 'express';\nimport { static as expressStatic } from 'express';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport z from 'zod';\nimport type { SerializableHistoryEntry } from './docs/docs.js';\nimport { renderLeafDocsHTML } from './docs/docs.js';\nimport type { SerializablePreset } from './docs/presets.js';\n\nexport type DocsRequestContext = {\n req: Request;\n res: Response;\n leaves: AnyLeaf[];\n presets: PresetGroup<AnyLeaf>[];\n};\n\nexport type DocsOnRequestResult = {\n leaves?: AnyLeaf[];\n presets?: PresetGroup<AnyLeaf>[];\n nonce?: string;\n html?: string;\n};\n\nexport type OpenApiDocsOptions = {\n /** Path where docs are mounted. Defaults to `/__rrroutes/docs`. */\n path?: string;\n prefix?: string;\n /** Whether to emit a CSP header + nonce. Defaults to true. */\n csp?: boolean;\n /** Override where static assets are served from. Defaults to `${path}/assets`. */\n assetBasePath?: string;\n /** Optional seed history entries that will pre-populate the docs UI history. */\n historySeeds?: SerializableHistoryEntry[];\n /**\n * Hook that runs on every request. Use it to adjust leaves, override nonce, or\n * provide a fully custom HTML response.\n */\n onRequest?: (ctx: DocsRequestContext) => DocsOnRequestResult | void;\n};\n\nexport type Preset<L extends AnyLeaf> = L extends infer A extends AnyLeaf? {\n method: A['method'];\n path: A['path'];\n // pre-set values for schemas. Does not have to be complete.\n body: z.output<A['cfg']['bodySchema']>;\n query: z.output<A['cfg']['querySchema']>;\n params: z.output<A['cfg']['paramsSchema']>;\n}:never;\n\nexport type PresetGroup<L extends AnyLeaf> = {\n name: string;\n description?: string;\n tags: string[];\n docsGroup?: string;\n\n ops: Preset<L>[];\n};\n\nexport type MountDocsArgs<L extends AnyLeaf> = {\n router: Router;\n leaves: L[];\n presets?: PresetGroup<L>[];\n options?: OpenApiDocsOptions;\n};\n\nconst trimTrailingSlash = (value: string) =>\n value.endsWith('/') && value.length > 1 ? value.slice(0, -1) : value;\n\nexport function mountRRRoutesDocs<L extends AnyLeaf>({\n router,\n leaves,\n presets = [],\n options = {},\n}: MountDocsArgs<L>) {\n const prefix = options.prefix ? trimTrailingSlash(options.prefix) : '';\n const docsPath = options.path ?? '/__rrroutes/docs';\n const normalizedDocsPath = trimTrailingSlash(docsPath);\n const assetsMountPath = trimTrailingSlash(\n options.assetBasePath ?? `${normalizedDocsPath}/assets`,\n );\n const publicDir = resolvePublicDir();\n const assetsDir = path.join(publicDir, 'assets');\n const cspEnabled = options.csp !== false;\n\n router.use(assetsMountPath, expressStatic(assetsDir, { immutable: true, maxAge: '365d' }));\n\n const docsRoutePaths = [normalizedDocsPath, `${normalizedDocsPath}/`, `${normalizedDocsPath}/*id`];\n\n router.get(docsRoutePaths, (req, res) => {\n const preparedLeaves = Array.isArray(leaves)\n ? leaves.filter((leaf) => leaf.cfg.docsHidden !== true)\n : [];\n const preparedPresets = Array.isArray(presets) ? presets : [];\n const onRequestResult =\n options.onRequest?.({ req, res, leaves: preparedLeaves, presets: preparedPresets }) ?? {};\n const finalLeaves = onRequestResult.leaves ?? preparedLeaves;\n const finalPresets = onRequestResult.presets ?? preparedPresets;\n\n const hasCustomHtml = typeof onRequestResult.html === 'string';\n\n let nonce = onRequestResult.nonce;\n if (!nonce && cspEnabled && !hasCustomHtml) {\n nonce = randomBytes(16).toString('base64');\n }\n\n const html = hasCustomHtml\n ? (onRequestResult.html as string)\n : renderLeafDocsHTML(finalLeaves, {\n cspNonce: nonce,\n assetBasePath: `${prefix}${assetsMountPath}`,\n docsBasePath: `${prefix}${normalizedDocsPath}`,\n baseUrlSuffix: prefix,\n historySeeds: options.historySeeds,\n presets: normalizePresets(finalPresets),\n });\n\n if (cspEnabled && nonce) {\n res.setHeader(\n 'Content-Security-Policy',\n [\n \"default-src 'self'\",\n `script-src 'self' 'nonce-${nonce}'`,\n `style-src 'self' 'nonce-${nonce}'`,\n \"img-src 'self' data:\",\n \"connect-src 'self'\",\n \"font-src 'self'\",\n \"frame-ancestors 'self'\",\n ].join('; '),\n );\n }\n\n res.send(html);\n });\n\n return { path: docsPath };\n}\n\nfunction resolvePublicDir() {\n const moduleDir =\n typeof __dirname !== 'undefined'\n ? __dirname\n : path.dirname(fileURLToPath(import.meta.url));\n const fromModule = path.resolve(moduleDir, '../public');\n if (fs.existsSync(fromModule)) return fromModule;\n\n // When running from source (ts-node), fall back to the built output path.\n const fallback = path.resolve(moduleDir, '../dist/public');\n if (fs.existsSync(fallback)) return fallback;\n\n return fromModule; // fallback; express static will 404 if missing\n}\n\nfunction normalizePresets(presets: PresetGroup<AnyLeaf>[]): SerializablePreset[] {\n if (!Array.isArray(presets)) return [];\n return presets.map((preset) => ({\n name: preset.name,\n description: preset.description,\n tags: Array.isArray(preset.tags) ? preset.tags.slice() : [],\n docsGroup: preset.docsGroup,\n ops: Array.isArray(preset.ops)\n ? preset.ops.map((op) => ({\n method: typeof op.method === 'string' ? op.method.toUpperCase() : '',\n path: typeof op.path === 'string' ? op.path : '',\n body: op.body,\n query: op.query,\n params: op.params,\n }))\n : [],\n }));\n}\n\nexport { renderLeafDocsHTML } from './docs/docs.js';\nexport { serializeLeaf } from './docs/serializer.js';\nexport type { SerializableLeaf } from './docs/serializer.js';\n","import type { AnyLeaf } from '@emeryld/rrroutes-contract';\nimport type { ReactElement } from 'react';\nimport { renderToStaticMarkup } from 'react-dom/server';\nimport type { SerializablePreset } from './presets.js';\nimport { serializeLeaf } from './serializer.js';\n\nexport interface RenderOptions {\n /** CSP nonce applied to data + script tags. */\n cspNonce?: string;\n /** Base URL where static assets are served (e.g. `/__rrroutes/docs/assets`). */\n assetBasePath?: string;\n /** Root path where the docs are mounted (e.g. `/__rrroutes/docs`). Used for client routing. */\n docsBasePath?: string;\n /** Optional suffix appended to the window origin when building default playground base URLs. */\n baseUrlSuffix?: string;\n /** Preset collections rendered into the docs UI. */\n presets?: SerializablePreset[];\n /** Optional seed history entries to pre-populate the UI (useful in dev). */\n historySeeds?: SerializableHistoryEntry[];\n}\n\nconst DEFAULT_ASSET_BASE = '/__rrroutes/docs/assets';\n\nfunction normalizeBase(base: string) {\n if (!base) return DEFAULT_ASSET_BASE;\n return base.endsWith('/') ? base.slice(0, -1) : base;\n}\n\nfunction normalizeDocsBase(base: string | undefined) {\n if (!base) return '';\n if (base === '/') return '/';\n return base.endsWith('/') && base.length > 1 ? base.slice(0, -1) : base;\n}\n\nfunction normalizeBaseUrlSuffix(suffix: string | undefined) {\n if (!suffix) return '';\n const trimmed = suffix.endsWith('/') && suffix.length > 1 ? suffix.slice(0, -1) : suffix;\n return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;\n}\n\ntype DocsDocumentProps = {\n leavesJson: string;\n presetsJson: string;\n assetBase: string;\n docsBase: string;\n historyJson: string;\n baseUrlSuffix?: string;\n cspNonce?: string;\n};\n\nexport const DocsDocument = ({\n leavesJson,\n presetsJson,\n assetBase,\n docsBase,\n historyJson,\n baseUrlSuffix,\n cspNonce,\n}: DocsDocumentProps) => {\n const cssHref = `${assetBase}/docs.css`;\n const jsSrc = `${assetBase}/docs.js`;\n const configJson = serializeConfig({ docsBasePath: docsBase, baseUrlSuffix });\n\n return (\n <html lang=\"en\">\n <head>\n <meta charSet=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>API Reference</title>\n <link rel=\"stylesheet\" href={cssHref} />\n </head>\n <body>\n <div id=\"docs-root\"></div>\n <script\n id=\"leaf-data\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: leavesJson }}\n />\n <script\n id=\"preset-data\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: presetsJson }}\n />\n <script\n id=\"history-data\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: historyJson }}\n />\n <script\n id=\"docs-config\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: configJson }}\n />\n <script type=\"module\" src={jsSrc} nonce={cspNonce} />\n </body>\n </html>\n );\n};\n\nfunction serializeLeaves(leaves: AnyLeaf[]) {\n return JSON.stringify(leaves.map(serializeLeaf)).replace(/<\\//g, '<\\\\/');\n}\n\nfunction serializePresets(presets: SerializablePreset[] | undefined) {\n return JSON.stringify(Array.isArray(presets) ? presets : []).replace(/<\\//g, '<\\\\/');\n}\n\nfunction serializeHistorySeeds(historySeeds: SerializableHistoryEntry[] | undefined) {\n return JSON.stringify(Array.isArray(historySeeds) ? historySeeds : []).replace(/<\\//g, '<\\\\/');\n}\n\ntype DocsConfig = { docsBasePath: string; baseUrlSuffix?: string };\n\nfunction serializeConfig(config: DocsConfig) {\n return JSON.stringify(config).replace(/<\\//g, '<\\\\/');\n}\n\nexport function createLeafDocsDocument(\n leaves: AnyLeaf[],\n options: RenderOptions = {},\n): ReactElement {\n const assetBase = normalizeBase(options.assetBasePath ?? DEFAULT_ASSET_BASE);\n const leavesJson = serializeLeaves(leaves);\n const presetsJson = serializePresets(options.presets);\n const docsBase = normalizeDocsBase(options.docsBasePath);\n const historyJson = serializeHistorySeeds(options.historySeeds);\n const baseUrlSuffix = normalizeBaseUrlSuffix(options.baseUrlSuffix);\n\n return (\n <DocsDocument\n leavesJson={leavesJson}\n presetsJson={presetsJson}\n assetBase={assetBase}\n docsBase={docsBase}\n historyJson={historyJson}\n baseUrlSuffix={baseUrlSuffix}\n cspNonce={options.cspNonce}\n />\n );\n}\n\nexport function renderLeafDocsHTML(leaves: AnyLeaf[], options: RenderOptions = {}): string {\n const doc = createLeafDocsDocument(leaves, options);\n const html = renderToStaticMarkup(doc);\n return `<!DOCTYPE html>${html}`;\n}\n\nexport type SerializableHistoryEntry = {\n id?: string;\n timestamp: number;\n method: string;\n path: string;\n fullUrl: string;\n params?: Record<string, string>;\n query?: Record<string, string>;\n body?: string;\n output?: string;\n status?: number;\n durationMs: number;\n error?: string;\n};\n","// schemaIntrospection.ts\nimport * as z from \"zod\";\n\nexport type SerializableSchemaNode = {\n kind: string; // \"object\" | \"string\" | \"number\" | ...\n optional?: boolean;\n nullable?: boolean;\n description?: string;\n\n // object\n properties?: Record<string, SerializableSchemaNode>;\n // array\n element?: SerializableSchemaNode;\n // union\n union?: SerializableSchemaNode[];\n // literal\n literal?: unknown;\n // enum\n enumValues?: string[];\n};\n\ntype ZodAny = z.ZodTypeAny;\n\n/**\n * Zod 3 uses `schema._def`, Zod 4 uses `schema._zod.def`.\n */\nfunction getDef(schema: unknown): any | undefined {\n if (!schema || typeof schema !== \"object\") return undefined;\n const anySchema = schema as any;\n return anySchema._zod?.def ?? anySchema._def;\n}\n\n/**\n * Try to get a human-readable description.\n * Zod 4: use metadata/registry; fallback to internal def.description.\n * Zod 3: only internal def.description exists.\n */\nfunction getDescription(schema: ZodAny): string | undefined {\n const anyZ: any = z as any;\n\n // Zod 4 global registry metadata, if present\n const registry = anyZ.globalRegistry?.get\n ? anyZ.globalRegistry.get(schema)\n : undefined;\n if (registry && typeof registry.description === \"string\") {\n return registry.description;\n }\n\n // Legacy / internal description\n const def = getDef(schema);\n if (def && typeof def.description === \"string\") {\n return def.description;\n }\n\n return undefined;\n}\n\n/**\n * Peel off wrappers (effects, optional, nullable, default) and\n * return the inner schema + flags.\n *\n * Supports:\n * - Zod 3: ZodEffects, ZodOptional, ZodNullable, ZodDefault\n * - Zod 4: ZodOptional, ZodNullable, ZodDefault\n */\nfunction unwrap(schema: ZodAny): {\n base: ZodAny;\n optional: boolean;\n nullable: boolean;\n} {\n let s: ZodAny = schema;\n let optional = false;\n let nullable = false;\n\n // Zod 3 only (undefined in Zod 4)\n const ZodEffectsCtor: any = (z as any).ZodEffects;\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n // Zod 3: ZodEffects wrapper\n if (ZodEffectsCtor && s instanceof ZodEffectsCtor) {\n const def = getDef(s) || {};\n const sourceType =\n typeof (s as any).sourceType === \"function\"\n ? (s as any).sourceType()\n : def.schema;\n if (!sourceType) break;\n s = sourceType;\n continue;\n }\n\n // Zod 3 + 4: optional/nullable/default wrappers\n if (s instanceof z.ZodOptional) {\n optional = true;\n const def = getDef(s);\n s = (def && def.innerType) || s; // innerType exists in both 3 & 4\n continue;\n }\n\n if (s instanceof z.ZodNullable) {\n nullable = true;\n const def = getDef(s);\n s = (def && def.innerType) || s;\n continue;\n }\n\n if (s instanceof z.ZodDefault) {\n const def = getDef(s);\n s = (def && def.innerType) || s;\n continue;\n }\n\n break;\n }\n\n return { base: s, optional, nullable };\n}\n\nexport function introspectSchema(\n schema: ZodAny | undefined\n): SerializableSchemaNode | undefined {\n if (!schema) return undefined;\n\n const { base, optional, nullable } = unwrap(schema);\n const def = getDef(base);\n\n const node: SerializableSchemaNode = {\n kind: inferKind(base),\n optional: optional || undefined,\n nullable: nullable || undefined,\n description: getDescription(base),\n };\n\n // OBJECT\n if (base instanceof z.ZodObject) {\n // Zod 3: _def.shape() (function)\n // Zod 4: .shape getter returns an object\n const rawShape: any =\n (base as any).shape ?? (def && typeof def.shape === \"function\"\n ? def.shape()\n : def?.shape);\n\n const shape =\n typeof rawShape === \"function\" ? rawShape() : rawShape ?? {};\n\n const props: Record<string, SerializableSchemaNode> = {};\n for (const key of Object.keys(shape)) {\n const child = shape[key] as ZodAny;\n const childNode = introspectSchema(child);\n if (childNode) props[key] = childNode;\n }\n node.properties = props;\n }\n\n // ARRAY\n if (base instanceof z.ZodArray) {\n // Zod 3: def.type is inner schema\n // Zod 4: def.element is inner schema\n const inner =\n (def && (def.element as ZodAny)) ||\n (def && (def.type as ZodAny)) ||\n undefined;\n if (inner) {\n node.element = introspectSchema(inner);\n }\n }\n\n // UNION\n if (base instanceof z.ZodUnion) {\n const options: ZodAny[] = (def && def.options) || [];\n node.union = options\n .map((opt) => introspectSchema(opt))\n .filter(Boolean) as SerializableSchemaNode[];\n }\n\n // LITERAL\n if (base instanceof z.ZodLiteral) {\n if (def) {\n // Zod 4: def.values (multi-literal)\n if (Array.isArray(def.values)) {\n node.literal =\n def.values.length === 1 ? def.values[0] : def.values.slice();\n } else {\n // Zod 3: def.value\n node.literal = def.value;\n }\n }\n }\n\n // ENUM\n if (base instanceof z.ZodEnum) {\n if (def) {\n if (Array.isArray(def.values)) {\n // Zod 3\n node.enumValues = def.values.slice();\n } else if (def.entries && typeof def.entries === \"object\") {\n // Zod 4: entries is a { key: value } map\n node.enumValues = Object.values(def.entries).map((v: unknown) =>\n String(v)\n );\n }\n }\n }\n\n return node;\n}\n\nfunction inferKind(schema: ZodAny): string {\n // This path still uses instanceof; it works with Zod 4 Classic\n // (importing from \"zod\"). Anything unknown falls back to \"unknown\".\n if (schema instanceof z.ZodString) return \"string\";\n if (schema instanceof z.ZodNumber) return \"number\";\n if (schema instanceof z.ZodBoolean) return \"boolean\";\n if (schema instanceof z.ZodBigInt) return \"bigint\";\n if (schema instanceof z.ZodDate) return \"date\";\n if (schema instanceof z.ZodArray) return \"array\";\n if (schema instanceof z.ZodObject) return \"object\";\n if (schema instanceof z.ZodUnion) return \"union\";\n if (schema instanceof z.ZodLiteral) return \"literal\";\n if (schema instanceof z.ZodEnum) return \"enum\";\n if (schema instanceof z.ZodRecord) return \"record\";\n if (schema instanceof z.ZodTuple) return \"tuple\";\n if (schema instanceof z.ZodUnknown) return \"unknown\";\n if (schema instanceof z.ZodAny) return \"any\";\n\n return \"unknown\";\n}\n","// serializer.ts\nimport type { AnyLeaf, MethodCfg } from \"@emeryld/rrroutes-contract\";\nimport { introspectSchema, SerializableSchemaNode } from \"./schemaIntrospection.js\";\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 // NEW: full Zod ASTs\n bodySchema?: SerializableSchemaNode;\n querySchema?: SerializableSchemaNode;\n paramsSchema?: SerializableSchemaNode;\n outputSchema?: SerializableSchemaNode;\n};\n\nexport type SerializableLeaf = {\n method: string;\n path: string;\n cfg: SerializableMethodCfg;\n};\n\nexport type { SerializableSchemaNode } from \"./schemaIntrospection.js\";\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 bodySchema: introspectSchema(cfg.bodySchema),\n querySchema: introspectSchema(cfg.querySchema),\n paramsSchema: introspectSchema(cfg.paramsSchema),\n outputSchema: introspectSchema(cfg.outputSchema),\n },\n };\n}\n","// renderLeafDocsHTML.ts\nimport type { AnyLeaf } from \"@emeryld/rrroutes-contract\";\nimport {\n createLeafDocsDocument,\n renderLeafDocsHTML as LeafDocsPage,\n RenderOptions,\n} from \"./LeafDocsPage.js\";\n\nexport function renderLeafDocsHTML(leaves: AnyLeaf[], options: RenderOptions = {}): string {\n return LeafDocsPage(leaves, options);\n}\n\nexport type { RenderOptions, SerializableHistoryEntry } from \"./LeafDocsPage.js\";\nexport { createLeafDocsDocument } from \"./LeafDocsPage.js\";\nexport type { SerializablePreset, SerializablePresetOperation } from \"./presets.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,4BAAAA;AAAA,EAAA;AAAA;AAAA;AASA,oBAA4B;AAE5B,qBAAwC;AACxC,qBAAe;AACf,uBAAiB;AACjB,sBAA8B;;;ACZ9B,oBAAqC;;;ACDrC,QAAmB;AAyBnB,SAAS,OAAO,QAAkC;AAChD,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,QAAM,YAAY;AAClB,SAAO,UAAU,MAAM,OAAO,UAAU;AAC1C;AAOA,SAAS,eAAe,QAAoC;AAC1D,QAAM,OAAY;AAGlB,QAAM,WAAW,KAAK,gBAAgB,MAClC,KAAK,eAAe,IAAI,MAAM,IAC9B;AACJ,MAAI,YAAY,OAAO,SAAS,gBAAgB,UAAU;AACxD,WAAO,SAAS;AAAA,EAClB;AAGA,QAAM,MAAM,OAAO,MAAM;AACzB,MAAI,OAAO,OAAO,IAAI,gBAAgB,UAAU;AAC9C,WAAO,IAAI;AAAA,EACb;AAEA,SAAO;AACT;AAUA,SAAS,OAAO,QAId;AACA,MAAI,IAAY;AAChB,MAAI,WAAW;AACf,MAAI,WAAW;AAGf,QAAM,iBAAiC;AAGvC,SAAO,MAAM;AAEX,QAAI,kBAAkB,aAAa,gBAAgB;AACjD,YAAM,MAAM,OAAO,CAAC,KAAK,CAAC;AAC1B,YAAM,aACJ,OAAQ,EAAU,eAAe,aAC5B,EAAU,WAAW,IACtB,IAAI;AACV,UAAI,CAAC,WAAY;AACjB,UAAI;AACJ;AAAA,IACF;AAGA,QAAI,aAAe,eAAa;AAC9B,iB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AAA,MAC9C,MAAM,GAAG;AAAA,MACT,OAAO,GAAG;AAAA,MACV,QAAQ,GAAG;AAAA,IACb,EAAE,IACF,CAAC;AAAA,EACP,EAAE;AACJ;","names":["renderLeafDocsHTML","renderLeafDocsHTML","path","expressStatic","renderLeafDocsHTML","fs"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -40,9 +40,9 @@ export type OpenApiDocsOptions = {
|
|
|
40
40
|
export type Preset<L extends AnyLeaf> = L extends infer A extends AnyLeaf ? {
|
|
41
41
|
method: A['method'];
|
|
42
42
|
path: A['path'];
|
|
43
|
-
body: z.
|
|
44
|
-
query: z.
|
|
45
|
-
params: z.
|
|
43
|
+
body: z.output<A['cfg']['bodySchema']>;
|
|
44
|
+
query: z.output<A['cfg']['querySchema']>;
|
|
45
|
+
params: z.output<A['cfg']['paramsSchema']>;
|
|
46
46
|
} : never;
|
|
47
47
|
export type PresetGroup<L extends AnyLeaf> = {
|
|
48
48
|
name: string;
|
package/dist/index.mjs
CHANGED
|
@@ -173,17 +173,23 @@ function normalizeDocsBase(base) {
|
|
|
173
173
|
if (base === "/") return "/";
|
|
174
174
|
return base.endsWith("/") && base.length > 1 ? base.slice(0, -1) : base;
|
|
175
175
|
}
|
|
176
|
+
function normalizeBaseUrlSuffix(suffix) {
|
|
177
|
+
if (!suffix) return "";
|
|
178
|
+
const trimmed = suffix.endsWith("/") && suffix.length > 1 ? suffix.slice(0, -1) : suffix;
|
|
179
|
+
return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
180
|
+
}
|
|
176
181
|
var DocsDocument = ({
|
|
177
182
|
leavesJson,
|
|
178
183
|
presetsJson,
|
|
179
184
|
assetBase,
|
|
180
185
|
docsBase,
|
|
181
186
|
historyJson,
|
|
187
|
+
baseUrlSuffix,
|
|
182
188
|
cspNonce
|
|
183
189
|
}) => {
|
|
184
190
|
const cssHref = `${assetBase}/docs.css`;
|
|
185
191
|
const jsSrc = `${assetBase}/docs.js`;
|
|
186
|
-
const configJson = serializeConfig(docsBase);
|
|
192
|
+
const configJson = serializeConfig({ docsBasePath: docsBase, baseUrlSuffix });
|
|
187
193
|
return /* @__PURE__ */ jsxs("html", { lang: "en", children: [
|
|
188
194
|
/* @__PURE__ */ jsxs("head", { children: [
|
|
189
195
|
/* @__PURE__ */ jsx("meta", { charSet: "UTF-8" }),
|
|
@@ -242,8 +248,8 @@ function serializePresets(presets) {
|
|
|
242
248
|
function serializeHistorySeeds(historySeeds) {
|
|
243
249
|
return JSON.stringify(Array.isArray(historySeeds) ? historySeeds : []).replace(/<\//g, "<\\/");
|
|
244
250
|
}
|
|
245
|
-
function serializeConfig(
|
|
246
|
-
return JSON.stringify(
|
|
251
|
+
function serializeConfig(config) {
|
|
252
|
+
return JSON.stringify(config).replace(/<\//g, "<\\/");
|
|
247
253
|
}
|
|
248
254
|
function createLeafDocsDocument(leaves, options = {}) {
|
|
249
255
|
const assetBase = normalizeBase(options.assetBasePath ?? DEFAULT_ASSET_BASE);
|
|
@@ -251,6 +257,7 @@ function createLeafDocsDocument(leaves, options = {}) {
|
|
|
251
257
|
const presetsJson = serializePresets(options.presets);
|
|
252
258
|
const docsBase = normalizeDocsBase(options.docsBasePath);
|
|
253
259
|
const historyJson = serializeHistorySeeds(options.historySeeds);
|
|
260
|
+
const baseUrlSuffix = normalizeBaseUrlSuffix(options.baseUrlSuffix);
|
|
254
261
|
return /* @__PURE__ */ jsx(
|
|
255
262
|
DocsDocument,
|
|
256
263
|
{
|
|
@@ -259,6 +266,7 @@ function createLeafDocsDocument(leaves, options = {}) {
|
|
|
259
266
|
assetBase,
|
|
260
267
|
docsBase,
|
|
261
268
|
historyJson,
|
|
269
|
+
baseUrlSuffix,
|
|
262
270
|
cspNonce: options.cspNonce
|
|
263
271
|
}
|
|
264
272
|
);
|
|
@@ -308,6 +316,7 @@ function mountRRRoutesDocs({
|
|
|
308
316
|
cspNonce: nonce,
|
|
309
317
|
assetBasePath: `${prefix}${assetsMountPath}`,
|
|
310
318
|
docsBasePath: `${prefix}${normalizedDocsPath}`,
|
|
319
|
+
baseUrlSuffix: prefix,
|
|
311
320
|
historySeeds: options.historySeeds,
|
|
312
321
|
presets: normalizePresets(finalPresets)
|
|
313
322
|
});
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/docs/LeafDocsPage.tsx","../src/docs/schemaIntrospection.ts","../src/docs/serializer.ts","../src/docs/docs.ts"],"sourcesContent":["/**\n * dry styles\nfake history logs data for testing\ngraphs for history data\nlogs webhook\nsecurity -> gated access + give environment and if environment='production' -> extra \"Are you sure you want to do this\" pop-up for each non-get action\n */\n\nimport type { AnyLeaf } from '@emeryld/rrroutes-contract';\nimport { randomBytes } from 'crypto';\nimport type { Request, Response, Router } from 'express';\nimport { static as expressStatic } from 'express';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport z from 'zod';\nimport type { SerializableHistoryEntry } from './docs/docs.js';\nimport { renderLeafDocsHTML } from './docs/docs.js';\nimport type { SerializablePreset } from './docs/presets.js';\n\nexport type DocsRequestContext = {\n req: Request;\n res: Response;\n leaves: AnyLeaf[];\n presets: PresetGroup<AnyLeaf>[];\n};\n\nexport type DocsOnRequestResult = {\n leaves?: AnyLeaf[];\n presets?: PresetGroup<AnyLeaf>[];\n nonce?: string;\n html?: string;\n};\n\nexport type OpenApiDocsOptions = {\n /** Path where docs are mounted. Defaults to `/__rrroutes/docs`. */\n path?: string;\n prefix?: string;\n /** Whether to emit a CSP header + nonce. Defaults to true. */\n csp?: boolean;\n /** Override where static assets are served from. Defaults to `${path}/assets`. */\n assetBasePath?: string;\n /** Optional seed history entries that will pre-populate the docs UI history. */\n historySeeds?: SerializableHistoryEntry[];\n /**\n * Hook that runs on every request. Use it to adjust leaves, override nonce, or\n * provide a fully custom HTML response.\n */\n onRequest?: (ctx: DocsRequestContext) => DocsOnRequestResult | void;\n};\n\nexport type Preset<L extends AnyLeaf> = L extends infer A extends AnyLeaf? {\n method: A['method'];\n path: A['path'];\n // pre-set values for schemas. Does not have to be complete.\n body: z.input<A['cfg']['bodySchema']>;\n query: z.input<A['cfg']['querySchema']>;\n params: z.input<A['cfg']['paramsSchema']>;\n}:never;\n\nexport type PresetGroup<L extends AnyLeaf> = {\n name: string;\n description?: string;\n tags: string[];\n docsGroup?: string;\n\n ops: Preset<L>[];\n};\n\nexport type MountDocsArgs<L extends AnyLeaf> = {\n router: Router;\n leaves: L[];\n presets?: PresetGroup<L>[];\n options?: OpenApiDocsOptions;\n};\n\nconst trimTrailingSlash = (value: string) =>\n value.endsWith('/') && value.length > 1 ? value.slice(0, -1) : value;\n\nexport function mountRRRoutesDocs<L extends AnyLeaf>({\n router,\n leaves,\n presets = [],\n options = {},\n}: MountDocsArgs<L>) {\n const prefix = options.prefix ? trimTrailingSlash(options.prefix) : '';\n const docsPath = options.path ?? '/__rrroutes/docs';\n const normalizedDocsPath = trimTrailingSlash(docsPath);\n const assetsMountPath = trimTrailingSlash(\n options.assetBasePath ?? `${normalizedDocsPath}/assets`,\n );\n const publicDir = resolvePublicDir();\n const assetsDir = path.join(publicDir, 'assets');\n const cspEnabled = options.csp !== false;\n\n router.use(assetsMountPath, expressStatic(assetsDir, { immutable: true, maxAge: '365d' }));\n\n const docsRoutePaths = [normalizedDocsPath, `${normalizedDocsPath}/`, `${normalizedDocsPath}/*id`];\n\n router.get(docsRoutePaths, (req, res) => {\n const preparedLeaves = Array.isArray(leaves)\n ? leaves.filter((leaf) => leaf.cfg.docsHidden !== true)\n : [];\n const preparedPresets = Array.isArray(presets) ? presets : [];\n const onRequestResult =\n options.onRequest?.({ req, res, leaves: preparedLeaves, presets: preparedPresets }) ?? {};\n const finalLeaves = onRequestResult.leaves ?? preparedLeaves;\n const finalPresets = onRequestResult.presets ?? preparedPresets;\n\n const hasCustomHtml = typeof onRequestResult.html === 'string';\n\n let nonce = onRequestResult.nonce;\n if (!nonce && cspEnabled && !hasCustomHtml) {\n nonce = randomBytes(16).toString('base64');\n }\n\n const html = hasCustomHtml\n ? (onRequestResult.html as string)\n : renderLeafDocsHTML(finalLeaves, {\n cspNonce: nonce,\n assetBasePath: `${prefix}${assetsMountPath}`,\n docsBasePath: `${prefix}${normalizedDocsPath}`,\n historySeeds: options.historySeeds,\n presets: normalizePresets(finalPresets),\n });\n\n if (cspEnabled && nonce) {\n res.setHeader(\n 'Content-Security-Policy',\n [\n \"default-src 'self'\",\n `script-src 'self' 'nonce-${nonce}'`,\n `style-src 'self' 'nonce-${nonce}'`,\n \"img-src 'self' data:\",\n \"connect-src 'self'\",\n \"font-src 'self'\",\n \"frame-ancestors 'self'\",\n ].join('; '),\n );\n }\n\n res.send(html);\n });\n\n return { path: docsPath };\n}\n\nfunction resolvePublicDir() {\n const moduleDir =\n typeof __dirname !== 'undefined'\n ? __dirname\n : path.dirname(fileURLToPath(import.meta.url));\n const fromModule = path.resolve(moduleDir, '../public');\n if (fs.existsSync(fromModule)) return fromModule;\n\n // When running from source (ts-node), fall back to the built output path.\n const fallback = path.resolve(moduleDir, '../dist/public');\n if (fs.existsSync(fallback)) return fallback;\n\n return fromModule; // fallback; express static will 404 if missing\n}\n\nfunction normalizePresets(presets: PresetGroup<AnyLeaf>[]): SerializablePreset[] {\n if (!Array.isArray(presets)) return [];\n return presets.map((preset) => ({\n name: preset.name,\n description: preset.description,\n tags: Array.isArray(preset.tags) ? preset.tags.slice() : [],\n docsGroup: preset.docsGroup,\n ops: Array.isArray(preset.ops)\n ? preset.ops.map((op) => ({\n method: typeof op.method === 'string' ? op.method.toUpperCase() : '',\n path: typeof op.path === 'string' ? op.path : '',\n body: op.body,\n query: op.query,\n params: op.params,\n }))\n : [],\n }));\n}\n\nexport { renderLeafDocsHTML } from './docs/docs.js';\nexport { serializeLeaf } from './docs/serializer.js';\nexport type { SerializableLeaf } from './docs/serializer.js';\n","import type { AnyLeaf } from '@emeryld/rrroutes-contract';\nimport type { ReactElement } from 'react';\nimport { renderToStaticMarkup } from 'react-dom/server';\nimport type { SerializablePreset } from './presets.js';\nimport { serializeLeaf } from './serializer.js';\n\nexport interface RenderOptions {\n /** CSP nonce applied to data + script tags. */\n cspNonce?: string;\n /** Base URL where static assets are served (e.g. `/__rrroutes/docs/assets`). */\n assetBasePath?: string;\n /** Root path where the docs are mounted (e.g. `/__rrroutes/docs`). Used for client routing. */\n docsBasePath?: string;\n /** Preset collections rendered into the docs UI. */\n presets?: SerializablePreset[];\n /** Optional seed history entries to pre-populate the UI (useful in dev). */\n historySeeds?: SerializableHistoryEntry[];\n}\n\nconst DEFAULT_ASSET_BASE = '/__rrroutes/docs/assets';\n\nfunction normalizeBase(base: string) {\n if (!base) return DEFAULT_ASSET_BASE;\n return base.endsWith('/') ? base.slice(0, -1) : base;\n}\n\nfunction normalizeDocsBase(base: string | undefined) {\n if (!base) return '';\n if (base === '/') return '/';\n return base.endsWith('/') && base.length > 1 ? base.slice(0, -1) : base;\n}\n\ntype DocsDocumentProps = {\n leavesJson: string;\n presetsJson: string;\n assetBase: string;\n docsBase: string;\n historyJson: string;\n cspNonce?: string;\n};\n\nexport const DocsDocument = ({\n leavesJson,\n presetsJson,\n assetBase,\n docsBase,\n historyJson,\n cspNonce,\n}: DocsDocumentProps) => {\n const cssHref = `${assetBase}/docs.css`;\n const jsSrc = `${assetBase}/docs.js`;\n const configJson = serializeConfig(docsBase);\n\n return (\n <html lang=\"en\">\n <head>\n <meta charSet=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>API Reference</title>\n <link rel=\"stylesheet\" href={cssHref} />\n </head>\n <body>\n <div id=\"docs-root\"></div>\n <script\n id=\"leaf-data\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: leavesJson }}\n />\n <script\n id=\"preset-data\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: presetsJson }}\n />\n <script\n id=\"history-data\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: historyJson }}\n />\n <script\n id=\"docs-config\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: configJson }}\n />\n <script type=\"module\" src={jsSrc} nonce={cspNonce} />\n </body>\n </html>\n );\n};\n\nfunction serializeLeaves(leaves: AnyLeaf[]) {\n return JSON.stringify(leaves.map(serializeLeaf)).replace(/<\\//g, '<\\\\/');\n}\n\nfunction serializePresets(presets: SerializablePreset[] | undefined) {\n return JSON.stringify(Array.isArray(presets) ? presets : []).replace(/<\\//g, '<\\\\/');\n}\n\nfunction serializeHistorySeeds(historySeeds: SerializableHistoryEntry[] | undefined) {\n return JSON.stringify(Array.isArray(historySeeds) ? historySeeds : []).replace(/<\\//g, '<\\\\/');\n}\n\nfunction serializeConfig(docsBase: string) {\n return JSON.stringify({ docsBasePath: docsBase }).replace(/<\\//g, '<\\\\/');\n}\n\nexport function createLeafDocsDocument(\n leaves: AnyLeaf[],\n options: RenderOptions = {},\n): ReactElement {\n const assetBase = normalizeBase(options.assetBasePath ?? DEFAULT_ASSET_BASE);\n const leavesJson = serializeLeaves(leaves);\n const presetsJson = serializePresets(options.presets);\n const docsBase = normalizeDocsBase(options.docsBasePath);\n const historyJson = serializeHistorySeeds(options.historySeeds);\n\n return (\n <DocsDocument\n leavesJson={leavesJson}\n presetsJson={presetsJson}\n assetBase={assetBase}\n docsBase={docsBase}\n historyJson={historyJson}\n cspNonce={options.cspNonce}\n />\n );\n}\n\nexport function renderLeafDocsHTML(leaves: AnyLeaf[], options: RenderOptions = {}): string {\n const doc = createLeafDocsDocument(leaves, options);\n const html = renderToStaticMarkup(doc);\n return `<!DOCTYPE html>${html}`;\n}\n\nexport type SerializableHistoryEntry = {\n id?: string;\n timestamp: number;\n method: string;\n path: string;\n fullUrl: string;\n params?: Record<string, string>;\n query?: Record<string, string>;\n body?: string;\n output?: string;\n status?: number;\n durationMs: number;\n error?: string;\n};\n","// schemaIntrospection.ts\nimport * as z from \"zod\";\n\nexport type SerializableSchemaNode = {\n kind: string; // \"object\" | \"string\" | \"number\" | ...\n optional?: boolean;\n nullable?: boolean;\n description?: string;\n\n // object\n properties?: Record<string, SerializableSchemaNode>;\n // array\n element?: SerializableSchemaNode;\n // union\n union?: SerializableSchemaNode[];\n // literal\n literal?: unknown;\n // enum\n enumValues?: string[];\n};\n\ntype ZodAny = z.ZodTypeAny;\n\n/**\n * Zod 3 uses `schema._def`, Zod 4 uses `schema._zod.def`.\n */\nfunction getDef(schema: unknown): any | undefined {\n if (!schema || typeof schema !== \"object\") return undefined;\n const anySchema = schema as any;\n return anySchema._zod?.def ?? anySchema._def;\n}\n\n/**\n * Try to get a human-readable description.\n * Zod 4: use metadata/registry; fallback to internal def.description.\n * Zod 3: only internal def.description exists.\n */\nfunction getDescription(schema: ZodAny): string | undefined {\n const anyZ: any = z as any;\n\n // Zod 4 global registry metadata, if present\n const registry = anyZ.globalRegistry?.get\n ? anyZ.globalRegistry.get(schema)\n : undefined;\n if (registry && typeof registry.description === \"string\") {\n return registry.description;\n }\n\n // Legacy / internal description\n const def = getDef(schema);\n if (def && typeof def.description === \"string\") {\n return def.description;\n }\n\n return undefined;\n}\n\n/**\n * Peel off wrappers (effects, optional, nullable, default) and\n * return the inner schema + flags.\n *\n * Supports:\n * - Zod 3: ZodEffects, ZodOptional, ZodNullable, ZodDefault\n * - Zod 4: ZodOptional, ZodNullable, ZodDefault\n */\nfunction unwrap(schema: ZodAny): {\n base: ZodAny;\n optional: boolean;\n nullable: boolean;\n} {\n let s: ZodAny = schema;\n let optional = false;\n let nullable = false;\n\n // Zod 3 only (undefined in Zod 4)\n const ZodEffectsCtor: any = (z as any).ZodEffects;\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n // Zod 3: ZodEffects wrapper\n if (ZodEffectsCtor && s instanceof ZodEffectsCtor) {\n const def = getDef(s) || {};\n const sourceType =\n typeof (s as any).sourceType === \"function\"\n ? (s as any).sourceType()\n : def.schema;\n if (!sourceType) break;\n s = sourceType;\n continue;\n }\n\n // Zod 3 + 4: optional/nullable/default wrappers\n if (s instanceof z.ZodOptional) {\n optional = true;\n const def = getDef(s);\n s = (def && def.innerType) || s; // innerType exists in both 3 & 4\n continue;\n }\n\n if (s instanceof z.ZodNullable) {\n nullable = true;\n const def = getDef(s);\n s = (def && def.innerType) || s;\n continue;\n }\n\n if (s instanceof z.ZodDefault) {\n const def = getDef(s);\n s = (def && def.innerType) || s;\n continue;\n }\n\n break;\n }\n\n return { base: s, optional, nullable };\n}\n\nexport function introspectSchema(\n schema: ZodAny | undefined\n): SerializableSchemaNode | undefined {\n if (!schema) return undefined;\n\n const { base, optional, nullable } = unwrap(schema);\n const def = getDef(base);\n\n const node: SerializableSchemaNode = {\n kind: inferKind(base),\n optional: optional || undefined,\n nullable: nullable || undefined,\n description: getDescription(base),\n };\n\n // OBJECT\n if (base instanceof z.ZodObject) {\n // Zod 3: _def.shape() (function)\n // Zod 4: .shape getter returns an object\n const rawShape: any =\n (base as any).shape ?? (def && typeof def.shape === \"function\"\n ? def.shape()\n : def?.shape);\n\n const shape =\n typeof rawShape === \"function\" ? rawShape() : rawShape ?? {};\n\n const props: Record<string, SerializableSchemaNode> = {};\n for (const key of Object.keys(shape)) {\n const child = shape[key] as ZodAny;\n const childNode = introspectSchema(child);\n if (childNode) props[key] = childNode;\n }\n node.properties = props;\n }\n\n // ARRAY\n if (base instanceof z.ZodArray) {\n // Zod 3: def.type is inner schema\n // Zod 4: def.element is inner schema\n const inner =\n (def && (def.element as ZodAny)) ||\n (def && (def.type as ZodAny)) ||\n undefined;\n if (inner) {\n node.element = introspectSchema(inner);\n }\n }\n\n // UNION\n if (base instanceof z.ZodUnion) {\n const options: ZodAny[] = (def && def.options) || [];\n node.union = options\n .map((opt) => introspectSchema(opt))\n .filter(Boolean) as SerializableSchemaNode[];\n }\n\n // LITERAL\n if (base instanceof z.ZodLiteral) {\n if (def) {\n // Zod 4: def.values (multi-literal)\n if (Array.isArray(def.values)) {\n node.literal =\n def.values.length === 1 ? def.values[0] : def.values.slice();\n } else {\n // Zod 3: def.value\n node.literal = def.value;\n }\n }\n }\n\n // ENUM\n if (base instanceof z.ZodEnum) {\n if (def) {\n if (Array.isArray(def.values)) {\n // Zod 3\n node.enumValues = def.values.slice();\n } else if (def.entries && typeof def.entries === \"object\") {\n // Zod 4: entries is a { key: value } map\n node.enumValues = Object.values(def.entries).map((v: unknown) =>\n String(v)\n );\n }\n }\n }\n\n return node;\n}\n\nfunction inferKind(schema: ZodAny): string {\n // This path still uses instanceof; it works with Zod 4 Classic\n // (importing from \"zod\"). Anything unknown falls back to \"unknown\".\n if (schema instanceof z.ZodString) return \"string\";\n if (schema instanceof z.ZodNumber) return \"number\";\n if (schema instanceof z.ZodBoolean) return \"boolean\";\n if (schema instanceof z.ZodBigInt) return \"bigint\";\n if (schema instanceof z.ZodDate) return \"date\";\n if (schema instanceof z.ZodArray) return \"array\";\n if (schema instanceof z.ZodObject) return \"object\";\n if (schema instanceof z.ZodUnion) return \"union\";\n if (schema instanceof z.ZodLiteral) return \"literal\";\n if (schema instanceof z.ZodEnum) return \"enum\";\n if (schema instanceof z.ZodRecord) return \"record\";\n if (schema instanceof z.ZodTuple) return \"tuple\";\n if (schema instanceof z.ZodUnknown) return \"unknown\";\n if (schema instanceof z.ZodAny) return \"any\";\n\n return \"unknown\";\n}\n","// serializer.ts\nimport type { AnyLeaf, MethodCfg } from \"@emeryld/rrroutes-contract\";\nimport { introspectSchema, SerializableSchemaNode } from \"./schemaIntrospection.js\";\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 // NEW: full Zod ASTs\n bodySchema?: SerializableSchemaNode;\n querySchema?: SerializableSchemaNode;\n paramsSchema?: SerializableSchemaNode;\n outputSchema?: SerializableSchemaNode;\n};\n\nexport type SerializableLeaf = {\n method: string;\n path: string;\n cfg: SerializableMethodCfg;\n};\n\nexport type { SerializableSchemaNode } from \"./schemaIntrospection.js\";\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 bodySchema: introspectSchema(cfg.bodySchema),\n querySchema: introspectSchema(cfg.querySchema),\n paramsSchema: introspectSchema(cfg.paramsSchema),\n outputSchema: introspectSchema(cfg.outputSchema),\n },\n };\n}\n","// renderLeafDocsHTML.ts\nimport type { AnyLeaf } from \"@emeryld/rrroutes-contract\";\nimport {\n createLeafDocsDocument,\n renderLeafDocsHTML as LeafDocsPage,\n RenderOptions,\n} from \"./LeafDocsPage.js\";\n\nexport function renderLeafDocsHTML(leaves: AnyLeaf[], options: RenderOptions = {}): string {\n return LeafDocsPage(leaves, options);\n}\n\nexport type { RenderOptions, SerializableHistoryEntry } from \"./LeafDocsPage.js\";\nexport { createLeafDocsDocument } from \"./LeafDocsPage.js\";\nexport type { SerializablePreset, SerializablePresetOperation } from \"./presets.js\";\n"],"mappings":";AASA,SAAS,mBAAmB;AAE5B,SAAS,UAAU,qBAAqB;AACxC,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;;;ACZ9B,SAAS,4BAA4B;;;ACDrC,YAAY,OAAO;AAyBnB,SAAS,OAAO,QAAkC;AAChD,MAAI,CAAC,UAA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AO,CAAC;AACrC,SAAO,QAAQ,IAAI,CAAC,YAAY;AAAA,IAC9B,MAAM,OAAO;AAAA,IACb,aAAa,OAAO;AAAA,IACpB,MAAM,MAAM,QAAQ,OAAO,IAAI,IAAI,OAAO,KAAK,MAAM,IAAI,CAAC;AAAA,IAC1D,WAAW,OAAO;AAAA,IAClB,KAAK,MAAM,QAAQ,OAAO,GAAG,IACzB,OAAO,IAAI,IAAI,CAAC,QAAQ;AAAA,MACtB,QAAQ,OAAO,GAAG,WAAW,WAAW,GAAG,OAAO,YAAY,IAAI;AAAA,MAClE,MAAM,OAAO,GAAG,SAAS,WAAW,GAAG,OAAO;AAAA,MAC9C,MAAM,GAAG;AAAA,MACT,OAAO,GAAG;AAAA,MACV,QAAQ,GAAG;AAAA,IACb,EAAE,IACF,CAAC;AAAA,EACP,EAAE;AACJ;","names":["renderLeafDocsHTML","renderLeafDocsHTML"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/docs/LeafDocsPage.tsx","../src/docs/schemaIntrospection.ts","../src/docs/serializer.ts","../src/docs/docs.ts"],"sourcesContent":["/**\n * dry styles\nfake history logs data for testing\ngraphs for history data\nlogs webhook\nsecurity -> gated access + give environment and if environment='production' -> extra \"Are you sure you want to do this\" pop-up for each non-get action\n */\n\nimport type { AnyLeaf } from '@emeryld/rrroutes-contract';\nimport { randomBytes } from 'crypto';\nimport type { Request, Response, Router } from 'express';\nimport { static as expressStatic } from 'express';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport z from 'zod';\nimport type { SerializableHistoryEntry } from './docs/docs.js';\nimport { renderLeafDocsHTML } from './docs/docs.js';\nimport type { SerializablePreset } from './docs/presets.js';\n\nexport type DocsRequestContext = {\n req: Request;\n res: Response;\n leaves: AnyLeaf[];\n presets: PresetGroup<AnyLeaf>[];\n};\n\nexport type DocsOnRequestResult = {\n leaves?: AnyLeaf[];\n presets?: PresetGroup<AnyLeaf>[];\n nonce?: string;\n html?: string;\n};\n\nexport type OpenApiDocsOptions = {\n /** Path where docs are mounted. Defaults to `/__rrroutes/docs`. */\n path?: string;\n prefix?: string;\n /** Whether to emit a CSP header + nonce. Defaults to true. */\n csp?: boolean;\n /** Override where static assets are served from. Defaults to `${path}/assets`. */\n assetBasePath?: string;\n /** Optional seed history entries that will pre-populate the docs UI history. */\n historySeeds?: SerializableHistoryEntry[];\n /**\n * Hook that runs on every request. Use it to adjust leaves, override nonce, or\n * provide a fully custom HTML response.\n */\n onRequest?: (ctx: DocsRequestContext) => DocsOnRequestResult | void;\n};\n\nexport type Preset<L extends AnyLeaf> = L extends infer A extends AnyLeaf? {\n method: A['method'];\n path: A['path'];\n // pre-set values for schemas. Does not have to be complete.\n body: z.output<A['cfg']['bodySchema']>;\n query: z.output<A['cfg']['querySchema']>;\n params: z.output<A['cfg']['paramsSchema']>;\n}:never;\n\nexport type PresetGroup<L extends AnyLeaf> = {\n name: string;\n description?: string;\n tags: string[];\n docsGroup?: string;\n\n ops: Preset<L>[];\n};\n\nexport type MountDocsArgs<L extends AnyLeaf> = {\n router: Router;\n leaves: L[];\n presets?: PresetGroup<L>[];\n options?: OpenApiDocsOptions;\n};\n\nconst trimTrailingSlash = (value: string) =>\n value.endsWith('/') && value.length > 1 ? value.slice(0, -1) : value;\n\nexport function mountRRRoutesDocs<L extends AnyLeaf>({\n router,\n leaves,\n presets = [],\n options = {},\n}: MountDocsArgs<L>) {\n const prefix = options.prefix ? trimTrailingSlash(options.prefix) : '';\n const docsPath = options.path ?? '/__rrroutes/docs';\n const normalizedDocsPath = trimTrailingSlash(docsPath);\n const assetsMountPath = trimTrailingSlash(\n options.assetBasePath ?? `${normalizedDocsPath}/assets`,\n );\n const publicDir = resolvePublicDir();\n const assetsDir = path.join(publicDir, 'assets');\n const cspEnabled = options.csp !== false;\n\n router.use(assetsMountPath, expressStatic(assetsDir, { immutable: true, maxAge: '365d' }));\n\n const docsRoutePaths = [normalizedDocsPath, `${normalizedDocsPath}/`, `${normalizedDocsPath}/*id`];\n\n router.get(docsRoutePaths, (req, res) => {\n const preparedLeaves = Array.isArray(leaves)\n ? leaves.filter((leaf) => leaf.cfg.docsHidden !== true)\n : [];\n const preparedPresets = Array.isArray(presets) ? presets : [];\n const onRequestResult =\n options.onRequest?.({ req, res, leaves: preparedLeaves, presets: preparedPresets }) ?? {};\n const finalLeaves = onRequestResult.leaves ?? preparedLeaves;\n const finalPresets = onRequestResult.presets ?? preparedPresets;\n\n const hasCustomHtml = typeof onRequestResult.html === 'string';\n\n let nonce = onRequestResult.nonce;\n if (!nonce && cspEnabled && !hasCustomHtml) {\n nonce = randomBytes(16).toString('base64');\n }\n\n const html = hasCustomHtml\n ? (onRequestResult.html as string)\n : renderLeafDocsHTML(finalLeaves, {\n cspNonce: nonce,\n assetBasePath: `${prefix}${assetsMountPath}`,\n docsBasePath: `${prefix}${normalizedDocsPath}`,\n baseUrlSuffix: prefix,\n historySeeds: options.historySeeds,\n presets: normalizePresets(finalPresets),\n });\n\n if (cspEnabled && nonce) {\n res.setHeader(\n 'Content-Security-Policy',\n [\n \"default-src 'self'\",\n `script-src 'self' 'nonce-${nonce}'`,\n `style-src 'self' 'nonce-${nonce}'`,\n \"img-src 'self' data:\",\n \"connect-src 'self'\",\n \"font-src 'self'\",\n \"frame-ancestors 'self'\",\n ].join('; '),\n );\n }\n\n res.send(html);\n });\n\n return { path: docsPath };\n}\n\nfunction resolvePublicDir() {\n const moduleDir =\n typeof __dirname !== 'undefined'\n ? __dirname\n : path.dirname(fileURLToPath(import.meta.url));\n const fromModule = path.resolve(moduleDir, '../public');\n if (fs.existsSync(fromModule)) return fromModule;\n\n // When running from source (ts-node), fall back to the built output path.\n const fallback = path.resolve(moduleDir, '../dist/public');\n if (fs.existsSync(fallback)) return fallback;\n\n return fromModule; // fallback; express static will 404 if missing\n}\n\nfunction normalizePresets(presets: PresetGroup<AnyLeaf>[]): SerializablePreset[] {\n if (!Array.isArray(presets)) return [];\n return presets.map((preset) => ({\n name: preset.name,\n description: preset.description,\n tags: Array.isArray(preset.tags) ? preset.tags.slice() : [],\n docsGroup: preset.docsGroup,\n ops: Array.isArray(preset.ops)\n ? preset.ops.map((op) => ({\n method: typeof op.method === 'string' ? op.method.toUpperCase() : '',\n path: typeof op.path === 'string' ? op.path : '',\n body: op.body,\n query: op.query,\n params: op.params,\n }))\n : [],\n }));\n}\n\nexport { renderLeafDocsHTML } from './docs/docs.js';\nexport { serializeLeaf } from './docs/serializer.js';\nexport type { SerializableLeaf } from './docs/serializer.js';\n","import type { AnyLeaf } from '@emeryld/rrroutes-contract';\nimport type { ReactElement } from 'react';\nimport { renderToStaticMarkup } from 'react-dom/server';\nimport type { SerializablePreset } from './presets.js';\nimport { serializeLeaf } from './serializer.js';\n\nexport interface RenderOptions {\n /** CSP nonce applied to data + script tags. */\n cspNonce?: string;\n /** Base URL where static assets are served (e.g. `/__rrroutes/docs/assets`). */\n assetBasePath?: string;\n /** Root path where the docs are mounted (e.g. `/__rrroutes/docs`). Used for client routing. */\n docsBasePath?: string;\n /** Optional suffix appended to the window origin when building default playground base URLs. */\n baseUrlSuffix?: string;\n /** Preset collections rendered into the docs UI. */\n presets?: SerializablePreset[];\n /** Optional seed history entries to pre-populate the UI (useful in dev). */\n historySeeds?: SerializableHistoryEntry[];\n}\n\nconst DEFAULT_ASSET_BASE = '/__rrroutes/docs/assets';\n\nfunction normalizeBase(base: string) {\n if (!base) return DEFAULT_ASSET_BASE;\n return base.endsWith('/') ? base.slice(0, -1) : base;\n}\n\nfunction normalizeDocsBase(base: string | undefined) {\n if (!base) return '';\n if (base === '/') return '/';\n return base.endsWith('/') && base.length > 1 ? base.slice(0, -1) : base;\n}\n\nfunction normalizeBaseUrlSuffix(suffix: string | undefined) {\n if (!suffix) return '';\n const trimmed = suffix.endsWith('/') && suffix.length > 1 ? suffix.slice(0, -1) : suffix;\n return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;\n}\n\ntype DocsDocumentProps = {\n leavesJson: string;\n presetsJson: string;\n assetBase: string;\n docsBase: string;\n historyJson: string;\n baseUrlSuffix?: string;\n cspNonce?: string;\n};\n\nexport const DocsDocument = ({\n leavesJson,\n presetsJson,\n assetBase,\n docsBase,\n historyJson,\n baseUrlSuffix,\n cspNonce,\n}: DocsDocumentProps) => {\n const cssHref = `${assetBase}/docs.css`;\n const jsSrc = `${assetBase}/docs.js`;\n const configJson = serializeConfig({ docsBasePath: docsBase, baseUrlSuffix });\n\n return (\n <html lang=\"en\">\n <head>\n <meta charSet=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>API Reference</title>\n <link rel=\"stylesheet\" href={cssHref} />\n </head>\n <body>\n <div id=\"docs-root\"></div>\n <script\n id=\"leaf-data\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: leavesJson }}\n />\n <script\n id=\"preset-data\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: presetsJson }}\n />\n <script\n id=\"history-data\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: historyJson }}\n />\n <script\n id=\"docs-config\"\n type=\"application/json\"\n nonce={cspNonce}\n dangerouslySetInnerHTML={{ __html: configJson }}\n />\n <script type=\"module\" src={jsSrc} nonce={cspNonce} />\n </body>\n </html>\n );\n};\n\nfunction serializeLeaves(leaves: AnyLeaf[]) {\n return JSON.stringify(leaves.map(serializeLeaf)).replace(/<\\//g, '<\\\\/');\n}\n\nfunction serializePresets(presets: SerializablePreset[] | undefined) {\n return JSON.stringify(Array.isArray(presets) ? presets : []).replace(/<\\//g, '<\\\\/');\n}\n\nfunction serializeHistorySeeds(historySeeds: SerializableHistoryEntry[] | undefined) {\n return JSON.stringify(Array.isArray(historySeeds) ? historySeeds : []).replace(/<\\//g, '<\\\\/');\n}\n\ntype DocsConfig = { docsBasePath: string; baseUrlSuffix?: string };\n\nfunction serializeConfig(config: DocsConfig) {\n return JSON.stringify(config).replace(/<\\//g, '<\\\\/');\n}\n\nexport function createLeafDocsDocument(\n leaves: AnyLeaf[],\n options: RenderOptions = {},\n): ReactElement {\n const assetBase = normalizeBase(options.assetBasePath ?? DEFAULT_ASSET_BASE);\n const leavesJson = serializeLeaves(leaves);\n const presetsJson = serializePresets(options.presets);\n const docsBase = normalizeDocsBase(options.docsBasePath);\n const historyJson = serializeHistorySeeds(options.historySeeds);\n const baseUrlSuffix = normalizeBaseUrlSuffix(options.baseUrlSuffix);\n\n return (\n <DocsDocument\n leavesJson={leavesJson}\n presetsJson={presetsJson}\n assetBase={assetBase}\n docsBase={docsBase}\n historyJson={historyJson}\n baseUrlSuffix={baseUrlSuffix}\n cspNonce={options.cspNonce}\n />\n );\n}\n\nexport function renderLeafDocsHTML(leaves: AnyLeaf[], options: RenderOptions = {}): string {\n const doc = createLeafDocsDocument(leaves, options);\n const html = renderToStaticMarkup(doc);\n return `<!DOCTYPE html>${html}`;\n}\n\nexport type SerializableHistoryEntry = {\n id?: string;\n timestamp: number;\n method: string;\n path: string;\n fullUrl: string;\n params?: Record<string, string>;\n query?: Record<string, string>;\n body?: string;\n output?: string;\n status?: number;\n durationMs: number;\n error?: string;\n};\n","// schemaIntrospection.ts\nimport * as z from \"zod\";\n\nexport type SerializableSchemaNode = {\n kind: string; // \"object\" | \"string\" | \"number\" | ...\n optional?: boolean;\n nullable?: boolean;\n description?: string;\n\n // object\n properties?: Record<string, SerializableSchemaNode>;\n // array\n element?: SerializableSchemaNode;\n // union\n union?: SerializableSchemaNode[];\n // literal\n literal?: unknown;\n // enum\n enumValues?: string[];\n};\n\ntype ZodAny = z.ZodTypeAny;\n\n/**\n * Zod 3 uses `schema._def`, Zod 4 uses `schema._zod.def`.\n */\nfunction getDef(schema: unknown): any | undefined {\n if (!schema || typeof schema !== \"object\") return undefined;\n const anySchema = schema as any;\n return anySchema._zod?.def ?? anySchema._def;\n}\n\n/**\n * Try to get a human-readable description.\n * Zod 4: use metadata/registry; fallback to internal def.description.\n * Zod 3: only internal def.description exists.\n */\nfunction getDescription(schema: ZodAny): string | undefined {\n const anyZ: any = z as any;\n\n // Zod 4 global registry metadata, if present\n const registry = anyZ.globalRegistry?.get\n ? anyZ.globalRegistry.get(schema)\n : undefined;\n if (registry && typeof registry.description === \"string\") {\n return registry.description;\n }\n\n // Legacy / internal description\n const def = getDef(schema);\n if (def && typeof def.description === \"string\") {\n return def.description;\n }\n\n return undefined;\n}\n\n/**\n * Peel off wrappers (effects, optional, nullable, default) and\n * return the inner schema + flags.\n *\n * Supports:\n * - Zod 3: ZodEffects, ZodOptional, ZodNullable, ZodDefault\n * - Zod 4: ZodOptional, ZodNullable, ZodDefault\n */\nfunction unwrap(schema: ZodAny): {\n base: ZodAny;\n optional: boolean;\n nullable: boolean;\n} {\n let s: ZodAny = schema;\n let optional = false;\n let nullable = false;\n\n // Zod 3 only (undefined in Zod 4)\n const ZodEffectsCtor: any = (z as any).ZodEffects;\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n // Zod 3: ZodEffects wrapper\n if (ZodEffectsCtor && s instanceof ZodEffectsCtor) {\n const def = getDef(s) || {};\n const sourceType =\n typeof (s as any).sourceType === \"function\"\n ? (s as any).sourceType()\n : def.schema;\n if (!sourceType) break;\n s = sourceType;\n continue;\n }\n\n // Zod 3 + 4: optional/nullable/default wrappers\n if (s instanceof z.ZodOptional) {\n optional = true;\n const def = getDef(s);\n s = (def && def.innerType) || s; // innerType exists in both 3 & 4\n continue;\n }\n\n if (s instanceof z.ZodNullable) {\n nullable = true;\n const def = getDef(s);\n s = (def && def.innerType) || s;\n continue;\n }\n\n if (s instanceof z.ZodDefault) {\n const def = getDef(s);\n s = (def && def.innerType) || s;\n continue;\n }\n\n break;\n }\n\n return { base: s, optional, nullable };\n}\n\nexport function introspectSchema(\n schema: ZodAny | undefined\n): SerializableSchemaNode | undefined {\n if (!schema) return undefined;\n\n const { base, optional, nullable } = unwrap(schema);\n const def = getDef(base);\n\n const node: SerializableSchemaNode = {\n kind: inferKind(base),\n optional: optional || undefined,\n nullable: nullable || undefined,\n description: getDescription(base),\n };\n\n // OBJECT\n if (base instanceof z.ZodObject) {\n // Zod 3: _def.shape() (function)\n // Zod 4: .shape getter returns an object\n const rawShape: any =\n (base as any).shape ?? (def && typeof def.shape === \"function\"\n ? def.shape()\n : def?.shape);\n\n const shape =\n typeof rawShape === \"function\" ? rawShape() : rawShape ?? {};\n\n const props: Record<string, SerializableSchemaNode> = {};\n for (const key of Object.keys(shape)) {\n const child = shape[key] as ZodAny;\n const childNode = introspectSchema(child);\n if (childNode) props[key] = childNode;\n }\n node.properties = props;\n }\n\n // ARRAY\n if (base instanceof z.ZodArray) {\n // Zod 3: def.type is inner schema\n // Zod 4: def.element is inner schema\n const inner =\n (def && (def.element as ZodAny)) ||\n (def && (def.type as ZodAny)) ||\n undefined;\n if (inner) {\n node.element = introspectSchema(inner);\n }\n }\n\n // UNION\n if (base instanceof z.ZodUnion) {\n const options: ZodAny[] = (def && def.options) || [];\n node.union = options\n .map((opt) => introspectSchema(opt))\n .filter(Boolean) as SerializableSchemaNode[];\n }\n\n // LITERAL\n if (base instanceof z.ZodLiteral) {\n if (def) {\n // Zod 4: def.values (multi-literal)\n if (Array.isArray(def.values)) {\n node.literal =\n def.values.length === 1 ? def.values[0] : def.values.slice();\n } else {\n // Zod 3: def.value\n node.literal = def.value;\n }\n }\n }\n\n // ENUM\n if (base instanceof z.ZodEnum) {\n if (def) {\n if (Array.isArray(def.values)) {\n // Zod 3\n node.enumValues = def.values.slice();\n } else if (def.entries && typeof def.entries === \"object\") {\n // Zod 4: entries is a { key: value } map\n node.enumValues = Object.values(def.entries).map((v: unknown) =>\n String(v)\n );\n }\n }\n }\n\n return node;\n}\n\nfunction inferKind(schema: ZodAny): string {\n // This path still uses instanceof; it works with Zod 4 Classic\n // (importing from \"zod\"). Anything unknown falls back to \"unknown\".\n if (schema instanceof z.ZodString) return \"string\";\n if (schema instanceof z.ZodNumber) return \"number\";\n if (schema instanceof z.ZodBoolean) return \"boolean\";\n if (schema instanceof z.ZodBigInt) return \"bigint\";\n if (schema instanceof z.ZodDate) return \"date\";\n if (schema instanceof z.ZodArray) return \"array\";\n if (schema instanceof z.ZodObject) return \"object\";\n if (schema instanceof z.ZodUnion) return \"union\";\n if (schema instanceof z.ZodLiteral) return \"literal\";\n if (schema instanceof z.ZodEnum) return \"enum\";\n if (schema instanceof z.ZodRecord) return \"record\";\n if (schema instanceof z.ZodTuple) return \"tuple\";\n if (schema instanceof z.ZodUnknown) return \"unknown\";\n if (schema instanceof z.ZodAny) return \"any\";\n\n return \"unknown\";\n}\n","// serializer.ts\nimport type { AnyLeaf, MethodCfg } from \"@emeryld/rrroutes-contract\";\nimport { introspectSchema, SerializableSchemaNode } from \"./schemaIntrospection.js\";\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 // NEW: full Zod ASTs\n bodySchema?: SerializableSchemaNode;\n querySchema?: SerializableSchemaNode;\n paramsSchema?: SerializableSchemaNode;\n outputSchema?: SerializableSchemaNode;\n};\n\nexport type SerializableLeaf = {\n method: string;\n path: string;\n cfg: SerializableMethodCfg;\n};\n\nexport type { SerializableSchemaNode } from \"./schemaIntrospection.js\";\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 bodySchema: introspectSchema(cfg.bodySchema),\n querySchema: introspectSchema(cfg.querySchema),\n paramsSchema: introspectSchema(cfg.paramsSchema),\n outputSchema: introspectSchema(cfg.outputSchema),\n },\n };\n}\n","// renderLeafDocsHTML.ts\nimport type { AnyLeaf } from \"@emeryld/rrroutes-contract\";\nimport {\n createLeafDocsDocument,\n renderLeafDocsHTML as LeafDocsPage,\n RenderOptions,\n} from \"./LeafDocsPage.js\";\n\nexport function renderLeafDocsHTML(leaves: AnyLeaf[], options: RenderOptions = {}): string {\n return LeafDocsPage(leaves, options);\n}\n\nexport type { RenderOptions, SerializableHistoryEntry } from \"./LeafDocsPage.js\";\nexport { createLeafDocsDocument } from \"./LeafDocsPage.js\";\nexport type { SerializablePreset, SerializablePresetOperation } from \"./presets.js\";\n"],"mappings":";AASA,SAAS,mBAAmB;AAE5B,SAAS,UAAU,qBAAqB;AACxC,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;;;ACZ9B,SAAS,4BAA4B;;;ACDrC,YAAY,OAAO;AAyBnB,SAAS,OAAO,QAAkC;AAChD,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,QAAM,YAAY;AAClB,SAAO,UAAU,MAAM,OAAO,UAAU;AAC1C;AAOA,SAAS,eAAe,QAAoC;AAC1D,QAAM,OAAY;AAGlB,QAAM,WAAW,KAAK,gBAAgB,MAClC,KAAK,eAAe,IAAI,MAAM,IAC9B;AACJ,MAAI,YAAY,OAAO,SAAS,gBAAgB,UAAU;AACxD,WAAO,SAAS;AAAA,EAClB;AAGA,QAAM,MAAM,OAAO,MAAM;AACzB,MAAI,OAAO,OAAO,IAAI,gBAAgB,UAAU;AAC9C,WAAO,IAAI;AAAA,EACb;AAEA,SAAO;AACT;AAUA,SAAS,OAAO,QAId;AACA,MAAI,IAAY;AAChB,MAAI,WAAW;AACf,MAA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