/** * @pwngh/economy-lab * * Copyright (c) Preston Neal * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ import type { WorkerCtx } from '../contract.js'; import type { Store } from '../ports.js'; /** * Result of one renewal sweep. Each due subscription appears in exactly one list, by id. * * - `charged`: the renewal was funded and posted, and the due date advanced. * - `lapsed`: the buyer could not cover the price, so the row was marked LAPSED and nothing was charged. * - `deadLettered`: billing threw a non-retryable error, so the row was given up on and the reason recorded. * - `retrying`: billing threw a temporary error, so the row was left for the next sweep and the * code recorded. */ export type SweepSummary = { charged: ReadonlyArray; lapsed: ReadonlyArray; deadLettered: ReadonlyArray<{ id: string; reason: string; }>; retrying: ReadonlyArray<{ id: string; code: string; }>; }; /** * Bill every due subscription, one at a time. If the buyer can afford it, charge and advance the * due date one period; if not, mark lapsed and charge nothing. Each is billed in its own try/catch * so an error on one is recorded and the sweep moves on. * * `now` is epoch ms; `limit` caps how many due subscriptions this run claims. * * @see {@link https://economy-lab-docs.pages.dev/economy/reference/background-worker/ Background * worker} for how this sweep claims, bills, and advances due subscriptions. */ export declare function sweepDueSubscriptions(store: Store, ctx: WorkerCtx, input: { now: number; limit: number; }): Promise;