@kubb/ast 5.0.0-alpha.35 → 5.0.0-alpha.38
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 +17 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -16
- package/dist/index.js +18 -57
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/visitor.ts +0 -41
package/dist/index.d.ts
CHANGED
|
@@ -3118,21 +3118,6 @@ declare function transform(node: PropertyNode, options: TransformOptions): Prope
|
|
|
3118
3118
|
declare function transform(node: ParameterNode, options: TransformOptions): ParameterNode;
|
|
3119
3119
|
declare function transform(node: ResponseNode, options: TransformOptions): ResponseNode;
|
|
3120
3120
|
declare function transform(node: Node, options: TransformOptions): Node;
|
|
3121
|
-
/**
|
|
3122
|
-
* Composes multiple visitors into one visitor, applied left to right.
|
|
3123
|
-
*
|
|
3124
|
-
* For each node kind, output from one visitor is input to the next.
|
|
3125
|
-
* If a visitor returns `undefined`, the previous node value is kept.
|
|
3126
|
-
*
|
|
3127
|
-
* @example
|
|
3128
|
-
* ```ts
|
|
3129
|
-
* const visitor = composeTransformers(
|
|
3130
|
-
* { operation: (node) => ({ ...node, operationId: `a_${node.operationId}` }) },
|
|
3131
|
-
* { operation: (node) => ({ ...node, operationId: `b_${node.operationId}` }) },
|
|
3132
|
-
* )
|
|
3133
|
-
* ```
|
|
3134
|
-
*/
|
|
3135
|
-
declare function composeTransformers(...visitors: Array<Visitor>): Visitor;
|
|
3136
3121
|
/**
|
|
3137
3122
|
* Runs a depth-first synchronous collection pass.
|
|
3138
3123
|
*
|
|
@@ -3363,5 +3348,5 @@ declare function createOperationParams(node: OperationNode, options: CreateOpera
|
|
|
3363
3348
|
*/
|
|
3364
3349
|
declare function extractStringsFromNodes(nodes: Array<CodeNode> | undefined): string;
|
|
3365
3350
|
//#endregion
|
|
3366
|
-
export { type ArraySchemaNode, type ArrowFunctionNode, AsyncVisitor, type BaseNode, type BreakNode, type CodeNode, CollectOptions, CollectVisitor, type ComplexSchemaType, type ConstNode, type DateSchemaNode, type DatetimeSchemaNode, DistributiveOmit, type EnumSchemaNode, type EnumValueNode, type ExportNode, type FileNode, type FormatStringSchemaNode, type FunctionNode, type FunctionNodeType, type FunctionParamNode, type FunctionParameterNode, type FunctionParametersNode, type HttpMethod, type HttpStatusCode, type ImportNode, InferSchema, InferSchemaNode, type InputMeta, type InputNode, type IntersectionSchemaNode, type Ipv4SchemaNode, type Ipv6SchemaNode, type JSDocNode, type JsxNode, type MediaType, Node, type NodeKind, type NumberSchemaNode, type ObjectSchemaNode, type OperationNode, type OperationParamsResolver, type OutputNode, type ParameterGroupNode, type ParameterLocation, type ParameterNode, type ParamsTypeNode, ParentOf, type ParserOptions, type PrimitiveSchemaType, type Printer, type PrinterFactoryOptions, type PrinterPartial, type PropertyNode, RefMap, type RefSchemaNode, type ResponseNode, type ScalarPrimitive, type ScalarSchemaNode, type ScalarSchemaType, type SchemaNode, type SchemaNodeByType, type SchemaType, type SourceNode, type SpecialSchemaType, type StatusCode, type StringSchemaNode, type TextNode, type TimeSchemaNode, TransformOptions, type TypeDeclarationNode, type TypeNode, type UnionSchemaNode, type UrlSchemaNode, Visitor, VisitorContext, VisitorDepth, WalkOptions, caseParams, childName, collect, collectImports,
|
|
3351
|
+
export { type ArraySchemaNode, type ArrowFunctionNode, AsyncVisitor, type BaseNode, type BreakNode, type CodeNode, CollectOptions, CollectVisitor, type ComplexSchemaType, type ConstNode, type DateSchemaNode, type DatetimeSchemaNode, DistributiveOmit, type EnumSchemaNode, type EnumValueNode, type ExportNode, type FileNode, type FormatStringSchemaNode, type FunctionNode, type FunctionNodeType, type FunctionParamNode, type FunctionParameterNode, type FunctionParametersNode, type HttpMethod, type HttpStatusCode, type ImportNode, InferSchema, InferSchemaNode, type InputMeta, type InputNode, type IntersectionSchemaNode, type Ipv4SchemaNode, type Ipv6SchemaNode, type JSDocNode, type JsxNode, type MediaType, Node, type NodeKind, type NumberSchemaNode, type ObjectSchemaNode, type OperationNode, type OperationParamsResolver, type OutputNode, type ParameterGroupNode, type ParameterLocation, type ParameterNode, type ParamsTypeNode, ParentOf, type ParserOptions, type PrimitiveSchemaType, type Printer, type PrinterFactoryOptions, type PrinterPartial, type PropertyNode, RefMap, type RefSchemaNode, type ResponseNode, type ScalarPrimitive, type ScalarSchemaNode, type ScalarSchemaType, type SchemaNode, type SchemaNodeByType, type SchemaType, type SourceNode, type SpecialSchemaType, type StatusCode, type StringSchemaNode, type TextNode, type TimeSchemaNode, TransformOptions, type TypeDeclarationNode, type TypeNode, type UnionSchemaNode, type UrlSchemaNode, Visitor, VisitorContext, VisitorDepth, WalkOptions, caseParams, childName, collect, collectImports, createArrowFunction, createBreak, createConst, createDiscriminantNode, createExport, createFile, createFunction, createFunctionParameter, createFunctionParameters, createImport, createInput, createJsx, createOperation, createOperationParams, createOutput, createParameter, createParameterGroup, createParamsType, createPrinterFactory, createProperty, createResponse, createSchema, createSource, createText, createType, definePrinter, enumPropName, extractRefName, extractStringsFromNodes, findDiscriminator, httpMethods, isInputNode, isOperationNode, isOutputNode, isScalarPrimitive, isSchemaNode, isStringType, mediaTypes, mergeAdjacentObjects, narrowSchema, nodeKinds, schemaTypes, setDiscriminatorEnum, setEnumName, simplifyUnion, syncOptionality, syncSchemaRef, transform, walk };
|
|
3367
3352
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -170,23 +170,6 @@ function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
|
170
170
|
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
171
171
|
}
|
|
172
172
|
//#endregion
|
|
173
|
-
//#region ../../internals/utils/src/string.ts
|
|
174
|
-
/**
|
|
175
|
-
* Strips the file extension from a path or file name.
|
|
176
|
-
* Only removes the last `.ext` segment when the dot is not part of a directory name.
|
|
177
|
-
*
|
|
178
|
-
* @example
|
|
179
|
-
* trimExtName('petStore.ts') // 'petStore'
|
|
180
|
-
* trimExtName('/src/models/pet.ts') // '/src/models/pet'
|
|
181
|
-
* trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'
|
|
182
|
-
* trimExtName('noExtension') // 'noExtension'
|
|
183
|
-
*/
|
|
184
|
-
function trimExtName(text) {
|
|
185
|
-
const dotIndex = text.lastIndexOf(".");
|
|
186
|
-
if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
|
|
187
|
-
return text;
|
|
188
|
-
}
|
|
189
|
-
//#endregion
|
|
190
173
|
//#region ../../internals/utils/src/reserved.ts
|
|
191
174
|
/**
|
|
192
175
|
* Returns `true` when `name` is a syntactically valid JavaScript variable name.
|
|
@@ -207,6 +190,23 @@ function isValidVarName(name) {
|
|
|
207
190
|
return true;
|
|
208
191
|
}
|
|
209
192
|
//#endregion
|
|
193
|
+
//#region ../../internals/utils/src/string.ts
|
|
194
|
+
/**
|
|
195
|
+
* Strips the file extension from a path or file name.
|
|
196
|
+
* Only removes the last `.ext` segment when the dot is not part of a directory name.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* trimExtName('petStore.ts') // 'petStore'
|
|
200
|
+
* trimExtName('/src/models/pet.ts') // '/src/models/pet'
|
|
201
|
+
* trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'
|
|
202
|
+
* trimExtName('noExtension') // 'noExtension'
|
|
203
|
+
*/
|
|
204
|
+
function trimExtName(text) {
|
|
205
|
+
const dotIndex = text.lastIndexOf(".");
|
|
206
|
+
if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
|
|
207
|
+
return text;
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
210
|
//#region src/guards.ts
|
|
211
211
|
/**
|
|
212
212
|
* Narrows a `SchemaNode` to the variant that matches `type`.
|
|
@@ -1683,45 +1683,6 @@ function transform(node, options) {
|
|
|
1683
1683
|
}
|
|
1684
1684
|
}
|
|
1685
1685
|
/**
|
|
1686
|
-
* Composes multiple visitors into one visitor, applied left to right.
|
|
1687
|
-
*
|
|
1688
|
-
* For each node kind, output from one visitor is input to the next.
|
|
1689
|
-
* If a visitor returns `undefined`, the previous node value is kept.
|
|
1690
|
-
*
|
|
1691
|
-
* @example
|
|
1692
|
-
* ```ts
|
|
1693
|
-
* const visitor = composeTransformers(
|
|
1694
|
-
* { operation: (node) => ({ ...node, operationId: `a_${node.operationId}` }) },
|
|
1695
|
-
* { operation: (node) => ({ ...node, operationId: `b_${node.operationId}` }) },
|
|
1696
|
-
* )
|
|
1697
|
-
* ```
|
|
1698
|
-
*/
|
|
1699
|
-
function composeTransformers(...visitors) {
|
|
1700
|
-
return {
|
|
1701
|
-
input(node, context) {
|
|
1702
|
-
return visitors.reduce((acc, v) => v.input?.(acc, context) ?? acc, node);
|
|
1703
|
-
},
|
|
1704
|
-
output(node, context) {
|
|
1705
|
-
return visitors.reduce((acc, v) => v.output?.(acc, context) ?? acc, node);
|
|
1706
|
-
},
|
|
1707
|
-
operation(node, context) {
|
|
1708
|
-
return visitors.reduce((acc, v) => v.operation?.(acc, context) ?? acc, node);
|
|
1709
|
-
},
|
|
1710
|
-
schema(node, context) {
|
|
1711
|
-
return visitors.reduce((acc, v) => v.schema?.(acc, context) ?? acc, node);
|
|
1712
|
-
},
|
|
1713
|
-
property(node, context) {
|
|
1714
|
-
return visitors.reduce((acc, v) => v.property?.(acc, context) ?? acc, node);
|
|
1715
|
-
},
|
|
1716
|
-
parameter(node, context) {
|
|
1717
|
-
return visitors.reduce((acc, v) => v.parameter?.(acc, context) ?? acc, node);
|
|
1718
|
-
},
|
|
1719
|
-
response(node, context) {
|
|
1720
|
-
return visitors.reduce((acc, v) => v.response?.(acc, context) ?? acc, node);
|
|
1721
|
-
}
|
|
1722
|
-
};
|
|
1723
|
-
}
|
|
1724
|
-
/**
|
|
1725
1686
|
* Runs a depth-first synchronous collection pass.
|
|
1726
1687
|
*
|
|
1727
1688
|
* Non-`undefined` values returned by visitor callbacks are appended to the result.
|
|
@@ -1915,6 +1876,6 @@ function setEnumName(propNode, parentName, propName, enumSuffix) {
|
|
|
1915
1876
|
return propNode;
|
|
1916
1877
|
}
|
|
1917
1878
|
//#endregion
|
|
1918
|
-
export { caseParams, childName, collect, collectImports,
|
|
1879
|
+
export { caseParams, childName, collect, collectImports, createArrowFunction, createBreak, createConst, createDiscriminantNode, createExport, createFile, createFunction, createFunctionParameter, createFunctionParameters, createImport, createInput, createJsx, createOperation, createOperationParams, createOutput, createParameter, createParameterGroup, createParamsType, createPrinterFactory, createProperty, createResponse, createSchema, createSource, createText, createType, definePrinter, enumPropName, extractRefName, extractStringsFromNodes, findDiscriminator, httpMethods, isInputNode, isOperationNode, isOutputNode, isScalarPrimitive, isSchemaNode, isStringType, mediaTypes, mergeAdjacentObjects, narrowSchema, nodeKinds, schemaTypes, setDiscriminatorEnum, setEnumName, simplifyUnion, syncOptionality, syncSchemaRef, transform, walk };
|
|
1919
1880
|
|
|
1920
1881
|
//# sourceMappingURL=index.js.map
|