1 | import type { DefaultElements, ISO8601Timestamp, Link, MakeRequest, MakeRequestPayload, VersionedLink } from '../common-types';
|
2 | import type { AsyncActionProcessingOptions } from '../methods/action';
|
3 |
|
4 | type Entity = 'Entry' | 'Asset';
|
5 | type Collection<T> = Array<T>;
|
6 | type EntityError = {
|
7 | entity: VersionedLink<Entity> | Link<Entity>;
|
8 | error: any;
|
9 | };
|
10 | export type BulkActionType = 'publish' | 'unpublish' | 'validate';
|
11 |
|
12 | export declare enum BulkActionStatus {
|
13 |
|
14 | created = "created",
|
15 |
|
16 | inProgress = "inProgress",
|
17 |
|
18 | succeeded = "succeeded",
|
19 |
|
20 | failed = "failed"
|
21 | }
|
22 | declare const STATUSES: BulkActionStatus[];
|
23 | type BulkActionStatuses = typeof STATUSES[number];
|
24 | interface BulkActionFailedError {
|
25 | sys: {
|
26 | type: 'Error';
|
27 | id: 'BulkActionFailed';
|
28 | };
|
29 | message?: string;
|
30 | details?: {
|
31 | errors: Collection<EntityError>;
|
32 | };
|
33 | }
|
34 | export type BulkActionPayload = BulkActionPublishPayload | BulkActionUnpublishPayload | BulkActionValidatePayload;
|
35 | export interface BulkActionValidatePayload extends MakeRequestPayload {
|
36 | action?: 'publish';
|
37 | entities: {
|
38 | sys?: {
|
39 | type: 'Array';
|
40 | };
|
41 | items: Collection<Link<Entity>>;
|
42 | };
|
43 | }
|
44 | export interface BulkActionUnpublishPayload extends MakeRequestPayload {
|
45 | entities: {
|
46 | sys?: {
|
47 | type: 'Array';
|
48 | };
|
49 | items: Collection<Link<Entity>>;
|
50 | };
|
51 | }
|
52 | export interface BulkActionPublishPayload extends MakeRequestPayload {
|
53 | entities: {
|
54 | sys?: {
|
55 | type: 'Array';
|
56 | };
|
57 | items: Collection<VersionedLink<Entity>>;
|
58 | };
|
59 | }
|
60 | export type BulkActionSysProps = {
|
61 | id: string;
|
62 | type: 'BulkAction';
|
63 | status: BulkActionStatuses;
|
64 | space: Link<'Space'>;
|
65 | environment: Link<'Environment'>;
|
66 | createdBy: Link<'User'>;
|
67 | createdAt: ISO8601Timestamp;
|
68 | updatedAt: ISO8601Timestamp;
|
69 | };
|
70 |
|
71 | export interface BulkActionProps<TPayload extends BulkActionPayload = any> {
|
72 | sys: BulkActionSysProps;
|
73 | action: BulkActionType;
|
74 |
|
75 | payload: TPayload;
|
76 |
|
77 | error?: BulkActionFailedError;
|
78 | }
|
79 | export interface BulkActionApiMethods {
|
80 |
|
81 | get(): BulkAction;
|
82 |
|
83 | waitProcessing(options?: AsyncActionProcessingOptions): Promise<BulkAction>;
|
84 | }
|
85 | export interface BulkAction<T extends BulkActionPayload = any> extends BulkActionProps<T>, BulkActionApiMethods, DefaultElements<BulkActionProps<T>> {
|
86 | }
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 | export declare function wrapBulkAction<TPayload extends BulkActionPayload = any>(makeRequest: MakeRequest, data: BulkActionProps<BulkActionPayload>): BulkAction<TPayload>;
|
94 | export {};
|