feat: expose optimizer workflow api

This commit is contained in:
Codex
2026-06-21 23:42:37 +08:00
parent 75bcab33c6
commit dd6480a8be
7 changed files with 346 additions and 18 deletions
+30
View File
@@ -245,6 +245,36 @@ export function getArticleJob(dbPath: string | undefined, id: string) {
});
}
export function updateArticleJob(
dbPath: string | undefined,
id: string,
changes: Partial<Pick<ArticleJob, "brand_template_id" | "status" | "export_paths">>,
) {
return withDb(dbPath, (db) => {
const existing = getArticleJob(dbPath, id);
if (!existing) return null;
const updated = {
brand_template_id: changes.brand_template_id ?? existing.brand_template_id,
status: changes.status ?? existing.status,
export_paths: changes.export_paths ?? existing.export_paths,
updated_at: nowIso(),
};
db.prepare(
`update article_jobs set
brand_template_id = @brand_template_id,
status = @status,
export_paths = @export_paths,
updated_at = @updated_at
where id = @id`,
).run({
id,
...updated,
export_paths: serialize(updated.export_paths),
});
return getArticleJob(dbPath, id);
});
}
export function saveFactCard(
dbPath: string | undefined,
jobId: string,