@kubb/ast 5.0.0-beta.64 → 5.0.0-beta.66

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 (45) hide show
  1. package/dist/{defineMacro-B7qm3zTd.d.ts → defineMacro-BQpu6Ags.d.ts} +2 -2
  2. package/dist/{defineMacro-CEZHaCXE.cjs → defineMacro-BxfaP1iL.cjs} +3 -4
  3. package/dist/{defineMacro-CEZHaCXE.cjs.map → defineMacro-BxfaP1iL.cjs.map} +1 -1
  4. package/dist/{defineMacro-B76LsJwO.js → defineMacro-D2vgAdoH.js} +2 -3
  5. package/dist/{defineMacro-B76LsJwO.js.map → defineMacro-D2vgAdoH.js.map} +1 -1
  6. package/dist/{index-BKD4drsX.d.ts → index-CeJAFegf.d.ts} +3 -3
  7. package/dist/index.cjs +115 -64
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.ts +38 -19
  10. package/dist/index.js +58 -7
  11. package/dist/index.js.map +1 -1
  12. package/dist/macros.cjs +5 -6
  13. package/dist/macros.cjs.map +1 -1
  14. package/dist/macros.d.ts +1 -1
  15. package/dist/macros.js +2 -3
  16. package/dist/macros.js.map +1 -1
  17. package/dist/{operationParams-ByVfpYr7.d.ts → operationParams-DCY3q4C7.d.ts} +2 -2
  18. package/dist/{schema-YNbOtTCM.js → refs-CXp6uOHL.js} +502 -2
  19. package/dist/refs-CXp6uOHL.js.map +1 -0
  20. package/dist/{schema-BkvrrOAr.cjs → refs-DDIY_Tpn.cjs} +597 -7
  21. package/dist/refs-DDIY_Tpn.cjs.map +1 -0
  22. package/dist/{types-BP9BZoq-.d.ts → types-DpeAMnq5.d.ts} +6 -6
  23. package/dist/types.d.ts +5 -5
  24. package/dist/{utils-BJi0y-xg.js → utils-C2kwfetT.js} +2 -3
  25. package/dist/utils-C2kwfetT.js.map +1 -0
  26. package/dist/{utils-CEepwqmb.cjs → utils-DYhjlv0E.cjs} +13 -14
  27. package/dist/utils-DYhjlv0E.cjs.map +1 -0
  28. package/dist/utils.cjs +3 -4
  29. package/dist/utils.d.ts +2 -2
  30. package/dist/utils.js +2 -3
  31. package/package.json +1 -5
  32. package/dist/factory-wJLzHeXT.d.ts +0 -27
  33. package/dist/factory.cjs +0 -89
  34. package/dist/factory.cjs.map +0 -1
  35. package/dist/factory.d.ts +0 -3
  36. package/dist/factory.js +0 -58
  37. package/dist/factory.js.map +0 -1
  38. package/dist/refs-Dx6U5LoE.js +0 -505
  39. package/dist/refs-Dx6U5LoE.js.map +0 -1
  40. package/dist/refs-u5SDdyV7.cjs +0 -599
  41. package/dist/refs-u5SDdyV7.cjs.map +0 -1
  42. package/dist/schema-BkvrrOAr.cjs.map +0 -1
  43. package/dist/schema-YNbOtTCM.js.map +0 -1
  44. package/dist/utils-BJi0y-xg.js.map +0 -1
  45. package/dist/utils-CEepwqmb.cjs.map +0 -1
@@ -1,5 +1,4 @@
1
- const require_schema = require("./schema-BkvrrOAr.cjs");
2
- const require_refs = require("./refs-u5SDdyV7.cjs");
1
+ const require_refs = require("./refs-DDIY_Tpn.cjs");
3
2
  //#region ../../internals/utils/src/promise.ts
