Apparel order fulfill
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user