mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-30 05:16:50 +01:00
12 lines
492 B
TypeScript
12 lines
492 B
TypeScript
import type { Db } from "@paperclipai/db";
|
|
import { DELIVERY_QUEUES, notifyDeliveryWork } from "./delivery-work-notifications.js";
|
|
|
|
export type PluginJobDatabase = Pick<Db, "transaction" | "select" | "update" | "insert" | "delete">;
|
|
|
|
export function writePluginJobChange<T>(db: PluginJobDatabase, write: (tx: PluginJobDatabase) => Promise<T>): Promise<T> {
|
|
return db.transaction(async tx => {
|
|
await notifyDeliveryWork(tx, DELIVERY_QUEUES.pluginSchedules);
|
|
return write(tx);
|
|
});
|
|
}
|