import "../options-B5K8QEV1.mjs"; import "../types-BCOU_CXE.mjs"; import "../types-XJPFqvc1.mjs"; import "../authz-cKSuylYa.mjs"; import { Jn as MediaUsageMaintenanceResult, Xn as PublishedRef, qn as EmDashRuntime } from "../index-HRJ8DhHY.mjs"; import "../runner-Bnq68jCZ.mjs"; import "../index-BFUET8yL.mjs"; import "../types-C2avdenh.mjs"; import "../hreflang-BktsQIF_.mjs"; import "../validate-3945fzPI.mjs"; import * as astro from "astro"; //#region src/astro/middleware.d.ts /** * Run scheduled maintenance (cron tasks, scheduled publishing, system cleanup) * outside any request. Resolves the runtime from the build-time virtual config * and the cached singleton — the same instance request handlers use. * * Wired into a platform heartbeat that is not a request: the Cloudflare Worker's * `scheduled()` handler (Cron Trigger) calls this. On Node the runtime's own * timer-based scheduler already drives the same work, so this isn't needed there. * * Returns the content promoted by the publishing sweep so the caller can purge * edge-cache tags for it. `onPublished` (optional) is awaited after each * collection's batch so the caller can invalidate edge-cache tags incrementally * rather than only after the whole sweep. */ declare function runScheduledTasks(options?: { onPublished?: (refs: PublishedRef[]) => Promise; }): Promise<{ published: PublishedRef[]; }>; declare function runScheduledMediaUsageTasks(): Promise; /** * Run a callback against the EmDash runtime outside any HTTP request — from a * Cloudflare Queue consumer, a `scheduled()` handler, or any other * platform-event handler that has no request and therefore no `locals.emdash`. * * Resolves the same cached runtime singleton request handlers use, so hooks, * plugin state, and storage all behave exactly as they do during a request. * A typical queue consumer finishes a job by calling back into a plugin route: * * ```ts * import { withEmDashRuntime } from "@premium-cms/emdash/middleware"; * * async function queue(batch: MessageBatch) { * await withEmDashRuntime(async (runtime) => { * for (const message of batch.messages) { * await runtime.handlePluginApiRoute( * "my-plugin", * "POST", * "/finishJob", * new Request("https://internal/", { * method: "POST", * body: JSON.stringify(message.body), * }), * ); * } * }); * } * ``` * * Server-only and fully trusted: the callback gets the raw runtime with no * auth or CSRF checks, same trust level as plugin cron. Never expose it to * user input without validating that input yourself. * * Throws when EmDash is not configured (no `emdash()` Astro integration). */ declare function withEmDashRuntime(run: (runtime: EmDashRuntime) => T | Promise): Promise; declare const onRequest: astro.MiddlewareHandler; //#endregion export { type EmDashRuntime, onRequest as default, onRequest, runScheduledMediaUsageTasks, runScheduledTasks, withEmDashRuntime }; //# sourceMappingURL=middleware.d.mts.map