@kubb/ast 5.0.0-beta.61 → 5.0.0-beta.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{defineMacro-Bv9R_9a2.cjs → defineMacro-BryDiuQl.cjs} +12 -20
- package/dist/defineMacro-BryDiuQl.cjs.map +1 -0
- package/dist/{defineMacro-BTXvS8nI.js → defineMacro-CNkUpxia.js} +12 -19
- package/dist/defineMacro-CNkUpxia.js.map +1 -0
- package/dist/{defineMacro-BLIR6k-j.d.ts → defineMacro-Vw-xQvq7.d.ts} +9 -17
- package/dist/factory.cjs +64 -4
- package/dist/factory.cjs.map +1 -0
- package/dist/factory.d.ts +2 -37
- package/dist/factory.js +58 -3
- package/dist/factory.js.map +1 -0
- package/dist/{index-BzjwdK2M.d.ts → index-CTaN_ee_.d.ts} +235 -198
- package/dist/index.cjs +19 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +36 -37
- package/dist/index.js +19 -17
- package/dist/index.js.map +1 -1
- package/dist/macros.cjs +33 -20
- package/dist/macros.cjs.map +1 -1
- package/dist/macros.d.ts +13 -11
- package/dist/macros.js +33 -20
- package/dist/macros.js.map +1 -1
- package/dist/{operationParams-BZ07xDm0.d.ts → operationParams-B44p6EQy.d.ts} +2 -2
- package/dist/{response-hnSw2NKE.cjs → response-BeG6hq2D.cjs} +394 -147
- package/dist/response-BeG6hq2D.cjs.map +1 -0
- package/dist/{response-KUdWiDWw.js → response-Rd1uisM1.js} +376 -136
- package/dist/response-Rd1uisM1.js.map +1 -0
- package/dist/{types-DyDzizSf.d.ts → types-DQTgVSwE.d.ts} +4 -54
- package/dist/types.d.ts +5 -6
- package/dist/{utils-BLJwyza-.cjs → utils-BDI3kXlb.cjs} +5 -5
- package/dist/{utils-BLJwyza-.cjs.map → utils-BDI3kXlb.cjs.map} +1 -1
- package/dist/{utils-CF_-Pn_c.js → utils-DW9rnfsD.js} +5 -5
- package/dist/{utils-CF_-Pn_c.js.map → utils-DW9rnfsD.js.map} +1 -1
- package/dist/utils.cjs +4 -4
- package/dist/utils.d.ts +11 -3
- package/dist/utils.js +3 -3
- package/dist/{visitor-DpKZ9Tk0.cjs → visitor-B7Zlnp4c.cjs} +3 -53
- package/dist/visitor-B7Zlnp4c.cjs.map +1 -0
- package/dist/{visitor-DJ6ZEJvq.js → visitor-DepQEKyp.js} +4 -42
- package/dist/visitor-DepQEKyp.js.map +1 -0
- package/package.json +1 -1
- package/src/constants.ts +0 -30
- package/src/dedupe.ts +1 -9
- package/src/defineMacro.ts +19 -12
- package/src/{node.ts → defineNode.ts} +19 -42
- package/src/dialect.ts +42 -19
- package/src/factory.ts +3 -90
- package/src/index.ts +6 -8
- package/src/macros/macroDiscriminatorEnum.ts +7 -1
- package/src/macros/macroEnumName.ts +9 -1
- package/src/macros/macroSimplifyUnion.ts +29 -19
- package/src/nodes/code.ts +32 -75
- package/src/nodes/content.ts +2 -7
- package/src/nodes/file.ts +102 -14
- package/src/nodes/function.ts +46 -46
- package/src/nodes/index.ts +2 -3
- package/src/nodes/input.ts +13 -9
- package/src/nodes/operation.ts +5 -5
- package/src/nodes/output.ts +1 -1
- package/src/nodes/parameter.ts +6 -6
- package/src/nodes/property.ts +6 -6
- package/src/nodes/requestBody.ts +6 -13
- package/src/nodes/response.ts +93 -8
- package/src/nodes/schema.ts +1 -1
- package/src/registry.ts +1 -1
- package/src/types.ts +4 -5
- package/src/utils/extractStringsFromNodes.ts +1 -0
- package/src/utils/operationParams.ts +1 -1
- package/src/visitor.ts +2 -13
- package/dist/defineMacro-BTXvS8nI.js.map +0 -1
- package/dist/defineMacro-Bv9R_9a2.cjs.map +0 -1
- package/dist/extractStringsFromNodes-Cja-xxx5.js +0 -29
- package/dist/extractStringsFromNodes-Cja-xxx5.js.map +0 -1
- package/dist/extractStringsFromNodes-DKgDjFO0.cjs +0 -34
- package/dist/extractStringsFromNodes-DKgDjFO0.cjs.map +0 -1
- package/dist/extractStringsFromNodes-p4mX1TQD.d.ts +0 -14
- package/dist/factory-CZNOGI-N.js +0 -283
- package/dist/factory-CZNOGI-N.js.map +0 -1
- package/dist/factory-DG1CVkEb.cjs +0 -300
- package/dist/factory-DG1CVkEb.cjs.map +0 -1
- package/dist/response-KUdWiDWw.js.map +0 -1
- package/dist/response-hnSw2NKE.cjs.map +0 -1
- package/dist/visitor-DJ6ZEJvq.js.map +0 -1
- package/dist/visitor-DpKZ9Tk0.cjs.map +0 -1
- package/src/mocks.ts +0 -56
- package/src/nodes/http.ts +0 -85
- /package/src/{printer.ts → definePrinter.ts} +0 -0
|
@@ -1,5 +1,75 @@
|
|
|
1
1
|
import { n as __name } from "./chunk-CNktS9qV.js";
|
|
2
2
|
|
|
3
|
+
//#region src/dialect.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The spec-specific questions a schema parser answers while turning a source document into Kubb
|
|
6
|
+
* AST nodes. The rest of the pipeline is generic JSON Schema, so this is the one seam where
|
|
7
|
+
* OpenAPI, AsyncAPI, and plain JSON Schema differ.
|
|
8
|
+
*/
|
|
9
|
+
type SchemaDialect<TSchema = unknown, TRef = TSchema, TDiscriminated = TSchema, TDocument = unknown> = {
|
|
10
|
+
/**
|
|
11
|
+
* Whether the schema is nullable.
|
|
12
|
+
*/
|
|
13
|
+
isNullable(schema?: TSchema): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the value is a `$ref` pointer.
|
|
16
|
+
*/
|
|
17
|
+
isReference(value?: unknown): value is TRef;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the schema carries a discriminator for polymorphism.
|
|
20
|
+
*/
|
|
21
|
+
isDiscriminator(value?: unknown): value is TDiscriminated;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the schema is binary data, converted to a `blob` node.
|
|
24
|
+
*/
|
|
25
|
+
isBinary(schema: TSchema): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Resolves a local `$ref` against the document, or nullish when it cannot.
|
|
28
|
+
*/
|
|
29
|
+
resolveRef<TResolved>(document: TDocument, ref: string): TResolved | null | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Derives a schema's `optional`/`nullish` flags from a parent's `required` value and the
|
|
32
|
+
* schema's own `nullable`. How "required" and "nullable" combine is spec-specific, so the
|
|
33
|
+
* dialect owns it. Method syntax keeps a concrete dialect assignable to the base
|
|
34
|
+
* `SchemaDialect` (bivariant parameters).
|
|
35
|
+
*/
|
|
36
|
+
optionality(schema: SchemaNode, required: boolean): SchemaNode;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A spec adapter's dialect. `name` identifies it in logs and diagnostics; `schema` holds the
|
|
40
|
+
* spec-specific schema questions the parser answers.
|
|
41
|
+
*/
|
|
42
|
+
type Dialect<TSchema = unknown, TRef = TSchema, TDiscriminated = TSchema, TDocument = unknown> = {
|
|
43
|
+
/**
|
|
44
|
+
* Identifies the dialect in logs and diagnostics.
|
|
45
|
+
*/
|
|
46
|
+
name: string;
|
|
47
|
+
/**
|
|
48
|
+
* The spec-specific schema behavior. See {@link SchemaDialect}.
|
|
49
|
+
*/
|
|
50
|
+
schema: SchemaDialect<TSchema, TRef, TDiscriminated, TDocument>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Types a {@link Dialect} for an adapter. Adds no runtime behavior and only pins the
|
|
54
|
+
* dialect's type for inference.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* export const oasDialect = defineDialect({
|
|
59
|
+
* name: 'oas',
|
|
60
|
+
* schema: {
|
|
61
|
+
* isNullable,
|
|
62
|
+
* isReference,
|
|
63
|
+
* isDiscriminator,
|
|
64
|
+
* isBinary: (schema) => schema.type === 'string' && schema.contentMediaType === 'application/octet-stream',
|
|
65
|
+
* resolveRef,
|
|
66
|
+
* optionality,
|
|
67
|
+
* },
|
|
68
|
+
* })
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare function defineDialect<TSchema, TRef, TDiscriminated, TDocument>(dialect: Dialect<TSchema, TRef, TDiscriminated, TDocument>): Dialect<TSchema, TRef, TDiscriminated, TDocument>;
|
|
72
|
+
//#endregion
|
|
3
73
|
//#region src/nodes/base.d.ts
|
|
4
74
|
/**
|
|
5
75
|
* `kind` values used by AST nodes.
|
|
@@ -25,12 +95,16 @@ type BaseNode = {
|
|
|
25
95
|
kind: NodeKind;
|
|
26
96
|
};
|
|
27
97
|
//#endregion
|
|
28
|
-
//#region src/
|
|
98
|
+
//#region src/defineNode.d.ts
|
|
99
|
+
/**
|
|
100
|
+
* Visitor callback names, one per traversable node kind, in traversal order.
|
|
101
|
+
* Kept in sync with the keys of `Visitor` in `visitor.ts`.
|
|
102
|
+
*/
|
|
103
|
+
declare const visitorKeys: readonly ["input", "output", "operation", "schema", "property", "parameter", "response"];
|
|
29
104
|
/**
|
|
30
|
-
*
|
|
31
|
-
* keys of `Visitor` in `visitor.ts`.
|
|
105
|
+
* One of the {@link visitorKeys} callback names.
|
|
32
106
|
*/
|
|
33
|
-
type VisitorKey =
|
|
107
|
+
type VisitorKey = (typeof visitorKeys)[number];
|
|
34
108
|
/**
|
|
35
109
|
* Distributive `Omit` that preserves each member of a union.
|
|
36
110
|
*
|
|
@@ -43,16 +117,6 @@ type VisitorKey = 'input' | 'output' | 'operation' | 'schema' | 'property' | 'pa
|
|
|
43
117
|
* ```
|
|
44
118
|
*/
|
|
45
119
|
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
46
|
-
/**
|
|
47
|
-
* Updates a schema's `optional` and `nullish` flags from a parent's `required`
|
|
48
|
-
* value and the schema's own `nullable`. Mirrors how OpenAPI parameters and
|
|
49
|
-
* object properties combine "required" and "nullable" into a single AST.
|
|
50
|
-
*
|
|
51
|
-
* - Non-required + non-nullable → `optional: true`.
|
|
52
|
-
* - Non-required + nullable → `nullish: true`.
|
|
53
|
-
* - Required → both flags cleared.
|
|
54
|
-
*/
|
|
55
|
-
declare function syncOptionality(schema: SchemaNode, required: boolean): SchemaNode;
|
|
56
120
|
/**
|
|
57
121
|
* The single definition derived from one {@link defineNode} call: the node's
|
|
58
122
|
* `create` builder, its `is` guard, and the traversal metadata the registry
|
|
@@ -64,9 +128,11 @@ type NodeDef<TNode extends BaseNode = BaseNode, TInput = never> = {
|
|
|
64
128
|
*/
|
|
65
129
|
kind: NodeKind;
|
|
66
130
|
/**
|
|
67
|
-
* Builds a node from its input, applying `defaults` and the optional `build` hook.
|
|
131
|
+
* Builds a node from its input, applying `defaults` and the optional `build` hook. An
|
|
132
|
+
* optional `dialect` is forwarded to `build` so nodes can derive spec-specific fields
|
|
133
|
+
* (e.g. a schema's `optional`/`nullish`) through `dialect.schema.optionality` when one is given.
|
|
68
134
|
*/
|
|
69
|
-
create: (input: TInput) => TNode;
|
|
135
|
+
create: (input: TInput, dialect?: Dialect) => TNode;
|
|
70
136
|
/**
|
|
71
137
|
* Type guard matching this node kind.
|
|
72
138
|
*/
|
|
@@ -79,43 +145,32 @@ type NodeDef<TNode extends BaseNode = BaseNode, TInput = never> = {
|
|
|
79
145
|
* Visitor callback name. Feeds `VISITOR_KEY_BY_KIND`.
|
|
80
146
|
*/
|
|
81
147
|
visitorKey?: VisitorKey;
|
|
82
|
-
/**
|
|
83
|
-
* When `true`, `create` is rerun after children are rebuilt so computed fields
|
|
84
|
-
* stay in sync. Feeds `nodeRebuilders`.
|
|
85
|
-
*/
|
|
86
|
-
rebuild?: boolean;
|
|
87
148
|
};
|
|
88
149
|
type DefineNodeConfig<TNode extends BaseNode, TInput, TBuilt extends object> = {
|
|
89
150
|
kind: TNode['kind'];
|
|
90
151
|
defaults?: Partial<TNode>;
|
|
91
|
-
build?: (input: TInput) => TBuilt;
|
|
152
|
+
build?: (input: TInput, dialect?: Dialect) => TBuilt;
|
|
92
153
|
children?: ReadonlyArray<string>;
|
|
93
154
|
visitorKey?: VisitorKey;
|
|
94
|
-
rebuild?: boolean;
|
|
95
155
|
};
|
|
96
156
|
/**
|
|
97
157
|
* Defines a node once and derives its `create` builder, `is` guard, and traversal
|
|
98
158
|
* metadata. `create` merges `defaults`, the `build` hook (or the raw input), and the
|
|
99
159
|
* `kind`, so node construction lives in one place without scattered `as` casts.
|
|
100
160
|
*
|
|
101
|
-
* Set `rebuild: true` when the `build` hook derives fields from children. After a
|
|
102
|
-
* transform rewrites those children, the registry reruns `create` so the derived
|
|
103
|
-
* fields stay correct.
|
|
104
|
-
*
|
|
105
161
|
* @example Simple node
|
|
106
162
|
* ```ts
|
|
107
163
|
* const importDef = defineNode<ImportNode>({ kind: 'Import' })
|
|
108
164
|
* const createImport = importDef.create
|
|
109
165
|
* ```
|
|
110
166
|
*
|
|
111
|
-
* @example Node with a build hook
|
|
167
|
+
* @example Node with a build hook
|
|
112
168
|
* ```ts
|
|
113
169
|
* const propertyDef = defineNode<PropertyNode, UserPropertyNode>({
|
|
114
170
|
* kind: 'Property',
|
|
115
171
|
* build: (props) => ({ ...props, required: props.required ?? false }),
|
|
116
172
|
* children: ['schema'],
|
|
117
173
|
* visitorKey: 'property',
|
|
118
|
-
* rebuild: true,
|
|
119
174
|
* })
|
|
120
175
|
* ```
|
|
121
176
|
*/
|
|
@@ -281,55 +336,12 @@ type FunctionNode = BaseNode & {
|
|
|
281
336
|
* // export const getPet = () => ...
|
|
282
337
|
* ```
|
|
283
338
|
*/
|
|
284
|
-
type ArrowFunctionNode =
|
|
339
|
+
type ArrowFunctionNode = Omit<FunctionNode, 'kind'> & {
|
|
285
340
|
kind: 'ArrowFunction';
|
|
286
|
-
/**
|
|
287
|
-
* Name of the arrow function (used as the `const` variable name).
|
|
288
|
-
*/
|
|
289
|
-
name: string;
|
|
290
|
-
/**
|
|
291
|
-
* Whether the function is a default export.
|
|
292
|
-
*/
|
|
293
|
-
default?: boolean | null;
|
|
294
|
-
/**
|
|
295
|
-
* Function parameter list rendered as a string (e.g. from `FunctionParams.toConstructor()`).
|
|
296
|
-
*/
|
|
297
|
-
params?: string | null;
|
|
298
|
-
/**
|
|
299
|
-
* Whether the arrow function should be exported.
|
|
300
|
-
*/
|
|
301
|
-
export?: boolean | null;
|
|
302
|
-
/**
|
|
303
|
-
* Whether the arrow function is async. When `true`, the return type is wrapped in `Promise<>`.
|
|
304
|
-
*/
|
|
305
|
-
async?: boolean | null;
|
|
306
|
-
/**
|
|
307
|
-
* TypeScript generic type parameters.
|
|
308
|
-
*
|
|
309
|
-
* @example Constrained generics
|
|
310
|
-
* `['T', 'U extends string']`
|
|
311
|
-
*/
|
|
312
|
-
generics?: string | Array<string> | null;
|
|
313
|
-
/**
|
|
314
|
-
* Return type annotation.
|
|
315
|
-
*
|
|
316
|
-
* @example Type reference
|
|
317
|
-
* `'Pet'`
|
|
318
|
-
*/
|
|
319
|
-
returnType?: string | null;
|
|
320
|
-
/**
|
|
321
|
-
* JSDoc documentation metadata.
|
|
322
|
-
*/
|
|
323
|
-
JSDoc?: JSDocNode | null;
|
|
324
341
|
/**
|
|
325
342
|
* Render the arrow function body as a single-line expression.
|
|
326
343
|
*/
|
|
327
344
|
singleLine?: boolean | null;
|
|
328
|
-
/**
|
|
329
|
-
* Child nodes representing the function body (children of the `Function.Arrow` component).
|
|
330
|
-
* Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
|
|
331
|
-
*/
|
|
332
|
-
nodes?: Array<CodeNode>;
|
|
333
345
|
};
|
|
334
346
|
/**
|
|
335
347
|
* AST node representing a raw text/string fragment in the source output.
|
|
@@ -396,6 +408,30 @@ type CodeNode = ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNo
|
|
|
396
408
|
* Definition for the {@link ConstNode}.
|
|
397
409
|
*/
|
|
398
410
|
declare const constDef: NodeDef<ConstNode, Omit<ConstNode, "kind">>;
|
|
411
|
+
/**
|
|
412
|
+
* Definition for the {@link TypeNode}.
|
|
413
|
+
*/
|
|
414
|
+
declare const typeDef: NodeDef<TypeNode, Omit<TypeNode, "kind">>;
|
|
415
|
+
/**
|
|
416
|
+
* Definition for the {@link FunctionNode}.
|
|
417
|
+
*/
|
|
418
|
+
declare const functionDef: NodeDef<FunctionNode, Omit<FunctionNode, "kind">>;
|
|
419
|
+
/**
|
|
420
|
+
* Definition for the {@link ArrowFunctionNode}.
|
|
421
|
+
*/
|
|
422
|
+
declare const arrowFunctionDef: NodeDef<ArrowFunctionNode, Omit<ArrowFunctionNode, "kind">>;
|
|
423
|
+
/**
|
|
424
|
+
* Definition for the {@link TextNode}.
|
|
425
|
+
*/
|
|
426
|
+
declare const textDef: NodeDef<TextNode, string>;
|
|
427
|
+
/**
|
|
428
|
+
* Definition for the {@link BreakNode}.
|
|
429
|
+
*/
|
|
430
|
+
declare const breakDef: NodeDef<BreakNode, void>;
|
|
431
|
+
/**
|
|
432
|
+
* Definition for the {@link JsxNode}.
|
|
433
|
+
*/
|
|
434
|
+
declare const jsxDef: NodeDef<JsxNode, string>;
|
|
399
435
|
/**
|
|
400
436
|
* Creates a `ConstNode` representing a TypeScript `const` declaration.
|
|
401
437
|
*
|
|
@@ -405,11 +441,7 @@ declare const constDef: NodeDef<ConstNode, Omit<ConstNode, "kind">>;
|
|
|
405
441
|
* // export const pets: Pet[] = ... as const
|
|
406
442
|
* ```
|
|
407
443
|
*/
|
|
408
|
-
declare const createConst: (input: Omit<ConstNode, "kind"
|
|
409
|
-
/**
|
|
410
|
-
* Definition for the {@link TypeNode}.
|
|
411
|
-
*/
|
|
412
|
-
declare const typeDef: NodeDef<TypeNode, Omit<TypeNode, "kind">>;
|
|
444
|
+
declare const createConst: (input: Omit<ConstNode, "kind">, dialect?: Dialect) => ConstNode;
|
|
413
445
|
/**
|
|
414
446
|
* Creates a `TypeNode` representing a TypeScript `type` alias declaration.
|
|
415
447
|
*
|
|
@@ -419,11 +451,7 @@ declare const typeDef: NodeDef<TypeNode, Omit<TypeNode, "kind">>;
|
|
|
419
451
|
* // export type Pet = ...
|
|
420
452
|
* ```
|
|
421
453
|
*/
|
|
422
|
-
declare const createType: (input: Omit<TypeNode, "kind"
|
|
423
|
-
/**
|
|
424
|
-
* Definition for the {@link FunctionNode}.
|
|
425
|
-
*/
|
|
426
|
-
declare const functionDef: NodeDef<FunctionNode, Omit<FunctionNode, "kind">>;
|
|
454
|
+
declare const createType: (input: Omit<TypeNode, "kind">, dialect?: Dialect) => TypeNode;
|
|
427
455
|
/**
|
|
428
456
|
* Creates a `FunctionNode` representing a TypeScript `function` declaration.
|
|
429
457
|
*
|
|
@@ -433,11 +461,7 @@ declare const functionDef: NodeDef<FunctionNode, Omit<FunctionNode, "kind">>;
|
|
|
433
461
|
* // export async function fetchPet(): Promise<Pet> { ... }
|
|
434
462
|
* ```
|
|
435
463
|
*/
|
|
436
|
-
declare const createFunction: (input: Omit<FunctionNode, "kind"
|
|
437
|
-
/**
|
|
438
|
-
* Definition for the {@link ArrowFunctionNode}.
|
|
439
|
-
*/
|
|
440
|
-
declare const arrowFunctionDef: NodeDef<ArrowFunctionNode, Omit<ArrowFunctionNode, "kind">>;
|
|
464
|
+
declare const createFunction: (input: Omit<FunctionNode, "kind">, dialect?: Dialect) => FunctionNode;
|
|
441
465
|
/**
|
|
442
466
|
* Creates an `ArrowFunctionNode` representing a TypeScript arrow function.
|
|
443
467
|
*
|
|
@@ -447,11 +471,7 @@ declare const arrowFunctionDef: NodeDef<ArrowFunctionNode, Omit<ArrowFunctionNod
|
|
|
447
471
|
* // export const double = (n: number) => ...
|
|
448
472
|
* ```
|
|
449
473
|
*/
|
|
450
|
-
declare const createArrowFunction: (input: Omit<ArrowFunctionNode, "kind"
|
|
451
|
-
/**
|
|
452
|
-
* Definition for the {@link TextNode}.
|
|
453
|
-
*/
|
|
454
|
-
declare const textDef: NodeDef<TextNode, string>;
|
|
474
|
+
declare const createArrowFunction: (input: Omit<ArrowFunctionNode, "kind">, dialect?: Dialect) => ArrowFunctionNode;
|
|
455
475
|
/**
|
|
456
476
|
* Creates a {@link TextNode} representing a raw string fragment in the source output.
|
|
457
477
|
*
|
|
@@ -461,11 +481,7 @@ declare const textDef: NodeDef<TextNode, string>;
|
|
|
461
481
|
* // { kind: 'Text', value: 'return fetch(id)' }
|
|
462
482
|
* ```
|
|
463
483
|
*/
|
|
464
|
-
declare const createText: (input: string) => TextNode;
|
|
465
|
-
/**
|
|
466
|
-
* Definition for the {@link BreakNode}.
|
|
467
|
-
*/
|
|
468
|
-
declare const breakDef: NodeDef<BreakNode, void>;
|
|
484
|
+
declare const createText: (input: string, dialect?: Dialect) => TextNode;
|
|
469
485
|
/**
|
|
470
486
|
* Creates a {@link BreakNode} representing a line break in the source output.
|
|
471
487
|
*
|
|
@@ -476,10 +492,6 @@ declare const breakDef: NodeDef<BreakNode, void>;
|
|
|
476
492
|
* ```
|
|
477
493
|
*/
|
|
478
494
|
declare function createBreak(): BreakNode;
|
|
479
|
-
/**
|
|
480
|
-
* Definition for the {@link JsxNode}.
|
|
481
|
-
*/
|
|
482
|
-
declare const jsxDef: NodeDef<JsxNode, string>;
|
|
483
495
|
/**
|
|
484
496
|
* Creates a {@link JsxNode} representing a raw JSX fragment in the source output.
|
|
485
497
|
*
|
|
@@ -489,7 +501,7 @@ declare const jsxDef: NodeDef<JsxNode, string>;
|
|
|
489
501
|
* // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
|
|
490
502
|
* ```
|
|
491
503
|
*/
|
|
492
|
-
declare const createJsx: (input: string) => JsxNode;
|
|
504
|
+
declare const createJsx: (input: string, dialect?: Dialect) => JsxNode;
|
|
493
505
|
//#endregion
|
|
494
506
|
//#region src/infer.d.ts
|
|
495
507
|
/**
|
|
@@ -673,8 +685,9 @@ type PropertyNode = BaseNode & {
|
|
|
673
685
|
*/
|
|
674
686
|
type UserPropertyNode = Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<PropertyNode, 'kind' | 'name' | 'schema'>>;
|
|
675
687
|
/**
|
|
676
|
-
* Definition for the {@link PropertyNode}. `required` defaults to `false`
|
|
677
|
-
* schema's `optional`/`nullish` flags are
|
|
688
|
+
* Definition for the {@link PropertyNode}. `required` defaults to `false`. When a `dialect` is
|
|
689
|
+
* passed to `create`, the schema's `optional`/`nullish` flags are derived through its
|
|
690
|
+
* `optionality`; without one, the schema is left as-is.
|
|
678
691
|
*/
|
|
679
692
|
declare const propertyDef: NodeDef<PropertyNode, UserPropertyNode>;
|
|
680
693
|
/**
|
|
@@ -690,7 +703,7 @@ declare const propertyDef: NodeDef<PropertyNode, UserPropertyNode>;
|
|
|
690
703
|
* // required=true, no optional/nullish
|
|
691
704
|
* ```
|
|
692
705
|
*/
|
|
693
|
-
declare const createProperty: (input: UserPropertyNode) => PropertyNode;
|
|
706
|
+
declare const createProperty: (input: UserPropertyNode, dialect?: Dialect) => PropertyNode;
|
|
694
707
|
//#endregion
|
|
695
708
|
//#region src/nodes/schema.d.ts
|
|
696
709
|
type PrimitiveSchemaType =
|
|
@@ -1355,18 +1368,14 @@ type ContentNode = BaseNode & {
|
|
|
1355
1368
|
*/
|
|
1356
1369
|
keysToOmit?: Array<string> | null;
|
|
1357
1370
|
};
|
|
1358
|
-
/**
|
|
1359
|
-
* Loosely-typed content entry accepted by the builders, normalized into a {@link ContentNode}.
|
|
1360
|
-
*/
|
|
1361
|
-
type UserContent = Omit<ContentNode, 'kind'>;
|
|
1362
1371
|
/**
|
|
1363
1372
|
* Definition for the {@link ContentNode}.
|
|
1364
1373
|
*/
|
|
1365
|
-
declare const contentDef: NodeDef<ContentNode,
|
|
1374
|
+
declare const contentDef: NodeDef<ContentNode, Omit<ContentNode, "kind">>;
|
|
1366
1375
|
/**
|
|
1367
1376
|
* Creates a `ContentNode` for a single request-body or response content type.
|
|
1368
1377
|
*/
|
|
1369
|
-
declare const createContent: (input:
|
|
1378
|
+
declare const createContent: (input: Omit<ContentNode, "kind">, dialect?: Dialect) => ContentNode;
|
|
1370
1379
|
//#endregion
|
|
1371
1380
|
//#region src/nodes/file.d.ts
|
|
1372
1381
|
/**
|
|
@@ -1605,6 +1614,19 @@ type FileNode<TMeta extends object = object> = BaseNode & {
|
|
|
1605
1614
|
* Definition for the {@link ImportNode}.
|
|
1606
1615
|
*/
|
|
1607
1616
|
declare const importDef: NodeDef<ImportNode, Omit<ImportNode, "kind">>;
|
|
1617
|
+
/**
|
|
1618
|
+
* Definition for the {@link ExportNode}.
|
|
1619
|
+
*/
|
|
1620
|
+
declare const exportDef: NodeDef<ExportNode, Omit<ExportNode, "kind">>;
|
|
1621
|
+
/**
|
|
1622
|
+
* Definition for the {@link SourceNode}.
|
|
1623
|
+
*/
|
|
1624
|
+
declare const sourceDef: NodeDef<SourceNode, Omit<SourceNode, "kind">>;
|
|
1625
|
+
/**
|
|
1626
|
+
* Definition for the {@link FileNode}. The fully resolved builder lives in
|
|
1627
|
+
* `createFile`, so this definition only supplies the guard.
|
|
1628
|
+
*/
|
|
1629
|
+
declare const fileDef: NodeDef<FileNode<object>, Omit<FileNode<object>, "kind">>;
|
|
1608
1630
|
/**
|
|
1609
1631
|
* Creates an `ImportNode` representing a language-agnostic import/dependency declaration.
|
|
1610
1632
|
*
|
|
@@ -1614,11 +1636,7 @@ declare const importDef: NodeDef<ImportNode, Omit<ImportNode, "kind">>;
|
|
|
1614
1636
|
* // import { useState } from 'react'
|
|
1615
1637
|
* ```
|
|
1616
1638
|
*/
|
|
1617
|
-
declare const createImport: (input: Omit<ImportNode, "kind"
|
|
1618
|
-
/**
|
|
1619
|
-
* Definition for the {@link ExportNode}.
|
|
1620
|
-
*/
|
|
1621
|
-
declare const exportDef: NodeDef<ExportNode, Omit<ExportNode, "kind">>;
|
|
1639
|
+
declare const createImport: (input: Omit<ImportNode, "kind">, dialect?: Dialect) => ImportNode;
|
|
1622
1640
|
/**
|
|
1623
1641
|
* Creates an `ExportNode` representing a language-agnostic export/public API declaration.
|
|
1624
1642
|
*
|
|
@@ -1628,11 +1646,7 @@ declare const exportDef: NodeDef<ExportNode, Omit<ExportNode, "kind">>;
|
|
|
1628
1646
|
* // export { Pet } from './Pet'
|
|
1629
1647
|
* ```
|
|
1630
1648
|
*/
|
|
1631
|
-
declare const createExport: (input: Omit<ExportNode, "kind"
|
|
1632
|
-
/**
|
|
1633
|
-
* Definition for the {@link SourceNode}.
|
|
1634
|
-
*/
|
|
1635
|
-
declare const sourceDef: NodeDef<SourceNode, Omit<SourceNode, "kind">>;
|
|
1649
|
+
declare const createExport: (input: Omit<ExportNode, "kind">, dialect?: Dialect) => ExportNode;
|
|
1636
1650
|
/**
|
|
1637
1651
|
* Creates a `SourceNode` representing a fragment of source code within a file.
|
|
1638
1652
|
*
|
|
@@ -1641,12 +1655,42 @@ declare const sourceDef: NodeDef<SourceNode, Omit<SourceNode, "kind">>;
|
|
|
1641
1655
|
* createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })
|
|
1642
1656
|
* ```
|
|
1643
1657
|
*/
|
|
1644
|
-
declare const createSource: (input: Omit<SourceNode, "kind"
|
|
1658
|
+
declare const createSource: (input: Omit<SourceNode, "kind">, dialect?: Dialect) => SourceNode;
|
|
1645
1659
|
/**
|
|
1646
|
-
*
|
|
1647
|
-
* `
|
|
1660
|
+
* Input descriptor for {@link createFile}, before `id`, `name`, and `extname` are computed
|
|
1661
|
+
* and `imports`/`exports`/`sources` are deduplicated.
|
|
1648
1662
|
*/
|
|
1649
|
-
|
|
1663
|
+
type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind' | 'id' | 'name' | 'extname' | 'imports' | 'exports' | 'sources'> & Pick<Partial<FileNode<TMeta>>, 'imports' | 'exports' | 'sources'>;
|
|
1664
|
+
/**
|
|
1665
|
+
* Creates a fully resolved `FileNode` from a file input descriptor.
|
|
1666
|
+
*
|
|
1667
|
+
* Computes:
|
|
1668
|
+
* - `id` SHA256 hash of the file path
|
|
1669
|
+
* - `name` `baseName` without extension
|
|
1670
|
+
* - `extname` extension extracted from `baseName`
|
|
1671
|
+
*
|
|
1672
|
+
* Deduplicates:
|
|
1673
|
+
* - `sources` via `combineSources`
|
|
1674
|
+
* - `exports` via `combineExports`
|
|
1675
|
+
* - `imports` via `combineImports` (also filters unused imports)
|
|
1676
|
+
*
|
|
1677
|
+
* @throws {Error} when `baseName` has no extension.
|
|
1678
|
+
*
|
|
1679
|
+
* @example
|
|
1680
|
+
* ```ts
|
|
1681
|
+
* const file = createFile({
|
|
1682
|
+
* baseName: 'petStore.ts',
|
|
1683
|
+
* path: 'src/models/petStore.ts',
|
|
1684
|
+
* sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],
|
|
1685
|
+
* imports: [createImport({ name: ['z'], path: 'zod' })],
|
|
1686
|
+
* exports: [createExport({ name: ['Pet'], path: './petStore' })],
|
|
1687
|
+
* })
|
|
1688
|
+
* // file.id = SHA256 hash of 'src/models/petStore.ts'
|
|
1689
|
+
* // file.name = 'petStore'
|
|
1690
|
+
* // file.extname = '.ts'
|
|
1691
|
+
* ```
|
|
1692
|
+
*/
|
|
1693
|
+
declare function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta>;
|
|
1650
1694
|
//#endregion
|
|
1651
1695
|
//#region src/nodes/function.d.ts
|
|
1652
1696
|
/**
|
|
@@ -1689,11 +1733,11 @@ type TypeLiteralNode = BaseNode & {
|
|
|
1689
1733
|
};
|
|
1690
1734
|
/**
|
|
1691
1735
|
* AST node for a single field accessed from a named group type.
|
|
1692
|
-
* TypeScript renders as `
|
|
1736
|
+
* TypeScript renders as `target['key']`.
|
|
1693
1737
|
*
|
|
1694
1738
|
* @example
|
|
1695
1739
|
* ```ts
|
|
1696
|
-
* createIndexedAccessType({
|
|
1740
|
+
* createIndexedAccessType({ target: 'GetPetPathParams', key: 'petId' })
|
|
1697
1741
|
* // GetPetPathParams['petId']
|
|
1698
1742
|
* ```
|
|
1699
1743
|
*/
|
|
@@ -1702,11 +1746,11 @@ type IndexedAccessTypeNode = BaseNode & {
|
|
|
1702
1746
|
/**
|
|
1703
1747
|
* Name of the type being indexed, e.g. `'GetPetPathParams'`.
|
|
1704
1748
|
*/
|
|
1705
|
-
|
|
1749
|
+
target: string;
|
|
1706
1750
|
/**
|
|
1707
1751
|
* Field key to access, e.g. `'petId'`.
|
|
1708
1752
|
*/
|
|
1709
|
-
|
|
1753
|
+
key: string;
|
|
1710
1754
|
};
|
|
1711
1755
|
/**
|
|
1712
1756
|
* AST node for an object destructuring binding, used as the name of a grouped function parameter.
|
|
@@ -1807,44 +1851,14 @@ type FunctionParamKind = FunctionParamNode['kind'];
|
|
|
1807
1851
|
* Definition for the {@link TypeLiteralNode}.
|
|
1808
1852
|
*/
|
|
1809
1853
|
declare const typeLiteralDef: NodeDef<TypeLiteralNode, Pick<TypeLiteralNode, "members">>;
|
|
1810
|
-
/**
|
|
1811
|
-
* Creates a {@link TypeLiteralNode} representing an inline anonymous object type.
|
|
1812
|
-
*
|
|
1813
|
-
* @example
|
|
1814
|
-
* ```ts
|
|
1815
|
-
* createTypeLiteral({ members: [{ name: 'petId', type: 'string', optional: false }] })
|
|
1816
|
-
* // { petId: string }
|
|
1817
|
-
* ```
|
|
1818
|
-
*/
|
|
1819
|
-
declare const createTypeLiteral: (input: Pick<TypeLiteralNode, "members">) => TypeLiteralNode;
|
|
1820
1854
|
/**
|
|
1821
1855
|
* Definition for the {@link IndexedAccessTypeNode}.
|
|
1822
1856
|
*/
|
|
1823
1857
|
declare const indexedAccessTypeDef: NodeDef<IndexedAccessTypeNode, Omit<IndexedAccessTypeNode, "kind">>;
|
|
1824
|
-
/**
|
|
1825
|
-
* Creates an {@link IndexedAccessTypeNode} representing a single field accessed from a named type.
|
|
1826
|
-
*
|
|
1827
|
-
* @example
|
|
1828
|
-
* ```ts
|
|
1829
|
-
* createIndexedAccessType({ objectType: 'DeletePetPathParams', indexType: 'petId' })
|
|
1830
|
-
* // DeletePetPathParams['petId']
|
|
1831
|
-
* ```
|
|
1832
|
-
*/
|
|
1833
|
-
declare const createIndexedAccessType: (input: Omit<IndexedAccessTypeNode, "kind">) => IndexedAccessTypeNode;
|
|
1834
1858
|
/**
|
|
1835
1859
|
* Definition for the {@link ObjectBindingPatternNode}.
|
|
1836
1860
|
*/
|
|
1837
1861
|
declare const objectBindingPatternDef: NodeDef<ObjectBindingPatternNode, Pick<ObjectBindingPatternNode, "elements">>;
|
|
1838
|
-
/**
|
|
1839
|
-
* Creates an {@link ObjectBindingPatternNode} for a destructured parameter binding.
|
|
1840
|
-
*
|
|
1841
|
-
* @example
|
|
1842
|
-
* ```ts
|
|
1843
|
-
* createObjectBindingPattern({ elements: [{ name: 'id' }, { name: 'name' }] })
|
|
1844
|
-
* // { id, name }
|
|
1845
|
-
* ```
|
|
1846
|
-
*/
|
|
1847
|
-
declare const createObjectBindingPattern: (input: Pick<ObjectBindingPatternNode, "elements">) => ObjectBindingPatternNode;
|
|
1848
1862
|
/**
|
|
1849
1863
|
* Plain property descriptor for a destructured group built by {@link createFunctionParameter}.
|
|
1850
1864
|
*/
|
|
@@ -1870,6 +1884,40 @@ type FunctionParameterInput = {
|
|
|
1870
1884
|
* paired with a {@link TypeLiteralNode} type.
|
|
1871
1885
|
*/
|
|
1872
1886
|
declare const functionParameterDef: NodeDef<FunctionParameterNode, FunctionParameterInput>;
|
|
1887
|
+
/**
|
|
1888
|
+
* Definition for the {@link FunctionParametersNode}.
|
|
1889
|
+
*/
|
|
1890
|
+
declare const functionParametersDef: NodeDef<FunctionParametersNode, Partial<Omit<FunctionParametersNode, "kind">>>;
|
|
1891
|
+
/**
|
|
1892
|
+
* Creates a {@link TypeLiteralNode} representing an inline anonymous object type.
|
|
1893
|
+
*
|
|
1894
|
+
* @example
|
|
1895
|
+
* ```ts
|
|
1896
|
+
* createTypeLiteral({ members: [{ name: 'petId', type: 'string', optional: false }] })
|
|
1897
|
+
* // { petId: string }
|
|
1898
|
+
* ```
|
|
1899
|
+
*/
|
|
1900
|
+
declare const createTypeLiteral: (input: Pick<TypeLiteralNode, "members">, dialect?: Dialect) => TypeLiteralNode;
|
|
1901
|
+
/**
|
|
1902
|
+
* Creates an {@link IndexedAccessTypeNode} representing a single field accessed from a named type.
|
|
1903
|
+
*
|
|
1904
|
+
* @example
|
|
1905
|
+
* ```ts
|
|
1906
|
+
* createIndexedAccessType({ target: 'DeletePetPathParams', key: 'petId' })
|
|
1907
|
+
* // DeletePetPathParams['petId']
|
|
1908
|
+
* ```
|
|
1909
|
+
*/
|
|
1910
|
+
declare const createIndexedAccessType: (input: Omit<IndexedAccessTypeNode, "kind">, dialect?: Dialect) => IndexedAccessTypeNode;
|
|
1911
|
+
/**
|
|
1912
|
+
* Creates an {@link ObjectBindingPatternNode} for a destructured parameter binding.
|
|
1913
|
+
*
|
|
1914
|
+
* @example
|
|
1915
|
+
* ```ts
|
|
1916
|
+
* createObjectBindingPattern({ elements: [{ name: 'id' }, { name: 'name' }] })
|
|
1917
|
+
* // { id, name }
|
|
1918
|
+
* ```
|
|
1919
|
+
*/
|
|
1920
|
+
declare const createObjectBindingPattern: (input: Pick<ObjectBindingPatternNode, "elements">, dialect?: Dialect) => ObjectBindingPatternNode;
|
|
1873
1921
|
/**
|
|
1874
1922
|
* Creates a `FunctionParameterNode`. `optional` defaults to `false`.
|
|
1875
1923
|
*
|
|
@@ -1885,11 +1933,7 @@ declare const functionParameterDef: NodeDef<FunctionParameterNode, FunctionParam
|
|
|
1885
1933
|
* // → { id, name }: { id: string; name?: string } = {}
|
|
1886
1934
|
* ```
|
|
1887
1935
|
*/
|
|
1888
|
-
declare const createFunctionParameter: (input: FunctionParameterInput) => FunctionParameterNode;
|
|
1889
|
-
/**
|
|
1890
|
-
* Definition for the {@link FunctionParametersNode}.
|
|
1891
|
-
*/
|
|
1892
|
-
declare const functionParametersDef: NodeDef<FunctionParametersNode, Partial<Omit<FunctionParametersNode, "kind">>>;
|
|
1936
|
+
declare const createFunctionParameter: (input: FunctionParameterInput, dialect?: Dialect) => FunctionParameterNode;
|
|
1893
1937
|
/**
|
|
1894
1938
|
* Creates a `FunctionParametersNode` from an ordered list of parameters.
|
|
1895
1939
|
*
|
|
@@ -1954,8 +1998,9 @@ type ParameterNode = BaseNode & {
|
|
|
1954
1998
|
};
|
|
1955
1999
|
type UserParameterNode = Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial<Omit<ParameterNode, 'kind' | 'name' | 'in' | 'schema'>>;
|
|
1956
2000
|
/**
|
|
1957
|
-
* Definition for the {@link ParameterNode}. `required` defaults to `false`
|
|
1958
|
-
* schema's `optional`/`nullish` flags are
|
|
2001
|
+
* Definition for the {@link ParameterNode}. `required` defaults to `false`. When a `dialect` is
|
|
2002
|
+
* passed to `create`, the schema's `optional`/`nullish` flags are derived through its
|
|
2003
|
+
* `optionality`; without one, the schema is left as-is.
|
|
1959
2004
|
*/
|
|
1960
2005
|
declare const parameterDef: NodeDef<ParameterNode, UserParameterNode>;
|
|
1961
2006
|
/**
|
|
@@ -1971,7 +2016,7 @@ declare const parameterDef: NodeDef<ParameterNode, UserParameterNode>;
|
|
|
1971
2016
|
* })
|
|
1972
2017
|
* ```
|
|
1973
2018
|
*/
|
|
1974
|
-
declare const createParameter: (input: UserParameterNode) => ParameterNode;
|
|
2019
|
+
declare const createParameter: (input: UserParameterNode, dialect?: Dialect) => ParameterNode;
|
|
1975
2020
|
//#endregion
|
|
1976
2021
|
//#region src/nodes/requestBody.d.ts
|
|
1977
2022
|
/**
|
|
@@ -2011,21 +2056,16 @@ type RequestBodyNode = BaseNode & {
|
|
|
2011
2056
|
content?: Array<ContentNode>;
|
|
2012
2057
|
};
|
|
2013
2058
|
/**
|
|
2014
|
-
*
|
|
2059
|
+
* Definition for the {@link RequestBodyNode}. Content entries are built upfront with
|
|
2060
|
+
* {@link createContent}, mirroring how `parameters` and `responses` take prebuilt nodes.
|
|
2015
2061
|
*/
|
|
2016
|
-
|
|
2017
|
-
content?: Array<UserContent>;
|
|
2018
|
-
};
|
|
2062
|
+
declare const requestBodyDef: NodeDef<RequestBodyNode, Omit<RequestBodyNode, "kind">>;
|
|
2019
2063
|
/**
|
|
2020
|
-
*
|
|
2064
|
+
* Creates a `RequestBodyNode`.
|
|
2021
2065
|
*/
|
|
2022
|
-
declare const
|
|
2023
|
-
/**
|
|
2024
|
-
* Creates a `RequestBodyNode`, normalizing each content entry into a `ContentNode`.
|
|
2025
|
-
*/
|
|
2026
|
-
declare const createRequestBody: (input: UserRequestBody) => RequestBodyNode;
|
|
2066
|
+
declare const createRequestBody: (input: Omit<RequestBodyNode, "kind">, dialect?: Dialect) => RequestBodyNode;
|
|
2027
2067
|
//#endregion
|
|
2028
|
-
//#region src/nodes/
|
|
2068
|
+
//#region src/nodes/response.d.ts
|
|
2029
2069
|
/**
|
|
2030
2070
|
* All supported HTTP status code literals as strings, as used in API specs
|
|
2031
2071
|
* (for example, `"200"` and `"404"`).
|
|
@@ -2043,8 +2083,6 @@ type HttpStatusCode = '100' | '101' | '102' | '103' | '200' | '201' | '202' | '2
|
|
|
2043
2083
|
* ```
|
|
2044
2084
|
*/
|
|
2045
2085
|
type StatusCode = HttpStatusCode | 'default';
|
|
2046
|
-
//#endregion
|
|
2047
|
-
//#region src/nodes/response.d.ts
|
|
2048
2086
|
/**
|
|
2049
2087
|
* AST node representing one operation response variant.
|
|
2050
2088
|
*
|
|
@@ -2057,7 +2095,7 @@ type StatusCode = HttpStatusCode | 'default';
|
|
|
2057
2095
|
* const response: ResponseNode = {
|
|
2058
2096
|
* kind: 'Response',
|
|
2059
2097
|
* statusCode: '200',
|
|
2060
|
-
* content: [{ contentType: 'application/json', schema: createSchema({ type: 'string' }) }],
|
|
2098
|
+
* content: [{ kind: 'Content', contentType: 'application/json', schema: createSchema({ type: 'string' }) }],
|
|
2061
2099
|
* }
|
|
2062
2100
|
* ```
|
|
2063
2101
|
*/
|
|
@@ -2092,7 +2130,7 @@ type ResponseNode = BaseNode & {
|
|
|
2092
2130
|
content?: Array<ContentNode>;
|
|
2093
2131
|
};
|
|
2094
2132
|
type ResponseInput = Pick<ResponseNode, 'statusCode'> & Partial<Omit<ResponseNode, 'kind' | 'statusCode' | 'content'>> & {
|
|
2095
|
-
content?: Array<
|
|
2133
|
+
content?: Array<ContentNode>;
|
|
2096
2134
|
schema?: SchemaNode;
|
|
2097
2135
|
mediaType?: string | null;
|
|
2098
2136
|
keysToOmit?: Array<string> | null;
|
|
@@ -2109,11 +2147,11 @@ declare const responseDef: NodeDef<ResponseNode, ResponseInput>;
|
|
|
2109
2147
|
* ```ts
|
|
2110
2148
|
* const response = createResponse({
|
|
2111
2149
|
* statusCode: '200',
|
|
2112
|
-
* content: [{ contentType: 'application/json', schema: createSchema({ type: 'object', properties: [] }) }],
|
|
2150
|
+
* content: [createContent({ contentType: 'application/json', schema: createSchema({ type: 'object', properties: [] }) })],
|
|
2113
2151
|
* })
|
|
2114
2152
|
* ```
|
|
2115
2153
|
*/
|
|
2116
|
-
declare const createResponse: (input: ResponseInput) => ResponseNode;
|
|
2154
|
+
declare const createResponse: (input: ResponseInput, dialect?: Dialect) => ResponseNode;
|
|
2117
2155
|
//#endregion
|
|
2118
2156
|
//#region src/nodes/operation.d.ts
|
|
2119
2157
|
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE';
|
|
@@ -2217,7 +2255,7 @@ type OperationInput = {
|
|
|
2217
2255
|
operationId: string;
|
|
2218
2256
|
method?: HttpOperationNode['method'];
|
|
2219
2257
|
path?: HttpOperationNode['path'];
|
|
2220
|
-
requestBody?:
|
|
2258
|
+
requestBody?: Omit<RequestBodyNode, 'kind'>;
|
|
2221
2259
|
[key: string]: unknown;
|
|
2222
2260
|
};
|
|
2223
2261
|
/**
|
|
@@ -2236,10 +2274,10 @@ declare const operationDef: NodeDef<OperationNode, OperationInput>;
|
|
|
2236
2274
|
* ```
|
|
2237
2275
|
*/
|
|
2238
2276
|
declare function createOperation(props: Pick<HttpOperationNode, 'operationId' | 'method' | 'path'> & Partial<Omit<HttpOperationNode, 'kind' | 'operationId' | 'method' | 'path' | 'requestBody'>> & {
|
|
2239
|
-
requestBody?:
|
|
2277
|
+
requestBody?: Omit<RequestBodyNode, 'kind'>;
|
|
2240
2278
|
}): HttpOperationNode;
|
|
2241
2279
|
declare function createOperation(props: Pick<GenericOperationNode, 'operationId'> & Partial<Omit<GenericOperationNode, 'kind' | 'operationId' | 'requestBody'>> & {
|
|
2242
|
-
requestBody?:
|
|
2280
|
+
requestBody?: Omit<RequestBodyNode, 'kind'>;
|
|
2243
2281
|
}): GenericOperationNode;
|
|
2244
2282
|
//#endregion
|
|
2245
2283
|
//#region src/nodes/input.d.ts
|
|
@@ -2306,8 +2344,7 @@ type InputMeta = {
|
|
|
2306
2344
|
* Produced by the adapter and consumed by all Kubb plugins.
|
|
2307
2345
|
*
|
|
2308
2346
|
* `Stream` switches `schemas` and `operations` between eager `Array`s (the default) and lazy
|
|
2309
|
-
* `AsyncIterable`s. The streaming variant `InputNode<true>` yields nodes one at a time
|
|
2310
|
-
* `meta` optional, since the adapter can emit metadata before the first node is parsed.
|
|
2347
|
+
* `AsyncIterable`s. The streaming variant `InputNode<true>` yields nodes one at a time.
|
|
2311
2348
|
*
|
|
2312
2349
|
* @example
|
|
2313
2350
|
* ```ts
|
|
@@ -2339,19 +2376,19 @@ type InputNode<Stream extends boolean = false> = BaseNode & {
|
|
|
2339
2376
|
* All operation nodes in the document.
|
|
2340
2377
|
*/
|
|
2341
2378
|
operations: Streamable<OperationNode, Stream>;
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2379
|
+
/**
|
|
2380
|
+
* Document metadata populated by the adapter.
|
|
2381
|
+
*/
|
|
2345
2382
|
meta: InputMeta;
|
|
2346
|
-
}
|
|
2383
|
+
};
|
|
2347
2384
|
/**
|
|
2348
2385
|
* Definition for the {@link InputNode}.
|
|
2349
2386
|
*/
|
|
2350
2387
|
declare const inputDef: NodeDef<InputNode<false>, Partial<Omit<InputNode<false>, "kind">>>;
|
|
2351
2388
|
/**
|
|
2352
2389
|
* Creates an `InputNode`. Pass `stream: true` for the streaming variant whose `schemas` and
|
|
2353
|
-
* `operations` are `AsyncIterable` sources
|
|
2354
|
-
*
|
|
2390
|
+
* `operations` are `AsyncIterable` sources. Otherwise it builds the eager variant with array
|
|
2391
|
+
* `schemas`/`operations`. Both variants get the defaulted `meta`.
|
|
2355
2392
|
*
|
|
2356
2393
|
* @example Eager
|
|
2357
2394
|
* ```ts
|
|
@@ -2429,5 +2466,5 @@ declare function createOutput(overrides?: Partial<Omit<OutputNode, 'kind'>>): Ou
|
|
|
2429
2466
|
*/
|
|
2430
2467
|
type Node = InputNode | OutputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode | RequestBodyNode | ContentNode | FunctionParamNode | FileNode | ImportNode | ExportNode | SourceNode | ConstNode | TypeNode | FunctionNode | ArrowFunctionNode;
|
|
2431
2468
|
//#endregion
|
|
2432
|
-
export {
|
|
2433
|
-
//# sourceMappingURL=index-
|
|
2469
|
+
export { exportDef as $, textDef as $t, IndexedAccessTypeNode as A, InferSchemaNode as At, functionParametersDef as B, TypeNode as Bt, ParameterNode as C, UrlSchemaNode as Ct, FunctionParamNode as D, UserPropertyNode as Dt, FunctionParamKind as E, PropertyNode as Et, createFunctionParameters as F, ConstNode as Ft, FileNode as G, createBreak as Gt, objectBindingPatternDef as H, breakDef as Ht, createIndexedAccessType as I, FunctionNode as It, UserFileNode as J, createJsx as Jt, ImportNode as K, createConst as Kt, createObjectBindingPattern as L, JSDocNode as Lt, TypeExpression as M, ArrowFunctionNode as Mt, TypeLiteralNode as N, BreakNode as Nt, FunctionParameterNode as O, createProperty as Ot, createFunctionParameter as P, CodeNode as Pt, createSource as Q, jsxDef as Qt, createTypeLiteral as R, JsxNode as Rt, ParameterLocation as S, UnionSchemaNode as St, parameterDef as T, schemaDef as Tt, typeLiteralDef as U, constDef as Ut, indexedAccessTypeDef as V, arrowFunctionDef as Vt, ExportNode as W, createArrowFunction as Wt, createFile as X, createType as Xt, createExport as Y, createText as Yt, createImport as Z, functionDef as Zt, createResponse as _, SchemaNode as _t, InputMeta as a, NodeKind as an, createContent as at, createRequestBody as b, StringSchemaNode as bt, inputDef as c, defineDialect as cn, DatetimeSchemaNode as ct, HttpOperationNode as d, NumberSchemaNode as dt, typeDef as en, fileDef as et, OperationNode as f, ObjectSchemaNode as ft, StatusCode as g, ScalarSchemaType as gt, ResponseNode as h, ScalarSchemaNode as ht, outputDef as i, BaseNode as in, contentDef as it, ObjectBindingPatternNode as j, ParserOptions as jt, FunctionParametersNode as k, propertyDef as kt, GenericOperationNode as l, EnumSchemaNode as lt, operationDef as m, RefSchemaNode as mt, OutputNode as n, NodeDef as nn, sourceDef as nt, InputNode as o, Dialect as on, ArraySchemaNode as ot, createOperation as p, PrimitiveSchemaType as pt, SourceNode as q, createFunction as qt, createOutput as r, defineNode as rn, ContentNode as rt, createInput as s, SchemaDialect as sn, DateSchemaNode as st, Node as t, DistributiveOmit as tn, importDef as tt, HttpMethod as u, IntersectionSchemaNode as ut, responseDef as v, SchemaNodeByType as vt, createParameter as w, createSchema as wt, requestBodyDef as x, TimeSchemaNode as xt, RequestBodyNode as y, SchemaType as yt, functionParameterDef as z, TextNode as zt };
|
|
2470
|
+
//# sourceMappingURL=index-CTaN_ee_.d.ts.map
|