export type CreateApiCustomFieldsArgs = {body: {custom_field?: ({key: unknown, name?: string | undefined, section_name?: string | undefined, default_options?: Record | undefined, default_component?: string | undefined, applicable_model?: string | undefined, organization_id: unknown}) | undefined}}; export type CreateApiCustomFieldsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /custom_fields * * POST /custom_fields */ export const createApiCustomFields = async (args: CreateApiCustomFieldsArgs, options?: CreateApiCustomFieldsOptions) => { const {baseUrl = "https://api.example.test", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/custom_fields${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 };