import { type PluginReadState, type PluginState } from "@sentry/junior-plugin-api"; import type { PgDatabase } from "drizzle-orm/pg-core"; import type { PgQueryResultHKT } from "drizzle-orm/pg-core/session"; import * as schedulerSqlSchema from "./db/schema"; import { type ScheduledRun, type ScheduledTask } from "./types"; export type SchedulerDb = PgDatabase; export interface SchedulerStore { claimDueRun(args: { nowMs: number; }): Promise; createTask(task: ScheduledTask): Promise; getRun(runId: string): Promise; getTask(taskId: string): Promise; listIncompleteRuns(): Promise; listTasks(): Promise; listTasksCreatedBy(input: ListTasksCreatedByInput): Promise; listTasksForTeam(teamId: string): Promise; markRunBlocked(args: { completedAtMs: number; errorMessage: string; runId: string; startedAtMs?: number; }): Promise; markRunCompleted(args: { completedAtMs: number; resultMessageTs?: string; runId: string; startedAtMs: number; }): Promise; markRunFailed(args: { completedAtMs: number; errorMessage: string; startedAtMs?: number; runId: string; }): Promise; markRunSkipped(args: { completedAtMs: number; errorMessage: string; runId: string; }): Promise; markRunDispatched(args: { claimedAtMs: number; dispatchId: string; nowMs: number; runId: string; }): Promise; saveTask(task: ScheduledTask): Promise; updateTaskAfterRun(args: { errorMessage?: string; nowMs: number; run: ScheduledRun; status: "blocked" | "completed" | "failed"; }): Promise; } export interface ListTasksCreatedByInput { before?: { createdAtMs: number; id: string; }; identityIds: string[]; limit: number; query?: string; } export interface SchedulerOperationalStore { listIncompleteRunsForTasks(tasks: ScheduledTask[]): Promise; listTasks(): Promise; } /** Create a scheduler store backed by this plugin's durable state namespace. */ export declare function createSchedulerStore(state: PluginState): SchedulerStore; /** Create a read-only scheduler store for operational reporting. */ export declare function createSchedulerOperationalStore(state: PluginReadState): SchedulerOperationalStore; /** Create a scheduler store backed by the plugin SQL database. */ export declare function createSchedulerSqlStore(db: SchedulerDb): SchedulerStore; /** Create a read-only scheduler operational store backed by SQL. */ export declare function createSchedulerOperationalSqlStore(db: SchedulerDb): SchedulerOperationalStore;