@@ -40,65 +40,65 @@ export const bulkActionHandlers = {
40
40
const environmentId = process . env . ENVIRONMENT_ID || args . environmentId
41
41
42
42
const contentfulClient = await getContentfulClient ( )
43
-
43
+
44
44
// Create the bulk action
45
45
const bulkAction = await contentfulClient . bulkAction . publish (
46
46
{
47
47
spaceId,
48
48
environmentId,
49
- } ,
49
+ } ,
50
50
{
51
51
entities : {
52
52
sys : {
53
53
type : "Array" ,
54
54
} ,
55
- items : args . entities . map ( entity => ( {
55
+ items : args . entities . map ( ( entity ) => ( {
56
56
sys : {
57
57
type : "Link" ,
58
58
linkType : entity . sys . type ,
59
- id : entity . sys . id
60
- }
59
+ id : entity . sys . id ,
60
+ } ,
61
61
} ) ) ,
62
62
} ,
63
- }
63
+ } ,
64
64
)
65
-
65
+
66
66
// Wait for the bulk action to complete
67
- let action = await contentfulClient . bulkAction . get ( {
67
+ let action = ( await contentfulClient . bulkAction . get ( {
68
68
spaceId,
69
69
environmentId,
70
- bulkActionId : bulkAction . sys . id
71
- } ) as unknown as BulkActionResponse
72
-
70
+ bulkActionId : bulkAction . sys . id ,
71
+ } ) ) as unknown as BulkActionResponse
72
+
73
73
while ( action . sys . status === "inProgress" || action . sys . status === "created" ) {
74
- await new Promise ( resolve => setTimeout ( resolve , 1000 ) )
75
- action = await contentfulClient . bulkAction . get ( {
74
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) )
75
+ action = ( await contentfulClient . bulkAction . get ( {
76
76
spaceId,
77
77
environmentId,
78
- bulkActionId : bulkAction . sys . id
79
- } ) as unknown as BulkActionResponse
78
+ bulkActionId : bulkAction . sys . id ,
79
+ } ) ) as unknown as BulkActionResponse
80
80
}
81
-
81
+
82
82
return {
83
83
content : [
84
- {
85
- type : "text" ,
84
+ {
85
+ type : "text" ,
86
86
text : `Bulk publish completed with status: ${ action . sys . status } . ${
87
- action . sys . status === "failed"
88
- ? `Error: ${ JSON . stringify ( action . error ) } `
87
+ action . sys . status === "failed"
88
+ ? `Error: ${ JSON . stringify ( action . error ) } `
89
89
: `Successfully processed ${ action . succeeded ?. length || 0 } items.`
90
- } `
91
- }
90
+ } `,
91
+ } ,
92
92
] ,
93
93
}
94
94
} ,
95
-
95
+
96
96
bulkUnpublish : async ( args : BulkUnpublishParams ) => {
97
97
const spaceId = process . env . SPACE_ID || args . spaceId
98
98
const environmentId = process . env . ENVIRONMENT_ID || args . environmentId
99
99
100
100
const contentfulClient = await getContentfulClient ( )
101
-
101
+
102
102
// Create the bulk action
103
103
const bulkAction = await contentfulClient . bulkAction . unpublish (
104
104
{
@@ -110,53 +110,53 @@ export const bulkActionHandlers = {
110
110
sys : {
111
111
type : "Array" ,
112
112
} ,
113
- items : args . entities . map ( entity => ( {
113
+ items : args . entities . map ( ( entity ) => ( {
114
114
sys : {
115
115
type : "Link" ,
116
116
linkType : entity . sys . type ,
117
- id : entity . sys . id
118
- }
117
+ id : entity . sys . id ,
118
+ } ,
119
119
} ) ) ,
120
120
} ,
121
- }
121
+ } ,
122
122
)
123
-
123
+
124
124
// Wait for the bulk action to complete
125
- let action = await contentfulClient . bulkAction . get ( {
125
+ let action = ( await contentfulClient . bulkAction . get ( {
126
126
spaceId,
127
127
environmentId,
128
- bulkActionId : bulkAction . sys . id
129
- } ) as unknown as BulkActionResponse
130
-
128
+ bulkActionId : bulkAction . sys . id ,
129
+ } ) ) as unknown as BulkActionResponse
130
+
131
131
while ( action . sys . status === "inProgress" || action . sys . status === "created" ) {
132
- await new Promise ( resolve => setTimeout ( resolve , 1000 ) )
133
- action = await contentfulClient . bulkAction . get ( {
132
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) )
133
+ action = ( await contentfulClient . bulkAction . get ( {
134
134
spaceId,
135
135
environmentId,
136
- bulkActionId : bulkAction . sys . id
137
- } ) as unknown as BulkActionResponse
136
+ bulkActionId : bulkAction . sys . id ,
137
+ } ) ) as unknown as BulkActionResponse
138
138
}
139
-
139
+
140
140
return {
141
141
content : [
142
- {
143
- type : "text" ,
142
+ {
143
+ type : "text" ,
144
144
text : `Bulk unpublish completed with status: ${ action . sys . status } . ${
145
- action . sys . status === "failed"
146
- ? `Error: ${ JSON . stringify ( action . error ) } `
145
+ action . sys . status === "failed"
146
+ ? `Error: ${ JSON . stringify ( action . error ) } `
147
147
: `Successfully processed ${ action . succeeded ?. length || 0 } items.`
148
- } `
149
- }
148
+ } `,
149
+ } ,
150
150
] ,
151
151
}
152
152
} ,
153
-
153
+
154
154
bulkValidate : async ( args : BulkValidateParams ) => {
155
155
const spaceId = process . env . SPACE_ID || args . spaceId
156
156
const environmentId = process . env . ENVIRONMENT_ID || args . environmentId
157
157
158
158
const contentfulClient = await getContentfulClient ( )
159
-
159
+
160
160
// Create the bulk action
161
161
const bulkAction = await contentfulClient . bulkAction . validate (
162
162
{
@@ -168,44 +168,44 @@ export const bulkActionHandlers = {
168
168
sys : {
169
169
type : "Array" ,
170
170
} ,
171
- items : args . entryIds . map ( id => ( {
171
+ items : args . entryIds . map ( ( id ) => ( {
172
172
sys : {
173
173
type : "Link" ,
174
174
linkType : "Entry" ,
175
- id
176
- }
175
+ id,
176
+ } ,
177
177
} ) ) ,
178
178
} ,
179
- }
179
+ } ,
180
180
)
181
-
181
+
182
182
// Wait for the bulk action to complete
183
- let action = await contentfulClient . bulkAction . get ( {
183
+ let action = ( await contentfulClient . bulkAction . get ( {
184
184
spaceId,
185
185
environmentId,
186
- bulkActionId : bulkAction . sys . id
187
- } ) as unknown as BulkActionResponse
188
-
186
+ bulkActionId : bulkAction . sys . id ,
187
+ } ) ) as unknown as BulkActionResponse
188
+
189
189
while ( action . sys . status === "inProgress" || action . sys . status === "created" ) {
190
- await new Promise ( resolve => setTimeout ( resolve , 1000 ) )
191
- action = await contentfulClient . bulkAction . get ( {
190
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) )
191
+ action = ( await contentfulClient . bulkAction . get ( {
192
192
spaceId,
193
193
environmentId,
194
- bulkActionId : bulkAction . sys . id
195
- } ) as unknown as BulkActionResponse
194
+ bulkActionId : bulkAction . sys . id ,
195
+ } ) ) as unknown as BulkActionResponse
196
196
}
197
-
197
+
198
198
return {
199
199
content : [
200
- {
201
- type : "text" ,
200
+ {
201
+ type : "text" ,
202
202
text : `Bulk validation completed with status: ${ action . sys . status } . ${
203
- action . sys . status === "failed"
204
- ? `Error: ${ JSON . stringify ( action . error ) } `
203
+ action . sys . status === "failed"
204
+ ? `Error: ${ JSON . stringify ( action . error ) } `
205
205
: `Successfully validated ${ action . succeeded ?. length || 0 } entries.`
206
- } `
207
- }
206
+ } `,
207
+ } ,
208
208
] ,
209
209
}
210
- }
210
+ } ,
211
211
}
0 commit comments