export type CreateApiLinksPageArgs = {body: {DomainId: number, path?: string | undefined, title?: string | undefined, prompt: string}}; export type CreateApiLinksPageOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create AI page * * POST /links/page */ export const createApiLinksPage = async (args: CreateApiLinksPageArgs, options?: CreateApiLinksPageOptions) => { const {baseUrl = "https://api.short.io", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/links/page${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 };