@kubb/ast 5.3.13 → 5.3.14
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 +21 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,13 @@ export declare function extractStringsFromNodes(nodes: Array<CodeNode> | undefin
|
|
|
54
54
|
* `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Order', targetName: 'OrderSchema' }) // 'OrderSchema'`
|
|
55
55
|
*/
|
|
56
56
|
export declare function resolveRefName(node: SchemaNode | null | undefined): string | null;
|
|
57
|
+
/**
|
|
58
|
+
* Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.
|
|
59
|
+
*
|
|
60
|
+
* Modifiers inherited from the resolved schema are included in the check because a ref emits the
|
|
61
|
+
* referenced schema variable with those modifiers already applied.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isBareRef(node: SchemaNode | null | undefined, keysToOmit?: Array<string> | null): boolean;
|
|
57
64
|
//#endregion
|
|
58
65
|
//#region src/utils/schemaGraph.d.ts
|
|
59
66
|
/**
|
|
@@ -271,7 +278,7 @@ export declare const nodeDefs: (NodeDef<InputNode, Partial<Omit<InputNode, "kind
|
|
|
271
278
|
type: "ipv6";
|
|
272
279
|
}) | ScalarSchemaNode, "kind">> | NodeDef<PropertyNode, Pick<PropertyNode, "schema" | "name"> & Partial<Omit<PropertyNode, "schema" | "kind" | "name">>> | NodeDef<ParameterNode, Pick<ParameterNode, "schema" | "name" | "in"> & Partial<Omit<ParameterNode, "schema" | "kind" | "name" | "in">>> | 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<ImportNode, Omit<ImportNode, "kind">> | NodeDef<ExportNode, Omit<ExportNode, "kind">> | NodeDef<SourceNode, Omit<SourceNode, "kind">> | NodeDef<FileNode<object>, Omit<FileNode<object>, "kind">>)[];
|
|
273
280
|
declare namespace exports_d_exports {
|
|
274
|
-
export { ArraySchemaNode, ArrowFunctionNode, BreakNode, CodeNode, ConstNode, ContentNode, DateOnlyTypeValue, DateSchemaNode, DateTimeTypeValue, DateTypeOptions, DatetimeSchemaNode, DistributiveOmit, Enforce, EnumSchemaNode, ExportNode, FileNode, FunctionNode, GenericOperationNode, HttpMethod, HttpOperationNode, ImportNode, InferSchemaNode, InputMeta, InputNode, IntersectionSchemaNode, JSDocNode, JsxNode, Macro, Node, NodeDef, NodeKind, NumberSchemaNode, ObjectSchemaNode, OperationNode, OutputNode, 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, arrowFunctionDef, breakDef, collect, collectImportedRefNames, collectSync, collectUsedSchemaNames, composeMacros, constDef, contentDef, createPrinter, defineMacro, defineNode, exportDef, extractStringsFromNodes, factory_d_exports as factory, fileDef, findCircularSchemas, findCircularSchemasFromGraph, functionDef, getSchemaLiteralValues, importDef, inferDiscriminatorPropertyName, inputDef, isHttpOperationNode, jsxDef, narrowSchema, nodeDefs, operationDef, optionality, outputDef, parameterDef, propertyDef, requestBodyDef, resolveRefName, resolveSchemaProperties, responseDef, schemaDef, schemaTypes, sourceDef, textDef, transform, typeDef };
|
|
281
|
+
export { ArraySchemaNode, ArrowFunctionNode, BreakNode, CodeNode, ConstNode, ContentNode, DateOnlyTypeValue, DateSchemaNode, DateTimeTypeValue, DateTypeOptions, DatetimeSchemaNode, DistributiveOmit, Enforce, EnumSchemaNode, ExportNode, FileNode, FunctionNode, GenericOperationNode, HttpMethod, HttpOperationNode, ImportNode, InferSchemaNode, InputMeta, InputNode, IntersectionSchemaNode, JSDocNode, JsxNode, Macro, Node, NodeDef, NodeKind, NumberSchemaNode, ObjectSchemaNode, OperationNode, OutputNode, 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, arrowFunctionDef, breakDef, collect, collectImportedRefNames, collectSync, collectUsedSchemaNames, composeMacros, constDef, contentDef, createPrinter, defineMacro, defineNode, exportDef, extractStringsFromNodes, factory_d_exports as factory, fileDef, findCircularSchemas, findCircularSchemasFromGraph, functionDef, getSchemaLiteralValues, importDef, inferDiscriminatorPropertyName, inputDef, isBareRef, isHttpOperationNode, jsxDef, narrowSchema, nodeDefs, operationDef, optionality, outputDef, parameterDef, propertyDef, requestBodyDef, resolveRefName, resolveSchemaProperties, responseDef, schemaDef, schemaTypes, sourceDef, textDef, transform, typeDef };
|
|
275
282
|
}
|
|
276
283
|
//#endregion
|
|
277
284
|
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 InferSchemaNode, type InputMeta, type InputNode, type IntersectionSchemaNode, type JSDocNode, type JsxNode, type Macro, type Node, type NodeDef, type NodeKind, type NumberSchemaNode, type ObjectSchemaNode, type OperationNode, type OutputNode, 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, applyMacros, arrowFunctionDef, exports_d_exports as ast, breakDef, collect, collectSync, composeMacros, constDef, contentDef, createPrinter, defineMacro, defineNode, exportDef, factory_d_exports as factory, fileDef, functionDef, importDef, inputDef, jsxDef, operationDef, outputDef, parameterDef, propertyDef, requestBodyDef, responseDef, schemaDef, schemaTypes, sourceDef, textDef, transform, typeDef };
|
package/dist/index.js
CHANGED
|
@@ -1338,6 +1338,25 @@ function resolveRefName(node) {
|
|
|
1338
1338
|
if (node.ref) return node.ref.split("/").at(-1) ?? node.ref;
|
|
1339
1339
|
return node.name ?? node.schema?.name ?? null;
|
|
1340
1340
|
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.
|
|
1343
|
+
*
|
|
1344
|
+
* Modifiers inherited from the resolved schema are included in the check because a ref emits the
|
|
1345
|
+
* referenced schema variable with those modifiers already applied.
|
|
1346
|
+
*/
|
|
1347
|
+
function isBareRef(node, keysToOmit) {
|
|
1348
|
+
if (!node || node.type !== "ref") return false;
|
|
1349
|
+
const meta = (() => {
|
|
1350
|
+
if (!node.schema) return node;
|
|
1351
|
+
const { kind: _kind, type: _type, name: _name, ref: _ref, schema: _schema, ...overrides } = node;
|
|
1352
|
+
const definedOverrides = Object.fromEntries(Object.entries(overrides).filter(([, value]) => value !== void 0));
|
|
1353
|
+
return {
|
|
1354
|
+
...node.schema,
|
|
1355
|
+
...definedOverrides
|
|
1356
|
+
};
|
|
1357
|
+
})();
|
|
1358
|
+
return !meta.nullable && !meta.optional && !meta.nullish && meta.default === void 0 && !meta.description && !meta.examples?.length && !keysToOmit?.length;
|
|
1359
|
+
}
|
|
1341
1360
|
//#endregion
|
|
1342
1361
|
//#region src/utils/schemaGraph.ts
|
|
1343
1362
|
/**
|
|
@@ -1699,6 +1718,7 @@ var exports_exports = /* @__PURE__ */ __exportAll({
|
|
|
1699
1718
|
importDef: () => importDef,
|
|
1700
1719
|
inferDiscriminatorPropertyName: () => inferDiscriminatorPropertyName,
|
|
1701
1720
|
inputDef: () => inputDef,
|
|
1721
|
+
isBareRef: () => isBareRef,
|
|
1702
1722
|
isHttpOperationNode: () => isHttpOperationNode,
|
|
1703
1723
|
jsxDef: () => jsxDef,
|
|
1704
1724
|
narrowSchema: () => narrowSchema,
|
|
@@ -1720,6 +1740,6 @@ var exports_exports = /* @__PURE__ */ __exportAll({
|
|
|
1720
1740
|
typeDef: () => typeDef
|
|
1721
1741
|
});
|
|
1722
1742
|
//#endregion
|
|
1723
|
-
export { applyMacros, arrowFunctionDef, exports_exports as ast, breakDef, collect, collectImportedRefNames, collectSync, collectUsedSchemaNames, composeMacros, constDef, contentDef, createPrinter, defineMacro, defineNode, exportDef, extractStringsFromNodes, factory_exports as factory, fileDef, findCircularSchemas, findCircularSchemasFromGraph, functionDef, getSchemaLiteralValues, importDef, inferDiscriminatorPropertyName, inputDef, isHttpOperationNode, jsxDef, narrowSchema, nodeDefs, operationDef, optionality, outputDef, parameterDef, propertyDef, requestBodyDef, resolveRefName, resolveSchemaProperties, responseDef, schemaDef, schemaTypes, sourceDef, textDef, transform, typeDef };
|
|
1743
|
+
export { applyMacros, arrowFunctionDef, exports_exports as ast, breakDef, collect, collectImportedRefNames, collectSync, collectUsedSchemaNames, composeMacros, constDef, contentDef, createPrinter, defineMacro, defineNode, exportDef, extractStringsFromNodes, factory_exports as factory, fileDef, findCircularSchemas, findCircularSchemasFromGraph, functionDef, getSchemaLiteralValues, importDef, inferDiscriminatorPropertyName, inputDef, isBareRef, isHttpOperationNode, jsxDef, narrowSchema, nodeDefs, operationDef, optionality, outputDef, parameterDef, propertyDef, requestBodyDef, resolveRefName, resolveSchemaProperties, responseDef, schemaDef, schemaTypes, sourceDef, textDef, transform, typeDef };
|
|
1724
1744
|
|
|
1725
1745
|
//# sourceMappingURL=index.js.map
|