2023-09-10 18:56:17 +00:00
|
|
|
import { GrammyTypes, IKV } from "../deps.ts";
|
|
|
|
import { SdTxt2ImgInfo, SdTxt2ImgRequest } from "../sd.ts";
|
|
|
|
import { db } from "./db.ts";
|
|
|
|
|
|
|
|
export interface JobSchema {
|
|
|
|
params: Partial<SdTxt2ImgRequest>;
|
2023-09-10 23:59:33 +00:00
|
|
|
request: GrammyTypes.Message & { from: GrammyTypes.User };
|
2023-09-10 18:56:17 +00:00
|
|
|
reply?: GrammyTypes.Message.TextMessage;
|
|
|
|
status:
|
|
|
|
| { type: "waiting" }
|
|
|
|
| { type: "processing"; progress: number; worker: string; updatedDate: Date }
|
|
|
|
| { type: "done"; info?: SdTxt2ImgInfo; startDate?: Date; endDate?: Date };
|
|
|
|
}
|
|
|
|
|
|
|
|
export const jobStore = new IKV.Store(db, "job", {
|
|
|
|
schema: new IKV.Schema<JobSchema>(),
|
|
|
|
indices: ["status.type"],
|
|
|
|
});
|