export type RuleSpecification = {searchQuery?: string | undefined, tags?: Array | undefined, groups?: Array | undefined, types?: Array | undefined, publishState?: ('DRAFT' | 'PUBLISHED' | 'PUBLISHED_WITH_DRAFT_EDITS') | undefined, published?: boolean | undefined, targetedDocumentId?: string | undefined, targetedDocumentIdField?: string | undefined, activeDateStart?: string | undefined, activeDateEnd?: string | undefined, expirationDateStart?: string | undefined, expirationDateEnd?: string | undefined, lastModifiedStart?: string | undefined, lastModifiedEnd?: string | undefined, createdStart?: string | undefined, createdEnd?: string | undefined, contentType?: ('RULE' | 'QUERY_REWRITE') | undefined}; export type DeleteRuleBulkOperationRequest = {type: 'deleteRule', ruleIds?: Array | undefined, ruleExternalIds?: Array | undefined, excludeRuleIds?: Array | undefined, excludeRuleExternalIds?: Array | undefined, specification?: RuleSpecification | undefined}; export type JsonNode = Record; export type EditRuleBulkOperationRequest = {type: 'editRule', ruleIds?: Array | undefined, ruleExternalIds?: Array | undefined, excludeRuleIds?: Array | undefined, excludeRuleExternalIds?: Array | undefined, specification?: RuleSpecification | undefined, patch: JsonNode, stageChanges?: boolean | undefined}; export type MigrateRuleBulkOperationRequest = {type: 'migrateRule', ruleIds?: Array | undefined, ruleExternalIds?: Array | undefined, excludeRuleIds?: Array | undefined, excludeRuleExternalIds?: Array | undefined, specification?: RuleSpecification | undefined, targetExperienceManagerInstanceId: string, published?: boolean | undefined}; export type PublishRuleBulkOperationRequest = {type: 'publishRule', ruleIds?: Array | undefined, ruleExternalIds?: Array | undefined, excludeRuleIds?: Array | undefined, excludeRuleExternalIds?: Array | undefined, specification?: RuleSpecification | undefined}; export type UnpublishRuleBulkOperationRequest = {type: 'unpublishRule', ruleIds?: Array | undefined, ruleExternalIds?: Array | undefined, excludeRuleIds?: Array | undefined, excludeRuleExternalIds?: Array | undefined, specification?: RuleSpecification | undefined}; export type UpdateApiBulkOperationsIdArgs = {id: string, 'If-Match'?: string | undefined, fields?: Array<'NONE'> | undefined, body: DeleteRuleBulkOperationRequest | EditRuleBulkOperationRequest | MigrateRuleBulkOperationRequest | PublishRuleBulkOperationRequest | UnpublishRuleBulkOperationRequest}; export type UpdateApiBulkOperationsIdOptions = {baseUrl?: string | undefined, authToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update bulk operation * * PUT /bulk-operations/{id} */ export const updateApiBulkOperationsId = async (args: UpdateApiBulkOperationsIdArgs, options?: UpdateApiBulkOperationsIdOptions) => { const {baseUrl = "https://commerce_studio_id.experiencemanager.lucidworks.com", fetch: fetchFn = fetch, authToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (args['If-Match'] != null) headers.set("If-Match", String(args['If-Match'])) 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/${encodeURIComponent(String(args.id))}${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 res.blob() };