Automation revamp part 1

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-28 01:46:27 +00:00
parent 0605f650b1
commit ea9125b805
9 changed files with 1237 additions and 58 deletions

View File

@@ -78,6 +78,62 @@ export interface ProcessingState {
remaining_count: number;
}
// NEW: Types for unified run_progress endpoint
export interface StageProgress {
number: number;
name: string;
type: 'AI' | 'Local' | 'Manual';
status: 'pending' | 'active' | 'completed' | 'skipped';
input_count: number;
output_count: number;
processed_count: number;
progress_percentage: number;
credits_used: number;
time_elapsed: string;
currently_processing?: ProcessingItem[];
up_next?: ProcessingItem[];
remaining_count?: number;
}
export interface GlobalProgress {
total_items: number;
completed_items: number;
percentage: number;
current_stage: number;
total_stages: number;
}
export interface InitialSnapshot {
stage_1_initial: number;
stage_2_initial: number;
stage_3_initial: number;
stage_4_initial: number;
stage_5_initial: number;
stage_6_initial: number;
stage_7_initial: number;
total_initial_items: number;
}
export interface RunProgressResponse {
run: {
run_id: string;
status: 'running' | 'paused' | 'cancelled' | 'completed' | 'failed';
current_stage: number;
trigger_type: 'manual' | 'scheduled';
started_at: string;
completed_at: string | null;
paused_at: string | null;
} | null;
global_progress: GlobalProgress | null;
stages: StageProgress[];
metrics: {
credits_used: number;
duration_seconds: number;
errors: string[];
} | null;
initial_snapshot: InitialSnapshot | null;
}
function buildUrl(endpoint: string, params?: Record<string, any>): string {
let url = `/v1/automation${endpoint}`;
if (params) {
@@ -211,4 +267,19 @@ export const automationService = {
);
return response.data;
},
/**
* Get unified run progress data - global + per-stage.
* This is the recommended endpoint for getting all automation progress data in a single call.
*/
getRunProgress: async (
siteId: number,
runId?: string
): Promise<RunProgressResponse> => {
const params: Record<string, any> = { site_id: siteId };
if (runId) {
params.run_id = runId;
}
return fetchAPI(buildUrl('/run_progress/', params));
},
};