import type { Sucrose } from './sucrose'; import type { LifeCycleStore, MaybeArray, InputSchema, LifeCycleType, HookContainer, Replace, SchemaValidator, AnyLocalHook, SSEPayload, Prettify } from './types'; import { ElysiaFile } from './universal/file'; export declare const replaceUrlPath: (url: string, pathname: string) => string; export declare const isClass: (v: Object) => boolean; export declare const mergeDeep: , B extends Record>(target: A, source: B, options?: { skipKeys?: string[]; override?: boolean; mergeArray?: boolean; seen?: WeakSet; }) => A & B; export declare const mergeCookie: (a: A, b: B) => A & B; export declare const mergeObjectArray: (a: T | T[] | undefined, b: T | T[] | undefined) => T[] | undefined; export declare const primitiveHooks: readonly ["start", "request", "parse", "transform", "resolve", "beforeHandle", "afterHandle", "mapResponse", "afterResponse", "trace", "error", "stop", "body", "headers", "params", "query", "response", "type", "detail"]; export declare const mergeResponse: (a: InputSchema["response"], b: InputSchema["response"]) => string | import("@sinclair/typebox").TSchema | import("./types").StandardSchemaV1Like | { [x: number]: string | import("./types").AnySchema; } | undefined; export declare const mergeSchemaValidator: (a?: SchemaValidator | null, b?: SchemaValidator | null) => SchemaValidator; export declare const mergeHook: (a?: Partial, b?: AnyLocalHook) => LifeCycleStore; export declare const lifeCycleToArray: (a: LifeCycleStore) => LifeCycleStore; export declare const hasHeaderShorthand: boolean; export declare const hasSetImmediate: boolean; export declare const checksum: (s: string) => number; export declare const injectChecksum: (checksum: number | undefined, x: MaybeArray | undefined) => HookContainer | HookContainer[] | undefined; export declare const mergeLifeCycle: (a: Partial, b: Partial, checksum?: number) => LifeCycleStore; export declare const asHookType: (fn: HookContainer, inject: LifeCycleType, { skipIfHasType }: { skipIfHasType?: boolean; }) => HookContainer; export declare const filterGlobalHook: (hook: AnyLocalHook) => AnyLocalHook; export declare const StatusMap: { readonly Continue: 100; readonly 'Switching Protocols': 101; readonly Processing: 102; readonly 'Early Hints': 103; readonly OK: 200; readonly Created: 201; readonly Accepted: 202; readonly 'Non-Authoritative Information': 203; readonly 'No Content': 204; readonly 'Reset Content': 205; readonly 'Partial Content': 206; readonly 'Multi-Status': 207; readonly 'Already Reported': 208; readonly 'Multiple Choices': 300; readonly 'Moved Permanently': 301; readonly Found: 302; readonly 'See Other': 303; readonly 'Not Modified': 304; readonly 'Temporary Redirect': 307; readonly 'Permanent Redirect': 308; readonly 'Bad Request': 400; readonly Unauthorized: 401; readonly 'Payment Required': 402; readonly Forbidden: 403; readonly 'Not Found': 404; readonly 'Method Not Allowed': 405; readonly 'Not Acceptable': 406; readonly 'Proxy Authentication Required': 407; readonly 'Request Timeout': 408; readonly Conflict: 409; readonly Gone: 410; readonly 'Length Required': 411; readonly 'Precondition Failed': 412; readonly 'Payload Too Large': 413; readonly 'URI Too Long': 414; readonly 'Unsupported Media Type': 415; readonly 'Range Not Satisfiable': 416; readonly 'Expectation Failed': 417; readonly "I'm a teapot": 418; readonly 'Enhance Your Calm': 420; readonly 'Misdirected Request': 421; readonly 'Unprocessable Content': 422; readonly Locked: 423; readonly 'Failed Dependency': 424; readonly 'Too Early': 425; readonly 'Upgrade Required': 426; readonly 'Precondition Required': 428; readonly 'Too Many Requests': 429; readonly 'Request Header Fields Too Large': 431; readonly 'Unavailable For Legal Reasons': 451; readonly 'Internal Server Error': 500; readonly 'Not Implemented': 501; readonly 'Bad Gateway': 502; readonly 'Service Unavailable': 503; readonly 'Gateway Timeout': 504; readonly 'HTTP Version Not Supported': 505; readonly 'Variant Also Negotiates': 506; readonly 'Insufficient Storage': 507; readonly 'Loop Detected': 508; readonly 'Not Extended': 510; readonly 'Network Authentication Required': 511; }; export declare const InvertedStatusMap: { [K in keyof StatusMap as StatusMap[K]]: K; }; export type StatusMap = typeof StatusMap; export type InvertedStatusMap = typeof InvertedStatusMap; export declare const signCookie: (val: string, secret: string | null) => Promise; export declare const unsignCookie: (input: string, secret: string | null) => Promise; export declare const insertStandaloneValidator: (hook: { standaloneValidator: InputSchema[]; }, name: Name, value: InputSchema[Name]) => void; export declare const isNumericString: (message: string | number) => boolean; export declare class PromiseGroup implements PromiseLike { onError: (error: any) => void; onFinally: () => void; root: Promise | null; promises: Promise[]; constructor(onError?: (error: any) => void, onFinally?: () => void); /** * The number of promises still being awaited. */ get size(): number; /** * Add a promise to the group. * @returns The promise that was added. */ add(promise: Promise): Promise; private drain; then(onfulfilled?: ((value: void) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; } export declare const fnToContainer: (fn: MaybeArray, /** Only add subType to non contained fn */ subType?: HookContainer["subType"]) => MaybeArray; export declare const localHookToLifeCycleStore: (a: AnyLocalHook) => LifeCycleStore; export declare const lifeCycleToFn: (a: Partial) => AnyLocalHook; export declare const cloneInference: (inference: Sucrose.Inference) => { body: boolean; cookie: boolean; headers: boolean; query: boolean; set: boolean; server: boolean; path: boolean; route: boolean; url: boolean; }; /** * * @param url URL to redirect to * @param HTTP status code to send, */ export declare const redirect: (url: string, status?: 301 | 302 | 303 | 307 | 308) => Response; export type redirect = typeof redirect; export declare const ELYSIA_FORM_DATA: unique symbol; export type ELYSIA_FORM_DATA = typeof ELYSIA_FORM_DATA; type IsTuple = T extends readonly any[] ? number extends T['length'] ? false : true : false; export type ElysiaFormData> = FormData & { [ELYSIA_FORM_DATA]: Replace extends infer A ? { [key in keyof A]: IsTuple extends true ? A[key][number] extends Blob | ElysiaFile ? File[] : A[key] : A[key]; } : T; }; export declare const ELYSIA_REQUEST_ID: unique symbol; export type ELYSIA_REQUEST_ID = typeof ELYSIA_REQUEST_ID; export declare const form: >(items: T) => ElysiaFormData; /** * Generates a random ID for schema identification. * * Uses crypto.randomUUID() when available, with a Math.random() fallback * for environments where crypto.randomUUID() throws an error * (e.g., Cloudflare Workers global scope). * * @see https://developers.cloudflare.com/workers/runtime-apis/handlers/ */ export declare const randomId: () => string; export declare const deduplicateChecksum: (array: HookContainer[]) => HookContainer[]; /** * Since it's a plugin, which means that ephemeral is demoted to volatile. * Which means there's no volatile and all previous ephemeral become volatile * We can just promote back without worry */ export declare const promoteEvent: (events?: (HookContainer | Function)[], as?: "scoped" | "global") => void; export declare const getLoosePath: (path: string) => string; export declare const isNotEmpty: (obj?: Object) => boolean; export declare const encodePath: (path: string, { dynamic }?: { dynamic?: boolean | undefined; }) => string; export declare const supportPerMethodInlineHandler: boolean; type FormatSSEPayload = T extends string ? { readonly data: T; } : Prettify>; /** * Return a Server Sent Events (SSE) payload * * @example * ```ts * import { sse } from 'elysia' * * new Elysia() * .get('/sse', function*() { * yield sse('Hello, world!') * yield sse({ * event: 'message', * data: { message: 'This is a JSON object' } * }) * } */ export declare const sse: (_payload: T) => T extends string ? { readonly data: T; } : T extends SSEPayload ? T : T extends ReadableStream ? ReadableStream> : T extends Generator ? Generator, B, C> : T extends AsyncGenerator ? AsyncGenerator, B_1, C_1> : T; export declare function getResponseLength(response: Response): Promise; export declare const emptySchema: { readonly headers: true; readonly cookie: true; readonly query: true; readonly params: true; readonly body: true; readonly response: true; }; export declare function deepClone(source: T, weak?: WeakMap): T; export {};