feat(phase-31): add campaign scheduling and recurring automation (T-233 to T-234)
This commit is contained in:
@@ -36,6 +36,11 @@ export interface Campaign {
|
||||
target_platform: string | null;
|
||||
tags: string[];
|
||||
created_at: string | null;
|
||||
is_recurring: boolean;
|
||||
recurrence_pattern: string | null;
|
||||
next_run_at: string | null;
|
||||
last_run_at: string | null;
|
||||
parent_campaign_id: string | null;
|
||||
tests: CampaignTest[];
|
||||
progress: CampaignProgress;
|
||||
}
|
||||
@@ -151,3 +156,40 @@ export async function generateCampaignFromThreatActor(actorId: string): Promise<
|
||||
const { data } = await client.post<Campaign>(`/campaigns/from-threat-actor/${actorId}`);
|
||||
return data;
|
||||
}
|
||||
|
||||
// ── Scheduling ─────────────────────────────────────────────────────
|
||||
|
||||
export interface SchedulePayload {
|
||||
is_recurring: boolean;
|
||||
recurrence_pattern?: string;
|
||||
next_run_at?: string;
|
||||
}
|
||||
|
||||
export interface CampaignHistoryEntry {
|
||||
id: string;
|
||||
name: string;
|
||||
status: string;
|
||||
test_count: number;
|
||||
completion_pct: number;
|
||||
created_at: string | null;
|
||||
completed_at: string | null;
|
||||
}
|
||||
|
||||
/** Configure recurrence scheduling for a campaign. */
|
||||
export async function scheduleCampaign(
|
||||
campaignId: string,
|
||||
payload: SchedulePayload,
|
||||
): Promise<Campaign> {
|
||||
const { data } = await client.patch<Campaign>(`/campaigns/${campaignId}/schedule`, payload);
|
||||
return data;
|
||||
}
|
||||
|
||||
/** Get execution history (child campaigns) for a recurring campaign. */
|
||||
export async function getCampaignHistory(campaignId: string): Promise<{
|
||||
campaign_id: string;
|
||||
campaign_name: string;
|
||||
items: CampaignHistoryEntry[];
|
||||
}> {
|
||||
const { data } = await client.get(`/campaigns/${campaignId}/history`);
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user