feat(core-shared/jobs): PayloadJobQueue

This commit is contained in:
2026-05-08 11:36:12 +02:00
parent b96cff34ba
commit 23a1faa002
2 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import type { Payload } from "payload";
import type { IJobQueue } from "./job-queue.interface";
export class PayloadJobQueue implements IJobQueue {
constructor(private readonly payload: Payload) {}
async enqueue<T>(
taskSlug: string,
input: T,
options?: { runAt?: Date },
): Promise<{ jobId: string }> {
const result = await this.payload.jobs.queue({
task: taskSlug,
input: input as never,
waitUntil: options?.runAt,
} as never);
const jobId = (result as { id: string | number }).id;
return { jobId: String(jobId) };
}
}