@kubb/ast 5.28.6 → 5.29.0
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/README.md +19 -10
- package/dist/factory.cjs +6 -6
- package/dist/factory.d.cts +2 -2
- package/dist/factory.d.ts +2 -2
- package/dist/factory.js +2 -2
- package/dist/{combineFileMembers-B-mdjXrG.js → file-AcKQt60j.js} +137 -123
- package/dist/file-AcKQt60j.js.map +1 -0
- package/dist/{file-DJqd2j3y.d.cts → file-CLh8vdcR.d.cts} +20 -29
- package/dist/{file-lssk85C8.cjs → file-DVw2Htda.cjs} +13 -13
- package/dist/{file-lssk85C8.cjs.map → file-DVw2Htda.cjs.map} +1 -1
- package/dist/{combineFileMembers-DZCKxAN0.cjs → file-Db_PYobC.cjs} +136 -122
- package/dist/file-Db_PYobC.cjs.map +1 -0
- package/dist/{file-Dg70hXm3.d.ts → file-VRwu7Set.d.ts} +20 -29
- package/dist/{file-CO9KnOvT.js → file-pjdyWLJ0.js} +2 -2
- package/dist/{file-CO9KnOvT.js.map → file-pjdyWLJ0.js.map} +1 -1
- package/dist/file.cjs +6 -6
- package/dist/file.d.cts +1 -1
- package/dist/file.d.ts +1 -1
- package/dist/file.js +2 -2
- package/dist/{graph-DWlCmvm6.js → graph-Cu2-NiKi.js} +78 -15
- package/dist/graph-Cu2-NiKi.js.map +1 -0
- package/dist/{graph-D6Ffy9YD.cjs → graph-CymJtC1M.cjs} +78 -15
- package/dist/graph-CymJtC1M.cjs.map +1 -0
- package/dist/graph.cjs +1 -1
- package/dist/graph.d.cts +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/graph.js +1 -1
- package/dist/{index-BGhhO3z8.d.ts → index-B4DY8ewx.d.ts} +2 -2
- package/dist/{index-DjwCRndP.d.ts → index-BEvWuiSq.d.ts} +1 -1
- package/dist/{index-DphKh9u9.d.ts → index-BXHrCLGe.d.ts} +1 -1
- package/dist/{index-C4ZZnf_X.d.cts → index-BgmSdJKJ.d.cts} +2 -2
- package/dist/{index-CKd3ogUZ.d.cts → index-C0YF5kEb.d.cts} +2 -2
- package/dist/{index-Ck6nqnxZ.d.cts → index-CGvAotBX.d.cts} +2 -2
- package/dist/{index-DVX6E3vZ.d.ts → index-CHilsNw-.d.ts} +2 -2
- package/dist/{index-C0_Y9yA1.d.ts → index-CsySa8TT.d.ts} +2 -2
- package/dist/{index-BM3jzSca.d.ts → index-DA-Ztg07.d.ts} +1 -1
- package/dist/{index-CiVsdeOh.d.cts → index-DPGecgel.d.cts} +1 -1
- package/dist/{index-DdD4PIY8.d.cts → index-Dbtc7izw.d.cts} +1 -1
- package/dist/{index-DSW89P6k.d.cts → index-QDfAzfWY.d.cts} +1 -1
- package/dist/{index-B8ZxUpy4.d.ts → index-QZa0vqFW.d.ts} +1 -1
- package/dist/{index-7A3j-6Np.d.cts → index-oY3-BSwC.d.cts} +1 -1
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +8 -8
- package/dist/isRecord-CwlfDtHp.cjs +16 -0
- package/dist/isRecord-CwlfDtHp.cjs.map +1 -0
- package/dist/isRecord-DaSp13D_.js +11 -0
- package/dist/isRecord-DaSp13D_.js.map +1 -0
- package/dist/{json-DeqPhPUQ.js → json-IKokiUCp.js} +34 -19
- package/dist/json-IKokiUCp.js.map +1 -0
- package/dist/{json-KV2VhBue.cjs → json-mEYdjumm.cjs} +34 -19
- package/dist/json-mEYdjumm.cjs.map +1 -0
- package/dist/json.cjs +1 -1
- package/dist/json.d.cts +1 -1
- package/dist/json.d.ts +1 -1
- package/dist/json.js +1 -1
- package/dist/{macro-3uGSg-ic.js → macro-DhgoqDs6.js} +2 -2
- package/dist/{macro-3uGSg-ic.js.map → macro-DhgoqDs6.js.map} +1 -1
- package/dist/{macro-Ywn4-0s5.cjs → macro-h3bm9G48.cjs} +2 -2
- package/dist/{macro-Ywn4-0s5.cjs.map → macro-h3bm9G48.cjs.map} +1 -1
- package/dist/macro.cjs +1 -1
- package/dist/macro.d.cts +1 -1
- package/dist/macro.d.ts +1 -1
- package/dist/macro.js +1 -1
- package/dist/{node-BeccjrHH.cjs → node-Dhh4jTDv.cjs} +2 -2
- package/dist/{node-BeccjrHH.cjs.map → node-Dhh4jTDv.cjs.map} +1 -1
- package/dist/{node-Dm56432_.js → node-Dy0mq_hi.js} +2 -2
- package/dist/{node-Dm56432_.js.map → node-Dy0mq_hi.js.map} +1 -1
- package/dist/node.cjs +2 -2
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +2 -2
- package/dist/{nodes-KgbYiyJQ.js → nodes-B-MW8yk-.js} +2 -2
- package/dist/{nodes-KgbYiyJQ.js.map → nodes-B-MW8yk-.js.map} +1 -1
- package/dist/{nodes-BGxHocS_.cjs → nodes-BjVv21pb.cjs} +12 -12
- package/dist/{nodes-BGxHocS_.cjs.map → nodes-BjVv21pb.cjs.map} +1 -1
- package/dist/promise-DMQPWp6M.cjs.map +1 -1
- package/dist/promise-bi4pc8Xr.js.map +1 -1
- package/dist/{schema-XGRiAvok.cjs → schema-CMe0Dvgd.cjs} +2 -2
- package/dist/{schema-XGRiAvok.cjs.map → schema-CMe0Dvgd.cjs.map} +1 -1
- package/dist/{schema-B05JSQRq.js → schema-CVIk19Mh.js} +2 -2
- package/dist/{schema-B05JSQRq.js.map → schema-CVIk19Mh.js.map} +1 -1
- package/dist/schema.cjs +2 -2
- package/dist/schema.d.cts +2 -2
- package/dist/schema.d.ts +2 -2
- package/dist/schema.js +2 -2
- package/dist/{visitor-xxcbpM5-.d.ts → visitor-BWHpwRgc.d.ts} +2 -2
- package/dist/{visitor-BIldddZd.d.cts → visitor-CPlsMCPZ.d.cts} +2 -2
- package/dist/{visitor-DA5yfOJz.js → visitor-CitcdWu0.js} +5 -10
- package/dist/visitor-CitcdWu0.js.map +1 -0
- package/dist/{visitor-DhuKS-7x.cjs → visitor-DT712cxr.cjs} +5 -10
- package/dist/visitor-DT712cxr.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/combineFileMembers-B-mdjXrG.js.map +0 -1
- package/dist/combineFileMembers-DZCKxAN0.cjs.map +0 -1
- package/dist/graph-D6Ffy9YD.cjs.map +0 -1
- package/dist/graph-DWlCmvm6.js.map +0 -1
- package/dist/json-DeqPhPUQ.js.map +0 -1
- package/dist/json-KV2VhBue.cjs.map +0 -1
- package/dist/visitor-DA5yfOJz.js.map +0 -1
- package/dist/visitor-DhuKS-7x.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BYyVTPww.js";
|
|
2
2
|
import { t as nodeKinds } from "./constants-UorsTFsa.js";
|
|
3
3
|
import { n as getNodeText } from "./nodeText-DFak5VpX.js";
|
|
4
|
-
import { r as transform, t as collect } from "./visitor-
|
|
4
|
+
import { r as transform, t as collect } from "./visitor-CitcdWu0.js";
|
|
5
5
|
// src/node/index.ts
|
|
6
6
|
var node_exports = /* @__PURE__ */ __exportAll({
|
|
7
7
|
collect: () => collect,
|
|
@@ -11,4 +11,4 @@ var node_exports = /* @__PURE__ */ __exportAll({
|
|
|
11
11
|
});
|
|
12
12
|
export { node_exports as t };
|
|
13
13
|
|
|
14
|
-
//# sourceMappingURL=node-
|
|
14
|
+
//# sourceMappingURL=node-Dy0mq_hi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-
|
|
1
|
+
{"version":3,"file":"node-Dy0mq_hi.js","names":[],"sources":["../src/node/index.ts"],"sourcesContent":["export { nodeKinds as kinds } from '../constants.ts'\nexport { getNodeText as getText } from '../utils/nodeText.ts'\nexport { collect, transform } from '../visitor.ts'\n"],"mappings":""}
|
package/dist/node.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_constants = require("./constants-BCRkFAiy.cjs");
|
|
3
|
-
const require_visitor = require("./visitor-
|
|
3
|
+
const require_visitor = require("./visitor-DT712cxr.cjs");
|
|
4
4
|
const require_nodeText = require("./nodeText-DH4dLGUb.cjs");
|
|
5
|
-
require("./node-
|
|
5
|
+
require("./node-Dhh4jTDv.cjs");
|
|
6
6
|
exports.collect = require_visitor.collect;
|
|
7
7
|
exports.getText = require_nodeText.getNodeText;
|
|
8
8
|
exports.kinds = require_constants.nodeKinds;
|
package/dist/node.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { i as nodeKinds } from "./base-CyJhBRMi.cjs";
|
|
2
|
-
import { a as collect, s as transform } from "./visitor-
|
|
3
|
-
import { n as getNodeText } from "./index-
|
|
2
|
+
import { a as collect, s as transform } from "./visitor-CPlsMCPZ.cjs";
|
|
3
|
+
import { n as getNodeText } from "./index-CGvAotBX.cjs";
|
|
4
4
|
export { collect, getNodeText as getText, nodeKinds as kinds, transform };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { i as nodeKinds } from "./base-A-xF4pUL.js";
|
|
2
|
-
import { a as collect, s as transform } from "./visitor-
|
|
3
|
-
import { n as getNodeText } from "./index-
|
|
2
|
+
import { a as collect, s as transform } from "./visitor-BWHpwRgc.js";
|
|
3
|
+
import { n as getNodeText } from "./index-CsySa8TT.js";
|
|
4
4
|
export { collect, getNodeText as getText, nodeKinds as kinds, transform };
|
package/dist/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as nodeKinds } from "./constants-UorsTFsa.js";
|
|
2
|
-
import { r as transform, t as collect } from "./visitor-
|
|
2
|
+
import { r as transform, t as collect } from "./visitor-CitcdWu0.js";
|
|
3
3
|
import { n as getNodeText } from "./nodeText-DFak5VpX.js";
|
|
4
|
-
import "./node-
|
|
4
|
+
import "./node-Dy0mq_hi.js";
|
|
5
5
|
export { collect, getNodeText as getText, nodeKinds as kinds, transform };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BYyVTPww.js";
|
|
2
2
|
import { t as nodeKinds } from "./constants-UorsTFsa.js";
|
|
3
|
-
import { a as
|
|
3
|
+
import { a as createExport, n as createSource, o as createImport, r as nodeFactory, t as createFile } from "./file-AcKQt60j.js";
|
|
4
4
|
import { t as applyOptionality } from "./optionality-FkRredTC.js";
|
|
5
5
|
import { t as createSchema } from "./schema-CC008xgK.js";
|
|
6
6
|
// src/nodes/code.ts
|
|
@@ -244,4 +244,4 @@ var nodes_exports = /* @__PURE__ */ __exportAll({
|
|
|
244
244
|
});
|
|
245
245
|
export { createOperation as a, createInput as c, createBreak as d, createConst as f, createType as g, createText as h, createParameter as i, createContent as l, createJsx as m, createResponse as n, createOperations as o, createFunction as p, createProperty as r, createRequestBody as s, nodes_exports as t, createArrowFunction as u };
|
|
246
246
|
|
|
247
|
-
//# sourceMappingURL=nodes-
|
|
247
|
+
//# sourceMappingURL=nodes-B-MW8yk-.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes-KgbYiyJQ.js","names":[],"sources":["../src/nodes/code.ts","../src/nodes/content.ts","../src/nodes/input.ts","../src/nodes/requestBody.ts","../src/nodes/operation.ts","../src/nodes/parameter.ts","../src/nodes/property.ts","../src/nodes/response.ts","../src/nodes/index.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\n\n/**\n * JSDoc documentation metadata attached to code declarations.\n */\nexport type JSDocNode = {\n /**\n * JSDoc comment lines. `undefined` entries are filtered out during rendering.\n *\n * @example\n * ```ts\n * ['@description A pet resource', '@deprecated']\n * ```\n */\n comments?: Array<string | undefined>\n}\n\n/**\n * AST node representing a TypeScript `const` declaration.\n *\n * Mirrors the props of the `Const` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createConst({ name: 'pet', export: true, asConst: true })\n * // export const pet = ... as const\n * ```\n */\nexport type ConstNode = BaseNode & {\n kind: 'Const'\n /**\n * Name of the constant declaration.\n */\n name: string\n /**\n * Whether the declaration should be exported.\n */\n export?: boolean | null\n /**\n * Explicit type annotation.\n *\n * @example Type reference\n * `'Pet'`\n */\n type?: string | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Whether to append `as const` to the declaration.\n */\n asConst?: boolean | null\n /**\n * Child nodes representing the value of the constant (children of the `Const` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript `type` alias declaration.\n *\n * Mirrors the props of the `Type` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createType({ name: 'Pet', export: true })\n * // export type Pet = ...\n * ```\n */\nexport type TypeNode = BaseNode & {\n kind: 'Type'\n /**\n * Name of the type alias.\n */\n name: string\n /**\n * Whether the declaration should be exported.\n */\n export?: boolean | null\n /**\n * How the declaration is written.\n * - `'type'` declares `type Name = …`\n * - `'interface'` declares `interface Name { … }`, so the body must be an object type\n *\n * @default 'type'\n */\n syntax?: 'type' | 'interface' | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Child nodes representing the type body (children of the `Type` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript `function` declaration.\n *\n * Mirrors the props of the `Function` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createFunction({ name: 'getPet', export: true, async: true, returnType: 'Pet' })\n * // export async function getPet(): Promise<Pet> { ... }\n * ```\n */\nexport type FunctionNode = BaseNode & {\n kind: 'Function'\n /**\n * Name of the function.\n */\n name: string\n /**\n * Whether the function is a default export.\n */\n default?: boolean | null\n /**\n * Function parameter list as a pre-rendered string, written verbatim between the parentheses.\n *\n * @example\n * `'id: string, config: Config = {}'`\n */\n params?: string | null\n /**\n * Whether the function should be exported.\n */\n export?: boolean | null\n /**\n * Whether the function is async. When `true`, the return type is wrapped in `Promise<>`.\n */\n async?: boolean | null\n /**\n * TypeScript generic type parameters.\n *\n * @example Constrained generics\n * `['T', 'U extends string']`\n */\n generics?: string | Array<string> | null\n /**\n * Return type annotation.\n *\n * @example Type reference\n * `'Pet'`\n */\n returnType?: string | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Child nodes representing the function body (children of the `Function` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript arrow function (`const name = () => { ... }`).\n *\n * Mirrors the props of the `Function.Arrow` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createArrowFunction({ name: 'getPet', export: true, singleLine: true })\n * // export const getPet = () => ...\n * ```\n */\nexport type ArrowFunctionNode = Omit<FunctionNode, 'kind'> & {\n kind: 'ArrowFunction'\n /**\n * Render the arrow function body as a single-line expression.\n */\n singleLine?: boolean | null\n}\n\n/**\n * AST node representing a raw text/string fragment in the source output.\n *\n * Used instead of bare `string` values so that all entries in `nodes` arrays\n * are typed `CodeNode` objects rather than a mixed `CodeNode | string` union.\n *\n * @example\n * ```ts\n * createText('return fetch(id)')\n * // { kind: 'Text', value: 'return fetch(id)' }\n * ```\n */\nexport type TextNode = BaseNode & {\n kind: 'Text'\n /**\n * The raw string content.\n */\n value: string\n}\n\n/**\n * AST node representing a blank line in the source output.\n *\n * Corresponds to `<br/>` in JSX components. `printNodes` turns a `Break` between two\n * statements into one blank line. Consecutive breaks, and breaks at the start or end of\n * the list, are folded away, so a `Break` never produces more than one blank line.\n *\n * @example\n * ```ts\n * createBreak()\n * // { kind: 'Break' }\n * ```\n */\nexport type BreakNode = BaseNode & {\n kind: 'Break'\n}\n\n/**\n * AST node representing a raw JSX fragment in the source output.\n *\n * Mirrors the `Jsx` component from `@kubb/renderer-jsx`. Embeds raw JSX/TSX markup\n * (including fragments `<>…</>`) directly in generated code.\n *\n * @example\n * ```ts\n * createJsx('<>\\n <a href={href}>Open</a>\\n</>')\n * // { kind: 'Jsx', value: '<>\\n <a href={href}>Open</a>\\n</>' }\n * ```\n */\nexport type JsxNode = BaseNode & {\n kind: 'Jsx'\n /**\n * The raw JSX string content.\n */\n value: string\n}\n\n/**\n * Union of all code-generation AST nodes.\n *\n * These nodes mirror the JSX components from `@kubb/renderer-jsx` and are used as\n * structured children in {@link SourceNode.nodes}.\n */\nexport type CodeNode = ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode\n\n/**\n * Creates a `ConstNode` representing a TypeScript `const` declaration.\n *\n * @example Exported constant with type and `as const`\n * ```ts\n * createConst({ name: 'pets', export: true, type: 'Pet[]', asConst: true })\n * // export const pets: Pet[] = ... as const\n * ```\n */\nexport const createConst = nodeFactory<ConstNode>(nodeKinds.const)\n\n/**\n * Creates a `TypeNode` representing a TypeScript `type` alias declaration.\n *\n * @example\n * ```ts\n * createType({ name: 'Pet', export: true })\n * // export type Pet = ...\n * ```\n */\nexport const createType = nodeFactory<TypeNode>(nodeKinds.type)\n\n/**\n * Creates a `FunctionNode` representing a TypeScript `function` declaration.\n *\n * @example\n * ```ts\n * createFunction({ name: 'fetchPet', export: true, async: true, returnType: 'Pet' })\n * // export async function fetchPet(): Promise<Pet> { ... }\n * ```\n */\nexport const createFunction = nodeFactory<FunctionNode>(nodeKinds.function)\n\n/**\n * Creates an `ArrowFunctionNode` representing a TypeScript arrow function.\n *\n * @example\n * ```ts\n * createArrowFunction({ name: 'double', export: true, params: 'n: number', singleLine: true })\n * // export const double = (n: number) => ...\n * ```\n */\nexport const createArrowFunction = nodeFactory<ArrowFunctionNode>(nodeKinds.arrowFunction)\n\n/**\n * Creates a {@link TextNode} representing a raw string fragment in the source output.\n *\n * @example\n * ```ts\n * createText('return fetch(id)')\n * // { kind: 'Text', value: 'return fetch(id)' }\n * ```\n */\nexport function createText(value: string): TextNode {\n return { kind: nodeKinds.text, value }\n}\n\n/**\n * Creates a {@link BreakNode} representing a line break in the source output.\n *\n * @example\n * ```ts\n * createBreak()\n * // { kind: 'Break' }\n * ```\n */\nexport function createBreak(): BreakNode {\n return { kind: nodeKinds.break }\n}\n\n/**\n * Creates a {@link JsxNode} representing a raw JSX fragment in the source output.\n *\n * @example\n * ```ts\n * createJsx('<>\\n <a href={href}>Open</a>\\n</>')\n * // { kind: 'Jsx', value: '<>\\n <a href={href}>Open</a>\\n</>' }\n * ```\n */\nexport function createJsx(value: string): JsxNode {\n return { kind: nodeKinds.jsx, value }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\nimport type { ParameterStyle } from './parameter.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * How one body property is serialized, from the `encoding` entry of its media type.\n */\nexport type EncodingNode = {\n /**\n * Content type of the part, for example `'application/json'` for a multipart property.\n */\n contentType?: string\n /**\n * Serialization style of the property.\n */\n style?: ParameterStyle\n /**\n * Whether array and object values expand into separate values.\n */\n explode?: boolean\n /**\n * Whether reserved characters are sent as-is instead of percent-encoded.\n */\n allowReserved?: boolean\n encoding?: Record<string, EncodingNode>\n prefixEncoding?: Array<EncodingNode>\n itemEncoding?: EncodingNode\n}\n\nexport type ExampleNode = {\n name?: string\n summary?: string\n description?: string\n value?: unknown\n serializedValue?: string\n}\n\n/**\n * AST node representing one content-type entry of a request body or response.\n *\n * There is one entry per content type declared in the spec (e.g. `application/json`,\n * `multipart/form-data`), and each entry holds its own body schema.\n *\n * @example\n * ```ts\n * const content: ContentNode = {\n * kind: 'Content',\n * contentType: 'application/json',\n * schema: createSchema({ type: 'string' }),\n * }\n * ```\n */\nexport type ContentNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Content'\n /**\n * The content type for this entry (e.g. `'application/json'`), or `''` for a response without a body.\n */\n contentType: string\n /**\n * Body schema for this content type. For a stream it is the same node as `stream.schema`.\n */\n schema?: SchemaNode\n /**\n * Set when the content is a stream of items (an event stream, JSON Lines, a channel of messages) instead of one body.\n */\n stream?: {\n /**\n * Schema of one item, such as one event of `text/event-stream` or one line of JSON Lines.\n */\n schema?: SchemaNode\n /**\n * What `schema` describes for an event stream.\n * - `'event'` the parsed event with its `event`, `data`, `id` and `retry` fields\n * - `'data'` only the `data` payload, which the client wraps in its own event type\n */\n shape?: 'event' | 'data'\n }\n /**\n * Property keys to exclude from the generated type via `Omit<Type, Keys>`.\n * Set when a referenced schema has `readOnly`/`writeOnly` fields that should be omitted.\n */\n keysToOmit?: Array<string> | null\n /**\n * Serialization settings per body property that sets at least one field in the spec's `encoding`.\n */\n encoding?: Record<string, EncodingNode>\n examples?: Array<ExampleNode>\n /**\n * Serialization of the first parts by position, for a body sent as an array of parts such as `multipart/mixed`.\n */\n prefixEncoding?: Array<EncodingNode>\n /**\n * Serialization of every part after `prefixEncoding`, for a body sent as an array of parts such as `multipart/mixed`.\n */\n itemEncoding?: EncodingNode\n /** Vendor extensions (`x-*` keys) from the source media type, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\n/**\n * Creates a `ContentNode` for a single request-body or response content type.\n */\nexport const createContent = nodeFactory<ContentNode>(nodeKinds.content)\n","import { nodeKinds } from '../constants.ts'\nimport type { BaseNode } from './base.ts'\nimport type { OperationNode } from './operation.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * A variable declared by a server URL template.\n */\nexport type InputServerVariable = {\n default?: string\n enum?: Array<string>\n description?: string\n}\n\n/**\n * A server from the source document, with `{variable}` placeholders filled from their defaults.\n */\nexport type InputServer = {\n url: string\n name?: string\n description?: string\n /**\n * Variables of the source URL template, copied as-is. `url` already has their defaults filled in, so\n * this tells a templated server apart from a literal one. Absent when the server declares none.\n */\n variables?: Record<string, InputServerVariable>\n}\n\nexport type ExternalDocs = { url: string; description?: string }\n\nexport type InputTag = {\n name: string\n summary?: string\n description?: string\n /**\n * Name of the tag this tag nests under. `group: { type: 'tag' }` places its files in the parent's folder.\n */\n parent?: string\n kind?: string\n externalDocs?: ExternalDocs\n}\n\nexport type OAuthFlow = {\n authorizationUrl?: string\n deviceAuthorizationUrl?: string\n tokenUrl?: string\n refreshUrl?: string\n scopes?: Record<string, string>\n}\n\n/**\n * How a client sends a credential, in the same shape as the `Auth` object the generated clients pass to `auth`.\n */\nexport type AuthCredential =\n | { type: 'http'; scheme: 'bearer' | 'basic' | (string & {}); bearerFormat?: string }\n | { type: 'apiKey'; in: 'header' | 'query' | 'cookie'; name: string }\n | { type: 'oauth2'; flows: Record<string, OAuthFlow>; metadataUrl?: string }\n | { type: 'openIdConnect'; url?: string }\n | { type: 'mutualTLS' }\n\n/**\n * One way to authenticate, keyed by `name`, which operations refer to in `auth`.\n */\nexport type AuthScheme = {\n name: string\n description?: string\n deprecated?: boolean\n credential: AuthCredential\n}\n\n/**\n * One way to meet an operation's auth. Every scheme in it applies together. `scopes` are the OAuth2 or OpenID\n * Connect scopes the call needs. An empty list means the call may be sent without credentials.\n */\nexport type AuthRequirement = Array<{ scheme: string; scopes?: Array<string> }>\n\n/**\n * Metadata for an API document, populated by the adapter and available to every generator.\n * Every field is a plain JSON value.\n *\n * @example\n * ```ts\n * const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://api.example.com/v2' }\n * ```\n */\nexport type InputMeta = {\n /**\n * API title from `info.title` in the source document.\n */\n title?: string\n /**\n * API description from `info.description` in the source document.\n */\n description?: string\n /**\n * API version string from `info.version` in the source document.\n */\n version?: string\n summary?: string\n termsOfService?: string\n contact?: { name?: string; url?: string; email?: string }\n license?: { name: string; identifier?: string; url?: string }\n externalDocs?: ExternalDocs\n /**\n * Resolved base URL from the first matching server entry in the source document.\n */\n baseURL?: string | null\n /**\n * The server index the adapter was configured with. A plugin uses it to pick the server at the same position in an\n * operation's or a path's own `servers`. It counts the source document's entries, including any without a URL.\n * Absent when the adapter was given no index.\n */\n serverIndex?: number\n servers?: Array<InputServer>\n tags?: Array<InputTag>\n auth?: Array<AuthScheme>\n /**\n * Vendor extensions (`x-*` keys) from the document root, copied as-is. Absent when the root has none.\n */\n extensions?: Record<string, unknown>\n}\n\n/**\n * Input AST node that contains all schemas and operations for one API document.\n * Produced by the adapter and consumed by all Kubb plugins.\n *\n * @example\n * ```ts\n * const input: InputNode = {\n * kind: 'Input',\n * schemas: [],\n * operations: [],\n * meta: {},\n * }\n * ```\n */\nexport type InputNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Input'\n /**\n * All schema nodes in the document.\n */\n schemas: Array<SchemaNode>\n /**\n * All operation nodes in the document.\n */\n operations: Array<OperationNode>\n /**\n * Document metadata populated by the adapter.\n */\n meta: InputMeta\n}\n\n/**\n * Creates an `InputNode`, defaulting `schemas`/`operations` to empty arrays and `meta` to an empty\n * object. Every call allocates fresh defaults so no two inputs share them.\n *\n * @example\n * ```ts\n * const input = createInput()\n * // { kind: 'Input', schemas: [], operations: [] }\n * ```\n */\nexport function createInput(overrides: Partial<Omit<InputNode, 'kind'>> = {}): InputNode {\n return { schemas: [], operations: [], meta: {}, ...overrides, kind: nodeKinds.input }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\nimport type { ContentNode } from './content.ts'\n\n/**\n * AST node representing an operation request body.\n *\n * Body schemas live exclusively inside the `content` array (one entry per content type),\n * mirroring {@link ResponseNode}.\n *\n * @example\n * ```ts\n * const requestBody: RequestBodyNode = {\n * kind: 'RequestBody',\n * required: true,\n * content: [{ kind: 'Content', contentType: 'application/json', schema: createSchema({ type: 'string' }) }],\n * }\n * ```\n */\nexport type RequestBodyNode = BaseNode & {\n kind: 'RequestBody'\n /**\n * Request body description carried over from the spec.\n */\n description?: string\n /**\n * Whether the request body is required (`requestBody.required: true` in the spec).\n * When `false` or absent, the generated `data` parameter should be optional.\n */\n required?: boolean\n /**\n * Content type entries for this request body.\n *\n * When the adapter `contentType` option is set, this array contains exactly one entry for\n * that content type. Otherwise it contains one entry per content type declared in the spec,\n * so plugins can generate code for every variant (for example, separate hooks for\n * `application/json` and `multipart/form-data`).\n */\n content?: Array<ContentNode>\n /** Vendor extensions (`x-*` keys) from the source request body, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\n/**\n * Creates a `RequestBodyNode`.\n */\nexport const createRequestBody = nodeFactory<RequestBodyNode>(nodeKinds.requestBody)\n","import { nodeKinds } from '../constants.ts'\nimport type { BaseNode } from './base.ts'\nimport type { AuthRequirement, ExternalDocs, InputServer } from './input.ts'\nimport type { ParameterNode } from './parameter.ts'\nimport { createRequestBody, type RequestBodyNode } from './requestBody.ts'\nimport type { ResponseNode } from './response.ts'\n\n/**\n * HTTP method an operation responds to. `QUERY` is the safe, idempotent method with a request body\n * from RFC 10008, declared with the `query` field of an OpenAPI 3.2 path item. Any other name is a\n * method the source declares outside this fixed set, in the capitalization it is sent with.\n */\nexport type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'QUERY' | (string & {})\n\n/**\n * Fields shared by every operation, regardless of transport.\n */\nexport type OperationNodeBase = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Operation'\n /**\n * Stable identifier for the operation.\n */\n operationId: string\n /**\n * Group labels for the operation.\n */\n tags: Array<string>\n /**\n * Short one-line operation summary.\n */\n summary?: string\n /**\n * Full operation description.\n */\n description?: string\n /**\n * Marks the operation as deprecated.\n */\n deprecated?: boolean\n externalDocs?: ExternalDocs\n /**\n * Query, path, header, and cookie parameters for the operation.\n */\n parameters: Array<ParameterNode>\n /**\n * Request body for the operation.\n */\n requestBody?: RequestBodyNode\n /**\n * Operation responses.\n */\n responses: Array<ResponseNode>\n /**\n * Vendor extensions (`x-*` keys) from the source operation, copied as-is. Absent when the source has none.\n */\n extensions?: Record<string, unknown>\n /** The operation's own `servers`, else its path item's, such as an upload host. Absent when neither declares any. */\n servers?: Array<InputServer>\n /**\n * Ways to authenticate, from the operation or else the document. Any one entry is enough. `[]` means no auth.\n */\n auth?: Array<AuthRequirement>\n}\n\n/**\n * Operation served over HTTP. `method` and `path` are guaranteed.\n *\n * @example\n * ```ts\n * const operation: HttpOperationNode = {\n * kind: 'Operation',\n * operationId: 'listPets',\n * protocol: 'http',\n * method: 'GET',\n * path: '/pets',\n * tags: [],\n * parameters: [],\n * responses: [],\n * }\n * ```\n */\nexport type HttpOperationNode = OperationNodeBase & {\n /**\n * Transport the operation belongs to.\n */\n protocol?: 'http'\n /**\n * HTTP method like `'GET'`.\n */\n method: HttpMethod\n /**\n * Path string, for example `/pets/{petId}`, with `{param}` notation preserved.\n */\n path: string\n}\n\n/**\n * Operation for a non-HTTP transport. HTTP-only fields are forbidden.\n */\nexport type GenericOperationNode = OperationNodeBase & {\n protocol?: never\n method?: never\n path?: never\n}\n\n/**\n * AST node representing one API operation.\n *\n * Discriminated on `protocol`: an {@link HttpOperationNode} (`protocol: 'http'`) guarantees\n * `method` and `path`, while a {@link GenericOperationNode} omits them. Narrow with\n * `ast.http.isOperation(node)` or `node.protocol === 'http'` before reading `method`/`path`.\n */\nexport type OperationNode = HttpOperationNode | GenericOperationNode\n\nexport type OperationInput = {\n operationId: string\n method?: HttpOperationNode['method']\n path?: HttpOperationNode['path']\n requestBody?: Omit<RequestBodyNode, 'kind'>\n [key: string]: unknown\n}\n\n/**\n * Creates an `OperationNode` with default empty arrays for `tags`, `parameters`, and `responses`.\n * HTTP operations (those carrying both `method` and `path`) are tagged with `protocol: 'http'`,\n * and the request body is normalized into a `RequestBodyNode`.\n *\n * @example\n * ```ts\n * const operation = createOperation({ operationId: 'getPetById', method: 'GET', path: '/pet/{petId}' })\n * // tags, parameters, and responses are []\n * ```\n */\nexport function createOperation(\n props: Pick<HttpOperationNode, 'operationId' | 'method' | 'path'> &\n Partial<Omit<HttpOperationNode, 'kind' | 'operationId' | 'method' | 'path' | 'requestBody'>> & {\n requestBody?: Omit<RequestBodyNode, 'kind'>\n },\n): HttpOperationNode\nexport function createOperation(\n props: Pick<GenericOperationNode, 'operationId'> &\n Partial<Omit<GenericOperationNode, 'kind' | 'operationId' | 'requestBody'>> & {\n requestBody?: Omit<RequestBodyNode, 'kind'>\n },\n): GenericOperationNode\nexport function createOperation(props: OperationInput): OperationNode {\n const { requestBody, ...rest } = props\n const isHttp = rest.method !== undefined && rest.path !== undefined\n\n const node = {\n tags: [],\n parameters: [],\n responses: [],\n ...rest,\n kind: nodeKinds.operation,\n ...(isHttp ? { protocol: 'http' as const } : {}),\n requestBody: requestBody ? createRequestBody(requestBody) : undefined,\n }\n\n return node as OperationNode\n}\n\n/**\n * The operations a plugin keeps, as one node. A template with `kind: 'Operations'` gets it once, after every operation.\n */\nexport type OperationsNode = BaseNode & {\n kind: 'Operations'\n operations: Array<OperationNode>\n}\n\n/**\n * Creates an `OperationsNode` for a list of operations.\n *\n * @example\n * ```ts\n * const node = createOperations({ operations: [listPets, getPetById] })\n * // { kind: 'Operations', operations: [...] }\n * ```\n */\nexport function createOperations({ operations }: { operations: Array<OperationNode> }): OperationsNode {\n return { kind: nodeKinds.operations, operations }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { applyOptionality } from '../optionality.ts'\nimport type { BaseNode } from './base.ts'\nimport type { EncodingNode, ExampleNode } from './content.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * Where a parameter is sent. `querystring` carries the whole query string as one value, serialized per `contentType`.\n */\nexport type ParameterLocation = 'path' | 'query' | 'header' | 'cookie' | 'querystring'\n\n/**\n * Parameter serialization style, controlling how a parameter value is rendered into the request.\n */\nexport type ParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject' | 'cookie'\n\n/**\n * AST node representing one operation parameter.\n *\n * @example\n * ```ts\n * const param: ParameterNode = {\n * kind: 'Parameter',\n * name: 'petId',\n * in: 'path',\n * schema: createSchema({ type: 'string' }),\n * required: true,\n * }\n * ```\n */\nexport type ParameterNode = BaseNode & {\n kind: 'Parameter'\n /**\n * Parameter name.\n */\n name: string\n /**\n * Parameter location (`path`, `query`, `header`, `cookie`, or `querystring`).\n */\n in: ParameterLocation\n /**\n * Parameter schema.\n */\n schema: SchemaNode\n /**\n * Whether the parameter is required.\n */\n required: boolean\n /**\n * Serialization style. Absent when the source omits it, leaving consumers to apply the\n * per-location default.\n */\n style?: ParameterStyle\n /**\n * Whether array and object values expand into separate values. Absent when the source omits it,\n * leaving consumers to apply the default for the style.\n */\n explode?: boolean\n /**\n * Whether reserved characters (RFC 3986 `:/?#[]@!$&'()*+,;=`) are sent as-is instead of\n * percent-encoded. Absent when the source omits it.\n */\n allowReserved?: boolean\n /**\n * Media type of a parameter described with `content` instead of `schema`, for example\n * `application/json` when the value is sent as a JSON-encoded string. Absent for `schema` parameters.\n */\n contentType?: string\n /**\n * Serialization settings per property of a `content` parameter, from the `encoding` of its media type. An OpenAPI 3.2\n * `querystring` parameter sent as `application/x-www-form-urlencoded` uses it to set `style` and `explode` per field.\n */\n encoding?: Record<string, EncodingNode>\n examples?: Array<ExampleNode>\n deprecated?: boolean\n allowEmptyValue?: boolean\n /** Vendor extensions (`x-*` keys) from the source parameter, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\nexport type UserParameterNode = Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial<Omit<ParameterNode, 'kind' | 'name' | 'in' | 'schema'>>\n\n/**\n * Creates a `ParameterNode`. `required` defaults to `false`, and the schema's\n * `optional`/`nullish` flags are derived from it.\n *\n * @example\n * ```ts\n * const param = createParameter({\n * name: 'petId',\n * in: 'path',\n * required: true,\n * schema: createSchema({ type: 'string' }),\n * })\n * ```\n */\nexport function createParameter(input: UserParameterNode): ParameterNode {\n const required = input.required ?? false\n\n return { ...input, required, schema: applyOptionality(input.schema, required), kind: nodeKinds.parameter }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { applyOptionality } from '../optionality.ts'\nimport type { BaseNode } from './base.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * AST node representing one named object property.\n *\n * @example\n * ```ts\n * const property: PropertyNode = {\n * kind: 'Property',\n * name: 'id',\n * schema: createSchema({ type: 'integer' }),\n * required: true,\n * }\n * ```\n */\nexport type PropertyNode = BaseNode & {\n kind: 'Property'\n /**\n * Property key.\n */\n name: string\n /**\n * Property schema.\n */\n schema: SchemaNode\n /**\n * Whether the property is required.\n */\n required: boolean\n}\n\n/**\n * Loosely-typed property accepted by `createProperty`, with `required` optional.\n */\nexport type UserPropertyNode = Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<PropertyNode, 'kind' | 'name' | 'schema'>>\n\n/**\n * Creates a `PropertyNode`. `required` defaults to `false`, and the schema's\n * `optional`/`nullish` flags are derived from it.\n *\n * @example\n * ```ts\n * const property = createProperty({\n * name: 'status',\n * required: true,\n * schema: createSchema({ type: 'string', nullable: true }),\n * })\n * // required=true, no optional/nullish\n * ```\n */\nexport function createProperty(input: UserPropertyNode): PropertyNode {\n const required = input.required ?? false\n\n return { ...input, required, schema: applyOptionality(input.schema, required), kind: nodeKinds.property }\n}\n","import { nodeKinds } from '../constants.ts'\nimport type { BaseNode } from './base.ts'\nimport { type ContentNode, createContent } from './content.ts'\nimport type { InputServer } from './input.ts'\nimport type { ParameterNode } from './parameter.ts'\nimport type { SchemaNode } from './schema.ts'\n\nexport type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\n\n/**\n * Response status code literal used by operations.\n *\n * Includes three-digit HTTP status code strings, ranges such as `\"2xx\"`, and `\"default\"` for catch-all responses.\n *\n * @example\n * ```ts\n * const status: StatusCode = '200'\n * const fallback: StatusCode = 'default'\n * ```\n */\nexport type StatusCode = `${1 | 2 | 3 | 4 | 5}${Digit}${Digit}` | `${1 | 2 | 3 | 4 | 5}xx` | 'default'\n\n/**\n * AST node representing one operation response variant.\n *\n * Mirrors {@link OperationNode.requestBody}: the response body schemas live exclusively inside\n * the `content` array (one entry per content type), so the same schema is never duplicated at the\n * node root and inside `content`.\n *\n * @example\n * ```ts\n * const response: ResponseNode = {\n * kind: 'Response',\n * statusCode: '200',\n * content: [{ kind: 'Content', contentType: 'application/json', schema: createSchema({ type: 'string' }) }],\n * }\n * ```\n */\nexport type ResponseNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Response'\n /**\n * HTTP status code or `'default'` for a fallback response.\n */\n statusCode: StatusCode\n summary?: string\n /**\n * Optional response description.\n */\n description?: string\n /**\n * All available content type entries for this response.\n *\n * For a response that declares content, the array holds exactly one entry for the adapter\n * `contentType` option when it is set. Otherwise it holds one entry per content type declared in\n * the spec, so that plugins can generate a union of response types (e.g. `application/json` and\n * `application/xml`). A body-less response always keeps a single entry whose `contentType` is `''`\n * and whose `schema` is the empty/`void` placeholder, even when the option is set.\n *\n * @example\n * ```ts\n * // spec response declares both application/json and application/xml\n * response.content[0].contentType // 'application/json'\n * response.content[1].contentType // 'application/xml'\n * ```\n */\n content?: Array<ContentNode>\n /**\n * Response headers, as `in: 'header'` parameters. `Content-Type` is left out.\n */\n headers?: Array<ParameterNode>\n links?: Record<string, ResponseLink>\n /** Vendor extensions (`x-*` keys) from the source response, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\n/**\n * A link to another operation. `parameters` and `requestBody` hold runtime expressions such as `$response.body#/id`.\n */\nexport type ResponseLink = {\n operationId?: string\n operationRef?: string\n parameters?: Record<string, unknown>\n requestBody?: unknown\n description?: string\n server?: InputServer\n}\n\nexport type ResponseInput = Pick<ResponseNode, 'statusCode'> &\n Partial<Omit<ResponseNode, 'kind' | 'statusCode' | 'content'>> & {\n content?: Array<ContentNode>\n schema?: SchemaNode\n mediaType?: string | null\n keysToOmit?: Array<string> | null\n }\n\n/**\n * Creates a `ResponseNode`. A single legacy `schema` (with optional `mediaType`/`keysToOmit`)\n * is normalized into one `content` entry.\n *\n * @example\n * ```ts\n * const response = createResponse({\n * statusCode: '200',\n * content: [createContent({ contentType: 'application/json', schema: createSchema({ type: 'object', properties: [] }) })],\n * })\n * ```\n */\nexport function createResponse(props: ResponseInput): ResponseNode {\n const { schema, mediaType, keysToOmit, content, ...rest } = props\n const entries = content ?? (schema ? [createContent({ contentType: mediaType ?? 'application/json', schema, keysToOmit: keysToOmit ?? null })] : undefined)\n\n return { ...rest, content: entries, kind: nodeKinds.response }\n}\n","import type { ArrowFunctionNode, BreakNode, ConstNode, FunctionNode, JsxNode, TextNode, TypeNode } from './code.ts'\nimport type { ContentNode } from './content.ts'\nimport type { ExportNode, FileNode, ImportNode, SourceNode } from './file.ts'\nimport type { InputNode } from './input.ts'\nimport type { OperationNode, OperationsNode } from './operation.ts'\nimport type { ParameterNode } from './parameter.ts'\nimport type { PropertyNode } from './property.ts'\nimport type { RequestBodyNode } from './requestBody.ts'\nimport type { ResponseNode } from './response.ts'\nimport type { SchemaNode } from './schema.ts'\n\nexport { createArrowFunction, createBreak, createConst, createFunction, createJsx, createText, createType } from './code.ts'\nexport { createContent } from './content.ts'\nexport { createExport, createFile, createImport, createSource } from './file.ts'\nexport type { ExportInput, ImportInput, ModuleName, Space, UserFileNode } from './file.ts'\nexport { createInput } from './input.ts'\nexport { createOperation, createOperations } from './operation.ts'\nexport { createParameter } from './parameter.ts'\nexport { createProperty } from './property.ts'\nexport { createRequestBody } from './requestBody.ts'\nexport { createResponse } from './response.ts'\nexport { createSchema } from './schema.ts'\n\n/**\n * Union of all AST node types.\n *\n * This lets TypeScript narrow types in `switch (node.kind)` blocks.\n *\n * @example\n * ```ts\n * function getKind(node: Node): string {\n * switch (node.kind) {\n * case nodeKinds.input:\n * return 'input'\n * default:\n * return 'other'\n * }\n * }\n * ```\n */\nexport type Node =\n | InputNode\n | OperationNode\n | OperationsNode\n | SchemaNode\n | PropertyNode\n | ParameterNode\n | ResponseNode\n | RequestBodyNode\n | ContentNode\n | FileNode\n | ImportNode\n | ExportNode\n | SourceNode\n | ConstNode\n | TypeNode\n | FunctionNode\n | ArrowFunctionNode\n | TextNode\n | BreakNode\n | JsxNode\n"],"mappings":";;;;;;;;;;;;;;;AAmQA,MAAa,cAAc,YAAuB,UAAU,KAAK;;;;;;;;;;AAWjE,MAAa,aAAa,YAAsB,UAAU,IAAI;;;;;;;;;;AAW9D,MAAa,iBAAiB,YAA0B,UAAU,QAAQ;;;;;;;;;;AAW1E,MAAa,sBAAsB,YAA+B,UAAU,aAAa;;;;;;;;;;AAWzF,SAAgB,WAAW,OAAyB;CAClD,OAAO;EAAE,MAAM,UAAU;EAAM;CAAM;AACvC;;;;;;;;;;AAWA,SAAgB,cAAyB;CACvC,OAAO,EAAE,MAAM,UAAU,MAAM;AACjC;;;;;;;;;;AAWA,SAAgB,UAAU,OAAwB;CAChD,OAAO;EAAE,MAAM,UAAU;EAAK;CAAM;AACtC;;;;;ACjOA,MAAa,gBAAgB,YAAyB,UAAU,OAAO;;;;;;;;;;;;AC2DvE,SAAgB,YAAY,YAA8C,CAAC,GAAc;CACvF,OAAO;EAAE,SAAS,CAAC;EAAG,YAAY,CAAC;EAAG,MAAM,CAAC;EAAG,GAAG;EAAW,MAAM,UAAU;CAAM;AACtF;;;;;ACzHA,MAAa,oBAAoB,YAA6B,UAAU,WAAW;;ACsGnF,SAAgB,gBAAgB,OAAsC;CACpE,MAAM,EAAE,aAAa,GAAG,SAAS;CACjC,MAAM,SAAS,KAAK,WAAW,KAAA,KAAa,KAAK,SAAS,KAAA;CAY1D,OAAO;EATL,MAAM,CAAC;EACP,YAAY,CAAC;EACb,WAAW,CAAC;EACZ,GAAG;EACH,MAAM,UAAU;EAChB,GAAI,SAAS,EAAE,UAAU,OAAgB,IAAI,CAAC;EAC9C,aAAa,cAAc,kBAAkB,WAAW,IAAI,KAAA;CAGpD;AACZ;;;;;;;;;;AAmBA,SAAgB,iBAAiB,EAAE,cAAoE;CACrG,OAAO;EAAE,MAAM,UAAU;EAAY;CAAW;AAClD;;;;;;;;;;;;;;;;ACxFA,SAAgB,gBAAgB,OAAyC;CACvE,MAAM,WAAW,MAAM,YAAY;CAEnC,OAAO;EAAE,GAAG;EAAO;EAAU,QAAQ,iBAAiB,MAAM,QAAQ,QAAQ;EAAG,MAAM,UAAU;CAAU;AAC3G;;;;;;;;;;;;;;;;AC/CA,SAAgB,eAAe,OAAuC;CACpE,MAAM,WAAW,MAAM,YAAY;CAEnC,OAAO;EAAE,GAAG;EAAO;EAAU,QAAQ,iBAAiB,MAAM,QAAQ,QAAQ;EAAG,MAAM,UAAU;CAAS;AAC1G;;;;;;;;;;;;;;ACqDA,SAAgB,eAAe,OAAoC;CACjE,MAAM,EAAE,QAAQ,WAAW,YAAY,SAAS,GAAG,SAAS;CAC5D,MAAM,UAAU,YAAY,SAAS,CAAC,cAAc;EAAE,aAAa,aAAa;EAAoB;EAAQ,YAAY,cAAc;CAAK,CAAC,CAAC,IAAI,KAAA;CAEjJ,OAAO;EAAE,GAAG;EAAM,SAAS;EAAS,MAAM,UAAU;CAAS;AAC/D"}
|
|
1
|
+
{"version":3,"file":"nodes-B-MW8yk-.js","names":[],"sources":["../src/nodes/code.ts","../src/nodes/content.ts","../src/nodes/input.ts","../src/nodes/requestBody.ts","../src/nodes/operation.ts","../src/nodes/parameter.ts","../src/nodes/property.ts","../src/nodes/response.ts","../src/nodes/index.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\n\n/**\n * JSDoc documentation metadata attached to code declarations.\n */\nexport type JSDocNode = {\n /**\n * JSDoc comment lines. `undefined` entries are filtered out during rendering.\n *\n * @example\n * ```ts\n * ['@description A pet resource', '@deprecated']\n * ```\n */\n comments?: Array<string | undefined>\n}\n\n/**\n * AST node representing a TypeScript `const` declaration.\n *\n * Mirrors the props of the `Const` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createConst({ name: 'pet', export: true, asConst: true })\n * // export const pet = ... as const\n * ```\n */\nexport type ConstNode = BaseNode & {\n kind: 'Const'\n /**\n * Name of the constant declaration.\n */\n name: string\n /**\n * Whether the declaration should be exported.\n */\n export?: boolean | null\n /**\n * Explicit type annotation.\n *\n * @example Type reference\n * `'Pet'`\n */\n type?: string | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Whether to append `as const` to the declaration.\n */\n asConst?: boolean | null\n /**\n * Child nodes representing the value of the constant (children of the `Const` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript `type` alias declaration.\n *\n * Mirrors the props of the `Type` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createType({ name: 'Pet', export: true })\n * // export type Pet = ...\n * ```\n */\nexport type TypeNode = BaseNode & {\n kind: 'Type'\n /**\n * Name of the type alias.\n */\n name: string\n /**\n * Whether the declaration should be exported.\n */\n export?: boolean | null\n /**\n * How the declaration is written.\n * - `'type'` declares `type Name = …`\n * - `'interface'` declares `interface Name { … }`, so the body must be an object type\n *\n * @default 'type'\n */\n syntax?: 'type' | 'interface' | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Child nodes representing the type body (children of the `Type` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript `function` declaration.\n *\n * Mirrors the props of the `Function` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createFunction({ name: 'getPet', export: true, async: true, returnType: 'Pet' })\n * // export async function getPet(): Promise<Pet> { ... }\n * ```\n */\nexport type FunctionNode = BaseNode & {\n kind: 'Function'\n /**\n * Name of the function.\n */\n name: string\n /**\n * Whether the function is a default export.\n */\n default?: boolean | null\n /**\n * Function parameter list as a pre-rendered string, written verbatim between the parentheses.\n *\n * @example\n * `'id: string, config: Config = {}'`\n */\n params?: string | null\n /**\n * Whether the function should be exported.\n */\n export?: boolean | null\n /**\n * Whether the function is async. When `true`, the return type is wrapped in `Promise<>`.\n */\n async?: boolean | null\n /**\n * TypeScript generic type parameters.\n *\n * @example Constrained generics\n * `['T', 'U extends string']`\n */\n generics?: string | Array<string> | null\n /**\n * Return type annotation.\n *\n * @example Type reference\n * `'Pet'`\n */\n returnType?: string | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Child nodes representing the function body (children of the `Function` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript arrow function (`const name = () => { ... }`).\n *\n * Mirrors the props of the `Function.Arrow` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createArrowFunction({ name: 'getPet', export: true, singleLine: true })\n * // export const getPet = () => ...\n * ```\n */\nexport type ArrowFunctionNode = Omit<FunctionNode, 'kind'> & {\n kind: 'ArrowFunction'\n /**\n * Render the arrow function body as a single-line expression.\n */\n singleLine?: boolean | null\n}\n\n/**\n * AST node representing a raw text/string fragment in the source output.\n *\n * Used instead of bare `string` values so that all entries in `nodes` arrays\n * are typed `CodeNode` objects rather than a mixed `CodeNode | string` union.\n *\n * @example\n * ```ts\n * createText('return fetch(id)')\n * // { kind: 'Text', value: 'return fetch(id)' }\n * ```\n */\nexport type TextNode = BaseNode & {\n kind: 'Text'\n /**\n * The raw string content.\n */\n value: string\n}\n\n/**\n * AST node representing a blank line in the source output.\n *\n * Corresponds to `<br/>` in JSX components. `printNodes` turns a `Break` between two\n * statements into one blank line. Consecutive breaks, and breaks at the start or end of\n * the list, are folded away, so a `Break` never produces more than one blank line.\n *\n * @example\n * ```ts\n * createBreak()\n * // { kind: 'Break' }\n * ```\n */\nexport type BreakNode = BaseNode & {\n kind: 'Break'\n}\n\n/**\n * AST node representing a raw JSX fragment in the source output.\n *\n * Mirrors the `Jsx` component from `@kubb/renderer-jsx`. Embeds raw JSX/TSX markup\n * (including fragments `<>…</>`) directly in generated code.\n *\n * @example\n * ```ts\n * createJsx('<>\\n <a href={href}>Open</a>\\n</>')\n * // { kind: 'Jsx', value: '<>\\n <a href={href}>Open</a>\\n</>' }\n * ```\n */\nexport type JsxNode = BaseNode & {\n kind: 'Jsx'\n /**\n * The raw JSX string content.\n */\n value: string\n}\n\n/**\n * Union of all code-generation AST nodes.\n *\n * These nodes mirror the JSX components from `@kubb/renderer-jsx` and are used as\n * structured children in {@link SourceNode.nodes}.\n */\nexport type CodeNode = ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode\n\n/**\n * Creates a `ConstNode` representing a TypeScript `const` declaration.\n *\n * @example Exported constant with type and `as const`\n * ```ts\n * createConst({ name: 'pets', export: true, type: 'Pet[]', asConst: true })\n * // export const pets: Pet[] = ... as const\n * ```\n */\nexport const createConst = nodeFactory<ConstNode>(nodeKinds.const)\n\n/**\n * Creates a `TypeNode` representing a TypeScript `type` alias declaration.\n *\n * @example\n * ```ts\n * createType({ name: 'Pet', export: true })\n * // export type Pet = ...\n * ```\n */\nexport const createType = nodeFactory<TypeNode>(nodeKinds.type)\n\n/**\n * Creates a `FunctionNode` representing a TypeScript `function` declaration.\n *\n * @example\n * ```ts\n * createFunction({ name: 'fetchPet', export: true, async: true, returnType: 'Pet' })\n * // export async function fetchPet(): Promise<Pet> { ... }\n * ```\n */\nexport const createFunction = nodeFactory<FunctionNode>(nodeKinds.function)\n\n/**\n * Creates an `ArrowFunctionNode` representing a TypeScript arrow function.\n *\n * @example\n * ```ts\n * createArrowFunction({ name: 'double', export: true, params: 'n: number', singleLine: true })\n * // export const double = (n: number) => ...\n * ```\n */\nexport const createArrowFunction = nodeFactory<ArrowFunctionNode>(nodeKinds.arrowFunction)\n\n/**\n * Creates a {@link TextNode} representing a raw string fragment in the source output.\n *\n * @example\n * ```ts\n * createText('return fetch(id)')\n * // { kind: 'Text', value: 'return fetch(id)' }\n * ```\n */\nexport function createText(value: string): TextNode {\n return { kind: nodeKinds.text, value }\n}\n\n/**\n * Creates a {@link BreakNode} representing a line break in the source output.\n *\n * @example\n * ```ts\n * createBreak()\n * // { kind: 'Break' }\n * ```\n */\nexport function createBreak(): BreakNode {\n return { kind: nodeKinds.break }\n}\n\n/**\n * Creates a {@link JsxNode} representing a raw JSX fragment in the source output.\n *\n * @example\n * ```ts\n * createJsx('<>\\n <a href={href}>Open</a>\\n</>')\n * // { kind: 'Jsx', value: '<>\\n <a href={href}>Open</a>\\n</>' }\n * ```\n */\nexport function createJsx(value: string): JsxNode {\n return { kind: nodeKinds.jsx, value }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\nimport type { ParameterStyle } from './parameter.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * How one body property is serialized, from the `encoding` entry of its media type.\n */\nexport type EncodingNode = {\n /**\n * Content type of the part, for example `'application/json'` for a multipart property.\n */\n contentType?: string\n /**\n * Serialization style of the property.\n */\n style?: ParameterStyle\n /**\n * Whether array and object values expand into separate values.\n */\n explode?: boolean\n /**\n * Whether reserved characters are sent as-is instead of percent-encoded.\n */\n allowReserved?: boolean\n encoding?: Record<string, EncodingNode>\n prefixEncoding?: Array<EncodingNode>\n itemEncoding?: EncodingNode\n}\n\nexport type ExampleNode = {\n name?: string\n summary?: string\n description?: string\n value?: unknown\n serializedValue?: string\n}\n\n/**\n * AST node representing one content-type entry of a request body or response.\n *\n * There is one entry per content type declared in the spec (e.g. `application/json`,\n * `multipart/form-data`), and each entry holds its own body schema.\n *\n * @example\n * ```ts\n * const content: ContentNode = {\n * kind: 'Content',\n * contentType: 'application/json',\n * schema: createSchema({ type: 'string' }),\n * }\n * ```\n */\nexport type ContentNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Content'\n /**\n * The content type for this entry (e.g. `'application/json'`), or `''` for a response without a body.\n */\n contentType: string\n /**\n * Body schema for this content type. For a stream it is the same node as `stream.schema`.\n */\n schema?: SchemaNode\n /**\n * Set when the content is a stream of items (an event stream, JSON Lines, a channel of messages) instead of one body.\n */\n stream?: {\n /**\n * Schema of one item, such as one event of `text/event-stream` or one line of JSON Lines.\n */\n schema?: SchemaNode\n /**\n * What `schema` describes for an event stream.\n * - `'event'` the parsed event with its `event`, `data`, `id` and `retry` fields\n * - `'data'` only the `data` payload, which the client wraps in its own event type\n */\n shape?: 'event' | 'data'\n }\n /**\n * Property keys to exclude from the generated type via `Omit<Type, Keys>`.\n * Set when a referenced schema has `readOnly`/`writeOnly` fields that should be omitted.\n */\n keysToOmit?: Array<string> | null\n /**\n * Serialization settings per body property that sets at least one field in the spec's `encoding`.\n */\n encoding?: Record<string, EncodingNode>\n examples?: Array<ExampleNode>\n /**\n * Serialization of the first parts by position, for a body sent as an array of parts such as `multipart/mixed`.\n */\n prefixEncoding?: Array<EncodingNode>\n /**\n * Serialization of every part after `prefixEncoding`, for a body sent as an array of parts such as `multipart/mixed`.\n */\n itemEncoding?: EncodingNode\n /** Vendor extensions (`x-*` keys) from the source media type, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\n/**\n * Creates a `ContentNode` for a single request-body or response content type.\n */\nexport const createContent = nodeFactory<ContentNode>(nodeKinds.content)\n","import { nodeKinds } from '../constants.ts'\nimport type { BaseNode } from './base.ts'\nimport type { OperationNode } from './operation.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * A variable declared by a server URL template.\n */\nexport type InputServerVariable = {\n default?: string\n enum?: Array<string>\n description?: string\n}\n\n/**\n * A server from the source document, with `{variable}` placeholders filled from their defaults.\n */\nexport type InputServer = {\n url: string\n name?: string\n description?: string\n /**\n * Variables of the source URL template, copied as-is. `url` already has their defaults filled in, so\n * this tells a templated server apart from a literal one. Absent when the server declares none.\n */\n variables?: Record<string, InputServerVariable>\n}\n\nexport type ExternalDocs = { url: string; description?: string }\n\nexport type InputTag = {\n name: string\n summary?: string\n description?: string\n /**\n * Name of the tag this tag nests under. `group: { type: 'tag' }` places its files in the parent's folder.\n */\n parent?: string\n kind?: string\n externalDocs?: ExternalDocs\n}\n\nexport type OAuthFlow = {\n authorizationUrl?: string\n deviceAuthorizationUrl?: string\n tokenUrl?: string\n refreshUrl?: string\n scopes?: Record<string, string>\n}\n\n/**\n * How a client sends a credential, in the same shape as the `Auth` object the generated clients pass to `auth`.\n */\nexport type AuthCredential =\n | { type: 'http'; scheme: 'bearer' | 'basic' | (string & {}); bearerFormat?: string }\n | { type: 'apiKey'; in: 'header' | 'query' | 'cookie'; name: string }\n | { type: 'oauth2'; flows: Record<string, OAuthFlow>; metadataUrl?: string }\n | { type: 'openIdConnect'; url?: string }\n | { type: 'mutualTLS' }\n\n/**\n * One way to authenticate, keyed by `name`, which operations refer to in `auth`.\n */\nexport type AuthScheme = {\n name: string\n description?: string\n deprecated?: boolean\n credential: AuthCredential\n}\n\n/**\n * One way to meet an operation's auth. Every scheme in it applies together. `scopes` are the OAuth2 or OpenID\n * Connect scopes the call needs. An empty list means the call may be sent without credentials.\n */\nexport type AuthRequirement = Array<{ scheme: string; scopes?: Array<string> }>\n\n/**\n * Metadata for an API document, populated by the adapter and available to every generator.\n * Every field is a plain JSON value.\n *\n * @example\n * ```ts\n * const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://api.example.com/v2' }\n * ```\n */\nexport type InputMeta = {\n /**\n * API title from `info.title` in the source document.\n */\n title?: string\n /**\n * API description from `info.description` in the source document.\n */\n description?: string\n /**\n * API version string from `info.version` in the source document.\n */\n version?: string\n summary?: string\n termsOfService?: string\n contact?: { name?: string; url?: string; email?: string }\n license?: { name: string; identifier?: string; url?: string }\n externalDocs?: ExternalDocs\n /**\n * Resolved base URL from the first matching server entry in the source document.\n */\n baseURL?: string | null\n /**\n * The server index the adapter was configured with. A plugin uses it to pick the server at the same position in an\n * operation's or a path's own `servers`. It counts the source document's entries, including any without a URL.\n * Absent when the adapter was given no index.\n */\n serverIndex?: number\n servers?: Array<InputServer>\n tags?: Array<InputTag>\n auth?: Array<AuthScheme>\n /**\n * Vendor extensions (`x-*` keys) from the document root, copied as-is. Absent when the root has none.\n */\n extensions?: Record<string, unknown>\n}\n\n/**\n * Input AST node that contains all schemas and operations for one API document.\n * Produced by the adapter and consumed by all Kubb plugins.\n *\n * @example\n * ```ts\n * const input: InputNode = {\n * kind: 'Input',\n * schemas: [],\n * operations: [],\n * meta: {},\n * }\n * ```\n */\nexport type InputNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Input'\n /**\n * All schema nodes in the document.\n */\n schemas: Array<SchemaNode>\n /**\n * All operation nodes in the document.\n */\n operations: Array<OperationNode>\n /**\n * Document metadata populated by the adapter.\n */\n meta: InputMeta\n}\n\n/**\n * Creates an `InputNode`, defaulting `schemas`/`operations` to empty arrays and `meta` to an empty\n * object. Every call allocates fresh defaults so no two inputs share them.\n *\n * @example\n * ```ts\n * const input = createInput()\n * // { kind: 'Input', schemas: [], operations: [] }\n * ```\n */\nexport function createInput(overrides: Partial<Omit<InputNode, 'kind'>> = {}): InputNode {\n return { schemas: [], operations: [], meta: {}, ...overrides, kind: nodeKinds.input }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\nimport type { ContentNode } from './content.ts'\n\n/**\n * AST node representing an operation request body.\n *\n * Body schemas live exclusively inside the `content` array (one entry per content type),\n * mirroring {@link ResponseNode}.\n *\n * @example\n * ```ts\n * const requestBody: RequestBodyNode = {\n * kind: 'RequestBody',\n * required: true,\n * content: [{ kind: 'Content', contentType: 'application/json', schema: createSchema({ type: 'string' }) }],\n * }\n * ```\n */\nexport type RequestBodyNode = BaseNode & {\n kind: 'RequestBody'\n /**\n * Request body description carried over from the spec.\n */\n description?: string\n /**\n * Whether the request body is required (`requestBody.required: true` in the spec).\n * When `false` or absent, the generated `data` parameter should be optional.\n */\n required?: boolean\n /**\n * Content type entries for this request body.\n *\n * When the adapter `contentType` option is set, this array contains exactly one entry for\n * that content type. Otherwise it contains one entry per content type declared in the spec,\n * so plugins can generate code for every variant (for example, separate hooks for\n * `application/json` and `multipart/form-data`).\n */\n content?: Array<ContentNode>\n /** Vendor extensions (`x-*` keys) from the source request body, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\n/**\n * Creates a `RequestBodyNode`.\n */\nexport const createRequestBody = nodeFactory<RequestBodyNode>(nodeKinds.requestBody)\n","import { nodeKinds } from '../constants.ts'\nimport type { BaseNode } from './base.ts'\nimport type { AuthRequirement, ExternalDocs, InputServer } from './input.ts'\nimport type { ParameterNode } from './parameter.ts'\nimport { createRequestBody, type RequestBodyNode } from './requestBody.ts'\nimport type { ResponseNode } from './response.ts'\n\n/**\n * HTTP method an operation responds to. `QUERY` is the safe, idempotent method with a request body\n * from RFC 10008, declared with the `query` field of an OpenAPI 3.2 path item. Any other name is a\n * method the source declares outside this fixed set, in the capitalization it is sent with.\n */\nexport type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'QUERY' | (string & {})\n\n/**\n * Fields shared by every operation, regardless of transport.\n */\nexport type OperationNodeBase = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Operation'\n /**\n * Stable identifier for the operation.\n */\n operationId: string\n /**\n * Group labels for the operation.\n */\n tags: Array<string>\n /**\n * Short one-line operation summary.\n */\n summary?: string\n /**\n * Full operation description.\n */\n description?: string\n /**\n * Marks the operation as deprecated.\n */\n deprecated?: boolean\n externalDocs?: ExternalDocs\n /**\n * Query, path, header, and cookie parameters for the operation.\n */\n parameters: Array<ParameterNode>\n /**\n * Request body for the operation.\n */\n requestBody?: RequestBodyNode\n /**\n * Operation responses.\n */\n responses: Array<ResponseNode>\n /**\n * Vendor extensions (`x-*` keys) from the source operation, copied as-is. Absent when the source has none.\n */\n extensions?: Record<string, unknown>\n /** The operation's own `servers`, else its path item's, such as an upload host. Absent when neither declares any. */\n servers?: Array<InputServer>\n /**\n * Ways to authenticate, from the operation or else the document. Any one entry is enough. `[]` means no auth.\n */\n auth?: Array<AuthRequirement>\n}\n\n/**\n * Operation served over HTTP. `method` and `path` are guaranteed.\n *\n * @example\n * ```ts\n * const operation: HttpOperationNode = {\n * kind: 'Operation',\n * operationId: 'listPets',\n * protocol: 'http',\n * method: 'GET',\n * path: '/pets',\n * tags: [],\n * parameters: [],\n * responses: [],\n * }\n * ```\n */\nexport type HttpOperationNode = OperationNodeBase & {\n /**\n * Transport the operation belongs to.\n */\n protocol?: 'http'\n /**\n * HTTP method like `'GET'`.\n */\n method: HttpMethod\n /**\n * Path string, for example `/pets/{petId}`, with `{param}` notation preserved.\n */\n path: string\n}\n\n/**\n * Operation for a non-HTTP transport. HTTP-only fields are forbidden.\n */\nexport type GenericOperationNode = OperationNodeBase & {\n protocol?: never\n method?: never\n path?: never\n}\n\n/**\n * AST node representing one API operation.\n *\n * Discriminated on `protocol`: an {@link HttpOperationNode} (`protocol: 'http'`) guarantees\n * `method` and `path`, while a {@link GenericOperationNode} omits them. Narrow with\n * `ast.http.isOperation(node)` or `node.protocol === 'http'` before reading `method`/`path`.\n */\nexport type OperationNode = HttpOperationNode | GenericOperationNode\n\nexport type OperationInput = {\n operationId: string\n method?: HttpOperationNode['method']\n path?: HttpOperationNode['path']\n requestBody?: Omit<RequestBodyNode, 'kind'>\n [key: string]: unknown\n}\n\n/**\n * Creates an `OperationNode` with default empty arrays for `tags`, `parameters`, and `responses`.\n * HTTP operations (those carrying both `method` and `path`) are tagged with `protocol: 'http'`,\n * and the request body is normalized into a `RequestBodyNode`.\n *\n * @example\n * ```ts\n * const operation = createOperation({ operationId: 'getPetById', method: 'GET', path: '/pet/{petId}' })\n * // tags, parameters, and responses are []\n * ```\n */\nexport function createOperation(\n props: Pick<HttpOperationNode, 'operationId' | 'method' | 'path'> &\n Partial<Omit<HttpOperationNode, 'kind' | 'operationId' | 'method' | 'path' | 'requestBody'>> & {\n requestBody?: Omit<RequestBodyNode, 'kind'>\n },\n): HttpOperationNode\nexport function createOperation(\n props: Pick<GenericOperationNode, 'operationId'> &\n Partial<Omit<GenericOperationNode, 'kind' | 'operationId' | 'requestBody'>> & {\n requestBody?: Omit<RequestBodyNode, 'kind'>\n },\n): GenericOperationNode\nexport function createOperation(props: OperationInput): OperationNode {\n const { requestBody, ...rest } = props\n const isHttp = rest.method !== undefined && rest.path !== undefined\n\n const node = {\n tags: [],\n parameters: [],\n responses: [],\n ...rest,\n kind: nodeKinds.operation,\n ...(isHttp ? { protocol: 'http' as const } : {}),\n requestBody: requestBody ? createRequestBody(requestBody) : undefined,\n }\n\n return node as OperationNode\n}\n\n/**\n * The operations a plugin keeps, as one node. A template with `kind: 'Operations'` gets it once, after every operation.\n */\nexport type OperationsNode = BaseNode & {\n kind: 'Operations'\n operations: Array<OperationNode>\n}\n\n/**\n * Creates an `OperationsNode` for a list of operations.\n *\n * @example\n * ```ts\n * const node = createOperations({ operations: [listPets, getPetById] })\n * // { kind: 'Operations', operations: [...] }\n * ```\n */\nexport function createOperations({ operations }: { operations: Array<OperationNode> }): OperationsNode {\n return { kind: nodeKinds.operations, operations }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { applyOptionality } from '../optionality.ts'\nimport type { BaseNode } from './base.ts'\nimport type { EncodingNode, ExampleNode } from './content.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * Where a parameter is sent. `querystring` carries the whole query string as one value, serialized per `contentType`.\n */\nexport type ParameterLocation = 'path' | 'query' | 'header' | 'cookie' | 'querystring'\n\n/**\n * Parameter serialization style, controlling how a parameter value is rendered into the request.\n */\nexport type ParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject' | 'cookie'\n\n/**\n * AST node representing one operation parameter.\n *\n * @example\n * ```ts\n * const param: ParameterNode = {\n * kind: 'Parameter',\n * name: 'petId',\n * in: 'path',\n * schema: createSchema({ type: 'string' }),\n * required: true,\n * }\n * ```\n */\nexport type ParameterNode = BaseNode & {\n kind: 'Parameter'\n /**\n * Parameter name.\n */\n name: string\n /**\n * Parameter location (`path`, `query`, `header`, `cookie`, or `querystring`).\n */\n in: ParameterLocation\n /**\n * Parameter schema.\n */\n schema: SchemaNode\n /**\n * Whether the parameter is required.\n */\n required: boolean\n /**\n * Serialization style. Absent when the source omits it, leaving consumers to apply the\n * per-location default.\n */\n style?: ParameterStyle\n /**\n * Whether array and object values expand into separate values. Absent when the source omits it,\n * leaving consumers to apply the default for the style.\n */\n explode?: boolean\n /**\n * Whether reserved characters (RFC 3986 `:/?#[]@!$&'()*+,;=`) are sent as-is instead of\n * percent-encoded. Absent when the source omits it.\n */\n allowReserved?: boolean\n /**\n * Media type of a parameter described with `content` instead of `schema`, for example\n * `application/json` when the value is sent as a JSON-encoded string. Absent for `schema` parameters.\n */\n contentType?: string\n /**\n * Serialization settings per property of a `content` parameter, from the `encoding` of its media type. An OpenAPI 3.2\n * `querystring` parameter sent as `application/x-www-form-urlencoded` uses it to set `style` and `explode` per field.\n */\n encoding?: Record<string, EncodingNode>\n examples?: Array<ExampleNode>\n deprecated?: boolean\n allowEmptyValue?: boolean\n /** Vendor extensions (`x-*` keys) from the source parameter, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\nexport type UserParameterNode = Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial<Omit<ParameterNode, 'kind' | 'name' | 'in' | 'schema'>>\n\n/**\n * Creates a `ParameterNode`. `required` defaults to `false`, and the schema's\n * `optional`/`nullish` flags are derived from it.\n *\n * @example\n * ```ts\n * const param = createParameter({\n * name: 'petId',\n * in: 'path',\n * required: true,\n * schema: createSchema({ type: 'string' }),\n * })\n * ```\n */\nexport function createParameter(input: UserParameterNode): ParameterNode {\n const required = input.required ?? false\n\n return { ...input, required, schema: applyOptionality(input.schema, required), kind: nodeKinds.parameter }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { applyOptionality } from '../optionality.ts'\nimport type { BaseNode } from './base.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * AST node representing one named object property.\n *\n * @example\n * ```ts\n * const property: PropertyNode = {\n * kind: 'Property',\n * name: 'id',\n * schema: createSchema({ type: 'integer' }),\n * required: true,\n * }\n * ```\n */\nexport type PropertyNode = BaseNode & {\n kind: 'Property'\n /**\n * Property key.\n */\n name: string\n /**\n * Property schema.\n */\n schema: SchemaNode\n /**\n * Whether the property is required.\n */\n required: boolean\n}\n\n/**\n * Loosely-typed property accepted by `createProperty`, with `required` optional.\n */\nexport type UserPropertyNode = Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<PropertyNode, 'kind' | 'name' | 'schema'>>\n\n/**\n * Creates a `PropertyNode`. `required` defaults to `false`, and the schema's\n * `optional`/`nullish` flags are derived from it.\n *\n * @example\n * ```ts\n * const property = createProperty({\n * name: 'status',\n * required: true,\n * schema: createSchema({ type: 'string', nullable: true }),\n * })\n * // required=true, no optional/nullish\n * ```\n */\nexport function createProperty(input: UserPropertyNode): PropertyNode {\n const required = input.required ?? false\n\n return { ...input, required, schema: applyOptionality(input.schema, required), kind: nodeKinds.property }\n}\n","import { nodeKinds } from '../constants.ts'\nimport type { BaseNode } from './base.ts'\nimport { type ContentNode, createContent } from './content.ts'\nimport type { InputServer } from './input.ts'\nimport type { ParameterNode } from './parameter.ts'\nimport type { SchemaNode } from './schema.ts'\n\nexport type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\n\n/**\n * Response status code literal used by operations.\n *\n * Includes three-digit HTTP status code strings, ranges such as `\"2xx\"`, and `\"default\"` for catch-all responses.\n *\n * @example\n * ```ts\n * const status: StatusCode = '200'\n * const fallback: StatusCode = 'default'\n * ```\n */\nexport type StatusCode = `${1 | 2 | 3 | 4 | 5}${Digit}${Digit}` | `${1 | 2 | 3 | 4 | 5}xx` | 'default'\n\n/**\n * AST node representing one operation response variant.\n *\n * Mirrors {@link OperationNode.requestBody}: the response body schemas live exclusively inside\n * the `content` array (one entry per content type), so the same schema is never duplicated at the\n * node root and inside `content`.\n *\n * @example\n * ```ts\n * const response: ResponseNode = {\n * kind: 'Response',\n * statusCode: '200',\n * content: [{ kind: 'Content', contentType: 'application/json', schema: createSchema({ type: 'string' }) }],\n * }\n * ```\n */\nexport type ResponseNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Response'\n /**\n * HTTP status code or `'default'` for a fallback response.\n */\n statusCode: StatusCode\n summary?: string\n /**\n * Optional response description.\n */\n description?: string\n /**\n * All available content type entries for this response.\n *\n * For a response that declares content, the array holds exactly one entry for the adapter\n * `contentType` option when it is set. Otherwise it holds one entry per content type declared in\n * the spec, so that plugins can generate a union of response types (e.g. `application/json` and\n * `application/xml`). A body-less response always keeps a single entry whose `contentType` is `''`\n * and whose `schema` is the empty/`void` placeholder, even when the option is set.\n *\n * @example\n * ```ts\n * // spec response declares both application/json and application/xml\n * response.content[0].contentType // 'application/json'\n * response.content[1].contentType // 'application/xml'\n * ```\n */\n content?: Array<ContentNode>\n /**\n * Response headers, as `in: 'header'` parameters. `Content-Type` is left out.\n */\n headers?: Array<ParameterNode>\n links?: Record<string, ResponseLink>\n /** Vendor extensions (`x-*` keys) from the source response, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\n/**\n * A link to another operation. `parameters` and `requestBody` hold runtime expressions such as `$response.body#/id`.\n */\nexport type ResponseLink = {\n operationId?: string\n operationRef?: string\n parameters?: Record<string, unknown>\n requestBody?: unknown\n description?: string\n server?: InputServer\n}\n\nexport type ResponseInput = Pick<ResponseNode, 'statusCode'> &\n Partial<Omit<ResponseNode, 'kind' | 'statusCode' | 'content'>> & {\n content?: Array<ContentNode>\n schema?: SchemaNode\n mediaType?: string | null\n keysToOmit?: Array<string> | null\n }\n\n/**\n * Creates a `ResponseNode`. A single legacy `schema` (with optional `mediaType`/`keysToOmit`)\n * is normalized into one `content` entry.\n *\n * @example\n * ```ts\n * const response = createResponse({\n * statusCode: '200',\n * content: [createContent({ contentType: 'application/json', schema: createSchema({ type: 'object', properties: [] }) })],\n * })\n * ```\n */\nexport function createResponse(props: ResponseInput): ResponseNode {\n const { schema, mediaType, keysToOmit, content, ...rest } = props\n const entries = content ?? (schema ? [createContent({ contentType: mediaType ?? 'application/json', schema, keysToOmit: keysToOmit ?? null })] : undefined)\n\n return { ...rest, content: entries, kind: nodeKinds.response }\n}\n","import type { ArrowFunctionNode, BreakNode, ConstNode, FunctionNode, JsxNode, TextNode, TypeNode } from './code.ts'\nimport type { ContentNode } from './content.ts'\nimport type { ExportNode, FileNode, ImportNode, SourceNode } from './file.ts'\nimport type { InputNode } from './input.ts'\nimport type { OperationNode, OperationsNode } from './operation.ts'\nimport type { ParameterNode } from './parameter.ts'\nimport type { PropertyNode } from './property.ts'\nimport type { RequestBodyNode } from './requestBody.ts'\nimport type { ResponseNode } from './response.ts'\nimport type { SchemaNode } from './schema.ts'\n\nexport { createArrowFunction, createBreak, createConst, createFunction, createJsx, createText, createType } from './code.ts'\nexport { createContent } from './content.ts'\nexport { createExport, createFile, createImport, createSource } from './file.ts'\nexport type { ExportInput, ImportInput, ModuleName, Space, UserFileNode } from './file.ts'\nexport { createInput } from './input.ts'\nexport { createOperation, createOperations } from './operation.ts'\nexport { createParameter } from './parameter.ts'\nexport { createProperty } from './property.ts'\nexport { createRequestBody } from './requestBody.ts'\nexport { createResponse } from './response.ts'\nexport { createSchema } from './schema.ts'\n\n/**\n * Union of all AST node types.\n *\n * This lets TypeScript narrow types in `switch (node.kind)` blocks.\n *\n * @example\n * ```ts\n * function getKind(node: Node): string {\n * switch (node.kind) {\n * case nodeKinds.input:\n * return 'input'\n * default:\n * return 'other'\n * }\n * }\n * ```\n */\nexport type Node =\n | InputNode\n | OperationNode\n | OperationsNode\n | SchemaNode\n | PropertyNode\n | ParameterNode\n | ResponseNode\n | RequestBodyNode\n | ContentNode\n | FileNode\n | ImportNode\n | ExportNode\n | SourceNode\n | ConstNode\n | TypeNode\n | FunctionNode\n | ArrowFunctionNode\n | TextNode\n | BreakNode\n | JsxNode\n"],"mappings":";;;;;;;;;;;;;;;AAmQA,MAAa,cAAc,YAAuB,UAAU,KAAK;;;;;;;;;;AAWjE,MAAa,aAAa,YAAsB,UAAU,IAAI;;;;;;;;;;AAW9D,MAAa,iBAAiB,YAA0B,UAAU,QAAQ;;;;;;;;;;AAW1E,MAAa,sBAAsB,YAA+B,UAAU,aAAa;;;;;;;;;;AAWzF,SAAgB,WAAW,OAAyB;CAClD,OAAO;EAAE,MAAM,UAAU;EAAM;CAAM;AACvC;;;;;;;;;;AAWA,SAAgB,cAAyB;CACvC,OAAO,EAAE,MAAM,UAAU,MAAM;AACjC;;;;;;;;;;AAWA,SAAgB,UAAU,OAAwB;CAChD,OAAO;EAAE,MAAM,UAAU;EAAK;CAAM;AACtC;;;;;ACjOA,MAAa,gBAAgB,YAAyB,UAAU,OAAO;;;;;;;;;;;;AC2DvE,SAAgB,YAAY,YAA8C,CAAC,GAAc;CACvF,OAAO;EAAE,SAAS,CAAC;EAAG,YAAY,CAAC;EAAG,MAAM,CAAC;EAAG,GAAG;EAAW,MAAM,UAAU;CAAM;AACtF;;;;;ACzHA,MAAa,oBAAoB,YAA6B,UAAU,WAAW;;ACsGnF,SAAgB,gBAAgB,OAAsC;CACpE,MAAM,EAAE,aAAa,GAAG,SAAS;CACjC,MAAM,SAAS,KAAK,WAAW,KAAA,KAAa,KAAK,SAAS,KAAA;CAY1D,OAAO;EATL,MAAM,CAAC;EACP,YAAY,CAAC;EACb,WAAW,CAAC;EACZ,GAAG;EACH,MAAM,UAAU;EAChB,GAAI,SAAS,EAAE,UAAU,OAAgB,IAAI,CAAC;EAC9C,aAAa,cAAc,kBAAkB,WAAW,IAAI,KAAA;CAGpD;AACZ;;;;;;;;;;AAmBA,SAAgB,iBAAiB,EAAE,cAAoE;CACrG,OAAO;EAAE,MAAM,UAAU;EAAY;CAAW;AAClD;;;;;;;;;;;;;;;;ACxFA,SAAgB,gBAAgB,OAAyC;CACvE,MAAM,WAAW,MAAM,YAAY;CAEnC,OAAO;EAAE,GAAG;EAAO;EAAU,QAAQ,iBAAiB,MAAM,QAAQ,QAAQ;EAAG,MAAM,UAAU;CAAU;AAC3G;;;;;;;;;;;;;;;;AC/CA,SAAgB,eAAe,OAAuC;CACpE,MAAM,WAAW,MAAM,YAAY;CAEnC,OAAO;EAAE,GAAG;EAAO;EAAU,QAAQ,iBAAiB,MAAM,QAAQ,QAAQ;EAAG,MAAM,UAAU;CAAS;AAC1G;;;;;;;;;;;;;;ACqDA,SAAgB,eAAe,OAAoC;CACjE,MAAM,EAAE,QAAQ,WAAW,YAAY,SAAS,GAAG,SAAS;CAC5D,MAAM,UAAU,YAAY,SAAS,CAAC,cAAc;EAAE,aAAa,aAAa;EAAoB;EAAQ,YAAY,cAAc;CAAK,CAAC,CAAC,IAAI,KAAA;CAEjJ,OAAO;EAAE,GAAG;EAAM,SAAS;EAAS,MAAM,UAAU;CAAS;AAC/D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
|
|
2
2
|
const require_constants = require("./constants-BCRkFAiy.cjs");
|
|
3
|
-
const
|
|
3
|
+
const require_file = require("./file-Db_PYobC.cjs");
|
|
4
4
|
const require_optionality = require("./optionality-C-qULYxo.cjs");
|
|
5
5
|
const require_schema = require("./schema-0YJZqRXb.cjs");
|
|
6
6
|
// src/nodes/code.ts
|
|
@@ -13,7 +13,7 @@ const require_schema = require("./schema-0YJZqRXb.cjs");
|
|
|
13
13
|
* // export const pets: Pet[] = ... as const
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
const createConst =
|
|
16
|
+
const createConst = require_file.nodeFactory(require_constants.nodeKinds.const);
|
|
17
17
|
/**
|
|
18
18
|
* Creates a `TypeNode` representing a TypeScript `type` alias declaration.
|
|
19
19
|
*
|
|
@@ -23,7 +23,7 @@ const createConst = require_combineFileMembers.nodeFactory(require_constants.nod
|
|
|
23
23
|
* // export type Pet = ...
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
const createType =
|
|
26
|
+
const createType = require_file.nodeFactory(require_constants.nodeKinds.type);
|
|
27
27
|
/**
|
|
28
28
|
* Creates a `FunctionNode` representing a TypeScript `function` declaration.
|
|
29
29
|
*
|
|
@@ -33,7 +33,7 @@ const createType = require_combineFileMembers.nodeFactory(require_constants.node
|
|
|
33
33
|
* // export async function fetchPet(): Promise<Pet> { ... }
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
const createFunction =
|
|
36
|
+
const createFunction = require_file.nodeFactory(require_constants.nodeKinds.function);
|
|
37
37
|
/**
|
|
38
38
|
* Creates an `ArrowFunctionNode` representing a TypeScript arrow function.
|
|
39
39
|
*
|
|
@@ -43,7 +43,7 @@ const createFunction = require_combineFileMembers.nodeFactory(require_constants.
|
|
|
43
43
|
* // export const double = (n: number) => ...
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
const createArrowFunction =
|
|
46
|
+
const createArrowFunction = require_file.nodeFactory(require_constants.nodeKinds.arrowFunction);
|
|
47
47
|
/**
|
|
48
48
|
* Creates a {@link TextNode} representing a raw string fragment in the source output.
|
|
49
49
|
*
|
|
@@ -90,7 +90,7 @@ function createJsx(value) {
|
|
|
90
90
|
/**
|
|
91
91
|
* Creates a `ContentNode` for a single request-body or response content type.
|
|
92
92
|
*/
|
|
93
|
-
const createContent =
|
|
93
|
+
const createContent = require_file.nodeFactory(require_constants.nodeKinds.content);
|
|
94
94
|
// src/nodes/input.ts
|
|
95
95
|
/**
|
|
96
96
|
* Creates an `InputNode`, defaulting `schemas`/`operations` to empty arrays and `meta` to an empty
|
|
@@ -115,7 +115,7 @@ function createInput(overrides = {}) {
|
|
|
115
115
|
/**
|
|
116
116
|
* Creates a `RequestBodyNode`.
|
|
117
117
|
*/
|
|
118
|
-
const createRequestBody =
|
|
118
|
+
const createRequestBody = require_file.nodeFactory(require_constants.nodeKinds.requestBody);
|
|
119
119
|
// src/nodes/operation.ts
|
|
120
120
|
function createOperation(props) {
|
|
121
121
|
const { requestBody, ...rest } = props;
|
|
@@ -225,10 +225,10 @@ var nodes_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
|
225
225
|
createBreak: () => createBreak,
|
|
226
226
|
createConst: () => createConst,
|
|
227
227
|
createContent: () => createContent,
|
|
228
|
-
createExport: () =>
|
|
229
|
-
createFile: () =>
|
|
228
|
+
createExport: () => require_file.createExport,
|
|
229
|
+
createFile: () => require_file.createFile,
|
|
230
230
|
createFunction: () => createFunction,
|
|
231
|
-
createImport: () =>
|
|
231
|
+
createImport: () => require_file.createImport,
|
|
232
232
|
createInput: () => createInput,
|
|
233
233
|
createJsx: () => createJsx,
|
|
234
234
|
createOperation: () => createOperation,
|
|
@@ -238,7 +238,7 @@ var nodes_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
|
238
238
|
createRequestBody: () => createRequestBody,
|
|
239
239
|
createResponse: () => createResponse,
|
|
240
240
|
createSchema: () => require_schema.createSchema,
|
|
241
|
-
createSource: () =>
|
|
241
|
+
createSource: () => require_file.createSource,
|
|
242
242
|
createText: () => createText,
|
|
243
243
|
createType: () => createType
|
|
244
244
|
});
|
|
@@ -339,4 +339,4 @@ Object.defineProperty(exports, "nodes_exports", {
|
|
|
339
339
|
}
|
|
340
340
|
});
|
|
341
341
|
|
|
342
|
-
//# sourceMappingURL=nodes-
|
|
342
|
+
//# sourceMappingURL=nodes-BjVv21pb.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes-BGxHocS_.cjs","names":["nodeFactory","nodeKinds","nodeFactory","nodeKinds","nodeKinds","nodeFactory","nodeKinds","nodeKinds","applyOptionality","nodeKinds","applyOptionality","nodeKinds","nodeKinds"],"sources":["../src/nodes/code.ts","../src/nodes/content.ts","../src/nodes/input.ts","../src/nodes/requestBody.ts","../src/nodes/operation.ts","../src/nodes/parameter.ts","../src/nodes/property.ts","../src/nodes/response.ts","../src/nodes/index.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\n\n/**\n * JSDoc documentation metadata attached to code declarations.\n */\nexport type JSDocNode = {\n /**\n * JSDoc comment lines. `undefined` entries are filtered out during rendering.\n *\n * @example\n * ```ts\n * ['@description A pet resource', '@deprecated']\n * ```\n */\n comments?: Array<string | undefined>\n}\n\n/**\n * AST node representing a TypeScript `const` declaration.\n *\n * Mirrors the props of the `Const` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createConst({ name: 'pet', export: true, asConst: true })\n * // export const pet = ... as const\n * ```\n */\nexport type ConstNode = BaseNode & {\n kind: 'Const'\n /**\n * Name of the constant declaration.\n */\n name: string\n /**\n * Whether the declaration should be exported.\n */\n export?: boolean | null\n /**\n * Explicit type annotation.\n *\n * @example Type reference\n * `'Pet'`\n */\n type?: string | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Whether to append `as const` to the declaration.\n */\n asConst?: boolean | null\n /**\n * Child nodes representing the value of the constant (children of the `Const` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript `type` alias declaration.\n *\n * Mirrors the props of the `Type` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createType({ name: 'Pet', export: true })\n * // export type Pet = ...\n * ```\n */\nexport type TypeNode = BaseNode & {\n kind: 'Type'\n /**\n * Name of the type alias.\n */\n name: string\n /**\n * Whether the declaration should be exported.\n */\n export?: boolean | null\n /**\n * How the declaration is written.\n * - `'type'` declares `type Name = …`\n * - `'interface'` declares `interface Name { … }`, so the body must be an object type\n *\n * @default 'type'\n */\n syntax?: 'type' | 'interface' | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Child nodes representing the type body (children of the `Type` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript `function` declaration.\n *\n * Mirrors the props of the `Function` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createFunction({ name: 'getPet', export: true, async: true, returnType: 'Pet' })\n * // export async function getPet(): Promise<Pet> { ... }\n * ```\n */\nexport type FunctionNode = BaseNode & {\n kind: 'Function'\n /**\n * Name of the function.\n */\n name: string\n /**\n * Whether the function is a default export.\n */\n default?: boolean | null\n /**\n * Function parameter list as a pre-rendered string, written verbatim between the parentheses.\n *\n * @example\n * `'id: string, config: Config = {}'`\n */\n params?: string | null\n /**\n * Whether the function should be exported.\n */\n export?: boolean | null\n /**\n * Whether the function is async. When `true`, the return type is wrapped in `Promise<>`.\n */\n async?: boolean | null\n /**\n * TypeScript generic type parameters.\n *\n * @example Constrained generics\n * `['T', 'U extends string']`\n */\n generics?: string | Array<string> | null\n /**\n * Return type annotation.\n *\n * @example Type reference\n * `'Pet'`\n */\n returnType?: string | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Child nodes representing the function body (children of the `Function` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript arrow function (`const name = () => { ... }`).\n *\n * Mirrors the props of the `Function.Arrow` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createArrowFunction({ name: 'getPet', export: true, singleLine: true })\n * // export const getPet = () => ...\n * ```\n */\nexport type ArrowFunctionNode = Omit<FunctionNode, 'kind'> & {\n kind: 'ArrowFunction'\n /**\n * Render the arrow function body as a single-line expression.\n */\n singleLine?: boolean | null\n}\n\n/**\n * AST node representing a raw text/string fragment in the source output.\n *\n * Used instead of bare `string` values so that all entries in `nodes` arrays\n * are typed `CodeNode` objects rather than a mixed `CodeNode | string` union.\n *\n * @example\n * ```ts\n * createText('return fetch(id)')\n * // { kind: 'Text', value: 'return fetch(id)' }\n * ```\n */\nexport type TextNode = BaseNode & {\n kind: 'Text'\n /**\n * The raw string content.\n */\n value: string\n}\n\n/**\n * AST node representing a blank line in the source output.\n *\n * Corresponds to `<br/>` in JSX components. `printNodes` turns a `Break` between two\n * statements into one blank line. Consecutive breaks, and breaks at the start or end of\n * the list, are folded away, so a `Break` never produces more than one blank line.\n *\n * @example\n * ```ts\n * createBreak()\n * // { kind: 'Break' }\n * ```\n */\nexport type BreakNode = BaseNode & {\n kind: 'Break'\n}\n\n/**\n * AST node representing a raw JSX fragment in the source output.\n *\n * Mirrors the `Jsx` component from `@kubb/renderer-jsx`. Embeds raw JSX/TSX markup\n * (including fragments `<>…</>`) directly in generated code.\n *\n * @example\n * ```ts\n * createJsx('<>\\n <a href={href}>Open</a>\\n</>')\n * // { kind: 'Jsx', value: '<>\\n <a href={href}>Open</a>\\n</>' }\n * ```\n */\nexport type JsxNode = BaseNode & {\n kind: 'Jsx'\n /**\n * The raw JSX string content.\n */\n value: string\n}\n\n/**\n * Union of all code-generation AST nodes.\n *\n * These nodes mirror the JSX components from `@kubb/renderer-jsx` and are used as\n * structured children in {@link SourceNode.nodes}.\n */\nexport type CodeNode = ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode\n\n/**\n * Creates a `ConstNode` representing a TypeScript `const` declaration.\n *\n * @example Exported constant with type and `as const`\n * ```ts\n * createConst({ name: 'pets', export: true, type: 'Pet[]', asConst: true })\n * // export const pets: Pet[] = ... as const\n * ```\n */\nexport const createConst = nodeFactory<ConstNode>(nodeKinds.const)\n\n/**\n * Creates a `TypeNode` representing a TypeScript `type` alias declaration.\n *\n * @example\n * ```ts\n * createType({ name: 'Pet', export: true })\n * // export type Pet = ...\n * ```\n */\nexport const createType = nodeFactory<TypeNode>(nodeKinds.type)\n\n/**\n * Creates a `FunctionNode` representing a TypeScript `function` declaration.\n *\n * @example\n * ```ts\n * createFunction({ name: 'fetchPet', export: true, async: true, returnType: 'Pet' })\n * // export async function fetchPet(): Promise<Pet> { ... }\n * ```\n */\nexport const createFunction = nodeFactory<FunctionNode>(nodeKinds.function)\n\n/**\n * Creates an `ArrowFunctionNode` representing a TypeScript arrow function.\n *\n * @example\n * ```ts\n * createArrowFunction({ name: 'double', export: true, params: 'n: number', singleLine: true })\n * // export const double = (n: number) => ...\n * ```\n */\nexport const createArrowFunction = nodeFactory<ArrowFunctionNode>(nodeKinds.arrowFunction)\n\n/**\n * Creates a {@link TextNode} representing a raw string fragment in the source output.\n *\n * @example\n * ```ts\n * createText('return fetch(id)')\n * // { kind: 'Text', value: 'return fetch(id)' }\n * ```\n */\nexport function createText(value: string): TextNode {\n return { kind: nodeKinds.text, value }\n}\n\n/**\n * Creates a {@link BreakNode} representing a line break in the source output.\n *\n * @example\n * ```ts\n * createBreak()\n * // { kind: 'Break' }\n * ```\n */\nexport function createBreak(): BreakNode {\n return { kind: nodeKinds.break }\n}\n\n/**\n * Creates a {@link JsxNode} representing a raw JSX fragment in the source output.\n *\n * @example\n * ```ts\n * createJsx('<>\\n <a href={href}>Open</a>\\n</>')\n * // { kind: 'Jsx', value: '<>\\n <a href={href}>Open</a>\\n</>' }\n * ```\n */\nexport function createJsx(value: string): JsxNode {\n return { kind: nodeKinds.jsx, value }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\nimport type { ParameterStyle } from './parameter.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * How one body property is serialized, from the `encoding` entry of its media type.\n */\nexport type EncodingNode = {\n /**\n * Content type of the part, for example `'application/json'` for a multipart property.\n */\n contentType?: string\n /**\n * Serialization style of the property.\n */\n style?: ParameterStyle\n /**\n * Whether array and object values expand into separate values.\n */\n explode?: boolean\n /**\n * Whether reserved characters are sent as-is instead of percent-encoded.\n */\n allowReserved?: boolean\n encoding?: Record<string, EncodingNode>\n prefixEncoding?: Array<EncodingNode>\n itemEncoding?: EncodingNode\n}\n\nexport type ExampleNode = {\n name?: string\n summary?: string\n description?: string\n value?: unknown\n serializedValue?: string\n}\n\n/**\n * AST node representing one content-type entry of a request body or response.\n *\n * There is one entry per content type declared in the spec (e.g. `application/json`,\n * `multipart/form-data`), and each entry holds its own body schema.\n *\n * @example\n * ```ts\n * const content: ContentNode = {\n * kind: 'Content',\n * contentType: 'application/json',\n * schema: createSchema({ type: 'string' }),\n * }\n * ```\n */\nexport type ContentNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Content'\n /**\n * The content type for this entry (e.g. `'application/json'`), or `''` for a response without a body.\n */\n contentType: string\n /**\n * Body schema for this content type. For a stream it is the same node as `stream.schema`.\n */\n schema?: SchemaNode\n /**\n * Set when the content is a stream of items (an event stream, JSON Lines, a channel of messages) instead of one body.\n */\n stream?: {\n /**\n * Schema of one item, such as one event of `text/event-stream` or one line of JSON Lines.\n */\n schema?: SchemaNode\n /**\n * What `schema` describes for an event stream.\n * - `'event'` the parsed event with its `event`, `data`, `id` and `retry` fields\n * - `'data'` only the `data` payload, which the client wraps in its own event type\n */\n shape?: 'event' | 'data'\n }\n /**\n * Property keys to exclude from the generated type via `Omit<Type, Keys>`.\n * Set when a referenced schema has `readOnly`/`writeOnly` fields that should be omitted.\n */\n keysToOmit?: Array<string> | null\n /**\n * Serialization settings per body property that sets at least one field in the spec's `encoding`.\n */\n encoding?: Record<string, EncodingNode>\n examples?: Array<ExampleNode>\n /**\n * Serialization of the first parts by position, for a body sent as an array of parts such as `multipart/mixed`.\n */\n prefixEncoding?: Array<EncodingNode>\n /**\n * Serialization of every part after `prefixEncoding`, for a body sent as an array of parts such as `multipart/mixed`.\n */\n itemEncoding?: EncodingNode\n /** Vendor extensions (`x-*` keys) from the source media type, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\n/**\n * Creates a `ContentNode` for a single request-body or response content type.\n */\nexport const createContent = nodeFactory<ContentNode>(nodeKinds.content)\n","import { nodeKinds } from '../constants.ts'\nimport type { BaseNode } from './base.ts'\nimport type { OperationNode } from './operation.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * A variable declared by a server URL template.\n */\nexport type InputServerVariable = {\n default?: string\n enum?: Array<string>\n description?: string\n}\n\n/**\n * A server from the source document, with `{variable}` placeholders filled from their defaults.\n */\nexport type InputServer = {\n url: string\n name?: string\n description?: string\n /**\n * Variables of the source URL template, copied as-is. `url` already has their defaults filled in, so\n * this tells a templated server apart from a literal one. Absent when the server declares none.\n */\n variables?: Record<string, InputServerVariable>\n}\n\nexport type ExternalDocs = { url: string; description?: string }\n\nexport type InputTag = {\n name: string\n summary?: string\n description?: string\n /**\n * Name of the tag this tag nests under. `group: { type: 'tag' }` places its files in the parent's folder.\n */\n parent?: string\n kind?: string\n externalDocs?: ExternalDocs\n}\n\nexport type OAuthFlow = {\n authorizationUrl?: string\n deviceAuthorizationUrl?: string\n tokenUrl?: string\n refreshUrl?: string\n scopes?: Record<string, string>\n}\n\n/**\n * How a client sends a credential, in the same shape as the `Auth` object the generated clients pass to `auth`.\n */\nexport type AuthCredential =\n | { type: 'http'; scheme: 'bearer' | 'basic' | (string & {}); bearerFormat?: string }\n | { type: 'apiKey'; in: 'header' | 'query' | 'cookie'; name: string }\n | { type: 'oauth2'; flows: Record<string, OAuthFlow>; metadataUrl?: string }\n | { type: 'openIdConnect'; url?: string }\n | { type: 'mutualTLS' }\n\n/**\n * One way to authenticate, keyed by `name`, which operations refer to in `auth`.\n */\nexport type AuthScheme = {\n name: string\n description?: string\n deprecated?: boolean\n credential: AuthCredential\n}\n\n/**\n * One way to meet an operation's auth. Every scheme in it applies together. `scopes` are the OAuth2 or OpenID\n * Connect scopes the call needs. An empty list means the call may be sent without credentials.\n */\nexport type AuthRequirement = Array<{ scheme: string; scopes?: Array<string> }>\n\n/**\n * Metadata for an API document, populated by the adapter and available to every generator.\n * Every field is a plain JSON value.\n *\n * @example\n * ```ts\n * const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://api.example.com/v2' }\n * ```\n */\nexport type InputMeta = {\n /**\n * API title from `info.title` in the source document.\n */\n title?: string\n /**\n * API description from `info.description` in the source document.\n */\n description?: string\n /**\n * API version string from `info.version` in the source document.\n */\n version?: string\n summary?: string\n termsOfService?: string\n contact?: { name?: string; url?: string; email?: string }\n license?: { name: string; identifier?: string; url?: string }\n externalDocs?: ExternalDocs\n /**\n * Resolved base URL from the first matching server entry in the source document.\n */\n baseURL?: string | null\n /**\n * The server index the adapter was configured with. A plugin uses it to pick the server at the same position in an\n * operation's or a path's own `servers`. It counts the source document's entries, including any without a URL.\n * Absent when the adapter was given no index.\n */\n serverIndex?: number\n servers?: Array<InputServer>\n tags?: Array<InputTag>\n auth?: Array<AuthScheme>\n /**\n * Vendor extensions (`x-*` keys) from the document root, copied as-is. Absent when the root has none.\n */\n extensions?: Record<string, unknown>\n}\n\n/**\n * Input AST node that contains all schemas and operations for one API document.\n * Produced by the adapter and consumed by all Kubb plugins.\n *\n * @example\n * ```ts\n * const input: InputNode = {\n * kind: 'Input',\n * schemas: [],\n * operations: [],\n * meta: {},\n * }\n * ```\n */\nexport type InputNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Input'\n /**\n * All schema nodes in the document.\n */\n schemas: Array<SchemaNode>\n /**\n * All operation nodes in the document.\n */\n operations: Array<OperationNode>\n /**\n * Document metadata populated by the adapter.\n */\n meta: InputMeta\n}\n\n/**\n * Creates an `InputNode`, defaulting `schemas`/`operations` to empty arrays and `meta` to an empty\n * object. Every call allocates fresh defaults so no two inputs share them.\n *\n * @example\n * ```ts\n * const input = createInput()\n * // { kind: 'Input', schemas: [], operations: [] }\n * ```\n */\nexport function createInput(overrides: Partial<Omit<InputNode, 'kind'>> = {}): InputNode {\n return { schemas: [], operations: [], meta: {}, ...overrides, kind: nodeKinds.input }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\nimport type { ContentNode } from './content.ts'\n\n/**\n * AST node representing an operation request body.\n *\n * Body schemas live exclusively inside the `content` array (one entry per content type),\n * mirroring {@link ResponseNode}.\n *\n * @example\n * ```ts\n * const requestBody: RequestBodyNode = {\n * kind: 'RequestBody',\n * required: true,\n * content: [{ kind: 'Content', contentType: 'application/json', schema: createSchema({ type: 'string' }) }],\n * }\n * ```\n */\nexport type RequestBodyNode = BaseNode & {\n kind: 'RequestBody'\n /**\n * Request body description carried over from the spec.\n */\n description?: string\n /**\n * Whether the request body is required (`requestBody.required: true` in the spec).\n * When `false` or absent, the generated `data` parameter should be optional.\n */\n required?: boolean\n /**\n * Content type entries for this request body.\n *\n * When the adapter `contentType` option is set, this array contains exactly one entry for\n * that content type. Otherwise it contains one entry per content type declared in the spec,\n * so plugins can generate code for every variant (for example, separate hooks for\n * `application/json` and `multipart/form-data`).\n */\n content?: Array<ContentNode>\n /** Vendor extensions (`x-*` keys) from the source request body, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\n/**\n * Creates a `RequestBodyNode`.\n */\nexport const createRequestBody = nodeFactory<RequestBodyNode>(nodeKinds.requestBody)\n","import { nodeKinds } from '../constants.ts'\nimport type { BaseNode } from './base.ts'\nimport type { AuthRequirement, ExternalDocs, InputServer } from './input.ts'\nimport type { ParameterNode } from './parameter.ts'\nimport { createRequestBody, type RequestBodyNode } from './requestBody.ts'\nimport type { ResponseNode } from './response.ts'\n\n/**\n * HTTP method an operation responds to. `QUERY` is the safe, idempotent method with a request body\n * from RFC 10008, declared with the `query` field of an OpenAPI 3.2 path item. Any other name is a\n * method the source declares outside this fixed set, in the capitalization it is sent with.\n */\nexport type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'QUERY' | (string & {})\n\n/**\n * Fields shared by every operation, regardless of transport.\n */\nexport type OperationNodeBase = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Operation'\n /**\n * Stable identifier for the operation.\n */\n operationId: string\n /**\n * Group labels for the operation.\n */\n tags: Array<string>\n /**\n * Short one-line operation summary.\n */\n summary?: string\n /**\n * Full operation description.\n */\n description?: string\n /**\n * Marks the operation as deprecated.\n */\n deprecated?: boolean\n externalDocs?: ExternalDocs\n /**\n * Query, path, header, and cookie parameters for the operation.\n */\n parameters: Array<ParameterNode>\n /**\n * Request body for the operation.\n */\n requestBody?: RequestBodyNode\n /**\n * Operation responses.\n */\n responses: Array<ResponseNode>\n /**\n * Vendor extensions (`x-*` keys) from the source operation, copied as-is. Absent when the source has none.\n */\n extensions?: Record<string, unknown>\n /** The operation's own `servers`, else its path item's, such as an upload host. Absent when neither declares any. */\n servers?: Array<InputServer>\n /**\n * Ways to authenticate, from the operation or else the document. Any one entry is enough. `[]` means no auth.\n */\n auth?: Array<AuthRequirement>\n}\n\n/**\n * Operation served over HTTP. `method` and `path` are guaranteed.\n *\n * @example\n * ```ts\n * const operation: HttpOperationNode = {\n * kind: 'Operation',\n * operationId: 'listPets',\n * protocol: 'http',\n * method: 'GET',\n * path: '/pets',\n * tags: [],\n * parameters: [],\n * responses: [],\n * }\n * ```\n */\nexport type HttpOperationNode = OperationNodeBase & {\n /**\n * Transport the operation belongs to.\n */\n protocol?: 'http'\n /**\n * HTTP method like `'GET'`.\n */\n method: HttpMethod\n /**\n * Path string, for example `/pets/{petId}`, with `{param}` notation preserved.\n */\n path: string\n}\n\n/**\n * Operation for a non-HTTP transport. HTTP-only fields are forbidden.\n */\nexport type GenericOperationNode = OperationNodeBase & {\n protocol?: never\n method?: never\n path?: never\n}\n\n/**\n * AST node representing one API operation.\n *\n * Discriminated on `protocol`: an {@link HttpOperationNode} (`protocol: 'http'`) guarantees\n * `method` and `path`, while a {@link GenericOperationNode} omits them. Narrow with\n * `ast.http.isOperation(node)` or `node.protocol === 'http'` before reading `method`/`path`.\n */\nexport type OperationNode = HttpOperationNode | GenericOperationNode\n\nexport type OperationInput = {\n operationId: string\n method?: HttpOperationNode['method']\n path?: HttpOperationNode['path']\n requestBody?: Omit<RequestBodyNode, 'kind'>\n [key: string]: unknown\n}\n\n/**\n * Creates an `OperationNode` with default empty arrays for `tags`, `parameters`, and `responses`.\n * HTTP operations (those carrying both `method` and `path`) are tagged with `protocol: 'http'`,\n * and the request body is normalized into a `RequestBodyNode`.\n *\n * @example\n * ```ts\n * const operation = createOperation({ operationId: 'getPetById', method: 'GET', path: '/pet/{petId}' })\n * // tags, parameters, and responses are []\n * ```\n */\nexport function createOperation(\n props: Pick<HttpOperationNode, 'operationId' | 'method' | 'path'> &\n Partial<Omit<HttpOperationNode, 'kind' | 'operationId' | 'method' | 'path' | 'requestBody'>> & {\n requestBody?: Omit<RequestBodyNode, 'kind'>\n },\n): HttpOperationNode\nexport function createOperation(\n props: Pick<GenericOperationNode, 'operationId'> &\n Partial<Omit<GenericOperationNode, 'kind' | 'operationId' | 'requestBody'>> & {\n requestBody?: Omit<RequestBodyNode, 'kind'>\n },\n): GenericOperationNode\nexport function createOperation(props: OperationInput): OperationNode {\n const { requestBody, ...rest } = props\n const isHttp = rest.method !== undefined && rest.path !== undefined\n\n const node = {\n tags: [],\n parameters: [],\n responses: [],\n ...rest,\n kind: nodeKinds.operation,\n ...(isHttp ? { protocol: 'http' as const } : {}),\n requestBody: requestBody ? createRequestBody(requestBody) : undefined,\n }\n\n return node as OperationNode\n}\n\n/**\n * The operations a plugin keeps, as one node. A template with `kind: 'Operations'` gets it once, after every operation.\n */\nexport type OperationsNode = BaseNode & {\n kind: 'Operations'\n operations: Array<OperationNode>\n}\n\n/**\n * Creates an `OperationsNode` for a list of operations.\n *\n * @example\n * ```ts\n * const node = createOperations({ operations: [listPets, getPetById] })\n * // { kind: 'Operations', operations: [...] }\n * ```\n */\nexport function createOperations({ operations }: { operations: Array<OperationNode> }): OperationsNode {\n return { kind: nodeKinds.operations, operations }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { applyOptionality } from '../optionality.ts'\nimport type { BaseNode } from './base.ts'\nimport type { EncodingNode, ExampleNode } from './content.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * Where a parameter is sent. `querystring` carries the whole query string as one value, serialized per `contentType`.\n */\nexport type ParameterLocation = 'path' | 'query' | 'header' | 'cookie' | 'querystring'\n\n/**\n * Parameter serialization style, controlling how a parameter value is rendered into the request.\n */\nexport type ParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject' | 'cookie'\n\n/**\n * AST node representing one operation parameter.\n *\n * @example\n * ```ts\n * const param: ParameterNode = {\n * kind: 'Parameter',\n * name: 'petId',\n * in: 'path',\n * schema: createSchema({ type: 'string' }),\n * required: true,\n * }\n * ```\n */\nexport type ParameterNode = BaseNode & {\n kind: 'Parameter'\n /**\n * Parameter name.\n */\n name: string\n /**\n * Parameter location (`path`, `query`, `header`, `cookie`, or `querystring`).\n */\n in: ParameterLocation\n /**\n * Parameter schema.\n */\n schema: SchemaNode\n /**\n * Whether the parameter is required.\n */\n required: boolean\n /**\n * Serialization style. Absent when the source omits it, leaving consumers to apply the\n * per-location default.\n */\n style?: ParameterStyle\n /**\n * Whether array and object values expand into separate values. Absent when the source omits it,\n * leaving consumers to apply the default for the style.\n */\n explode?: boolean\n /**\n * Whether reserved characters (RFC 3986 `:/?#[]@!$&'()*+,;=`) are sent as-is instead of\n * percent-encoded. Absent when the source omits it.\n */\n allowReserved?: boolean\n /**\n * Media type of a parameter described with `content` instead of `schema`, for example\n * `application/json` when the value is sent as a JSON-encoded string. Absent for `schema` parameters.\n */\n contentType?: string\n /**\n * Serialization settings per property of a `content` parameter, from the `encoding` of its media type. An OpenAPI 3.2\n * `querystring` parameter sent as `application/x-www-form-urlencoded` uses it to set `style` and `explode` per field.\n */\n encoding?: Record<string, EncodingNode>\n examples?: Array<ExampleNode>\n deprecated?: boolean\n allowEmptyValue?: boolean\n /** Vendor extensions (`x-*` keys) from the source parameter, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\nexport type UserParameterNode = Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial<Omit<ParameterNode, 'kind' | 'name' | 'in' | 'schema'>>\n\n/**\n * Creates a `ParameterNode`. `required` defaults to `false`, and the schema's\n * `optional`/`nullish` flags are derived from it.\n *\n * @example\n * ```ts\n * const param = createParameter({\n * name: 'petId',\n * in: 'path',\n * required: true,\n * schema: createSchema({ type: 'string' }),\n * })\n * ```\n */\nexport function createParameter(input: UserParameterNode): ParameterNode {\n const required = input.required ?? false\n\n return { ...input, required, schema: applyOptionality(input.schema, required), kind: nodeKinds.parameter }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { applyOptionality } from '../optionality.ts'\nimport type { BaseNode } from './base.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * AST node representing one named object property.\n *\n * @example\n * ```ts\n * const property: PropertyNode = {\n * kind: 'Property',\n * name: 'id',\n * schema: createSchema({ type: 'integer' }),\n * required: true,\n * }\n * ```\n */\nexport type PropertyNode = BaseNode & {\n kind: 'Property'\n /**\n * Property key.\n */\n name: string\n /**\n * Property schema.\n */\n schema: SchemaNode\n /**\n * Whether the property is required.\n */\n required: boolean\n}\n\n/**\n * Loosely-typed property accepted by `createProperty`, with `required` optional.\n */\nexport type UserPropertyNode = Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<PropertyNode, 'kind' | 'name' | 'schema'>>\n\n/**\n * Creates a `PropertyNode`. `required` defaults to `false`, and the schema's\n * `optional`/`nullish` flags are derived from it.\n *\n * @example\n * ```ts\n * const property = createProperty({\n * name: 'status',\n * required: true,\n * schema: createSchema({ type: 'string', nullable: true }),\n * })\n * // required=true, no optional/nullish\n * ```\n */\nexport function createProperty(input: UserPropertyNode): PropertyNode {\n const required = input.required ?? false\n\n return { ...input, required, schema: applyOptionality(input.schema, required), kind: nodeKinds.property }\n}\n","import { nodeKinds } from '../constants.ts'\nimport type { BaseNode } from './base.ts'\nimport { type ContentNode, createContent } from './content.ts'\nimport type { InputServer } from './input.ts'\nimport type { ParameterNode } from './parameter.ts'\nimport type { SchemaNode } from './schema.ts'\n\nexport type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\n\n/**\n * Response status code literal used by operations.\n *\n * Includes three-digit HTTP status code strings, ranges such as `\"2xx\"`, and `\"default\"` for catch-all responses.\n *\n * @example\n * ```ts\n * const status: StatusCode = '200'\n * const fallback: StatusCode = 'default'\n * ```\n */\nexport type StatusCode = `${1 | 2 | 3 | 4 | 5}${Digit}${Digit}` | `${1 | 2 | 3 | 4 | 5}xx` | 'default'\n\n/**\n * AST node representing one operation response variant.\n *\n * Mirrors {@link OperationNode.requestBody}: the response body schemas live exclusively inside\n * the `content` array (one entry per content type), so the same schema is never duplicated at the\n * node root and inside `content`.\n *\n * @example\n * ```ts\n * const response: ResponseNode = {\n * kind: 'Response',\n * statusCode: '200',\n * content: [{ kind: 'Content', contentType: 'application/json', schema: createSchema({ type: 'string' }) }],\n * }\n * ```\n */\nexport type ResponseNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Response'\n /**\n * HTTP status code or `'default'` for a fallback response.\n */\n statusCode: StatusCode\n summary?: string\n /**\n * Optional response description.\n */\n description?: string\n /**\n * All available content type entries for this response.\n *\n * For a response that declares content, the array holds exactly one entry for the adapter\n * `contentType` option when it is set. Otherwise it holds one entry per content type declared in\n * the spec, so that plugins can generate a union of response types (e.g. `application/json` and\n * `application/xml`). A body-less response always keeps a single entry whose `contentType` is `''`\n * and whose `schema` is the empty/`void` placeholder, even when the option is set.\n *\n * @example\n * ```ts\n * // spec response declares both application/json and application/xml\n * response.content[0].contentType // 'application/json'\n * response.content[1].contentType // 'application/xml'\n * ```\n */\n content?: Array<ContentNode>\n /**\n * Response headers, as `in: 'header'` parameters. `Content-Type` is left out.\n */\n headers?: Array<ParameterNode>\n links?: Record<string, ResponseLink>\n /** Vendor extensions (`x-*` keys) from the source response, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\n/**\n * A link to another operation. `parameters` and `requestBody` hold runtime expressions such as `$response.body#/id`.\n */\nexport type ResponseLink = {\n operationId?: string\n operationRef?: string\n parameters?: Record<string, unknown>\n requestBody?: unknown\n description?: string\n server?: InputServer\n}\n\nexport type ResponseInput = Pick<ResponseNode, 'statusCode'> &\n Partial<Omit<ResponseNode, 'kind' | 'statusCode' | 'content'>> & {\n content?: Array<ContentNode>\n schema?: SchemaNode\n mediaType?: string | null\n keysToOmit?: Array<string> | null\n }\n\n/**\n * Creates a `ResponseNode`. A single legacy `schema` (with optional `mediaType`/`keysToOmit`)\n * is normalized into one `content` entry.\n *\n * @example\n * ```ts\n * const response = createResponse({\n * statusCode: '200',\n * content: [createContent({ contentType: 'application/json', schema: createSchema({ type: 'object', properties: [] }) })],\n * })\n * ```\n */\nexport function createResponse(props: ResponseInput): ResponseNode {\n const { schema, mediaType, keysToOmit, content, ...rest } = props\n const entries = content ?? (schema ? [createContent({ contentType: mediaType ?? 'application/json', schema, keysToOmit: keysToOmit ?? null })] : undefined)\n\n return { ...rest, content: entries, kind: nodeKinds.response }\n}\n","import type { ArrowFunctionNode, BreakNode, ConstNode, FunctionNode, JsxNode, TextNode, TypeNode } from './code.ts'\nimport type { ContentNode } from './content.ts'\nimport type { ExportNode, FileNode, ImportNode, SourceNode } from './file.ts'\nimport type { InputNode } from './input.ts'\nimport type { OperationNode, OperationsNode } from './operation.ts'\nimport type { ParameterNode } from './parameter.ts'\nimport type { PropertyNode } from './property.ts'\nimport type { RequestBodyNode } from './requestBody.ts'\nimport type { ResponseNode } from './response.ts'\nimport type { SchemaNode } from './schema.ts'\n\nexport { createArrowFunction, createBreak, createConst, createFunction, createJsx, createText, createType } from './code.ts'\nexport { createContent } from './content.ts'\nexport { createExport, createFile, createImport, createSource } from './file.ts'\nexport type { ExportInput, ImportInput, ModuleName, Space, UserFileNode } from './file.ts'\nexport { createInput } from './input.ts'\nexport { createOperation, createOperations } from './operation.ts'\nexport { createParameter } from './parameter.ts'\nexport { createProperty } from './property.ts'\nexport { createRequestBody } from './requestBody.ts'\nexport { createResponse } from './response.ts'\nexport { createSchema } from './schema.ts'\n\n/**\n * Union of all AST node types.\n *\n * This lets TypeScript narrow types in `switch (node.kind)` blocks.\n *\n * @example\n * ```ts\n * function getKind(node: Node): string {\n * switch (node.kind) {\n * case nodeKinds.input:\n * return 'input'\n * default:\n * return 'other'\n * }\n * }\n * ```\n */\nexport type Node =\n | InputNode\n | OperationNode\n | OperationsNode\n | SchemaNode\n | PropertyNode\n | ParameterNode\n | ResponseNode\n | RequestBodyNode\n | ContentNode\n | FileNode\n | ImportNode\n | ExportNode\n | SourceNode\n | ConstNode\n | TypeNode\n | FunctionNode\n | ArrowFunctionNode\n | TextNode\n | BreakNode\n | JsxNode\n"],"mappings":";;;;;;;;;;;;;;;AAmQA,MAAa,cAAcA,2BAAAA,YAAuBC,kBAAAA,UAAU,KAAK;;;;;;;;;;AAWjE,MAAa,aAAaD,2BAAAA,YAAsBC,kBAAAA,UAAU,IAAI;;;;;;;;;;AAW9D,MAAa,iBAAiBD,2BAAAA,YAA0BC,kBAAAA,UAAU,QAAQ;;;;;;;;;;AAW1E,MAAa,sBAAsBD,2BAAAA,YAA+BC,kBAAAA,UAAU,aAAa;;;;;;;;;;AAWzF,SAAgB,WAAW,OAAyB;CAClD,OAAO;EAAE,MAAMA,kBAAAA,UAAU;EAAM;CAAM;AACvC;;;;;;;;;;AAWA,SAAgB,cAAyB;CACvC,OAAO,EAAE,MAAMA,kBAAAA,UAAU,MAAM;AACjC;;;;;;;;;;AAWA,SAAgB,UAAU,OAAwB;CAChD,OAAO;EAAE,MAAMA,kBAAAA,UAAU;EAAK;CAAM;AACtC;;;;;ACjOA,MAAa,gBAAgBC,2BAAAA,YAAyBC,kBAAAA,UAAU,OAAO;;;;;;;;;;;;AC2DvE,SAAgB,YAAY,YAA8C,CAAC,GAAc;CACvF,OAAO;EAAE,SAAS,CAAC;EAAG,YAAY,CAAC;EAAG,MAAM,CAAC;EAAG,GAAG;EAAW,MAAMC,kBAAAA,UAAU;CAAM;AACtF;;;;;ACzHA,MAAa,oBAAoBC,2BAAAA,YAA6BC,kBAAAA,UAAU,WAAW;;ACsGnF,SAAgB,gBAAgB,OAAsC;CACpE,MAAM,EAAE,aAAa,GAAG,SAAS;CACjC,MAAM,SAAS,KAAK,WAAW,KAAA,KAAa,KAAK,SAAS,KAAA;CAY1D,OAAO;EATL,MAAM,CAAC;EACP,YAAY,CAAC;EACb,WAAW,CAAC;EACZ,GAAG;EACH,MAAMC,kBAAAA,UAAU;EAChB,GAAI,SAAS,EAAE,UAAU,OAAgB,IAAI,CAAC;EAC9C,aAAa,cAAc,kBAAkB,WAAW,IAAI,KAAA;CAGpD;AACZ;;;;;;;;;;AAmBA,SAAgB,iBAAiB,EAAE,cAAoE;CACrG,OAAO;EAAE,MAAMA,kBAAAA,UAAU;EAAY;CAAW;AAClD;;;;;;;;;;;;;;;;ACxFA,SAAgB,gBAAgB,OAAyC;CACvE,MAAM,WAAW,MAAM,YAAY;CAEnC,OAAO;EAAE,GAAG;EAAO;EAAU,QAAQC,oBAAAA,iBAAiB,MAAM,QAAQ,QAAQ;EAAG,MAAMC,kBAAAA,UAAU;CAAU;AAC3G;;;;;;;;;;;;;;;;AC/CA,SAAgB,eAAe,OAAuC;CACpE,MAAM,WAAW,MAAM,YAAY;CAEnC,OAAO;EAAE,GAAG;EAAO;EAAU,QAAQC,oBAAAA,iBAAiB,MAAM,QAAQ,QAAQ;EAAG,MAAMC,kBAAAA,UAAU;CAAS;AAC1G;;;;;;;;;;;;;;ACqDA,SAAgB,eAAe,OAAoC;CACjE,MAAM,EAAE,QAAQ,WAAW,YAAY,SAAS,GAAG,SAAS;CAC5D,MAAM,UAAU,YAAY,SAAS,CAAC,cAAc;EAAE,aAAa,aAAa;EAAoB;EAAQ,YAAY,cAAc;CAAK,CAAC,CAAC,IAAI,KAAA;CAEjJ,OAAO;EAAE,GAAG;EAAM,SAAS;EAAS,MAAMC,kBAAAA,UAAU;CAAS;AAC/D"}
|
|
1
|
+
{"version":3,"file":"nodes-BjVv21pb.cjs","names":["nodeFactory","nodeKinds","nodeFactory","nodeKinds","nodeKinds","nodeFactory","nodeKinds","nodeKinds","applyOptionality","nodeKinds","applyOptionality","nodeKinds","nodeKinds"],"sources":["../src/nodes/code.ts","../src/nodes/content.ts","../src/nodes/input.ts","../src/nodes/requestBody.ts","../src/nodes/operation.ts","../src/nodes/parameter.ts","../src/nodes/property.ts","../src/nodes/response.ts","../src/nodes/index.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\n\n/**\n * JSDoc documentation metadata attached to code declarations.\n */\nexport type JSDocNode = {\n /**\n * JSDoc comment lines. `undefined` entries are filtered out during rendering.\n *\n * @example\n * ```ts\n * ['@description A pet resource', '@deprecated']\n * ```\n */\n comments?: Array<string | undefined>\n}\n\n/**\n * AST node representing a TypeScript `const` declaration.\n *\n * Mirrors the props of the `Const` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createConst({ name: 'pet', export: true, asConst: true })\n * // export const pet = ... as const\n * ```\n */\nexport type ConstNode = BaseNode & {\n kind: 'Const'\n /**\n * Name of the constant declaration.\n */\n name: string\n /**\n * Whether the declaration should be exported.\n */\n export?: boolean | null\n /**\n * Explicit type annotation.\n *\n * @example Type reference\n * `'Pet'`\n */\n type?: string | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Whether to append `as const` to the declaration.\n */\n asConst?: boolean | null\n /**\n * Child nodes representing the value of the constant (children of the `Const` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript `type` alias declaration.\n *\n * Mirrors the props of the `Type` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createType({ name: 'Pet', export: true })\n * // export type Pet = ...\n * ```\n */\nexport type TypeNode = BaseNode & {\n kind: 'Type'\n /**\n * Name of the type alias.\n */\n name: string\n /**\n * Whether the declaration should be exported.\n */\n export?: boolean | null\n /**\n * How the declaration is written.\n * - `'type'` declares `type Name = …`\n * - `'interface'` declares `interface Name { … }`, so the body must be an object type\n *\n * @default 'type'\n */\n syntax?: 'type' | 'interface' | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Child nodes representing the type body (children of the `Type` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript `function` declaration.\n *\n * Mirrors the props of the `Function` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createFunction({ name: 'getPet', export: true, async: true, returnType: 'Pet' })\n * // export async function getPet(): Promise<Pet> { ... }\n * ```\n */\nexport type FunctionNode = BaseNode & {\n kind: 'Function'\n /**\n * Name of the function.\n */\n name: string\n /**\n * Whether the function is a default export.\n */\n default?: boolean | null\n /**\n * Function parameter list as a pre-rendered string, written verbatim between the parentheses.\n *\n * @example\n * `'id: string, config: Config = {}'`\n */\n params?: string | null\n /**\n * Whether the function should be exported.\n */\n export?: boolean | null\n /**\n * Whether the function is async. When `true`, the return type is wrapped in `Promise<>`.\n */\n async?: boolean | null\n /**\n * TypeScript generic type parameters.\n *\n * @example Constrained generics\n * `['T', 'U extends string']`\n */\n generics?: string | Array<string> | null\n /**\n * Return type annotation.\n *\n * @example Type reference\n * `'Pet'`\n */\n returnType?: string | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Child nodes representing the function body (children of the `Function` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript arrow function (`const name = () => { ... }`).\n *\n * Mirrors the props of the `Function.Arrow` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createArrowFunction({ name: 'getPet', export: true, singleLine: true })\n * // export const getPet = () => ...\n * ```\n */\nexport type ArrowFunctionNode = Omit<FunctionNode, 'kind'> & {\n kind: 'ArrowFunction'\n /**\n * Render the arrow function body as a single-line expression.\n */\n singleLine?: boolean | null\n}\n\n/**\n * AST node representing a raw text/string fragment in the source output.\n *\n * Used instead of bare `string` values so that all entries in `nodes` arrays\n * are typed `CodeNode` objects rather than a mixed `CodeNode | string` union.\n *\n * @example\n * ```ts\n * createText('return fetch(id)')\n * // { kind: 'Text', value: 'return fetch(id)' }\n * ```\n */\nexport type TextNode = BaseNode & {\n kind: 'Text'\n /**\n * The raw string content.\n */\n value: string\n}\n\n/**\n * AST node representing a blank line in the source output.\n *\n * Corresponds to `<br/>` in JSX components. `printNodes` turns a `Break` between two\n * statements into one blank line. Consecutive breaks, and breaks at the start or end of\n * the list, are folded away, so a `Break` never produces more than one blank line.\n *\n * @example\n * ```ts\n * createBreak()\n * // { kind: 'Break' }\n * ```\n */\nexport type BreakNode = BaseNode & {\n kind: 'Break'\n}\n\n/**\n * AST node representing a raw JSX fragment in the source output.\n *\n * Mirrors the `Jsx` component from `@kubb/renderer-jsx`. Embeds raw JSX/TSX markup\n * (including fragments `<>…</>`) directly in generated code.\n *\n * @example\n * ```ts\n * createJsx('<>\\n <a href={href}>Open</a>\\n</>')\n * // { kind: 'Jsx', value: '<>\\n <a href={href}>Open</a>\\n</>' }\n * ```\n */\nexport type JsxNode = BaseNode & {\n kind: 'Jsx'\n /**\n * The raw JSX string content.\n */\n value: string\n}\n\n/**\n * Union of all code-generation AST nodes.\n *\n * These nodes mirror the JSX components from `@kubb/renderer-jsx` and are used as\n * structured children in {@link SourceNode.nodes}.\n */\nexport type CodeNode = ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode\n\n/**\n * Creates a `ConstNode` representing a TypeScript `const` declaration.\n *\n * @example Exported constant with type and `as const`\n * ```ts\n * createConst({ name: 'pets', export: true, type: 'Pet[]', asConst: true })\n * // export const pets: Pet[] = ... as const\n * ```\n */\nexport const createConst = nodeFactory<ConstNode>(nodeKinds.const)\n\n/**\n * Creates a `TypeNode` representing a TypeScript `type` alias declaration.\n *\n * @example\n * ```ts\n * createType({ name: 'Pet', export: true })\n * // export type Pet = ...\n * ```\n */\nexport const createType = nodeFactory<TypeNode>(nodeKinds.type)\n\n/**\n * Creates a `FunctionNode` representing a TypeScript `function` declaration.\n *\n * @example\n * ```ts\n * createFunction({ name: 'fetchPet', export: true, async: true, returnType: 'Pet' })\n * // export async function fetchPet(): Promise<Pet> { ... }\n * ```\n */\nexport const createFunction = nodeFactory<FunctionNode>(nodeKinds.function)\n\n/**\n * Creates an `ArrowFunctionNode` representing a TypeScript arrow function.\n *\n * @example\n * ```ts\n * createArrowFunction({ name: 'double', export: true, params: 'n: number', singleLine: true })\n * // export const double = (n: number) => ...\n * ```\n */\nexport const createArrowFunction = nodeFactory<ArrowFunctionNode>(nodeKinds.arrowFunction)\n\n/**\n * Creates a {@link TextNode} representing a raw string fragment in the source output.\n *\n * @example\n * ```ts\n * createText('return fetch(id)')\n * // { kind: 'Text', value: 'return fetch(id)' }\n * ```\n */\nexport function createText(value: string): TextNode {\n return { kind: nodeKinds.text, value }\n}\n\n/**\n * Creates a {@link BreakNode} representing a line break in the source output.\n *\n * @example\n * ```ts\n * createBreak()\n * // { kind: 'Break' }\n * ```\n */\nexport function createBreak(): BreakNode {\n return { kind: nodeKinds.break }\n}\n\n/**\n * Creates a {@link JsxNode} representing a raw JSX fragment in the source output.\n *\n * @example\n * ```ts\n * createJsx('<>\\n <a href={href}>Open</a>\\n</>')\n * // { kind: 'Jsx', value: '<>\\n <a href={href}>Open</a>\\n</>' }\n * ```\n */\nexport function createJsx(value: string): JsxNode {\n return { kind: nodeKinds.jsx, value }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\nimport type { ParameterStyle } from './parameter.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * How one body property is serialized, from the `encoding` entry of its media type.\n */\nexport type EncodingNode = {\n /**\n * Content type of the part, for example `'application/json'` for a multipart property.\n */\n contentType?: string\n /**\n * Serialization style of the property.\n */\n style?: ParameterStyle\n /**\n * Whether array and object values expand into separate values.\n */\n explode?: boolean\n /**\n * Whether reserved characters are sent as-is instead of percent-encoded.\n */\n allowReserved?: boolean\n encoding?: Record<string, EncodingNode>\n prefixEncoding?: Array<EncodingNode>\n itemEncoding?: EncodingNode\n}\n\nexport type ExampleNode = {\n name?: string\n summary?: string\n description?: string\n value?: unknown\n serializedValue?: string\n}\n\n/**\n * AST node representing one content-type entry of a request body or response.\n *\n * There is one entry per content type declared in the spec (e.g. `application/json`,\n * `multipart/form-data`), and each entry holds its own body schema.\n *\n * @example\n * ```ts\n * const content: ContentNode = {\n * kind: 'Content',\n * contentType: 'application/json',\n * schema: createSchema({ type: 'string' }),\n * }\n * ```\n */\nexport type ContentNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Content'\n /**\n * The content type for this entry (e.g. `'application/json'`), or `''` for a response without a body.\n */\n contentType: string\n /**\n * Body schema for this content type. For a stream it is the same node as `stream.schema`.\n */\n schema?: SchemaNode\n /**\n * Set when the content is a stream of items (an event stream, JSON Lines, a channel of messages) instead of one body.\n */\n stream?: {\n /**\n * Schema of one item, such as one event of `text/event-stream` or one line of JSON Lines.\n */\n schema?: SchemaNode\n /**\n * What `schema` describes for an event stream.\n * - `'event'` the parsed event with its `event`, `data`, `id` and `retry` fields\n * - `'data'` only the `data` payload, which the client wraps in its own event type\n */\n shape?: 'event' | 'data'\n }\n /**\n * Property keys to exclude from the generated type via `Omit<Type, Keys>`.\n * Set when a referenced schema has `readOnly`/`writeOnly` fields that should be omitted.\n */\n keysToOmit?: Array<string> | null\n /**\n * Serialization settings per body property that sets at least one field in the spec's `encoding`.\n */\n encoding?: Record<string, EncodingNode>\n examples?: Array<ExampleNode>\n /**\n * Serialization of the first parts by position, for a body sent as an array of parts such as `multipart/mixed`.\n */\n prefixEncoding?: Array<EncodingNode>\n /**\n * Serialization of every part after `prefixEncoding`, for a body sent as an array of parts such as `multipart/mixed`.\n */\n itemEncoding?: EncodingNode\n /** Vendor extensions (`x-*` keys) from the source media type, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\n/**\n * Creates a `ContentNode` for a single request-body or response content type.\n */\nexport const createContent = nodeFactory<ContentNode>(nodeKinds.content)\n","import { nodeKinds } from '../constants.ts'\nimport type { BaseNode } from './base.ts'\nimport type { OperationNode } from './operation.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * A variable declared by a server URL template.\n */\nexport type InputServerVariable = {\n default?: string\n enum?: Array<string>\n description?: string\n}\n\n/**\n * A server from the source document, with `{variable}` placeholders filled from their defaults.\n */\nexport type InputServer = {\n url: string\n name?: string\n description?: string\n /**\n * Variables of the source URL template, copied as-is. `url` already has their defaults filled in, so\n * this tells a templated server apart from a literal one. Absent when the server declares none.\n */\n variables?: Record<string, InputServerVariable>\n}\n\nexport type ExternalDocs = { url: string; description?: string }\n\nexport type InputTag = {\n name: string\n summary?: string\n description?: string\n /**\n * Name of the tag this tag nests under. `group: { type: 'tag' }` places its files in the parent's folder.\n */\n parent?: string\n kind?: string\n externalDocs?: ExternalDocs\n}\n\nexport type OAuthFlow = {\n authorizationUrl?: string\n deviceAuthorizationUrl?: string\n tokenUrl?: string\n refreshUrl?: string\n scopes?: Record<string, string>\n}\n\n/**\n * How a client sends a credential, in the same shape as the `Auth` object the generated clients pass to `auth`.\n */\nexport type AuthCredential =\n | { type: 'http'; scheme: 'bearer' | 'basic' | (string & {}); bearerFormat?: string }\n | { type: 'apiKey'; in: 'header' | 'query' | 'cookie'; name: string }\n | { type: 'oauth2'; flows: Record<string, OAuthFlow>; metadataUrl?: string }\n | { type: 'openIdConnect'; url?: string }\n | { type: 'mutualTLS' }\n\n/**\n * One way to authenticate, keyed by `name`, which operations refer to in `auth`.\n */\nexport type AuthScheme = {\n name: string\n description?: string\n deprecated?: boolean\n credential: AuthCredential\n}\n\n/**\n * One way to meet an operation's auth. Every scheme in it applies together. `scopes` are the OAuth2 or OpenID\n * Connect scopes the call needs. An empty list means the call may be sent without credentials.\n */\nexport type AuthRequirement = Array<{ scheme: string; scopes?: Array<string> }>\n\n/**\n * Metadata for an API document, populated by the adapter and available to every generator.\n * Every field is a plain JSON value.\n *\n * @example\n * ```ts\n * const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://api.example.com/v2' }\n * ```\n */\nexport type InputMeta = {\n /**\n * API title from `info.title` in the source document.\n */\n title?: string\n /**\n * API description from `info.description` in the source document.\n */\n description?: string\n /**\n * API version string from `info.version` in the source document.\n */\n version?: string\n summary?: string\n termsOfService?: string\n contact?: { name?: string; url?: string; email?: string }\n license?: { name: string; identifier?: string; url?: string }\n externalDocs?: ExternalDocs\n /**\n * Resolved base URL from the first matching server entry in the source document.\n */\n baseURL?: string | null\n /**\n * The server index the adapter was configured with. A plugin uses it to pick the server at the same position in an\n * operation's or a path's own `servers`. It counts the source document's entries, including any without a URL.\n * Absent when the adapter was given no index.\n */\n serverIndex?: number\n servers?: Array<InputServer>\n tags?: Array<InputTag>\n auth?: Array<AuthScheme>\n /**\n * Vendor extensions (`x-*` keys) from the document root, copied as-is. Absent when the root has none.\n */\n extensions?: Record<string, unknown>\n}\n\n/**\n * Input AST node that contains all schemas and operations for one API document.\n * Produced by the adapter and consumed by all Kubb plugins.\n *\n * @example\n * ```ts\n * const input: InputNode = {\n * kind: 'Input',\n * schemas: [],\n * operations: [],\n * meta: {},\n * }\n * ```\n */\nexport type InputNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Input'\n /**\n * All schema nodes in the document.\n */\n schemas: Array<SchemaNode>\n /**\n * All operation nodes in the document.\n */\n operations: Array<OperationNode>\n /**\n * Document metadata populated by the adapter.\n */\n meta: InputMeta\n}\n\n/**\n * Creates an `InputNode`, defaulting `schemas`/`operations` to empty arrays and `meta` to an empty\n * object. Every call allocates fresh defaults so no two inputs share them.\n *\n * @example\n * ```ts\n * const input = createInput()\n * // { kind: 'Input', schemas: [], operations: [] }\n * ```\n */\nexport function createInput(overrides: Partial<Omit<InputNode, 'kind'>> = {}): InputNode {\n return { schemas: [], operations: [], meta: {}, ...overrides, kind: nodeKinds.input }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\nimport type { ContentNode } from './content.ts'\n\n/**\n * AST node representing an operation request body.\n *\n * Body schemas live exclusively inside the `content` array (one entry per content type),\n * mirroring {@link ResponseNode}.\n *\n * @example\n * ```ts\n * const requestBody: RequestBodyNode = {\n * kind: 'RequestBody',\n * required: true,\n * content: [{ kind: 'Content', contentType: 'application/json', schema: createSchema({ type: 'string' }) }],\n * }\n * ```\n */\nexport type RequestBodyNode = BaseNode & {\n kind: 'RequestBody'\n /**\n * Request body description carried over from the spec.\n */\n description?: string\n /**\n * Whether the request body is required (`requestBody.required: true` in the spec).\n * When `false` or absent, the generated `data` parameter should be optional.\n */\n required?: boolean\n /**\n * Content type entries for this request body.\n *\n * When the adapter `contentType` option is set, this array contains exactly one entry for\n * that content type. Otherwise it contains one entry per content type declared in the spec,\n * so plugins can generate code for every variant (for example, separate hooks for\n * `application/json` and `multipart/form-data`).\n */\n content?: Array<ContentNode>\n /** Vendor extensions (`x-*` keys) from the source request body, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\n/**\n * Creates a `RequestBodyNode`.\n */\nexport const createRequestBody = nodeFactory<RequestBodyNode>(nodeKinds.requestBody)\n","import { nodeKinds } from '../constants.ts'\nimport type { BaseNode } from './base.ts'\nimport type { AuthRequirement, ExternalDocs, InputServer } from './input.ts'\nimport type { ParameterNode } from './parameter.ts'\nimport { createRequestBody, type RequestBodyNode } from './requestBody.ts'\nimport type { ResponseNode } from './response.ts'\n\n/**\n * HTTP method an operation responds to. `QUERY` is the safe, idempotent method with a request body\n * from RFC 10008, declared with the `query` field of an OpenAPI 3.2 path item. Any other name is a\n * method the source declares outside this fixed set, in the capitalization it is sent with.\n */\nexport type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'QUERY' | (string & {})\n\n/**\n * Fields shared by every operation, regardless of transport.\n */\nexport type OperationNodeBase = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Operation'\n /**\n * Stable identifier for the operation.\n */\n operationId: string\n /**\n * Group labels for the operation.\n */\n tags: Array<string>\n /**\n * Short one-line operation summary.\n */\n summary?: string\n /**\n * Full operation description.\n */\n description?: string\n /**\n * Marks the operation as deprecated.\n */\n deprecated?: boolean\n externalDocs?: ExternalDocs\n /**\n * Query, path, header, and cookie parameters for the operation.\n */\n parameters: Array<ParameterNode>\n /**\n * Request body for the operation.\n */\n requestBody?: RequestBodyNode\n /**\n * Operation responses.\n */\n responses: Array<ResponseNode>\n /**\n * Vendor extensions (`x-*` keys) from the source operation, copied as-is. Absent when the source has none.\n */\n extensions?: Record<string, unknown>\n /** The operation's own `servers`, else its path item's, such as an upload host. Absent when neither declares any. */\n servers?: Array<InputServer>\n /**\n * Ways to authenticate, from the operation or else the document. Any one entry is enough. `[]` means no auth.\n */\n auth?: Array<AuthRequirement>\n}\n\n/**\n * Operation served over HTTP. `method` and `path` are guaranteed.\n *\n * @example\n * ```ts\n * const operation: HttpOperationNode = {\n * kind: 'Operation',\n * operationId: 'listPets',\n * protocol: 'http',\n * method: 'GET',\n * path: '/pets',\n * tags: [],\n * parameters: [],\n * responses: [],\n * }\n * ```\n */\nexport type HttpOperationNode = OperationNodeBase & {\n /**\n * Transport the operation belongs to.\n */\n protocol?: 'http'\n /**\n * HTTP method like `'GET'`.\n */\n method: HttpMethod\n /**\n * Path string, for example `/pets/{petId}`, with `{param}` notation preserved.\n */\n path: string\n}\n\n/**\n * Operation for a non-HTTP transport. HTTP-only fields are forbidden.\n */\nexport type GenericOperationNode = OperationNodeBase & {\n protocol?: never\n method?: never\n path?: never\n}\n\n/**\n * AST node representing one API operation.\n *\n * Discriminated on `protocol`: an {@link HttpOperationNode} (`protocol: 'http'`) guarantees\n * `method` and `path`, while a {@link GenericOperationNode} omits them. Narrow with\n * `ast.http.isOperation(node)` or `node.protocol === 'http'` before reading `method`/`path`.\n */\nexport type OperationNode = HttpOperationNode | GenericOperationNode\n\nexport type OperationInput = {\n operationId: string\n method?: HttpOperationNode['method']\n path?: HttpOperationNode['path']\n requestBody?: Omit<RequestBodyNode, 'kind'>\n [key: string]: unknown\n}\n\n/**\n * Creates an `OperationNode` with default empty arrays for `tags`, `parameters`, and `responses`.\n * HTTP operations (those carrying both `method` and `path`) are tagged with `protocol: 'http'`,\n * and the request body is normalized into a `RequestBodyNode`.\n *\n * @example\n * ```ts\n * const operation = createOperation({ operationId: 'getPetById', method: 'GET', path: '/pet/{petId}' })\n * // tags, parameters, and responses are []\n * ```\n */\nexport function createOperation(\n props: Pick<HttpOperationNode, 'operationId' | 'method' | 'path'> &\n Partial<Omit<HttpOperationNode, 'kind' | 'operationId' | 'method' | 'path' | 'requestBody'>> & {\n requestBody?: Omit<RequestBodyNode, 'kind'>\n },\n): HttpOperationNode\nexport function createOperation(\n props: Pick<GenericOperationNode, 'operationId'> &\n Partial<Omit<GenericOperationNode, 'kind' | 'operationId' | 'requestBody'>> & {\n requestBody?: Omit<RequestBodyNode, 'kind'>\n },\n): GenericOperationNode\nexport function createOperation(props: OperationInput): OperationNode {\n const { requestBody, ...rest } = props\n const isHttp = rest.method !== undefined && rest.path !== undefined\n\n const node = {\n tags: [],\n parameters: [],\n responses: [],\n ...rest,\n kind: nodeKinds.operation,\n ...(isHttp ? { protocol: 'http' as const } : {}),\n requestBody: requestBody ? createRequestBody(requestBody) : undefined,\n }\n\n return node as OperationNode\n}\n\n/**\n * The operations a plugin keeps, as one node. A template with `kind: 'Operations'` gets it once, after every operation.\n */\nexport type OperationsNode = BaseNode & {\n kind: 'Operations'\n operations: Array<OperationNode>\n}\n\n/**\n * Creates an `OperationsNode` for a list of operations.\n *\n * @example\n * ```ts\n * const node = createOperations({ operations: [listPets, getPetById] })\n * // { kind: 'Operations', operations: [...] }\n * ```\n */\nexport function createOperations({ operations }: { operations: Array<OperationNode> }): OperationsNode {\n return { kind: nodeKinds.operations, operations }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { applyOptionality } from '../optionality.ts'\nimport type { BaseNode } from './base.ts'\nimport type { EncodingNode, ExampleNode } from './content.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * Where a parameter is sent. `querystring` carries the whole query string as one value, serialized per `contentType`.\n */\nexport type ParameterLocation = 'path' | 'query' | 'header' | 'cookie' | 'querystring'\n\n/**\n * Parameter serialization style, controlling how a parameter value is rendered into the request.\n */\nexport type ParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject' | 'cookie'\n\n/**\n * AST node representing one operation parameter.\n *\n * @example\n * ```ts\n * const param: ParameterNode = {\n * kind: 'Parameter',\n * name: 'petId',\n * in: 'path',\n * schema: createSchema({ type: 'string' }),\n * required: true,\n * }\n * ```\n */\nexport type ParameterNode = BaseNode & {\n kind: 'Parameter'\n /**\n * Parameter name.\n */\n name: string\n /**\n * Parameter location (`path`, `query`, `header`, `cookie`, or `querystring`).\n */\n in: ParameterLocation\n /**\n * Parameter schema.\n */\n schema: SchemaNode\n /**\n * Whether the parameter is required.\n */\n required: boolean\n /**\n * Serialization style. Absent when the source omits it, leaving consumers to apply the\n * per-location default.\n */\n style?: ParameterStyle\n /**\n * Whether array and object values expand into separate values. Absent when the source omits it,\n * leaving consumers to apply the default for the style.\n */\n explode?: boolean\n /**\n * Whether reserved characters (RFC 3986 `:/?#[]@!$&'()*+,;=`) are sent as-is instead of\n * percent-encoded. Absent when the source omits it.\n */\n allowReserved?: boolean\n /**\n * Media type of a parameter described with `content` instead of `schema`, for example\n * `application/json` when the value is sent as a JSON-encoded string. Absent for `schema` parameters.\n */\n contentType?: string\n /**\n * Serialization settings per property of a `content` parameter, from the `encoding` of its media type. An OpenAPI 3.2\n * `querystring` parameter sent as `application/x-www-form-urlencoded` uses it to set `style` and `explode` per field.\n */\n encoding?: Record<string, EncodingNode>\n examples?: Array<ExampleNode>\n deprecated?: boolean\n allowEmptyValue?: boolean\n /** Vendor extensions (`x-*` keys) from the source parameter, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\nexport type UserParameterNode = Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial<Omit<ParameterNode, 'kind' | 'name' | 'in' | 'schema'>>\n\n/**\n * Creates a `ParameterNode`. `required` defaults to `false`, and the schema's\n * `optional`/`nullish` flags are derived from it.\n *\n * @example\n * ```ts\n * const param = createParameter({\n * name: 'petId',\n * in: 'path',\n * required: true,\n * schema: createSchema({ type: 'string' }),\n * })\n * ```\n */\nexport function createParameter(input: UserParameterNode): ParameterNode {\n const required = input.required ?? false\n\n return { ...input, required, schema: applyOptionality(input.schema, required), kind: nodeKinds.parameter }\n}\n","import { nodeKinds } from '../constants.ts'\nimport { applyOptionality } from '../optionality.ts'\nimport type { BaseNode } from './base.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * AST node representing one named object property.\n *\n * @example\n * ```ts\n * const property: PropertyNode = {\n * kind: 'Property',\n * name: 'id',\n * schema: createSchema({ type: 'integer' }),\n * required: true,\n * }\n * ```\n */\nexport type PropertyNode = BaseNode & {\n kind: 'Property'\n /**\n * Property key.\n */\n name: string\n /**\n * Property schema.\n */\n schema: SchemaNode\n /**\n * Whether the property is required.\n */\n required: boolean\n}\n\n/**\n * Loosely-typed property accepted by `createProperty`, with `required` optional.\n */\nexport type UserPropertyNode = Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<PropertyNode, 'kind' | 'name' | 'schema'>>\n\n/**\n * Creates a `PropertyNode`. `required` defaults to `false`, and the schema's\n * `optional`/`nullish` flags are derived from it.\n *\n * @example\n * ```ts\n * const property = createProperty({\n * name: 'status',\n * required: true,\n * schema: createSchema({ type: 'string', nullable: true }),\n * })\n * // required=true, no optional/nullish\n * ```\n */\nexport function createProperty(input: UserPropertyNode): PropertyNode {\n const required = input.required ?? false\n\n return { ...input, required, schema: applyOptionality(input.schema, required), kind: nodeKinds.property }\n}\n","import { nodeKinds } from '../constants.ts'\nimport type { BaseNode } from './base.ts'\nimport { type ContentNode, createContent } from './content.ts'\nimport type { InputServer } from './input.ts'\nimport type { ParameterNode } from './parameter.ts'\nimport type { SchemaNode } from './schema.ts'\n\nexport type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9\n\n/**\n * Response status code literal used by operations.\n *\n * Includes three-digit HTTP status code strings, ranges such as `\"2xx\"`, and `\"default\"` for catch-all responses.\n *\n * @example\n * ```ts\n * const status: StatusCode = '200'\n * const fallback: StatusCode = 'default'\n * ```\n */\nexport type StatusCode = `${1 | 2 | 3 | 4 | 5}${Digit}${Digit}` | `${1 | 2 | 3 | 4 | 5}xx` | 'default'\n\n/**\n * AST node representing one operation response variant.\n *\n * Mirrors {@link OperationNode.requestBody}: the response body schemas live exclusively inside\n * the `content` array (one entry per content type), so the same schema is never duplicated at the\n * node root and inside `content`.\n *\n * @example\n * ```ts\n * const response: ResponseNode = {\n * kind: 'Response',\n * statusCode: '200',\n * content: [{ kind: 'Content', contentType: 'application/json', schema: createSchema({ type: 'string' }) }],\n * }\n * ```\n */\nexport type ResponseNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Response'\n /**\n * HTTP status code or `'default'` for a fallback response.\n */\n statusCode: StatusCode\n summary?: string\n /**\n * Optional response description.\n */\n description?: string\n /**\n * All available content type entries for this response.\n *\n * For a response that declares content, the array holds exactly one entry for the adapter\n * `contentType` option when it is set. Otherwise it holds one entry per content type declared in\n * the spec, so that plugins can generate a union of response types (e.g. `application/json` and\n * `application/xml`). A body-less response always keeps a single entry whose `contentType` is `''`\n * and whose `schema` is the empty/`void` placeholder, even when the option is set.\n *\n * @example\n * ```ts\n * // spec response declares both application/json and application/xml\n * response.content[0].contentType // 'application/json'\n * response.content[1].contentType // 'application/xml'\n * ```\n */\n content?: Array<ContentNode>\n /**\n * Response headers, as `in: 'header'` parameters. `Content-Type` is left out.\n */\n headers?: Array<ParameterNode>\n links?: Record<string, ResponseLink>\n /** Vendor extensions (`x-*` keys) from the source response, copied as-is. */\n extensions?: Record<string, unknown>\n}\n\n/**\n * A link to another operation. `parameters` and `requestBody` hold runtime expressions such as `$response.body#/id`.\n */\nexport type ResponseLink = {\n operationId?: string\n operationRef?: string\n parameters?: Record<string, unknown>\n requestBody?: unknown\n description?: string\n server?: InputServer\n}\n\nexport type ResponseInput = Pick<ResponseNode, 'statusCode'> &\n Partial<Omit<ResponseNode, 'kind' | 'statusCode' | 'content'>> & {\n content?: Array<ContentNode>\n schema?: SchemaNode\n mediaType?: string | null\n keysToOmit?: Array<string> | null\n }\n\n/**\n * Creates a `ResponseNode`. A single legacy `schema` (with optional `mediaType`/`keysToOmit`)\n * is normalized into one `content` entry.\n *\n * @example\n * ```ts\n * const response = createResponse({\n * statusCode: '200',\n * content: [createContent({ contentType: 'application/json', schema: createSchema({ type: 'object', properties: [] }) })],\n * })\n * ```\n */\nexport function createResponse(props: ResponseInput): ResponseNode {\n const { schema, mediaType, keysToOmit, content, ...rest } = props\n const entries = content ?? (schema ? [createContent({ contentType: mediaType ?? 'application/json', schema, keysToOmit: keysToOmit ?? null })] : undefined)\n\n return { ...rest, content: entries, kind: nodeKinds.response }\n}\n","import type { ArrowFunctionNode, BreakNode, ConstNode, FunctionNode, JsxNode, TextNode, TypeNode } from './code.ts'\nimport type { ContentNode } from './content.ts'\nimport type { ExportNode, FileNode, ImportNode, SourceNode } from './file.ts'\nimport type { InputNode } from './input.ts'\nimport type { OperationNode, OperationsNode } from './operation.ts'\nimport type { ParameterNode } from './parameter.ts'\nimport type { PropertyNode } from './property.ts'\nimport type { RequestBodyNode } from './requestBody.ts'\nimport type { ResponseNode } from './response.ts'\nimport type { SchemaNode } from './schema.ts'\n\nexport { createArrowFunction, createBreak, createConst, createFunction, createJsx, createText, createType } from './code.ts'\nexport { createContent } from './content.ts'\nexport { createExport, createFile, createImport, createSource } from './file.ts'\nexport type { ExportInput, ImportInput, ModuleName, Space, UserFileNode } from './file.ts'\nexport { createInput } from './input.ts'\nexport { createOperation, createOperations } from './operation.ts'\nexport { createParameter } from './parameter.ts'\nexport { createProperty } from './property.ts'\nexport { createRequestBody } from './requestBody.ts'\nexport { createResponse } from './response.ts'\nexport { createSchema } from './schema.ts'\n\n/**\n * Union of all AST node types.\n *\n * This lets TypeScript narrow types in `switch (node.kind)` blocks.\n *\n * @example\n * ```ts\n * function getKind(node: Node): string {\n * switch (node.kind) {\n * case nodeKinds.input:\n * return 'input'\n * default:\n * return 'other'\n * }\n * }\n * ```\n */\nexport type Node =\n | InputNode\n | OperationNode\n | OperationsNode\n | SchemaNode\n | PropertyNode\n | ParameterNode\n | ResponseNode\n | RequestBodyNode\n | ContentNode\n | FileNode\n | ImportNode\n | ExportNode\n | SourceNode\n | ConstNode\n | TypeNode\n | FunctionNode\n | ArrowFunctionNode\n | TextNode\n | BreakNode\n | JsxNode\n"],"mappings":";;;;;;;;;;;;;;;AAmQA,MAAa,cAAcA,aAAAA,YAAuBC,kBAAAA,UAAU,KAAK;;;;;;;;;;AAWjE,MAAa,aAAaD,aAAAA,YAAsBC,kBAAAA,UAAU,IAAI;;;;;;;;;;AAW9D,MAAa,iBAAiBD,aAAAA,YAA0BC,kBAAAA,UAAU,QAAQ;;;;;;;;;;AAW1E,MAAa,sBAAsBD,aAAAA,YAA+BC,kBAAAA,UAAU,aAAa;;;;;;;;;;AAWzF,SAAgB,WAAW,OAAyB;CAClD,OAAO;EAAE,MAAMA,kBAAAA,UAAU;EAAM;CAAM;AACvC;;;;;;;;;;AAWA,SAAgB,cAAyB;CACvC,OAAO,EAAE,MAAMA,kBAAAA,UAAU,MAAM;AACjC;;;;;;;;;;AAWA,SAAgB,UAAU,OAAwB;CAChD,OAAO;EAAE,MAAMA,kBAAAA,UAAU;EAAK;CAAM;AACtC;;;;;ACjOA,MAAa,gBAAgBC,aAAAA,YAAyBC,kBAAAA,UAAU,OAAO;;;;;;;;;;;;AC2DvE,SAAgB,YAAY,YAA8C,CAAC,GAAc;CACvF,OAAO;EAAE,SAAS,CAAC;EAAG,YAAY,CAAC;EAAG,MAAM,CAAC;EAAG,GAAG;EAAW,MAAMC,kBAAAA,UAAU;CAAM;AACtF;;;;;ACzHA,MAAa,oBAAoBC,aAAAA,YAA6BC,kBAAAA,UAAU,WAAW;;ACsGnF,SAAgB,gBAAgB,OAAsC;CACpE,MAAM,EAAE,aAAa,GAAG,SAAS;CACjC,MAAM,SAAS,KAAK,WAAW,KAAA,KAAa,KAAK,SAAS,KAAA;CAY1D,OAAO;EATL,MAAM,CAAC;EACP,YAAY,CAAC;EACb,WAAW,CAAC;EACZ,GAAG;EACH,MAAMC,kBAAAA,UAAU;EAChB,GAAI,SAAS,EAAE,UAAU,OAAgB,IAAI,CAAC;EAC9C,aAAa,cAAc,kBAAkB,WAAW,IAAI,KAAA;CAGpD;AACZ;;;;;;;;;;AAmBA,SAAgB,iBAAiB,EAAE,cAAoE;CACrG,OAAO;EAAE,MAAMA,kBAAAA,UAAU;EAAY;CAAW;AAClD;;;;;;;;;;;;;;;;ACxFA,SAAgB,gBAAgB,OAAyC;CACvE,MAAM,WAAW,MAAM,YAAY;CAEnC,OAAO;EAAE,GAAG;EAAO;EAAU,QAAQC,oBAAAA,iBAAiB,MAAM,QAAQ,QAAQ;EAAG,MAAMC,kBAAAA,UAAU;CAAU;AAC3G;;;;;;;;;;;;;;;;AC/CA,SAAgB,eAAe,OAAuC;CACpE,MAAM,WAAW,MAAM,YAAY;CAEnC,OAAO;EAAE,GAAG;EAAO;EAAU,QAAQC,oBAAAA,iBAAiB,MAAM,QAAQ,QAAQ;EAAG,MAAMC,kBAAAA,UAAU;CAAS;AAC1G;;;;;;;;;;;;;;ACqDA,SAAgB,eAAe,OAAoC;CACjE,MAAM,EAAE,QAAQ,WAAW,YAAY,SAAS,GAAG,SAAS;CAC5D,MAAM,UAAU,YAAY,SAAS,CAAC,cAAc;EAAE,aAAa,aAAa;EAAoB;EAAQ,YAAY,cAAc;CAAK,CAAC,CAAC,IAAI,KAAA;CAEjJ,OAAO;EAAE,GAAG;EAAM,SAAS;EAAS,MAAMC,kBAAAA,UAAU;CAAS;AAC/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise-DMQPWp6M.cjs","names":[],"sources":["../../../internals/utils/src/promise.ts"],"sourcesContent":["/** 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\nexport type 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 * Returns the value cached under `key` in `store`, computing and storing it on the first call.\n * Pass a `WeakMap` for object keys, so an entry goes away with its key, or a `Map` for primitive\n * keys. A cached `null` or `undefined` counts as a hit, so `compute` runs once per key.\n *\n * @example\n * `const refs = memo(refCache, node, () => collectRefs(node))`\n */\nexport function memo<TKey, TValue>(store: Store<TKey, TValue>, key: TKey, compute: () => TValue): TValue {\n const cached = store.get(key)\n if (cached !== undefined || store.has(key)) return cached as TValue\n const value = compute()\n store.set(key, value)\n return value\n}\n\nclass BoundedStore<TKey, TValue> implements Store<TKey, TValue> {\n readonly #entry = new Map<TKey, TValue>()\n readonly #max: number\n\n constructor(max: number) {\n this.#max = max\n }\n\n has(key: TKey): boolean {\n return this.#entry.has(key)\n }\n\n get(key: TKey): TValue | undefined {\n return this.#entry.get(key)\n }\n\n set(key: TKey, value: TValue): void {\n if (this.#entry.size >= this.#max) this.#entry.clear()\n this.#entry.set(key, value)\n }\n}\n\nclass LastEntryStore<TKey, TValue> extends BoundedStore<TKey, TValue> {\n constructor() {\n super(1)\n }\n\n // A key equal to the stored one but a different object, such as a copy of a string, replaces the\n // stored key, so the next lookup is an identity hit instead of a full comparison.\n #touch(key: TKey): boolean {\n if (!super.has(key)) return false\n this.set(key, super.get(key) as TValue)\n return true\n }\n\n override has(key: TKey): boolean {\n return this.#touch(key)\n }\n\n override get(key: TKey): TValue | undefined {\n return this.#touch(key) ? super.get(key) : undefined\n }\n}\n\n/**\n * Creates a store for `memo`. With no options it is a `Map`. Each option changes one thing:\n *\n * - `weak` holds the keys weakly, in a `WeakMap`, so an entry goes away with its key.\n * - `max` bounds the store: it empties itself before the entry that would pass `max`, which keeps a\n * cache in a long-running process from growing without end. `max: 1` keeps only the last entry.\n *\n * @example\n * `const patterns = memo.create<string, RegExp>()`\n *\n * @example Freed with its key\n * `const refs = memo.create<SchemaNode, Array<string>>({ weak: true })`\n *\n * @example Bounded\n * `const names = memo.create<string, string>({ max: 100_000 })`\n *\n * @example Many values per key\n * ```ts\n * const filesByPlugin = memo.create<string, Array<string>>()\n * memo(filesByPlugin, 'plugin-ts', () => []).push('models.ts')\n * ```\n */\nfunction createStore<TKey, TValue>(options?: { weak?: false; max?: undefined }): Map<TKey, TValue>\nfunction createStore<TKey extends WeakKey, TValue>(options: { weak: true; max?: undefined }): WeakMap<TKey, TValue>\nfunction createStore<TKey, TValue>(options: { max: number; weak?: false }): Store<TKey, TValue>\nfunction createStore<TKey, TValue>({ weak, max }: { weak?: boolean; max?: number } = {}): Store<TKey, TValue> {\n if (weak) return new WeakMap<WeakKey, TValue>() as Store<TKey, TValue>\n if (max === undefined) return new Map<TKey, TValue>()\n if (max !== 1) return new BoundedStore<TKey, TValue>(max)\n return new LastEntryStore<TKey, TValue>()\n}\n\nmemo.create = createStore\n\nexport type InParallelOptions<TItem> = {\n /**\n * Items to work through, handed out in order.\n */\n items: ReadonlyArray<TItem>\n /**\n * How many items may be in flight at once.\n */\n limit: number\n /**\n * Runs once per item, with the item's position so a caller can report progress.\n */\n run(item: TItem, index: number): Promise<void>\n}\n\n/**\n * Runs `run` over every item with at most `limit` in flight. Workers share one iterator, so each\n * takes the next item the moment it frees up instead of waiting for a batch to drain. The first\n * rejection rejects the call, and the other workers start no new item after it.\n *\n * @example\n * ```ts\n * await inParallel({ items: files, limit: 50, run: (file) => storage.writeItem(file.path, file.source) })\n * ```\n */\nexport async function inParallel<TItem>({ items, limit, run }: InParallelOptions<TItem>): Promise<void> {\n const queue = items.entries()\n let failed = false\n\n const worker = async (): Promise<void> => {\n for (const [index, item] of queue) {\n if (failed) return\n await run(item, index).catch((error: unknown) => {\n failed = true\n throw error\n })\n }\n }\n\n await Promise.all(Array.from({ length: Math.min(limit, items.length) }, () => worker()))\n}\n"],"mappings":";;;;;;;;;;AAyBA,SAAgB,KAAmB,OAA4B,KAAW,SAA+B;CACvG,MAAM,SAAS,MAAM,IAAI,GAAG;CAC5B,IAAI,WAAW,KAAA,KAAa,MAAM,IAAI,GAAG,GAAG,OAAO;CACnD,MAAM,QAAQ,QAAQ;CACtB,MAAM,IAAI,KAAK,KAAK;CACpB,OAAO;AACT;AAEA,IAAM,eAAN,MAAgE;CACrD,yBAAS,IAAI,IAAkB;CAC/B;CAET,YAAY,KAAa;EACvB,KAAK,OAAO;CACd;CAEA,IAAI,KAAoB;EACtB,OAAO,KAAK,OAAO,IAAI,GAAG;CAC5B;CAEA,IAAI,KAA+B;EACjC,OAAO,KAAK,OAAO,IAAI,GAAG;CAC5B;CAEA,IAAI,KAAW,OAAqB;EAClC,IAAI,KAAK,OAAO,QAAQ,KAAK,MAAM,KAAK,OAAO,MAAM;EACrD,KAAK,OAAO,IAAI,KAAK,KAAK;CAC5B;AACF;AAEA,IAAM,iBAAN,cAA2C,aAA2B;CACpE,cAAc;EACZ,MAAM,CAAC;CACT;CAIA,OAAO,KAAoB;EACzB,IAAI,CAAC,MAAM,IAAI,GAAG,GAAG,OAAO;EAC5B,KAAK,IAAI,KAAK,MAAM,IAAI,GAAG,CAAW;EACtC,OAAO;CACT;CAES,IAAI,KAAoB;EAC/B,OAAO,KAAK,OAAO,GAAG;CACxB;CAES,IAAI,KAA+B;EAC1C,OAAO,KAAK,OAAO,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,KAAA;CAC7C;AACF;AA2BA,SAAS,YAA0B,EAAE,MAAM,QAA0C,CAAC,GAAwB;CAC5G,IAAI,MAAM,uBAAO,IAAI,QAAyB;CAC9C,IAAI,QAAQ,KAAA,GAAW,uBAAO,IAAI,IAAkB;CACpD,IAAI,QAAQ,GAAG,OAAO,IAAI,aAA2B,GAAG;CACxD,OAAO,IAAI,eAA6B;AAC1C;AAEA,KAAK,SAAS"}
|
|
1
|
+
{"version":3,"file":"promise-DMQPWp6M.cjs","names":[],"sources":["../../../internals/utils/src/promise.ts"],"sourcesContent":["/** 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\nexport type 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 * Returns the value cached under `key` in `store`, computing and storing it on the first call.\n * Pass a `WeakMap` for object keys, so an entry goes away with its key, or a `Map` for primitive\n * keys. A cached `null` or `undefined` counts as a hit, so `compute` runs once per key.\n *\n * @example\n * `const refs = memo(refCache, node, () => collectRefs(node))`\n */\nexport function memo<TKey, TValue>(store: Store<TKey, TValue>, key: TKey, compute: () => TValue): TValue {\n const cached = store.get(key)\n if (cached !== undefined || store.has(key)) return cached as TValue\n const value = compute()\n store.set(key, value)\n return value\n}\n\nclass BoundedStore<TKey, TValue> implements Store<TKey, TValue> {\n readonly #entry = new Map<TKey, TValue>()\n readonly #max: number\n\n constructor(max: number) {\n this.#max = max\n }\n\n has(key: TKey): boolean {\n return this.#entry.has(key)\n }\n\n get(key: TKey): TValue | undefined {\n return this.#entry.get(key)\n }\n\n set(key: TKey, value: TValue): void {\n if (this.#entry.size >= this.#max) this.#entry.clear()\n this.#entry.set(key, value)\n }\n}\n\nclass LastEntryStore<TKey, TValue> extends BoundedStore<TKey, TValue> {\n constructor() {\n super(1)\n }\n\n // A key equal to the stored one but a different object, such as a copy of a string, replaces the\n // stored key, so the next lookup is an identity hit instead of a full comparison.\n #touch(key: TKey): boolean {\n if (!super.has(key)) return false\n this.set(key, super.get(key) as TValue)\n return true\n }\n\n override has(key: TKey): boolean {\n return this.#touch(key)\n }\n\n override get(key: TKey): TValue | undefined {\n return this.#touch(key) ? super.get(key) : undefined\n }\n}\n\n/**\n * Creates a store for `memo`. With no options it is a `Map`. Each option changes one thing:\n *\n * - `weak` holds the keys weakly, in a `WeakMap`, so an entry goes away with its key.\n * - `max` bounds the store: it empties itself before the entry that would pass `max`, which keeps a\n * cache in a long-running process from growing without end. `max: 1` keeps only the last entry.\n *\n * @example\n * `const patterns = memo.create<string, RegExp>()`\n *\n * @example Freed with its key\n * `const refs = memo.create<SchemaNode, Array<string>>({ weak: true })`\n *\n * @example Bounded\n * `const names = memo.create<string, string>({ max: 100_000 })`\n *\n * @example Many values per key\n * ```ts\n * const filesByPlugin = memo.create<string, Array<string>>()\n * memo(filesByPlugin, 'plugin-ts', () => []).push('models.ts')\n * ```\n */\nfunction createStore<TKey, TValue>(options?: { weak?: false; max?: undefined }): Map<TKey, TValue>\nfunction createStore<TKey extends WeakKey, TValue>(options: { weak: true; max?: undefined }): WeakMap<TKey, TValue>\nfunction createStore<TKey, TValue>(options: { max: number; weak?: false }): Store<TKey, TValue>\nfunction createStore<TKey, TValue>({ weak, max }: { weak?: boolean; max?: number } = {}): Store<TKey, TValue> {\n if (weak) return new WeakMap<WeakKey, TValue>() as Store<TKey, TValue>\n if (max === undefined) return new Map<TKey, TValue>()\n if (max !== 1) return new BoundedStore<TKey, TValue>(max)\n return new LastEntryStore<TKey, TValue>()\n}\n\nmemo.create = createStore\n\nexport type InParallelOptions<TItem> = {\n /**\n * Items to work through, handed out in order.\n */\n items: ReadonlyArray<TItem>\n /**\n * How many items may be in flight at once.\n */\n limit: number\n /**\n * Runs once per item, with the item's position so a caller can report progress.\n */\n run(item: TItem, index: number): Promise<void>\n}\n\n/**\n * Runs `run` over every item with at most `limit` in flight. Workers share one iterator, so each\n * takes the next item the moment it frees up instead of waiting for a batch to drain. The first\n * rejection rejects the call, and the other workers start no new item after it.\n *\n * @throws {RangeError} When `limit` is not a positive whole number, which would run no item at all.\n *\n * @example\n * ```ts\n * await inParallel({ items: files, limit: 50, run: (file) => storage.writeItem(file.path, file.source) })\n * ```\n */\nexport async function inParallel<TItem>({ items, limit, run }: InParallelOptions<TItem>): Promise<void> {\n if (!Number.isInteger(limit) || limit < 1) throw new RangeError(`inParallel needs a limit of 1 or more, got ${limit}`)\n const queue = items.entries()\n let failed = false\n\n const worker = async (): Promise<void> => {\n for (const [index, item] of queue) {\n if (failed) return\n await run(item, index).catch((error: unknown) => {\n failed = true\n throw error\n })\n }\n }\n\n await Promise.all(Array.from({ length: Math.min(limit, items.length) }, () => worker()))\n}\n"],"mappings":";;;;;;;;;;AAyBA,SAAgB,KAAmB,OAA4B,KAAW,SAA+B;CACvG,MAAM,SAAS,MAAM,IAAI,GAAG;CAC5B,IAAI,WAAW,KAAA,KAAa,MAAM,IAAI,GAAG,GAAG,OAAO;CACnD,MAAM,QAAQ,QAAQ;CACtB,MAAM,IAAI,KAAK,KAAK;CACpB,OAAO;AACT;AAEA,IAAM,eAAN,MAAgE;CACrD,yBAAS,IAAI,IAAkB;CAC/B;CAET,YAAY,KAAa;EACvB,KAAK,OAAO;CACd;CAEA,IAAI,KAAoB;EACtB,OAAO,KAAK,OAAO,IAAI,GAAG;CAC5B;CAEA,IAAI,KAA+B;EACjC,OAAO,KAAK,OAAO,IAAI,GAAG;CAC5B;CAEA,IAAI,KAAW,OAAqB;EAClC,IAAI,KAAK,OAAO,QAAQ,KAAK,MAAM,KAAK,OAAO,MAAM;EACrD,KAAK,OAAO,IAAI,KAAK,KAAK;CAC5B;AACF;AAEA,IAAM,iBAAN,cAA2C,aAA2B;CACpE,cAAc;EACZ,MAAM,CAAC;CACT;CAIA,OAAO,KAAoB;EACzB,IAAI,CAAC,MAAM,IAAI,GAAG,GAAG,OAAO;EAC5B,KAAK,IAAI,KAAK,MAAM,IAAI,GAAG,CAAW;EACtC,OAAO;CACT;CAES,IAAI,KAAoB;EAC/B,OAAO,KAAK,OAAO,GAAG;CACxB;CAES,IAAI,KAA+B;EAC1C,OAAO,KAAK,OAAO,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,KAAA;CAC7C;AACF;AA2BA,SAAS,YAA0B,EAAE,MAAM,QAA0C,CAAC,GAAwB;CAC5G,IAAI,MAAM,uBAAO,IAAI,QAAyB;CAC9C,IAAI,QAAQ,KAAA,GAAW,uBAAO,IAAI,IAAkB;CACpD,IAAI,QAAQ,GAAG,OAAO,IAAI,aAA2B,GAAG;CACxD,OAAO,IAAI,eAA6B;AAC1C;AAEA,KAAK,SAAS"}
|