@kubb/ast 5.14.0 → 5.14.2
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 +11 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -3
- package/dist/index.d.ts +32 -3
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -927,6 +927,27 @@ type UserParameterNode = Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial
|
|
|
927
927
|
declare function createParameter(input: UserParameterNode): ParameterNode;
|
|
928
928
|
//#endregion
|
|
929
929
|
//#region src/nodes/content.d.ts
|
|
930
|
+
/**
|
|
931
|
+
* How one body property is serialized, from the `encoding` entry of its media type.
|
|
932
|
+
*/
|
|
933
|
+
type EncodingNode = {
|
|
934
|
+
/**
|
|
935
|
+
* Content type of the part, for example `'application/json'` for a multipart property.
|
|
936
|
+
*/
|
|
937
|
+
contentType?: string;
|
|
938
|
+
/**
|
|
939
|
+
* Serialization style of the property.
|
|
940
|
+
*/
|
|
941
|
+
style?: ParameterStyle;
|
|
942
|
+
/**
|
|
943
|
+
* Whether array and object values expand into separate values.
|
|
944
|
+
*/
|
|
945
|
+
explode?: boolean;
|
|
946
|
+
/**
|
|
947
|
+
* Whether reserved characters are sent as-is instead of percent-encoded.
|
|
948
|
+
*/
|
|
949
|
+
allowReserved?: boolean;
|
|
950
|
+
};
|
|
930
951
|
/**
|
|
931
952
|
* AST node representing one content-type entry of a request body or response.
|
|
932
953
|
*
|
|
@@ -960,6 +981,10 @@ type ContentNode = BaseNode & {
|
|
|
960
981
|
* Set when a referenced schema has `readOnly`/`writeOnly` fields that should be omitted.
|
|
961
982
|
*/
|
|
962
983
|
keysToOmit?: Array<string> | null;
|
|
984
|
+
/**
|
|
985
|
+
* Serialization settings per body property that sets at least one field in the spec's `encoding`.
|
|
986
|
+
*/
|
|
987
|
+
encoding?: Record<string, EncodingNode>;
|
|
963
988
|
};
|
|
964
989
|
/**
|
|
965
990
|
* Creates a `ContentNode` for a single request-body or response content type.
|
|
@@ -2578,7 +2603,11 @@ type InlineFilesOptions = {
|
|
|
2578
2603
|
export declare function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult;
|
|
2579
2604
|
//#endregion
|
|
2580
2605
|
//#region src/utils/refs.d.ts
|
|
2581
|
-
/**
|
|
2606
|
+
/**
|
|
2607
|
+
* Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.
|
|
2608
|
+
* The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`
|
|
2609
|
+
* (RFC 6901), so `a~1b~0c` names the component `a/b~c`.
|
|
2610
|
+
*/
|
|
2582
2611
|
export declare function refName(ref: string): string;
|
|
2583
2612
|
/**
|
|
2584
2613
|
* Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when
|
|
@@ -2828,8 +2857,8 @@ type ParserOptions = {
|
|
|
2828
2857
|
enumSuffix: 'enum' | (string & {});
|
|
2829
2858
|
};
|
|
2830
2859
|
declare namespace index_d_exports {
|
|
2831
|
-
export { ArraySchemaNode, ArrowFunctionNode, BreakNode, CodeNode, ConstNode, ContentNode, DateOnlyTypeValue, DateSchemaNode, DateTimeTypeValue, DateTypeOptions, DatetimeSchemaNode, DistributiveOmit, 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 };
|
|
2860
|
+
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 };
|
|
2832
2861
|
}
|
|
2833
2862
|
//#endregion
|
|
2834
|
-
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 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 };
|
|
2863
|
+
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 };
|
|
2835
2864
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -927,6 +927,27 @@ type UserParameterNode = Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial
|
|
|
927
927
|
declare function createParameter(input: UserParameterNode): ParameterNode;
|
|
928
928
|
//#endregion
|
|
929
929
|
//#region src/nodes/content.d.ts
|
|
930
|
+
/**
|
|
931
|
+
* How one body property is serialized, from the `encoding` entry of its media type.
|
|
932
|
+
*/
|
|
933
|
+
type EncodingNode = {
|
|
934
|
+
/**
|
|
935
|
+
* Content type of the part, for example `'application/json'` for a multipart property.
|
|
936
|
+
*/
|
|
937
|
+
contentType?: string;
|
|
938
|
+
/**
|
|
939
|
+
* Serialization style of the property.
|
|
940
|
+
*/
|
|
941
|
+
style?: ParameterStyle;
|
|
942
|
+
/**
|
|
943
|
+
* Whether array and object values expand into separate values.
|
|
944
|
+
*/
|
|
945
|
+
explode?: boolean;
|
|
946
|
+
/**
|
|
947
|
+
* Whether reserved characters are sent as-is instead of percent-encoded.
|
|
948
|
+
*/
|
|
949
|
+
allowReserved?: boolean;
|
|
950
|
+
};
|
|
930
951
|
/**
|
|
931
952
|
* AST node representing one content-type entry of a request body or response.
|
|
932
953
|
*
|
|
@@ -960,6 +981,10 @@ type ContentNode = BaseNode & {
|
|
|
960
981
|
* Set when a referenced schema has `readOnly`/`writeOnly` fields that should be omitted.
|
|
961
982
|
*/
|
|
962
983
|
keysToOmit?: Array<string> | null;
|
|
984
|
+
/**
|
|
985
|
+
* Serialization settings per body property that sets at least one field in the spec's `encoding`.
|
|
986
|
+
*/
|
|
987
|
+
encoding?: Record<string, EncodingNode>;
|
|
963
988
|
};
|
|
964
989
|
/**
|
|
965
990
|
* Creates a `ContentNode` for a single request-body or response content type.
|
|
@@ -2578,7 +2603,11 @@ type InlineFilesOptions = {
|
|
|
2578
2603
|
export declare function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult;
|
|
2579
2604
|
//#endregion
|
|
2580
2605
|
//#region src/utils/refs.d.ts
|
|
2581
|
-
/**
|
|
2606
|
+
/**
|
|
2607
|
+
* Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.
|
|
2608
|
+
* The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`
|
|
2609
|
+
* (RFC 6901), so `a~1b~0c` names the component `a/b~c`.
|
|
2610
|
+
*/
|
|
2582
2611
|
export declare function refName(ref: string): string;
|
|
2583
2612
|
/**
|
|
2584
2613
|
* Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when
|
|
@@ -2828,8 +2857,8 @@ type ParserOptions = {
|
|
|
2828
2857
|
enumSuffix: 'enum' | (string & {});
|
|
2829
2858
|
};
|
|
2830
2859
|
declare namespace index_d_exports {
|
|
2831
|
-
export { ArraySchemaNode, ArrowFunctionNode, BreakNode, CodeNode, ConstNode, ContentNode, DateOnlyTypeValue, DateSchemaNode, DateTimeTypeValue, DateTypeOptions, DatetimeSchemaNode, DistributiveOmit, 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 };
|
|
2860
|
+
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 };
|
|
2832
2861
|
}
|
|
2833
2862
|
//#endregion
|
|
2834
|
-
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 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 };
|
|
2863
|
+
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 };
|
|
2835
2864
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1109,9 +1109,18 @@ function rewriteNodes(nodes, rewrite) {
|
|
|
1109
1109
|
}
|
|
1110
1110
|
//#endregion
|
|
1111
1111
|
//#region src/utils/refs.ts
|
|
1112
|
-
/**
|
|
1112
|
+
/**
|
|
1113
|
+
* Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.
|
|
1114
|
+
* The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`
|
|
1115
|
+
* (RFC 6901), so `a~1b~0c` names the component `a/b~c`.
|
|
1116
|
+
*/
|
|
1113
1117
|
function refName(ref) {
|
|
1114
|
-
|
|
1118
|
+
const segment = ref.split("/").at(-1) ?? ref;
|
|
1119
|
+
let decoded = segment;
|
|
1120
|
+
try {
|
|
1121
|
+
decoded = decodeURIComponent(segment);
|
|
1122
|
+
} catch {}
|
|
1123
|
+
return decoded.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
1115
1124
|
}
|
|
1116
1125
|
/**
|
|
1117
1126
|
* Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when
|