import type { EffectLike, EffectRemoteCommand, EffectRemoteForm, EffectRemotePrerenderFunction, PrerenderOptions, QueryFactory, RemoteFormHandler, RemoteHandler, SchemaEncodedInput, SchemaInput, StandardSchema, StandardSchemaInput, StandardSchemaOutput } from "./types.js"; import type { RemoteFormInput } from "@sveltejs/kit"; import { type Schema } from "effect"; type FormSchemaEncodedInput = S extends Schema.Top ? FormRemoteInput : never; type FormRemoteInput = NormalizeFormEncoded extends RemoteFormInput ? NormalizeFormEncoded : never; type FormStandardSchemaInput = StandardSchemaInput extends RemoteFormInput ? StandardSchemaInput : RemoteFormInput; type FormScalar = string | number | boolean | File; type NormalizeFormEncoded = Value extends FormScalar ? Value : Value extends ReadonlyArray ? Array> : Value extends object ? NormalizeFormObject : Value; type NormalizeFormObject = { readonly [Key in keyof Value]: Key extends OptionalFormKeys ? NormalizeFormEncoded> : NormalizeFormEncoded; }; type OptionalFormKeys = { [Key in keyof Value]-?: Record extends Pick ? Key : never; }[keyof Value]; /** * Factory for read-only remote query functions. * * @example * ```ts * export const getUser = Query(Schema.Struct({ id: Schema.String }), (input) => * Effect.succeed(input.id) * ); * * export const getUserBatch = Query.batch(Schema.String, (ids) => * Effect.succeed((id) => ids.includes(id)) * ); * ``` * * @since 2.0.0 */ export declare const Query: QueryFactory; /** * Creates a write-oriented remote command from a no-argument Effect handler. * * @example * ```ts * export const RebuildCache = Command(() => Effect.succeed("done")); * ``` * * @since 2.0.0 * @param validate_or_handler - Effect value or no-argument handler to run on * the server when the command is invoked. * @returns A command function that yields an Effect when called. */ export declare function Command(validate_or_handler: EffectLike | RemoteHandler): EffectRemoteCommand; /** * Creates a write-oriented remote command with unchecked input. * * @example * ```ts * export const SaveDraft = Command("unchecked", (input: { id: string }) => * Effect.succeed(input.id) * ); * ``` * * @since 2.0.0 * @param validate_or_handler - `"unchecked"` sentinel that skips runtime input * validation. * @param maybe_handler - Handler that receives the caller-provided input. * @returns A command function that yields an Effect when called with input. */ export declare function Command(validate_or_handler: "unchecked", maybe_handler: RemoteHandler): EffectRemoteCommand; /** * Creates a write-oriented remote command validated with an Effect Schema. * * @example * ```ts * export const SaveUser = Command(Schema.Struct({ id: Schema.String }), ({ id }) => * Effect.succeed({ id, saved: true }) * ); * ``` * * @since 2.0.0 * @param validate_or_handler - Effect Schema used to decode and validate * caller input before the handler runs. * @param maybe_handler - Handler that receives the decoded schema output. * @returns A command function whose caller input is the schema encoded type. */ export declare function Command, A, E = never, R = never>(validate_or_handler: S, maybe_handler: RemoteHandler, A, E, R>): EffectRemoteCommand, A, E>; /** * Creates a write-oriented remote command validated with a Standard Schema. * * @example * ```ts * export const Toggle = Command(standard_schema, (input) => * Effect.succeed(input.enabled) * ); * ``` * * @since 3.0.0 * @param validate_or_handler - Standard Schema used to validate caller input * before the handler runs. * @param maybe_handler - Handler that receives the decoded schema output. * @returns A command function whose caller input is the schema input type. */ export declare function Command(validate_or_handler: S, maybe_handler: RemoteHandler, A, E, R>): EffectRemoteCommand, A, E>; /** * Factory for a remote form handler. * * @example * ```ts * export const SignIn = Form(signInSchema, ({ data, invalid }) => * Effect.gen(function* () { * if (!data.email.includes("@")) { * return yield* invalid.email("Use an email address."); * } * * return { email: data.email }; * }) * ); * ``` * * @since 2.0.0 * @param validate_or_handler - A schema, `"unchecked"`, or no-arg handler. * @param maybe_handler - Handler used when a validator is supplied. * @returns A SvelteKit form function. */ export declare function Form(validate_or_handler: EffectLike | RemoteFormHandler): EffectRemoteForm; export declare function Form(validate_or_handler: "unchecked", maybe_handler: RemoteFormHandler): EffectRemoteForm; export declare function Form(validate_or_handler: S, maybe_handler: RemoteFormHandler, A, E, R>): EffectRemoteForm, A, E>; export declare function Form(validate_or_handler: S, maybe_handler: RemoteFormHandler, A, E, R>): EffectRemoteForm, A, E>; /** * Creates a prerenderable remote function from a no-argument Effect handler. * * @example * ```ts * export const GetBuildInfo = Prerender(() => Effect.succeed("ready")); * ``` * * @since 2.0.0 * @param validate_or_handler - Effect value or no-argument handler to run at * prerender time. * @param maybe_options - Optional prerender inputs and dynamic fallback * configuration. * @returns A prerender function that yields an Effect when called. */ export declare function Prerender(validate_or_handler: EffectLike | RemoteHandler, maybe_options?: PrerenderOptions): EffectRemotePrerenderFunction; /** * Creates a prerenderable remote function with unchecked input. * * @example * ```ts * export const GetPost = Prerender( * "unchecked", * (slug: string) => Effect.succeed({ slug }), * { inputs: () => Effect.succeed(["intro"]) }, * ); * ``` * * @since 2.0.0 * @param validate_or_handler - `"unchecked"` sentinel that skips runtime input * validation. * @param maybe_handler - Handler that receives the caller-provided input. * @param maybe_options - Optional prerender inputs and dynamic fallback * configuration. * @returns A prerender function that yields an Effect when called with input. */ export declare function Prerender(validate_or_handler: "unchecked", maybe_handler: RemoteHandler, maybe_options?: PrerenderOptions): EffectRemotePrerenderFunction; /** * Creates a prerenderable remote function validated with an Effect Schema. * * @example * ```ts * export const GetPost = Prerender( * Schema.String, * (slug) => Effect.succeed({ slug }), * { inputs: () => Effect.succeed(["intro"]) }, * ); * ``` * * @since 2.0.0 * @param validate_or_handler - Effect Schema used to decode and validate * caller input before the handler runs. * @param maybe_handler - Handler that receives the decoded schema output. * @param maybe_options - Optional prerender inputs and dynamic fallback * configuration. * @returns A prerender function whose caller input is the schema encoded type. */ export declare function Prerender, A, E = never, R = never>(validate_or_handler: S, maybe_handler: RemoteHandler, A, E, R>, maybe_options?: PrerenderOptions>): EffectRemotePrerenderFunction, A, E>; /** * Creates a prerenderable remote function validated with a Standard Schema. * * @example * ```ts * export const GetPost = Prerender( * standard_schema, * (post) => Effect.succeed(post.slug), * { dynamic: true }, * ); * ``` * * @since 3.0.0 * @param validate_or_handler - Standard Schema used to validate caller input * before the handler runs. * @param maybe_handler - Handler that receives the decoded schema output. * @param maybe_options - Optional prerender inputs and dynamic fallback * configuration. * @returns A prerender function whose caller input is the schema input type. */ export declare function Prerender(validate_or_handler: S, maybe_handler: RemoteHandler, A, E, R>, maybe_options?: PrerenderOptions>): EffectRemotePrerenderFunction, A, E>; export {};