2023-09-10 18:56:17 +00:00
|
|
|
import { GrammyTypes, IKV } from "../deps.ts";
|
2023-09-13 09:50:22 +00:00
|
|
|
import { SdTxt2ImgInfo } from "../common/sdApi.ts";
|
|
|
|
import { PngInfo } from "../common/parsePngInfo.ts";
|
2023-09-10 18:56:17 +00:00
|
|
|
import { db } from "./db.ts";
|
|
|
|
|
|
|
|
export interface JobSchema {
|
2023-09-12 01:57:44 +00:00
|
|
|
task:
|
2023-09-12 20:37:41 +00:00
|
|
|
| {
|
|
|
|
type: "txt2img";
|
|
|
|
params: Partial<PngInfo>;
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: "img2img";
|
|
|
|
params: Partial<PngInfo>;
|
|
|
|
fileId: string;
|
|
|
|
};
|
2023-09-12 01:57:44 +00:00
|
|
|
from: GrammyTypes.User;
|
|
|
|
chat: GrammyTypes.Chat;
|
|
|
|
requestMessageId: number;
|
2023-09-10 18:56:17 +00:00
|
|
|
status:
|
2023-09-12 20:37:41 +00:00
|
|
|
| {
|
|
|
|
type: "waiting";
|
|
|
|
message?: GrammyTypes.Message.TextMessage;
|
2023-09-14 01:23:55 +00:00
|
|
|
lastErrorDate?: Date;
|
2023-09-12 20:37:41 +00:00
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: "processing";
|
|
|
|
progress: number;
|
|
|
|
worker: string;
|
|
|
|
updatedDate: Date;
|
|
|
|
message?: GrammyTypes.Message.TextMessage;
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: "done";
|
|
|
|
info?: SdTxt2ImgInfo;
|
|
|
|
startDate?: Date;
|
|
|
|
endDate?: Date;
|
|
|
|
};
|
2023-09-10 18:56:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const jobStore = new IKV.Store(db, "job", {
|
|
|
|
schema: new IKV.Schema<JobSchema>(),
|
|
|
|
indices: ["status.type"],
|
|
|
|
});
|