@@ -69,6 +69,49 @@ export interface BulkActionPublishPayload extends MakeRequestPayload {
6969 }
7070}
7171
72+ interface AddFieldsEntity < L extends Link < Entity > | VersionedLink < Entity > > {
73+ entity : L
74+ add ?: {
75+ fields : Record < '*' , string [ ] >
76+ }
77+ }
78+
79+ interface RemoveFieldsEntity < L extends Link < Entity > | VersionedLink < Entity > > {
80+ entity : L
81+ remove ?: {
82+ fields : Record < '*' , string [ ] >
83+ }
84+ }
85+ type BulkActionEntity < L extends Link < Entity > | VersionedLink < Entity > > = {
86+ entity : L
87+ }
88+
89+ export interface PublishBulkActionV2Payload < PublishActionType extends 'add' | 'remove' = 'add' > {
90+ action : 'publish'
91+ entities : PublishActionType extends 'remove'
92+ ? RemoveFieldsEntity < VersionedLink < Entity > > [ ]
93+ : AddFieldsEntity < VersionedLink < Entity > > [ ]
94+ }
95+
96+ export interface ValidateBulkActionV2Payload < PublishActionType extends 'add' | 'remove' = 'add' > {
97+ action : 'validate'
98+ entities : PublishActionType extends 'remove'
99+ ? RemoveFieldsEntity < Link < Entity > > [ ]
100+ : AddFieldsEntity < Link < Entity > > [ ]
101+ }
102+
103+ export interface UnpublishBulkActionV2Payload {
104+ action : 'unpublish'
105+ entities : BulkActionEntity < Link < Entity > > [ ]
106+ }
107+
108+ export type BulkActionV2Payload =
109+ | PublishBulkActionV2Payload < 'add' >
110+ | PublishBulkActionV2Payload < 'remove' >
111+ | UnpublishBulkActionV2Payload
112+ | ValidateBulkActionV2Payload < 'add' >
113+ | ValidateBulkActionV2Payload < 'remove' >
114+
72115export type BulkActionSysProps = {
73116 id : string
74117 type : 'BulkAction'
@@ -81,7 +124,7 @@ export type BulkActionSysProps = {
81124}
82125
83126/** The object returned by the BulkActions API */
84- export interface BulkActionProps < TPayload extends BulkActionPayload = any > {
127+ export interface BulkActionProps < TPayload extends BulkActionPayload | BulkActionV2Payload = any > {
85128 sys : BulkActionSysProps
86129 action : BulkActionType
87130 /** original payload when BulkAction was created */
@@ -120,15 +163,15 @@ function createBulkActionApi(makeRequest: MakeRequest) {
120163 params,
121164 } ) . then ( ( bulkAction ) => wrapBulkAction ( makeRequest , bulkAction ) )
122165 } ,
123- async waitProcessing < TPayload extends BulkActionPayload = any > (
166+ async waitProcessing < TPayload extends BulkActionPayload | BulkActionV2Payload = any > (
124167 options ?: AsyncActionProcessingOptions ,
125168 ) : Promise < BulkActionProps < TPayload > > {
126169 return pollAsyncActionStatus < BulkActionProps < TPayload > > ( async ( ) => this . get ( ) , options )
127170 } ,
128171 }
129172}
130173
131- export interface BulkAction < T extends BulkActionPayload = any >
174+ export interface BulkAction < T extends BulkActionPayload | BulkActionV2Payload = any >
132175 extends BulkActionProps < T > ,
133176 BulkActionApiMethods ,
134177 DefaultElements < BulkActionProps < T > > { }
@@ -139,9 +182,9 @@ export interface BulkAction<T extends BulkActionPayload = any>
139182 * @param data - Raw BulkAction data
140183 * @return Wrapped BulkAction data
141184 */
142- export function wrapBulkAction < TPayload extends BulkActionPayload = any > (
185+ export function wrapBulkAction < TPayload extends BulkActionPayload | BulkActionV2Payload = any > (
143186 makeRequest : MakeRequest ,
144- data : BulkActionProps < BulkActionPayload > ,
187+ data : BulkActionProps < BulkActionPayload | BulkActionV2Payload > ,
145188) : BulkAction < TPayload > {
146189 const bulkAction = toPlainObject ( copy ( data ) )
147190 const bulkActionWithApiMethods = enhanceWithMethods (
0 commit comments