export type DeleteMemoriesRequest = {memory_ids: Array, user_id?: (string | null) | undefined}; export type DeleteApiMemoriesArgs = {db_id?: (string | null) | undefined, table?: (string | null) | undefined, body: DeleteMemoriesRequest}; export type DeleteApiMemoriesOptions = {baseUrl: string, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete Multiple Memories * * DELETE /memories */ export const deleteApiMemories = async (args: DeleteApiMemoriesArgs, options: DeleteApiMemoriesOptions) => { const {baseUrl, fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.db_id != null) query.append("db_id", String(args.db_id)) if (args.table != null) query.append("table", String(args.table)) if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/memories${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", 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 };