export type GetApiApiV1WorkspacesSlugCollectionsSearchArgs = {q: string, status: string, include_archived: string, owner: string, updated_after: string, limit: string, cursor: string}; export type GetApiApiV1WorkspacesSlugCollectionsSearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /api/v1/workspaces/{slug}/collections/search */ export const getApiApiV1WorkspacesSlugCollectionsSearch = async (args: GetApiApiV1WorkspacesSlugCollectionsSearchArgs, options?: GetApiApiV1WorkspacesSlugCollectionsSearchOptions) => { const {baseUrl = "https://api.trybrein.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.q != null) query.append("q", String(args.q)) if (args.status != null) query.append("status", String(args.status)) if (args.include_archived != null) query.append("include_archived", String(args.include_archived)) if (args.owner != null) query.append("owner", String(args.owner)) if (args.updated_after != null) query.append("updated_after", String(args.updated_after)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.cursor != null) query.append("cursor", String(args.cursor)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/workspaces/${encodeURIComponent(String(args.slug))}/collections/search${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 undefined };