feat(workflow): implement workflow copy and delete lifecycle commands
This commit is contained in:
1 parent
fec25bff8a
commit
b043cb614e
9 files changed
+521
-2
No files matched your search
@@ -24,6 +24,8 @@ hose-use workflow diff <snapshotId1> <snapshotId2> [--pipelineId=<id>]
|
||||
hose-use workflow diff-job <jobId1> <jobId2> [--json]
|
||||
hose-use workflow test <pipelineId> [--flow=<单号>] [--record=<ID>] [--body='{...}'] [--dry-run|--yes]
|
||||
hose-use workflow debug <pipelineId> --flow=<单号> --yes
|
||||
hose-use workflow copy <pipelineId> [--name=<名称>] [--platform-id=<应用ID>] [--dry-run|--yes]
|
||||
hose-use workflow delete <pipelineId> [--dry-run|--yes]
|
||||
```
|
||||
|
||||
## 触发器分类与调测路径分支 (Path Branching)
|
||||
|
||||
@@ -132,6 +132,36 @@ export async function updateWorkflow(
|
||||
return unwrap(response, WorkflowDetailSchema);
|
||||
}
|
||||
|
||||
export async function copyWorkflow(
|
||||
client: KyInstance,
|
||||
pipelineId: string,
|
||||
workflow: import("./types.js").WorkflowDetail
|
||||
): Promise<import("./types.js").WorkflowDetail> {
|
||||
const response = await client.put(`api/easo/pipelines/${pipelineId}/copy`, {
|
||||
json: workflow,
|
||||
});
|
||||
return unwrap(response, WorkflowDetailSchema);
|
||||
}
|
||||
|
||||
export async function createWorkflow(
|
||||
client: KyInstance,
|
||||
workflow: Record<string, any>
|
||||
): Promise<import("./types.js").WorkflowDetail> {
|
||||
const response = await client.post("api/easo/pipelines", {
|
||||
json: workflow,
|
||||
});
|
||||
return unwrap(response, WorkflowDetailSchema);
|
||||
}
|
||||
|
||||
export async function deleteWorkflow(
|
||||
client: KyInstance,
|
||||
pipelineId: string
|
||||
): Promise<boolean> {
|
||||
const response = await client.delete(`api/easo/pipelines/${pipelineId}`);
|
||||
await response.text().catch(() => "");
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function listWorkflowSnapshots(
|
||||
client: KyInstance,
|
||||
pipelineId: string,
|
||||
|
||||
@@ -50,6 +50,37 @@ export function updateWorkflow(...args: Parameters<typeof api.updateWorkflow>) {
|
||||
return api.updateWorkflow(...args);
|
||||
}
|
||||
|
||||
export async function copyWorkflow(
|
||||
client: import("ky").KyInstance,
|
||||
pipelineId: string,
|
||||
options: { label?: string; platformId?: string } = {}
|
||||
): Promise<import("./types.js").WorkflowDetail> {
|
||||
const detail = await api.getWorkflowDetail(client, pipelineId);
|
||||
const cloned = JSON.parse(JSON.stringify(detail)) as import("./types.js").WorkflowDetail;
|
||||
if (options.label) {
|
||||
cloned.label = options.label;
|
||||
} else if (!cloned.label.includes("副本")) {
|
||||
cloned.label = `${cloned.label} 副本`;
|
||||
}
|
||||
if (options.platformId) {
|
||||
cloned.platformId = options.platformId;
|
||||
}
|
||||
// 如果首节点是 Webhook,重新分配独立唯一的 urlPath,并清理历史脏样本
|
||||
if (cloned.tasks?.[0]?.type === "webhook") {
|
||||
(cloned.tasks[0] as any).urlPath = crypto.randomUUID();
|
||||
delete (cloned.tasks[0] as any).sampleId;
|
||||
}
|
||||
return api.copyWorkflow(client, pipelineId, cloned);
|
||||
}
|
||||
|
||||
export function createWorkflow(...args: Parameters<typeof api.createWorkflow>) {
|
||||
return api.createWorkflow(...args);
|
||||
}
|
||||
|
||||
export function deleteWorkflow(...args: Parameters<typeof api.deleteWorkflow>) {
|
||||
return api.deleteWorkflow(...args);
|
||||
}
|
||||
|
||||
export function listWorkflowSnapshots(...args: Parameters<typeof api.listWorkflowSnapshots>) {
|
||||
return api.listWorkflowSnapshots(...args);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user