export type SharingRole = 'editandshare' | 'edit' | 'comment' | 'view'; export type CreateApiV1DocumentsIdRequestAccessArgs = {id: string, body: {role: SharingRole, message: string}}; export type CreateApiV1DocumentsIdRequestAccessOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Request Document Access * * POST /v1/documents/{id}/requestAccess * * Also accepts auth: OAuth2 */ export const createApiV1DocumentsIdRequestAccess = async (args: CreateApiV1DocumentsIdRequestAccessArgs, options?: CreateApiV1DocumentsIdRequestAccessOptions) => { const {baseUrl = "https://api.lucid.co", 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', `Bearer ${ApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/documents/${encodeURIComponent(String(args.id))}/requestAccess${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 };