fina autoamtiona adn billing and credits
This commit is contained in:
@@ -25,10 +25,14 @@ export interface StageResult {
|
||||
|
||||
export interface AutomationRun {
|
||||
run_id: string;
|
||||
status: 'running' | 'paused' | 'completed' | 'failed';
|
||||
status: 'running' | 'paused' | 'cancelled' | 'completed' | 'failed';
|
||||
current_stage: number;
|
||||
trigger_type: 'manual' | 'scheduled';
|
||||
started_at: string;
|
||||
completed_at?: string | null;
|
||||
paused_at?: string | null;
|
||||
resumed_at?: string | null;
|
||||
cancelled_at?: string | null;
|
||||
total_credits_used: number;
|
||||
stage_1_result: StageResult | null;
|
||||
stage_2_result: StageResult | null;
|
||||
@@ -56,6 +60,24 @@ export interface PipelineStage {
|
||||
type: 'AI' | 'Local' | 'Manual';
|
||||
}
|
||||
|
||||
export interface ProcessingItem {
|
||||
id: number;
|
||||
title: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface ProcessingState {
|
||||
stage_number: number;
|
||||
stage_name: string;
|
||||
stage_type: 'AI' | 'Local' | 'Manual';
|
||||
total_items: number;
|
||||
processed_items: number;
|
||||
percentage: number;
|
||||
currently_processing: ProcessingItem[];
|
||||
up_next: ProcessingItem[];
|
||||
remaining_count: number;
|
||||
}
|
||||
|
||||
function buildUrl(endpoint: string, params?: Record<string, any>): string {
|
||||
let url = `/v1/automation${endpoint}`;
|
||||
if (params) {
|
||||
@@ -109,8 +131,8 @@ export const automationService = {
|
||||
/**
|
||||
* Pause automation run
|
||||
*/
|
||||
pause: async (runId: string): Promise<void> => {
|
||||
await fetchAPI(buildUrl('/pause/', { run_id: runId }), {
|
||||
pause: async (siteId: number, runId: string): Promise<void> => {
|
||||
await fetchAPI(buildUrl('/pause/', { site_id: siteId, run_id: runId }), {
|
||||
method: 'POST',
|
||||
});
|
||||
},
|
||||
@@ -118,8 +140,17 @@ export const automationService = {
|
||||
/**
|
||||
* Resume paused automation run
|
||||
*/
|
||||
resume: async (runId: string): Promise<void> => {
|
||||
await fetchAPI(buildUrl('/resume/', { run_id: runId }), {
|
||||
resume: async (siteId: number, runId: string): Promise<void> => {
|
||||
await fetchAPI(buildUrl('/resume/', { site_id: siteId, run_id: runId }), {
|
||||
method: 'POST',
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Cancel automation run
|
||||
*/
|
||||
cancel: async (siteId: number, runId: string): Promise<void> => {
|
||||
await fetchAPI(buildUrl('/cancel/', { site_id: siteId, run_id: runId }), {
|
||||
method: 'POST',
|
||||
});
|
||||
},
|
||||
@@ -167,4 +198,17 @@ export const automationService = {
|
||||
method: 'POST',
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Get current processing state for active automation run
|
||||
*/
|
||||
getCurrentProcessing: async (
|
||||
siteId: number,
|
||||
runId: string
|
||||
): Promise<ProcessingState | null> => {
|
||||
const response = await fetchAPI(
|
||||
buildUrl('/current_processing/', { site_id: siteId, run_id: runId })
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user