export type DefaultSpecification = Record; export type Pageable = {page?: number | undefined, size?: number | undefined, sort?: Array | undefined}; export type GetApiBulkOperationsArgs = {specification: DefaultSpecification, pageable: Pageable, fields?: Array<'NONE'> | undefined}; export type GetApiBulkOperationsOptions = {baseUrl?: string | undefined, authToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * List bulk operations * * GET /bulk-operations */ export const getApiBulkOperations = async (args: GetApiBulkOperationsArgs, options?: GetApiBulkOperationsOptions) => { const {baseUrl = "https://commerce_studio_id.experiencemanager.lucidworks.com", fetch: fetchFn = fetch, authToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.specification != null) query.append("specification", JSON.stringify(args.specification)) if (args.pageable != null) query.append("pageable", JSON.stringify(args.pageable)) for (const item of args.fields ?? []) query.append("fields", String(item)) if (authToken !== undefined) headers.set('authorization', `Bearer ${authToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/bulk-operations${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 res.blob() };