UNPKG

permix

Version:

Permix is a lightweight, framework-agnostic, type-safe permissions management library for JavaScript applications on the client and server sides.

943 lines (942 loc) 87.4 kB
import { A as Definition, C as Rules, D as Action, O as ActionName, _ as PermixHooks, g as Permix, l as CheckArgs, u as CheckContext } from "../index-BYcbfVQ7.mjs"; import { t as MaybePromise } from "../utils-ReVRszGL.mjs"; import { Context } from "elysia"; //#region src/elysia/permix.d.ts interface MiddlewareContext { context: Context; } interface PermixOptions<D extends Definition> { /** * Called when a `checkMiddleware` denies the request. Defaults to a 403 JSON * response of `{ error: 'Forbidden' }`. */ onForbidden?: (params: CheckContext<D> & MiddlewareContext) => MaybePromise<any>; } /** * Create a middleware factory that wires Permix into Elysia routes. * * Use `.contextKey('name')` to set a custom context key (defaults to a unique * `Symbol('permix')`). * * @example * ```ts * import { Elysia } from 'elysia' * import { createPermix } from 'permix/elysia' * * const permix = createPermix<{ * post: ['create', 'read'] * }>() * * new Elysia() * .onBeforeHandle(permix.setupMiddleware(({ context }) => ({ * post: { create: true, read: true }, * }))) * .onBeforeHandle('/posts', permix.checkMiddleware('post.read')) * .get('/posts', () => ({ ok: true })) * .listen(3000) * ``` * * @link https://permix.letstri.dev/docs/integrations/elysia */ declare function createPermix<D extends Definition>(options?: PermixOptions<D>): { setupMiddleware: (callbackOrRules: Rules<D> | ((context: MiddlewareContext) => MaybePromise<Rules<D>>)) => (context: { body: unknown; query: Record<string, string>; params: Record<string, string>; headers: Record<string, string | undefined>; cookie: Record<string, import("elysia").Cookie<unknown>>; server: import("elysia/universal/server").Server | null; redirect: import("elysia").redirect; set: { headers: import("elysia").HTTPHeaders; status?: number | keyof import("elysia").StatusMap; redirect?: string; cookie?: Record<string, { domain?: string | undefined | undefined; expires?: Date | undefined; httpOnly?: boolean | undefined | undefined; maxAge?: number | undefined | undefined; path?: string | undefined | undefined; priority?: "low" | "medium" | "high" | undefined | undefined; partitioned?: boolean | undefined | undefined; sameSite?: true | false | "lax" | "strict" | "none" | undefined | undefined; secure?: boolean | undefined | undefined; secrets?: string | null | (string | null)[] | undefined; value?: unknown; }>; }; path: string; route: string; request: Request; store: {}; status: <const Code extends number | keyof import("elysia").StatusMap, const T = (Code extends 200 | 403 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 400 | 401 | 402 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? { readonly 100: "Continue"; readonly 101: "Switching Protocols"; readonly 102: "Processing"; readonly 103: "Early Hints"; readonly 200: "OK"; readonly 201: "Created"; readonly 202: "Accepted"; readonly 203: "Non-Authoritative Information"; readonly 204: "No Content"; readonly 205: "Reset Content"; readonly 206: "Partial Content"; readonly 207: "Multi-Status"; readonly 208: "Already Reported"; readonly 300: "Multiple Choices"; readonly 301: "Moved Permanently"; readonly 302: "Found"; readonly 303: "See Other"; readonly 304: "Not Modified"; readonly 307: "Temporary Redirect"; readonly 308: "Permanent Redirect"; readonly 400: "Bad Request"; readonly 401: "Unauthorized"; readonly 402: "Payment Required"; readonly 403: "Forbidden"; readonly 404: "Not Found"; readonly 405: "Method Not Allowed"; readonly 406: "Not Acceptable"; readonly 407: "Proxy Authentication Required"; readonly 408: "Request Timeout"; readonly 409: "Conflict"; readonly 410: "Gone"; readonly 411: "Length Required"; readonly 412: "Precondition Failed"; readonly 413: "Payload Too Large"; readonly 414: "URI Too Long"; readonly 415: "Unsupported Media Type"; readonly 416: "Range Not Satisfiable"; readonly 417: "Expectation Failed"; readonly 418: "I'm a teapot"; readonly 420: "Enhance Your Calm"; readonly 421: "Misdirected Request"; readonly 422: "Unprocessable Content"; readonly 423: "Locked"; readonly 424: "Failed Dependency"; readonly 425: "Too Early"; readonly 426: "Upgrade Required"; readonly 428: "Precondition Required"; readonly 429: "Too Many Requests"; readonly 431: "Request Header Fields Too Large"; readonly 451: "Unavailable For Legal Reasons"; readonly 500: "Internal Server Error"; readonly 501: "Not Implemented"; readonly 502: "Bad Gateway"; readonly 503: "Service Unavailable"; readonly 504: "Gateway Timeout"; readonly 505: "HTTP Version Not Supported"; readonly 506: "Variant Also Negotiates"; readonly 507: "Insufficient Storage"; readonly 508: "Loop Detected"; readonly 510: "Not Extended"; readonly 511: "Network Authentication Required"; }[Code] : Code)>(code: Code, response?: T) => import("elysia").ElysiaCustomStatusResponse<Code, T, Code extends "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required" ? { 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; }[Code] : Code>; }) => Promise<void>; checkMiddleware: (...args: CheckArgs<D>) => (context: { body: unknown; query: Record<string, string>; params: Record<string, string>; headers: Record<string, string | undefined>; cookie: Record<string, import("elysia").Cookie<unknown>>; server: import("elysia/universal/server").Server | null; redirect: import("elysia").redirect; set: { headers: import("elysia").HTTPHeaders; status?: number | keyof import("elysia").StatusMap; redirect?: string; cookie?: Record<string, { domain?: string | undefined | undefined; expires?: Date | undefined; httpOnly?: boolean | undefined | undefined; maxAge?: number | undefined | undefined; path?: string | undefined | undefined; priority?: "low" | "medium" | "high" | undefined | undefined; partitioned?: boolean | undefined | undefined; sameSite?: true | false | "lax" | "strict" | "none" | undefined | undefined; secure?: boolean | undefined | undefined; secrets?: string | null | (string | null)[] | undefined; value?: unknown; }>; }; path: string; route: string; request: Request; store: {}; status: <const Code extends number | keyof import("elysia").StatusMap, const T = (Code extends 200 | 403 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 400 | 401 | 402 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? { readonly 100: "Continue"; readonly 101: "Switching Protocols"; readonly 102: "Processing"; readonly 103: "Early Hints"; readonly 200: "OK"; readonly 201: "Created"; readonly 202: "Accepted"; readonly 203: "Non-Authoritative Information"; readonly 204: "No Content"; readonly 205: "Reset Content"; readonly 206: "Partial Content"; readonly 207: "Multi-Status"; readonly 208: "Already Reported"; readonly 300: "Multiple Choices"; readonly 301: "Moved Permanently"; readonly 302: "Found"; readonly 303: "See Other"; readonly 304: "Not Modified"; readonly 307: "Temporary Redirect"; readonly 308: "Permanent Redirect"; readonly 400: "Bad Request"; readonly 401: "Unauthorized"; readonly 402: "Payment Required"; readonly 403: "Forbidden"; readonly 404: "Not Found"; readonly 405: "Method Not Allowed"; readonly 406: "Not Acceptable"; readonly 407: "Proxy Authentication Required"; readonly 408: "Request Timeout"; readonly 409: "Conflict"; readonly 410: "Gone"; readonly 411: "Length Required"; readonly 412: "Precondition Failed"; readonly 413: "Payload Too Large"; readonly 414: "URI Too Long"; readonly 415: "Unsupported Media Type"; readonly 416: "Range Not Satisfiable"; readonly 417: "Expectation Failed"; readonly 418: "I'm a teapot"; readonly 420: "Enhance Your Calm"; readonly 421: "Misdirected Request"; readonly 422: "Unprocessable Content"; readonly 423: "Locked"; readonly 424: "Failed Dependency"; readonly 425: "Too Early"; readonly 426: "Upgrade Required"; readonly 428: "Precondition Required"; readonly 429: "Too Many Requests"; readonly 431: "Request Header Fields Too Large"; readonly 451: "Unavailable For Legal Reasons"; readonly 500: "Internal Server Error"; readonly 501: "Not Implemented"; readonly 502: "Bad Gateway"; readonly 503: "Service Unavailable"; readonly 504: "Gateway Timeout"; readonly 505: "HTTP Version Not Supported"; readonly 506: "Variant Also Negotiates"; readonly 507: "Insufficient Storage"; readonly 508: "Loop Detected"; readonly 510: "Not Extended"; readonly 511: "Network Authentication Required"; }[Code] : Code)>(code: Code, response?: T) => import("elysia").ElysiaCustomStatusResponse<Code, T, Code extends "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required" ? { 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; }[Code] : Code>; }) => MaybePromise<any>; template: <T = void>(rules: Rules<D> | ((param: T) => Rules<D>)) => (param: T) => Rules<D>; get: (context: { body: unknown; query: Record<string, string>; params: Record<string, string>; headers: Record<string, string | undefined>; cookie: Record<string, import("elysia").Cookie<unknown>>; server: import("elysia/universal/server").Server | null; redirect: import("elysia").redirect; set: { headers: import("elysia").HTTPHeaders; status?: number | keyof import("elysia").StatusMap; redirect?: string; cookie?: Record<string, { domain?: string | undefined | undefined; expires?: Date | undefined; httpOnly?: boolean | undefined | undefined; maxAge?: number | undefined | undefined; path?: string | undefined | undefined; priority?: "low" | "medium" | "high" | undefined | undefined; partitioned?: boolean | undefined | undefined; sameSite?: true | false | "lax" | "strict" | "none" | undefined | undefined; secure?: boolean | undefined | undefined; secrets?: string | null | (string | null)[] | undefined; value?: unknown; }>; }; path: string; route: string; request: Request; store: {}; status: <const Code extends number | keyof import("elysia").StatusMap, const T = (Code extends 200 | 403 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 400 | 401 | 402 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? { readonly 100: "Continue"; readonly 101: "Switching Protocols"; readonly 102: "Processing"; readonly 103: "Early Hints"; readonly 200: "OK"; readonly 201: "Created"; readonly 202: "Accepted"; readonly 203: "Non-Authoritative Information"; readonly 204: "No Content"; readonly 205: "Reset Content"; readonly 206: "Partial Content"; readonly 207: "Multi-Status"; readonly 208: "Already Reported"; readonly 300: "Multiple Choices"; readonly 301: "Moved Permanently"; readonly 302: "Found"; readonly 303: "See Other"; readonly 304: "Not Modified"; readonly 307: "Temporary Redirect"; readonly 308: "Permanent Redirect"; readonly 400: "Bad Request"; readonly 401: "Unauthorized"; readonly 402: "Payment Required"; readonly 403: "Forbidden"; readonly 404: "Not Found"; readonly 405: "Method Not Allowed"; readonly 406: "Not Acceptable"; readonly 407: "Proxy Authentication Required"; readonly 408: "Request Timeout"; readonly 409: "Conflict"; readonly 410: "Gone"; readonly 411: "Length Required"; readonly 412: "Precondition Failed"; readonly 413: "Payload Too Large"; readonly 414: "URI Too Long"; readonly 415: "Unsupported Media Type"; readonly 416: "Range Not Satisfiable"; readonly 417: "Expectation Failed"; readonly 418: "I'm a teapot"; readonly 420: "Enhance Your Calm"; readonly 421: "Misdirected Request"; readonly 422: "Unprocessable Content"; readonly 423: "Locked"; readonly 424: "Failed Dependency"; readonly 425: "Too Early"; readonly 426: "Upgrade Required"; readonly 428: "Precondition Required"; readonly 429: "Too Many Requests"; readonly 431: "Request Header Fields Too Large"; readonly 451: "Unavailable For Legal Reasons"; readonly 500: "Internal Server Error"; readonly 501: "Not Implemented"; readonly 502: "Bad Gateway"; readonly 503: "Service Unavailable"; readonly 504: "Gateway Timeout"; readonly 505: "HTTP Version Not Supported"; readonly 506: "Variant Also Negotiates"; readonly 507: "Insufficient Storage"; readonly 508: "Loop Detected"; readonly 510: "Not Extended"; readonly 511: "Network Authentication Required"; }[Code] : Code)>(code: Code, response?: T) => import("elysia").ElysiaCustomStatusResponse<Code, T, Code extends "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required" ? { 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; }[Code] : Code>; }) => Permix<D> | null; getOrThrow: (context: { body: unknown; query: Record<string, string>; params: Record<string, string>; headers: Record<string, string | undefined>; cookie: Record<string, import("elysia").Cookie<unknown>>; server: import("elysia/universal/server").Server | null; redirect: import("elysia").redirect; set: { headers: import("elysia").HTTPHeaders; status?: number | keyof import("elysia").StatusMap; redirect?: string; cookie?: Record<string, { domain?: string | undefined | undefined; expires?: Date | undefined; httpOnly?: boolean | undefined | undefined; maxAge?: number | undefined | undefined; path?: string | undefined | undefined; priority?: "low" | "medium" | "high" | undefined | undefined; partitioned?: boolean | undefined | undefined; sameSite?: true | false | "lax" | "strict" | "none" | undefined | undefined; secure?: boolean | undefined | undefined; secrets?: string | null | (string | null)[] | undefined; value?: unknown; }>; }; path: string; route: string; request: Request; store: {}; status: <const Code extends number | keyof import("elysia").StatusMap, const T = (Code extends 200 | 403 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 400 | 401 | 402 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? { readonly 100: "Continue"; readonly 101: "Switching Protocols"; readonly 102: "Processing"; readonly 103: "Early Hints"; readonly 200: "OK"; readonly 201: "Created"; readonly 202: "Accepted"; readonly 203: "Non-Authoritative Information"; readonly 204: "No Content"; readonly 205: "Reset Content"; readonly 206: "Partial Content"; readonly 207: "Multi-Status"; readonly 208: "Already Reported"; readonly 300: "Multiple Choices"; readonly 301: "Moved Permanently"; readonly 302: "Found"; readonly 303: "See Other"; readonly 304: "Not Modified"; readonly 307: "Temporary Redirect"; readonly 308: "Permanent Redirect"; readonly 400: "Bad Request"; readonly 401: "Unauthorized"; readonly 402: "Payment Required"; readonly 403: "Forbidden"; readonly 404: "Not Found"; readonly 405: "Method Not Allowed"; readonly 406: "Not Acceptable"; readonly 407: "Proxy Authentication Required"; readonly 408: "Request Timeout"; readonly 409: "Conflict"; readonly 410: "Gone"; readonly 411: "Length Required"; readonly 412: "Precondition Failed"; readonly 413: "Payload Too Large"; readonly 414: "URI Too Long"; readonly 415: "Unsupported Media Type"; readonly 416: "Range Not Satisfiable"; readonly 417: "Expectation Failed"; readonly 418: "I'm a teapot"; readonly 420: "Enhance Your Calm"; readonly 421: "Misdirected Request"; readonly 422: "Unprocessable Content"; readonly 423: "Locked"; readonly 424: "Failed Dependency"; readonly 425: "Too Early"; readonly 426: "Upgrade Required"; readonly 428: "Precondition Required"; readonly 429: "Too Many Requests"; readonly 431: "Request Header Fields Too Large"; readonly 451: "Unavailable For Legal Reasons"; readonly 500: "Internal Server Error"; readonly 501: "Not Implemented"; readonly 502: "Bad Gateway"; readonly 503: "Service Unavailable"; readonly 504: "Gateway Timeout"; readonly 505: "HTTP Version Not Supported"; readonly 506: "Variant Also Negotiates"; readonly 507: "Insufficient Storage"; readonly 508: "Loop Detected"; readonly 510: "Not Extended"; readonly 511: "Network Authentication Required"; }[Code] : Code)>(code: Code, response?: T) => import("elysia").ElysiaCustomStatusResponse<Code, T, Code extends "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required" ? { 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; }[Code] : Code>; }) => Permix<D>; getRules: (context: { body: unknown; query: Record<string, string>; params: Record<string, string>; headers: Record<string, string | undefined>; cookie: Record<string, import("elysia").Cookie<unknown>>; server: import("elysia/universal/server").Server | null; redirect: import("elysia").redirect; set: { headers: import("elysia").HTTPHeaders; status?: number | keyof import("elysia").StatusMap; redirect?: string; cookie?: Record<string, { domain?: string | undefined | undefined; expires?: Date | undefined; httpOnly?: boolean | undefined | undefined; maxAge?: number | undefined | undefined; path?: string | undefined | undefined; priority?: "low" | "medium" | "high" | undefined | undefined; partitioned?: boolean | undefined | undefined; sameSite?: true | false | "lax" | "strict" | "none" | undefined | undefined; secure?: boolean | undefined | undefined; secrets?: string | null | (string | null)[] | undefined; value?: unknown; }>; }; path: string; route: string; request: Request; store: {}; status: <const Code extends number | keyof import("elysia").StatusMap, const T = (Code extends 200 | 403 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 400 | 401 | 402 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? { readonly 100: "Continue"; readonly 101: "Switching Protocols"; readonly 102: "Processing"; readonly 103: "Early Hints"; readonly 200: "OK"; readonly 201: "Created"; readonly 202: "Accepted"; readonly 203: "Non-Authoritative Information"; readonly 204: "No Content"; readonly 205: "Reset Content"; readonly 206: "Partial Content"; readonly 207: "Multi-Status"; readonly 208: "Already Reported"; readonly 300: "Multiple Choices"; readonly 301: "Moved Permanently"; readonly 302: "Found"; readonly 303: "See Other"; readonly 304: "Not Modified"; readonly 307: "Temporary Redirect"; readonly 308: "Permanent Redirect"; readonly 400: "Bad Request"; readonly 401: "Unauthorized"; readonly 402: "Payment Required"; readonly 403: "Forbidden"; readonly 404: "Not Found"; readonly 405: "Method Not Allowed"; readonly 406: "Not Acceptable"; readonly 407: "Proxy Authentication Required"; readonly 408: "Request Timeout"; readonly 409: "Conflict"; readonly 410: "Gone"; readonly 411: "Length Required"; readonly 412: "Precondition Failed"; readonly 413: "Payload Too Large"; readonly 414: "URI Too Long"; readonly 415: "Unsupported Media Type"; readonly 416: "Range Not Satisfiable"; readonly 417: "Expectation Failed"; readonly 418: "I'm a teapot"; readonly 420: "Enhance Your Calm"; readonly 421: "Misdirected Request"; readonly 422: "Unprocessable Content"; readonly 423: "Locked"; readonly 424: "Failed Dependency"; readonly 425: "Too Early"; readonly 426: "Upgrade Required"; readonly 428: "Precondition Required"; readonly 429: "Too Many Requests"; readonly 431: "Request Header Fields Too Large"; readonly 451: "Unavailable For Legal Reasons"; readonly 500: "Internal Server Error"; readonly 501: "Not Implemented"; readonly 502: "Bad Gateway"; readonly 503: "Service Unavailable"; readonly 504: "Gateway Timeout"; readonly 505: "HTTP Version Not Supported"; readonly 506: "Variant Also Negotiates"; readonly 507: "Insufficient Storage"; readonly 508: "Loop Detected"; readonly 510: "Not Extended"; readonly 511: "Network Authentication Required"; }[Code] : Code)>(code: Code, response?: T) => import("elysia").ElysiaCustomStatusResponse<Code, T, Code extends "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required" ? { 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; }[Code] : Code>; }) => Rules<D> | null; hook: <K extends keyof PermixHooks<D>>(name: K, fn: PermixHooks<D>[K]) => () => void; hookOnce: <K extends keyof PermixHooks<D>>(name: K, fn: PermixHooks<D>[K]) => void; readonly key: string | symbol; $inferDefinition: D; $inferPath: D extends readonly Action[] ? `${ActionName<D[number]>}` : { [K in keyof D & string]: D[K] extends Definition ? D[K] extends infer T ? T extends D[K] ? T extends readonly Action[] ? `${K}.${ActionName<T[number]>}` : { [K_2 in keyof T & string]: T[K_2] extends Definition ? T[K_2] extends infer T_1 ? T_1 extends T[K_2] ? T_1 extends readonly Action[] ? `${K}.${K_2}.${ActionName<T_1[number]>}` : { [K_3 in keyof T_1 & string]: T_1[K_3] extends Definition ? T_1[K_3] extends infer T_2 ? T_2 extends T_1[K_3] ? T_2 extends readonly Action[] ? `${K}.${K_2}.${K_3}.${ActionName<T_2[number]>}` : { [K_4 in keyof T_2 & string]: T_2[K_4] extends Definition ? T_2[K_4] extends infer T_3 ? T_3 extends T_2[K_4] ? T_3 extends readonly Action[] ? `${K}.${K_2}.${K_3}.${K_4}.${ActionName<T_3[number]>}` : { [K_5 in keyof T_3 & string]: T_3[K_5] extends Definition ? T_3[K_5] extends infer T_4 ? T_4 extends T_3[K_5] ? T_4 extends readonly Action[] ? `${K}.${K_2}.${K_3}.${K_4}.${K_5}.${ActionName<T_4[number]>}` : { [K_6 in keyof T_4 & string]: T_4[K_6] extends Definition ? T_4[K_6] extends infer T_5 ? T_5 extends T_4[K_6] ? T_5 extends readonly Action[] ? `${K}.${K_2}.${K_3}.${K_4}.${K_5}.${K_6}.${ActionName<T_5[number]>}` : { [K_7 in keyof T_5 & string]: T_5[K_7] extends Definition ? T_5[K_7] extends infer T_6 ? T_6 extends T_5[K_7] ? T_6 extends readonly Action[] ? `${K}.${K_2}.${K_3}.${K_4}.${K_5}.${K_6}.${K_7}.${ActionName<T_6[number]>}` : { [K_8 in keyof T_6 & string]: T_6[K_8] extends Definition ? T_6[K_8] extends infer T_7 ? T_7 extends T_6[K_8] ? T_7 extends readonly Action[] ? `${K}.${K_2}.${K_3}.${K_4}.${K_5}.${K_6}.${K_7}.${K_8}.${ActionName<T_7[number]>}` : { [K_9 in keyof T_7 & string]: T_7[K_9] extends Definition ? T_7[K_9] extends infer T_8 ? T_8 extends T_7[K_9] ? T_8 extends readonly Action[] ? `${K}.${K_2}.${K_3}.${K_4}.${K_5}.${K_6}.${K_7}.${K_8}.${K_9}.${ActionName<T_8[number]>}` : { [K_10 in keyof T_8 & string]: T_8[K_10] extends Definition ? never : never }[keyof T_8 & string] : never : never : never }[keyof T_7 & string] : never : never : never }[keyof T_6 & string] : never : never : never }[keyof T_5 & string] : never : never : never }[keyof T_4 & string] : never : never : never }[keyof T_3 & string] : never : never : never }[keyof T_2 & string] : never : never : never }[keyof T_1 & string] : never : never : never }[keyof T & string] : never : never : never }[keyof D & string]; } & { contextKey(newKey: string | symbol): { setupMiddleware: (callbackOrRules: Rules<D> | ((context: MiddlewareContext) => MaybePromise<Rules<D>>)) => (context: { body: unknown; query: Record<string, string>; params: Record<string, string>; headers: Record<string, string | undefined>; cookie: Record<string, import("elysia").Cookie<unknown>>; server: import("elysia/universal/server").Server | null; redirect: import("elysia").redirect; set: { headers: import("elysia").HTTPHeaders; status?: number | keyof import("elysia").StatusMap; redirect?: string; cookie?: Record<string, { domain?: string | undefined | undefined; expires?: Date | undefined; httpOnly?: boolean | undefined | undefined; maxAge?: number | undefined | undefined; path?: string | undefined | undefined; priority?: "low" | "medium" | "high" | undefined | undefined; partitioned?: boolean | undefined | undefined; sameSite?: true | false | "lax" | "strict" | "none" | undefined | undefined; secure?: boolean | undefined | undefined; secrets?: string | null | (string | null)[] | undefined; value?: unknown; }>; }; path: string; route: string; request: Request; store: {}; status: <const Code extends number | keyof import("elysia").StatusMap, const T = (Code extends 200 | 403 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 400 | 401 | 402 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? { readonly 100: "Continue"; readonly 101: "Switching Protocols"; readonly 102: "Processing"; readonly 103: "Early Hints"; readonly 200: "OK"; readonly 201: "Created"; readonly 202: "Accepted"; readonly 203: "Non-Authoritative Information"; readonly 204: "No Content"; readonly 205: "Reset Content"; readonly 206: "Partial Content"; readonly 207: "Multi-Status"; readonly 208: "Already Reported"; readonly 300: "Multiple Choices"; readonly 301: "Moved Permanently"; readonly 302: "Found"; readonly 303: "See Other"; readonly 304: "Not Modified"; readonly 307: "Temporary Redirect"; readonly 308: "Permanent Redirect"; readonly 400: "Bad Request"; readonly 401: "Unauthorized"; readonly 402: "Payment Required"; readonly 403: "Forbidden"; readonly 404: "Not Found"; readonly 405: "Method Not Allowed"; readonly 406: "Not Acceptable"; readonly 407: "Proxy Authentication Required"; readonly 408: "Request Timeout"; readonly 409: "Conflict"; readonly 410: "Gone"; readonly 411: "Length Required"; readonly 412: "Precondition Failed"; readonly 413: "Payload Too Large"; readonly 414: "URI Too Long"; readonly 415: "Unsupported Media Type"; readonly 416: "Range Not Satisfiable"; readonly 417: "Expectation Failed"; readonly 418: "I'm a teapot"; readonly 420: "Enhance Your Calm"; readonly 421: "Misdirected Request"; readonly 422: "Unprocessable Content"; readonly 423: "Locked"; readonly 424: "Failed Dependency"; readonly 425: "Too Early"; readonly 426: "Upgrade Required"; readonly 428: "Precondition Required"; readonly 429: "Too Many Requests"; readonly 431: "Request Header Fields Too Large"; readonly 451: "Unavailable For Legal Reasons"; readonly 500: "Internal Server Error"; readonly 501: "Not Implemented"; readonly 502: "Bad Gateway"; readonly 503: "Service Unavailable"; readonly 504: "Gateway Timeout"; readonly 505: "HTTP Version Not Supported"; readonly 506: "Variant Also Negotiates"; readonly 507: "Insufficient Storage"; readonly 508: "Loop Detected"; readonly 510: "Not Extended"; readonly 511: "Network Authentication Required"; }[Code] : Code)>(code: Code, response?: T) => import("elysia").ElysiaCustomStatusResponse<Code, T, Code extends "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required" ? { 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; readonl