/** * @module defer-config * @category Internal * * The `when` options for the public `defer` surface (#1091, RFC 0001). A * reaction defers itself to a future time either declaratively (the * `.defer(when)` builder step) or imperatively (`throw new DeferSignal(when)` * inside a handler); both resolve `when` through here. * * The load-bearing rule is **derivability**. A deferred stream's due-time must * be recomputable by whichever worker re-claims it after the wait, so `when` * never resolves against `Date.now()`. `after` is measured from the triggering * event's `created` timestamp, and `at` is either a fixed `Date` or a pure * function of the event. Either way, re-delivering the same event yields the * same due-time, which is what makes a defer correct across restarts and * competing workers. * * Validation follows the config-schema standard (CLAUDE.md): an internal * `*OptionsSchema` const, a public inferred type, and a resolver. Slice 2 * ships `after` / `at`; recurrence (`every`) extends this in Slice 3 (#1092). * * @internal */ import type { Committed, DeferWhen, Schemas } from "../types/index.js"; /** * Resolve `when` to an absolute due-time (ms since epoch) for a given * triggering event. Validates via {@link DeferWhenSchema} (throws `ZodError` * on a bad shape), then derives the time: `after` from `event.created`, `at` * from its absolute `Date`. Never reads `Date.now()`, so the result is stable * across re-delivery. * * @internal */ export declare function resolve_defer_at(when: DeferWhen, event: Committed): number; /** * The schedule handed to the declarative `.defer` builder step: either a * literal {@link DeferWhen} (fixed cooldown/deadline) or a function of the * triggering event (read the payload to choose the schedule). * * @internal */ export type DeferSchedule = DeferWhen | ((event: TEvent) => DeferWhen); /** * Validate a literal `when` at build time (fail fast, per the config-schema * standard) — throws `ZodError` on a bad shape (both/neither of `after`/`at`, * an empty or non-positive duration). The function form of a `.defer` schedule * can only be checked when it runs, so builders pass just the literal here. * * @internal */ export declare function assert_defer_when(when: DeferWhen): void; /** * Wrap a reaction handler so it holds until its schedule is due, then runs. * On each delivery it resolves the schedule against the triggering event; if * the due-time hasn't arrived it throws {@link DeferSignal} (the drain holds * the stream, no watermark advance, no retry bump), otherwise it runs the * real handler. The wrapper keeps the original handler's `name` so reaction * registration and de-dup are unaffected, and preserves the handler's exact * type so the builder step is transparent. * * @internal */ export declare function make_deferred Promise>(handler: H, schedule: DeferSchedule[0]>): H; //# sourceMappingURL=defer-config.d.ts.map