4
3
  /**
5
4
  * Wraps `factory` with a keyed cache backed by the provided store.
@@ -263,7 +262,7 @@ function* mergeAdjacentObjectsLazy(members) {
263
262
  if (objectMember && !objectMember.name && acc !== void 0) {
264
263
  const accObject = require_refs.narrowSchema(acc, "object");
265
264
  if (accObject && !accObject.name) {
266
- acc = require_schema.createSchema({
265
+ acc = require_refs.createSchema({
267
266
  ...accObject,
268
267
  properties: [...accObject.properties ?? [], ...objectMember.properties ?? []]
269
268
  });
@@ -585,7 +584,7 @@ function lazyGetter({ name, body }) {
585
584
  //#endregion
586
585
  //#region src/utils/operationParams.ts
587
586
  const caseParamsMemo = memoize(/* @__PURE__ */ new WeakMap(), (params) => memoize(/* @__PURE__ */ new Map(), (casing) => params.map((param) => {
588
- const transformed = casing === "camelcase" || !isValidVarName(param.name) ? require_schema.camelCase(param.name) : param.name;
587
+ const transformed = casing === "camelcase" || !isValidVarName(param.name) ? require_refs.camelCase(param.name) : param.name;
589
588
  return {
590
589
  ...param,
591
590
  name: transformed
@@ -619,7 +618,7 @@ function resolveParamType({ node, param, resolver }) {
619
618
  header: resolver.resolveHeaderParamsName
620
619
  };
621
620
  const groupName = groupLocation ? groupResolvers[groupLocation].call(resolver, node, param) : void 0;
622
- if (groupName && groupName !== individualName) return require_schema.createIndexedAccessType({
621
+ if (groupName && groupName !== individualName) return require_refs.createIndexedAccessType({
623
622
  target: groupName,
624
623
  key: param.name
625
624
  });
@@ -693,31 +692,31 @@ function createOperationParams(node, options) {
693
692
  ...bodyProperty,
694
693
  ...trailingGroups.flatMap(buildGroupProperty)
695
694
  ];
696
- if (children.length) params.push(require_schema.createFunctionParameter({
695
+ if (children.length) params.push(require_refs.createFunctionParameter({
697
696
  properties: children,
698
697
  default: emptyObjectDefault(children)
699
698
  }));
700
699
  } else {
701
700
  if (pathParamsType === "inlineSpread" && pathParams.length) {
702
701
  const spreadType = resolver?.resolvePathParamsName(node, pathParams[0]);
703
- params.push(require_schema.createFunctionParameter({
702
+ params.push(require_refs.createFunctionParameter({
704
703
  name: pathName,
705
704
  type: spreadType ? wrapType(spreadType) : void 0,
706
705
  rest: true
707
706
  }));
708
- } else if (pathParamsType === "inline") params.push(...pathParams.map((p) => require_schema.createFunctionParameter(toProperty(p))));
707
+ } else if (pathParamsType === "inline") params.push(...pathParams.map((p) => require_refs.createFunctionParameter(toProperty(p))));
709
708
  else if (pathParams.length) {
710
709
  const pathChildren = pathParams.map(toProperty);
711
- params.push(require_schema.createFunctionParameter({
710
+ params.push(require_refs.createFunctionParameter({
712
711
  properties: pathChildren,
713
712
  default: pathParamsDefault ?? emptyObjectDefault(pathChildren)
714
713
  }));
715
714
  }
716
- params.push(...bodyProperty.map((p) => require_schema.createFunctionParameter(p)));
715
+ params.push(...bodyProperty.map((p) => require_refs.createFunctionParameter(p)));
717
716
  params.push(...trailingGroups.flatMap(buildGroupParam));
718
717
  }
719
718
  params.push(...extraParams);
720
- return require_schema.createFunctionParameters({ params });
719
+ return require_refs.createFunctionParameters({ params });
721
720
  }
722
721
  /**
723
722
  * Builds the property descriptor for a query or header group.
@@ -751,7 +750,7 @@ function buildGroupProperty({ name, node, params, groupType, resolver, wrapType
751
750
  * {@link TypeLiteralNode} from the individual params.
752
751
  */
753
752
  function buildGroupParam(args) {
754
- return buildGroupProperty(args).map((p) => require_schema.createFunctionParameter(p));
753
+ return buildGroupProperty(args).map((p) => require_refs.createFunctionParameter(p));
755
754
  }
756
755
  /**
757
756
  * Builds a {@link TypeLiteralNode} for an inline anonymous type grouping named fields.
@@ -760,7 +759,7 @@ function buildGroupParam(args) {
760
759
  * Each language printer renders this appropriately (TypeScript: `{ petId: string; name?: string }`).
761
760
  */
762
761
  function buildTypeLiteral({ node, params, resolver }) {
763
- return require_schema.createTypeLiteral({ members: params.map((p) => ({
762
+ return require_refs.createTypeLiteral({ members: params.map((p) => ({
764
763
  name: p.name,
765
764
  type: resolveParamType({
766
765
  node,
@@ -916,4 +915,4 @@ Object.defineProperty(exports, "trimQuotes", {
916
915
  }
917
916
  });
918
917
 
919
- //# sourceMappingURL=utils-CEepwqmb.cjs.map
918
+ //# sourceMappingURL=utils-DYhjlv0E.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-DYhjlv0E.cjs","names":["INDENT","narrowSchema","createSchema","resolveRefName","collectLazy","camelCase","createIndexedAccessType","resolveGroupType","createFunctionParameter","createFunctionParameters","createTypeLiteral"],"sources":["../../../internals/utils/src/promise.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/string.ts","../src/utils/codegen.ts","../src/utils/schemaMerge.ts","../src/utils/strings.ts","../src/utils/schemaGraph.ts","../src/utils/schemaTraversal.ts","../src/utils/operationParams.ts"],"sourcesContent":["function* chunks<T>(arr: ReadonlyArray<T>, size: number): Generator<Array<T>> {\n for (let i = 0; i < arr.length; i += size) {\n yield arr.slice(i, i + size)\n }\n}\n\nexport type ForBatchesOptions = {\n /**\n * Maximum batch size handed to `process`.\n * Parallel dispatch within a batch is the caller's responsibility\n * (typically via `Promise.all(batch.map(...))`).\n */\n concurrency: number\n /**\n * Called after every batch.\n *\n * Use a cheap, idempotent callback (e.g. one that short-circuits when there\n * is nothing new to do). The helper does not coalesce calls — if you need\n * throttling, do it inside `flush` itself.\n */\n flush?: () => Promise<void>\n}\n\n/**\n * Slices `source` into batches of `concurrency` items and awaits `process` for each batch.\n * Accepts both plain arrays (sync) and `AsyncIterable` (streaming).\n *\n * `process` controls whether items inside a batch run in parallel; this helper only\n * controls batch size and per-batch flushing.\n *\n * @example\n * ```ts\n * // parallel dispatch inside each batch\n * await forBatches(schemas, (batch) => Promise.all(batch.map(process)), { concurrency: 8 })\n *\n * // async iterable with a flush after every batch\n * await forBatches(stream.schemas, (batch) => dispatch(batch), { concurrency: 8, flush })\n * ```\n */\nexport async function forBatches<T>(\n source: ReadonlyArray<T> | AsyncIterable<T>,\n process: (batch: Array<T>) => Promise<unknown>,\n options: ForBatchesOptions,\n): Promise<void> {\n const { concurrency, flush } = options\n\n if (Array.isArray(source)) {\n for (const batch of chunks(source, concurrency)) {\n await process(batch)\n if (flush) await flush()\n }\n return\n }\n\n const batch: Array<T> = []\n for await (const item of source) {\n batch.push(item)\n if (batch.length >= concurrency) {\n await process(batch.splice(0))\n\n if (flush) await flush()\n }\n }\n if (batch.length > 0) {\n await process(batch.splice(0))\n\n if (flush) await flush()\n }\n}\n\n/** A value that may already be resolved or still pending.\n *\n * @example\n * ```ts\n * function load(id: string): PossiblePromise<string> {\n * return cache.get(id) ?? fetchRemote(id)\n * }\n * ```\n */\nexport type PossiblePromise<T> = Promise<T> | T\n\n/** Returns `true` when `result` is a thenable `Promise`.\n *\n * @example\n * ```ts\n * isPromise(Promise.resolve(1)) // true\n * isPromise(42) // false\n * ```\n */\nexport function isPromise<T>(result: PossiblePromise<T>): result is Promise<T> {\n return result !== null && result !== undefined && typeof (result as Record<string, unknown>)['then'] === 'function'\n}\n\ntype Store<TKey, TValue> = {\n has(key: TKey): boolean\n get(key: TKey): TValue | undefined\n set(key: TKey, value: TValue): unknown\n}\n\n/**\n * Wraps `factory` with a keyed cache backed by the provided store.\n *\n * Pass a `WeakMap` for object keys (results are GC-eligible when the key is\n * collected) or a `Map` for primitive keys. For multi-argument functions,\n * nest two `memoize` calls — the outer keyed by the first argument, the\n * inner (created once per outer miss) keyed by the second.\n *\n * Because the cache is owned by the caller, it can be shared, inspected, or\n * cleared independently of the memoized function.\n *\n * @example Single WeakMap key\n * ```ts\n * const cache = new WeakMap<SchemaNode, Set<string>>()\n * const getRefs = memoize(cache, (node) => collectRefs(node))\n * ```\n *\n * @example Single Map key (primitive)\n * ```ts\n * const cache = new Map<string, Resolver>()\n * const getResolver = memoize(cache, (name) => buildResolver(name))\n * ```\n *\n * @example Two-level (object + primitive)\n * ```ts\n * const outer = new WeakMap<Params[], Map<string, Params[]>>()\n * const fn = memoize(outer, (params) => memoize(new Map(), (key) => transform(params, key)))\n * fn(params)('camelcase')\n * ```\n */\nexport function memoize<TKey, TValue>(store: Store<TKey, TValue>, factory: (key: TKey) => TValue): (key: TKey) => TValue {\n return (key: TKey): TValue => {\n if (store.has(key)) return store.get(key)!\n const value = factory(key)\n store.set(key, value)\n return value\n }\n}\n\n/**\n * Container that switches between an eager `Array<T>` and a lazy `AsyncIterable<T>`.\n *\n * `Array<T>` by default. With `Stream` set to `true` it becomes `AsyncIterable<T>`, so large\n * collections can be produced lazily without holding every item in memory. Pairs with\n * {@link arrayToAsyncIterable}, which lifts a plain array into the streaming form.\n *\n * @example\n * ```ts\n * type Eager = Streamable<number> // Array<number>\n * type Lazy = Streamable<number, true> // AsyncIterable<number>\n * ```\n */\nexport type Streamable<T, Stream extends boolean = false> = Stream extends true ? AsyncIterable<T> : Array<T>\n\n/**\n * Wraps a plain array in a reusable `AsyncIterable`.\n * Each `[Symbol.asyncIterator]()` call returns a fresh generator so the\n * iterable can be consumed multiple times (e.g. once per plugin pre-scan).\n *\n * @example\n * ```ts\n * const stream = arrayToAsyncIterable([1, 2, 3])\n * for await (const n of stream) console.log(n) // 1, 2, 3\n * ```\n */\nexport function arrayToAsyncIterable<T>(arr: ReadonlyArray<T>): AsyncIterable<T> {\n return {\n [Symbol.asyncIterator]() {\n return (async function* () {\n yield* arr\n })()\n },\n }\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Prefixes `word` with `_` when it is a reserved JavaScript/Java identifier or starts with a digit.\n *\n * @example\n * ```ts\n * transformReservedWord('class') // '_class'\n * transformReservedWord('42foo') // '_42foo'\n * transformReservedWord('status') // 'status'\n * ```\n */\nexport function transformReservedWord(word: string): string {\n const firstChar = word.charCodeAt(0)\n if (word && (reservedWords.has(word as 'valueOf') || (firstChar >= 48 && firstChar <= 57))) {\n return `_${word}`\n }\n return word\n}\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","/**\n * Wraps a value in single quotes for emitting a single-quoted JavaScript string literal, escaping\n * any backslash or single quote in the content.\n *\n * @example\n * ```ts\n * singleQuote('foo') // \"'foo'\"\n * singleQuote(\"o'clock\") // \"'o\\\\'clock'\"\n * ```\n */\nexport function singleQuote(value: string | number | boolean | undefined | null): string {\n if (value === undefined || value === null) return \"''\"\n const escaped = String(value).replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")\n\n return `'${escaped}'`\n}\n","import { isIdentifier, singleQuote } from '@internals/utils'\nimport { INDENT } from '../constants.ts'\n\n/**\n * Builds a JSDoc comment block from an array of lines. Returns `fallback` when there are no\n * comments.\n *\n * @example\n * ```ts\n * buildJSDoc(['@type string', '@example hello'])\n * // '/**\\n * @type string\\n * @example hello\\n *\\/\\n '\n * ```\n */\nexport function buildJSDoc(\n comments: Array<string>,\n options: {\n /**\n * String used to indent each comment line.\n * @default ' * '\n */\n indent?: string\n /**\n * String appended after the closing tag.\n * @default '\\n '\n */\n suffix?: string\n /**\n * Returned as-is when `comments` is empty.\n * @default ' '\n */\n fallback?: string\n } = {},\n): string {\n const { indent = ' * ', suffix = '\\n ', fallback = ' ' } = options\n\n if (comments.length === 0) return fallback\n\n return `/**\\n${comments.map((c) => `${indent}${c}`).join('\\n')}\\n */${suffix}`\n}\n\n/**\n * Indents every non-empty line of `text` by one indent level, leaving blank lines empty.\n */\nfunction indentLines(text: string): string {\n if (!text) return ''\n return text\n .split('\\n')\n .map((line) => (line.trim() ? `${INDENT}${line}` : ''))\n .join('\\n')\n}\n\n/**\n * Renders an object key, quoting it with single quotes only when it is not a valid identifier.\n * Reserved words and globals (`name`, `class`, …) are valid bare keys and stay unquoted.\n *\n * @example\n * ```ts\n * objectKey('name') // 'name'\n * objectKey('x-total') // \"'x-total'\"\n * ```\n */\nexport function objectKey(name: string): string {\n return isIdentifier(name) ? name : singleQuote(name)\n}\n\n/**\n * Assembles a multi-line object literal from already-rendered `entries`, indenting each entry one\n * level and closing the brace at column zero. Entries that are themselves multi-line objects indent\n * cumulatively. Each entry ends with a trailing comma to match the formatter's multi-line style.\n *\n * @example\n * ```ts\n * buildObject(['id: z.number()', 'name: z.string()'])\n * // '{\\n id: z.number(),\\n name: z.string(),\\n}'\n * ```\n */\nexport function buildObject(entries: Array<string>): string {\n if (entries.length === 0) return '{}'\n const body = entries.map((entry) => `${indentLines(entry)},`).join('\\n')\n\n return `{\\n${body}\\n}`\n}\n\n/**\n * Assembles a bracketed list (array by default) from already-rendered `items`. Keeps everything on\n * one line when no item spans multiple lines, and otherwise puts each item on its own line, indented\n * one level with a trailing comma and the closing bracket at column zero. Used for member lists such\n * as `z.union([…])` and `z.array([…])`.\n *\n * @example\n * ```ts\n * buildList(['z.string()', 'z.number()'])\n * // '[z.string(), z.number()]'\n * ```\n */\nexport function buildList(items: Array<string>, brackets: [open: string, close: string] = ['[', ']']): string {\n const [open, close] = brackets\n if (items.length === 0) return `${open}${close}`\n if (!items.some((item) => item.includes('\\n'))) return `${open}${items.join(', ')}${close}`\n const body = items.map((item) => `${indentLines(item)},`).join('\\n')\n\n return `${open}\\n${body}\\n${close}`\n}\n","import { narrowSchema } from '../guards.ts'\nimport { createSchema, type SchemaNode } from '../nodes/schema.ts'\n\n/**\n * Merges a run of adjacent anonymous object members into one. Named or non-object members break the\n * run and pass through unchanged. The merge follows member order, so callers control which members\n * combine by where they place them in the sequence.\n *\n * @example\n * ```ts\n * const merged = [...mergeAdjacentObjectsLazy([objectA, objectB])]\n * ```\n */\nexport function* mergeAdjacentObjectsLazy(members: Iterable<SchemaNode>): Generator<SchemaNode, void, undefined> {\n let acc: SchemaNode | undefined\n\n for (const member of members) {\n const objectMember = narrowSchema(member, 'object')\n if (objectMember && !objectMember.name && acc !== undefined) {\n const accObject = narrowSchema(acc, 'object')\n if (accObject && !accObject.name) {\n acc = createSchema({\n ...accObject,\n properties: [...(accObject.properties ?? []), ...(objectMember.properties ?? [])],\n })\n continue\n }\n }\n if (acc !== undefined) yield acc\n acc = member\n }\n\n if (acc !== undefined) yield acc\n}\n","/**\n * Strips a single matching pair of `\"...\"`, `'...'`, or `` `...` `` from both ends of `text`.\n * Returns the string unchanged when no balanced quote pair is found.\n *\n * @example\n * ```ts\n * trimQuotes('\"hello\"') // 'hello'\n * trimQuotes('hello') // 'hello'\n * ```\n */\nexport function trimQuotes(text: string): string {\n if (text.length >= 2) {\n const first = text[0]\n const last = text[text.length - 1]\n if ((first === '\"' && last === '\"') || (first === \"'\" && last === \"'\") || (first === '`' && last === '`')) {\n return text.slice(1, -1)\n }\n }\n return text\n}\n\n/**\n * Serializes a primitive to a single-quoted string literal, stripping any surrounding quotes first.\n *\n * Escaping runs through `JSON.stringify`, then the result switches to single quotes so the generated\n * code matches the repo style without a formatter.\n *\n * @example\n * ```ts\n * stringify('hello') // \"'hello'\"\n * stringify('\"hello\"') // \"'hello'\"\n * ```\n */\nexport function stringify(value: string | number | boolean | undefined): string {\n if (value === undefined || value === null) return \"''\"\n const json = JSON.stringify(trimQuotes(value.toString()))\n const inner = json.slice(1, -1).replace(/\\\\\"/g, '\"').replace(/'/g, \"\\\\'\")\n return `'${inner}'`\n}\n\n/**\n * Escapes characters that are not allowed inside JS string literals, covering quotes, backslashes,\n * and the Unicode line terminators U+2028 and U+2029.\n *\n * @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4\n *\n * @example\n * ```ts\n * jsStringEscape('say \"hi\"\\nbye') // 'say \\\\\"hi\\\\\"\\\\nbye'\n * ```\n */\nexport function jsStringEscape(input: unknown): string {\n return `${input}`.replace(/[\"'\\\\\\n\\r\\u2028\\u2029]/g, (character) => {\n switch (character) {\n case '\"':\n case \"'\":\n case '\\\\':\n return `\\\\${character}`\n case '\\n':\n return '\\\\n'\n case '\\r':\n return '\\\\r'\n case '\\u2028':\n return '\\\\u2028'\n case '\\u2029':\n return '\\\\u2029'\n default:\n return ''\n }\n })\n}\n\n/**\n * Converts a pattern string into a `new RegExp(...)` constructor call or a regex literal string.\n * Inline flags expressed as a `^(?im)` prefix are extracted and applied to the resulting expression.\n * Pass `null` as the second argument to emit a `/pattern/flags` literal instead.\n *\n * @example\n * ```ts\n * toRegExpString('^(?im)foo') // 'new RegExp(\"^foo\", \"im\")'\n * toRegExpString('^(?im)foo', null) // '/^foo/im'\n * ```\n */\nexport function toRegExpString(text: string, func: string | null = 'RegExp'): string {\n const raw = trimQuotes(text)\n\n const match = raw.match(/^\\^(\\(\\?([igmsuy]+)\\))/i)\n const replacementTarget = match?.[1] ?? ''\n const matchedFlags = match?.[2]\n const cleaned = raw\n .replace(/^\\\\?\\//, '')\n .replace(/\\\\?\\/$/, '')\n .replace(replacementTarget, '')\n\n const { source, flags } = new RegExp(cleaned, matchedFlags)\n\n if (func === null) return `/${source}/${flags}`\n\n return `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : ''})`\n}\n\n/**\n * Renders a plain object as multi-line `key: value` source for embedding in generated code. Nested\n * objects recurse with fixed indentation, so the result drops straight into an object literal\n * without re-parsing.\n *\n * @example\n * ```ts\n * stringifyObject({ foo: 'bar', nested: { a: 1 } })\n * // 'foo: bar,\\nnested: {\\n a: 1\\n }'\n * ```\n */\nexport function stringifyObject(value: Record<string, unknown>): string {\n const items = Object.entries(value)\n .map(([key, val]) => {\n if (val !== null && typeof val === 'object') {\n return `${key}: {\\n ${stringifyObject(val as Record<string, unknown>)}\\n }`\n }\n return `${key}: ${val}`\n })\n .filter(Boolean)\n return items.join(',\\n')\n}\n\n/**\n * Renders a dotted path or string array as an optional-chaining accessor expression rooted at\n * `accessor`. Returns `null` for an empty path.\n *\n * @example\n * ```ts\n * getNestedAccessor('pagination.next.id', 'lastPage')\n * // \"lastPage?.['pagination']?.['next']?.['id']\"\n * ```\n */\nexport function getNestedAccessor(param: string | Array<string>, accessor: string): string | null {\n const parts = Array.isArray(param) ? param : param.split('.')\n if (parts.length === 0 || (parts.length === 1 && parts[0] === '')) return null\n return `${accessor}?.['${`${parts.join(\"']?.['\")}']`}`\n}\n","import { memoize } from '@internals/utils'\nimport type { OperationNode, SchemaNode } from '../nodes/index.ts'\nimport { collect, collectLazy } from '../visitor.ts'\nimport { resolveRefName } from './refs.ts'\n\n/**\n * Memoized inner pass that walks a single node and returns the names of every schema it references.\n */\nconst collectSchemaRefs = memoize(new WeakMap<SchemaNode, ReadonlySet<string>>(), (node: SchemaNode): ReadonlySet<string> => {\n const refs = new Set<string>()\n collect<void>(node, {\n schema(child) {\n if (child.type === 'ref') {\n const name = resolveRefName(child)\n if (name) refs.add(name)\n }\n },\n })\n return refs\n})\n\n/**\n * Collects the names of every ref found anywhere inside a node's own subtree.\n *\n * Each ref contributes its name only, so the schema it points to is never traversed here. Pass `out`\n * to accumulate names from several nodes into one set.\n *\n * @example Collect refs from a single schema\n * ```ts\n * const names = collectReferencedSchemaNames(petSchema)\n * // Set { 'Category', 'Tag' }\n * ```\n *\n * @example Accumulate refs from multiple schemas into one set\n * ```ts\n * const out = new Set<string>()\n * for (const schema of schemas) {\n * collectReferencedSchemaNames(schema, out)\n * }\n * ```\n */\nexport function collectReferencedSchemaNames(node: SchemaNode | undefined, out: Set<string> = new Set()): Set<string> {\n if (!node) return out\n for (const name of collectSchemaRefs(node)) out.add(name)\n return out\n}\n\n/**\n * Memoized two-level cache keyed first on the operations array, then on the schemas array.\n */\nconst collectUsedSchemaNamesMemo = memoize(new WeakMap<ReadonlyArray<OperationNode>, (schemas: ReadonlyArray<SchemaNode>) => Set<string>>(), (ops) =>\n memoize(new WeakMap<ReadonlyArray<SchemaNode>, Set<string>>(), (schemas) => computeUsedSchemaNames(ops, schemas)),\n)\n\nfunction computeUsedSchemaNames(operations: ReadonlyArray<OperationNode>, schemas: ReadonlyArray<SchemaNode>): Set<string> {\n const schemaMap = new Map<string, SchemaNode>()\n for (const schema of schemas) {\n if (schema.name) schemaMap.set(schema.name, schema)\n }\n\n const result = new Set<string>()\n\n function visitSchema(schema: SchemaNode): void {\n const directRefs = collectReferencedSchemaNames(schema)\n for (const name of directRefs) {\n if (!result.has(name)) {\n result.add(name)\n const namedSchema = schemaMap.get(name)\n if (namedSchema) visitSchema(namedSchema)\n }\n }\n }\n\n for (const op of operations) {\n for (const schema of collectLazy<SchemaNode>(op, { depth: 'shallow', schema: (node) => node })) {\n visitSchema(schema)\n }\n }\n\n return result\n}\n\n/**\n * Collects the names of all top-level schemas transitively used by a set of operations.\n *\n * An operation uses a schema when its parameters, request body, or responses reference it, directly\n * or through other named schemas. Once a name is added to the result it is not revisited, so\n * reference cycles terminate.\n *\n * Pair it with `include` filters so schemas reachable only from excluded operations stay ungenerated.\n *\n * @example Only generate schemas referenced by included operations\n * ```ts\n * const includedOps = operations.filter((op) => resolver.resolveOptions(op, { options, include }) !== null)\n * const allowed = collectUsedSchemaNames(includedOps, schemas)\n *\n * for (const schema of schemas) {\n * if (schema.name && !allowed.has(schema.name)) continue\n * // generate schema\n * }\n * ```\n */\nexport function collectUsedSchemaNames(operations: ReadonlyArray<OperationNode>, schemas: ReadonlyArray<SchemaNode>): Set<string> {\n return collectUsedSchemaNamesMemo(operations)(schemas)\n}\n\nconst EMPTY_CIRCULAR_SET = new Set<string>()\n\nconst findCircularSchemasMemo = memoize(new WeakMap<ReadonlyArray<SchemaNode>, Set<string>>(), (schemas: ReadonlyArray<SchemaNode>): Set<string> => {\n const graph = new Map<string, Set<string>>()\n\n for (const schema of schemas) {\n if (!schema.name) continue\n graph.set(schema.name, collectReferencedSchemaNames(schema))\n }\n\n const circular = new Set<string>()\n for (const start of graph.keys()) {\n const visited = new Set<string>()\n const stack: Array<string> = [...(graph.get(start) ?? [])]\n while (stack.length > 0) {\n const node = stack.pop()!\n if (node === start) {\n circular.add(start)\n break\n }\n if (visited.has(node)) continue\n visited.add(node)\n\n const next = graph.get(node)\n if (next) for (const r of next) stack.push(r)\n }\n }\n\n return circular\n})\n\n/**\n * Finds every schema that takes part in a circular dependency chain, including direct self-loops.\n *\n * Wrap the returned schema positions in a deferred construct (a lazy getter or `z.lazy(() => …)`) so\n * the generated code does not recurse forever. Refs are followed by name only, so the walk stays\n * linear in the size of the schema graph.\n *\n * @note Call this once on the full graph, then check individual schemas with `containsCircularRef()`.\n */\nexport function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string> {\n if (schemas.length === 0) return EMPTY_CIRCULAR_SET\n return findCircularSchemasMemo(schemas)\n}\n\n/**\n * Returns `true` when a schema, or anything nested inside it, references a circular schema.\n *\n * Pass `excludeName` to skip refs to a specific schema, which helps when self-references are handled\n * on their own. Pair it with `findCircularSchemas()` to decide where lazy wrappers go.\n *\n * @note Stops at the first matching circular ref.\n */\nexport function containsCircularRef(\n node: SchemaNode | undefined,\n { circularSchemas, excludeName }: { circularSchemas: ReadonlySet<string>; excludeName?: string },\n): boolean {\n if (!node || circularSchemas.size === 0) return false\n\n for (const _ of collectLazy<true>(node, {\n schema(child) {\n if (child.type !== 'ref') return null\n const name = resolveRefName(child)\n return name && name !== excludeName && circularSchemas.has(name) ? true : null\n },\n })) {\n return true\n }\n\n return false\n}\n","import type { ArraySchemaNode, IntersectionSchemaNode, ObjectSchemaNode, PropertyNode, SchemaNode, UnionSchemaNode } from '../nodes/index.ts'\nimport { objectKey } from './codegen.ts'\n\n/**\n * Converts a child schema to printer output. Plugins instantiate it with their own output type:\n * `string` for the zod and faker printers, `ts.TypeNode` for the TypeScript printer. A printer's\n * `this.transform` fits directly, so its `null` for an empty result carries through to `output`.\n */\nexport type SchemaTransform<TOutput> = (schema: SchemaNode) => TOutput\n\n/**\n * A union or intersection member, or an array or tuple item, paired with its transformed output.\n */\nexport type MappedSchema<TOutput> = {\n /**\n * The original child schema, kept so the printer can read its metadata for leaf formatting.\n */\n schema: SchemaNode\n /**\n * The child schema after being run through the transform.\n */\n output: TOutput\n}\n\n/**\n * An object property paired with its transformed output.\n */\nexport type MappedProperty<TOutput> = {\n /**\n * The property name as written on the schema, before any identifier quoting.\n */\n name: string\n /**\n * The original property node, kept so the printer can read `required`, `schema`, and metadata.\n */\n property: PropertyNode\n /**\n * The property schema after being run through the transform.\n */\n output: TOutput\n}\n\n/**\n * Maps each property of an object schema to its transformed output. Pairs every result with the\n * original property so the printer keeps full control over modifiers, getters, and key syntax.\n *\n * @example\n * ```ts\n * const entries = mapSchemaProperties(node, (schema) => this.transform(schema))\n * // entries: [{ name: 'id', property, output: 'z.number()' }, ...]\n * ```\n */\nexport function mapSchemaProperties<TOutput>(node: ObjectSchemaNode, transform: SchemaTransform<TOutput>): Array<MappedProperty<TOutput>> {\n return node.properties.map((property) => ({ name: property.name, property, output: transform(property.schema) }))\n}\n\n/**\n * Maps each member of a union or intersection schema to its transformed output, pairing every\n * result with the original member.\n */\nexport function mapSchemaMembers<TOutput>(node: UnionSchemaNode | IntersectionSchemaNode, transform: SchemaTransform<TOutput>): Array<MappedSchema<TOutput>> {\n return (node.members ?? []).map((schema) => ({ schema, output: transform(schema) }))\n}\n\n/**\n * Maps each item of an array or tuple schema to its transformed output, pairing every result with\n * the original item.\n */\nexport function mapSchemaItems<TOutput>(node: ArraySchemaNode, transform: SchemaTransform<TOutput>): Array<MappedSchema<TOutput>> {\n return (node.items ?? []).map((schema) => ({ schema, output: transform(schema) }))\n}\n\n/**\n * Emits a lazy getter for a circular-ref property position, `get name() { return body }`. The key\n * is quoted only when it is not a valid identifier. Used by the string printers to defer evaluation\n * of a recursive schema until first access.\n *\n * @example\n * ```ts\n * lazyGetter({ name: 'parent', body: 'z.lazy(() => Pet)' })\n * // \"get parent() { return z.lazy(() => Pet) }\"\n * ```\n */\nexport function lazyGetter({ name, body }: { name: string; body: string }): string {\n return `get ${objectKey(name)}() { return ${body} }`\n}\n","import { camelCase, isValidVarName, memoize } from '@internals/utils'\nimport { createFunctionParameter, createFunctionParameters, createIndexedAccessType, createTypeLiteral } from '../nodes/function.ts'\nimport type { FunctionParameterNode, FunctionParametersNode, OperationNode, ParameterNode, TypeExpression, TypeLiteralNode } from '../nodes/index.ts'\nimport { resolveGroupType } from './refs.ts'\n\nconst caseParamsMemo = memoize(new WeakMap<Array<ParameterNode>, (casing: string) => Array<ParameterNode>>(), (params) =>\n memoize(new Map<string, Array<ParameterNode>>(), (casing: string) =>\n params.map((param) => {\n const transformed = casing === 'camelcase' || !isValidVarName(param.name) ? camelCase(param.name) : param.name\n return { ...param, name: transformed }\n }),\n ),\n)\n\n/**\n * Applies casing rules to parameter names and returns a new array without mutating the input.\n *\n * Run it before handing parameters to schema builders so output property keys get the right casing\n * while `OperationNode.parameters` stays intact for other consumers. When `casing` is unset, the\n * original array is returned unchanged.\n */\nexport function caseParams(params: Array<ParameterNode>, casing: 'camelcase' | undefined): Array<ParameterNode> {\n if (!casing) return params\n return caseParamsMemo(params)(casing)\n}\n\n/**\n * Named type for a group of parameters (query or header) emitted as a single typed parameter.\n */\nexport type ParamGroupType = {\n /**\n * Type expression for the group, a plain group-name reference.\n */\n type: TypeExpression\n /**\n * Whether the parameter group is optional.\n */\n optional: boolean\n}\n\n/**\n * A single member of a destructured parameter group, fed to `createFunctionParameter({ properties })`.\n */\ntype GroupProperty = {\n name: string\n type: TypeExpression\n optional?: boolean\n}\n\n/**\n * Resolver interface for {@link createOperationParams}.\n *\n * `ResolverTs` from `@kubb/plugin-ts` satisfies this interface and can be passed directly.\n */\nexport type OperationParamsResolver = {\n /**\n * Resolves the type name for an individual parameter.\n *\n * @example Individual path parameter name\n * `resolver.resolveParamName(node, param) // → 'DeletePetPathPetId'`\n */\n resolveParamName(node: OperationNode, param: ParameterNode): string\n /**\n * Resolves the request body type name.\n *\n * @example Request body type name\n * `resolver.resolveDataName(node) // → 'CreatePetData'`\n */\n resolveDataName(node: OperationNode): string\n /**\n * Resolves the grouped path parameters type name.\n * When the return value equals `resolveParamName`, no indexed access is emitted.\n *\n * @example Grouped path params type name\n * `resolver.resolvePathParamsName(node, param) // → 'DeletePetPathParams'`\n */\n resolvePathParamsName(node: OperationNode, param: ParameterNode): string\n /**\n * Resolves the grouped query parameters type name.\n * When the return value equals `resolveParamName`, an inline struct type is emitted instead.\n *\n * @example Grouped query params type name\n * `resolver.resolveQueryParamsName(node, param) // → 'FindPetsByStatusQueryParams'`\n */\n resolveQueryParamsName(node: OperationNode, param: ParameterNode): string\n /**\n * Resolves the grouped header parameters type name.\n * When the return value equals `resolveParamName`, an inline struct type is emitted instead.\n *\n * @example Grouped header params type name\n * `resolver.resolveHeaderParamsName(node, param) // → 'DeletePetHeaderParams'`\n */\n resolveHeaderParamsName(node: OperationNode, param: ParameterNode): string\n}\n\n/**\n * Options for {@link createOperationParams}.\n */\nexport type CreateOperationParamsOptions = {\n /**\n * How all operation parameters are grouped in the function signature.\n * - `'object'` wraps all params into a single destructured object `{ petId, data, params }`\n * - `'inline'` emits each param category as a separate top-level parameter\n */\n paramsType: 'object' | 'inline'\n /**\n * How path parameters are emitted when `paramsType` is `'inline'`.\n * - `'object'` groups them as `{ petId, storeId }: PathParams`\n * - `'inline'` spreads them as individual parameters `petId: string, storeId: string`\n * - `'inlineSpread'` emits a single rest parameter `...pathParams: PathParams`\n */\n pathParamsType: 'object' | 'inline' | 'inlineSpread'\n /**\n * Converts parameter names to camelCase before output.\n */\n paramsCasing?: 'camelcase'\n /**\n * Resolver for parameter and request body type names.\n * Pass `ResolverTs` from `@kubb/plugin-ts` directly.\n * When omitted, falls back to the schema primitive or `'unknown'`.\n */\n resolver?: OperationParamsResolver\n /**\n * Default value for the path parameters binding when `pathParamsType` is `'object'`.\n * Falls back to `'{}'` when all path params are optional.\n */\n pathParamsDefault?: string\n /**\n * Extra parameters appended after the standard operation parameters.\n *\n * @example Plugin-specific trailing parameter\n * ```ts\n * extraParams: [createFunctionParameter({ name: 'options', type: 'Partial<RequestOptions>', default: '{}' })]\n * ```\n */\n extraParams?: Array<FunctionParameterNode>\n /**\n * Override the default parameter names used for body, query, header, and rest-path groups.\n *\n * Useful when targeting languages or frameworks with different naming conventions.\n *\n * @default { data: 'data', params: 'params', headers: 'headers', path: 'pathParams' }\n */\n paramNames?: {\n /**\n * Name for the request body parameter.\n * @default 'data'\n */\n data?: string\n /**\n * Name for the query parameters group parameter.\n * @default 'params'\n */\n params?: string\n /**\n * Name for the header parameters group parameter.\n * @default 'headers'\n */\n headers?: string\n /**\n * Name for the rest path-parameters parameter when `pathParamsType` is `'inlineSpread'`.\n * @default 'pathParams'\n */\n path?: string\n }\n /**\n * Transforms every resolved type name before it lands in a parameter node, for framework-level\n * type wrappers.\n *\n * @example Vue Query, wrap every parameter type with `MaybeRefOrGetter`\n * `typeWrapper: (t) => \\`MaybeRefOrGetter<${t}>\\``\n */\n typeWrapper?: (type: string) => string\n}\n\n/**\n * Resolves the {@link TypeExpression} for an individual parameter.\n *\n * Without a resolver, it falls back to the schema primitive (a plain type-name string). When the\n * parameter belongs to a named group, it emits an {@link IndexedAccessTypeNode} like\n * `GroupParams['petId']`, otherwise the resolved individual name.\n */\nexport function resolveParamType({\n node,\n param,\n resolver,\n}: {\n node: OperationNode\n param: ParameterNode\n resolver: OperationParamsResolver | undefined\n}): TypeExpression {\n if (!resolver) {\n return param.schema.primitive ?? 'unknown'\n }\n\n const individualName = resolver.resolveParamName(node, param)\n\n const groupLocation = param.in === 'path' || param.in === 'query' || param.in === 'header' ? param.in : undefined\n\n const groupResolvers = {\n path: resolver.resolvePathParamsName,\n query: resolver.resolveQueryParamsName,\n header: resolver.resolveHeaderParamsName,\n } as const\n\n const groupName = groupLocation ? groupResolvers[groupLocation].call(resolver, node, param) : undefined\n\n if (groupName && groupName !== individualName) {\n return createIndexedAccessType({ target: groupName, key: param.name })\n }\n\n return individualName\n}\n\n/**\n * Converts an `OperationNode` into function parameters for code generation.\n *\n * Centralizes parameter grouping logic for all plugins. `paramsType` chooses between one\n * destructured object parameter (`object`) and separate top-level parameters (`inline`), while\n * `pathParamsType` controls how path params render in inline mode. Provide a `resolver` for type\n * name resolution and `extraParams` for plugin-specific trailing parameters such as an `options` object.\n */\nexport function createOperationParams(node: OperationNode, options: CreateOperationParamsOptions): FunctionParametersNode {\n const { paramsType, pathParamsType, paramsCasing, resolver, pathParamsDefault, extraParams = [], paramNames, typeWrapper } = options\n\n const dataName = paramNames?.data ?? 'data'\n const paramsName = paramNames?.params ?? 'params'\n const headersName = paramNames?.headers ?? 'headers'\n const pathName = paramNames?.path ?? 'pathParams'\n\n const wrapType = (type: string): string => (typeWrapper ? typeWrapper(type) : type)\n // typeWrapper takes a type-name string, so only plain references are wrapped.\n // TypeLiteral and IndexedAccessType expressions are pre-resolved and pass through unchanged.\n const wrapTypeExpression = (type: TypeExpression): TypeExpression => (typeof type === 'string' ? wrapType(type) : type)\n\n const casedParams = caseParams(node.parameters, paramsCasing)\n const pathParams = casedParams.filter((p) => p.in === 'path')\n const queryParams = casedParams.filter((p) => p.in === 'query')\n const headerParams = casedParams.filter((p) => p.in === 'header')\n\n const toProperty = (param: ParameterNode): GroupProperty => ({\n name: param.name,\n type: wrapTypeExpression(resolveParamType({ node, param, resolver })),\n optional: !param.required,\n })\n const emptyObjectDefault = (props: Array<GroupProperty>): string | undefined => (props.every((p) => p.optional) ? '{}' : undefined)\n\n const bodyType = node.requestBody?.content?.[0]?.schema ? wrapType(resolver?.resolveDataName(node) ?? 'unknown') : undefined\n const bodyProperty: Array<GroupProperty> = bodyType ? [{ name: dataName, type: bodyType, optional: !(node.requestBody?.required ?? false) }] : []\n\n const trailingGroups: Array<BuildGroupArgs> = [\n { name: paramsName, node, params: queryParams, groupType: resolveGroupType({ node, params: queryParams, group: 'query', resolver }), resolver, wrapType },\n {\n name: headersName,\n node,\n params: headerParams,\n groupType: resolveGroupType({ node, params: headerParams, group: 'header', resolver }),\n resolver,\n wrapType,\n },\n ]\n\n const params: Array<FunctionParameterNode> = []\n\n if (paramsType === 'object') {\n const children = [...pathParams.map(toProperty), ...bodyProperty, ...trailingGroups.flatMap(buildGroupProperty)]\n if (children.length) {\n params.push(createFunctionParameter({ properties: children, default: emptyObjectDefault(children) }))\n }\n } else {\n if (pathParamsType === 'inlineSpread' && pathParams.length) {\n const spreadType = resolver?.resolvePathParamsName(node, pathParams[0]!)\n params.push(createFunctionParameter({ name: pathName, type: spreadType ? wrapType(spreadType) : undefined, rest: true }))\n } else if (pathParamsType === 'inline') {\n params.push(...pathParams.map((p) => createFunctionParameter(toProperty(p))))\n } else if (pathParams.length) {\n const pathChildren = pathParams.map(toProperty)\n params.push(createFunctionParameter({ properties: pathChildren, default: pathParamsDefault ?? emptyObjectDefault(pathChildren) }))\n }\n\n params.push(...bodyProperty.map((p) => createFunctionParameter(p)))\n params.push(...trailingGroups.flatMap(buildGroupParam))\n }\n\n params.push(...extraParams)\n\n return createFunctionParameters({ params })\n}\n\n/**\n * Shared arguments for building a query or header parameter group.\n */\nexport type BuildGroupArgs = {\n name: string\n node: OperationNode\n params: Array<ParameterNode>\n groupType: ParamGroupType | null\n resolver: OperationParamsResolver | undefined\n wrapType: (type: string) => string\n}\n\n/**\n * Builds the property descriptor for a query or header group.\n * Returns an empty array when there are no params to emit.\n *\n * A pre-resolved `groupType` emits `name: GroupType`. Otherwise it builds an inline\n * {@link TypeLiteralNode} from the individual params.\n */\nfunction buildGroupProperty({ name, node, params, groupType, resolver, wrapType }: BuildGroupArgs): Array<GroupProperty> {\n if (groupType) {\n const type = typeof groupType.type === 'string' ? wrapType(groupType.type) : groupType.type\n return [{ name, type, optional: groupType.optional }]\n }\n if (params.length) {\n return [{ name, type: buildTypeLiteral({ node, params, resolver }), optional: params.every((p) => !p.required) }]\n }\n return []\n}\n\n/**\n * Builds a single {@link FunctionParameterNode} for a query or header group.\n * Returns an empty array when there are no params to emit.\n *\n * A pre-resolved `groupType` emits `name: GroupType`. Otherwise it builds an inline\n * {@link TypeLiteralNode} from the individual params.\n */\nexport function buildGroupParam(args: BuildGroupArgs): Array<FunctionParameterNode> {\n return buildGroupProperty(args).map((p) => createFunctionParameter(p))\n}\n\n/**\n * Builds a {@link TypeLiteralNode} for an inline anonymous type grouping named fields.\n *\n * Used when query or header parameters have no dedicated group type name.\n * Each language printer renders this appropriately (TypeScript: `{ petId: string; name?: string }`).\n */\nexport function buildTypeLiteral({\n node,\n params,\n resolver,\n}: {\n node: OperationNode\n params: Array<ParameterNode>\n resolver: OperationParamsResolver | undefined\n}): TypeLiteralNode {\n return createTypeLiteral({\n members: params.map((p) => ({\n name: p.name,\n type: resolveParamType({ node, param: p, resolver }),\n optional: !p.required,\n })),\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiIA,SAAgB,QAAsB,OAA4B,SAAuD;CACvH,QAAQ,QAAsB;EAC5B,IAAI,MAAM,IAAI,GAAG,GAAG,OAAO,MAAM,IAAI,GAAG;EACxC,MAAM,QAAQ,QAAQ,GAAG;EACzB,MAAM,IAAI,KAAK,KAAK;EACpB,OAAO;CACT;AACF;;;;;;;ACpIA,MAAM,gBAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;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utils.cjs CHANGED
@@ -1,7 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_schema = require("./schema-BkvrrOAr.cjs");
3
- const require_refs = require("./refs-u5SDdyV7.cjs");
4
- const require_utils = require("./utils-CEepwqmb.cjs");
2
+ const require_refs = require("./refs-DDIY_Tpn.cjs");
3
+ const require_utils = require("./utils-DYhjlv0E.cjs");
5
4
  exports.buildGroupParam = require_utils.buildGroupParam;
6
5
  exports.buildJSDoc = require_utils.buildJSDoc;
7
6
  exports.buildList = require_utils.buildList;
@@ -14,7 +13,7 @@ exports.containsCircularRef = require_utils.containsCircularRef;
14
13
  exports.createOperationParams = require_utils.createOperationParams;
15
14
  exports.enumPropName = require_refs.enumPropName;
16
15
  exports.extractRefName = require_refs.extractRefName;
17
- exports.extractStringsFromNodes = require_schema.extractStringsFromNodes;
16
+ exports.extractStringsFromNodes = require_refs.extractStringsFromNodes;
18
17
  exports.findCircularSchemas = require_utils.findCircularSchemas;
19
18
  exports.getNestedAccessor = require_utils.getNestedAccessor;
20
19
  exports.isStringType = require_refs.isStringType;
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as __name } from "./rolldown-runtime-CNktS9qV.js";
2
- import { C as ParameterNode, Et as PropertyNode, Pt as CodeNode, St as UnionSchemaNode, _t as SchemaNode, f as OperationNode, ft as ObjectSchemaNode, ot as ArraySchemaNode, ut as IntersectionSchemaNode } from "./index-BKD4drsX.js";
3
- import { a as buildTypeLiteral, c as resolveParamType, i as buildGroupParam, n as OperationParamsResolver, o as caseParams, r as ParamGroupType, s as createOperationParams, t as BuildGroupArgs } from "./operationParams-ByVfpYr7.js";
2
+ import { C as ParameterNode, Et as PropertyNode, Pt as CodeNode, St as UnionSchemaNode, _t as SchemaNode, f as OperationNode, ft as ObjectSchemaNode, ot as ArraySchemaNode, ut as IntersectionSchemaNode } from "./index-CeJAFegf.js";
3
+ import { a as buildTypeLiteral, c as resolveParamType, i as buildGroupParam, n as OperationParamsResolver, o as caseParams, r as ParamGroupType, s as createOperationParams, t as BuildGroupArgs } from "./operationParams-DCY3q4C7.js";
4
4
 
5
5
  //#region ../../internals/utils/src/reserved.d.ts
6
6
  /**
package/dist/utils.js CHANGED
@@ -1,4 +1,3 @@
1
- import { a as resolveGroupType, i as isStringType, n as enumPropName, o as resolveRefName, r as extractRefName, s as syncSchemaRef, t as childName } from "./refs-Dx6U5LoE.js";
2
- import { I as extractStringsFromNodes } from "./schema-YNbOtTCM.js";
3
- import { C as objectKey, S as buildObject, _ as toRegExpString, a as resolveParamType, b as buildJSDoc, c as mapSchemaMembers, d as containsCircularRef, f as findCircularSchemas, g as stringifyObject, h as stringify, i as createOperationParams, l as mapSchemaProperties, m as jsStringEscape, n as buildTypeLiteral, o as lazyGetter, p as getNestedAccessor, r as caseParams, s as mapSchemaItems, t as buildGroupParam, u as collectUsedSchemaNames, v as trimQuotes, w as isValidVarName, x as buildList, y as mergeAdjacentObjectsLazy } from "./utils-BJi0y-xg.js";
1
+ import { J as extractStringsFromNodes, a as resolveGroupType, i as isStringType, n as enumPropName, o as resolveRefName, r as extractRefName, s as syncSchemaRef, t as childName } from "./refs-CXp6uOHL.js";
2
+ import { C as objectKey, S as buildObject, _ as toRegExpString, a as resolveParamType, b as buildJSDoc, c as mapSchemaMembers, d as containsCircularRef, f as findCircularSchemas, g as stringifyObject, h as stringify, i as createOperationParams, l as mapSchemaProperties, m as jsStringEscape, n as buildTypeLiteral, o as lazyGetter, p as getNestedAccessor, r as caseParams, s as mapSchemaItems, t as buildGroupParam, u as collectUsedSchemaNames, v as trimQuotes, w as isValidVarName, x as buildList, y as mergeAdjacentObjectsLazy } from "./utils-C2kwfetT.js";
4
3
  export { buildGroupParam, buildJSDoc, buildList, buildObject, buildTypeLiteral, caseParams, childName, collectUsedSchemaNames, containsCircularRef, createOperationParams, enumPropName, extractRefName, extractStringsFromNodes, findCircularSchemas, getNestedAccessor, isStringType, isValidVarName, jsStringEscape, lazyGetter, mapSchemaItems, mapSchemaMembers, mapSchemaProperties, mergeAdjacentObjectsLazy, objectKey, resolveGroupType, resolveParamType, resolveRefName, stringify, stringifyObject, syncSchemaRef, toRegExpString, trimQuotes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/ast",
3
- "version": "5.0.0-beta.64",
3
+ "version": "5.0.0-beta.66",
4
4
  "description": "Spec-agnostic AST layer for Kubb. Defines the node tree, visitor pattern, factory functions, and type guards used across all code generation plugins.",
5
5
  "keywords": [
6
6
  "ast",
@@ -30,10 +30,6 @@
30
30
  "import": "./dist/index.js",
31
31
  "require": "./dist/index.cjs"
32
32
  },
33
- "./factory": {
34
- "import": "./dist/factory.js",
35
- "require": "./dist/factory.cjs"
36
- },
37
33
  "./macros": {
38
34
  "import": "./dist/macros.js",
39
35
  "require": "./dist/macros.cjs"
@@ -1,27 +0,0 @@
1
- import { n as __name, t as __exportAll } from "./rolldown-runtime-CNktS9qV.js";
2
- import { F as createFunctionParameters, Gt as createBreak, I as createIndexedAccessType, J as UserFileNode, Jt as createJsx, Kt as createConst, L as createObjectBindingPattern, Ot as createProperty, P as createFunctionParameter, Q as createSource, R as createTypeLiteral, Wt as createArrowFunction, X as createFile, Xt as createType, Y as createExport, Yt as createText, Z as createImport, _ as createResponse, at as createContent, b as createRequestBody, p as createOperation, qt as createFunction, r as createOutput, s as createInput, t as Node, w as createParameter, wt as createSchema } from "./index-BKD4drsX.js";
3
-
4
- //#region src/factory.d.ts
5
- declare namespace factory_d_exports {
6
- export { UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createFunctionParameter, createFunctionParameters, createImport, createIndexedAccessType, createInput, createJsx, createObjectBindingPattern, createOperation, createOutput, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType, createTypeLiteral, update };
7
- }
8
- /**
9
- * Identity-preserving node update: returns `node` unchanged when every field in
10
- * `changes` already equals (by reference) the current value, otherwise a new node
11
- * with the changes applied.
12
- *
13
- * Mirrors the TypeScript compiler's `factory.updateX` contract. Pair it with the
14
- * structural sharing in {@link transform} so a no-op rewrite does not allocate and
15
- * downstream passes can detect "nothing changed" by identity. Comparison is shallow,
16
- * so a structurally equal but newly allocated array or object counts as a change.
17
- *
18
- * @example
19
- * ```ts
20
- * update(node, { name: node.name }) // -> same `node` reference
21
- * update(node, { name: 'renamed' }) // -> new node, `name` replaced
22
- * ```
23
- */
24
- declare function update<T extends Node>(node: T, changes: Partial<T>): T;
25
- //#endregion
26
- export { update as n, factory_d_exports as t };
27
- //# sourceMappingURL=factory-wJLzHeXT.d.ts.map
package/dist/factory.cjs DELETED
@@ -1,89 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_schema = require("./schema-BkvrrOAr.cjs");
3
- //#region src/factory.ts
4
- var factory_exports = /* @__PURE__ */ require_schema.__exportAll({
5
- createArrowFunction: () => require_schema.createArrowFunction,
6
- createBreak: () => require_schema.createBreak,
7
- createConst: () => require_schema.createConst,
8
- createContent: () => require_schema.createContent,
9
- createExport: () => require_schema.createExport,
10
- createFile: () => require_schema.createFile,
11
- createFunction: () => require_schema.createFunction,
12
- createFunctionParameter: () => require_schema.createFunctionParameter,
13
- createFunctionParameters: () => require_schema.createFunctionParameters,
14
- createImport: () => require_schema.createImport,
15
- createIndexedAccessType: () => require_schema.createIndexedAccessType,
16
- createInput: () => require_schema.createInput,
17
- createJsx: () => require_schema.createJsx,
18
- createObjectBindingPattern: () => require_schema.createObjectBindingPattern,
19
- createOperation: () => require_schema.createOperation,
20
- createOutput: () => require_schema.createOutput,
21
- createParameter: () => require_schema.createParameter,
22
- createProperty: () => require_schema.createProperty,
23
- createRequestBody: () => require_schema.createRequestBody,
24
- createResponse: () => require_schema.createResponse,
25
- createSchema: () => require_schema.createSchema,
26
- createSource: () => require_schema.createSource,
27
- createText: () => require_schema.createText,
28
- createType: () => require_schema.createType,
29
- createTypeLiteral: () => require_schema.createTypeLiteral,
30
- update: () => update
31
- });
32
- /**
33
- * Identity-preserving node update: returns `node` unchanged when every field in
34
- * `changes` already equals (by reference) the current value, otherwise a new node
35
- * with the changes applied.
36
- *
37
- * Mirrors the TypeScript compiler's `factory.updateX` contract. Pair it with the
38
- * structural sharing in {@link transform} so a no-op rewrite does not allocate and
39
- * downstream passes can detect "nothing changed" by identity. Comparison is shallow,
40
- * so a structurally equal but newly allocated array or object counts as a change.
41
- *
42
- * @example
43
- * ```ts
44
- * update(node, { name: node.name }) // -> same `node` reference
45
- * update(node, { name: 'renamed' }) // -> new node, `name` replaced
46
- * ```
47
- */
48
- function update(node, changes) {
49
- for (const key in changes) if (changes[key] !== node[key]) return {
50
- ...node,
51
- ...changes
52
- };
53
- return node;
54
- }
55
- //#endregion
56
- exports.createArrowFunction = require_schema.createArrowFunction;
57
- exports.createBreak = require_schema.createBreak;
58
- exports.createConst = require_schema.createConst;
59
- exports.createContent = require_schema.createContent;
60
- exports.createExport = require_schema.createExport;
61
- exports.createFile = require_schema.createFile;
62
- exports.createFunction = require_schema.createFunction;
63
- exports.createFunctionParameter = require_schema.createFunctionParameter;
64
- exports.createFunctionParameters = require_schema.createFunctionParameters;
65
- exports.createImport = require_schema.createImport;
66
- exports.createIndexedAccessType = require_schema.createIndexedAccessType;
67
- exports.createInput = require_schema.createInput;
68
- exports.createJsx = require_schema.createJsx;
69
- exports.createObjectBindingPattern = require_schema.createObjectBindingPattern;
70
- exports.createOperation = require_schema.createOperation;
71
- exports.createOutput = require_schema.createOutput;
72
- exports.createParameter = require_schema.createParameter;
73
- exports.createProperty = require_schema.createProperty;
74
- exports.createRequestBody = require_schema.createRequestBody;
75
- exports.createResponse = require_schema.createResponse;
76
- exports.createSchema = require_schema.createSchema;
77
- exports.createSource = require_schema.createSource;
78
- exports.createText = require_schema.createText;
79
- exports.createType = require_schema.createType;
80
- exports.createTypeLiteral = require_schema.createTypeLiteral;
81
- Object.defineProperty(exports, "factory_exports", {
82
- enumerable: true,
83
- get: function() {
84
- return factory_exports;
85
- }
86
- });
87
- exports.update = update;
88
-
89
- //# sourceMappingURL=factory.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory.cjs","names":[],"sources":["../src/factory.ts"],"sourcesContent":["import type { Node } from './nodes/index.ts'\n\n// Node constructors, grouped under the `factory` namespace the way the TypeScript compiler exposes\n// `ts.factory.createX`. Aggregating them here lets `export * as factory from './factory.ts'` in the\n// barrel surface every `createX` alongside the `createFile`/`update` helpers from a single module.\nexport { createArrowFunction, createBreak, createConst, createFunction, createJsx, createText, createType } from './nodes/code.ts'\nexport { createContent } from './nodes/content.ts'\nexport { createExport, createFile, createImport, createSource } from './nodes/file.ts'\nexport type { UserFileNode } from './nodes/file.ts'\nexport { createFunctionParameter, createFunctionParameters, createIndexedAccessType, createObjectBindingPattern, createTypeLiteral } from './nodes/function.ts'\nexport { createInput } from './nodes/input.ts'\nexport { createOperation } from './nodes/operation.ts'\nexport { createOutput } from './nodes/output.ts'\nexport { createParameter } from './nodes/parameter.ts'\nexport { createProperty } from './nodes/property.ts'\nexport { createRequestBody } from './nodes/requestBody.ts'\nexport { createResponse } from './nodes/response.ts'\nexport { createSchema } from './nodes/schema.ts'\n\n/**\n * Identity-preserving node update: returns `node` unchanged when every field in\n * `changes` already equals (by reference) the current value, otherwise a new node\n * with the changes applied.\n *\n * Mirrors the TypeScript compiler's `factory.updateX` contract. Pair it with the\n * structural sharing in {@link transform} so a no-op rewrite does not allocate and\n * downstream passes can detect \"nothing changed\" by identity. Comparison is shallow,\n * so a structurally equal but newly allocated array or object counts as a change.\n *\n * @example\n * ```ts\n * update(node, { name: node.name }) // -> same `node` reference\n * update(node, { name: 'renamed' }) // -> new node, `name` replaced\n * ```\n */\nexport function update<T extends Node>(node: T, changes: Partial<T>): T {\n for (const key in changes) {\n if (changes[key] !== node[key as keyof T]) {\n return { ...node, ...changes }\n }\n }\n\n return node\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,OAAuB,MAAS,SAAwB;CACtE,KAAK,MAAM,OAAO,SAChB,IAAI,QAAQ,SAAS,KAAK,MACxB,OAAO;EAAE,GAAG;EAAM,GAAG;CAAQ;CAIjC,OAAO;AACT"}
package/dist/factory.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { F as createFunctionParameters, Gt as createBreak, I as createIndexedAccessType, J as UserFileNode, Jt as createJsx, Kt as createConst, L as createObjectBindingPattern, Ot as createProperty, P as createFunctionParameter, Q as createSource, R as createTypeLiteral, Wt as createArrowFunction, X as createFile, Xt as createType, Y as createExport, Yt as createText, Z as createImport, _ as createResponse, at as createContent, b as createRequestBody, p as createOperation, qt as createFunction, r as createOutput, s as createInput, w as createParameter, wt as createSchema } from "./index-BKD4drsX.js";
2
- import { n as update } from "./factory-wJLzHeXT.js";
3
- export { type UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createFunctionParameter, createFunctionParameters, createImport, createIndexedAccessType, createInput, createJsx, createObjectBindingPattern, createOperation, createOutput, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType, createTypeLiteral, update };
package/dist/factory.js DELETED
@@ -1,58 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-CNktS9qV.js";
2
- import { A as createImport, B as createContent, G as createBreak, J as createJsx, K as createConst, O as createExport, S as createTypeLiteral, W as createArrowFunction, X as createType, Y as createText, a as createProperty, b as createIndexedAccessType, f as createOperation, g as createInput, j as createSource, k as createFile, m as createRequestBody, q as createFunction, r as createResponse, s as createParameter, t as createSchema, u as createOutput, v as createFunctionParameter, x as createObjectBindingPattern, y as createFunctionParameters } from "./schema-YNbOtTCM.js";
3
- //#region src/factory.ts
4
- var factory_exports = /* @__PURE__ */ __exportAll({
5
- createArrowFunction: () => createArrowFunction,
6
- createBreak: () => createBreak,
7
- createConst: () => createConst,
8
- createContent: () => createContent,
9
- createExport: () => createExport,
10
- createFile: () => createFile,
11
- createFunction: () => createFunction,
12
- createFunctionParameter: () => createFunctionParameter,
13
- createFunctionParameters: () => createFunctionParameters,
14
- createImport: () => createImport,
15
- createIndexedAccessType: () => createIndexedAccessType,
16
- createInput: () => createInput,
17
- createJsx: () => createJsx,
18
- createObjectBindingPattern: () => createObjectBindingPattern,
19
- createOperation: () => createOperation,
20
- createOutput: () => createOutput,
21
- createParameter: () => createParameter,
22
- createProperty: () => createProperty,
23
- createRequestBody: () => createRequestBody,
24
- createResponse: () => createResponse,
25
- createSchema: () => createSchema,
26
- createSource: () => createSource,
27
- createText: () => createText,
28
- createType: () => createType,
29
- createTypeLiteral: () => createTypeLiteral,
30
- update: () => update
31
- });
32
- /**
33
- * Identity-preserving node update: returns `node` unchanged when every field in
34
- * `changes` already equals (by reference) the current value, otherwise a new node
35
- * with the changes applied.
36
- *
37
- * Mirrors the TypeScript compiler's `factory.updateX` contract. Pair it with the
38
- * structural sharing in {@link transform} so a no-op rewrite does not allocate and
39
- * downstream passes can detect "nothing changed" by identity. Comparison is shallow,
40
- * so a structurally equal but newly allocated array or object counts as a change.
41
- *
42
- * @example
43
- * ```ts
44
- * update(node, { name: node.name }) // -> same `node` reference
45
- * update(node, { name: 'renamed' }) // -> new node, `name` replaced
46
- * ```
47
- */
48
- function update(node, changes) {
49
- for (const key in changes) if (changes[key] !== node[key]) return {
50
- ...node,
51
- ...changes
52
- };
53
- return node;
54
- }
55
- //#endregion
56
- export { createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createFunctionParameter, createFunctionParameters, createImport, createIndexedAccessType, createInput, createJsx, createObjectBindingPattern, createOperation, createOutput, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType, createTypeLiteral, factory_exports as t, update };
57
-
58
- //# sourceMappingURL=factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory.js","names":[],"sources":["../src/factory.ts"],"sourcesContent":["import type { Node } from './nodes/index.ts'\n\n// Node constructors, grouped under the `factory` namespace the way the TypeScript compiler exposes\n// `ts.factory.createX`. Aggregating them here lets `export * as factory from './factory.ts'` in the\n// barrel surface every `createX` alongside the `createFile`/`update` helpers from a single module.\nexport { createArrowFunction, createBreak, createConst, createFunction, createJsx, createText, createType } from './nodes/code.ts'\nexport { createContent } from './nodes/content.ts'\nexport { createExport, createFile, createImport, createSource } from './nodes/file.ts'\nexport type { UserFileNode } from './nodes/file.ts'\nexport { createFunctionParameter, createFunctionParameters, createIndexedAccessType, createObjectBindingPattern, createTypeLiteral } from './nodes/function.ts'\nexport { createInput } from './nodes/input.ts'\nexport { createOperation } from './nodes/operation.ts'\nexport { createOutput } from './nodes/output.ts'\nexport { createParameter } from './nodes/parameter.ts'\nexport { createProperty } from './nodes/property.ts'\nexport { createRequestBody } from './nodes/requestBody.ts'\nexport { createResponse } from './nodes/response.ts'\nexport { createSchema } from './nodes/schema.ts'\n\n/**\n * Identity-preserving node update: returns `node` unchanged when every field in\n * `changes` already equals (by reference) the current value, otherwise a new node\n * with the changes applied.\n *\n * Mirrors the TypeScript compiler's `factory.updateX` contract. Pair it with the\n * structural sharing in {@link transform} so a no-op rewrite does not allocate and\n * downstream passes can detect \"nothing changed\" by identity. Comparison is shallow,\n * so a structurally equal but newly allocated array or object counts as a change.\n *\n * @example\n * ```ts\n * update(node, { name: node.name }) // -> same `node` reference\n * update(node, { name: 'renamed' }) // -> new node, `name` replaced\n * ```\n */\nexport function update<T extends Node>(node: T, changes: Partial<T>): T {\n for (const key in changes) {\n if (changes[key] !== node[key as keyof T]) {\n return { ...node, ...changes }\n }\n }\n\n return node\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,OAAuB,MAAS,SAAwB;CACtE,KAAK,MAAM,OAAO,SAChB,IAAI,QAAQ,SAAS,KAAK,MACxB,OAAO;EAAE,GAAG;EAAM,GAAG;CAAQ;CAIjC,OAAO;AACT"}