feat(workflow): 补齐项目版本运行与工作台链路
This commit is contained in:
44
frontend/src/api/__tests__/workflow.spec.ts
Normal file
44
frontend/src/api/__tests__/workflow.spec.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import {
|
||||
getWorkflowDefinition,
|
||||
getWorkflowWorkspace,
|
||||
listWorkflowDefinitions,
|
||||
saveWorkflowDefinition,
|
||||
} from '../workflow';
|
||||
import { get, post } from '../request';
|
||||
|
||||
vi.mock('../request', () => ({
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
}));
|
||||
|
||||
describe('workflow api', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('maps workflow endpoints correctly', () => {
|
||||
listWorkflowDefinitions();
|
||||
getWorkflowDefinition('1001');
|
||||
saveWorkflowDefinition({
|
||||
projectId: '2001',
|
||||
workflowCode: 'WF_RAG_SUPPORT',
|
||||
workflowName: '知识问答流程',
|
||||
status: 'DRAFT',
|
||||
});
|
||||
getWorkflowWorkspace('2001', '1001');
|
||||
|
||||
expect(get).toHaveBeenCalledWith('/workflows/definitions');
|
||||
expect(get).toHaveBeenCalledWith('/workflows/definition/detail', { params: { id: '1001' } });
|
||||
expect(post).toHaveBeenCalledWith('/workflows/definition/save', {
|
||||
projectId: '2001',
|
||||
workflowCode: 'WF_RAG_SUPPORT',
|
||||
workflowName: '知识问答流程',
|
||||
status: 'DRAFT',
|
||||
});
|
||||
expect(get).toHaveBeenCalledWith('/workflow-workspace/detail', {
|
||||
params: { projectId: '2001', workflowId: '1001' },
|
||||
});
|
||||
});
|
||||
});
|
||||
87
frontend/src/api/workflow.ts
Normal file
87
frontend/src/api/workflow.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import { get, post } from './request';
|
||||
|
||||
export interface ProjectRecord {
|
||||
id?: string;
|
||||
projectCode: string;
|
||||
projectName: string;
|
||||
environment?: string;
|
||||
publishStatus?: string;
|
||||
currentVersion?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface WorkflowDefinitionRecord {
|
||||
id?: string;
|
||||
projectId: string;
|
||||
workflowCode: string;
|
||||
workflowName: string;
|
||||
description?: string;
|
||||
boundAgentId?: string;
|
||||
status?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface WorkflowVersionRecord {
|
||||
id?: string;
|
||||
workflowId: string;
|
||||
versionNo: number;
|
||||
snapshotName: string;
|
||||
graphJson: string;
|
||||
publishStatus?: string;
|
||||
publishedTime?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface WorkflowRunRecord {
|
||||
id?: string;
|
||||
workflowId: string;
|
||||
workflowVersionId: string;
|
||||
agentId?: string;
|
||||
requestId: string;
|
||||
runSource?: string;
|
||||
status?: string;
|
||||
inputJson?: string;
|
||||
outputJson?: string;
|
||||
durationMs?: number;
|
||||
estimatedCost?: number;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface WorkflowWorkspace {
|
||||
projectId: string;
|
||||
projectCode: string;
|
||||
projectName: string;
|
||||
environment?: string;
|
||||
publishStatus?: string;
|
||||
workflowId?: string;
|
||||
workflowCode?: string;
|
||||
workflowName?: string;
|
||||
workflowStatus?: string;
|
||||
currentPublishedVersionNo?: number;
|
||||
latestRequestId?: string;
|
||||
latestDurationMs?: number;
|
||||
workflows: WorkflowDefinitionRecord[];
|
||||
versions: WorkflowVersionRecord[];
|
||||
recentRuns: WorkflowRunRecord[];
|
||||
}
|
||||
|
||||
export function listWorkflowDefinitions() {
|
||||
return get<WorkflowDefinitionRecord[]>('/workflows/definitions');
|
||||
}
|
||||
|
||||
export function getWorkflowDefinition(id: string) {
|
||||
return get<WorkflowDefinitionRecord>('/workflows/definition/detail', { params: { id } });
|
||||
}
|
||||
|
||||
export function saveWorkflowDefinition(data: WorkflowDefinitionRecord) {
|
||||
return post<boolean, WorkflowDefinitionRecord>('/workflows/definition/save', data);
|
||||
}
|
||||
|
||||
export function getWorkflowWorkspace(projectId: string, workflowId?: string) {
|
||||
return get<WorkflowWorkspace>('/workflow-workspace/detail', {
|
||||
params: {
|
||||
projectId,
|
||||
workflowId,
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user