import type { DefaultElements, ISO8601Timestamp, Link, MakeRequest, MakeRequestPayload, VersionedLink } from '../common-types'; import type { AsyncActionProcessingOptions } from '../methods/action'; /** Entity types supported by the BulkAction API */ type Entity = 'Entry' | 'Asset'; type Collection = Array; type EntityError = { entity: VersionedLink | Link; error: any; }; export type BulkActionType = 'publish' | 'unpublish' | 'validate'; /** Represents the state of the BulkAction */ export declare enum BulkActionStatus { /** BulkAction is pending execution */ created = "created", /** BulkAction has been started and pending completion */ inProgress = "inProgress", /** BulkAction was completed successfully (terminal state) */ succeeded = "succeeded", /** BulkAction failed to complete (terminal state) */ failed = "failed" } declare const STATUSES: BulkActionStatus[]; type BulkActionStatuses = (typeof STATUSES)[number]; interface BulkActionFailedError { sys: { type: 'Error'; id: 'BulkActionFailed'; }; message?: string; details?: { errors: Collection; }; } export type BulkActionPayload = BulkActionPublishPayload | BulkActionUnpublishPayload | BulkActionValidatePayload; export interface BulkActionValidatePayload extends MakeRequestPayload { action?: 'publish'; entities: { sys?: { type: 'Array'; }; items: Collection>; }; } export interface BulkActionUnpublishPayload extends MakeRequestPayload { entities: { sys?: { type: 'Array'; }; items: Collection>; }; } export interface BulkActionPublishPayload extends MakeRequestPayload { entities: { sys?: { type: 'Array'; }; items: Collection>; }; } export type BulkActionSysProps = { id: string; type: 'BulkAction'; status: BulkActionStatuses; space: Link<'Space'>; environment: Link<'Environment'>; createdBy: Link<'User'>; createdAt: ISO8601Timestamp; updatedAt: ISO8601Timestamp; }; /** The object returned by the BulkActions API */ export interface BulkActionProps { sys: BulkActionSysProps; action: BulkActionType; /** original payload when BulkAction was created */ payload: TPayload; /** error information, if present */ error?: BulkActionFailedError; } export interface BulkActionApiMethods { /** Performs a new GET request and returns the wrapper BulkAction */ get(): BulkAction; /** Waits until the BulkAction is in one of the final states (`succeeded` or `failed`) and returns it. */ waitProcessing(options?: AsyncActionProcessingOptions): Promise; } export interface BulkAction extends BulkActionProps, BulkActionApiMethods, DefaultElements> { } /** * @private * @param makeRequest - function to make requests via an adapter * @param data - Raw BulkAction data * @return Wrapped BulkAction data */ export declare function wrapBulkAction(makeRequest: MakeRequest, data: BulkActionProps): BulkAction; export {};