/** * @param {string} id - Run id. * @returns {void} */ export function registerActiveDeploymentRun(id: string): void; /** * @param {string} id - Run id. * @returns {void} */ export function unregisterActiveDeploymentRun(id: string): void; /** * @param {number} staleRunTimeoutMs - Lease duration. * @returns {number} Heartbeat interval strictly below the lease. */ export function heartbeatIntervalMs(staleRunTimeoutMs: number): number; /** * @param {{activeRunIds: Set, nowMs: number, run: {heartbeatAtMs: number|null, id: string, launchProtectedUntilMs?: number|null, requestedAtMs: number, status?: string}, staleRunTimeoutMs: number}} args - Lease data. * @returns {boolean} Whether ownership expired. */ export function isRunLeaseExpired({ activeRunIds: localIds, nowMs, run, staleRunTimeoutMs }: { activeRunIds: Set; nowMs: number; run: { heartbeatAtMs: number | null; id: string; launchProtectedUntilMs?: number | null; requestedAtMs: number; status?: string; }; staleRunTimeoutMs: number; }): boolean; /** * @param {{id: string, mountIdentifier: string, ownerToken: string}} args - Fence identifiers. * @returns {Record} Update conditions. */ export function terminalTransitionConditions({ id, mountIdentifier, ownerToken }: { id: string; mountIdentifier: string; ownerToken: string; }): Record; /** * Includes the observed heartbeat so a concurrent renewal defeats stale reconciliation. * * @param {{mountIdentifier: string, run: Pick}} args - Fence data. * @returns {Record} Update conditions. */ export function reconciliationConditions({ mountIdentifier, run }: { mountIdentifier: string; run: Pick; }): Record; /** Rampway-owned durable deployment state stored through Velocious's database abstraction. */ export default class DeploymentRunStore { /** * @param {object} args - Store options. * @param {any} args.configuration - Velocious configuration. * @param {string} [args.databaseIdentifier] - Database identifier. * @param {string} args.mountIdentifier - Authenticated mount scope. * @param {number} args.staleRunTimeoutMs - Lease duration. */ constructor({ configuration, databaseIdentifier, mountIdentifier, staleRunTimeoutMs }: { configuration: any; databaseIdentifier?: string | undefined; mountIdentifier: string; staleRunTimeoutMs: number; }); configuration: any; databaseIdentifier: string; mountIdentifier: string; staleRunTimeoutMs: number; /** @type {Promise|null} */ readyPromise: Promise | null; /** @returns {Promise} */ ensureReady(): Promise; /** * Adds the handoff lease to databases created by the previous API schema. * * @param {any} db - Open Velocious database connection. * @returns {Promise} */ _ensureLaunchProtectionColumn(db: any): Promise; /** @param {any} db @returns {Promise} */ _ensureExpectedActiveRevisionColumn(db: any): Promise; /** * @param {string} id - Run id. * @returns {Promise} Run. */ findRunById(id: string): Promise; /** * @param {string} key - Idempotency key. * @returns {Promise} Run. */ findRunByKey(key: string): Promise; /** * Serializes admission by target then by mount-global idempotency key. * * @param {{idempotencyKey: string, project: string, revision: string, expectedActiveRevision?: string|null, stage: string}} args - Run request. * @returns {Promise<{outcome: string, run: DeploymentRunRow|null}>} Admission result. */ createRunIfPossible({ idempotencyKey, project, revision, expectedActiveRevision, stage }: { idempotencyKey: string; project: string; revision: string; expectedActiveRevision?: string | null; stage: string; }): Promise<{ outcome: string; run: DeploymentRunRow | null; }>; /** * @param {{id: string, startedAtMs: number}} args - Cross-process worker claim. * @returns {Promise} Claimed run. */ claimPendingRun({ id, startedAtMs }: { id: string; startedAtMs: number; }): Promise; /** @param {{id: string, startedAtMs: number}} args - Transition. @returns {Promise} */ markRunning({ id, startedAtMs }: { id: string; startedAtMs: number; }): Promise; /** @param {{id: string, ownerToken: string, finishedAtMs: number, error: any}} args - Launch failure. @returns {Promise} */ markPendingFailed({ id, ownerToken, finishedAtMs, error }: { id: string; ownerToken: string; finishedAtMs: number; error: any; }): Promise; /** @param {{id: string, finishedAtMs: number, error: any}} args - Pre-claim worker failure. @returns {Promise} */ failPendingRun({ id, finishedAtMs, error }: { id: string; finishedAtMs: number; error: any; }): Promise; /** @param {{id: string, heartbeatAtMs: number}} args - Heartbeat. @returns {Promise} */ heartbeat({ id, heartbeatAtMs }: { id: string; heartbeatAtMs: number; }): Promise; /** @param {{id: string, ownerToken: string, finishedAtMs: number, result: any}} args - Transition. @returns {Promise} */ markSucceeded({ id, ownerToken, finishedAtMs, result }: { id: string; ownerToken: string; finishedAtMs: number; result: any; }): Promise; /** @param {{id: string, ownerToken: string, finishedAtMs: number, error: any}} args - Transition. @returns {Promise} */ markFailed({ id, ownerToken, finishedAtMs, error }: { id: string; ownerToken: string; finishedAtMs: number; error: any; }): Promise; /** @param {{id: string, ownerToken: string, finishedAtMs: number, error: any}} args - Transition. @returns {Promise} */ markReconciliationRequired({ id, ownerToken, finishedAtMs, error }: { id: string; ownerToken: string; finishedAtMs: number; error: any; }): Promise; /** @param {{event: string, payload: any, runId: string|null}} args - Audit event. @returns {Promise} */ addAuditEvent({ event, payload, runId }: { event: string; payload: any; runId: string | null; }): Promise; /** * @param {{runId: string}} args - Query. * @returns {Promise>>} Events. */ listAuditEvents({ runId }: { runId: string; }): Promise>>; /** * @param {any} db - Open Velocious database connection. * @param {DeploymentRunRow} run - Observed stale run. * @returns {Promise} Whether this reconciler won. */ _reconcileExpiredRun(db: any, run: DeploymentRunRow): Promise; /** * Reconciles an expired pending/running owner before returning durable state. * * @param {any} db - Open Velocious database connection. * @param {DeploymentRunRow|null} run - Observed run. * @returns {Promise} Current durable run. */ _reconcileExpiredRunIfNeeded(db: any, run: DeploymentRunRow | null): Promise; /** @param {{data: Record, id: string, ownerToken: string}} args - Transition. @returns {Promise} */ _transition({ data, id, ownerToken }: { data: Record; id: string; ownerToken: string; }): Promise; /** * @param {string} kind - Lock kind. * @param {string} value - Scoped value. * @returns {string} Lock name. */ _lockName(kind: string, value: string): string; /** * @param {any} db - Connection. * @param {string} id - Run id. * @returns {Promise} Run. */ _findRunById(db: any, id: string): Promise; /** * @param {any} db - Connection. * @param {string} key - Idempotency key. * @returns {Promise} Run. */ _findRunByKey(db: any, key: string): Promise; /** * @param {any} db - Connection. * @param {{project: string, stage: string}} args - Target. * @returns {Promise} Run. */ _findBlockingRun(db: any, { project, stage }: { project: string; stage: string; }): Promise; /** * @param {Record} row - Database row. * @returns {DeploymentRunRow} Run. */ _row(row: Record): DeploymentRunRow; /** * @param {string} context - Context. * @param {unknown} error - Failure. * @returns {void} */ _emitFrameworkError(context: string, error: unknown): void; /** * @template T * @param {(db: any) => Promise} callback - Work. * @returns {Promise} Result. */ _withDb(callback: (db: any) => Promise): Promise; } export type DeploymentRunRow = { id: string; mountIdentifier: string; project: string; stage: string; revision: string; expectedActiveRevision: string | null; idempotencyKey: string; status: string; result: any; error: any; requestedAtMs: number; startedAtMs: number | null; finishedAtMs: number | null; ownerToken: string | null; heartbeatAtMs: number | null; launchProtectedUntilMs: number | null; }; export type DeploymentRunStoreContract = { findRunById: (id: string) => Promise; findRunByKey: (key: string) => Promise; createRunIfPossible: (args: { idempotencyKey: string; project: string; revision: string; expectedActiveRevision?: string | null; stage: string; }) => Promise<{ outcome: string; run: DeploymentRunRow | null; }>; markRunning: (args: { id: string; startedAtMs: number; }) => Promise; claimPendingRun: (args: { id: string; startedAtMs: number; }) => Promise; heartbeat: (args: { id: string; heartbeatAtMs: number; }) => Promise; markPendingFailed: (args: { id: string; ownerToken: string; finishedAtMs: number; error: any; }) => Promise; failPendingRun: (args: { id: string; finishedAtMs: number; error: any; }) => Promise; markSucceeded: (args: { id: string; ownerToken: string; finishedAtMs: number; result: any; }) => Promise; markFailed: (args: { id: string; ownerToken: string; finishedAtMs: number; error: any; }) => Promise; markReconciliationRequired: (args: { id: string; ownerToken: string; finishedAtMs: number; error: any; }) => Promise; addAuditEvent: (args: { event: string; payload: any; runId: string | null; }) => Promise; }; export const AUDIT_TABLE: "rampway_deployment_api_audit_events"; /** * @typedef {object} DeploymentRunRow * @property {string} id * @property {string} mountIdentifier * @property {string} project * @property {string} stage * @property {string} revision * @property {string|null} expectedActiveRevision * @property {string} idempotencyKey * @property {string} status * @property {any} result * @property {any} error * @property {number} requestedAtMs * @property {number|null} startedAtMs * @property {number|null} finishedAtMs * @property {string|null} ownerToken * @property {number|null} heartbeatAtMs * @property {number|null} launchProtectedUntilMs */ /** * @typedef {object} DeploymentRunStoreContract * @property {(id: string) => Promise} findRunById * @property {(key: string) => Promise} findRunByKey * @property {(args: {idempotencyKey: string, project: string, revision: string, expectedActiveRevision?: string|null, stage: string}) => Promise<{outcome: string, run: DeploymentRunRow|null}>} createRunIfPossible * @property {(args: {id: string, startedAtMs: number}) => Promise} markRunning * @property {(args: {id: string, startedAtMs: number}) => Promise} claimPendingRun * @property {(args: {id: string, heartbeatAtMs: number}) => Promise} heartbeat * @property {(args: {id: string, ownerToken: string, finishedAtMs: number, error: any}) => Promise} markPendingFailed * @property {(args: {id: string, finishedAtMs: number, error: any}) => Promise} failPendingRun * @property {(args: {id: string, ownerToken: string, finishedAtMs: number, result: any}) => Promise} markSucceeded * @property {(args: {id: string, ownerToken: string, finishedAtMs: number, error: any}) => Promise} markFailed * @property {(args: {id: string, ownerToken: string, finishedAtMs: number, error: any}) => Promise} markReconciliationRequired * @property {(args: {event: string, payload: any, runId: string|null}) => Promise} addAuditEvent */ export const RUNS_TABLE: "rampway_deployment_runs"; //# sourceMappingURL=run-store.d.ts.map