zod-nest 3.2.0 → 3.2.2

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.
Files changed (43) hide show
  1. package/dist/chunk-26E2XEJU.js +294 -0
  2. package/dist/chunk-26E2XEJU.js.map +1 -0
  3. package/dist/chunk-4RXGLSPP.js +73 -0
  4. package/dist/chunk-4RXGLSPP.js.map +1 -0
  5. package/dist/chunk-FKXVNCDD.js +863 -0
  6. package/dist/chunk-FKXVNCDD.js.map +1 -0
  7. package/dist/chunk-LHNXO52A.mjs +838 -0
  8. package/dist/chunk-LHNXO52A.mjs.map +1 -0
  9. package/dist/chunk-LXRBMFWD.js +103 -0
  10. package/dist/chunk-LXRBMFWD.js.map +1 -0
  11. package/dist/chunk-RAF7JGS6.mjs +286 -0
  12. package/dist/chunk-RAF7JGS6.mjs.map +1 -0
  13. package/dist/chunk-WI4JKXT6.mjs +83 -0
  14. package/dist/chunk-WI4JKXT6.mjs.map +1 -0
  15. package/dist/chunk-ZZW54ETO.mjs +67 -0
  16. package/dist/chunk-ZZW54ETO.mjs.map +1 -0
  17. package/dist/express/index.d.mts +3 -3
  18. package/dist/express/index.d.ts +3 -3
  19. package/dist/express/index.js +33 -1118
  20. package/dist/express/index.js.map +1 -1
  21. package/dist/express/index.mjs +6 -1102
  22. package/dist/express/index.mjs.map +1 -1
  23. package/dist/fastify/index.d.mts +3 -3
  24. package/dist/fastify/index.d.ts +3 -3
  25. package/dist/fastify/index.js +18 -1109
  26. package/dist/fastify/index.js.map +1 -1
  27. package/dist/fastify/index.mjs +6 -1102
  28. package/dist/fastify/index.mjs.map +1 -1
  29. package/dist/helpers/index.js +81 -122
  30. package/dist/helpers/index.js.map +1 -1
  31. package/dist/helpers/index.mjs +4 -101
  32. package/dist/helpers/index.mjs.map +1 -1
  33. package/dist/index.d.mts +2 -2
  34. package/dist/index.d.ts +2 -2
  35. package/dist/index.js +263 -1091
  36. package/dist/index.js.map +1 -1
  37. package/dist/index.mjs +18 -895
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/{param-decorators-CX1cUqfY.d.ts → param-decorators-23pStLeF.d.ts} +1 -1
  40. package/dist/{param-decorators-DbgygRVn.d.mts → param-decorators-Dfd2Cy08.d.mts} +1 -1
  41. package/dist/{registry-C9xStKa6.d.mts → registry-Cs1Y0a-L.d.mts} +1 -1
  42. package/dist/{registry-C9xStKa6.d.ts → registry-Cs1Y0a-L.d.ts} +1 -1
  43. package/package.json +26 -33
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema/constants.ts","../src/schema/discover-dependents.ts","../src/schema/registry.ts","../src/schema/composition.ts","../src/schema/errors.ts","../src/schema/override.ts","../src/schema/post-process.ts","../src/schema/engine.ts","../src/dto/symbols.ts","../src/dto/predicates.ts","../src/exceptions/validation.exception.ts","../src/schema/anon-id.ts","../src/decorators/internal/zod-schema-ref.ts","../src/decorators/internal/zod-param-expand.ts","../src/decorators/internal/flatten-intersection.ts"],"names":["COMPONENTS_SCHEMAS_PREFIX","DEFS_PREFIX","ZOD_NEST_ERROR_EXTENSION","ZOD_NEST_ERROR_DUPLICATE_ID","ZOD_NEST_DTO_EXTENSION","INNER_TYPE_WRAPPERS","Set","readId","schema","meta","z","globalRegistry","get","undefined","id","resolveLazyTarget","getter","error","ReferenceError","collectChildren","def","_zod","type","shape","out","Object","values","catchall","push","element","options","map","opt","left","right","items","it","rest","keyType","valueType","in","has","innerType","discoverDependents","visited","WeakSet","stack","length","current","pop","add","child","createRegistry","seen","Map","forceExposed","anonymous","pendingRoots","recordOnce","set","flushPendingDiscovery","root","splice","childId","zodRegistry","register","flags","expose","existing","hasCollision","size","getCollisions","ids","keys","forceExposedIds","anonymousIds","defaultRegistry","singleton","registerSchema","registry","explicit","metaId","lineageMap","WeakMap","OPTIONAL_WRAPPER_TYPES","isOptionalProp","propSchema","computeShapeKeys","entries","properties","key","required","filter","computeOverriddenKeys","parent","overriddenKeys","parentProp","extend","build","result","op","getLineage","DEFAULT_BUILD_REF","createCompositionOverride","opts","buildRef","ctx","jsonSchema","zodSchema","entry","parentCache","parentId","childProps","childRequired","parentPropSet","parentReqSet","deltaProps","value","deltaRequired","delta","additionalProperties","allOf","$ref","unevaluatedProperties","ZodNestError","Error","message","name","ZodNestUnrepresentableError","path","zodType","formatPath","String","join","primitiveOverride","format","combine","overrides","list","candidate","o","rewriteRefs","node","rootRef","Array","isArray","item","obj","ref","startsWith","slice","refsIn","rootDefId","raw","isReferenced","defs","ownRef","referencesRoot","stripEnvelope","$schema","$defs","resolveRoot","refs","liftedId","body","delete","rootId","strict","postProcess","rawDefs","STRICT_REQUIRES_OVERRIDE","ANNOTATION_ONLY_KEYS","isStrictlyUnrepresentable","every","descentTarget","$in","io","traits","markPipeCoverage","covered","target","buildToJsonSchemaOptions","params","compositionOverride","uri","customOverride","createCustomOverride","merged","override","unrepresentableHits","coveredByPipe","wrapped","record","peekRegistration","unrepresentable","metadata","cycles","reused","consumeUnrepresentable","firstHit","find","hit","resolveRootId","toOpenApi","built","toJSONSchema","description","ZOD_DTO_SYMBOL","Symbol","for","isZodDto","isZodSchema","ZodType","ZodValidationException","BadRequestException","zodError","argMetadata","statusCode","HttpStatus","BAD_REQUEST","errors","treeifyError","cause","ANON_RESPONSE_PREFIX","ANON_BODY_PREFIX","anonIdCache","counterRef","resolveAnonId","prefix","cached","resolveSchemaRef","kind","deferAnonInline","anonId","isZodObject","expandObjectSchema","decoratorName","resolution","forceRequired","paramSchemaBody","intersectionArms","unionOptions","collectObjectShapes","shapes","unionCrossed","allShapes","variant","variantResult","arms","flattenObjectIntersection","collected","mergedShape","assign","optional","object"],"mappings":";;;;;AACO,IAAMA,yBAAAA,GAA4B;AAGlC,IAAMC,WAAAA,GAAc,UAAA;AAGpB,IAAMC,wBAAAA,GAA2B;AAGjC,IAAMC,2BAAAA,GAA8B;AAQpC,IAAMC,sBAAAA,GAAyB;ACdtC,IAAMC,mBAAAA,uBAA0BC,GAAAA,CAAI;AAClC,EAAA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,CAAC1J,GAAAA,EAAK2B,KAAAA,KAAU5F,MAAAA,CAAO+D,OAAAA,CAAQmK,WAAAA,CAAAA,EAAc;AACtDA,MAAAA,WAAAA,CAAYjK,GAAAA,CAAAA,GAAO2B,KAAAA,CAAMwI,QAAAA,EAAQ;AACnC,IAAA;AACF,EAAA;AACA,EAAA,MAAMlE,MAAAA,GAASjL,CAAAA,CAAEoP,MAAAA,CAAOH,WAAAA,CAAAA;AAOxB7K,EAAAA,cAAAA,CAAetE,QAAQuE,QAAAA,CAAAA;AAKvB,EAAA,KAAA,MAAW,CAAC5B,KAAAA,EAAOY,OAAAA,CAAAA,IAAYpB,kBAAAA,CAAmBnC,MAAAA,CAAAA,EAAS;AACzDuE,IAAAA,QAAAA,CAASd,QAAAA,CAASd,OAAOY,OAAAA,CAAAA;AAC3B,EAAA;AACA,EAAA,MAAM,EAAEvD,MAAAA,EAAQ4J,IAAAA,EAAI,GAAKuC,UAAUhB,MAAAA,EAAQ;IAAEX,EAAAA,EAAI,OAAA;AAASjG,IAAAA;GAAS,CAAA;AACnE,EAAA,OAAOqF,IAAAA;AACT,CAAA,EA5CyC,2BAAA","file":"chunk-LHNXO52A.mjs","sourcesContent":["/** OpenAPI 3.1 `$ref` prefix for entries in `components.schemas`. */\nexport const COMPONENTS_SCHEMAS_PREFIX = '#/components/schemas/';\n\n/** JSON Schema `$ref` prefix for entries in `$defs` (single-schema emission). */\nexport const DEFS_PREFIX = '#/$defs/';\n\n/** OpenAPI extension key zod-nest uses to surface engine errors inside emitted schemas. */\nexport const ZOD_NEST_ERROR_EXTENSION = 'x-zod-nest-error';\n\n/** Value of `x-zod-nest-error` when a registry id is claimed by more than one schema. */\nexport const ZOD_NEST_ERROR_DUPLICATE_ID = 'duplicate-id';\n\n/**\n * OpenAPI extension key used by `createZodDto` to mark a class for `applyZodNest`.\n * The marker carries `{ __zodNestDto: true, dtoId, io }` so `applyZodNest` can\n * locate every zod-nest DTO in the @nestjs/swagger document and inject the\n * real Zod-derived schema.\n */\nexport const ZOD_NEST_DTO_EXTENSION = 'x-zod-nest-dto';\n","import { z } from 'zod';\n\nimport type { $ZodType, $ZodTypes } from 'zod/v4/core';\n\nconst INNER_TYPE_WRAPPERS = new Set([\n 'optional',\n 'nullable',\n 'default',\n 'prefault',\n 'catch',\n 'nonoptional',\n 'success',\n 'readonly',\n 'promise',\n]);\n\nconst readId = (schema: z.ZodType): string | undefined => {\n const meta = z.globalRegistry.get(schema);\n if (meta === undefined) {\n return undefined;\n }\n const id = (meta as { id?: unknown }).id;\n return typeof id === 'string' ? id : undefined;\n};\n\n// A `z.lazy` getter can close over a `const` still in its temporal dead zone\n// (mutual recursion under ESM). Treat that as \"no child yet\" — `toOpenApi`\n// calls the getter again and reports a genuinely broken reference then.\nconst resolveLazyTarget = (getter: () => $ZodType): z.ZodType[] => {\n try {\n return [getter() as unknown as z.ZodType];\n } catch (error) {\n if (error instanceof ReferenceError) {\n return [];\n }\n throw error;\n }\n};\n\nconst collectChildren = (schema: z.ZodType): z.ZodType[] => {\n const def = (schema as unknown as $ZodTypes)._zod.def;\n if (def.type === 'object') {\n const shape = def.shape as Record<string, z.ZodType>;\n const out: z.ZodType[] = [...Object.values(shape)];\n if (def.catchall !== undefined) {\n out.push(def.catchall as unknown as z.ZodType);\n }\n return out;\n }\n if (def.type === 'array') {\n return [def.element as unknown as z.ZodType];\n }\n if (def.type === 'union') {\n return (def.options as readonly $ZodType[]).map((opt) => opt as unknown as z.ZodType);\n }\n if (def.type === 'intersection') {\n return [def.left as unknown as z.ZodType, def.right as unknown as z.ZodType];\n }\n if (def.type === 'tuple') {\n const out: z.ZodType[] = (def.items as readonly $ZodType[]).map(\n (it) => it as unknown as z.ZodType,\n );\n if (def.rest !== null) {\n out.push(def.rest as unknown as z.ZodType);\n }\n return out;\n }\n if (def.type === 'record' || def.type === 'map') {\n return [def.keyType as unknown as z.ZodType, def.valueType as unknown as z.ZodType];\n }\n if (def.type === 'set') {\n return [def.valueType as unknown as z.ZodType];\n }\n if (def.type === 'pipe') {\n return [def.in as unknown as z.ZodType, def.out as unknown as z.ZodType];\n }\n if (def.type === 'lazy') {\n return resolveLazyTarget(() => def.getter());\n }\n if (INNER_TYPE_WRAPPERS.has(def.type)) {\n return [(def as { innerType: $ZodType }).innerType as unknown as z.ZodType];\n }\n return [];\n};\n\n/**\n * Returns every named descendant of `schema` — sub-schemas carrying\n * `.meta({ id })` reachable through the Zod composition tree, at any depth.\n *\n * Cycle-safe via a visited `WeakSet` keyed by Zod schema identity; safe for\n * `z.lazy` schemas that close over themselves. Leaf types (string, number,\n * enum, literal, custom, transform, …) have no children and are skipped.\n */\nexport const discoverDependents = (schema: z.ZodType): ReadonlyArray<[z.ZodType, string]> => {\n const visited = new WeakSet<z.ZodType>();\n const out: [z.ZodType, string][] = [];\n const stack: z.ZodType[] = [schema];\n while (stack.length > 0) {\n const current = stack.pop() as z.ZodType;\n if (visited.has(current)) {\n continue;\n }\n visited.add(current);\n for (const child of collectChildren(current)) {\n // Defensive: a malformed/in-progress schema can yield an undefined slot\n // (sparse object shape, undefined tuple item, etc.). The walker treats\n // such slots as \"no child here\" rather than crashing — the user's\n // schema may still emit fine through `toJSONSchema`.\n if (child === undefined || visited.has(child)) {\n continue;\n }\n const id = readId(child);\n if (id !== undefined) {\n out.push([child, id]);\n }\n stack.push(child);\n }\n }\n return out;\n};\n","import { z } from 'zod';\n\nimport { discoverDependents } from './discover-dependents.js';\nimport { singleton } from './singleton.js';\n\n/**\n * Per-registration flags carried alongside the id.\n *\n * - `expose` — force the id into the emitted document even when no endpoint\n * references it. The author deliberately wants it in `components.schemas`\n * (e.g. for out-of-band client codegen). Default exposure is otherwise\n * reachability-scoped, so an unreferenced schema is pruned unless flagged.\n * - `anonymous` — the id is a synthetic placeholder for a schema with no\n * resolvable id (passed inline to `@ZodResponse` / `@ZodBody`). It exists\n * only to carry the body through bulk emission under the document's\n * `strict` / `override` options; `inlineAnonymousBodies` later inlines the\n * body at each `$ref` site and prunes the component, so the synthetic id\n * never reaches the final document.\n *\n * Both flags are sticky — once set for an id they stay set, so a later plain\n * `register` of the same id (e.g. the idempotent re-register inside\n * `createZodDto`) doesn't clear them.\n */\nexport interface RegisterFlags {\n readonly expose?: boolean;\n readonly anonymous?: boolean;\n}\n\nexport interface ZodNestRegistry {\n readonly zodRegistry: typeof z.globalRegistry;\n register(schema: z.ZodType, id: string, flags?: RegisterFlags): void;\n hasCollision(id: string): boolean;\n getCollisions(): ReadonlyMap<string, ReadonlySet<z.ZodType>>;\n /**\n * Snapshot of every id registered through this `ZodNestRegistry`. The\n * underlying Zod registry is `z.globalRegistry`, which may hold third-party\n * entries — bulk emission filters its output against this snapshot to keep\n * only zod-nest-known ids.\n *\n * Includes ids discovered transitively via `.meta({ id })` on descendants\n * of explicitly-registered schemas.\n */\n ids(): readonly string[];\n /** Ids registered with `{ expose: true }` — exposed regardless of usage. */\n forceExposedIds(): readonly string[];\n /** Ids registered with `{ anonymous: true }` — inlined + pruned by `applyZodNest`. */\n anonymousIds(): readonly string[];\n}\n\nexport const createRegistry = (): ZodNestRegistry => {\n const seen = new Map<string, Set<z.ZodType>>();\n const forceExposed = new Set<string>();\n const anonymous = new Set<string>();\n const pendingRoots: z.ZodType[] = [];\n\n const recordOnce = (schema: z.ZodType, id: string): boolean => {\n let set = seen.get(id);\n if (set === undefined) {\n set = new Set<z.ZodType>();\n seen.set(id, set);\n }\n if (set.has(schema)) {\n return false;\n }\n set.add(schema);\n return true;\n };\n\n const flushPendingDiscovery = (): void => {\n for (const root of pendingRoots.splice(0)) {\n for (const [child, childId] of discoverDependents(root)) {\n recordOnce(child, childId);\n }\n }\n };\n\n return {\n zodRegistry: z.globalRegistry,\n register: (schema, id, flags) => {\n // Flags are sticky: a later plain re-register of the same id (e.g. the\n // idempotent call inside `createZodDto`) must not clear an earlier\n // `expose` / `anonymous`.\n if (flags?.expose === true) {\n forceExposed.add(id);\n }\n if (flags?.anonymous === true) {\n anonymous.add(id);\n }\n // `globalRegistry.add` overwrites the schema's entire meta entry; we\n // must merge so user-supplied fields (`title`, `description`,\n // anything else in `.meta({...})`) survive registration. The `has`\n // gate avoids promoting parent-inherited meta into a local entry\n // — `get()` returns parent-merged metadata when the schema has no\n // local entry, and writing that back here would freeze the\n // inherited fields against the schema.\n if (z.globalRegistry.has(schema)) {\n // `?? {}` is unreachable — the `has` gate guarantees a local entry —\n // but the return type is optional, so the fallback satisfies it.\n const existing = z.globalRegistry.get(schema) ?? {};\n if (existing.id !== id) {\n z.globalRegistry.add(schema, { ...existing, id });\n }\n } else {\n z.globalRegistry.add(schema, { id });\n }\n if (!recordOnce(schema, id)) {\n return;\n }\n // Queue, don't walk: forcing `z.lazy` getters here reads forward\n // references still in their temporal dead zone (throws under ESM,\n // yields `undefined` under CJS). Draining on first read is always safe.\n pendingRoots.push(schema);\n },\n hasCollision: (id) => {\n flushPendingDiscovery();\n const set = seen.get(id);\n return set !== undefined && set.size > 1;\n },\n getCollisions: () => {\n flushPendingDiscovery();\n const out = new Map<string, Set<z.ZodType>>();\n for (const [id, set] of seen) {\n if (set.size <= 1) {\n continue;\n }\n out.set(id, set);\n }\n return out;\n },\n ids: () => {\n flushPendingDiscovery();\n return [...seen.keys()];\n },\n forceExposedIds: () => [...forceExposed],\n anonymousIds: () => [...anonymous],\n };\n};\n\n/** Process-wide default registry. Shared so subpath ids reach `applyZodNest`. */\nexport const defaultRegistry: ZodNestRegistry = singleton('default-registry', createRegistry);\n\nexport interface RegisterSchemaOptions {\n /** Forces this id, overriding any `.meta({ id })` already on the schema. */\n readonly id?: string;\n /**\n * Force the schema into the emitted document even when no endpoint\n * references it. Default exposure is reachability-scoped — see\n * {@link RegisterFlags.expose}.\n */\n readonly expose?: boolean;\n /**\n * Mark the resolved id as a synthetic anonymous placeholder — inlined and\n * pruned by `applyZodNest`. See {@link RegisterFlags.anonymous}.\n */\n readonly anonymous?: boolean;\n}\n\n/**\n * Register a schema with the given registry, resolving its id from (in order):\n * an explicit `options.id`, then `.meta({ id })` on the schema. Returns the\n * resolved id, or `undefined` when neither source yields one (the call is then\n * a no-op — callers with their own fallback path handle that case).\n *\n * Shared by `createZodDto` and `extend` so a schema named via `.meta({ id })`\n * gets its body emitted into `components.schemas` even when it never flows\n * through `createZodDto` (e.g. used only as an `extend()` parent — Zod's\n * `.extend()` produces a flat object, so the parent isn't a transitive\n * descendant of the child and would otherwise be missed by `discoverDependents`).\n *\n * Idempotent — `registry.register` already deduplicates repeat calls.\n */\nexport const registerSchema = (\n schema: z.ZodType,\n registry: ZodNestRegistry = defaultRegistry,\n options?: RegisterSchemaOptions,\n): string | undefined => {\n const flags: RegisterFlags = { expose: options?.expose, anonymous: options?.anonymous };\n const explicit = options?.id;\n if (typeof explicit === 'string' && explicit !== '') {\n registry.register(schema, explicit, flags);\n return explicit;\n }\n const meta = registry.zodRegistry.get(schema);\n const metaId = meta === undefined ? undefined : (meta as { id?: unknown }).id;\n if (typeof metaId !== 'string' || metaId === '') {\n return undefined;\n }\n registry.register(schema, metaId, flags);\n return metaId;\n};\n","/**\n * Composition layer — emits OpenAPI `allOf` for schemas derived via `extend`.\n *\n * **EXPERIMENTAL**: output shape may change as edge cases surface.\n */\n\nimport { z } from 'zod';\n\nimport type { $ZodType } from 'zod/v4/core';\nimport type { SchemaObject } from './openapi.types.js';\nimport type { Override } from './override.js';\nimport type { ZodNestRegistry } from './registry.js';\n\nimport { DEFS_PREFIX } from './constants.js';\nimport { registerSchema } from './registry.js';\nimport { singleton } from './singleton.js';\n\n/**\n * Lineage record for a composition-derived schema. Read by the override to\n * emit `allOf` instead of a flat body.\n *\n * @experimental — shape may change.\n */\nexport interface LineageEntry {\n readonly op: 'extend';\n readonly parent: z.ZodObject;\n /**\n * Keys the child redeclared with a *different* schema than the parent's\n * (e.g. narrowing `type: SomeEnum` to `type: z.literal('A')`). Computed by\n * reference comparison at `extend()` time — Zod's `.extend()` keeps the same\n * shape reference for untouched keys and assigns a fresh one for overrides.\n * The composition override keeps these in the delta instead of dropping them\n * as parent-owned, so the narrowing survives in the emitted `allOf`.\n */\n readonly overriddenKeys: ReadonlySet<string>;\n}\n\n// `WeakMap` (not `z.registry`) so transient derived schemas can GC — Zod's\n// own docs warn against long-running registries pinning short-lived schemas.\nconst lineageMap = singleton('lineage-map', () => new WeakMap<$ZodType, LineageEntry>());\n\n/** Zod's wrapper types that make a property optional in JSON Schema's `required` sense. */\nexport const OPTIONAL_WRAPPER_TYPES: ReadonlySet<string> = new Set(['optional', 'default']);\n\nexport const isOptionalProp = (propSchema: z.ZodType): boolean =>\n OPTIONAL_WRAPPER_TYPES.has(propSchema._zod.def.type);\n\nconst computeShapeKeys = (\n schema: z.ZodObject,\n): { properties: readonly string[]; required: readonly string[] } => {\n const entries = Object.entries(schema.shape);\n return {\n properties: entries.map(([key]) => key),\n required: entries.filter(([, propSchema]) => !isOptionalProp(propSchema)).map(([key]) => key),\n };\n};\n\n/**\n * Keys the child shares with the parent by name but redeclares with a\n * different schema. Relies on Zod's `.extend()` reference semantics: untouched\n * keys keep the parent's shape reference, overridden keys get a fresh one.\n */\nconst computeOverriddenKeys = (parent: z.ZodObject, child: z.ZodObject): ReadonlySet<string> => {\n const overriddenKeys = new Set<string>();\n for (const key of Object.keys(child.shape)) {\n const parentProp = parent.shape[key];\n if (parentProp !== undefined && parentProp !== child.shape[key]) {\n overriddenKeys.add(key);\n }\n }\n return overriddenKeys;\n};\n\n/**\n * Wraps a derived `z.ZodObject` and records the parent → child link so\n * emission rewrites the body to `allOf: [{ $ref: <parent> }, <delta>]`.\n *\n * @experimental — output shape may change as the surface stabilizes.\n *\n * @example\n * const Base = z.object({ id: z.string() }).meta({ id: 'Base' });\n * const Child = extend(Base, (s) => s.extend({ role: z.string() }).meta({ id: 'Child' }));\n */\nexport const extend = <P extends z.ZodObject, S extends z.ZodObject>(\n parent: P,\n build: (p: P) => S,\n): S => {\n const result = build(parent);\n lineageMap.set(result, {\n op: 'extend',\n parent,\n overriddenKeys: computeOverriddenKeys(parent, result),\n });\n // Auto-register named parent/result so their bodies land in\n // `components.schemas`. Zod's `.extend()` produces a flat object, so the\n // parent isn't a transitive descendant of the result — without this, a\n // parent named only via `.meta({ id })` would be referenced by `$ref` but\n // never emitted, yielding `DANGLING_REF`. No-op when the schema is\n // anonymous. The composition override (below) re-registers against the\n // active registry at emit time as a backstop for custom-registry users.\n registerSchema(parent);\n registerSchema(result);\n return result;\n};\n\n/**\n * Read the lineage entry for a composition-derived schema, or `undefined`.\n *\n * @experimental — `LineageEntry` shape may change.\n */\nexport const getLineage = (schema: z.ZodType): LineageEntry | undefined => lineageMap.get(schema);\n\n/**\n * Default ref builder for single-schema mode (`toOpenApi`) — refs land in\n * `#/$defs/<id>` and `post-process` rewrites them to `#/components/schemas/<id>`.\n * Bulk mode passes its own `uri` callback so refs land at the final location.\n */\nexport const DEFAULT_BUILD_REF = (id: string): string => `${DEFS_PREFIX}${id}`;\n\nexport interface CreateCompositionOverrideOptions {\n /** Shape the `$ref` string for a parent id. Defaults to `#/$defs/<id>`. */\n buildRef: (id: string) => string;\n /** Registry to resolve parent ids against. Use the same instance the engine emits with. */\n registry: ZodNestRegistry;\n}\n\n/**\n * Factory for the composition override. Returns an `Override` that rewrites\n * composition-derived schemas to `allOf` form, falling back to Zod's flat\n * emission when no lineage entry exists or the parent has no registered id.\n *\n * Mutation happens in-place — Zod's override doesn't propagate\n * `ctx.jsonSchema = newBody` reassignments; only mutations on the existing\n * object reference reach the caller.\n */\nexport const createCompositionOverride = (opts: CreateCompositionOverrideOptions): Override => {\n const { buildRef, registry } = opts;\n return (ctx) => {\n const { jsonSchema, zodSchema } = ctx;\n const entry = lineageMap.get(zodSchema);\n if (entry === undefined) {\n return;\n }\n\n const parentCache = computeShapeKeys(entry.parent);\n\n const parentId = registry.zodRegistry.get(entry.parent)?.id;\n if (parentId === undefined) {\n // Anonymous parent — fall back to Zod's flat emission.\n return;\n }\n // Backstop the eager `extend()` registration above: that only writes to\n // `defaultRegistry`, so custom-registry users need the parent surfaced\n // here too. Idempotent against the eager call.\n registerSchema(entry.parent, registry);\n\n const childProps = jsonSchema.properties ?? {};\n const childRequired = jsonSchema.required ?? [];\n const parentPropSet = new Set(parentCache.properties);\n const parentReqSet = new Set(parentCache.required);\n\n const deltaProps: NonNullable<SchemaObject['properties']> = {};\n for (const [key, value] of Object.entries(childProps)) {\n // Drop parent-owned keys, but keep any the child overrode with a\n // different schema — otherwise the narrowing (e.g. enum → literal) is\n // lost and `allOf` would only carry the parent's wider constraint.\n if (parentPropSet.has(key) && !entry.overriddenKeys.has(key)) {\n continue;\n }\n deltaProps[key] = value;\n }\n // Mirror the properties logic: drop parent-required keys, but keep any the\n // child overrode and still requires — its narrowed body now lives in the\n // delta, so the `required` marker must travel with it (otherwise the\n // overridden field reads as optional in the delta arm, e.g. breaking a\n // discriminated union whose discriminator must be required on each arm).\n const deltaRequired = childRequired.filter(\n (key) => !parentReqSet.has(key) || entry.overriddenKeys.has(key),\n );\n\n const delta: SchemaObject = { type: 'object', properties: deltaProps };\n if (deltaRequired.length > 0) {\n delta.required = deltaRequired;\n }\n\n delete jsonSchema.properties;\n delete jsonSchema.required;\n delete jsonSchema.additionalProperties;\n // Keep `type: 'object'` on the wrapper rather than deleting it: every arm of\n // the `allOf` is an object, so the wrapper is unambiguously an object, and\n // the explicit `type` is the more correct / tool-friendly emission.\n // `type: 'object'` + `allOf` is valid (the instance must be an object AND\n // satisfy every arm); `unevaluatedProperties: false` still closes the shape.\n jsonSchema.type = 'object';\n jsonSchema.allOf = [{ $ref: buildRef(parentId) }, delta];\n jsonSchema.unevaluatedProperties = false;\n };\n};\n","export class ZodNestError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ZodNestError';\n }\n}\n\nexport class ZodNestUnrepresentableError extends ZodNestError {\n readonly path: ReadonlyArray<string | number>;\n readonly zodType: string;\n\n constructor(path: ReadonlyArray<string | number>, zodType: string) {\n super(\n `Unrepresentable Zod schema \\`${zodType}\\` at ${formatPath(path)}: no override produced ` +\n `a JSON Schema body. Set strict: false to emit \\`{}\\` instead, or supply an \\`override\\` ` +\n `that handles this Zod type.`,\n );\n this.name = 'ZodNestUnrepresentableError';\n this.path = path;\n this.zodType = zodType;\n }\n}\n\nconst formatPath = (path: ReadonlyArray<string | number>): string => {\n if (path.length === 0) {\n return '<root>';\n }\n return '/' + path.map(String).join('/');\n};\n","import type { $ZodTypes } from 'zod/v4/core';\nimport type { SchemaObject } from './openapi.types.js';\n\nexport interface OverrideContext {\n zodSchema: $ZodTypes;\n jsonSchema: SchemaObject;\n path: (string | number)[];\n}\n\nexport type Override = (ctx: OverrideContext) => void;\n\n/**\n * Type-driven override for primitive Zod constructs that JSON Schema can't\n * represent directly (bigint → integer, date → string + date-time format).\n * Composition's `allOf`-form emission lives in `composition.ts`; the engine\n * combines both into the full override chain per call site (since composition\n * needs a uri-aware `buildRef` that differs between single-schema and bulk\n * emission).\n */\nexport const primitiveOverride: Override = ({ zodSchema, jsonSchema }) => {\n const type = zodSchema._zod.def.type;\n if (type === 'bigint') {\n jsonSchema.type = 'integer';\n return;\n }\n if (type === 'date') {\n jsonSchema.type = 'string';\n jsonSchema.format = 'date-time';\n return;\n }\n};\n\nexport const combine = (...overrides: ReadonlyArray<Override | undefined>): Override => {\n const list: Override[] = [];\n for (const candidate of overrides) {\n if (typeof candidate !== 'function') {\n continue;\n }\n list.push(candidate);\n }\n return (ctx) => {\n for (const o of list) {\n o(ctx);\n }\n };\n};\n","import type { SchemaObject } from './openapi.types.js';\n\nimport { COMPONENTS_SCHEMAS_PREFIX, DEFS_PREFIX } from './constants.js';\nimport { ZodNestError } from './errors.js';\n\nexport interface PostProcessResult {\n schema: SchemaObject;\n refs: Map<string, SchemaObject>;\n}\n\nexport interface PostProcessOptions {\n /** Component id of the emitted root, when it has one. Resolves `'#'` refs. */\n rootId?: string;\n strict?: boolean;\n}\n\n// Zod emits '#' for a cycle back to the document root, so it resolves to the\n// root's own component — never to whichever def happens to contain it.\nconst rewriteRefs = (node: unknown, rootRef: string | undefined): void => {\n if (Array.isArray(node)) {\n for (const item of node) {\n rewriteRefs(item, rootRef);\n }\n return;\n }\n if (node === null || typeof node !== 'object') {\n return;\n }\n const obj = node as Record<string, unknown>;\n const ref = obj.$ref;\n if (typeof ref === 'string' && ref.startsWith(DEFS_PREFIX)) {\n obj.$ref = COMPONENTS_SCHEMAS_PREFIX + ref.slice(DEFS_PREFIX.length);\n } else if (ref === '#' && rootRef !== undefined) {\n obj.$ref = rootRef;\n }\n for (const value of Object.values(obj)) {\n rewriteRefs(value, rootRef);\n }\n};\n\nconst refsIn = function* (node: unknown): Generator<string> {\n if (Array.isArray(node)) {\n for (const item of node) {\n yield* refsIn(item);\n }\n return;\n }\n if (node === null || typeof node !== 'object') {\n return;\n }\n const obj = node as Record<string, unknown>;\n if (typeof obj.$ref === 'string') {\n yield obj.$ref;\n }\n for (const value of Object.values(obj)) {\n yield* refsIn(value);\n }\n};\n\nconst rootDefId = (raw: SchemaObject): string | undefined => {\n const ref = raw.$ref;\n if (typeof ref !== 'string' || !ref.startsWith(DEFS_PREFIX)) {\n return undefined;\n }\n return ref.slice(DEFS_PREFIX.length);\n};\n\nconst isReferenced = (defs: SchemaObject['$defs'], id: string): boolean => {\n const ownRef = `${DEFS_PREFIX}${id}`;\n for (const ref of refsIn(defs)) {\n if (ref === '#' || ref === ownRef) {\n return true;\n }\n }\n return false;\n};\n\nconst referencesRoot = (raw: SchemaObject): boolean => {\n for (const ref of refsIn(raw)) {\n if (ref === '#') {\n return true;\n }\n }\n return false;\n};\n\nconst stripEnvelope = (raw: SchemaObject): SchemaObject => {\n const root: SchemaObject = { ...raw };\n delete root.$schema;\n delete root.$defs;\n return root;\n};\n\ninterface ResolvedRoot {\n schema: SchemaObject;\n rootRef: string | undefined;\n}\n\n// A referenced root has to be addressable, so it keeps (or gains) a component\n// entry and the caller gets a `$ref`. Inlining an unreferenced one keeps zod\n// 4.4 and 4.5 emitting the same shape.\nconst resolveRoot = (\n raw: SchemaObject,\n refs: Map<string, SchemaObject>,\n options: PostProcessOptions | undefined,\n): ResolvedRoot => {\n const liftedId = rootDefId(raw);\n if (liftedId !== undefined) {\n const body = refs.get(liftedId);\n if (body !== undefined && !isReferenced(raw.$defs, liftedId)) {\n refs.delete(liftedId);\n return { schema: body, rootRef: undefined };\n }\n return { schema: stripEnvelope(raw), rootRef: `${COMPONENTS_SCHEMAS_PREFIX}${liftedId}` };\n }\n\n const root = stripEnvelope(raw);\n if (!referencesRoot(raw)) {\n return { schema: root, rootRef: undefined };\n }\n\n const rootId = options?.rootId;\n if (rootId === undefined) {\n if (options?.strict ?? true) {\n throw new ZodNestError(\n 'A schema referenced from inside its own emission has no id, so the reference ' +\n 'cannot be resolved. Add `.meta({ id: \"…\" })` to the root schema, or set ' +\n 'strict: false to leave the reference unresolved.',\n );\n }\n return { schema: root, rootRef: undefined };\n }\n\n refs.set(rootId, root);\n const rootRef = `${COMPONENTS_SCHEMAS_PREFIX}${rootId}`;\n return { schema: { $ref: rootRef }, rootRef };\n};\n\nexport const postProcess = (raw: SchemaObject, options?: PostProcessOptions): PostProcessResult => {\n const refs = new Map<string, SchemaObject>();\n const rawDefs = raw.$defs;\n if (rawDefs !== undefined) {\n for (const [id, body] of Object.entries(rawDefs)) {\n refs.set(id, body);\n }\n }\n\n const { schema, rootRef } = resolveRoot(raw, refs, options);\n rewriteRefs(schema, rootRef);\n\n for (const body of refs.values()) {\n rewriteRefs(body, rootRef);\n }\n\n return { schema, refs };\n};\n","import { z } from 'zod';\n\nimport type { $ZodType, $ZodTypes } from 'zod/v4/core';\nimport type { SchemaObject } from './openapi.types.js';\nimport type { Override } from './override.js';\nimport type { ZodNestRegistry } from './registry.js';\n\nimport { createCompositionOverride, DEFAULT_BUILD_REF } from './composition.js';\nimport { ZOD_NEST_ERROR_DUPLICATE_ID, ZOD_NEST_ERROR_EXTENSION } from './constants.js';\nimport { createCustomOverride, peekRegistration } from './custom-override.js';\nimport { ZodNestUnrepresentableError } from './errors.js';\nimport { combine, primitiveOverride } from './override.js';\nimport { postProcess } from './post-process.js';\n\n/**\n * Zod constructs that JSON Schema can't represent without an override. When\n * one of these shows up and our combined override chain didn't produce any\n * body for it, strict mode collects the hit and surfaces it as a\n * `ZodNestUnrepresentableError`. Bound to `engine.ts` since the strict-hit\n * collection lives here too.\n */\nconst STRICT_REQUIRES_OVERRIDE: ReadonlySet<string> = new Set([\n 'bigint',\n 'date',\n 'symbol',\n 'undefined',\n 'void',\n 'map',\n 'set',\n 'transform',\n 'nan',\n 'custom',\n]);\n\n/**\n * Keywords that annotate a schema without describing its shape. A body made\n * only of these has no type, so it's as unrepresentable as an empty one —\n * `.meta({ title })` on an unregistered schema emits exactly that, and\n * checking emptiness alone let it through as a valid annotation-only body.\n *\n * Deliberately an allow-list of annotations rather than a deny-list of\n * structural keywords: an unrecognised keyword counts as structural, so a\n * future JSON Schema addition can't turn into a spurious build failure.\n */\nconst ANNOTATION_ONLY_KEYS: ReadonlySet<string> = new Set([\n 'title',\n 'description',\n 'deprecated',\n 'examples',\n 'default',\n 'readOnly',\n 'writeOnly',\n '$id',\n '$schema',\n '$comment',\n 'id',\n]);\n\nconst isStrictlyUnrepresentable = (jsonSchema: SchemaObject, zodSchema: $ZodTypes): boolean => {\n if (!STRICT_REQUIRES_OVERRIDE.has(zodSchema._zod.def.type)) {\n return false;\n }\n return Object.keys(jsonSchema).every((key) => ANNOTATION_ONLY_KEYS.has(key));\n};\n\nexport interface ToOpenApiOptions {\n io: 'input' | 'output';\n registry: ZodNestRegistry;\n override?: Override;\n strict?: boolean;\n}\n\nexport interface ToOpenApiResult {\n schema: SchemaObject;\n refs: Map<string, SchemaObject>;\n}\n\ninterface UnrepresentableHit {\n path: (string | number)[];\n zodType: string;\n /**\n * Schema instance that emitted empty. Kept so `consumeUnrepresentable`\n * can drop hits whose outer pipe later marked them covered — pipes process\n * inner before outer in reverse-seen order, so the inner's hit fires\n * before the outer pipe gets to declare coverage.\n */\n zodSchema: $ZodType;\n}\n\nconst descentTarget = ($in: $ZodType, out: $ZodType, io: 'input' | 'output'): $ZodType => {\n if (io === 'output') {\n return out;\n }\n // A transform emits its output shape, so its input side is never the target.\n if ($in._zod.traits.has('$ZodTransform')) {\n return out;\n }\n return $in;\n};\n\n/**\n * Mark a pipe's descent target as covered by an outer registration when\n * the override for the outer pipe fires. Recurses for nested\n * pipe-of-pipe chains (e.g. `pipe(pipe2, transform)`) so the deep inner\n * descent target also has its strict-mode hit suppressed.\n *\n * Mirrors Zod's `pipeProcessor` descent rules (`json-schema-processors.js`):\n * - `io === 'output'` → cover `def.out`\n * - `io === 'input'` → cover `def.out` when `def.in` is a `$ZodTransform`\n * (Zod skips preprocessing on input emission), else `def.in`.\n */\nconst markPipeCoverage = (\n schema: $ZodType,\n io: 'input' | 'output',\n covered: WeakSet<$ZodType>,\n): void => {\n const def = schema._zod.def as { type: string; in?: $ZodType; out?: $ZodType };\n if (def.type !== 'pipe' || def.in === undefined || def.out === undefined) {\n return;\n }\n const target = descentTarget(def.in, def.out, io);\n if (covered.has(target)) {\n return;\n }\n covered.add(target);\n markPipeCoverage(target, io, covered);\n};\n\n/**\n * Parameters for `buildToJsonSchemaOptions` — the shared option-bag builder\n * used by both `toOpenApi` (single-schema mode) and `bulkEmit` (registry-mode).\n * Centralizes the override chain, unrepresentable detection,\n * metadata wiring, and target/cycles defaults so both paths emit equivalent\n * JSON Schema for the same input.\n */\nexport interface BuildToJsonSchemaOptionsParams {\n registry: ZodNestRegistry;\n io: 'input' | 'output';\n override?: Override;\n strict?: boolean;\n /**\n * Zod's strategy for anonymous reused sub-schemas. Both single-schema and\n * bulk modes use `'inline'` — `'ref'` extracts anonymous reused branches\n * into a virtual `__shared/$defs` table whose refs don't resolve against\n * `components.schemas`, producing dangling refs. Registered schemas\n * (`metadata.id` present) always go through the `uri` callback regardless,\n * so DTO-to-DTO `$ref`s are unaffected.\n */\n reused: 'inline' | 'ref';\n /** Bulk-mode only — shapes internal `$ref`s to `#/components/schemas/<id>`. */\n uri?: (id: string) => string;\n}\n\nexport interface BuiltJsonSchemaOptions {\n options: NonNullable<Parameters<typeof z.toJSONSchema>[1]>;\n /** Throws `ZodNestUnrepresentableError` if any strict-unrepresentable hit was collected during emission. */\n consumeUnrepresentable(): void;\n}\n\nexport const buildToJsonSchemaOptions = (\n params: BuildToJsonSchemaOptionsParams,\n): BuiltJsonSchemaOptions => {\n const strict = params.strict ?? true;\n // Composition's `buildRef` differs between single-schema and bulk modes:\n // single-schema emits `#/$defs/<id>` (post-process rewrites to\n // `#/components/schemas/<id>`); bulk emits `#/components/schemas/<id>`\n // directly via the configured `uri` callback (post-process is skipped).\n const compositionOverride = createCompositionOverride({\n buildRef: params.uri ?? DEFAULT_BUILD_REF,\n registry: params.registry,\n });\n // Chain order matches precedence (left → right, last-write-wins mutation\n // semantics). Caller's `params.override` runs last so per-call overrides\n // remain the ultimate escape hatch; `customOverride` consults the\n // `overrideJSONSchema(...)` registration map (parameterized by `io` so it\n // can pick divergent input/output fragments) and clobbers the built-in\n // primitive/composition mappings for the registered schema instance.\n const customOverride = createCustomOverride(params.io);\n const merged = combine(primitiveOverride, compositionOverride, customOverride, params.override);\n const unrepresentableHits: UnrepresentableHit[] = [];\n // Inner descent targets shadowed by an outer pipe registration. Populated\n // JIT during traversal: Zod processes inner-before-outer in reverse-seen\n // order, but `consumeUnrepresentable` runs only after traversal completes,\n // so by then the outer pipe's coverage declaration has landed.\n const coveredByPipe = new WeakSet<$ZodType>();\n\n const wrapped: Override = (ctx) => {\n merged(ctx);\n if (ctx.zodSchema._zod.def.type === 'pipe') {\n const record = peekRegistration(ctx.zodSchema);\n if (record !== undefined && record[params.io] !== undefined) {\n markPipeCoverage(ctx.zodSchema, params.io, coveredByPipe);\n }\n }\n if (!strict || !isStrictlyUnrepresentable(ctx.jsonSchema, ctx.zodSchema)) {\n return;\n }\n unrepresentableHits.push({\n path: [...ctx.path],\n zodType: ctx.zodSchema._zod.def.type,\n zodSchema: ctx.zodSchema,\n });\n };\n\n const options: NonNullable<Parameters<typeof z.toJSONSchema>[1]> = {\n target: 'draft-2020-12',\n io: params.io,\n unrepresentable: 'any',\n metadata: params.registry.zodRegistry,\n override: wrapped,\n cycles: 'ref',\n reused: params.reused,\n };\n if (params.uri !== undefined) {\n options.uri = params.uri;\n }\n\n return {\n options,\n consumeUnrepresentable: () => {\n const firstHit = unrepresentableHits.find((hit) => !coveredByPipe.has(hit.zodSchema));\n if (firstHit !== undefined) {\n throw new ZodNestUnrepresentableError(firstHit.path, firstHit.zodType);\n }\n },\n };\n};\n\n// Covers both `.meta({ id })` and `registry.register(schema, id)` — the latter\n// writes the id through to the zod registry.\nconst resolveRootId = (schema: z.ZodType, registry: ZodNestRegistry): string | undefined => {\n const id = registry.zodRegistry.get(schema)?.id;\n return typeof id === 'string' && id !== '' ? id : undefined;\n};\n\nexport const toOpenApi = (schema: z.ZodType, opts: ToOpenApiOptions): ToOpenApiResult => {\n const built = buildToJsonSchemaOptions({\n registry: opts.registry,\n io: opts.io,\n override: opts.override,\n strict: opts.strict,\n reused: 'inline',\n });\n const raw = z.toJSONSchema(schema, built.options);\n built.consumeUnrepresentable();\n\n const result = postProcess(raw, {\n rootId: resolveRootId(schema, opts.registry),\n strict: opts.strict,\n });\n\n for (const [id] of opts.registry.getCollisions()) {\n if (!result.refs.has(id)) {\n continue;\n }\n result.refs.set(id, {\n description: `ERROR: duplicate zod-nest id <${id}>`,\n [ZOD_NEST_ERROR_EXTENSION]: ZOD_NEST_ERROR_DUPLICATE_ID,\n });\n }\n\n return result;\n};\n","/** Runtime tag placed on every class returned by `createZodDto`. */\nexport const ZOD_DTO_SYMBOL: unique symbol = Symbol.for('zod-nest.dto');\n","import { z } from 'zod';\n\nimport type { ZodDto } from './dto.types.js';\n\nimport { ZOD_DTO_SYMBOL } from './symbols.js';\n\n/**\n * Runtime guard: is `value` a class returned by `createZodDto`?\n *\n * Used by `ZodValidationPipe`, `ZodSerializerInterceptor`, and `applyZodNest`\n * to discriminate zod-nest DTOs from plain\n * constructors, class-validator DTOs, primitives, and any other metatypes\n * NestJS exposes via `ArgumentMetadata`.\n */\nexport const isZodDto = (value: unknown): value is ZodDto =>\n typeof value === 'function' &&\n (value as unknown as Record<symbol, unknown>)[ZOD_DTO_SYMBOL] === true;\n\n/**\n * Runtime guard: is `value` a Zod schema (any `z.*` type)?\n *\n * Used by `@ZodResponse` to accept a raw schema in place of a DTO — including\n * `z.discriminatedUnion` / `z.union` / `z.intersection`, which can't be wrapped\n * with `createZodDto` (their `z.infer` is a union, so `class … extends\n * createZodDto(schema)` fails to typecheck with TS2509). `instanceof z.ZodType`\n * holds for every schema built through the same `zod` module instance.\n */\nexport const isZodSchema = (value: unknown): value is z.ZodType => value instanceof z.ZodType;\n","import { BadRequestException, HttpStatus } from '@nestjs/common';\nimport { z } from 'zod';\n\nimport type { ArgumentMetadata } from '@nestjs/common';\n\n/**\n * Default exception thrown by `ZodValidationPipe` when input fails to parse.\n *\n * Body shape (returned by `getResponse()`):\n * ```\n * {\n * statusCode: 400,\n * message: 'Validation failed',\n * errors: z.treeifyError(zodError),\n * }\n * ```\n *\n * Carries `zodError` and `argMetadata` so custom exception filters can\n * introspect the original validation failure.\n */\nexport class ZodValidationException extends BadRequestException {\n readonly zodError: z.ZodError;\n readonly argMetadata?: ArgumentMetadata;\n\n constructor(zodError: z.ZodError, argMetadata?: ArgumentMetadata) {\n super(\n {\n statusCode: HttpStatus.BAD_REQUEST,\n message: 'Validation failed',\n errors: z.treeifyError(zodError),\n },\n { cause: zodError },\n );\n this.zodError = zodError;\n this.argMetadata = argMetadata;\n }\n}\n","import type { z } from 'zod';\n\nimport { singleton } from './singleton.js';\n\n/** Synthetic-id prefix for an anonymous `@ZodResponse` body. */\nexport const ANON_RESPONSE_PREFIX = '_AnonResponseSchema_';\n/** Synthetic-id prefix for an anonymous `@ZodBody` body. */\nexport const ANON_BODY_PREFIX = '_AnonBodySchema_';\n\n/**\n * One synthetic id per schema instance, cached so the same un-named schema\n * reused across routes maps to a single id (and therefore a single registry\n * entry) rather than minting a fresh one per decoration. WeakMap so the id is\n * GC'd with the schema. Mirrors the cache pattern in `output-dto.ts` /\n * `normalize-type.ts`.\n *\n * The counter is module-global so ids are unique across both prefixes; the\n * prefix is only chosen on first sight of a schema, so a schema passed to both\n * `@ZodBody` and `@ZodResponse` keeps whichever id it got first — harmless,\n * since the id is internal and inlined away.\n */\nconst anonIdCache = singleton('anon-id-cache', () => new WeakMap<z.ZodType, string>());\nconst counterRef = singleton('anon-id-counter', () => ({ value: 0 }));\n\nexport const resolveAnonId = (schema: z.ZodType, prefix: string): string => {\n const cached = anonIdCache.get(schema);\n if (cached !== undefined) {\n return cached;\n }\n counterRef.value += 1;\n const id = `${prefix}${counterRef.value}`;\n anonIdCache.set(schema, id);\n return id;\n};\n","import { z } from 'zod';\n\nimport type { ZodNestRegistry } from '../../schema/registry.js';\n\nimport { ANON_BODY_PREFIX, resolveAnonId } from '../../schema/anon-id.js';\nimport { COMPONENTS_SCHEMAS_PREFIX } from '../../schema/constants.js';\nimport { discoverDependents } from '../../schema/discover-dependents.js';\nimport { toOpenApi } from '../../schema/engine.js';\nimport { defaultRegistry, registerSchema } from '../../schema/registry.js';\n\n/**\n * Resolution of a schema used by `@ZodBody` / `@ZodQuery` / `@ZodParam` /\n * `@ZodHeaders` / `@ZodCookies`.\n *\n * - `ref` — the schema (or property's schema) has an id via `.meta({ id })`\n * or via the explicit `id` option. It's registered in the registry so\n * `applyZodNest`'s bulk-emit pass writes its body to `components.schemas`,\n * and the decorator references it as `{ $ref: '#/components/schemas/<id>' }`.\n * - `inline` — no id was resolvable; the JSON Schema body is embedded\n * directly into the operation. Named descendants are still registered so\n * any nested `$ref`s inside the inline body resolve at doc-build time.\n */\nexport interface SchemaRefResolutionRef {\n readonly kind: 'ref';\n readonly ref: { readonly $ref: string };\n}\nexport interface SchemaRefResolutionInline {\n readonly kind: 'inline';\n readonly schema: Record<string, unknown>;\n}\nexport type SchemaRefResolution = SchemaRefResolutionRef | SchemaRefResolutionInline;\n\nexport interface ResolveSchemaRefOptions {\n /** Forces this id, overriding any `.meta({ id })` already on the schema. */\n readonly id?: string;\n /** Registry to register into. Defaults to `defaultRegistry`. */\n readonly registry?: ZodNestRegistry;\n /**\n * When `true`, an anonymous (un-named) schema is registered under a synthetic\n * `anonymous` id and returned as a `$ref` instead of being rendered inline\n * here. `applyZodNest`'s `inlineAnonymousBodies` pass then inlines the body\n * (emitted by bulk-emit under the document's `strict` / `override`) and\n * prunes the component. Used by `@ZodBody`, where the body is emitted as a\n * full schema; left `false` for per-property param expansion, which inlines\n * the (usually primitive) property body directly.\n */\n readonly deferAnonInline?: boolean;\n}\n\n/**\n * Resolve a schema for embedding in an OpenAPI operation. If the schema is\n * named (has `.meta({ id })` or an explicit `options.id`), it's registered\n * and a `$ref` is returned. Otherwise:\n *\n * - with `deferAnonInline`, the schema is registered under a synthetic\n * `anonymous` id and a `$ref` to it is returned — `applyZodNest` inlines and\n * prunes it later, so the body honors the document's `strict` / `override`;\n * - without it, the schema is rendered inline here via `toOpenApi(...)`, and\n * any *named descendants* are registered so refs inside the inline body\n * resolve at doc-build time.\n */\n// With `deferAnonInline: true`, an anonymous schema is registered and returned\n// as a `$ref` too, so the result is always a `ref` — narrow the return so\n// callers (e.g. `@ZodBody`) don't carry a dead `inline` branch.\nexport function resolveSchemaRef(\n schema: z.ZodType,\n options: ResolveSchemaRefOptions & { readonly deferAnonInline: true },\n): SchemaRefResolutionRef;\nexport function resolveSchemaRef(\n schema: z.ZodType,\n options?: ResolveSchemaRefOptions,\n): SchemaRefResolution;\nexport function resolveSchemaRef(\n schema: z.ZodType,\n options?: ResolveSchemaRefOptions,\n): SchemaRefResolution {\n const registry = options?.registry ?? defaultRegistry;\n const id = registerSchema(schema, registry, { id: options?.id });\n if (id !== undefined) {\n return { kind: 'ref', ref: { $ref: `${COMPONENTS_SCHEMAS_PREFIX}${id}` } };\n }\n if (options?.deferAnonInline === true) {\n // `registerSchema` registers the schema and (via `register`) its named\n // descendants, so nested `$ref`s inside the emitted body resolve.\n const anonId = resolveAnonId(schema, ANON_BODY_PREFIX);\n registerSchema(schema, registry, { id: anonId, anonymous: true });\n return { kind: 'ref', ref: { $ref: `${COMPONENTS_SCHEMAS_PREFIX}${anonId}` } };\n }\n for (const [child, childId] of discoverDependents(schema)) {\n registry.register(child, childId);\n }\n const { schema: body } = toOpenApi(schema, { io: 'input', registry });\n return { kind: 'inline', schema: body as Record<string, unknown> };\n}\n","import { z } from 'zod';\n\nimport type { ZodNestRegistry } from '../../schema/registry.js';\nimport type { SchemaRefResolution } from './zod-schema-ref.js';\n\nimport { isOptionalProp } from '../../schema/composition.js';\nimport { ZodNestError } from '../../schema/errors.js';\nimport { defaultRegistry, registerSchema } from '../../schema/registry.js';\nimport { resolveSchemaRef } from './zod-schema-ref.js';\n\nexport const isZodObject = (schema: z.ZodType): schema is z.ZodObject =>\n schema._zod.def.type === 'object';\n\nexport interface ExpandedParam {\n readonly name: string;\n readonly required: boolean;\n readonly resolution: SchemaRefResolution;\n}\n\nexport interface ExpandObjectSchemaOptions {\n readonly id?: string;\n readonly registry?: ZodNestRegistry;\n /**\n * When `true`, every expanded property is marked `required` regardless of\n * its Zod optionality — path params can't be optional in OpenAPI.\n */\n readonly forceRequired?: boolean;\n /** Decorator name used in error messages, e.g. `@ZodQuery`. */\n readonly decoratorName: string;\n}\n\n/**\n * Expand a Zod object schema into one parameter entry per property. Used by\n * `@ZodQuery`, `@ZodParam`, `@ZodHeaders`, and `@ZodCookies` — they all\n * project an object schema onto N named OpenAPI parameters.\n *\n * Registers the root schema (when it has an id) so `components.schemas[id]`\n * holds the full object body for cross-referencing. Each property's schema\n * goes through `resolveSchemaRef` independently: named properties become\n * `$ref`s, anonymous properties inline.\n *\n * Throws `ZodNestError` when the schema is not a `z.object` — non-object\n * schemas can't be represented as a flat list of named params in OpenAPI.\n */\nexport const expandObjectSchema = (\n schema: z.ZodType,\n options: ExpandObjectSchemaOptions,\n): ExpandedParam[] => {\n if (!isZodObject(schema)) {\n throw new ZodNestError(\n `${options.decoratorName} requires a \\`z.object({...})\\` schema (got \\`${schema._zod.def.type}\\`). ` +\n `Each property of the object becomes one OpenAPI parameter. ` +\n `For non-object body shapes (intersections, unions, primitives), use \\`@ZodBody\\` instead.`,\n );\n }\n const registry = options.registry ?? defaultRegistry;\n // Register the root if it has an id — it isn't referenced by the per-property\n // expansion below, so it'll only land in `components.schemas` when something\n // else references it (`@ZodBody`, another decorator, a manual `$ref`).\n // Idempotent + harmless when the schema is anonymous.\n registerSchema(schema, registry, { id: options.id });\n const result: ExpandedParam[] = [];\n for (const [name, propSchema] of Object.entries(schema.shape)) {\n const resolution = resolveSchemaRef(propSchema, { registry });\n const required = options.forceRequired === true || !isOptionalProp(propSchema);\n result.push({ name, required, resolution });\n }\n return result;\n};\n\n/**\n * Resolve the JSON Schema body for a single expanded parameter. `$ref` for\n * named property schemas, otherwise the inline JSON Schema body.\n */\nexport const paramSchemaBody = (\n resolution: SchemaRefResolution,\n): { $ref: string } | Record<string, unknown> =>\n resolution.kind === 'ref' ? resolution.ref : resolution.schema;\n","import { z } from 'zod';\n\nimport type { ZodNestRegistry } from '../../schema/registry.js';\n\nimport { discoverDependents } from '../../schema/discover-dependents.js';\nimport { toOpenApi } from '../../schema/engine.js';\nimport { ZodNestError } from '../../schema/errors.js';\nimport { registerSchema } from '../../schema/registry.js';\nimport { isZodObject } from './zod-param-expand.js';\n\n/**\n * Runtime shape of Zod v4's `$ZodIntersectionDef`. The upstream `.left` /\n * `.right` are typed as Zod's internal `$ZodType` base, not the public\n * `z.ZodType`; the structures are runtime-equivalent. The cast at the\n * boundary keeps the rest of this module on the public type.\n */\ninterface IntersectionDef {\n readonly type: 'intersection';\n readonly left: z.ZodType;\n readonly right: z.ZodType;\n}\n\ninterface UnionDef {\n readonly type: 'union';\n readonly options: ReadonlyArray<z.ZodType>;\n}\n\nconst intersectionArms = (\n schema: z.ZodType,\n): { readonly left: z.ZodType; readonly right: z.ZodType } | null => {\n if (schema._zod.def.type !== 'intersection') {\n return null;\n }\n // Zod-internal → public-type boundary: `$ZodType` vs `z.ZodType`.\n const def = schema._zod.def as unknown as IntersectionDef;\n return { left: def.left, right: def.right };\n};\n\nconst unionOptions = (schema: z.ZodType): ReadonlyArray<z.ZodType> | null => {\n if (schema._zod.def.type !== 'union') {\n return null;\n }\n // Zod-internal → public-type boundary. `discriminatedUnion` also uses\n // `type: 'union'` and shares the `options` field shape.\n const def = schema._zod.def as unknown as UnionDef;\n return def.options;\n};\n\ninterface CollectedShapes {\n readonly shapes: ReadonlyArray<Record<string, z.ZodType>>;\n /**\n * `true` when the walk traversed a union arm at any depth — signals that\n * the merged shape should mark all properties optional, since no single\n * property is guaranteed across the original variants.\n */\n readonly unionCrossed: boolean;\n}\n\n/**\n * Walk an intersection / union tree and collect every `z.object` shape\n * reachable. Returns `null` as soon as a non-object leaf is hit (a\n * primitive, a tuple, a transform — anything that isn't an object and\n * isn't a composite of objects). Single-object input returns one shape.\n */\nconst collectObjectShapes = (schema: z.ZodType): CollectedShapes | null => {\n if (isZodObject(schema)) {\n return { shapes: [schema.shape], unionCrossed: false };\n }\n const options = unionOptions(schema);\n if (options !== null) {\n const allShapes: Array<Record<string, z.ZodType>> = [];\n for (const variant of options) {\n const variantResult = collectObjectShapes(variant);\n if (variantResult === null) {\n return null;\n }\n allShapes.push(...variantResult.shapes);\n }\n return { shapes: allShapes, unionCrossed: true };\n }\n const arms = intersectionArms(schema);\n if (arms === null) {\n return null;\n }\n const left = collectObjectShapes(arms.left);\n if (left === null) {\n return null;\n }\n const right = collectObjectShapes(arms.right);\n if (right === null) {\n return null;\n }\n return {\n shapes: [...left.shapes, ...right.shapes],\n unionCrossed: left.unionCrossed || right.unionCrossed,\n };\n};\n\n/**\n * Merge an intersection / union tree of `z.object` arms into a single\n * anonymous `z.object`, emit it inline, and return the JSON Schema body.\n * Used by `@ZodBody({ flatten: true })` so Swagger UI's\n * `multipart/form-data` `try-it-out` form renders correctly — the UI\n * doesn't follow `$ref` or unwrap `allOf` / `oneOf`, so it needs a flat\n * object literal at the operation's `schema` site.\n *\n * Supported shapes:\n * - `z.object({...})` — single-arm case, identity merge.\n * - `z.intersection(obj, obj)` — merges both arms' properties.\n * - Nested intersections (`intersection(intersection(A, B), C)`) — all\n * reachable arms merged in source order.\n * - `z.union([obj, obj, ...])` / `z.discriminatedUnion(...)` — merges all\n * variant properties. **All merged properties become optional** because\n * no single property is guaranteed across the original variants.\n * - `intersection(union(...), union(...))` — combines the above; any\n * property reachable through a union is optional in the result.\n *\n * Rejected shapes (throws `ZodNestError`):\n * - Any non-object leaf at any depth: primitives, tuples, transforms,\n * nullable/optional wrappers around non-objects.\n *\n * Behavior details:\n * - Property collisions resolve right-arm-wins (mirrors `z.object`'s spread\n * semantics; for unions, later variants override earlier ones).\n * - The original schema's `.meta({ id })` on the root is *not* preserved —\n * the merged object is anonymous and lives only in the operation body.\n * - Per-property `.meta({ id })` schemas keep their `$ref` emission via\n * normal `toOpenApi` traversal.\n * - The spec emission becomes less precise (a union arm's \"you must supply\n * variant A or variant B\" becomes \"any subset of all variants' fields\").\n * This is the documented trade-off for Swagger UI compatibility — runtime\n * validation via `ZodValidationPipe(originalSchema)` still enforces the\n * precise shape.\n */\nexport const flattenObjectIntersection = (\n schema: z.ZodType,\n registry: ZodNestRegistry,\n decoratorName: string,\n): Record<string, unknown> => {\n const collected = collectObjectShapes(schema);\n if (collected === null) {\n throw new ZodNestError(\n `${decoratorName} \\`flatten: true\\` requires every leaf of the schema to be a ` +\n `\\`z.object({...})\\` — intersections and unions of objects are supported, but ` +\n `primitives, tuples, transforms, and other non-object leaves are not. Drop ` +\n `\\`flatten: true\\` to emit the original schema with its composition intact.`,\n );\n }\n const mergedShape: Record<string, z.ZodType> = {};\n for (const shape of collected.shapes) {\n Object.assign(mergedShape, shape);\n }\n if (collected.unionCrossed) {\n // Wrap each property in `.optional()` — no single property is guaranteed\n // across the original union variants, so the merged spec must allow any\n // subset. Runtime validation against the original schema still enforces\n // the precise variant shape.\n for (const [key, value] of Object.entries(mergedShape)) {\n mergedShape[key] = value.optional();\n }\n }\n const merged = z.object(mergedShape);\n // Register the root if it has a `.meta({ id })` so the schema's natural\n // (non-flattened) emission lands in `components.schemas[id]` via the\n // exposure-by-registration rule in `applyZodNest`. The inline operation\n // body remains the flat merged form for Swagger UI compatibility — the\n // catalog gets the structural composition (`allOf` / `oneOf`). No-op\n // when the schema is anonymous.\n registerSchema(schema, registry);\n // Walk named descendants of the *original* schema so per-property $refs\n // resolve when bulk-emit runs. `toOpenApi` below will also register\n // descendants of the merged shape, but the original may carry meta entries\n // on nodes that the merged object's shape doesn't directly reference.\n for (const [child, childId] of discoverDependents(schema)) {\n registry.register(child, childId);\n }\n const { schema: body } = toOpenApi(merged, { io: 'input', registry });\n return body as Record<string, unknown>;\n};\n"]}
@@ -0,0 +1,103 @@
1
+ 'use strict';
2
+
3
+ var chunk4RXGLSPP_js = require('./chunk-4RXGLSPP.js');
4
+
5
+ // src/helpers/fragments.ts
6
+ var dateTimeFragment = {
7
+ type: "string",
8
+ format: "date-time"
9
+ };
10
+ var dateFragment = {
11
+ type: "string",
12
+ format: "date"
13
+ };
14
+ var timeFragment = {
15
+ type: "string",
16
+ format: "time"
17
+ };
18
+ var uuidFragment = {
19
+ type: "string",
20
+ format: "uuid"
21
+ };
22
+ var emailFragment = {
23
+ type: "string",
24
+ format: "email"
25
+ };
26
+ var uriFragment = {
27
+ type: "string",
28
+ format: "uri"
29
+ };
30
+ var hostnameFragment = {
31
+ type: "string",
32
+ format: "hostname"
33
+ };
34
+ var ipv4Fragment = {
35
+ type: "string",
36
+ format: "ipv4"
37
+ };
38
+ var ipv6Fragment = {
39
+ type: "string",
40
+ format: "ipv6"
41
+ };
42
+ var binaryFragment = {
43
+ type: "string",
44
+ format: "binary"
45
+ };
46
+ var byteFragment = {
47
+ type: "string",
48
+ format: "byte"
49
+ };
50
+ var int32Fragment = {
51
+ type: "integer",
52
+ format: "int32"
53
+ };
54
+ var int64Fragment = {
55
+ type: "integer",
56
+ format: "int64"
57
+ };
58
+ var floatFragment = {
59
+ type: "number",
60
+ format: "float"
61
+ };
62
+ var doubleFragment = {
63
+ type: "number",
64
+ format: "double"
65
+ };
66
+ var opaqueFragment = {
67
+ type: "object",
68
+ additionalProperties: true
69
+ };
70
+ var enrich = /* @__PURE__ */ chunk4RXGLSPP_js.__name((base, extras) => ({
71
+ ...base,
72
+ ...extras
73
+ }), "enrich");
74
+ var binary = /* @__PURE__ */ chunk4RXGLSPP_js.__name((opts) => ({
75
+ ...binaryFragment,
76
+ ...opts
77
+ }), "binary");
78
+ var opaque = /* @__PURE__ */ chunk4RXGLSPP_js.__name((opts) => ({
79
+ ...opaqueFragment,
80
+ ...opts
81
+ }), "opaque");
82
+
83
+ exports.binary = binary;
84
+ exports.binaryFragment = binaryFragment;
85
+ exports.byteFragment = byteFragment;
86
+ exports.dateFragment = dateFragment;
87
+ exports.dateTimeFragment = dateTimeFragment;
88
+ exports.doubleFragment = doubleFragment;
89
+ exports.emailFragment = emailFragment;
90
+ exports.enrich = enrich;
91
+ exports.floatFragment = floatFragment;
92
+ exports.hostnameFragment = hostnameFragment;
93
+ exports.int32Fragment = int32Fragment;
94
+ exports.int64Fragment = int64Fragment;
95
+ exports.ipv4Fragment = ipv4Fragment;
96
+ exports.ipv6Fragment = ipv6Fragment;
97
+ exports.opaque = opaque;
98
+ exports.opaqueFragment = opaqueFragment;
99
+ exports.timeFragment = timeFragment;
100
+ exports.uriFragment = uriFragment;
101
+ exports.uuidFragment = uuidFragment;
102
+ //# sourceMappingURL=chunk-LXRBMFWD.js.map
103
+ //# sourceMappingURL=chunk-LXRBMFWD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helpers/fragments.ts"],"names":["dateTimeFragment","type","format","dateFragment","timeFragment","uuidFragment","emailFragment","uriFragment","hostnameFragment","ipv4Fragment","ipv6Fragment","binaryFragment","byteFragment","int32Fragment","int64Fragment","floatFragment","doubleFragment","opaqueFragment","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A,EAAM,QAAA;EAAUC,MAAAA,EAAQ;AAAS;AAG1D,IAAMe,cAAAA,GAAiB;EAC5BhB,IAAAA,EAAM,QAAA;EACNiB,oBAAAA,EAAsB;AACxB;AAsEO,IAAMC,MAAAA,mBAASC,uBAAA,CAAA,CAAyBC,IAAAA,EAASC,MAAAA,MAAyC;EAC/F,GAAGD,IAAAA;EACH,GAAGC;AACL,CAAA,CAAA,EAHsB,QAAA;AAmBf,IAAMC,MAAAA,4CAAUC,IAAAA,MAAgD;EACrE,GAAGb,cAAAA;EACH,GAAGa;AACL,CAAA,CAAA,EAHsB,QAAA;AAcf,IAAMC,MAAAA,4CAAUD,IAAAA,MAAgD;EACrE,GAAGP,cAAAA;EACH,GAAGO;AACL,CAAA,CAAA,EAHsB,QAAA","file":"chunk-LXRBMFWD.js","sourcesContent":["import type { SchemaObject } from '../schema/openapi.types.js';\n\n/**\n * Common JSON Schema fragment catalog — reusable building blocks for assembling\n * fragments by hand: alongside `z.custom<T>()`, in `overrideJSONSchema` calls,\n * in custom override callbacks, in tests that build expected fragments.\n *\n * The catalog overlaps with what Zod constructs already emit (`z.uuid()` →\n * `uuidFragment` shape, `z.email()` → `emailFragment` shape, etc.) — the\n * helpers don't *replace* those Zod constructs; they're a parallel catalog\n * for programmatic fragment assembly.\n *\n * Each fragment is `as const satisfies SchemaObject` so its literal type\n * powers the dispatch in {@link enrich} — passing wrong-family options\n * fails at compile time.\n */\n\n// ---------------------------------------------------------------------------\n// Layer 1 — Fragment catalog\n// ---------------------------------------------------------------------------\n\n// String formats (RFC-defined)\nexport const dateTimeFragment = {\n type: 'string',\n format: 'date-time',\n} as const satisfies SchemaObject;\nexport const dateFragment = { type: 'string', format: 'date' } as const satisfies SchemaObject;\nexport const timeFragment = { type: 'string', format: 'time' } as const satisfies SchemaObject;\nexport const uuidFragment = { type: 'string', format: 'uuid' } as const satisfies SchemaObject;\nexport const emailFragment = { type: 'string', format: 'email' } as const satisfies SchemaObject;\nexport const uriFragment = { type: 'string', format: 'uri' } as const satisfies SchemaObject;\nexport const hostnameFragment = {\n type: 'string',\n format: 'hostname',\n} as const satisfies SchemaObject;\nexport const ipv4Fragment = { type: 'string', format: 'ipv4' } as const satisfies SchemaObject;\nexport const ipv6Fragment = { type: 'string', format: 'ipv6' } as const satisfies SchemaObject;\n\n// Binary / encoded payloads\nexport const binaryFragment = { type: 'string', format: 'binary' } as const satisfies SchemaObject;\nexport const byteFragment = { type: 'string', format: 'byte' } as const satisfies SchemaObject;\n\n// Numeric formats (OpenAPI 3.1)\nexport const int32Fragment = { type: 'integer', format: 'int32' } as const satisfies SchemaObject;\nexport const int64Fragment = { type: 'integer', format: 'int64' } as const satisfies SchemaObject;\nexport const floatFragment = { type: 'number', format: 'float' } as const satisfies SchemaObject;\nexport const doubleFragment = { type: 'number', format: 'double' } as const satisfies SchemaObject;\n\n// Object passthrough\nexport const opaqueFragment = {\n type: 'object',\n additionalProperties: true,\n} as const satisfies SchemaObject;\n\n// ---------------------------------------------------------------------------\n// Layer 2 — Per-family option types\n// ---------------------------------------------------------------------------\n\nexport interface StringFormatOptions {\n description?: string;\n examples?: string[];\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n}\n\nexport interface BinaryFragmentOptions {\n description?: string;\n contentMediaType?: string;\n contentEncoding?: string;\n}\n\nexport interface NumberFormatOptions {\n description?: string;\n examples?: number[];\n minimum?: number;\n maximum?: number;\n exclusiveMinimum?: number;\n exclusiveMaximum?: number;\n multipleOf?: number;\n}\n\nexport interface OpaqueFragmentOptions {\n description?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Layer 3 — Type-strict generic enrich\n// ---------------------------------------------------------------------------\n\n// `binary` discriminates before the generic string-format branch because its\n// option set diverges (contentMediaType / contentEncoding instead of length\n// constraints). Order matters here.\ntype OptionsFor<T> = T extends { readonly format: 'binary' }\n ? BinaryFragmentOptions\n : T extends {\n readonly format:\n | 'date-time'\n | 'date'\n | 'time'\n | 'uuid'\n | 'email'\n | 'uri'\n | 'hostname'\n | 'ipv4'\n | 'ipv6'\n | 'byte';\n }\n ? StringFormatOptions\n : T extends { readonly format: 'int32' | 'int64' | 'float' | 'double' }\n ? NumberFormatOptions\n : T extends { readonly type: 'object'; readonly additionalProperties: true }\n ? OpaqueFragmentOptions\n : never;\n\n/**\n * Merge a catalog fragment with extras whose shape is dictated by the base\n * fragment's family. Passing wrong-family extras (e.g. a `contentMediaType`\n * onto `uuidFragment`) is a compile-time error.\n *\n * Returns a fresh `SchemaObject` — the original fragment is never mutated.\n */\nexport const enrich = <T extends SchemaObject>(base: T, extras: OptionsFor<T>): SchemaObject => ({\n ...base,\n ...extras,\n});\n\n// ---------------------------------------------------------------------------\n// Layer 3b — Sugar functions\n// ---------------------------------------------------------------------------\n\n/**\n * Binary-content fragment with typed enrichment. Sugar for\n * `enrich(binaryFragment, opts)` — exists because the `binary` option set\n * (`contentMediaType` / `contentEncoding`) is nuanced enough to deserve a\n * dedicated entry point and discoverable via auto-complete.\n *\n * @example\n * overrideJSONSchema(z.instanceof(File), binary());\n * overrideJSONSchema(z.instanceof(File), binary({ contentMediaType: 'application/pdf' }));\n */\nexport const binary = (opts?: BinaryFragmentOptions): SchemaObject => ({\n ...binaryFragment,\n ...opts,\n});\n\n/**\n * Opaque-object fragment with typed enrichment. Sugar for\n * `enrich(opaqueFragment, opts)` — exists for parity with {@link binary}\n * and because opaque passthrough payloads commonly carry a description\n * explaining why the API doesn't introspect them.\n *\n * @example\n * overrideJSONSchema(z.unknown(), opaque({ description: 'JWT passthrough' }));\n */\nexport const opaque = (opts?: OpaqueFragmentOptions): SchemaObject => ({\n ...opaqueFragment,\n ...opts,\n});\n"]}
@@ -0,0 +1,286 @@
1
+ import { ZodValidationException, defaultRegistry, isZodSchema, isZodObject, flattenObjectIntersection, resolveSchemaRef } from './chunk-LHNXO52A.mjs';
2
+ import { binary } from './chunk-WI4JKXT6.mjs';
3
+ import { singleton, __name, overrideJSONSchema } from './chunk-ZZW54ETO.mjs';
4
+ import { z } from 'zod';
5
+ import { ApiConsumes, ApiBody } from '@nestjs/swagger';
6
+ import { createParamDecorator } from '@nestjs/common';
7
+
8
+ // src/multipart/file-checks.ts
9
+ var normalizeExtension = /* @__PURE__ */ __name((extension) => extension.startsWith(".") ? extension.toLowerCase() : `.${extension.toLowerCase()}`, "normalizeExtension");
10
+ var mimeTypeCheck = /* @__PURE__ */ __name((accessors, options) => {
11
+ const allowed = new Set(options.mimeTypes.map((mimeType) => mimeType.toLowerCase()));
12
+ return (payload) => {
13
+ const mimeType = accessors.mimeType(payload.value).toLowerCase();
14
+ if (allowed.has(mimeType)) {
15
+ return;
16
+ }
17
+ payload.issues.push({
18
+ code: "custom",
19
+ input: payload.value,
20
+ message: `Expected one of ${options.mimeTypes.join(", ")}, received ${mimeType}`
21
+ });
22
+ };
23
+ }, "mimeTypeCheck");
24
+ var extensionCheck = /* @__PURE__ */ __name((accessors, options) => {
25
+ const allowed = new Set(options.extensions.map(normalizeExtension));
26
+ return (payload) => {
27
+ const fileName = accessors.fileName(payload.value).toLowerCase();
28
+ const matched = [
29
+ ...allowed
30
+ ].some((extension) => fileName.endsWith(extension));
31
+ if (matched) {
32
+ return;
33
+ }
34
+ payload.issues.push({
35
+ code: "custom",
36
+ input: payload.value,
37
+ message: `Expected a file ending in ${options.extensions.map(normalizeExtension).join(", ")}, received ${fileName}`
38
+ });
39
+ };
40
+ }, "extensionCheck");
41
+ var sizeCheck = /* @__PURE__ */ __name((readSize, options) => {
42
+ return (payload) => {
43
+ const size = readSize(payload.value);
44
+ if (size <= options.maxSize) {
45
+ return;
46
+ }
47
+ payload.issues.push({
48
+ code: "custom",
49
+ input: payload.value,
50
+ message: `Expected at most ${options.maxSize} bytes, received ${size}`
51
+ });
52
+ };
53
+ }, "sizeCheck");
54
+
55
+ // src/multipart/file-marker.ts
56
+ var fileSchemas = singleton("file-schemas", () => /* @__PURE__ */ new WeakSet());
57
+ var isZodType = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && "_zod" in value, "isZodType");
58
+ var innerOf = /* @__PURE__ */ __name((def) => {
59
+ if ("innerType" in def) {
60
+ return def.innerType;
61
+ }
62
+ if ("element" in def) {
63
+ return def.element;
64
+ }
65
+ return void 0;
66
+ }, "innerOf");
67
+ var unwrapOnce = /* @__PURE__ */ __name((schema) => {
68
+ const inner = innerOf(schema._zod.def);
69
+ return isZodType(inner) ? inner : void 0;
70
+ }, "unwrapOnce");
71
+ var markFileSchema = /* @__PURE__ */ __name((schema) => {
72
+ fileSchemas.add(schema);
73
+ return schema;
74
+ }, "markFileSchema");
75
+ var isFileSchema = /* @__PURE__ */ __name((schema) => {
76
+ if (fileSchemas.has(schema)) {
77
+ return true;
78
+ }
79
+ const inner = unwrapOnce(schema);
80
+ if (inner === void 0) {
81
+ return false;
82
+ }
83
+ return isFileSchema(inner);
84
+ }, "isFileSchema");
85
+
86
+ // src/multipart/build-file-schema.ts
87
+ var resolveFragment = /* @__PURE__ */ __name((options) => {
88
+ const contentMediaType = options?.contentMediaType ?? singleMimeType(options?.mimeTypes);
89
+ return binary({
90
+ ...options?.description !== void 0 ? {
91
+ description: options.description
92
+ } : {},
93
+ ...contentMediaType !== void 0 ? {
94
+ contentMediaType
95
+ } : {}
96
+ });
97
+ }, "resolveFragment");
98
+ var singleMimeType = /* @__PURE__ */ __name((mimeTypes) => {
99
+ if (mimeTypes === void 0 || mimeTypes.length !== 1) {
100
+ return void 0;
101
+ }
102
+ return mimeTypes[0];
103
+ }, "singleMimeType");
104
+ var collectChecks = /* @__PURE__ */ __name((params) => {
105
+ const { accessors, options, maxSize } = params;
106
+ const checks = [];
107
+ if (options?.mimeTypes !== void 0) {
108
+ checks.push(mimeTypeCheck(accessors, {
109
+ mimeTypes: options.mimeTypes
110
+ }));
111
+ }
112
+ if (options?.extensions !== void 0) {
113
+ checks.push(extensionCheck(accessors, {
114
+ extensions: options.extensions
115
+ }));
116
+ }
117
+ if (maxSize !== void 0 && accessors.size !== void 0) {
118
+ checks.push(sizeCheck(accessors.size, {
119
+ maxSize
120
+ }));
121
+ }
122
+ return checks;
123
+ }, "collectChecks");
124
+ var withId = /* @__PURE__ */ __name((schema, options, fragment) => {
125
+ if (options?.id === void 0) {
126
+ return schema;
127
+ }
128
+ return overrideJSONSchema(schema.meta({
129
+ id: options.id
130
+ }), fragment);
131
+ }, "withId");
132
+ var buildFileSchema = /* @__PURE__ */ __name((params) => {
133
+ const fragment = resolveFragment(params.options);
134
+ const base = overrideJSONSchema(z.custom(params.predicate), fragment);
135
+ const checks = collectChecks(params);
136
+ const checked = checks.length === 0 ? base : overrideJSONSchema(base.check(...checks), fragment);
137
+ return markFileSchema(withId(checked, params.options, fragment));
138
+ }, "buildFileSchema");
139
+
140
+ // src/multipart/metadata.ts
141
+ var MultipartFilesIn = {
142
+ Request: "request",
143
+ Body: "body"
144
+ };
145
+ var ZOD_MULTIPART_METADATA_KEY = /* @__PURE__ */ Symbol.for("zod-nest.multipart");
146
+ var MULTIPART_CONTENT_TYPE = "multipart/form-data";
147
+ var toSchema = /* @__PURE__ */ __name((body) => isZodSchema(body) ? body : z.object({
148
+ ...body
149
+ }), "toSchema");
150
+ var toShape = /* @__PURE__ */ __name((body) => {
151
+ if (!isZodSchema(body)) {
152
+ return body;
153
+ }
154
+ return isZodObject(body) ? body.shape : void 0;
155
+ }, "toShape");
156
+ var partitionKeys = /* @__PURE__ */ __name((shape) => {
157
+ const fileKeys = [];
158
+ const textKeys = [];
159
+ for (const [key, schema] of Object.entries(shape ?? {})) {
160
+ if (isFileSchema(schema)) {
161
+ fileKeys.push(key);
162
+ continue;
163
+ }
164
+ textKeys.push(key);
165
+ }
166
+ return {
167
+ fileKeys,
168
+ textKeys
169
+ };
170
+ }, "partitionKeys");
171
+ var resolveBody = /* @__PURE__ */ __name((schema, options, registry) => {
172
+ if (options?.flatten === true) {
173
+ return flattenObjectIntersection(schema, registry, "@ZodMultipart");
174
+ }
175
+ const resolved = resolveSchemaRef(schema, {
176
+ ...options?.id !== void 0 ? {
177
+ id: options.id
178
+ } : {},
179
+ registry
180
+ });
181
+ return resolved.kind === "ref" ? resolved.ref : resolved.schema;
182
+ }, "resolveBody");
183
+ var createZodMultipart = /* @__PURE__ */ __name((defaultFilesIn) => {
184
+ return (body, options) => {
185
+ const registry = options?.registry ?? defaultRegistry;
186
+ const shape = toShape(body);
187
+ const metadata = {
188
+ shape,
189
+ ...partitionKeys(shape),
190
+ filesIn: options?.filesIn ?? defaultFilesIn
191
+ };
192
+ const schema = resolveBody(toSchema(body), options, registry);
193
+ return (target, propertyKey, descriptor) => {
194
+ const handler = descriptor.value;
195
+ if (typeof handler !== "function") {
196
+ throw new TypeError("[zod-nest] @ZodMultipart can only be applied to methods.");
197
+ }
198
+ Reflect.defineMetadata(ZOD_MULTIPART_METADATA_KEY, metadata, handler);
199
+ const swaggerDescriptor = descriptor;
200
+ ApiConsumes(MULTIPART_CONTENT_TYPE)(target, propertyKey, swaggerDescriptor);
201
+ ApiBody({
202
+ schema,
203
+ ...options?.description !== void 0 ? {
204
+ description: options.description
205
+ } : {},
206
+ required: options?.required ?? true
207
+ })(target, propertyKey, swaggerDescriptor);
208
+ };
209
+ };
210
+ }, "createZodMultipart");
211
+ var readMetadata = /* @__PURE__ */ __name((ctx, decorator) => {
212
+ const metadata = Reflect.getMetadata(ZOD_MULTIPART_METADATA_KEY, ctx.getHandler());
213
+ if (!isMultipartMetadata(metadata)) {
214
+ throw new Error(`[zod-nest] ${decorator} requires @ZodMultipart on the same handler \u2014 it reads the declared shape from there.`);
215
+ }
216
+ return metadata;
217
+ }, "readMetadata");
218
+ var isMultipartMetadata = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && "shape" in value && "filesIn" in value, "isMultipartMetadata");
219
+ var requireShape = /* @__PURE__ */ __name((metadata, decorator) => {
220
+ if (metadata.shape !== void 0) {
221
+ return metadata.shape;
222
+ }
223
+ throw new Error(`[zod-nest] ${decorator} needs a flat body shape, but @ZodMultipart was given a composite schema (an intersection or union). Validate it with @Body(new ZodValidationPipe(schema)) instead.`);
224
+ }, "requireShape");
225
+ var schemaFor = /* @__PURE__ */ __name((metadata, name, decorator) => {
226
+ const shape = requireShape(metadata, decorator);
227
+ const schema = shape[name];
228
+ if (schema === void 0) {
229
+ throw new Error(`[zod-nest] ${decorator}('${name}') has no matching property in the @ZodMultipart shape. Declared: ${Object.keys(shape).join(", ")}.`);
230
+ }
231
+ return schema;
232
+ }, "schemaFor");
233
+ var pick = /* @__PURE__ */ __name((shape, keys) => {
234
+ const wanted = new Set(keys);
235
+ const picked = {};
236
+ for (const [key, schema] of Object.entries(shape)) {
237
+ if (wanted.has(key)) {
238
+ picked[key] = schema;
239
+ }
240
+ }
241
+ return z.object(picked);
242
+ }, "pick");
243
+ var validate = /* @__PURE__ */ __name(async (schema, value, argType) => {
244
+ const result = await schema.safeParseAsync(value);
245
+ if (result.success) {
246
+ return result.data;
247
+ }
248
+ throw new ZodValidationException(result.error, {
249
+ type: argType,
250
+ metatype: void 0,
251
+ data: void 0
252
+ });
253
+ }, "validate");
254
+ var assertFilesOnRequest = /* @__PURE__ */ __name((metadata, decorator) => {
255
+ if (metadata.filesIn === MultipartFilesIn.Request) {
256
+ return;
257
+ }
258
+ throw new Error(`[zod-nest] ${decorator} is unavailable under filesIn: 'body' \u2014 the parser puts files in the request body, so read them with @ZodMultipartBody().`);
259
+ }, "assertFilesOnRequest");
260
+ var resolveUploadedFile = /* @__PURE__ */ __name(async (name, ctx) => {
261
+ const metadata = readMetadata(ctx, "@ZodUploadedFile");
262
+ assertFilesOnRequest(metadata, "@ZodUploadedFile");
263
+ const request = ctx.switchToHttp().getRequest();
264
+ return validate(schemaFor(metadata, name, "@ZodUploadedFile"), request.file, "custom");
265
+ }, "resolveUploadedFile");
266
+ var resolveUploadedFiles = /* @__PURE__ */ __name(async (name, ctx) => {
267
+ const metadata = readMetadata(ctx, "@ZodUploadedFiles");
268
+ assertFilesOnRequest(metadata, "@ZodUploadedFiles");
269
+ const request = ctx.switchToHttp().getRequest();
270
+ const schema = name === void 0 ? pick(requireShape(metadata, "@ZodUploadedFiles"), metadata.fileKeys) : schemaFor(metadata, name, "@ZodUploadedFiles");
271
+ return validate(schema, request.files, "custom");
272
+ }, "resolveUploadedFiles");
273
+ var resolveMultipartBody = /* @__PURE__ */ __name(async (_data, ctx) => {
274
+ const metadata = readMetadata(ctx, "@ZodMultipartBody");
275
+ const shape = requireShape(metadata, "@ZodMultipartBody");
276
+ const request = ctx.switchToHttp().getRequest();
277
+ const keys = metadata.filesIn === MultipartFilesIn.Body ? Object.keys(shape) : metadata.textKeys;
278
+ return validate(pick(shape, keys), request.body, "body");
279
+ }, "resolveMultipartBody");
280
+ var ZodUploadedFile = createParamDecorator(resolveUploadedFile);
281
+ var ZodUploadedFiles = createParamDecorator(resolveUploadedFiles);
282
+ var ZodMultipartBody = createParamDecorator(resolveMultipartBody);
283
+
284
+ export { MULTIPART_CONTENT_TYPE, MultipartFilesIn, ZodMultipartBody, ZodUploadedFile, ZodUploadedFiles, buildFileSchema, createZodMultipart };
285
+ //# sourceMappingURL=chunk-RAF7JGS6.mjs.map
286
+ //# sourceMappingURL=chunk-RAF7JGS6.mjs.map