export type Side = 'A' | 'B'; export type ImageSearch = {searchId: string, selected: number}; export type Synopsis = {text: string, images_query: string, image_type: string, image_search: ImageSearch}; export type Overlay = {start_chunk: number, end_chunk: number, images_query: string, image_type: string, image_search: ImageSearch}; export type Question = {text: string, images_query: string, image_type: string, image_search: ImageSearch}; export type Answers = {text: string}; export type GameDetail = {correctAnswer?: Side | undefined, synopsis: Array, overlays: Array, question: Array, answers: Array}; export type NewVersionDto = {version: number, gameDetail: GameDetail, manualOverrides: Record}; export type CreateApiV2AutogameArticleDraftsIdVersionArgs = {id: string, body: NewVersionDto}; export type CreateApiV2AutogameArticleDraftsIdVersionOptions = {baseUrl: string, accessToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /v2/autogame/article/drafts/{id}/version */ export const createApiV2AutogameArticleDraftsIdVersion = async (args: CreateApiV2AutogameArticleDraftsIdVersionArgs, options: CreateApiV2AutogameArticleDraftsIdVersionOptions) => { const {baseUrl, fetch: fetchFn = fetch, accessToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (accessToken !== undefined) headers.set('authorization', `Bearer ${accessToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/autogame/article/drafts/${encodeURIComponent(String(args.id))}/version${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };