@kubb/ast 5.0.0-beta.62 → 5.0.0-beta.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{defineMacro-Vw-xQvq7.d.ts → defineMacro-BATi7xoC.d.ts} +4 -5
- package/dist/{defineMacro-BryDiuQl.cjs → defineMacro-CEZHaCXE.cjs} +5 -5
- package/dist/defineMacro-CEZHaCXE.cjs.map +1 -0
- package/dist/{defineMacro-CNkUpxia.js → defineMacro-Shz8f6SG.js} +3 -3
- package/dist/defineMacro-Shz8f6SG.js.map +1 -0
- package/dist/factory.cjs +56 -56
- package/dist/factory.cjs.map +1 -1
- package/dist/factory.d.ts +5 -5
- package/dist/factory.js +5 -5
- package/dist/factory.js.map +1 -1
- package/dist/{index-CTaN_ee_.d.ts → index-B9cc8MBS.d.ts} +46 -113
- package/dist/index.cjs +142 -271
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +12 -5
- package/dist/index.js +108 -236
- package/dist/index.js.map +1 -1
- package/dist/macros.cjs +12 -12
- package/dist/macros.cjs.map +1 -1
- package/dist/macros.d.ts +2 -2
- package/dist/macros.js +4 -4
- package/dist/macros.js.map +1 -1
- package/dist/{operationParams-B44p6EQy.d.ts → operationParams-k5CKwSWZ.d.ts} +9 -2
- package/dist/{visitor-DepQEKyp.js → refs-BjNDuCBD.js} +115 -120
- package/dist/refs-BjNDuCBD.js.map +1 -0
- package/dist/{visitor-B7Zlnp4c.cjs → refs-u5SDdyV7.cjs} +139 -144
- package/dist/refs-u5SDdyV7.cjs.map +1 -0
- package/dist/{response-BeG6hq2D.cjs → schema-BkvrrOAr.cjs} +171 -153
- package/dist/schema-BkvrrOAr.cjs.map +1 -0
- package/dist/{response-Rd1uisM1.js → schema-Cbnxmz4b.js} +166 -154
- package/dist/schema-Cbnxmz4b.js.map +1 -0
- package/dist/{types-DQTgVSwE.d.ts → types-BB_xgRJ3.d.ts} +55 -79
- package/dist/types.d.ts +5 -5
- package/dist/{utils-BDI3kXlb.cjs → utils-CEepwqmb.cjs} +74 -67
- package/dist/utils-CEepwqmb.cjs.map +1 -0
- package/dist/{utils-DW9rnfsD.js → utils-DaXkewb1.js} +56 -49
- package/dist/utils-DaXkewb1.js.map +1 -0
- package/dist/utils.cjs +11 -11
- package/dist/utils.d.ts +44 -29
- package/dist/utils.js +3 -3
- package/package.json +1 -1
- package/src/constants.ts +3 -6
- package/src/defineMacro.ts +1 -1
- package/src/defineNode.ts +6 -9
- package/src/definePrinter.ts +5 -3
- package/src/dialect.ts +23 -13
- package/src/factory.ts +4 -4
- package/src/index.ts +1 -1
- package/src/infer.ts +1 -1
- package/src/macros/macroEnumName.ts +1 -1
- package/src/nodes/code.ts +8 -5
- package/src/nodes/file.ts +5 -4
- package/src/nodes/operation.ts +3 -0
- package/src/nodes/parameter.ts +5 -5
- package/src/nodes/property.ts +5 -5
- package/src/nodes/schema.ts +4 -4
- package/src/optionality.ts +15 -0
- package/src/types.ts +1 -2
- package/src/utils/codegen.ts +6 -7
- package/src/utils/fileMerge.ts +7 -8
- package/src/utils/operationParams.ts +8 -8
- package/src/utils/refs.ts +14 -18
- package/src/utils/schemaGraph.ts +41 -33
- package/src/utils/schemaMerge.ts +2 -2
- package/src/visitor.ts +1 -1
- package/dist/defineMacro-BryDiuQl.cjs.map +0 -1
- package/dist/defineMacro-CNkUpxia.js.map +0 -1
- package/dist/response-BeG6hq2D.cjs.map +0 -1
- package/dist/response-Rd1uisM1.js.map +0 -1
- package/dist/utils-BDI3kXlb.cjs.map +0 -1
- package/dist/utils-DW9rnfsD.js.map +0 -1
- package/dist/visitor-B7Zlnp4c.cjs.map +0 -1
- package/dist/visitor-DepQEKyp.js.map +0 -1
- package/src/dedupe.ts +0 -231
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-DaXkewb1.js","names":[],"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\n/** Returns `true` when `result` is a rejected `Promise.allSettled` result with a typed `reason`.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseRejectedResult<Error>).map((r) => r.reason.message)\n * ```\n */\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n return result.status === 'rejected'\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":";;;;;;;;;;;;;;;;;;;;;;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AAC,KAAK,MAAM,wBAAwB,CAAC,CAAC;AACvE;;;;;;;AAQA,SAAgB,iBAAiB,EAC/B,MACA,QACA,YAKkB;CAClB,OAAO,kBAAkB,EACvB,SAAS,OAAO,KAAK,OAAO;EAC1B,MAAM,EAAE;EACR,MAAM,iBAAiB;GAAE;GAAM,OAAO;GAAG;EAAS,CAAC;EACnD,UAAU,CAAC,EAAE;CACf,EAAE,EACJ,CAAC;AACH"}
|
package/dist/utils.cjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const require_utils = require("./utils-
|
|
2
|
+
const require_schema = require("./schema-BkvrrOAr.cjs");
|
|
3
|
+
const require_refs = require("./refs-u5SDdyV7.cjs");
|
|
4
|
+
const require_utils = require("./utils-CEepwqmb.cjs");
|
|
5
5
|
exports.buildGroupParam = require_utils.buildGroupParam;
|
|
6
6
|
exports.buildJSDoc = require_utils.buildJSDoc;
|
|
7
7
|
exports.buildList = require_utils.buildList;
|
|
8
8
|
exports.buildObject = require_utils.buildObject;
|
|
9
9
|
exports.buildTypeLiteral = require_utils.buildTypeLiteral;
|
|
10
10
|
exports.caseParams = require_utils.caseParams;
|
|
11
|
-
exports.childName =
|
|
11
|
+
exports.childName = require_refs.childName;
|
|
12
12
|
exports.collectUsedSchemaNames = require_utils.collectUsedSchemaNames;
|
|
13
13
|
exports.containsCircularRef = require_utils.containsCircularRef;
|
|
14
14
|
exports.createOperationParams = require_utils.createOperationParams;
|
|
15
|
-
exports.enumPropName =
|
|
16
|
-
exports.extractRefName =
|
|
17
|
-
exports.extractStringsFromNodes =
|
|
15
|
+
exports.enumPropName = require_refs.enumPropName;
|
|
16
|
+
exports.extractRefName = require_refs.extractRefName;
|
|
17
|
+
exports.extractStringsFromNodes = require_schema.extractStringsFromNodes;
|
|
18
18
|
exports.findCircularSchemas = require_utils.findCircularSchemas;
|
|
19
19
|
exports.getNestedAccessor = require_utils.getNestedAccessor;
|
|
20
|
-
exports.isStringType =
|
|
20
|
+
exports.isStringType = require_refs.isStringType;
|
|
21
21
|
exports.isValidVarName = require_utils.isValidVarName;
|
|
22
22
|
exports.jsStringEscape = require_utils.jsStringEscape;
|
|
23
23
|
exports.lazyGetter = require_utils.lazyGetter;
|
|
@@ -26,11 +26,11 @@ exports.mapSchemaMembers = require_utils.mapSchemaMembers;
|
|
|
26
26
|
exports.mapSchemaProperties = require_utils.mapSchemaProperties;
|
|
27
27
|
exports.mergeAdjacentObjectsLazy = require_utils.mergeAdjacentObjectsLazy;
|
|
28
28
|
exports.objectKey = require_utils.objectKey;
|
|
29
|
-
exports.resolveGroupType =
|
|
29
|
+
exports.resolveGroupType = require_refs.resolveGroupType;
|
|
30
30
|
exports.resolveParamType = require_utils.resolveParamType;
|
|
31
|
-
exports.resolveRefName =
|
|
31
|
+
exports.resolveRefName = require_refs.resolveRefName;
|
|
32
32
|
exports.stringify = require_utils.stringify;
|
|
33
33
|
exports.stringifyObject = require_utils.stringifyObject;
|
|
34
|
-
exports.syncSchemaRef =
|
|
34
|
+
exports.syncSchemaRef = require_refs.syncSchemaRef;
|
|
35
35
|
exports.toRegExpString = require_utils.toRegExpString;
|
|
36
36
|
exports.trimQuotes = require_utils.trimQuotes;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as __name } from "./chunk-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-
|
|
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-
|
|
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-B9cc8MBS.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-k5CKwSWZ.js";
|
|
4
4
|
|
|
5
5
|
//#region ../../internals/utils/src/reserved.d.ts
|
|
6
6
|
/**
|
|
@@ -17,8 +17,8 @@ declare function isValidVarName(name: string): boolean;
|
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/utils/codegen.d.ts
|
|
19
19
|
/**
|
|
20
|
-
* Builds a JSDoc comment block from an array of lines
|
|
21
|
-
* comments
|
|
20
|
+
* Builds a JSDoc comment block from an array of lines. Returns `fallback` when there are no
|
|
21
|
+
* comments.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* ```ts
|
|
@@ -56,9 +56,8 @@ declare function buildJSDoc(comments: Array<string>, options?: {
|
|
|
56
56
|
declare function objectKey(name: string): string;
|
|
57
57
|
/**
|
|
58
58
|
* Assembles a multi-line object literal from already-rendered `entries`, indenting each entry one
|
|
59
|
-
* level and closing the brace at column zero.
|
|
60
|
-
*
|
|
61
|
-
* formatter's multi-line style.
|
|
59
|
+
* level and closing the brace at column zero. Entries that are themselves multi-line objects indent
|
|
60
|
+
* cumulatively. Each entry ends with a trailing comma to match the formatter's multi-line style.
|
|
62
61
|
*
|
|
63
62
|
* @example
|
|
64
63
|
* ```ts
|
|
@@ -70,8 +69,8 @@ declare function buildObject(entries: Array<string>): string;
|
|
|
70
69
|
/**
|
|
71
70
|
* Assembles a bracketed list (array by default) from already-rendered `items`. Keeps everything on
|
|
72
71
|
* one line when no item spans multiple lines, and otherwise puts each item on its own line, indented
|
|
73
|
-
* one level with a trailing comma and the closing bracket at column zero.
|
|
74
|
-
* `z.
|
|
72
|
+
* one level with a trailing comma and the closing bracket at column zero. Used for member lists such
|
|
73
|
+
* as `z.union([…])` and `z.array([…])`.
|
|
75
74
|
*
|
|
76
75
|
* @example
|
|
77
76
|
* ```ts
|
|
@@ -95,32 +94,28 @@ declare function extractStringsFromNodes(nodes: Array<CodeNode> | undefined): st
|
|
|
95
94
|
* Returns the last path segment of a reference string.
|
|
96
95
|
*
|
|
97
96
|
* @example
|
|
98
|
-
*
|
|
99
|
-
* extractRefName('#/components/schemas/Pet') // 'Pet'
|
|
100
|
-
* ```
|
|
97
|
+
* `extractRefName('#/components/schemas/Pet') // 'Pet'`
|
|
101
98
|
*/
|
|
102
99
|
declare function extractRefName(ref: string): string;
|
|
103
100
|
/**
|
|
104
|
-
* Resolves the schema name of a ref node
|
|
101
|
+
* Resolves the schema name of a ref node. Uses the last segment of `ref` when set, otherwise falls
|
|
102
|
+
* back to `name` then nested `schema.name`.
|
|
105
103
|
*
|
|
106
104
|
* Returns `null` for non-ref nodes or when no name resolves.
|
|
107
105
|
*
|
|
108
106
|
* @example
|
|
109
|
-
*
|
|
110
|
-
* resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' })
|
|
111
|
-
* // => 'Pet'
|
|
112
|
-
* ```
|
|
107
|
+
* `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' }) // 'Pet'`
|
|
113
108
|
*/
|
|
114
109
|
declare function resolveRefName(node: SchemaNode | undefined): string | null;
|
|
115
110
|
/**
|
|
116
111
|
* Builds a PascalCase child schema name by joining a parent name and property name.
|
|
117
112
|
* Returns `null` when there is no parent to nest under.
|
|
118
113
|
*
|
|
119
|
-
* @example
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
114
|
+
* @example Nested under a parent
|
|
115
|
+
* `childName('Order', 'shipping_address') // 'OrderShippingAddress'`
|
|
116
|
+
*
|
|
117
|
+
* @example No parent
|
|
118
|
+
* `childName(undefined, 'params') // null`
|
|
124
119
|
*/
|
|
125
120
|
declare function childName(parentName: string | null | undefined, propName: string): string | null;
|
|
126
121
|
/**
|
|
@@ -128,16 +123,16 @@ declare function childName(parentName: string | null | undefined, propName: stri
|
|
|
128
123
|
* empty parts.
|
|
129
124
|
*
|
|
130
125
|
* @example
|
|
131
|
-
*
|
|
132
|
-
* enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'
|
|
133
|
-
* ```
|
|
126
|
+
* `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`
|
|
134
127
|
*/
|
|
135
128
|
declare function enumPropName(parentName: string | null | undefined, propName: string, enumSuffix: string): string;
|
|
136
129
|
/**
|
|
137
130
|
* Merges a ref node with its resolved schema, giving usage-site fields precedence.
|
|
138
131
|
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
132
|
+
* Every field set on the ref node except `kind`, `type`, `name`, `ref`, and `schema` overrides the
|
|
133
|
+
* same field in the resolved `node.schema` (for example `description`, `nullable`, `readOnly`,
|
|
134
|
+
* `deprecated`). Fields left `undefined` on the ref do not shadow the resolved schema. Non-ref
|
|
135
|
+
* nodes and refs without a resolved `schema` are returned unchanged.
|
|
141
136
|
*
|
|
142
137
|
* @example
|
|
143
138
|
* ```ts
|
|
@@ -174,8 +169,8 @@ declare function resolveGroupType({
|
|
|
174
169
|
//#region src/utils/schemaMerge.d.ts
|
|
175
170
|
/**
|
|
176
171
|
* Merges a run of adjacent anonymous object members into one. Named or non-object members break the
|
|
177
|
-
* run and pass through.
|
|
178
|
-
*
|
|
172
|
+
* run and pass through unchanged. The merge follows member order, so callers control which members
|
|
173
|
+
* combine by where they place them in the sequence.
|
|
179
174
|
*
|
|
180
175
|
* @example
|
|
181
176
|
* ```ts
|
|
@@ -258,6 +253,26 @@ declare function stringifyObject(value: Record<string, unknown>): string;
|
|
|
258
253
|
declare function getNestedAccessor(param: string | Array<string>, accessor: string): string | null;
|
|
259
254
|
//#endregion
|
|
260
255
|
//#region src/utils/schemaGraph.d.ts
|
|
256
|
+
/**
|
|
257
|
+
* Collects the names of all top-level schemas transitively used by a set of operations.
|
|
258
|
+
*
|
|
259
|
+
* An operation uses a schema when its parameters, request body, or responses reference it, directly
|
|
260
|
+
* or through other named schemas. Once a name is added to the result it is not revisited, so
|
|
261
|
+
* reference cycles terminate.
|
|
262
|
+
*
|
|
263
|
+
* Pair it with `include` filters so schemas reachable only from excluded operations stay ungenerated.
|
|
264
|
+
*
|
|
265
|
+
* @example Only generate schemas referenced by included operations
|
|
266
|
+
* ```ts
|
|
267
|
+
* const includedOps = operations.filter((op) => resolver.resolveOptions(op, { options, include }) !== null)
|
|
268
|
+
* const allowed = collectUsedSchemaNames(includedOps, schemas)
|
|
269
|
+
*
|
|
270
|
+
* for (const schema of schemas) {
|
|
271
|
+
* if (schema.name && !allowed.has(schema.name)) continue
|
|
272
|
+
* // generate schema
|
|
273
|
+
* }
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
261
276
|
declare function collectUsedSchemaNames(operations: ReadonlyArray<OperationNode>, schemas: ReadonlyArray<SchemaNode>): Set<string>;
|
|
262
277
|
/**
|
|
263
278
|
* Finds every schema that takes part in a circular dependency chain, including direct self-loops.
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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-
|
|
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-BjNDuCBD.js";
|
|
2
|
+
import { I as extractStringsFromNodes } from "./schema-Cbnxmz4b.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-DaXkewb1.js";
|
|
4
4
|
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.
|
|
3
|
+
"version": "5.0.0-beta.63",
|
|
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",
|
package/src/constants.ts
CHANGED
|
@@ -17,7 +17,6 @@ export const visitorDepths = {
|
|
|
17
17
|
* Schema type discriminators used by all AST schema nodes.
|
|
18
18
|
*
|
|
19
19
|
* Each value is a stable discriminator across the AST (for example `schema.type === schemaTypes.object`).
|
|
20
|
-
* Call `isScalarPrimitive()` to check for the scalar types.
|
|
21
20
|
*/
|
|
22
21
|
export const schemaTypes = {
|
|
23
22
|
/**
|
|
@@ -127,16 +126,14 @@ export const schemaTypes = {
|
|
|
127
126
|
} as const satisfies Record<SchemaType, SchemaType>
|
|
128
127
|
|
|
129
128
|
/**
|
|
130
|
-
* Default concurrency
|
|
131
|
-
*
|
|
132
|
-
* Set to 30 to balance I/O-bound resolver parallelism against event-loop and memory pressure
|
|
133
|
-
* during large spec traversals. Override it for different hardware constraints.
|
|
129
|
+
* Default sibling concurrency for `walk()`. Higher values overlap I/O-bound visitor work,
|
|
130
|
+
* lower values reduce memory pressure. Pass `concurrency` to `walk()` to override it.
|
|
134
131
|
*
|
|
135
132
|
* @example
|
|
136
133
|
* ```ts
|
|
137
134
|
* import { walk, WALK_CONCURRENCY } from '@kubb/ast'
|
|
138
135
|
*
|
|
139
|
-
* walk(root, { concurrency: WALK_CONCURRENCY,
|
|
136
|
+
* walk(root, { concurrency: WALK_CONCURRENCY, operation: () => {} })
|
|
140
137
|
* ```
|
|
141
138
|
*/
|
|
142
139
|
export const WALK_CONCURRENCY = 30
|
package/src/defineMacro.ts
CHANGED
|
@@ -29,7 +29,7 @@ function enforceWeight(enforce?: Enforce): number {
|
|
|
29
29
|
*/
|
|
30
30
|
export type Macro = Visitor & {
|
|
31
31
|
/**
|
|
32
|
-
* Macro identifier
|
|
32
|
+
* Macro identifier used to tell macros apart, for example `'simplify-union'`.
|
|
33
33
|
*/
|
|
34
34
|
name: string
|
|
35
35
|
/**
|
package/src/defineNode.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Dialect } from './dialect.ts'
|
|
2
1
|
import type { BaseNode, NodeKind } from './nodes/base.ts'
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -29,7 +28,7 @@ export type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omi
|
|
|
29
28
|
* Builds a type guard that matches nodes of the given `kind`.
|
|
30
29
|
*/
|
|
31
30
|
function isKind<T extends BaseNode>(kind: NodeKind) {
|
|
32
|
-
return (node: unknown): node is T => (node as BaseNode)
|
|
31
|
+
return (node: unknown): node is T => (node as BaseNode | undefined)?.kind === kind
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
/**
|
|
@@ -43,11 +42,9 @@ export type NodeDef<TNode extends BaseNode = BaseNode, TInput = never> = {
|
|
|
43
42
|
*/
|
|
44
43
|
kind: NodeKind
|
|
45
44
|
/**
|
|
46
|
-
* Builds a node from its input, applying `defaults` and the optional `build` hook.
|
|
47
|
-
* optional `dialect` is forwarded to `build` so nodes can derive spec-specific fields
|
|
48
|
-
* (e.g. a schema's `optional`/`nullish`) through `dialect.schema.optionality` when one is given.
|
|
45
|
+
* Builds a node from its input, applying `defaults` and the optional `build` hook.
|
|
49
46
|
*/
|
|
50
|
-
create: (input: TInput
|
|
47
|
+
create: (input: TInput) => TNode
|
|
51
48
|
/**
|
|
52
49
|
* Type guard matching this node kind.
|
|
53
50
|
*/
|
|
@@ -65,7 +62,7 @@ export type NodeDef<TNode extends BaseNode = BaseNode, TInput = never> = {
|
|
|
65
62
|
type DefineNodeConfig<TNode extends BaseNode, TInput, TBuilt extends object> = {
|
|
66
63
|
kind: TNode['kind']
|
|
67
64
|
defaults?: Partial<TNode>
|
|
68
|
-
build?: (input: TInput
|
|
65
|
+
build?: (input: TInput) => TBuilt
|
|
69
66
|
children?: ReadonlyArray<string>
|
|
70
67
|
visitorKey?: VisitorKey
|
|
71
68
|
}
|
|
@@ -96,8 +93,8 @@ export function defineNode<TNode extends BaseNode, TInput = Omit<TNode, 'kind'>,
|
|
|
96
93
|
): NodeDef<TNode, TInput> {
|
|
97
94
|
const { kind, defaults, build, children, visitorKey } = config
|
|
98
95
|
|
|
99
|
-
function create(input: TInput
|
|
100
|
-
const base = build ? build(input
|
|
96
|
+
function create(input: TInput): TNode {
|
|
97
|
+
const base = build ? build(input) : input
|
|
101
98
|
return { ...defaults, ...(base as object), kind } as TNode
|
|
102
99
|
}
|
|
103
100
|
|
package/src/definePrinter.ts
CHANGED
|
@@ -191,11 +191,13 @@ export function definePrinter<T extends PrinterFactoryOptions = PrinterFactoryOp
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
|
-
* Generic printer
|
|
194
|
+
* Generic printer factory behind `definePrinter`. Pass a `getKey` function that maps a node to its
|
|
195
|
+
* handler key, and it returns a `definePrinter`-style helper for that node and key type. `definePrinter`
|
|
196
|
+
* itself is this factory keyed by `node.type`.
|
|
195
197
|
*
|
|
196
|
-
* @example
|
|
198
|
+
* @example Key a printer by `node.kind` instead of `node.type`
|
|
197
199
|
* ```ts
|
|
198
|
-
*
|
|
200
|
+
* const defineFunctionPrinter = createPrinterFactory<FunctionParamNode, FunctionParamKind, Partial<Record<FunctionParamKind, FunctionParamNode>>>(
|
|
199
201
|
* (node) => node.kind,
|
|
200
202
|
* )
|
|
201
203
|
* ```
|
package/src/dialect.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Node } from './nodes/index.ts'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The spec-specific questions a schema parser answers while turning a source document into Kubb
|
|
@@ -26,20 +26,26 @@ export type SchemaDialect<TSchema = unknown, TRef = TSchema, TDiscriminated = TS
|
|
|
26
26
|
* Resolves a local `$ref` against the document, or nullish when it cannot.
|
|
27
27
|
*/
|
|
28
28
|
resolveRef<TResolved>(document: TDocument, ref: string): TResolved | null | undefined
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* How a dialect collapses structurally identical schemas into shared definitions. The contract is
|
|
33
|
+
* generic over the plan and context types, which the adapter supplies. The mechanics live in the
|
|
34
|
+
* adapter, not here, so `@kubb/ast` carries no dedupe logic. The returned plan owns the rewriting
|
|
35
|
+
* behavior, so callers interact with one object.
|
|
36
|
+
*/
|
|
37
|
+
export type Dedupe<TPlan = unknown, TContext = unknown> = {
|
|
29
38
|
/**
|
|
30
|
-
*
|
|
31
|
-
* schema's own `nullable`. How "required" and "nullable" combine is spec-specific, so the
|
|
32
|
-
* dialect owns it. Method syntax keeps a concrete dialect assignable to the base
|
|
33
|
-
* `SchemaDialect` (bivariant parameters).
|
|
39
|
+
* Scans a forest of nodes and produces a plan describing which shapes to share.
|
|
34
40
|
*/
|
|
35
|
-
|
|
41
|
+
plan(roots: ReadonlyArray<Node>, context: TContext): TPlan
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
/**
|
|
39
|
-
* A spec adapter's dialect. `name` identifies it in logs and diagnostics
|
|
40
|
-
* spec-specific schema questions the parser answers.
|
|
45
|
+
* A spec adapter's dialect. `name` identifies it in logs and diagnostics, `schema` holds the
|
|
46
|
+
* spec-specific schema questions the parser answers, and `dedupe` is the schema-sharing seam.
|
|
41
47
|
*/
|
|
42
|
-
export type Dialect<TSchema = unknown, TRef = TSchema, TDiscriminated = TSchema, TDocument = unknown> = {
|
|
48
|
+
export type Dialect<TSchema = unknown, TRef = TSchema, TDiscriminated = TSchema, TDocument = unknown, TDedupe extends Dedupe = Dedupe> = {
|
|
43
49
|
/**
|
|
44
50
|
* Identifies the dialect in logs and diagnostics.
|
|
45
51
|
*/
|
|
@@ -48,6 +54,10 @@ export type Dialect<TSchema = unknown, TRef = TSchema, TDiscriminated = TSchema,
|
|
|
48
54
|
* The spec-specific schema behavior. See {@link SchemaDialect}.
|
|
49
55
|
*/
|
|
50
56
|
schema: SchemaDialect<TSchema, TRef, TDiscriminated, TDocument>
|
|
57
|
+
/**
|
|
58
|
+
* The schema-sharing behavior. See {@link Dedupe}.
|
|
59
|
+
*/
|
|
60
|
+
dedupe: TDedupe
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
/**
|
|
@@ -64,13 +74,13 @@ export type Dialect<TSchema = unknown, TRef = TSchema, TDiscriminated = TSchema,
|
|
|
64
74
|
* isDiscriminator,
|
|
65
75
|
* isBinary: (schema) => schema.type === 'string' && schema.contentMediaType === 'application/octet-stream',
|
|
66
76
|
* resolveRef,
|
|
67
|
-
* optionality,
|
|
68
77
|
* },
|
|
78
|
+
* dedupe: { plan },
|
|
69
79
|
* })
|
|
70
80
|
* ```
|
|
71
81
|
*/
|
|
72
|
-
export function defineDialect<TSchema, TRef, TDiscriminated, TDocument>(
|
|
73
|
-
dialect: Dialect<TSchema, TRef, TDiscriminated, TDocument>,
|
|
74
|
-
): Dialect<TSchema, TRef, TDiscriminated, TDocument> {
|
|
82
|
+
export function defineDialect<TSchema, TRef, TDiscriminated, TDocument, TDedupe extends Dedupe>(
|
|
83
|
+
dialect: Dialect<TSchema, TRef, TDiscriminated, TDocument, TDedupe>,
|
|
84
|
+
): Dialect<TSchema, TRef, TDiscriminated, TDocument, TDedupe> {
|
|
75
85
|
return dialect
|
|
76
86
|
}
|
package/src/factory.ts
CHANGED
|
@@ -22,10 +22,10 @@ export { createSchema } from './nodes/schema.ts'
|
|
|
22
22
|
* `changes` already equals (by reference) the current value, otherwise a new node
|
|
23
23
|
* with the changes applied.
|
|
24
24
|
*
|
|
25
|
-
* Mirrors the TypeScript compiler's `factory.updateX` contract
|
|
26
|
-
* structural sharing in {@link transform} so a no-op rewrite
|
|
27
|
-
* downstream passes can detect "nothing changed" by identity. Comparison is
|
|
28
|
-
*
|
|
25
|
+
* Mirrors the TypeScript compiler's `factory.updateX` contract. Pair it with the
|
|
26
|
+
* structural sharing in {@link transform} so a no-op rewrite does not allocate and
|
|
27
|
+
* downstream passes can detect "nothing changed" by identity. Comparison is shallow,
|
|
28
|
+
* so a structurally equal but newly allocated array or object counts as a change.
|
|
29
29
|
*
|
|
30
30
|
* @example
|
|
31
31
|
* ```ts
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { schemaTypes } from './constants.ts'
|
|
2
|
-
export { applyDedupe, buildDedupePlan } from './dedupe.ts'
|
|
3
2
|
export { defineDialect } from './dialect.ts'
|
|
4
3
|
export { isHttpOperationNode, narrowSchema } from './guards.ts'
|
|
5
4
|
export { applyMacros, composeMacros, defineMacro } from './defineMacro.ts'
|
|
6
5
|
export { defineNode } from './defineNode.ts'
|
|
6
|
+
export { optionality } from './optionality.ts'
|
|
7
7
|
export { createPrinterFactory, definePrinter } from './definePrinter.ts'
|
|
8
8
|
export { signatureOf } from './signature.ts'
|
|
9
9
|
export { collect, transform, walk } from './visitor.ts'
|
package/src/infer.ts
CHANGED
|
@@ -10,7 +10,7 @@ type Props = {
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Builds a macro that names an inline enum schema from its parent and property name. Boolean enums
|
|
13
|
-
* are left anonymous
|
|
13
|
+
* are left anonymous. Non-enum nodes are returned unchanged.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```ts
|
package/src/nodes/code.ts
CHANGED
|
@@ -116,7 +116,10 @@ export type FunctionNode = BaseNode & {
|
|
|
116
116
|
*/
|
|
117
117
|
default?: boolean | null
|
|
118
118
|
/**
|
|
119
|
-
* Function parameter list
|
|
119
|
+
* Function parameter list as a pre-rendered string, written verbatim between the parentheses.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* `'id: string, config: Config = {}'`
|
|
120
123
|
*/
|
|
121
124
|
params?: string | null
|
|
122
125
|
/**
|
|
@@ -193,16 +196,16 @@ export type TextNode = BaseNode & {
|
|
|
193
196
|
}
|
|
194
197
|
|
|
195
198
|
/**
|
|
196
|
-
* AST node representing a line
|
|
199
|
+
* AST node representing a blank line in the source output.
|
|
197
200
|
*
|
|
198
|
-
* Corresponds to `<br/>` in JSX components.
|
|
199
|
-
*
|
|
201
|
+
* Corresponds to `<br/>` in JSX components. `printNodes` turns a `Break` between two
|
|
202
|
+
* statements into one blank line. Consecutive breaks, and breaks at the start or end of
|
|
203
|
+
* the list, are folded away, so a `Break` never produces more than one blank line.
|
|
200
204
|
*
|
|
201
205
|
* @example
|
|
202
206
|
* ```ts
|
|
203
207
|
* createBreak()
|
|
204
208
|
* // { kind: 'Break' }
|
|
205
|
-
* // prints as '' → blank line when surrounded by other nodes
|
|
206
209
|
* ```
|
|
207
210
|
*/
|
|
208
211
|
export type BreakNode = BaseNode & {
|
package/src/nodes/file.ts
CHANGED
|
@@ -197,13 +197,14 @@ export type FileNode<TMeta extends object = object> = BaseNode & {
|
|
|
197
197
|
id: string
|
|
198
198
|
/**
|
|
199
199
|
* File name without extension, derived from `baseName`.
|
|
200
|
-
*
|
|
200
|
+
*
|
|
201
|
+
* @see https://nodejs.org/api/path.html#pathformatpathobject
|
|
201
202
|
*/
|
|
202
203
|
name: string
|
|
203
204
|
/**
|
|
204
|
-
* File base name, including extension
|
|
205
|
-
*
|
|
206
|
-
* @
|
|
205
|
+
* File base name, including extension, shaped like `${name}${extname}`.
|
|
206
|
+
*
|
|
207
|
+
* @see https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
207
208
|
*/
|
|
208
209
|
baseName: `${string}.${string}`
|
|
209
210
|
/**
|