@kubb/ast 5.0.0-beta.57 → 5.0.0-beta.59
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 +21 -7
- package/dist/casing-BE2R1RXg.cjs +88 -0
- package/dist/casing-BE2R1RXg.cjs.map +1 -0
- package/dist/chunk-CNktS9qV.js +17 -0
- package/dist/extractStringsFromNodes-WMYJ8nQL.d.ts +82 -0
- package/dist/factory-BmcGBdeg.cjs +1251 -0
- package/dist/factory-BmcGBdeg.cjs.map +1 -0
- package/dist/factory-Du7nEP4B.js +282 -0
- package/dist/factory-Du7nEP4B.js.map +1 -0
- package/dist/factory.cjs +28 -0
- package/dist/factory.d.ts +62 -0
- package/dist/factory.js +3 -0
- package/dist/{types-C5aVnRE1.d.ts → index-BzjwdK2M.d.ts} +94 -1146
- package/dist/index.cjs +220 -1481
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +96 -58
- package/dist/index.js +182 -1920
- package/dist/index.js.map +1 -1
- package/dist/operationParams-BZ07xDm0.d.ts +204 -0
- package/dist/response-DKxTr522.js +683 -0
- package/dist/response-DKxTr522.js.map +1 -0
- package/dist/types-olVl9v5p.d.ts +764 -0
- package/dist/types.d.ts +5 -2
- package/dist/utils-BCtRXfhI.cjs +275 -0
- package/dist/utils-BCtRXfhI.cjs.map +1 -0
- package/dist/utils-SdZU0F3H.js +1336 -0
- package/dist/utils-SdZU0F3H.js.map +1 -0
- package/dist/utils.cjs +129 -13
- package/dist/utils.d.ts +127 -76
- package/dist/utils.js +3 -2
- package/package.json +5 -1
- package/src/constants.ts +8 -14
- package/src/dedupe.ts +8 -0
- package/src/factory.ts +18 -1
- package/src/guards.ts +1 -1
- package/src/index.ts +7 -50
- package/src/node.ts +1 -1
- package/src/nodes/base.ts +0 -10
- package/src/nodes/code.ts +29 -47
- package/src/nodes/content.ts +2 -2
- package/src/nodes/file.ts +28 -23
- package/src/nodes/function.ts +2 -17
- package/src/nodes/index.ts +1 -1
- package/src/nodes/input.ts +20 -19
- package/src/nodes/operation.ts +1 -1
- package/src/nodes/parameter.ts +0 -3
- package/src/nodes/property.ts +0 -3
- package/src/nodes/requestBody.ts +3 -6
- package/src/nodes/schema.ts +3 -2
- package/src/printer.ts +4 -4
- package/src/registry.ts +31 -26
- package/src/signature.ts +3 -3
- package/src/transformers.ts +28 -1
- package/src/types.ts +2 -53
- package/src/utils/codegen.ts +104 -0
- package/src/utils/extractStringsFromNodes.ts +34 -0
- package/src/utils/fileMerge.ts +184 -0
- package/src/utils/index.ts +8 -296
- package/src/utils/operationParams.ts +353 -0
- package/src/utils/refs.ts +112 -0
- package/src/utils/schemaGraph.ts +169 -0
- package/src/utils/strings.ts +139 -0
- package/src/visitor.ts +43 -19
- package/dist/chunk-C0LytTxp.js +0 -8
- package/dist/utils-0p8ZO287.js +0 -570
- package/dist/utils-0p8ZO287.js.map +0 -1
- package/dist/utils-cdQ6Pzyi.cjs +0 -726
- package/dist/utils-cdQ6Pzyi.cjs.map +0 -1
- package/src/utils/ast.ts +0 -879
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $ as
|
|
1
|
+
import { n as __name } from "./chunk-CNktS9qV.js";
|
|
2
|
+
import { $ as fileDef, $t as textDef, A as FunctionParametersNode, At as InferSchemaNode, B as functionParameterDef, Bt as TypeNode, C as ParameterLocation, Ct as UrlSchemaNode, D as FunctionParamKind, Dt as UserPropertyNode, E as parameterDef, Et as PropertyNode, Ft as ConstNode, G as ExportNode, H as indexedAccessTypeDef, Ht as breakDef, It as FunctionNode, J as SourceNode, K as FileNode, Lt as JSDocNode, M as ObjectBindingPatternNode, Mt as ArrowFunctionNode, N as TypeExpression, Nt as BreakNode, O as FunctionParamNode, P as TypeLiteralNode, Pt as CodeNode, Q as exportDef, Qt as jsxDef, Rt as JsxNode, S as requestBodyDef, St as UnionSchemaNode, Tt as schemaDef, U as objectBindingPatternDef, Ut as constDef, V as functionParametersDef, Vt as arrowFunctionDef, W as typeLiteralDef, Zt as functionDef, _ as responseDef, _t as SchemaNode, a as InputMeta, an as BaseNode, b as UserRequestBody, bt as StringSchemaNode, c as inputDef, ct as DatetimeSchemaNode, d as HttpOperationNode, dt as NumberSchemaNode, en as typeDef, et as importDef, f as OperationNode, ft as ObjectSchemaNode, gt as ScalarSchemaType, h as ResponseNode, ht as ScalarSchemaNode, i as outputDef, in as syncOptionality, it as contentDef, j as IndexedAccessTypeNode, jt as ParserOptions, k as FunctionParameterNode, kt as propertyDef, l as GenericOperationNode, lt as EnumSchemaNode, m as operationDef, mt as RefSchemaNode, n as OutputNode, nn as NodeDef, nt as ContentNode, o as InputNode, on as NodeKind, ot as ArraySchemaNode, pt as PrimitiveSchemaType, q as ImportNode, rn as defineNode, rt as UserContent, st as DateSchemaNode, t as Node, tn as DistributiveOmit, tt as sourceDef, u as HttpMethod, ut as IntersectionSchemaNode, v as StatusCode, vt as SchemaNodeByType, w as ParameterNode, xt as TimeSchemaNode, y as RequestBodyNode, yt as SchemaType, zt as TextNode } from "./index-BzjwdK2M.js";
|
|
3
|
+
import { UserFileNode, t as factory_d_exports } from "./factory.js";
|
|
4
|
+
import { _ as applyDedupe, a as definePrinter, b as schemaTypes, c as VisitorContext, d as walk, f as SchemaDialect, g as DedupePlan, h as DedupeLookups, i as createPrinterFactory, l as collect, m as DedupeCanonical, n as PrinterFactoryOptions, o as ParentOf, p as defineSchemaDialect, r as PrinterPartial, s as Visitor, t as Printer, u as transform, v as buildDedupePlan, y as httpMethods } from "./types-olVl9v5p.js";
|
|
5
|
+
import { n as OperationParamsResolver } from "./operationParams-BZ07xDm0.js";
|
|
6
|
+
import { a as simplifyUnion, i as setEnumName, n as mergeAdjacentObjectsLazy, r as setDiscriminatorEnum, t as extractStringsFromNodes } from "./extractStringsFromNodes-WMYJ8nQL.js";
|
|
3
7
|
|
|
4
8
|
//#region src/guards.d.ts
|
|
5
9
|
/**
|
|
@@ -13,7 +17,7 @@ import { $ as createParameter, $t as InferSchemaNode, A as applyDedupe, At as co
|
|
|
13
17
|
*/
|
|
14
18
|
declare function narrowSchema<T extends SchemaNode['type']>(node: SchemaNode | undefined, type: T): SchemaNodeByType[T] | null;
|
|
15
19
|
/**
|
|
16
|
-
* Narrows an `OperationNode` to an `HttpOperationNode
|
|
20
|
+
* Narrows an `OperationNode` to an `HttpOperationNode` so `method` and `path` are present.
|
|
17
21
|
*
|
|
18
22
|
* @example
|
|
19
23
|
* ```ts
|
|
@@ -24,6 +28,94 @@ declare function narrowSchema<T extends SchemaNode['type']>(node: SchemaNode | u
|
|
|
24
28
|
*/
|
|
25
29
|
declare function isHttpOperationNode(node: OperationNode): node is HttpOperationNode;
|
|
26
30
|
//#endregion
|
|
31
|
+
//#region src/registry.d.ts
|
|
32
|
+
/**
|
|
33
|
+
* Every node definition. Adding a node means adding its `defineNode` to one
|
|
34
|
+
* `nodes/*.ts` file and listing it here. The visitor tables in `visitor.ts` derive from it.
|
|
35
|
+
*/
|
|
36
|
+
declare const nodeDefs: (NodeDef<ConstNode, Omit<ConstNode, "kind">> | NodeDef<TypeNode, Omit<TypeNode, "kind">> | NodeDef<FunctionNode, Omit<FunctionNode, "kind">> | NodeDef<ArrowFunctionNode, Omit<ArrowFunctionNode, "kind">> | NodeDef<TextNode, string> | NodeDef<BreakNode, void> | NodeDef<JsxNode, string> | NodeDef<SchemaNode, (Omit<ObjectSchemaNode, "kind" | "properties" | "primitive"> & {
|
|
37
|
+
properties?: Array<PropertyNode>;
|
|
38
|
+
primitive?: "object";
|
|
39
|
+
}) | DistributiveOmit<ArraySchemaNode | UnionSchemaNode | IntersectionSchemaNode | EnumSchemaNode | RefSchemaNode | DatetimeSchemaNode | DateSchemaNode | TimeSchemaNode | StringSchemaNode | NumberSchemaNode | UrlSchemaNode | (BaseNode & {
|
|
40
|
+
kind: "Schema";
|
|
41
|
+
name?: string | null;
|
|
42
|
+
title?: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
nullable?: boolean;
|
|
45
|
+
optional?: boolean;
|
|
46
|
+
nullish?: boolean;
|
|
47
|
+
deprecated?: boolean;
|
|
48
|
+
readOnly?: boolean;
|
|
49
|
+
writeOnly?: boolean;
|
|
50
|
+
default?: unknown;
|
|
51
|
+
example?: unknown;
|
|
52
|
+
primitive?: PrimitiveSchemaType;
|
|
53
|
+
format?: string;
|
|
54
|
+
} & {
|
|
55
|
+
type: "uuid" | "email";
|
|
56
|
+
min?: number;
|
|
57
|
+
max?: number;
|
|
58
|
+
}) | (BaseNode & {
|
|
59
|
+
kind: "Schema";
|
|
60
|
+
name?: string | null;
|
|
61
|
+
title?: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
nullable?: boolean;
|
|
64
|
+
optional?: boolean;
|
|
65
|
+
nullish?: boolean;
|
|
66
|
+
deprecated?: boolean;
|
|
67
|
+
readOnly?: boolean;
|
|
68
|
+
writeOnly?: boolean;
|
|
69
|
+
default?: unknown;
|
|
70
|
+
example?: unknown;
|
|
71
|
+
primitive?: PrimitiveSchemaType;
|
|
72
|
+
format?: string;
|
|
73
|
+
} & {
|
|
74
|
+
type: "ipv4";
|
|
75
|
+
}) | (BaseNode & {
|
|
76
|
+
kind: "Schema";
|
|
77
|
+
name?: string | null;
|
|
78
|
+
title?: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
nullable?: boolean;
|
|
81
|
+
optional?: boolean;
|
|
82
|
+
nullish?: boolean;
|
|
83
|
+
deprecated?: boolean;
|
|
84
|
+
readOnly?: boolean;
|
|
85
|
+
writeOnly?: boolean;
|
|
86
|
+
default?: unknown;
|
|
87
|
+
example?: unknown;
|
|
88
|
+
primitive?: PrimitiveSchemaType;
|
|
89
|
+
format?: string;
|
|
90
|
+
} & {
|
|
91
|
+
type: "ipv6";
|
|
92
|
+
}) | ScalarSchemaNode, "kind">> | NodeDef<TypeLiteralNode, Pick<TypeLiteralNode, "members">> | NodeDef<IndexedAccessTypeNode, Omit<IndexedAccessTypeNode, "kind">> | NodeDef<ObjectBindingPatternNode, Pick<ObjectBindingPatternNode, "elements">> | NodeDef<FunctionParameterNode, {
|
|
93
|
+
name: string;
|
|
94
|
+
type?: TypeExpression;
|
|
95
|
+
optional?: boolean;
|
|
96
|
+
default?: string;
|
|
97
|
+
rest?: boolean;
|
|
98
|
+
} | {
|
|
99
|
+
properties: Array<{
|
|
100
|
+
name: string;
|
|
101
|
+
type: TypeExpression;
|
|
102
|
+
optional?: boolean;
|
|
103
|
+
}>;
|
|
104
|
+
optional?: boolean;
|
|
105
|
+
default?: string;
|
|
106
|
+
}> | NodeDef<FunctionParametersNode, Partial<Omit<FunctionParametersNode, "kind">>> | NodeDef<ContentNode, UserContent> | NodeDef<ResponseNode, Pick<ResponseNode, "statusCode"> & Partial<Omit<ResponseNode, "kind" | "statusCode" | "content">> & {
|
|
107
|
+
content?: Array<UserContent>;
|
|
108
|
+
schema?: SchemaNode;
|
|
109
|
+
mediaType?: string | null;
|
|
110
|
+
keysToOmit?: Array<string> | null;
|
|
111
|
+
}> | NodeDef<InputNode<false>, Partial<Omit<InputNode<false>, "kind">>> | NodeDef<ImportNode, Omit<ImportNode, "kind">> | NodeDef<ExportNode, Omit<ExportNode, "kind">> | NodeDef<SourceNode, Omit<SourceNode, "kind">> | NodeDef<FileNode<object>, Omit<FileNode<object>, "kind">> | NodeDef<ParameterNode, Pick<ParameterNode, "name" | "schema" | "in"> & Partial<Omit<ParameterNode, "kind" | "name" | "schema" | "in">>> | NodeDef<PropertyNode, UserPropertyNode> | NodeDef<RequestBodyNode, UserRequestBody> | NodeDef<OperationNode, {
|
|
112
|
+
[key: string]: unknown;
|
|
113
|
+
operationId: string;
|
|
114
|
+
method?: HttpOperationNode["method"];
|
|
115
|
+
path?: HttpOperationNode["path"];
|
|
116
|
+
requestBody?: UserRequestBody;
|
|
117
|
+
}> | NodeDef<OutputNode, Partial<Omit<OutputNode, "kind">>>)[];
|
|
118
|
+
//#endregion
|
|
27
119
|
//#region src/signature.d.ts
|
|
28
120
|
/**
|
|
29
121
|
* Computes a deterministic, shape-only signature (a content hash) for a schema node. Two schemas
|
|
@@ -40,59 +132,5 @@ declare function isHttpOperationNode(node: OperationNode): node is HttpOperation
|
|
|
40
132
|
*/
|
|
41
133
|
declare function signatureOf(node: SchemaNode): string;
|
|
42
134
|
//#endregion
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Replaces a discriminator property's schema with a string enum of allowed values.
|
|
46
|
-
*
|
|
47
|
-
* If `node` is not an object schema, or if the property does not exist, the input
|
|
48
|
-
* node is returned as-is.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```ts
|
|
52
|
-
* const schema = createSchema({
|
|
53
|
-
* type: 'object',
|
|
54
|
-
* properties: [createProperty({ name: 'type', required: true, schema: createSchema({ type: 'string' }) })],
|
|
55
|
-
* })
|
|
56
|
-
* const result = setDiscriminatorEnum({ node: schema, propertyName: 'type', values: ['dog', 'cat'] })
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
declare function setDiscriminatorEnum({
|
|
60
|
-
node,
|
|
61
|
-
propertyName,
|
|
62
|
-
values,
|
|
63
|
-
enumName
|
|
64
|
-
}: {
|
|
65
|
-
node: SchemaNode;
|
|
66
|
-
propertyName: string;
|
|
67
|
-
values: Array<string>;
|
|
68
|
-
enumName?: string;
|
|
69
|
-
}): SchemaNode;
|
|
70
|
-
/**
|
|
71
|
-
* Merges adjacent anonymous object members into a single anonymous object member.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts
|
|
75
|
-
* const merged = mergeAdjacentObjects([
|
|
76
|
-
* createSchema({ type: 'object', properties: [createProperty({ name: 'a', schema: createSchema({ type: 'string' }) })] }),
|
|
77
|
-
* createSchema({ type: 'object', properties: [createProperty({ name: 'b', schema: createSchema({ type: 'number' }) })] }),
|
|
78
|
-
* ])
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
declare function mergeAdjacentObjectsLazy(members: Iterable<SchemaNode>): Generator<SchemaNode, void, undefined>;
|
|
82
|
-
/**
|
|
83
|
-
* Removes enum members that are covered by broader scalar primitives in the same union.
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```ts
|
|
87
|
-
* const simplified = simplifyUnion([
|
|
88
|
-
* createSchema({ type: 'enum', primitive: 'string', enumValues: ['active'] }),
|
|
89
|
-
* createSchema({ type: 'string' }),
|
|
90
|
-
* ])
|
|
91
|
-
* // keeps only string member
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
declare function simplifyUnion(members: Array<SchemaNode>): Array<SchemaNode>;
|
|
95
|
-
declare function setEnumName(propNode: SchemaNode, parentName: string | null | undefined, propName: string, enumSuffix: string): SchemaNode;
|
|
96
|
-
//#endregion
|
|
97
|
-
export { type ArraySchemaNode, type ArrowFunctionNode, type CodeNode, type ConstNode, type DateSchemaNode, type DatetimeSchemaNode, type DedupeCanonical, type DedupeLookups, type DedupePlan, type DistributiveOmit, type EnumSchemaNode, type ExportNode, type FileNode, type FunctionNode, type FunctionNodeType, type FunctionParamNode, type FunctionParameterNode, type FunctionParametersNode, type HttpMethod, type HttpOperationNode, type ImportNode, type IndexedAccessTypeNode, type InferSchemaNode, type InputMeta, type InputNode, type IntersectionSchemaNode, type JSDocNode, type JsxNode, type Node, type NodeDef, type NodeKind, type NumberSchemaNode, type ObjectBindingPatternNode, type ObjectSchemaNode, type OperationNode, type OperationParamsResolver, type OutputNode, type ParameterLocation, type ParameterNode, type ParentOf, type ParserOptions, type PrimitiveSchemaType, type Printer, type PrinterFactoryOptions, type PrinterPartial, type PropertyNode, type RefSchemaNode, type ResponseNode, type ScalarSchemaType, type SchemaDialect, type SchemaNode, type SchemaNodeByType, type SchemaType, type SourceNode, type StatusCode, type StringSchemaNode, type TextNode, type TimeSchemaNode, type TypeExpression, type TypeLiteralNode, type TypeNode, type UnionSchemaNode, type UrlSchemaNode, type UserFileNode, type Visitor, type VisitorContext, applyDedupe, arrowFunctionDef, breakDef, buildDedupePlan, caseParams, collect, collectUsedSchemaNames, constDef, containsCircularRef, contentDef, createArrowFunction, createBreak, createConst, createDiscriminantNode, createExport, createFile, createFunction, createFunctionParameter, createFunctionParameters, createImport, createIndexedAccessType, createInput, createJsx, createObjectBindingPattern, createOperation, createOperationParams, createOutput, createParameter, createPrinterFactory, createProperty, createResponse, createSchema, createSource, createStreamInput, createText, createType, createTypeLiteral, defineNode, definePrinter, defineSchemaDialect, exportDef, extractStringsFromNodes, fileDef, findCircularSchemas, functionDef, functionParameterDef, functionParametersDef, httpMethods, importDef, indexedAccessTypeDef, inputDef, isHttpOperationNode, isStringType, jsxDef, mergeAdjacentObjectsLazy, narrowSchema, objectBindingPatternDef, operationDef, outputDef, parameterDef, propertyDef, requestBodyDef, responseDef, schemaDef, schemaTypes, setDiscriminatorEnum, setEnumName, signatureOf, simplifyUnion, sourceDef, syncOptionality, syncSchemaRef, textDef, transform, typeDef, typeLiteralDef, update, walk };
|
|
135
|
+
export { type ArraySchemaNode, type ArrowFunctionNode, type BreakNode, type CodeNode, type ConstNode, type ContentNode, type DateSchemaNode, type DatetimeSchemaNode, type DedupeCanonical, type DedupeLookups, type DedupePlan, type DistributiveOmit, type EnumSchemaNode, type ExportNode, type FileNode, type FunctionNode, type FunctionParamKind, type FunctionParamNode, type FunctionParameterNode, type FunctionParametersNode, type GenericOperationNode, type HttpMethod, type HttpOperationNode, type ImportNode, type IndexedAccessTypeNode, type InferSchemaNode, type InputMeta, type InputNode, type IntersectionSchemaNode, type JSDocNode, type JsxNode, type Node, type NodeDef, type NodeKind, type NumberSchemaNode, type ObjectBindingPatternNode, type ObjectSchemaNode, type OperationNode, type OperationParamsResolver, type OutputNode, type ParameterLocation, type ParameterNode, 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 SchemaDialect, type SchemaNode, type SchemaNodeByType, type SchemaType, type SourceNode, type StatusCode, type StringSchemaNode, type TextNode, type TimeSchemaNode, type TypeExpression, type TypeLiteralNode, type TypeNode, type UnionSchemaNode, type UrlSchemaNode, type UserFileNode, type Visitor, type VisitorContext, applyDedupe, arrowFunctionDef, breakDef, buildDedupePlan, collect, constDef, contentDef, createPrinterFactory, defineNode, definePrinter, defineSchemaDialect, exportDef, extractStringsFromNodes, factory_d_exports as factory, fileDef, functionDef, functionParameterDef, functionParametersDef, httpMethods, importDef, indexedAccessTypeDef, inputDef, isHttpOperationNode, jsxDef, mergeAdjacentObjectsLazy, narrowSchema, nodeDefs, objectBindingPatternDef, operationDef, outputDef, parameterDef, propertyDef, requestBodyDef, responseDef, schemaDef, schemaTypes, setDiscriminatorEnum, setEnumName, signatureOf, simplifyUnion, sourceDef, syncOptionality, textDef, transform, typeDef, typeLiteralDef, walk };
|
|
98
136
|
//# sourceMappingURL=index.d.ts.map
|