export type CollectionContentSchema = {collection_id?: string | undefined, date_created?: string | undefined, object_id: string, object_type: string}; export type CreateApiV1CollectionsCollectionIdContentsArgs = {'App-ID': string, 'Auth-Token': string, collection_id: string, low_priority_indexing?: boolean | undefined, index_immediately?: boolean | undefined, body: CollectionContentSchema}; export type CreateApiV1CollectionsCollectionIdContentsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Add an object to a collection * * POST /v1/collections/{collection_id}/contents/ */ export const createApiV1CollectionsCollectionIdContents = async (args: CreateApiV1CollectionsCollectionIdContentsArgs, options: CreateApiV1CollectionsCollectionIdContentsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['App-ID'] != null) headers.set("App-ID", String(args['App-ID'])) if (args['Auth-Token'] != null) headers.set("Auth-Token", String(args['Auth-Token'])) if (args.low_priority_indexing != null) query.append("low_priority_indexing", String(args.low_priority_indexing)) if (args.index_immediately != null) query.append("index_immediately", String(args.index_immediately)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/collections/${encodeURIComponent(String(args.collection_id))}/contents/${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 };