export type PageContainerEntryView = {identifier: string, uuid: string, contentletsId: Array, personaTag?: (string | null) | undefined}; export type CreateApiApiV1PagePageIdContentArgs = {pageId: string, variantName?: string | undefined, body: Array}; export type CreateApiApiV1PagePageIdContentOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Replace the content mapping of a page * * POST /api/v1/page/{pageId}/content */ export const createApiApiV1PagePageIdContent = async (args: CreateApiApiV1PagePageIdContentArgs, options: CreateApiApiV1PagePageIdContentOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.variantName != null) query.append("variantName", String(args.variantName)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/page/${encodeURIComponent(String(args.pageId))}/content${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 (await res.json()) as unknown };