Apparel order fulfill

This commit is contained in:
Dominic Ferrando
2026-07-12 19:38:03 -04:00
parent 7149d95eeb
commit 0a74985503
3 changed files with 32 additions and 17 deletions
+3 -3
View File
@@ -10,7 +10,7 @@ export type EventSource = "portal" | "printful" | "webflow";
export type EventStatus = "pending" | "processing" | "failed" | "fulfilled";
type EventProcessor<P extends TSchema, S extends TSchema> =
(id: string, payload: Static<P>, setState: (state: Static<S>) => Promise<void>) => Promise<void>;
(payload: Static<P>, setState: (state: Static<S>) => Promise<void>, id: string) => Promise<void>;
export type EventTypeOptions<P extends TSchema, S extends TSchema> = {
schemas: { payload: P, state: S },
@@ -196,12 +196,12 @@ export class EventQueue<G extends string, T extends Record<string, EventTypeOpti
const cfg = this.events[type as keyof T]!;
try {
Value.Assert(cfg.schemas.payload, payload);
await cfg.processor(id, payload, async (state) => {
await cfg.processor(payload, async (state) => {
await db.updateTable("events")
.set({ state })
.where("id", "=", id)
.execute();
});
}, id);
}
catch (err) {
await this.fail(id);