/** Remote error wire protocol shared by client and server adapters. */ /** Shared marker used to recognize remote errors across package copies. */ export declare const effect_remote_error_marker = "__svelte_effect_remote__"; /** Decodes the shared remote-error marker without relying on class identity. */ export declare const remote_error_decoder: unique symbol; /** * A single field-level or form-level validation issue reported by a * {@link Form} handler. * * @example * ```ts * const issue: FormIssue = { * message: "Use an email address.", * path: ["email"], * }; * ``` * * @since 2.0.0 */ export interface FormIssue { /** Human-readable validation message. */ message: string; /** Path to the offending field as an array of string-or-number keys. */ path: (string | number)[]; } /** * Error subtype thrown by {@link Form} handlers to signal validation * failures. The `issues` array is forwarded to SvelteKit's `invalid()` * helper on the server and surfaced as `FormError` on the client. * * @example * ```ts * const error: FormError = { * _tag: "FormError", * issues: [{ message: "Required.", path: ["email"] }], * }; * ``` * * @since 2.0.0 */ export interface FormError { readonly _tag: "FormError"; readonly issues: readonly FormIssue[]; /** Phantom type slot for the schema this error was derived from. */ readonly _schema?: SchemaType; } export declare function create_form_error(issues: readonly FormIssue[]): FormError; /** * Type guard that narrows an unknown value to a {@link FormError}. * * @example * ```ts * if (is_form_error(error)) { * console.log(error.issues); * } * ``` * * @since 2.0.0 * @param value - The value to check. * @returns `true` when the value is a FormError. */ export declare function is_form_error(value: unknown): value is FormError; /** * Union of all wire-level error shapes that a remote function can * surface on its error channel. * * @example * ```ts * const result: Effect.Effect> = myQuery(); * ``` * * @since 2.0.0 */ export type RemoteFailure = ErrorType | RemoteValidationError | RemoteHttpError | RemoteTransportError; /** * Validation errors that originate from a server-side {@link Form} * handler calling `invalid()` (SvelteKit's `fail`). * * @example * ```ts * const error: RemoteValidationError = { * _tag: "RemoteValidationError", * status: 400, * issues: [{ message: "Required.", path: ["email"] }], * }; * ``` * * @since 2.0.0 */ export interface RemoteValidationError { readonly _tag: "RemoteValidationError"; readonly issues?: readonly FormIssue[]; readonly body?: unknown; readonly status: number; } /** * HTTP-level errors with a status code and optional response body. Raised * when the server explicitly calls SvelteKit's `error(status, body)`. * * @example * ```ts * const error: RemoteHttpError = { * _tag: "RemoteHttpError", * status: 404, * body: { message: "Not found" }, * }; * ``` * * @since 2.0.0 */ export interface RemoteHttpError { readonly _tag: "RemoteHttpError"; readonly status: number; readonly body?: unknown; readonly cause?: unknown; } /** * Transport-level errors raised by the client adapter when the network * request fails or the response cannot be decoded. * * @example * ```ts * const error: RemoteTransportError = { * _tag: "RemoteTransportError", * cause: new Error("Network unavailable"), * }; * ``` * * @since 2.0.0 */ export interface RemoteTransportError { readonly _tag: "RemoteTransportError"; readonly cause?: unknown; readonly body?: unknown; } export interface SerializedRemoteFailureEnvelope { readonly __svelte_effect_remote__: true; readonly encoded: string; } export declare function create_remote_validation_error(issues: readonly FormIssue[], body?: unknown, status?: number): RemoteValidationError; export declare function create_remote_http_error(status: number, body?: unknown, cause?: unknown): RemoteHttpError; export declare function create_remote_transport_error(cause: unknown, body?: unknown): RemoteTransportError; export declare function create_serialized_remote_failure_envelope(encoded: string): SerializedRemoteFailureEnvelope; export declare function is_serialized_remote_failure_envelope(value: unknown): value is SerializedRemoteFailureEnvelope; /** * Checks whether a value is a {@link RemoteValidationError}. * * @example * ```ts * if (is_remote_validation_error(error)) { * console.log(error.issues); * } * ``` * * @since 2.0.0 * @param value - The value to check. * @returns `true` when the value is a remote validation error. */ export declare function is_remote_validation_error(value: unknown): value is RemoteValidationError; /** * Checks whether a value is a {@link RemoteHttpError}. * * @example * ```ts * if (is_remote_http_error(error)) { * console.log(error.status); * } * ``` * * @since 2.0.0 * @param value - The value to check. * @returns `true` when the value is a remote HTTP error. */ export declare function is_remote_http_error(value: unknown): value is RemoteHttpError; /** * Checks whether a value is a {@link RemoteTransportError}. * * @example * ```ts * if (is_remote_transport_error(error)) { * console.error(error.cause); * } * ``` * * @since 2.0.0 * @param value - The value to check. * @returns `true` when the value is a remote transport error. */ export declare function is_remote_transport_error(value: unknown): value is RemoteTransportError;