import type { ApprovedActionDispatchCursor, ApprovedActionDispatchExecutionSnapshot, } from '../domain/approvedActionDispatchExecution'; export interface ListDueApprovedActionDispatchesQuery { nowMs: number; limit: number; cursor?: ApprovedActionDispatchCursor; } export interface ListDueApprovedActionDispatchesResult { dispatches: readonly ApprovedActionDispatchExecutionSnapshot[]; truncated: boolean; nextCursor?: Readonly; } export interface ClaimApprovedActionDispatchCommand { dispatchId: string; owner: string; leaseToken: string; nowMs: number; leaseDurationMs: number; } export type ClaimApprovedActionDispatchResult = | { status: 'claimed'; snapshot: Readonly; } | { status: 'not_found' } | { status: | 'not_due' | 'leased' | 'executing' | 'recovery_required' | 'succeeded' | 'failed' | 'blocked'; snapshot: Readonly; }; export interface StartApprovedActionDispatchCommand { dispatchId: string; approvalRequestId: string; actionDigest: string; owner: string; leaseToken: string; expectedVersion: number; startedAtMs: number; } export interface RenewApprovedActionDispatchLeaseCommand { dispatchId: string; owner: string; leaseToken: string; expectedVersion: number; nowMs: number; leaseDurationMs: number; } export interface ReleaseApprovedActionDispatchBeforeStartCommand { dispatchId: string; owner: string; leaseToken: string; expectedVersion: number; resultMutationId: string; resultCode: string; atMs: number; retryAtMs?: number; } export interface CompleteApprovedActionDispatchCommand { dispatchId: string; owner: string; leaseToken: string; expectedVersion: number; resultMutationId: string; outcome: 'succeeded' | 'failed' | 'indeterminate'; resultCode: string; completedAtMs: number; } export interface ApprovedActionDispatchRepository { findById( dispatchId: string, ): Promise | null>; listDue( query: ListDueApprovedActionDispatchesQuery, ): Promise; claim( command: ClaimApprovedActionDispatchCommand, ): Promise; start( command: StartApprovedActionDispatchCommand, ): Promise>; renew( command: RenewApprovedActionDispatchLeaseCommand, ): Promise>; releaseBeforeStart( command: ReleaseApprovedActionDispatchBeforeStartCommand, ): Promise>; complete( command: CompleteApprovedActionDispatchCommand, ): Promise>; }