refactor: fix exit-1 comment, remove JSON round-trip, use OfficeMeta cast
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { END, type ModeratorCondition, type ModeratorTable, START } from "@uncaged/workflow-runtime";
|
||||
import type { DocumentEditorMeta } from "./roles.js";
|
||||
import type { DocumentEditorMeta, OfficeMeta } from "./roles.js";
|
||||
|
||||
const officeIsEdit: ModeratorCondition<DocumentEditorMeta> = {
|
||||
name: "officeIsEdit",
|
||||
@@ -7,7 +7,7 @@ const officeIsEdit: ModeratorCondition<DocumentEditorMeta> = {
|
||||
check: (ctx) => {
|
||||
const officeStep = ctx.steps.find((s) => s.role === "office");
|
||||
if (officeStep === undefined) return false;
|
||||
return (officeStep.meta as { mode: string }).mode === "edit";
|
||||
return (officeStep.meta as OfficeMeta).mode === "edit";
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ export function createDifferAdapter(
|
||||
if (!result.ok) {
|
||||
const e = result.error;
|
||||
if (e.kind === "non_zero_exit" && e.exitCode === 1) {
|
||||
// docx-diff exits 1 when documents have differences — this is a success path
|
||||
} else if (e.kind === "non_zero_exit") {
|
||||
throw new Error(`differ: docx-diff failed (exit ${e.exitCode}): ${e.stderr}`);
|
||||
} else if (e.kind === "timeout") {
|
||||
@@ -52,8 +53,7 @@ export function createDifferAdapter(
|
||||
throw new Error(`differ: report file not found: ${reportPath}`);
|
||||
}
|
||||
|
||||
const raw = JSON.stringify({ outputDocx, sourceDocx, diffReport: reportPath });
|
||||
const meta = schema.parse(JSON.parse(raw)) as T;
|
||||
const meta = schema.parse({ outputDocx, sourceDocx, diffReport: reportPath });
|
||||
return { meta, childThread: null };
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user