import type { Selectable } from 'kysely'; import type * as Webhooks from '../../internal/Webhooks.js'; import type * as Db from '../Db.js'; import type * as db_Schema from '../Schema.js'; /** Columns of the `webhook_deliveries` table, derived from `Schema.WebhookDelivery`. */ export type Table = db_Schema.WebhookDelivery; /** A stored webhook-delivery row. */ export type Record = Selectable; /** A failed delivery joined to its organization-owned subscription. */ export type OrganizationFailure = Pick; /** Maps a stored row to the domain delivery (null columns → absent fields). */ export declare function toDelivery(row: Record): Webhooks.Delivery; /** * Inserts a delivery row from its domain value. * * @param db - The database. * @param delivery - The delivery to insert. * @param expiresAt - Retention deadline (ISO); the row is invisible past it. */ export declare function insert(db: Db.Db, delivery: Webhooks.Delivery, expiresAt: string): Promise; /** * Lists a subscription's unexpired deliveries, newest first, with keyset * paging (`id < cursor` — ids embed a zero-padded timestamp, so lexical order * is chronological). * * @param db - The database. * @param subscriptionId - The owning subscription id (`wh_…`). * @param options - Paging options plus the retention timestamp. * @returns The deliveries. */ export declare function list(db: Db.Db, subscriptionId: string, options: list.Options): Promise; /** Lists recent failed webhook deliveries across an organization. */ export declare function listFailuresByOrg(db: Db.Db, orgId: string, options: listFailuresByOrg.Options): Promise; export declare namespace listFailuresByOrg { /** Bounds for the organization failure scan. */ type Options = { /** Window start (ISO 8601), inclusive. */ from: string; /** Maximum failures to return. */ limit: number; /** ISO timestamp retention is evaluated against. */ now: string; }; } /** Counts failed webhook deliveries across an organization in a time window. */ export declare function countFailuresByOrg(db: Db.Db, orgId: string, options: countFailuresByOrg.Options): Promise; export declare namespace countFailuresByOrg { /** Bounds for the organization failure count. */ type Options = { /** Window start (ISO 8601), inclusive. */ from: string; /** ISO timestamp retention is evaluated against. */ now: string; }; } export declare namespace list { /** Options for {@link list}. */ type Options = { /** Return deliveries whose id sorts before this one (older entries). */ cursor?: string | undefined; /** Maximum deliveries to return. */ limit?: number | undefined; /** ISO timestamp retention is evaluated against. */ now: string; /** Rows to skip from the head (positional pagination; exclusive with `cursor`). */ offset?: number | undefined; }; } /** * Counts a subscription's unexpired deliveries. * * @param db - The database. * @param subscriptionId - The owning subscription id (`wh_…`). * @param now - ISO timestamp retention is evaluated against. * @returns The count. */ export declare function count(db: Db.Db, subscriptionId: string, now: string): Promise; /** * Reads a single unexpired delivery scoped to its subscription. * * @param db - The database. * @param subscriptionId - The owning subscription id (`wh_…`). * @param deliveryId - The delivery id (`whd_…`). * @param now - ISO timestamp retention is evaluated against. * @returns The delivery, or `null` when absent. */ export declare function get(db: Db.Db, subscriptionId: string, deliveryId: string, now: string): Promise; /** * Deletes deliveries past their retention deadline. Called best-effort from * the poller tick. * * @param db - The database. * @param now - ISO timestamp retention is evaluated against. * @returns The number of rows deleted. */ export declare function pruneExpired(db: Db.Db, now: string): Promise; //# sourceMappingURL=webhookDeliveries.d.ts.map