Complete governed campaign lifecycle actions
This commit is contained in:
@@ -85,6 +85,21 @@ export type CampaignVersionListItem = {
|
||||
execution_snapshot_at?: string | null;
|
||||
delivery_mode?: "synchronous" | "worker_queue" | "database_queue" | null;
|
||||
delivery_mode_selected_at?: string | null;
|
||||
archived_at?: string | null;
|
||||
archived_by_user_id?: string | null;
|
||||
};
|
||||
|
||||
export type CampaignLifecycleAction = {
|
||||
allowed: boolean;
|
||||
reason?: string | null;
|
||||
};
|
||||
|
||||
export type CampaignLifecyclePolicy = {
|
||||
policy_id: string;
|
||||
policy_version: string;
|
||||
state_token: string;
|
||||
actions: Record<string, CampaignLifecycleAction>;
|
||||
provenance: Record<string, unknown>;
|
||||
};
|
||||
|
||||
export type CampaignVersionDetail = CampaignVersionListItem & {
|
||||
@@ -1004,10 +1019,59 @@ payload: CampaignUpdatePayload)
|
||||
|
||||
export async function archiveCampaign(
|
||||
settings: ApiSettings,
|
||||
campaignId: string)
|
||||
campaignId: string,
|
||||
expectedStateToken: string)
|
||||
: Promise<CampaignListItem> {
|
||||
return apiFetch<CampaignListItem>(settings, `/api/v1/campaigns/${campaignId}/archive`, {
|
||||
method: "POST"
|
||||
method: "POST",
|
||||
body: JSON.stringify({ expected_state_token: expectedStateToken })
|
||||
});
|
||||
}
|
||||
|
||||
export async function getCampaignLifecyclePolicy(
|
||||
settings: ApiSettings,
|
||||
campaignId: string,
|
||||
versionId?: string | null)
|
||||
: Promise<CampaignLifecyclePolicy> {
|
||||
const suffix = versionId ? `?version_id=${encodeURIComponent(versionId)}` : "";
|
||||
return apiFetch<CampaignLifecyclePolicy>(settings, `/api/v1/campaigns/${campaignId}/lifecycle-policy${suffix}`);
|
||||
}
|
||||
|
||||
export async function deleteCampaign(
|
||||
settings: ApiSettings,
|
||||
campaignId: string,
|
||||
expectedStateToken: string)
|
||||
: Promise<void> {
|
||||
await apiFetch<void>(settings, `/api/v1/campaigns/${campaignId}`, {
|
||||
method: "DELETE",
|
||||
body: JSON.stringify({ expected_state_token: expectedStateToken })
|
||||
});
|
||||
}
|
||||
|
||||
export async function copyCampaign(
|
||||
settings: ApiSettings,
|
||||
campaignId: string,
|
||||
sourceVersionId: string,
|
||||
expectedStateToken: string)
|
||||
: Promise<CampaignCreateResponse> {
|
||||
return apiFetch<CampaignCreateResponse>(settings, `/api/v1/campaigns/${campaignId}/copies`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
source_version_id: sourceVersionId,
|
||||
expected_state_token: expectedStateToken
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export async function archiveCampaignVersion(
|
||||
settings: ApiSettings,
|
||||
campaignId: string,
|
||||
versionId: string,
|
||||
expectedStateToken: string)
|
||||
: Promise<CampaignVersionListItem> {
|
||||
return apiFetch<CampaignVersionListItem>(settings, `/api/v1/campaigns/${campaignId}/versions/${versionId}/archive`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ expected_state_token: expectedStateToken })
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user