@kubb/ast 5.0.0-alpha.67 → 5.0.0-alpha.69

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.d.ts CHANGED
@@ -3362,6 +3362,77 @@ declare function createOperationParams(node: OperationNode, options: CreateOpera
3362
3362
  * Used by `createFile` to build the full source string for import filtering.
3363
3363
  */
3364
3364
  declare function extractStringsFromNodes(nodes: Array<CodeNode> | undefined): string;
3365
+ /**
3366
+ * Resolves the referenced schema name of a `ref` node, falling back through
3367
+ * `ref` → `name` → nested `schema.name`. Returns `undefined` for non-ref
3368
+ * nodes or when no name can be resolved.
3369
+ *
3370
+ * @example
3371
+ * ```ts
3372
+ * resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' })
3373
+ * // => 'Pet'
3374
+ * ```
3375
+ */
3376
+ declare function resolveRefName(node: SchemaNode | undefined): string | undefined;
3377
+ /**
3378
+ * Recursively collects every named schema referenced (transitively) from
3379
+ * `node` via `ref` edges. Refs are followed by name only — the resolved
3380
+ * `node.schema` of a ref is not traversed inline.
3381
+ *
3382
+ * @example
3383
+ * ```ts
3384
+ * const refs = collectReferencedSchemaNames(petSchema)
3385
+ * // => Set { 'Cat', 'Dog' }
3386
+ * ```
3387
+ */
3388
+ declare function collectReferencedSchemaNames(node: SchemaNode | undefined, out?: Set<string>): Set<string>;
3389
+ /**
3390
+ * Identifies every named schema that participates in a circular dependency
3391
+ * chain — including direct self-loops (e.g. `TreeNode → TreeNode`) and indirect
3392
+ * cycles spanning multiple schemas (e.g. `Pet → Cat → Pet`).
3393
+ *
3394
+ * The returned set contains schema names. Plugins that translate schemas into
3395
+ * a host language can use this to wrap recursive positions in a deferred
3396
+ * construct (lazy getter, `z.lazy(() => …)`, etc.) and avoid runtime stack
3397
+ * overflows when the generated code is executed.
3398
+ *
3399
+ * Refs are followed by name only — `node.schema` (the resolved referent) is
3400
+ * not traversed inline, which keeps the algorithm linear in the size of the
3401
+ * schema graph.
3402
+ *
3403
+ * @example
3404
+ * ```ts
3405
+ * const circular = findCircularSchemas(inputNode.schemas)
3406
+ * if (circular.has('Pet')) {
3407
+ * // emit lazy wrapper for any property whose schema references Pet
3408
+ * }
3409
+ * ```
3410
+ */
3411
+ declare function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string>;
3412
+ /**
3413
+ * Returns true when `node` (or anything nested within it) carries a `ref`
3414
+ * whose resolved name belongs to `circularSchemas`.
3415
+ *
3416
+ * When `excludeName` is provided, refs to that name are ignored — useful
3417
+ * when self-references are already handled separately from cross-schema
3418
+ * cycles (e.g. the faker plugin emits `undefined as any` for direct
3419
+ * self-recursion but a lazy getter for indirect cycles).
3420
+ *
3421
+ * @example
3422
+ * ```ts
3423
+ * const circular = findCircularSchemas(schemas)
3424
+ * if (containsCircularRef(property.schema, { circularSchemas: circular, excludeName: 'Pet' })) {
3425
+ * // emit `get foo() { return fakeCat() }` instead of eager call
3426
+ * }
3427
+ * ```
3428
+ */
3429
+ declare function containsCircularRef(node: SchemaNode | undefined, {
3430
+ circularSchemas,
3431
+ excludeName
3432
+ }: {
3433
+ circularSchemas: ReadonlySet<string>;
3434
+ excludeName?: string;
3435
+ }): boolean;
3365
3436
  //#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, 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 };
3437
+ 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, collectReferencedSchemaNames, containsCircularRef, 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, findCircularSchemas, findDiscriminator, httpMethods, isInputNode, isOperationNode, isOutputNode, isScalarPrimitive, isSchemaNode, isStringType, mediaTypes, mergeAdjacentObjects, narrowSchema, nodeKinds, resolveRefName, schemaTypes, setDiscriminatorEnum, setEnumName, simplifyUnion, syncOptionality, syncSchemaRef, transform, walk };
3367
3438
  //# sourceMappingURL=index.d.ts.map