feat(bill): refactor translator to modular functions and preserve inline positions for attachments and invoices
This commit is contained in:
1 parent
0ee5031dc8
commit
3777e81ee7
4 files changed
+722
-80
No files matched your search
+5
-3
@@ -15,7 +15,7 @@ import {
|
||||
validateGatewayAction,
|
||||
} from "./domains/approval/index.js";
|
||||
import { getRawBillFlow } from "./domains/bill/api.js";
|
||||
import { approveBill, rejectBill } from "./domains/bill/tools.js";
|
||||
import { approveBill, rejectBill, getTranslatorContext } from "./domains/bill/tools.js";
|
||||
import { translateBillFlowToMarkdown } from "./domains/bill/translator.js";
|
||||
import { VERSION } from "./version.js";
|
||||
|
||||
@@ -164,7 +164,8 @@ export async function runAiProCli(rawArgs: string[]): Promise<{ stdout: string;
|
||||
const flowIdObj = (raw.flowId && typeof raw.flowId === "object" ? raw.flowId : raw) as Record<string, any>;
|
||||
const form = (flowIdObj.form && typeof flowIdObj.form === "object" ? flowIdObj.form : {}) as Record<string, any>;
|
||||
const title = form.title || flowIdObj.title || "<无标题>";
|
||||
const snapshot = translateBillFlowToMarkdown(raw);
|
||||
const translatorContext = await getTranslatorContext(context.client, context.corpId).catch(() => undefined);
|
||||
const snapshot = translateBillFlowToMarkdown(raw, translatorContext);
|
||||
|
||||
// 创建全新独立运行实例 (永久长 ID + 6 位短 ID, 6 小时有效期)
|
||||
const run = repo.createApprovalRun({
|
||||
@@ -298,7 +299,8 @@ export async function runAiProCli(rawArgs: string[]): Promise<{ stdout: string;
|
||||
if (!raw) {
|
||||
throw new Error(`在当前企业下未找到单号或 ID 为 [${targetSn}] 的单据`);
|
||||
}
|
||||
const markdown = translateBillFlowToMarkdown(raw);
|
||||
const translatorContext = await getTranslatorContext(context.client, context.corpId).catch(() => undefined);
|
||||
const markdown = translateBillFlowToMarkdown(raw, translatorContext);
|
||||
|
||||
repo.logAiProAction({
|
||||
action: "translate",
|
||||
|
||||
Reference in new issue
Block a user