import { ErrorFactory } from "./errors.mjs"; //#region src/middleware.d.ts /** * Structural surface of @convex-dev/rate-limiter's RateLimiter (checked * against 0.3.x; re-verify at install). The host mounts the component and * constructs the limiter; the kit only ever receives the instance — * injection keeps the kit dependency-free. */ export type RateLimiterLike = { limit: (ctx: never, name: string, options?: { key?: string; }) => Promise<{ ok: boolean; retryAfter?: number; }>; }; /** * The first packaged middleware: rate limiting on the Command/Query * middleware seams. Runs before guards and the handler; a rejected call * throws RATE_LIMITED (audit and handler never run). Keyed by ctx.tenant by * default — when no key fn is given and ctx.tenant is undefined, this is a * configuration error, not a silent shared bucket. * * The returned middleware is shape-compatible with both AnyCommandMiddleware * and AnyQueryMiddleware. */ export declare function rateLimit(config: { limiter: RateLimiterLike; name: string; /** Defaults to ctx.tenant. */ key?: (context: Context) => string; /** Observe a rejection before the throw (metrics, headers). */ onLimit?: (status: { ok: boolean; retryAfter?: number; }, context: Context) => void | Promise; errors?: ErrorFactory; }): (input: { context: never; next: (options?: { context?: object; }) => Promise; }) => Promise; //#endregion //# sourceMappingURL=middleware.d.mts.map