@kubb/ast 5.14.6 → 5.15.1
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/index.cjs +37 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -64
- package/dist/index.d.ts +11 -64
- package/dist/index.js +37 -57
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
//#endregion
|
|
2
|
-
//#region src/constants.d.ts
|
|
3
1
|
/**
|
|
4
2
|
* Node kind discriminators used by every AST node (for example `node.kind === nodeKinds.text`).
|
|
5
3
|
*/
|
|
@@ -145,8 +143,6 @@ export declare const schemaTypes: {
|
|
|
145
143
|
*/
|
|
146
144
|
readonly never: 'never';
|
|
147
145
|
};
|
|
148
|
-
//#endregion
|
|
149
|
-
//#region src/nodes/base.d.ts
|
|
150
146
|
/**
|
|
151
147
|
* `kind` values used by AST nodes.
|
|
152
148
|
*
|
|
@@ -178,8 +174,6 @@ type BaseNode = {
|
|
|
178
174
|
};
|
|
179
175
|
/** `Omit` applied to each member of a union, so the union survives. */
|
|
180
176
|
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
181
|
-
//#endregion
|
|
182
|
-
//#region src/nodes/property.d.ts
|
|
183
177
|
/**
|
|
184
178
|
* AST node representing one named object property.
|
|
185
179
|
*
|
|
@@ -227,8 +221,6 @@ type UserPropertyNode = Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<Pro
|
|
|
227
221
|
* ```
|
|
228
222
|
*/
|
|
229
223
|
declare function createProperty(input: UserPropertyNode): PropertyNode;
|
|
230
|
-
//#endregion
|
|
231
|
-
//#region src/nodes/schema.d.ts
|
|
232
224
|
type PrimitiveSchemaType =
|
|
233
225
|
/**
|
|
234
226
|
* Text value.
|
|
@@ -849,8 +841,6 @@ type CreateSchemaOutput<T extends CreateSchemaInput> = SchemaNodeByType[T['type'
|
|
|
849
841
|
*/
|
|
850
842
|
declare function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>;
|
|
851
843
|
declare function createSchema(props: CreateSchemaInput): SchemaNode;
|
|
852
|
-
//#endregion
|
|
853
|
-
//#region src/nodes/parameter.d.ts
|
|
854
844
|
type ParameterLocation = 'path' | 'query' | 'header' | 'cookie';
|
|
855
845
|
/**
|
|
856
846
|
* Parameter serialization style, controlling how a parameter value is rendered into the request.
|
|
@@ -925,8 +915,6 @@ type UserParameterNode = Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial
|
|
|
925
915
|
* ```
|
|
926
916
|
*/
|
|
927
917
|
declare function createParameter(input: UserParameterNode): ParameterNode;
|
|
928
|
-
//#endregion
|
|
929
|
-
//#region src/nodes/content.d.ts
|
|
930
918
|
/**
|
|
931
919
|
* How one body property is serialized, from the `encoding` entry of its media type.
|
|
932
920
|
*/
|
|
@@ -990,8 +978,6 @@ type ContentNode = BaseNode & {
|
|
|
990
978
|
* Creates a `ContentNode` for a single request-body or response content type.
|
|
991
979
|
*/
|
|
992
980
|
declare const createContent: (input: Omit<ContentNode, "kind">) => ContentNode;
|
|
993
|
-
//#endregion
|
|
994
|
-
//#region src/nodes/requestBody.d.ts
|
|
995
981
|
/**
|
|
996
982
|
* AST node representing an operation request body.
|
|
997
983
|
*
|
|
@@ -1032,8 +1018,6 @@ type RequestBodyNode = BaseNode & {
|
|
|
1032
1018
|
* Creates a `RequestBodyNode`.
|
|
1033
1019
|
*/
|
|
1034
1020
|
declare const createRequestBody: (input: Omit<RequestBodyNode, "kind">) => RequestBodyNode;
|
|
1035
|
-
//#endregion
|
|
1036
|
-
//#region src/nodes/response.d.ts
|
|
1037
1021
|
type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
1038
1022
|
/**
|
|
1039
1023
|
* Response status code literal used by operations.
|
|
@@ -1112,8 +1096,6 @@ type ResponseInput = Pick<ResponseNode, 'statusCode'> & Partial<Omit<ResponseNod
|
|
|
1112
1096
|
* ```
|
|
1113
1097
|
*/
|
|
1114
1098
|
declare function createResponse(props: ResponseInput): ResponseNode;
|
|
1115
|
-
//#endregion
|
|
1116
|
-
//#region src/nodes/operation.d.ts
|
|
1117
1099
|
/**
|
|
1118
1100
|
* HTTP method an operation responds to. `QUERY` is the safe, idempotent method with a request body
|
|
1119
1101
|
* from RFC 10008, declared with the `query` field of an OpenAPI 3.2 path item.
|
|
@@ -1228,8 +1210,6 @@ declare function createOperation(props: Pick<HttpOperationNode, 'operationId' |
|
|
|
1228
1210
|
declare function createOperation(props: Pick<GenericOperationNode, 'operationId'> & Partial<Omit<GenericOperationNode, 'kind' | 'operationId' | 'requestBody'>> & {
|
|
1229
1211
|
requestBody?: Omit<RequestBodyNode, 'kind'>;
|
|
1230
1212
|
}): GenericOperationNode;
|
|
1231
|
-
//#endregion
|
|
1232
|
-
//#region src/guards.d.ts
|
|
1233
1213
|
/**
|
|
1234
1214
|
* Narrows a `SchemaNode` to the variant that matches `type`.
|
|
1235
1215
|
*
|
|
@@ -1251,8 +1231,6 @@ export declare function narrowSchema<T extends SchemaNode['type']>(node: SchemaN
|
|
|
1251
1231
|
* ```
|
|
1252
1232
|
*/
|
|
1253
1233
|
export declare function isHttpOperationNode(node: OperationNode): node is HttpOperationNode;
|
|
1254
|
-
//#endregion
|
|
1255
|
-
//#region src/nodes/code.d.ts
|
|
1256
1234
|
/**
|
|
1257
1235
|
* JSDoc documentation metadata attached to code declarations.
|
|
1258
1236
|
*/
|
|
@@ -1553,8 +1531,6 @@ declare function createBreak(): BreakNode;
|
|
|
1553
1531
|
* ```
|
|
1554
1532
|
*/
|
|
1555
1533
|
declare function createJsx(value: string): JsxNode;
|
|
1556
|
-
//#endregion
|
|
1557
|
-
//#region src/nodes/file.d.ts
|
|
1558
1534
|
/**
|
|
1559
1535
|
* Supported file extensions.
|
|
1560
1536
|
*/
|
|
@@ -1877,8 +1853,6 @@ type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind'
|
|
|
1877
1853
|
* ```
|
|
1878
1854
|
*/
|
|
1879
1855
|
declare function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta>;
|
|
1880
|
-
//#endregion
|
|
1881
|
-
//#region src/nodes/input.d.ts
|
|
1882
1856
|
/**
|
|
1883
1857
|
* A server from the source document, with `{variable}` placeholders filled from their defaults.
|
|
1884
1858
|
*/
|
|
@@ -1914,13 +1888,13 @@ type InputSecurityScheme = {
|
|
|
1914
1888
|
/**
|
|
1915
1889
|
* Metadata for an API document, populated by the adapter and available to every generator.
|
|
1916
1890
|
*
|
|
1917
|
-
*
|
|
1918
|
-
*
|
|
1919
|
-
*
|
|
1891
|
+
* Computed fields (`circularNames`, `enumNames`) are sets, pre-calculated once during the adapter
|
|
1892
|
+
* pre-scan so generators never need to iterate the full schema list themselves. Every other field
|
|
1893
|
+
* is a plain JSON value.
|
|
1920
1894
|
*
|
|
1921
1895
|
* @example
|
|
1922
1896
|
* ```ts
|
|
1923
|
-
* const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://api.example.com/v2', circularNames:
|
|
1897
|
+
* const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://api.example.com/v2', circularNames: new Set(), enumNames: new Set() }
|
|
1924
1898
|
* ```
|
|
1925
1899
|
*/
|
|
1926
1900
|
type InputMeta = {
|
|
@@ -1951,29 +1925,23 @@ type InputMeta = {
|
|
|
1951
1925
|
* Computed once during the adapter pre-scan, so a generator never has to
|
|
1952
1926
|
* call `findCircularSchemas` itself.
|
|
1953
1927
|
*
|
|
1954
|
-
* Convert to a `Set` once at the start of a generator, not per-schema,
|
|
1955
|
-
* so lookups stay O(1) without repeated allocations.
|
|
1956
|
-
*
|
|
1957
1928
|
* @example Wrap a circular schema in z.lazy()
|
|
1958
1929
|
* ```ts
|
|
1959
|
-
*
|
|
1960
|
-
* if (circular.has(schema.name)) { ... }
|
|
1930
|
+
* if (meta.circularNames.has(schema.name)) { ... }
|
|
1961
1931
|
* ```
|
|
1962
1932
|
*/
|
|
1963
|
-
circularNames:
|
|
1933
|
+
circularNames: ReadonlySet<string>;
|
|
1964
1934
|
/**
|
|
1965
1935
|
* Names of schemas whose type is `enum`.
|
|
1966
1936
|
* Computed once during the adapter pre-scan, so a generator never has to
|
|
1967
1937
|
* filter the schema list itself.
|
|
1968
1938
|
*
|
|
1969
|
-
* Convert to a `Set` once at the start of a generator when you need repeated
|
|
1970
|
-
* membership checks, so each check stays O(1) instead of an array scan.
|
|
1971
|
-
*
|
|
1972
1939
|
* @example Check if a referenced schema is an enum
|
|
1973
|
-
*
|
|
1974
|
-
*
|
|
1940
|
+
* ```ts
|
|
1941
|
+
* const isEnum = meta.enumNames.has(schemaName)
|
|
1942
|
+
* ```
|
|
1975
1943
|
*/
|
|
1976
|
-
enumNames:
|
|
1944
|
+
enumNames: ReadonlySet<string>;
|
|
1977
1945
|
};
|
|
1978
1946
|
/**
|
|
1979
1947
|
* Input AST node that contains all schemas and operations for one API document.
|
|
@@ -1985,7 +1953,7 @@ type InputMeta = {
|
|
|
1985
1953
|
* kind: 'Input',
|
|
1986
1954
|
* schemas: [],
|
|
1987
1955
|
* operations: [],
|
|
1988
|
-
* meta: { circularNames:
|
|
1956
|
+
* meta: { circularNames: new Set(), enumNames: new Set() },
|
|
1989
1957
|
* }
|
|
1990
1958
|
* ```
|
|
1991
1959
|
*/
|
|
@@ -2039,8 +2007,6 @@ declare namespace index_d_exports$1 {
|
|
|
2039
2007
|
* ```
|
|
2040
2008
|
*/
|
|
2041
2009
|
type Node = InputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode | RequestBodyNode | ContentNode | FileNode | ImportNode | ExportNode | SourceNode | ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode;
|
|
2042
|
-
//#endregion
|
|
2043
|
-
//#region src/visitor.d.ts
|
|
2044
2010
|
/**
|
|
2045
2011
|
* Ordered mapping of `[NodeType, ParentType]` pairs.
|
|
2046
2012
|
*
|
|
@@ -2266,8 +2232,6 @@ export declare function collect<T>(node: Node, options: CollectOptions<T>): Gene
|
|
|
2266
2232
|
* ```
|
|
2267
2233
|
*/
|
|
2268
2234
|
export declare function collectSync<T>(node: Node, options: CollectOptions<T>): Array<T>;
|
|
2269
|
-
//#endregion
|
|
2270
|
-
//#region src/defineMacro.d.ts
|
|
2271
2235
|
/**
|
|
2272
2236
|
* Ordering hint shared by macros and plugins. `pre` runs before unmarked items, `post` after,
|
|
2273
2237
|
* and `undefined` keeps declaration order.
|
|
@@ -2341,15 +2305,11 @@ export declare function composeMacros(macros: ReadonlyArray<Macro>): Visitor;
|
|
|
2341
2305
|
export declare function applyMacros<TNode extends Node>(root: TNode, macros: ReadonlyArray<Macro>, options?: {
|
|
2342
2306
|
depth?: VisitorDepth;
|
|
2343
2307
|
}): TNode;
|
|
2344
|
-
//#endregion
|
|
2345
|
-
//#region src/optionality.d.ts
|
|
2346
2308
|
/**
|
|
2347
2309
|
* Generic JSON Schema optionality: a non-required field is optional, and a
|
|
2348
2310
|
* non-required nullable field is nullish.
|
|
2349
2311
|
*/
|
|
2350
2312
|
export declare function optionality(schema: SchemaNode, required: boolean): SchemaNode;
|
|
2351
|
-
//#endregion
|
|
2352
|
-
//#region src/createPrinter.d.ts
|
|
2353
2313
|
/**
|
|
2354
2314
|
* Runtime context passed as `this` to printer handlers.
|
|
2355
2315
|
*
|
|
@@ -2545,8 +2505,6 @@ type PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) =
|
|
|
2545
2505
|
* ```
|
|
2546
2506
|
*/
|
|
2547
2507
|
export declare function createPrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T>;
|
|
2548
|
-
//#endregion
|
|
2549
|
-
//#region src/utils/extractStringsFromNodes.d.ts
|
|
2550
2508
|
/**
|
|
2551
2509
|
* Extracts all string content from a `CodeNode` tree recursively.
|
|
2552
2510
|
*
|
|
@@ -2554,8 +2512,6 @@ export declare function createPrinter<T extends PrinterFactoryOptions = PrinterF
|
|
|
2554
2512
|
* and nested node content. Used to build the full source string for import filtering.
|
|
2555
2513
|
*/
|
|
2556
2514
|
export declare function extractStringsFromNodes(nodes: Array<CodeNode> | undefined): string;
|
|
2557
|
-
//#endregion
|
|
2558
|
-
//#region src/utils/inline.d.ts
|
|
2559
2515
|
/**
|
|
2560
2516
|
* Whether every source of `file` is inline. Other files absorb such a file, so it is never written.
|
|
2561
2517
|
*/
|
|
@@ -2601,8 +2557,6 @@ type InlineFilesOptions = {
|
|
|
2601
2557
|
* `inline.expression`, until no inline names are left. The definitions' own imports move to the importing file.
|
|
2602
2558
|
*/
|
|
2603
2559
|
export declare function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult;
|
|
2604
|
-
//#endregion
|
|
2605
|
-
//#region src/utils/refs.d.ts
|
|
2606
2560
|
/**
|
|
2607
2561
|
* Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.
|
|
2608
2562
|
* The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`
|
|
@@ -2654,8 +2608,6 @@ export declare function mergeRefWithSchema(node: RefSchemaNode): SchemaNode;
|
|
|
2654
2608
|
* referenced schema variable with those modifiers already applied.
|
|
2655
2609
|
*/
|
|
2656
2610
|
export declare function isBareRef(node: SchemaNode | null | undefined, keysToOmit?: Array<string> | null): boolean;
|
|
2657
|
-
//#endregion
|
|
2658
|
-
//#region src/utils/schemaGraph.d.ts
|
|
2659
2611
|
/**
|
|
2660
2612
|
* Collects the names of every schema a node's subtree references, resolved with `resolveRefName`.
|
|
2661
2613
|
* Each ref contributes its name only, so the schema it points to is never traversed. The walk is
|
|
@@ -2735,8 +2687,6 @@ export declare function findCircularSchemasFromGraph(graph: ReadonlyMap<string,
|
|
|
2735
2687
|
* @note Call this once on the full graph, then check individual schemas with `containsCircularRef()`.
|
|
2736
2688
|
*/
|
|
2737
2689
|
export declare function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string>;
|
|
2738
|
-
//#endregion
|
|
2739
|
-
//#region src/utils/schemaProperties.d.ts
|
|
2740
2690
|
/**
|
|
2741
2691
|
* Finds every matching property exposed by an object, resolved reference, or intersection.
|
|
2742
2692
|
*
|
|
@@ -2788,8 +2738,6 @@ export declare function getSchemaLiteralValues(node: SchemaNode): ReadonlyArray<
|
|
|
2788
2738
|
* literal value, the same shape a declared OpenAPI `discriminator` already narrows on.
|
|
2789
2739
|
*/
|
|
2790
2740
|
export declare function inferDiscriminatorPropertyName(members: ReadonlyArray<SchemaNode>): string | undefined;
|
|
2791
|
-
//#endregion
|
|
2792
|
-
//#region src/infer.d.ts
|
|
2793
2741
|
/**
|
|
2794
2742
|
* How `format: 'date-time'` schemas are represented downstream.
|
|
2795
2743
|
* - `false` falls through to a plain `string` (no validation).
|
|
@@ -2859,6 +2807,5 @@ type ParserOptions = {
|
|
|
2859
2807
|
declare namespace index_d_exports {
|
|
2860
2808
|
export { ArraySchemaNode, ArrowFunctionNode, BreakNode, CodeNode, ConstNode, ContentNode, DateOnlyTypeValue, DateSchemaNode, DateTimeTypeValue, DateTypeOptions, DatetimeSchemaNode, DistributiveOmit, EncodingNode, Enforce, EnumSchemaNode, ExportNode, FileNode, FunctionNode, GenericOperationNode, HttpMethod, HttpOperationNode, ImportNode, InlineLanguage, InputMeta, InputNode, InputSecurityScheme, InputServer, IntersectionSchemaNode, JSDocNode, JsxNode, Macro, Node, NodeKind, NotSchemaNode, NumberSchemaNode, ObjectSchemaNode, OperationNode, ParameterLocation, ParameterNode, ParameterStyle, ParentOf, ParserOptions, PrimitiveSchemaType, Printer, PrinterFactoryOptions, PrinterPartial, PropertyNode, RefSchemaNode, RequestBodyNode, ResponseNode, ScalarSchemaNode, ScalarSchemaType, SchemaNode, SchemaNodeByType, SchemaType, SourceNode, StatusCode, StringSchemaNode, TextNode, TimeSchemaNode, TypeNode, UnionSchemaNode, UrlSchemaNode, UserFileNode, Visitor, VisitorContext, applyMacros, index_d_exports as ast, collect, collectImportedRefNames, collectSchemaRefs, collectSync, collectUsedSchemaNames, composeMacros, createPrinter, defineMacro, extractStringsFromNodes, index_d_exports$1 as factory, findCircularSchemas, findCircularSchemasFromGraph, findSchema, forEachChild, forEachSchema, getSchemaLiteralValues, inferDiscriminatorPropertyName, inlineFiles, isBareRef, isHttpOperationNode, isVirtualFile, mergeRefWithSchema, narrowSchema, nodeKinds, optionality, refName, resolveRef, resolveRefName, resolveSchemaProperties, schemaTypes, transform };
|
|
2861
2809
|
}
|
|
2862
|
-
//#endregion
|
|
2863
2810
|
export { type ArraySchemaNode, type ArrowFunctionNode, type BreakNode, type CodeNode, type ConstNode, type ContentNode, type DateOnlyTypeValue, type DateSchemaNode, type DateTimeTypeValue, type DateTypeOptions, type DatetimeSchemaNode, type DistributiveOmit, type EncodingNode, type Enforce, type EnumSchemaNode, type ExportNode, type FileNode, type FunctionNode, type GenericOperationNode, type HttpMethod, type HttpOperationNode, type ImportNode, type InlineLanguage, type InputMeta, type InputNode, type InputSecurityScheme, type InputServer, type IntersectionSchemaNode, type JSDocNode, type JsxNode, type Macro, type Node, type NodeKind, type NotSchemaNode, type NumberSchemaNode, type ObjectSchemaNode, type OperationNode, type ParameterLocation, type ParameterNode, type ParameterStyle, type ParentOf, type ParserOptions, type PrimitiveSchemaType, type Printer, type PrinterFactoryOptions, type PrinterPartial, type PropertyNode, type RefSchemaNode, type RequestBodyNode, type ResponseNode, type ScalarSchemaNode, type ScalarSchemaType, type SchemaNode, type SchemaNodeByType, type SchemaType, type SourceNode, type StatusCode, type StringSchemaNode, type TextNode, type TimeSchemaNode, type TypeNode, type UnionSchemaNode, type UrlSchemaNode, type UserFileNode, type Visitor, type VisitorContext, index_d_exports as ast, index_d_exports$1 as factory };
|
|
2864
2811
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
//#endregion
|
|
2
|
-
//#region src/constants.d.ts
|
|
3
1
|
/**
|
|
4
2
|
* Node kind discriminators used by every AST node (for example `node.kind === nodeKinds.text`).
|
|
5
3
|
*/
|
|
@@ -145,8 +143,6 @@ export declare const schemaTypes: {
|
|
|
145
143
|
*/
|
|
146
144
|
readonly never: 'never';
|
|
147
145
|
};
|
|
148
|
-
//#endregion
|
|
149
|
-
//#region src/nodes/base.d.ts
|
|
150
146
|
/**
|
|
151
147
|
* `kind` values used by AST nodes.
|
|
152
148
|
*
|
|
@@ -178,8 +174,6 @@ type BaseNode = {
|
|
|
178
174
|
};
|
|
179
175
|
/** `Omit` applied to each member of a union, so the union survives. */
|
|
180
176
|
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
181
|
-
//#endregion
|
|
182
|
-
//#region src/nodes/property.d.ts
|
|
183
177
|
/**
|
|
184
178
|
* AST node representing one named object property.
|
|
185
179
|
*
|
|
@@ -227,8 +221,6 @@ type UserPropertyNode = Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<Pro
|
|
|
227
221
|
* ```
|
|
228
222
|
*/
|
|
229
223
|
declare function createProperty(input: UserPropertyNode): PropertyNode;
|
|
230
|
-
//#endregion
|
|
231
|
-
//#region src/nodes/schema.d.ts
|
|
232
224
|
type PrimitiveSchemaType =
|
|
233
225
|
/**
|
|
234
226
|
* Text value.
|
|
@@ -849,8 +841,6 @@ type CreateSchemaOutput<T extends CreateSchemaInput> = SchemaNodeByType[T['type'
|
|
|
849
841
|
*/
|
|
850
842
|
declare function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>;
|
|
851
843
|
declare function createSchema(props: CreateSchemaInput): SchemaNode;
|
|
852
|
-
//#endregion
|
|
853
|
-
//#region src/nodes/parameter.d.ts
|
|
854
844
|
type ParameterLocation = 'path' | 'query' | 'header' | 'cookie';
|
|
855
845
|
/**
|
|
856
846
|
* Parameter serialization style, controlling how a parameter value is rendered into the request.
|
|
@@ -925,8 +915,6 @@ type UserParameterNode = Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial
|
|
|
925
915
|
* ```
|
|
926
916
|
*/
|
|
927
917
|
declare function createParameter(input: UserParameterNode): ParameterNode;
|
|
928
|
-
//#endregion
|
|
929
|
-
//#region src/nodes/content.d.ts
|
|
930
918
|
/**
|
|
931
919
|
* How one body property is serialized, from the `encoding` entry of its media type.
|
|
932
920
|
*/
|
|
@@ -990,8 +978,6 @@ type ContentNode = BaseNode & {
|
|
|
990
978
|
* Creates a `ContentNode` for a single request-body or response content type.
|
|
991
979
|
*/
|
|
992
980
|
declare const createContent: (input: Omit<ContentNode, "kind">) => ContentNode;
|
|
993
|
-
//#endregion
|
|
994
|
-
//#region src/nodes/requestBody.d.ts
|
|
995
981
|
/**
|
|
996
982
|
* AST node representing an operation request body.
|
|
997
983
|
*
|
|
@@ -1032,8 +1018,6 @@ type RequestBodyNode = BaseNode & {
|
|
|
1032
1018
|
* Creates a `RequestBodyNode`.
|
|
1033
1019
|
*/
|
|
1034
1020
|
declare const createRequestBody: (input: Omit<RequestBodyNode, "kind">) => RequestBodyNode;
|
|
1035
|
-
//#endregion
|
|
1036
|
-
//#region src/nodes/response.d.ts
|
|
1037
1021
|
type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
1038
1022
|
/**
|
|
1039
1023
|
* Response status code literal used by operations.
|
|
@@ -1112,8 +1096,6 @@ type ResponseInput = Pick<ResponseNode, 'statusCode'> & Partial<Omit<ResponseNod
|
|
|
1112
1096
|
* ```
|
|
1113
1097
|
*/
|
|
1114
1098
|
declare function createResponse(props: ResponseInput): ResponseNode;
|
|
1115
|
-
//#endregion
|
|
1116
|
-
//#region src/nodes/operation.d.ts
|
|
1117
1099
|
/**
|
|
1118
1100
|
* HTTP method an operation responds to. `QUERY` is the safe, idempotent method with a request body
|
|
1119
1101
|
* from RFC 10008, declared with the `query` field of an OpenAPI 3.2 path item.
|
|
@@ -1228,8 +1210,6 @@ declare function createOperation(props: Pick<HttpOperationNode, 'operationId' |
|
|
|
1228
1210
|
declare function createOperation(props: Pick<GenericOperationNode, 'operationId'> & Partial<Omit<GenericOperationNode, 'kind' | 'operationId' | 'requestBody'>> & {
|
|
1229
1211
|
requestBody?: Omit<RequestBodyNode, 'kind'>;
|
|
1230
1212
|
}): GenericOperationNode;
|
|
1231
|
-
//#endregion
|
|
1232
|
-
//#region src/guards.d.ts
|
|
1233
1213
|
/**
|
|
1234
1214
|
* Narrows a `SchemaNode` to the variant that matches `type`.
|
|
1235
1215
|
*
|
|
@@ -1251,8 +1231,6 @@ export declare function narrowSchema<T extends SchemaNode['type']>(node: SchemaN
|
|
|
1251
1231
|
* ```
|
|
1252
1232
|
*/
|
|
1253
1233
|
export declare function isHttpOperationNode(node: OperationNode): node is HttpOperationNode;
|
|
1254
|
-
//#endregion
|
|
1255
|
-
//#region src/nodes/code.d.ts
|
|
1256
1234
|
/**
|
|
1257
1235
|
* JSDoc documentation metadata attached to code declarations.
|
|
1258
1236
|
*/
|
|
@@ -1553,8 +1531,6 @@ declare function createBreak(): BreakNode;
|
|
|
1553
1531
|
* ```
|
|
1554
1532
|
*/
|
|
1555
1533
|
declare function createJsx(value: string): JsxNode;
|
|
1556
|
-
//#endregion
|
|
1557
|
-
//#region src/nodes/file.d.ts
|
|
1558
1534
|
/**
|
|
1559
1535
|
* Supported file extensions.
|
|
1560
1536
|
*/
|
|
@@ -1877,8 +1853,6 @@ type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind'
|
|
|
1877
1853
|
* ```
|
|
1878
1854
|
*/
|
|
1879
1855
|
declare function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta>;
|
|
1880
|
-
//#endregion
|
|
1881
|
-
//#region src/nodes/input.d.ts
|
|
1882
1856
|
/**
|
|
1883
1857
|
* A server from the source document, with `{variable}` placeholders filled from their defaults.
|
|
1884
1858
|
*/
|
|
@@ -1914,13 +1888,13 @@ type InputSecurityScheme = {
|
|
|
1914
1888
|
/**
|
|
1915
1889
|
* Metadata for an API document, populated by the adapter and available to every generator.
|
|
1916
1890
|
*
|
|
1917
|
-
*
|
|
1918
|
-
*
|
|
1919
|
-
*
|
|
1891
|
+
* Computed fields (`circularNames`, `enumNames`) are sets, pre-calculated once during the adapter
|
|
1892
|
+
* pre-scan so generators never need to iterate the full schema list themselves. Every other field
|
|
1893
|
+
* is a plain JSON value.
|
|
1920
1894
|
*
|
|
1921
1895
|
* @example
|
|
1922
1896
|
* ```ts
|
|
1923
|
-
* const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://api.example.com/v2', circularNames:
|
|
1897
|
+
* const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://api.example.com/v2', circularNames: new Set(), enumNames: new Set() }
|
|
1924
1898
|
* ```
|
|
1925
1899
|
*/
|
|
1926
1900
|
type InputMeta = {
|
|
@@ -1951,29 +1925,23 @@ type InputMeta = {
|
|
|
1951
1925
|
* Computed once during the adapter pre-scan, so a generator never has to
|
|
1952
1926
|
* call `findCircularSchemas` itself.
|
|
1953
1927
|
*
|
|
1954
|
-
* Convert to a `Set` once at the start of a generator, not per-schema,
|
|
1955
|
-
* so lookups stay O(1) without repeated allocations.
|
|
1956
|
-
*
|
|
1957
1928
|
* @example Wrap a circular schema in z.lazy()
|
|
1958
1929
|
* ```ts
|
|
1959
|
-
*
|
|
1960
|
-
* if (circular.has(schema.name)) { ... }
|
|
1930
|
+
* if (meta.circularNames.has(schema.name)) { ... }
|
|
1961
1931
|
* ```
|
|
1962
1932
|
*/
|
|
1963
|
-
circularNames:
|
|
1933
|
+
circularNames: ReadonlySet<string>;
|
|
1964
1934
|
/**
|
|
1965
1935
|
* Names of schemas whose type is `enum`.
|
|
1966
1936
|
* Computed once during the adapter pre-scan, so a generator never has to
|
|
1967
1937
|
* filter the schema list itself.
|
|
1968
1938
|
*
|
|
1969
|
-
* Convert to a `Set` once at the start of a generator when you need repeated
|
|
1970
|
-
* membership checks, so each check stays O(1) instead of an array scan.
|
|
1971
|
-
*
|
|
1972
1939
|
* @example Check if a referenced schema is an enum
|
|
1973
|
-
*
|
|
1974
|
-
*
|
|
1940
|
+
* ```ts
|
|
1941
|
+
* const isEnum = meta.enumNames.has(schemaName)
|
|
1942
|
+
* ```
|
|
1975
1943
|
*/
|
|
1976
|
-
enumNames:
|
|
1944
|
+
enumNames: ReadonlySet<string>;
|
|
1977
1945
|
};
|
|
1978
1946
|
/**
|
|
1979
1947
|
* Input AST node that contains all schemas and operations for one API document.
|
|
@@ -1985,7 +1953,7 @@ type InputMeta = {
|
|
|
1985
1953
|
* kind: 'Input',
|
|
1986
1954
|
* schemas: [],
|
|
1987
1955
|
* operations: [],
|
|
1988
|
-
* meta: { circularNames:
|
|
1956
|
+
* meta: { circularNames: new Set(), enumNames: new Set() },
|
|
1989
1957
|
* }
|
|
1990
1958
|
* ```
|
|
1991
1959
|
*/
|
|
@@ -2039,8 +2007,6 @@ declare namespace index_d_exports$1 {
|
|
|
2039
2007
|
* ```
|
|
2040
2008
|
*/
|
|
2041
2009
|
type Node = InputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode | RequestBodyNode | ContentNode | FileNode | ImportNode | ExportNode | SourceNode | ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode;
|
|
2042
|
-
//#endregion
|
|
2043
|
-
//#region src/visitor.d.ts
|
|
2044
2010
|
/**
|
|
2045
2011
|
* Ordered mapping of `[NodeType, ParentType]` pairs.
|
|
2046
2012
|
*
|
|
@@ -2266,8 +2232,6 @@ export declare function collect<T>(node: Node, options: CollectOptions<T>): Gene
|
|
|
2266
2232
|
* ```
|
|
2267
2233
|
*/
|
|
2268
2234
|
export declare function collectSync<T>(node: Node, options: CollectOptions<T>): Array<T>;
|
|
2269
|
-
//#endregion
|
|
2270
|
-
//#region src/defineMacro.d.ts
|
|
2271
2235
|
/**
|
|
2272
2236
|
* Ordering hint shared by macros and plugins. `pre` runs before unmarked items, `post` after,
|
|
2273
2237
|
* and `undefined` keeps declaration order.
|
|
@@ -2341,15 +2305,11 @@ export declare function composeMacros(macros: ReadonlyArray<Macro>): Visitor;
|
|
|
2341
2305
|
export declare function applyMacros<TNode extends Node>(root: TNode, macros: ReadonlyArray<Macro>, options?: {
|
|
2342
2306
|
depth?: VisitorDepth;
|
|
2343
2307
|
}): TNode;
|
|
2344
|
-
//#endregion
|
|
2345
|
-
//#region src/optionality.d.ts
|
|
2346
2308
|
/**
|
|
2347
2309
|
* Generic JSON Schema optionality: a non-required field is optional, and a
|
|
2348
2310
|
* non-required nullable field is nullish.
|
|
2349
2311
|
*/
|
|
2350
2312
|
export declare function optionality(schema: SchemaNode, required: boolean): SchemaNode;
|
|
2351
|
-
//#endregion
|
|
2352
|
-
//#region src/createPrinter.d.ts
|
|
2353
2313
|
/**
|
|
2354
2314
|
* Runtime context passed as `this` to printer handlers.
|
|
2355
2315
|
*
|
|
@@ -2545,8 +2505,6 @@ type PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) =
|
|
|
2545
2505
|
* ```
|
|
2546
2506
|
*/
|
|
2547
2507
|
export declare function createPrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T>;
|
|
2548
|
-
//#endregion
|
|
2549
|
-
//#region src/utils/extractStringsFromNodes.d.ts
|
|
2550
2508
|
/**
|
|
2551
2509
|
* Extracts all string content from a `CodeNode` tree recursively.
|
|
2552
2510
|
*
|
|
@@ -2554,8 +2512,6 @@ export declare function createPrinter<T extends PrinterFactoryOptions = PrinterF
|
|
|
2554
2512
|
* and nested node content. Used to build the full source string for import filtering.
|
|
2555
2513
|
*/
|
|
2556
2514
|
export declare function extractStringsFromNodes(nodes: Array<CodeNode> | undefined): string;
|
|
2557
|
-
//#endregion
|
|
2558
|
-
//#region src/utils/inline.d.ts
|
|
2559
2515
|
/**
|
|
2560
2516
|
* Whether every source of `file` is inline. Other files absorb such a file, so it is never written.
|
|
2561
2517
|
*/
|
|
@@ -2601,8 +2557,6 @@ type InlineFilesOptions = {
|
|
|
2601
2557
|
* `inline.expression`, until no inline names are left. The definitions' own imports move to the importing file.
|
|
2602
2558
|
*/
|
|
2603
2559
|
export declare function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult;
|
|
2604
|
-
//#endregion
|
|
2605
|
-
//#region src/utils/refs.d.ts
|
|
2606
2560
|
/**
|
|
2607
2561
|
* Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.
|
|
2608
2562
|
* The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`
|
|
@@ -2654,8 +2608,6 @@ export declare function mergeRefWithSchema(node: RefSchemaNode): SchemaNode;
|
|
|
2654
2608
|
* referenced schema variable with those modifiers already applied.
|
|
2655
2609
|
*/
|
|
2656
2610
|
export declare function isBareRef(node: SchemaNode | null | undefined, keysToOmit?: Array<string> | null): boolean;
|
|
2657
|
-
//#endregion
|
|
2658
|
-
//#region src/utils/schemaGraph.d.ts
|
|
2659
2611
|
/**
|
|
2660
2612
|
* Collects the names of every schema a node's subtree references, resolved with `resolveRefName`.
|
|
2661
2613
|
* Each ref contributes its name only, so the schema it points to is never traversed. The walk is
|
|
@@ -2735,8 +2687,6 @@ export declare function findCircularSchemasFromGraph(graph: ReadonlyMap<string,
|
|
|
2735
2687
|
* @note Call this once on the full graph, then check individual schemas with `containsCircularRef()`.
|
|
2736
2688
|
*/
|
|
2737
2689
|
export declare function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string>;
|
|
2738
|
-
//#endregion
|
|
2739
|
-
//#region src/utils/schemaProperties.d.ts
|
|
2740
2690
|
/**
|
|
2741
2691
|
* Finds every matching property exposed by an object, resolved reference, or intersection.
|
|
2742
2692
|
*
|
|
@@ -2788,8 +2738,6 @@ export declare function getSchemaLiteralValues(node: SchemaNode): ReadonlyArray<
|
|
|
2788
2738
|
* literal value, the same shape a declared OpenAPI `discriminator` already narrows on.
|
|
2789
2739
|
*/
|
|
2790
2740
|
export declare function inferDiscriminatorPropertyName(members: ReadonlyArray<SchemaNode>): string | undefined;
|
|
2791
|
-
//#endregion
|
|
2792
|
-
//#region src/infer.d.ts
|
|
2793
2741
|
/**
|
|
2794
2742
|
* How `format: 'date-time'` schemas are represented downstream.
|
|
2795
2743
|
* - `false` falls through to a plain `string` (no validation).
|
|
@@ -2859,6 +2807,5 @@ type ParserOptions = {
|
|
|
2859
2807
|
declare namespace index_d_exports {
|
|
2860
2808
|
export { ArraySchemaNode, ArrowFunctionNode, BreakNode, CodeNode, ConstNode, ContentNode, DateOnlyTypeValue, DateSchemaNode, DateTimeTypeValue, DateTypeOptions, DatetimeSchemaNode, DistributiveOmit, EncodingNode, Enforce, EnumSchemaNode, ExportNode, FileNode, FunctionNode, GenericOperationNode, HttpMethod, HttpOperationNode, ImportNode, InlineLanguage, InputMeta, InputNode, InputSecurityScheme, InputServer, IntersectionSchemaNode, JSDocNode, JsxNode, Macro, Node, NodeKind, NotSchemaNode, NumberSchemaNode, ObjectSchemaNode, OperationNode, ParameterLocation, ParameterNode, ParameterStyle, ParentOf, ParserOptions, PrimitiveSchemaType, Printer, PrinterFactoryOptions, PrinterPartial, PropertyNode, RefSchemaNode, RequestBodyNode, ResponseNode, ScalarSchemaNode, ScalarSchemaType, SchemaNode, SchemaNodeByType, SchemaType, SourceNode, StatusCode, StringSchemaNode, TextNode, TimeSchemaNode, TypeNode, UnionSchemaNode, UrlSchemaNode, UserFileNode, Visitor, VisitorContext, applyMacros, index_d_exports as ast, collect, collectImportedRefNames, collectSchemaRefs, collectSync, collectUsedSchemaNames, composeMacros, createPrinter, defineMacro, extractStringsFromNodes, index_d_exports$1 as factory, findCircularSchemas, findCircularSchemasFromGraph, findSchema, forEachChild, forEachSchema, getSchemaLiteralValues, inferDiscriminatorPropertyName, inlineFiles, isBareRef, isHttpOperationNode, isVirtualFile, mergeRefWithSchema, narrowSchema, nodeKinds, optionality, refName, resolveRef, resolveRefName, resolveSchemaProperties, schemaTypes, transform };
|
|
2861
2809
|
}
|
|
2862
|
-
//#endregion
|
|
2863
2810
|
export { type ArraySchemaNode, type ArrowFunctionNode, type BreakNode, type CodeNode, type ConstNode, type ContentNode, type DateOnlyTypeValue, type DateSchemaNode, type DateTimeTypeValue, type DateTypeOptions, type DatetimeSchemaNode, type DistributiveOmit, type EncodingNode, type Enforce, type EnumSchemaNode, type ExportNode, type FileNode, type FunctionNode, type GenericOperationNode, type HttpMethod, type HttpOperationNode, type ImportNode, type InlineLanguage, type InputMeta, type InputNode, type InputSecurityScheme, type InputServer, type IntersectionSchemaNode, type JSDocNode, type JsxNode, type Macro, type Node, type NodeKind, type NotSchemaNode, type NumberSchemaNode, type ObjectSchemaNode, type OperationNode, type ParameterLocation, type ParameterNode, type ParameterStyle, type ParentOf, type ParserOptions, type PrimitiveSchemaType, type Printer, type PrinterFactoryOptions, type PrinterPartial, type PropertyNode, type RefSchemaNode, type RequestBodyNode, type ResponseNode, type ScalarSchemaNode, type ScalarSchemaType, type SchemaNode, type SchemaNodeByType, type SchemaType, type SourceNode, type StatusCode, type StringSchemaNode, type TextNode, type TimeSchemaNode, type TypeNode, type UnionSchemaNode, type UrlSchemaNode, type UserFileNode, type Visitor, type VisitorContext, index_d_exports as ast, index_d_exports$1 as factory };
|
|
2864
2811
|
//# sourceMappingURL=index.d.ts.map
|