export type CollectionItem = {itemId: string}; export type Collection = {collectionId: string, collectionName: string, items: Array}; export type UpdateApiCollectionsCollectionIdArgs = {collectionId: string, body: Collection}; export type UpdateApiCollectionsCollectionIdOptions = {baseUrl: string, userAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update collection properties. * * PUT /collections/{collectionId} * * Also accepts auth: adminAuth */ export const updateApiCollectionsCollectionId = async (args: UpdateApiCollectionsCollectionIdArgs, options: UpdateApiCollectionsCollectionIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, userAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (userAuth !== undefined) headers.set("authentication", userAuth) const url = `${baseUrl.replace(/\/+$/, '')}/collections/${encodeURIComponent(String(args.collectionId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };