export type CreateApiFileConfigArgs = {'X-Auth-Token': string, 'X-Transaction-ID'?: string | undefined, body: BodyInit}; export type CreateApiFileConfigOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Upload configure file * * POST /file/config */ export const createApiFileConfig = async (args: CreateApiFileConfigArgs, options: CreateApiFileConfigOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['X-Auth-Token'] != null) headers.set("X-Auth-Token", String(args['X-Auth-Token'])) if (args['X-Transaction-ID'] != null) headers.set("X-Transaction-ID", String(args['X-Transaction-ID'])) const url = `${baseUrl.replace(/\/+$/, '')}/file/config${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };