/// <reference types="node" />
import { EnqueueJob } from "./types/queues/POST/body";
import { QueuesUpdateCronBody } from "./types/queues/update-cron";
import Owl, { Closable } from "@quirrel/owl";
import { QueueRepo } from "./queue-repo";
import { Redis } from "ioredis";
interface PaginationOpts {
    cursor: number;
    count?: number;
}
interface JobDTO {
    id: string;
    endpoint: string;
    body: string;
    runAt: string;
    exclusive: boolean;
    retry: number[];
    count: number;
    repeat?: {
        every?: number;
        times?: number;
        count: number;
        cron?: string;
        cronTimezone?: string;
    };
}
export declare class JobsRepo implements Closable {
    protected readonly owl: Owl<"every" | "cron">;
    protected producer: import("@quirrel/owl/dist/producer/producer").Producer<"cron" | "every">;
    readonly queueRepo: QueueRepo;
    constructor(owl: Owl<"every" | "cron">, redis: Redis);
    private static toJobDTO;
    close(): Promise<void>;
    find(byTokenId: string, endpoint: string, { count, cursor }: PaginationOpts): Promise<{
        cursor: number;
        jobs: JobDTO[];
    }>;
    findAll({ count, cursor }: PaginationOpts): Promise<{
        cursor: number;
        jobs: {
            tokenId: string;
            id: string;
            endpoint: string;
            body: string;
            runAt: string;
            exclusive: boolean;
            retry: number[];
            count: number;
            repeat?: {
                every?: number | undefined;
                times?: number | undefined;
                count: number;
                cron?: string | undefined;
                cronTimezone?: string | undefined;
            } | undefined;
        }[];
    }>;
    findByTokenId(byTokenId: string, { count, cursor }: PaginationOpts): Promise<{
        cursor: number;
        jobs: JobDTO[];
    }>;
    queueStatsByTokenId(byTokenId: string): Promise<{
        [k: string]: {
            count: number;
        };
    }>;
    findById(tokenId: string, endpoint: string, id: string): Promise<JobDTO | undefined>;
    invoke(tokenId: string, endpoint: string, id: string): Promise<"not_found" | "invoked">;
    private emptyByGetter;
    emptyQueue(tokenId: string, endpoint: string): Promise<void>;
    emptyToken(tokenId: string): Promise<void>;
    delete(tokenId: string, endpoint: string, id: string): Promise<"deleted" | "not_found">;
    enqueue(tokenId: string, endpoint: string, { body, runAt: runAtOption, id, delay, repeat, override, exclusive, retry, }: EnqueueJob): Promise<JobDTO>;
    updateCron(tokenId: string, { baseUrl, crons, dryRun }: QueuesUpdateCronBody): Promise<{
        deleted: string[];
    }>;
    onEvent(requesterTokenId: string, cb: (event: string, job: {
        endpoint: string;
        id: string;
        runAt?: string;
    } | JobDTO) => void): () => Promise<void>;
}
declare module "fastify" {
    interface FastifyInstance {
        jobs: JobsRepo;
    }
}
export declare const jobsRepoPlugin: import("fastify").FastifyPluginCallback<Record<never, never>, import("http").Server, import("fastify").FastifyTypeProviderDefault>;
export {};
