import { getBoss } from "../../boss-instance";
import { WorkerQueue } from "./queues";

/**
 * Enqueue a single incremental sync job via PgBoss.
 * Called on an interval from the main API process so it survives worker restarts.
 */
export async function enqueueIncrementalSync(): Promise<void> {
  const jobId = await getBoss().send(
    WorkerQueue.DALPURI_INCREMENTAL_SYNC,
    {
      enqueuedAt: new Date().toISOString(),
    },
    {
      singletonKey: "dalpuri-incremental-sync",
    }
  );

  if (!jobId) {
    console.debug("[interval] DALPURI_INCREMENTAL_SYNC already pending or active");
  }
}
