export type CreateApiApiV1WWIdSearchArgs = {wId: string, body: {query: string, includeDataSources?: boolean | undefined, viewType?: string | undefined, spaceIds?: Array | undefined, nodeIds?: Array | undefined, searchSourceUrls?: boolean | undefined}}; export type CreateApiApiV1WWIdSearchOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Search for nodes in the workspace * * POST /api/v1/w/{wId}/search */ export const createApiApiV1WWIdSearch = async (args: CreateApiApiV1WWIdSearchArgs, options?: CreateApiApiV1WWIdSearchOptions) => { const {baseUrl = "https://dust.tt", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/w/${encodeURIComponent(String(args.wId))}/search${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 };