export type ColumnConfig = {preloadingDays?: number | undefined, priority?: number | undefined}; export type CreateApiSchemaTablesTableColumnsArgs = {table: string, body: {caseInsensitive?: boolean | undefined, config?: ColumnConfig | undefined, defaultValue?: string | undefined, deleted?: boolean | undefined, disableAutoExpand?: boolean | undefined, name?: string | undefined, type?: string | undefined, addToArchivingSortOrder?: boolean | undefined}}; export type CreateApiSchemaTablesTableColumnsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * add a single column to existing table * * POST /schema/tables/{table}/columns */ export const createApiSchemaTablesTableColumns = async (args: CreateApiSchemaTablesTableColumnsArgs, options: CreateApiSchemaTablesTableColumnsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/schema/tables/${encodeURIComponent(String(args.table))}/columns${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 };