/** * FluentSchemaHelpers — Chainable Parameter Declarations * * Provides `f.string()`, `f.number()`, `f.boolean()`, `f.enum()`, `f.array()` * that build ParamDescriptors via fluent method chaining. * * These are syntax sugar over the existing `ParamDescriptors` system. * At build time, `.toDescriptor()` produces the same JSON descriptor * that `convertParamsToZod()` already knows how to convert. * * @example * ```typescript * const f = initFusion(); * * f.query('users.list') * .input({ * limit: f.number().min(1).max(100).default(10).describe('Max results'), * status: f.enum('active', 'inactive').optional(), * name: f.string().min(3).example('Alice').describe('Search by name'), * }) * .resolve(async ({ input, ctx }) => { ... }); * ``` * * @module */ import type { ParamDef, StringParamDef, NumberParamDef, BooleanParamDef, EnumParamDef, ArrayParamDef } from './ParamDescriptors.js'; /** * Symbol used to detect fluent schema helpers at runtime. * @internal */ export declare const FLUENT_DESCRIPTOR: unique symbol; /** * Base interface for all fluent descriptors. * @internal */ export interface FluentDescriptor { readonly [FLUENT_DESCRIPTOR]: true; /** Convert the fluent descriptor to a plain ParamDef for ParamDescriptors. */ toDescriptor(): ParamDef; } /** * Type guard: is this value a FluentDescriptor? * @internal */ export declare function isFluentDescriptor(value: unknown): value is FluentDescriptor; /** * Infer the TypeScript type from a single fluent descriptor or ParamDef. * @internal */ type InferSingleFluent = T extends FluentString ? string : T extends FluentNumber ? number : T extends FluentBoolean ? boolean : T extends FluentEnum ? V : T extends FluentArray ? (T extends { _itemType: 'string'; } ? string[] : T extends { _itemType: 'number'; } ? number[] : T extends { _itemType: 'boolean'; } ? boolean[] : unknown[]) : T extends 'string' ? string : T extends 'number' ? number : T extends 'boolean' ? boolean : T extends { type: 'string'; } ? string : T extends { type: 'number'; } ? number : T extends { type: 'boolean'; } ? boolean : T extends { enum: readonly (infer V)[]; } ? V : T extends { array: 'string'; } ? string[] : T extends { array: 'number'; } ? number[] : T extends { array: 'boolean'; } ? boolean[] : unknown; /** * Check if a fluent/param value is optional. * @internal */ type IsFieldOptional = T extends { _optional: true; } ? true : T extends { optional: true; } ? true : false; /** Required keys from a FluentParamsMap */ type FluentRequiredKeys> = { [K in keyof T]: IsFieldOptional extends true ? never : K; }[keyof T]; /** Optional keys from a FluentParamsMap */ type FluentOptionalKeys> = { [K in keyof T]: IsFieldOptional extends true ? K : never; }[keyof T]; /** * Infer the full TypeScript type from a FluentParamsMap. * * Required params become required properties, optional params become * optional properties with `| undefined`. * * @example * ```typescript * const schema = { * limit: f.number().min(1).max(100), // required: number * status: f.enum('active', 'inactive').optional(), // optional: 'active' | 'inactive' * }; * type T = InferFluentParams; * // { limit: number; status?: 'active' | 'inactive' } * ``` */ export type InferFluentParams> = { [K in FluentRequiredKeys]: InferSingleFluent; } & { [K in FluentOptionalKeys]?: InferSingleFluent; }; export declare class FluentString implements FluentDescriptor { readonly [FLUENT_DESCRIPTOR]: true; private _desc?; /** @internal */ _optional: boolean; private _min?; private _max?; private _regex?; private _default?; private _examples?; /** Set minimum string length */ min(n: number): this; /** Set maximum string length */ max(n: number): this; /** Set regex validation pattern */ regex(pattern: string): this; /** Mark as optional */ optional(): FluentString & { _optional: true; }; /** Set human-readable description */ describe(text: string): this; /** Set default value (appended to description for LLM, auto-marks as optional) */ default(value: string): this; /** Add a single LLM few-shot example (AI-First DX) */ example(value: string): this; /** Set multiple LLM few-shot examples */ examples(...values: string[]): this; toDescriptor(): StringParamDef; } export declare class FluentNumber implements FluentDescriptor { readonly [FLUENT_DESCRIPTOR]: true; private _desc?; /** @internal */ _optional: boolean; private _min?; private _max?; private _int; private _default?; private _examples?; /** Set minimum value */ min(n: number): this; /** Set maximum value */ max(n: number): this; /** Restrict to integers */ int(): this; /** Mark as optional */ optional(): FluentNumber & { _optional: true; }; /** Set human-readable description */ describe(text: string): this; /** Set default value (appended to description for LLM, auto-marks as optional) */ default(value: number): this; /** Add a single LLM few-shot example (AI-First DX) */ example(value: number): this; /** Set multiple LLM few-shot examples */ examples(...values: number[]): this; toDescriptor(): NumberParamDef; } export declare class FluentBoolean implements FluentDescriptor { readonly [FLUENT_DESCRIPTOR]: true; private _desc?; /** @internal */ _optional: boolean; private _default?; /** Mark as optional */ optional(): FluentBoolean & { _optional: true; }; /** Set human-readable description */ describe(text: string): this; /** Set default value (appended to description for LLM, auto-marks as optional) */ default(value: boolean): this; toDescriptor(): BooleanParamDef; } export declare class FluentEnum implements FluentDescriptor { readonly [FLUENT_DESCRIPTOR]: true; private _desc?; /** @internal */ _optional: boolean; private _examples?; private _default?; private readonly _values; constructor(...values: [V, ...V[]]); /** Mark as optional */ optional(): FluentEnum & { _optional: true; }; /** Set human-readable description */ describe(text: string): this; /** Set default value (appended to description for LLM) */ default(value: V): this; /** Add a single LLM few-shot example (AI-First DX) */ example(value: V): this; /** Set multiple LLM few-shot examples */ examples(...values: V[]): this; toDescriptor(): EnumParamDef; } type PrimitiveType = 'string' | 'number' | 'boolean'; export declare class FluentArray implements FluentDescriptor { readonly [FLUENT_DESCRIPTOR]: true; private _desc?; /** @internal */ _optional: boolean; private _min?; private _max?; /** @internal */ readonly _itemType: PrimitiveType; constructor(itemType: PrimitiveType); /** Set minimum array length */ min(n: number): this; /** Set maximum array length */ max(n: number): this; /** Mark as optional */ optional(): FluentArray & { _optional: true; }; /** Set human-readable description */ describe(text: string): this; toDescriptor(): ArrayParamDef; } /** * A map where values can be either classic ParamDef or FluentDescriptor. * The FluentToolBuilder resolves these to ParamDef at build time. */ export type FluentParamsMap = Record; /** * Resolve a FluentParamsMap to a plain ParamsMap by calling .toDescriptor() * on any FluentDescriptor values. * @internal */ export declare function resolveFluentParams(input: FluentParamsMap): Record; export {}; //# sourceMappingURL=FluentSchemaHelpers.d.ts.map