Files
atlas-seller-kit/apps/web/src/services/imageSuites.ts
T

21 lines
1.2 KiB
TypeScript

import type { CreateImageSuiteRequest, ImageSuite, ImageSuitePlanInput } from '@atlas/contracts';
import { api } from './api';
const path = (productId: string) => `/products/${productId}/ai/image-suites`;
const headers = (key: string) => ({ headers: { 'Idempotency-Key': key } });
export const imageSuitesApi = {
plan: (productId: string, input: ImageSuitePlanInput, key: string) =>
api.post<ImageSuite>(`/products/${productId}/ai/suite-plans`, input, headers(key)),
generate: (productId: string, input: CreateImageSuiteRequest, key: string) =>
api.post<ImageSuite>(path(productId), input, headers(key)),
read: (productId: string, id: string) => api.get<ImageSuite>(`${path(productId)}/${id}`),
list: (productId: string, cursor?: string) =>
api.getList<ImageSuite, { next_cursor: string | null; has_more: boolean }>(
`${path(productId)}?limit=100${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ''}`
),
cancel: (productId: string, id: string) =>
api.post<ImageSuite>(`${path(productId)}/${id}/cancel`, {}, headers(crypto.randomUUID())),
retry: (productId: string, id: string, key: string) =>
api.post<ImageSuite>(`${path(productId)}/${id}/retry`, {}, headers(key)),
};