export type GetApiV1DocumentsPickerArgs = {token: string, allowDocumentCreation?: boolean | undefined, autoSelectCreatedDocument?: boolean | undefined, newDocumentTitleSuggestion?: string | undefined, hideCancelButton?: boolean | undefined, onErrorRedirect?: string | undefined}; export type GetApiV1DocumentsPickerOptions = {baseUrl?: string | undefined, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Embedded Document Picker * * GET /v1/documents/picker */ export const getApiV1DocumentsPicker = async (args: GetApiV1DocumentsPickerArgs, options?: GetApiV1DocumentsPickerOptions) => { const {baseUrl = "https://lucid.app", fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/html") if (args.token != null) query.append("token", String(args.token)) if (args.allowDocumentCreation != null) query.append("allowDocumentCreation", String(args.allowDocumentCreation)) if (args.autoSelectCreatedDocument != null) query.append("autoSelectCreatedDocument", String(args.autoSelectCreatedDocument)) if (args.newDocumentTitleSuggestion != null) query.append("newDocumentTitleSuggestion", String(args.newDocumentTitleSuggestion)) if (args.hideCancelButton != null) query.append("hideCancelButton", String(args.hideCancelButton)) if (args.onErrorRedirect != null) query.append("onErrorRedirect", String(args.onErrorRedirect)) if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/documents/picker${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };