export default class BackgroundJobsStore {
    /**
     * Runs constructor.
     * @param {object} args - Options.
     * @param {import("../configuration.js").default} args.configuration - Configuration.
     * @param {string} [args.databaseIdentifier] - Database identifier.
     */
    constructor({ configuration, databaseIdentifier }: {
        configuration: import("../configuration.js").default;
        databaseIdentifier?: string | undefined;
    });
    configuration: import("../configuration.js").default;
    databaseIdentifier: string | undefined;
    logger: Logger;
    _readyPromise: Promise<void> | null;
    /**
     * Runs get database identifier.
     * @returns {string} - Database identifier.
     */
    getDatabaseIdentifier(): string;
    /**
     * Runs ensure ready.
     * @returns {Promise<void>} - Resolves when ready.
     */
    ensureReady(): Promise<void>;
    /**
     * Runs enqueue.
     * @param {object} args - Options.
     * @param {string} args.jobName - Job name.
     * @param {Array<?>} args.args - Arguments.
     * @param {import("./types.js").BackgroundJobOptions} [args.options] - Options.
     * @returns {Promise<string>} - Job id.
     */
    enqueue({ jobName, args, options }: {
        jobName: string;
        args: Array<unknown>;
        options?: import("./types.js").BackgroundJobOptions | undefined;
    }): Promise<string>;
    /**
     * Runs next available job.
     * @param {object} [args] - Options.
     * @param {boolean} [args.forked] - Compatibility filter for non-inline vs inline jobs.
     * @param {import("./types.js").BackgroundJobExecutionMode | import("./types.js").BackgroundJobExecutionMode[]} [args.executionMode] - Execution mode or modes to match.
     * @returns {Promise<import("./types.js").BackgroundJobRow | null>} - Next job.
     */
    nextAvailableJob(args?: {
        forked?: boolean | undefined;
        executionMode?: import("./types.js").BackgroundJobExecutionMode | import("./types.js").BackgroundJobExecutionMode[] | undefined;
    }): Promise<import("./types.js").BackgroundJobRow | null>;
    /**
     * Returns the soonest future-scheduled queued job (one whose
     * `scheduled_at_ms` is in the future), or null when there are no
     * future-scheduled jobs. Used by the event-driven dispatcher to arm a
     * `setTimeout` for the exact moment the next scheduled job becomes
     * eligible, replacing the legacy 1-second polling loop.
     * @returns {Promise<import("./types.js").BackgroundJobRow | null>} - Soonest future-scheduled job, or null.
     */
    nextScheduledJob(): Promise<import("./types.js").BackgroundJobRow | null>;
    /**
     * Runs next queued job.
     * @param {object} args - Options.
     * @param {import("../database/drivers/base.js").default} args.db - Database connection.
     * @param {"<=" | ">"} args.scheduledAtOperator - Scheduled timestamp operator.
     * @param {boolean} [args.forked] - Compatibility filter for non-inline vs inline jobs.
     * @param {import("./types.js").BackgroundJobExecutionMode | import("./types.js").BackgroundJobExecutionMode[]} [args.executionMode] - Execution mode or modes to match.
     * @returns {Promise<import("./types.js").BackgroundJobRow | null>} - Next matching queued job.
     */
    _nextQueuedJob({ db, scheduledAtOperator, forked, executionMode }: {
        db: import("../database/drivers/base.js").default;
        scheduledAtOperator: "<=" | ">";
        forked?: boolean | undefined;
        executionMode?: import("./types.js").BackgroundJobExecutionMode | import("./types.js").BackgroundJobExecutionMode[] | undefined;
    }): Promise<import("./types.js").BackgroundJobRow | null>;
    /**
     * Runs get job.
     * @param {string} jobId - Job id.
     * @returns {Promise<import("./types.js").BackgroundJobRow | null>} - Job row.
     */
    getJob(jobId: string): Promise<import("./types.js").BackgroundJobRow | null>;
    /**
     * Counts jobs grouped by status. Used by the dashboard overview.
     * @returns {Promise<Record<string, number>>} - Counts keyed by status.
     */
    countsByStatus(): Promise<Record<string, number>>;
    /**
     * Counts jobs matching the given filters.
     * @param {object} [args] - Options.
     * @param {string} [args.status] - Filter by status.
     * @param {string} [args.jobName] - Filter by job name.
     * @returns {Promise<number>} - Matching job count.
     */
    countJobs({ status, jobName }?: {
        status?: string | undefined;
        jobName?: string | undefined;
    }): Promise<number>;
    /**
     * Lists jobs for the dashboard, filtered, sorted and paginated.
     * @param {object} [args] - Options.
     * @param {string} [args.status] - Filter by status.
     * @param {string} [args.jobName] - Filter by job name.
     * @param {number} [args.limit] - Maximum rows to return.
     * @param {number} [args.offset] - Rows to skip.
     * @param {string} [args.sortColumn] - Camel-cased column to sort by (see SORTABLE_COLUMNS).
     * @param {"ASC" | "DESC"} [args.sortDirection] - Sort direction.
     * @returns {Promise<import("./types.js").BackgroundJobRow[]>} - Normalized job rows.
     */
    listJobs({ status, jobName, limit, offset, sortColumn, sortDirection }?: {
        status?: string | undefined;
        jobName?: string | undefined;
        limit?: number | undefined;
        offset?: number | undefined;
        sortColumn?: string | undefined;
        sortDirection?: "ASC" | "DESC" | undefined;
    }): Promise<import("./types.js").BackgroundJobRow[]>;
    /**
     * Runs mark handed off.
     * @param {object} args - Options.
     * @param {string} args.jobId - Job id.
     * @param {string} [args.workerId] - Worker id.
     * @returns {Promise<number>} - Resolves with handed off timestamp.
     */
    markHandedOff({ jobId, workerId }: {
        jobId: string;
        workerId?: string | undefined;
    }): Promise<number>;
    /**
     * Runs mark completed.
     * @param {object} args - Options.
     * @param {string} args.jobId - Job id.
     * @param {string} [args.workerId] - Worker id.
     * @param {number} [args.handedOffAtMs] - Handed off timestamp.
     * @returns {Promise<void>} - Resolves when updated.
     */
    markCompleted({ jobId, workerId, handedOffAtMs }: {
        jobId: string;
        workerId?: string | undefined;
        handedOffAtMs?: number | undefined;
    }): Promise<void>;
    /**
     * Runs mark returned to queue.
     * @param {object} args - Options.
     * @param {string} args.jobId - Job id.
     * @returns {Promise<void>} - Resolves when updated.
     */
    markReturnedToQueue({ jobId }: {
        jobId: string;
    }): Promise<void>;
    /**
     * Runs mark failed.
     * @param {object} args - Options.
     * @param {string} args.jobId - Job id.
     * @param {?} args.error - Error.
     * @param {string} [args.workerId] - Worker id.
     * @param {number} [args.handedOffAtMs] - Handed off timestamp.
     * @returns {Promise<import("./types.js").BackgroundJobRow | null>} - Updated job row when the report was accepted.
     */
    markFailed({ jobId, error, workerId, handedOffAtMs }: {
        jobId: string;
        error: unknown;
        workerId?: string | undefined;
        handedOffAtMs?: number | undefined;
    }): Promise<import("./types.js").BackgroundJobRow | null>;
    /**
     * Runs mark orphaned jobs.
     * @param {object} [args] - Options.
     * @param {number} [args.orphanedAfterMs] - Mark jobs orphaned after this duration.
     * @returns {Promise<number>} - Count of orphaned jobs.
     */
    markOrphanedJobs({ orphanedAfterMs }?: {
        orphanedAfterMs?: number | undefined;
    }): Promise<number>;
    /**
     * Runs clear all.
     * @returns {Promise<void>} - Resolves when cleared.
     */
    clearAll(): Promise<void>;
    /**
     * Runs get retry delay ms.
     * @param {number} retryCount - Retry attempt count (1-based).
     * @returns {number} - Delay in milliseconds.
     */
    getRetryDelayMs(retryCount: number): number;
    /**
     * Runs normalize max retries.
     * @param {number | null | undefined} maxRetries - Input.
     * @returns {number} - Normalized max retries.
     */
    _normalizeMaxRetries(maxRetries: number | null | undefined): number;
    _ensureSchema(): Promise<void>;
    /**
     * Runs ensure migrations table.
     * @param {import("../database/drivers/base.js").default} db - Database connection.
     * @returns {Promise<void>} - Resolves when complete.
     */
    _ensureMigrationsTable(db: import("../database/drivers/base.js").default): Promise<void>;
    /**
     * Runs has migration.
     * @param {import("../database/drivers/base.js").default} db - Database connection.
     * @param {string} [version] - Migration version.
     * @returns {Promise<boolean>} - Whether migration exists.
     */
    _hasMigration(db: import("../database/drivers/base.js").default, version?: string): Promise<boolean>;
    /**
     * Runs apply migrations.
     * @param {import("../database/drivers/base.js").default} db - Database connection.
     * @returns {Promise<void>} - Resolves when complete.
     */
    _applyMigrations(db: import("../database/drivers/base.js").default): Promise<void>;
    /**
     * Runs ensure jobs table columns.
     * @param {import("../database/drivers/base.js").default} db - Database connection.
     * @returns {Promise<void>} - Resolves when complete.
     */
    _ensureJobsTableColumns(db: import("../database/drivers/base.js").default): Promise<void>;
    /**
     * Runs backfill execution modes once.
     * @param {import("../database/drivers/base.js").default} db - Database connection.
     * @returns {Promise<void>} - Resolves when complete.
     */
    _backfillExecutionModesOnce(db: import("../database/drivers/base.js").default): Promise<void>;
    /**
     * Runs record migration.
     * @param {import("../database/drivers/base.js").default} db - Database connection.
     * @param {string} version - Migration version.
     * @returns {Promise<void>} - Resolves when complete.
     */
    _recordMigration(db: import("../database/drivers/base.js").default, version: string): Promise<void>;
    _initializeModel(): Promise<void>;
    /**
     * Runs get job row by id.
     * @param {import("../database/drivers/base.js").default} db - Database connection.
     * @param {string} jobId - Job id.
     * @returns {Promise<import("./types.js").BackgroundJobRow | null>} - Job row.
     */
    _getJobRowById(db: import("../database/drivers/base.js").default, jobId: string): Promise<import("./types.js").BackgroundJobRow | null>;
    /**
     * Runs apply failure.
     * @param {object} args - Options.
     * @param {import("../database/drivers/base.js").default} args.db - Database connection.
     * @param {import("./types.js").BackgroundJobRow} args.job - Job row.
     * @param {?} args.error - Error.
     * @param {boolean} args.markOrphaned - Whether marking orphaned.
     * @returns {Promise<import("./types.js").BackgroundJobRow>} - Updated job row.
     */
    _applyFailure({ db, job, error, markOrphaned }: {
        db: import("../database/drivers/base.js").default;
        job: import("./types.js").BackgroundJobRow;
        error: unknown;
        markOrphaned: boolean;
    }): Promise<import("./types.js").BackgroundJobRow>;
    /**
     * Runs failure update.
     * @param {object} args - Options.
     * @param {string} args.failureMessage - Last failure message.
     * @param {boolean} args.markOrphaned - Whether marking orphaned.
     * @param {number} args.nextAttempt - Next attempt count.
     * @param {number} args.now - Current timestamp.
     * @param {number | null} args.scheduledAt - Next scheduled timestamp.
     * @param {boolean} args.shouldRetry - Whether the job should retry.
     * @returns {Record<string, ?>} - Database update data.
     */
    _failureUpdate({ failureMessage, markOrphaned, nextAttempt, now, scheduledAt, shouldRetry }: {
        failureMessage: string;
        markOrphaned: boolean;
        nextAttempt: number;
        now: number;
        scheduledAt: number | null;
        shouldRetry: boolean;
    }): Record<string, unknown>;
    /**
     * Runs apply orphaned failure update.
     * @param {object} args - Options.
     * @param {boolean} args.markOrphaned - Whether marking orphaned.
     * @param {number} args.now - Current timestamp.
     * @param {Record<string, ?>} args.update - Database update data.
     * @returns {void}
     */
    _applyOrphanedFailureUpdate({ markOrphaned, now, update }: {
        markOrphaned: boolean;
        now: number;
        update: Record<string, unknown>;
    }): void;
    /**
     * Runs apply failure status update.
     * @param {object} args - Options.
     * @param {boolean} args.markOrphaned - Whether marking orphaned.
     * @param {number} args.now - Current timestamp.
     * @param {number | null} args.scheduledAt - Next scheduled timestamp.
     * @param {boolean} args.shouldRetry - Whether the job should retry.
     * @param {Record<string, ?>} args.update - Database update data.
     * @returns {void}
     */
    _applyFailureStatusUpdate({ markOrphaned, now, scheduledAt, shouldRetry, update }: {
        markOrphaned: boolean;
        now: number;
        scheduledAt: number | null;
        shouldRetry: boolean;
        update: Record<string, unknown>;
    }): void;
    /**
     * Runs job with failure update.
     * @param {object} args - Options.
     * @param {string} args.failureMessage - Last failure message.
     * @param {import("./types.js").BackgroundJobRow} args.job - Job row.
     * @param {number} args.nextAttempt - Next attempt count.
     * @param {Record<string, ?>} args.update - Database update data.
     * @returns {import("./types.js").BackgroundJobRow} - Updated job row.
     */
    _jobWithFailureUpdate({ failureMessage, job, nextAttempt, update }: {
        failureMessage: string;
        job: import("./types.js").BackgroundJobRow;
        nextAttempt: number;
        update: Record<string, unknown>;
    }): import("./types.js").BackgroundJobRow;
    /**
     * Runs normalize job row.
     * @param {Record<string, ?>} row - Raw database row.
     * @returns {import("./types.js").BackgroundJobRow} - Normalized job row.
     */
    _normalizeJobRow(row: Record<string, unknown>): import("./types.js").BackgroundJobRow;
    /**
     * Runs normalize number.
     * @param {?} value - Input value.
     * @returns {number | null} - Normalized number.
     */
    _normalizeNumber(value: unknown): number | null;
    /**
     * Runs normalize boolean.
     * @param {?} value - Input value.
     * @returns {boolean} - Normalized boolean.
     */
    _normalizeBoolean(value: unknown): boolean;
    /**
     * Runs normalize execution mode.
     * @param {import("./types.js").BackgroundJobOptions} [options] - Job options.
     * @returns {import("./types.js").BackgroundJobExecutionMode} - Normalized execution mode.
     */
    _normalizeExecutionMode(options?: import("./types.js").BackgroundJobOptions): import("./types.js").BackgroundJobExecutionMode;
    /**
     * Runs normalize execution mode name.
     * @param {string} executionMode - Execution mode name.
     * @returns {import("./types.js").BackgroundJobExecutionMode} - Normalized execution mode.
     */
    _normalizeExecutionModeName(executionMode: string): import("./types.js").BackgroundJobExecutionMode;
    /**
     * Runs parse args.
     * @param {?} value - Input value.
     * @returns {Array<?>} - Parsed args.
     */
    _parseArgs(value: unknown): Array<unknown>;
    /**
     * Runs with db.
     * @template T
     * @param {(db: import("../database/drivers/base.js").default) => Promise<T>} callback - Callback.
     * @returns {Promise<T>} - Callback result.
     */
    _withDb<T>(callback: (db: import("../database/drivers/base.js").default) => Promise<T>): Promise<T>;
    /**
     * Runs should accept report.
     * @param {object} args - Options.
     * @param {import("./types.js").BackgroundJobRow} args.job - Job row.
     * @param {string | null | undefined} args.workerId - Worker id from report.
     * @param {number | null | undefined} args.handedOffAtMs - Handed off timestamp from report.
     * @returns {boolean} - Whether to accept the report.
     */
    _shouldAcceptReport({ job, workerId, handedOffAtMs }: {
        job: import("./types.js").BackgroundJobRow;
        workerId: string | null | undefined;
        handedOffAtMs: number | null | undefined;
    }): boolean;
    /**
     * Runs worker report matches.
     * @param {object} args - Options.
     * @param {import("./types.js").BackgroundJobRow} args.job - Job row.
     * @param {string | null | undefined} args.workerId - Worker id from report.
     * @returns {boolean} - Whether the worker report matches.
     */
    _workerReportMatches({ job, workerId }: {
        job: import("./types.js").BackgroundJobRow;
        workerId: string | null | undefined;
    }): boolean;
    /**
     * Runs handoff report matches.
     * @param {object} args - Options.
     * @param {number | null | undefined} args.handedOffAtMs - Handed off timestamp from report.
     * @param {import("./types.js").BackgroundJobRow} args.job - Job row.
     * @returns {boolean} - Whether the handoff report matches.
     */
    _handoffReportMatches({ handedOffAtMs, job }: {
        handedOffAtMs: number | null | undefined;
        job: import("./types.js").BackgroundJobRow;
    }): boolean;
    /**
     * Runs migration key.
     * @param {string} [version] - Migration version.
     * @returns {string} - Migration key.
     */
    _migrationKey(version?: string): string;
}
import Logger from "../logger.js";
//# sourceMappingURL=store.d.ts.map