strapi-plugin-bulk-updater 1.6.7 → 1.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{BulkUpdater-vPg_CrwY.mjs → BulkUpdater-4E6M5K8J.mjs} +84 -35
- package/dist/_chunks/BulkUpdater-4E6M5K8J.mjs.map +1 -0
- package/dist/_chunks/{BulkUpdater-Bs4BXQlU.js → BulkUpdater-CKDhgvZ6.js} +84 -35
- package/dist/_chunks/BulkUpdater-CKDhgvZ6.js.map +1 -0
- package/dist/_chunks/{SettingsPage-D2qYhqpF.mjs → SettingsPage-BX9sCRmw.mjs} +9 -5
- package/dist/_chunks/SettingsPage-BX9sCRmw.mjs.map +1 -0
- package/dist/_chunks/{SettingsPage-Dv2DRplw.js → SettingsPage-Crh2syU4.js} +7 -3
- package/dist/_chunks/SettingsPage-Crh2syU4.js.map +1 -0
- package/dist/_chunks/{ValidationRulesTab-BtOCWK8E.mjs → ValidationRulesTab-BqbENLpg.mjs} +144 -33
- package/dist/_chunks/ValidationRulesTab-BqbENLpg.mjs.map +1 -0
- package/dist/_chunks/{ValidationRulesTab-BTm3QXxM.js → ValidationRulesTab-R1vlW2wY.js} +139 -28
- package/dist/_chunks/ValidationRulesTab-R1vlW2wY.js.map +1 -0
- package/dist/admin/index.js +14 -4
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +14 -4
- package/dist/admin/index.mjs.map +1 -1
- package/dist/server/index.js +291 -32
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +291 -32
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/_chunks/BulkUpdater-Bs4BXQlU.js.map +0 -1
- package/dist/_chunks/BulkUpdater-vPg_CrwY.mjs.map +0 -1
- package/dist/_chunks/SettingsPage-D2qYhqpF.mjs.map +0 -1
- package/dist/_chunks/SettingsPage-Dv2DRplw.js.map +0 -1
- package/dist/_chunks/ValidationRulesTab-BTm3QXxM.js.map +0 -1
- package/dist/_chunks/ValidationRulesTab-BtOCWK8E.mjs.map +0 -1
package/dist/server/index.mjs
CHANGED
|
@@ -1,5 +1,156 @@
|
|
|
1
1
|
import crypto from "crypto";
|
|
2
2
|
import { errors } from "@strapi/utils";
|
|
3
|
+
const PLUGIN_ID = "bulk-updater";
|
|
4
|
+
const PERMISSIONS = {
|
|
5
|
+
// General
|
|
6
|
+
read: `plugin::${PLUGIN_ID}.read`,
|
|
7
|
+
// Workspace
|
|
8
|
+
workspaceView: `plugin::${PLUGIN_ID}.workspace.view`,
|
|
9
|
+
workspaceExecute: `plugin::${PLUGIN_ID}.workspace.execute`,
|
|
10
|
+
workspacePublish: `plugin::${PLUGIN_ID}.workspace.publish`,
|
|
11
|
+
// CSV Management
|
|
12
|
+
csvExport: `plugin::${PLUGIN_ID}.csv.export`,
|
|
13
|
+
csvImport: `plugin::${PLUGIN_ID}.csv.import`,
|
|
14
|
+
// Audit Trail
|
|
15
|
+
auditView: `plugin::${PLUGIN_ID}.audit.view`,
|
|
16
|
+
auditDetails: `plugin::${PLUGIN_ID}.audit.details`,
|
|
17
|
+
auditRollback: `plugin::${PLUGIN_ID}.audit.rollback`,
|
|
18
|
+
// Approvals (Maker-Checker)
|
|
19
|
+
approvalView: `plugin::${PLUGIN_ID}.approval.view`,
|
|
20
|
+
approvalApprove: `plugin::${PLUGIN_ID}.approval.approve`,
|
|
21
|
+
approvalReject: `plugin::${PLUGIN_ID}.approval.reject`,
|
|
22
|
+
// Validation Rules
|
|
23
|
+
validationView: `plugin::${PLUGIN_ID}.validation.view`,
|
|
24
|
+
validationManage: `plugin::${PLUGIN_ID}.validation.manage`,
|
|
25
|
+
// Settings
|
|
26
|
+
settingsView: `plugin::${PLUGIN_ID}.settings.view`,
|
|
27
|
+
settingsManage: `plugin::${PLUGIN_ID}.settings.manage`
|
|
28
|
+
};
|
|
29
|
+
const BULK_UPDATER_PERMISSION_ACTIONS = [
|
|
30
|
+
{
|
|
31
|
+
section: "plugins",
|
|
32
|
+
displayName: "Access Bulk Updater Plugin",
|
|
33
|
+
uid: "read",
|
|
34
|
+
pluginName: PLUGIN_ID,
|
|
35
|
+
subCategory: "General"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
section: "plugins",
|
|
39
|
+
displayName: "View Workspace & Collections",
|
|
40
|
+
uid: "workspace.view",
|
|
41
|
+
pluginName: PLUGIN_ID,
|
|
42
|
+
subCategory: "Workspace"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
section: "plugins",
|
|
46
|
+
displayName: "Execute Bulk Updates",
|
|
47
|
+
uid: "workspace.execute",
|
|
48
|
+
pluginName: PLUGIN_ID,
|
|
49
|
+
subCategory: "Workspace"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
section: "plugins",
|
|
53
|
+
displayName: "Execute Bulk Publishing",
|
|
54
|
+
uid: "workspace.publish",
|
|
55
|
+
pluginName: PLUGIN_ID,
|
|
56
|
+
subCategory: "Workspace"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
section: "plugins",
|
|
60
|
+
displayName: "Export CSV & Templates",
|
|
61
|
+
uid: "csv.export",
|
|
62
|
+
pluginName: PLUGIN_ID,
|
|
63
|
+
subCategory: "CSV Management"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
section: "plugins",
|
|
67
|
+
displayName: "Import CSV & Validate Preflight",
|
|
68
|
+
uid: "csv.import",
|
|
69
|
+
pluginName: PLUGIN_ID,
|
|
70
|
+
subCategory: "CSV Management"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
section: "plugins",
|
|
74
|
+
displayName: "View Audit History",
|
|
75
|
+
uid: "audit.view",
|
|
76
|
+
pluginName: PLUGIN_ID,
|
|
77
|
+
subCategory: "Audit Trail"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
section: "plugins",
|
|
81
|
+
displayName: "View Audit Details & Diffs",
|
|
82
|
+
uid: "audit.details",
|
|
83
|
+
pluginName: PLUGIN_ID,
|
|
84
|
+
subCategory: "Audit Trail"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
section: "plugins",
|
|
88
|
+
displayName: "Execute Batch Rollback",
|
|
89
|
+
uid: "audit.rollback",
|
|
90
|
+
pluginName: PLUGIN_ID,
|
|
91
|
+
subCategory: "Audit Trail"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
section: "plugins",
|
|
95
|
+
displayName: "View Pending Batches for Review",
|
|
96
|
+
uid: "approval.view",
|
|
97
|
+
pluginName: PLUGIN_ID,
|
|
98
|
+
subCategory: "Approvals"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
section: "plugins",
|
|
102
|
+
displayName: "Approve Batches & Execute Now",
|
|
103
|
+
uid: "approval.approve",
|
|
104
|
+
pluginName: PLUGIN_ID,
|
|
105
|
+
subCategory: "Approvals"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
section: "plugins",
|
|
109
|
+
displayName: "Reject Pending Batches",
|
|
110
|
+
uid: "approval.reject",
|
|
111
|
+
pluginName: PLUGIN_ID,
|
|
112
|
+
subCategory: "Approvals"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
section: "plugins",
|
|
116
|
+
displayName: "View Validation Rules & Scan Violations",
|
|
117
|
+
uid: "validation.view",
|
|
118
|
+
pluginName: PLUGIN_ID,
|
|
119
|
+
subCategory: "Validation Rules"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
section: "plugins",
|
|
123
|
+
displayName: "Create, Edit, Toggle & Delete Validation Rules",
|
|
124
|
+
uid: "validation.manage",
|
|
125
|
+
pluginName: PLUGIN_ID,
|
|
126
|
+
subCategory: "Validation Rules"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
section: "plugins",
|
|
130
|
+
displayName: "View Plugin Settings",
|
|
131
|
+
uid: "settings.view",
|
|
132
|
+
pluginName: PLUGIN_ID,
|
|
133
|
+
subCategory: "Settings"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
section: "plugins",
|
|
137
|
+
displayName: "Manage Plugin Settings",
|
|
138
|
+
uid: "settings.manage",
|
|
139
|
+
pluginName: PLUGIN_ID,
|
|
140
|
+
subCategory: "Settings"
|
|
141
|
+
}
|
|
142
|
+
];
|
|
143
|
+
function requirePermissions(actions, mode = "all") {
|
|
144
|
+
return [
|
|
145
|
+
{
|
|
146
|
+
name: "plugin::bulk-updater.hasPermissions",
|
|
147
|
+
config: {
|
|
148
|
+
actions: Array.isArray(actions) ? actions : [actions],
|
|
149
|
+
mode
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
];
|
|
153
|
+
}
|
|
3
154
|
const routes = {
|
|
4
155
|
admin: {
|
|
5
156
|
type: "admin",
|
|
@@ -9,7 +160,15 @@ const routes = {
|
|
|
9
160
|
path: "/models",
|
|
10
161
|
handler: "bulkUpdater.getModels",
|
|
11
162
|
config: {
|
|
12
|
-
policies:
|
|
163
|
+
policies: requirePermissions(
|
|
164
|
+
[
|
|
165
|
+
PERMISSIONS.workspaceView,
|
|
166
|
+
PERMISSIONS.csvExport,
|
|
167
|
+
PERMISSIONS.csvImport,
|
|
168
|
+
PERMISSIONS.validationView
|
|
169
|
+
],
|
|
170
|
+
"any"
|
|
171
|
+
)
|
|
13
172
|
}
|
|
14
173
|
},
|
|
15
174
|
{
|
|
@@ -17,7 +176,10 @@ const routes = {
|
|
|
17
176
|
path: "/collections/:uid/entries",
|
|
18
177
|
handler: "bulkUpdater.getCollectionEntries",
|
|
19
178
|
config: {
|
|
20
|
-
policies:
|
|
179
|
+
policies: requirePermissions(
|
|
180
|
+
[PERMISSIONS.workspaceView, PERMISSIONS.csvExport, PERMISSIONS.csvImport],
|
|
181
|
+
"any"
|
|
182
|
+
)
|
|
21
183
|
}
|
|
22
184
|
},
|
|
23
185
|
{
|
|
@@ -25,7 +187,10 @@ const routes = {
|
|
|
25
187
|
path: "/relation-options",
|
|
26
188
|
handler: "bulkUpdater.getRelationOptions",
|
|
27
189
|
config: {
|
|
28
|
-
policies:
|
|
190
|
+
policies: requirePermissions(
|
|
191
|
+
[PERMISSIONS.workspaceView, PERMISSIONS.csvExport, PERMISSIONS.csvImport],
|
|
192
|
+
"any"
|
|
193
|
+
)
|
|
29
194
|
}
|
|
30
195
|
},
|
|
31
196
|
{
|
|
@@ -33,7 +198,10 @@ const routes = {
|
|
|
33
198
|
path: "/media-options",
|
|
34
199
|
handler: "bulkUpdater.getMediaOptions",
|
|
35
200
|
config: {
|
|
36
|
-
policies:
|
|
201
|
+
policies: requirePermissions(
|
|
202
|
+
[PERMISSIONS.workspaceView, PERMISSIONS.csvExport, PERMISSIONS.csvImport],
|
|
203
|
+
"any"
|
|
204
|
+
)
|
|
37
205
|
}
|
|
38
206
|
},
|
|
39
207
|
{
|
|
@@ -41,7 +209,7 @@ const routes = {
|
|
|
41
209
|
path: "/batch-update",
|
|
42
210
|
handler: "bulkUpdater.batchUpdate",
|
|
43
211
|
config: {
|
|
44
|
-
policies:
|
|
212
|
+
policies: requirePermissions(PERMISSIONS.workspaceExecute)
|
|
45
213
|
}
|
|
46
214
|
},
|
|
47
215
|
{
|
|
@@ -49,7 +217,7 @@ const routes = {
|
|
|
49
217
|
path: "/batch-publish",
|
|
50
218
|
handler: "bulkUpdater.batchPublish",
|
|
51
219
|
config: {
|
|
52
|
-
policies:
|
|
220
|
+
policies: requirePermissions(PERMISSIONS.workspacePublish)
|
|
53
221
|
}
|
|
54
222
|
},
|
|
55
223
|
{
|
|
@@ -57,7 +225,7 @@ const routes = {
|
|
|
57
225
|
path: "/preview",
|
|
58
226
|
handler: "bulkUpdater.previewBatch",
|
|
59
227
|
config: {
|
|
60
|
-
policies:
|
|
228
|
+
policies: requirePermissions(PERMISSIONS.workspaceExecute)
|
|
61
229
|
}
|
|
62
230
|
},
|
|
63
231
|
{
|
|
@@ -65,7 +233,7 @@ const routes = {
|
|
|
65
233
|
path: "/pending-batches",
|
|
66
234
|
handler: "bulkUpdater.getPendingBatches",
|
|
67
235
|
config: {
|
|
68
|
-
policies:
|
|
236
|
+
policies: requirePermissions(PERMISSIONS.approvalView)
|
|
69
237
|
}
|
|
70
238
|
},
|
|
71
239
|
{
|
|
@@ -73,7 +241,7 @@ const routes = {
|
|
|
73
241
|
path: "/batches/:batchId/approve",
|
|
74
242
|
handler: "bulkUpdater.approveBatch",
|
|
75
243
|
config: {
|
|
76
|
-
policies:
|
|
244
|
+
policies: requirePermissions(PERMISSIONS.approvalApprove)
|
|
77
245
|
}
|
|
78
246
|
},
|
|
79
247
|
{
|
|
@@ -81,7 +249,7 @@ const routes = {
|
|
|
81
249
|
path: "/batches/:batchId/reject",
|
|
82
250
|
handler: "bulkUpdater.rejectBatch",
|
|
83
251
|
config: {
|
|
84
|
-
policies:
|
|
252
|
+
policies: requirePermissions(PERMISSIONS.approvalReject)
|
|
85
253
|
}
|
|
86
254
|
},
|
|
87
255
|
{
|
|
@@ -89,7 +257,7 @@ const routes = {
|
|
|
89
257
|
path: "/batches/:batchId/execute-now",
|
|
90
258
|
handler: "bulkUpdater.executeNow",
|
|
91
259
|
config: {
|
|
92
|
-
policies:
|
|
260
|
+
policies: requirePermissions(PERMISSIONS.approvalApprove)
|
|
93
261
|
}
|
|
94
262
|
},
|
|
95
263
|
{
|
|
@@ -97,7 +265,10 @@ const routes = {
|
|
|
97
265
|
path: "/batches/recent",
|
|
98
266
|
handler: "bulkUpdater.getRecentBatches",
|
|
99
267
|
config: {
|
|
100
|
-
policies:
|
|
268
|
+
policies: requirePermissions(
|
|
269
|
+
[PERMISSIONS.workspaceView, PERMISSIONS.auditView, PERMISSIONS.approvalView],
|
|
270
|
+
"any"
|
|
271
|
+
)
|
|
101
272
|
}
|
|
102
273
|
},
|
|
103
274
|
{
|
|
@@ -105,7 +276,16 @@ const routes = {
|
|
|
105
276
|
path: "/batches/:batchId/status",
|
|
106
277
|
handler: "bulkUpdater.getBatchStatus",
|
|
107
278
|
config: {
|
|
108
|
-
policies:
|
|
279
|
+
policies: requirePermissions(
|
|
280
|
+
[
|
|
281
|
+
PERMISSIONS.workspaceView,
|
|
282
|
+
PERMISSIONS.workspaceExecute,
|
|
283
|
+
PERMISSIONS.csvImport,
|
|
284
|
+
PERMISSIONS.auditView,
|
|
285
|
+
PERMISSIONS.approvalView
|
|
286
|
+
],
|
|
287
|
+
"any"
|
|
288
|
+
)
|
|
109
289
|
}
|
|
110
290
|
},
|
|
111
291
|
{
|
|
@@ -113,7 +293,7 @@ const routes = {
|
|
|
113
293
|
path: "/batches/:batchId/report",
|
|
114
294
|
handler: "bulkUpdater.getBatchReport",
|
|
115
295
|
config: {
|
|
116
|
-
policies: []
|
|
296
|
+
policies: requirePermissions([PERMISSIONS.auditDetails, PERMISSIONS.approvalView], "any")
|
|
117
297
|
}
|
|
118
298
|
},
|
|
119
299
|
{
|
|
@@ -121,7 +301,7 @@ const routes = {
|
|
|
121
301
|
path: "/batches/:batchId/diffs",
|
|
122
302
|
handler: "bulkUpdater.getPendingBatchDiffs",
|
|
123
303
|
config: {
|
|
124
|
-
policies: []
|
|
304
|
+
policies: requirePermissions([PERMISSIONS.approvalView, PERMISSIONS.auditDetails], "any")
|
|
125
305
|
}
|
|
126
306
|
},
|
|
127
307
|
{
|
|
@@ -129,7 +309,7 @@ const routes = {
|
|
|
129
309
|
path: "/batches/:batchId/diffs/export",
|
|
130
310
|
handler: "bulkUpdater.exportPendingBatchDiffs",
|
|
131
311
|
config: {
|
|
132
|
-
policies: []
|
|
312
|
+
policies: requirePermissions([PERMISSIONS.approvalView, PERMISSIONS.auditDetails], "any")
|
|
133
313
|
}
|
|
134
314
|
},
|
|
135
315
|
{
|
|
@@ -137,7 +317,7 @@ const routes = {
|
|
|
137
317
|
path: "/audit/history",
|
|
138
318
|
handler: "audit.getHistory",
|
|
139
319
|
config: {
|
|
140
|
-
policies:
|
|
320
|
+
policies: requirePermissions(PERMISSIONS.auditView)
|
|
141
321
|
}
|
|
142
322
|
},
|
|
143
323
|
{
|
|
@@ -145,7 +325,7 @@ const routes = {
|
|
|
145
325
|
path: "/audit/:batchId/rollback",
|
|
146
326
|
handler: "audit.rollback",
|
|
147
327
|
config: {
|
|
148
|
-
policies:
|
|
328
|
+
policies: requirePermissions(PERMISSIONS.auditRollback)
|
|
149
329
|
}
|
|
150
330
|
},
|
|
151
331
|
{
|
|
@@ -153,7 +333,7 @@ const routes = {
|
|
|
153
333
|
path: "/validation-rules",
|
|
154
334
|
handler: "validationRules.getRules",
|
|
155
335
|
config: {
|
|
156
|
-
policies:
|
|
336
|
+
policies: requirePermissions(PERMISSIONS.validationView)
|
|
157
337
|
}
|
|
158
338
|
},
|
|
159
339
|
{
|
|
@@ -161,7 +341,7 @@ const routes = {
|
|
|
161
341
|
path: "/validation-rules",
|
|
162
342
|
handler: "validationRules.saveRule",
|
|
163
343
|
config: {
|
|
164
|
-
policies:
|
|
344
|
+
policies: requirePermissions(PERMISSIONS.validationManage)
|
|
165
345
|
}
|
|
166
346
|
},
|
|
167
347
|
{
|
|
@@ -169,7 +349,7 @@ const routes = {
|
|
|
169
349
|
path: "/validation-rules/:id",
|
|
170
350
|
handler: "validationRules.deleteRule",
|
|
171
351
|
config: {
|
|
172
|
-
policies:
|
|
352
|
+
policies: requirePermissions(PERMISSIONS.validationManage)
|
|
173
353
|
}
|
|
174
354
|
},
|
|
175
355
|
{
|
|
@@ -177,7 +357,7 @@ const routes = {
|
|
|
177
357
|
path: "/validation-rules/:id/toggle",
|
|
178
358
|
handler: "validationRules.toggleRule",
|
|
179
359
|
config: {
|
|
180
|
-
policies:
|
|
360
|
+
policies: requirePermissions(PERMISSIONS.validationManage)
|
|
181
361
|
}
|
|
182
362
|
},
|
|
183
363
|
{
|
|
@@ -185,7 +365,7 @@ const routes = {
|
|
|
185
365
|
path: "/validation-rules/:id/scan",
|
|
186
366
|
handler: "validationRules.scanViolations",
|
|
187
367
|
config: {
|
|
188
|
-
policies:
|
|
368
|
+
policies: requirePermissions(PERMISSIONS.validationView)
|
|
189
369
|
}
|
|
190
370
|
},
|
|
191
371
|
{
|
|
@@ -193,7 +373,7 @@ const routes = {
|
|
|
193
373
|
path: "/csv/template/:uid",
|
|
194
374
|
handler: "csv.getTemplate",
|
|
195
375
|
config: {
|
|
196
|
-
policies: []
|
|
376
|
+
policies: requirePermissions([PERMISSIONS.csvExport, PERMISSIONS.csvImport], "any")
|
|
197
377
|
}
|
|
198
378
|
},
|
|
199
379
|
{
|
|
@@ -201,7 +381,7 @@ const routes = {
|
|
|
201
381
|
path: "/csv/export/:uid",
|
|
202
382
|
handler: "csv.exportCollection",
|
|
203
383
|
config: {
|
|
204
|
-
policies:
|
|
384
|
+
policies: requirePermissions(PERMISSIONS.csvExport)
|
|
205
385
|
}
|
|
206
386
|
},
|
|
207
387
|
{
|
|
@@ -209,7 +389,7 @@ const routes = {
|
|
|
209
389
|
path: "/csv/export/:uid",
|
|
210
390
|
handler: "csv.exportCollection",
|
|
211
391
|
config: {
|
|
212
|
-
policies:
|
|
392
|
+
policies: requirePermissions(PERMISSIONS.csvExport)
|
|
213
393
|
}
|
|
214
394
|
},
|
|
215
395
|
{
|
|
@@ -217,7 +397,7 @@ const routes = {
|
|
|
217
397
|
path: "/csv/export-bulk",
|
|
218
398
|
handler: "csv.exportBulk",
|
|
219
399
|
config: {
|
|
220
|
-
policies:
|
|
400
|
+
policies: requirePermissions(PERMISSIONS.csvExport)
|
|
221
401
|
}
|
|
222
402
|
},
|
|
223
403
|
{
|
|
@@ -225,7 +405,7 @@ const routes = {
|
|
|
225
405
|
path: "/csv/export-violations/:ruleId",
|
|
226
406
|
handler: "csv.exportViolations",
|
|
227
407
|
config: {
|
|
228
|
-
policies:
|
|
408
|
+
policies: requirePermissions(PERMISSIONS.csvExport)
|
|
229
409
|
}
|
|
230
410
|
},
|
|
231
411
|
{
|
|
@@ -233,7 +413,7 @@ const routes = {
|
|
|
233
413
|
path: "/csv/import",
|
|
234
414
|
handler: "csv.importCsv",
|
|
235
415
|
config: {
|
|
236
|
-
policies:
|
|
416
|
+
policies: requirePermissions(PERMISSIONS.csvImport)
|
|
237
417
|
}
|
|
238
418
|
},
|
|
239
419
|
{
|
|
@@ -241,7 +421,7 @@ const routes = {
|
|
|
241
421
|
path: "/csv/import-chunk",
|
|
242
422
|
handler: "csv.importChunk",
|
|
243
423
|
config: {
|
|
244
|
-
policies:
|
|
424
|
+
policies: requirePermissions(PERMISSIONS.csvImport)
|
|
245
425
|
}
|
|
246
426
|
},
|
|
247
427
|
{
|
|
@@ -249,7 +429,7 @@ const routes = {
|
|
|
249
429
|
path: "/csv/validate-preflight",
|
|
250
430
|
handler: "csv.validatePreflight",
|
|
251
431
|
config: {
|
|
252
|
-
policies:
|
|
432
|
+
policies: requirePermissions(PERMISSIONS.csvImport)
|
|
253
433
|
}
|
|
254
434
|
},
|
|
255
435
|
{
|
|
@@ -257,12 +437,76 @@ const routes = {
|
|
|
257
437
|
path: "/csv/submit-batch",
|
|
258
438
|
handler: "csv.submitBatch",
|
|
259
439
|
config: {
|
|
260
|
-
policies:
|
|
440
|
+
policies: requirePermissions(PERMISSIONS.csvImport)
|
|
261
441
|
}
|
|
262
442
|
}
|
|
263
443
|
]
|
|
264
444
|
}
|
|
265
445
|
};
|
|
446
|
+
const hasPermissions = (policyContext, config, { strapi } = {}) => {
|
|
447
|
+
const ctx = policyContext?.isSelect ? policyContext : policyContext?.context || policyContext;
|
|
448
|
+
let actions = [];
|
|
449
|
+
let mode = "all";
|
|
450
|
+
if (Array.isArray(config)) {
|
|
451
|
+
actions = config;
|
|
452
|
+
} else if (config && typeof config === "object") {
|
|
453
|
+
actions = Array.isArray(config.actions) ? config.actions : [];
|
|
454
|
+
if (config.mode === "any") {
|
|
455
|
+
mode = "any";
|
|
456
|
+
}
|
|
457
|
+
} else if (typeof config === "string") {
|
|
458
|
+
actions = [config];
|
|
459
|
+
}
|
|
460
|
+
if (!actions || actions.length === 0) {
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
const user = ctx?.state?.user;
|
|
464
|
+
const userAbility = ctx?.state?.userAbility;
|
|
465
|
+
if (user?.isSuperAdmin === true) {
|
|
466
|
+
return true;
|
|
467
|
+
}
|
|
468
|
+
if (userAbility && typeof userAbility.can === "function") {
|
|
469
|
+
const isAllowed2 = mode === "any" ? actions.some((act) => userAbility.can(act)) : actions.every((act) => userAbility.can(act));
|
|
470
|
+
if (isAllowed2) {
|
|
471
|
+
return true;
|
|
472
|
+
}
|
|
473
|
+
if (ctx) {
|
|
474
|
+
ctx.status = 403;
|
|
475
|
+
ctx.body = {
|
|
476
|
+
data: null,
|
|
477
|
+
error: {
|
|
478
|
+
status: 403,
|
|
479
|
+
name: "ForbiddenError",
|
|
480
|
+
message: "You do not have permission to perform this action."
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
const permissions = Array.isArray(ctx?.state?.permissions) ? ctx.state.permissions : Array.isArray(user?.permissions) ? user.permissions.map((p) => typeof p === "string" ? p : p?.action).filter(Boolean) : [];
|
|
487
|
+
if (permissions.includes("*")) {
|
|
488
|
+
return true;
|
|
489
|
+
}
|
|
490
|
+
const isAllowed = mode === "any" ? actions.some((act) => permissions.includes(act)) : actions.every((act) => permissions.includes(act));
|
|
491
|
+
if (isAllowed) {
|
|
492
|
+
return true;
|
|
493
|
+
}
|
|
494
|
+
if (ctx) {
|
|
495
|
+
ctx.status = 403;
|
|
496
|
+
ctx.body = {
|
|
497
|
+
data: null,
|
|
498
|
+
error: {
|
|
499
|
+
status: 403,
|
|
500
|
+
name: "ForbiddenError",
|
|
501
|
+
message: "You do not have permission to perform this action."
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
return false;
|
|
506
|
+
};
|
|
507
|
+
const policies = {
|
|
508
|
+
hasPermissions
|
|
509
|
+
};
|
|
266
510
|
const auditLog = {
|
|
267
511
|
collectionName: "bulk_updater_audit_logs",
|
|
268
512
|
info: {
|
|
@@ -12101,6 +12345,18 @@ const index = {
|
|
|
12101
12345
|
},
|
|
12102
12346
|
bootstrap({ strapi }) {
|
|
12103
12347
|
installUndiciCrashGuard(strapi);
|
|
12348
|
+
try {
|
|
12349
|
+
const actionProvider = strapi.admin?.services?.permission?.actionProvider;
|
|
12350
|
+
if (actionProvider?.registerMany) {
|
|
12351
|
+
actionProvider.registerMany(BULK_UPDATER_PERMISSION_ACTIONS);
|
|
12352
|
+
} else if (actionProvider?.register) {
|
|
12353
|
+
for (const action of BULK_UPDATER_PERMISSION_ACTIONS) {
|
|
12354
|
+
actionProvider.register(action);
|
|
12355
|
+
}
|
|
12356
|
+
}
|
|
12357
|
+
} catch (err) {
|
|
12358
|
+
strapi.log?.warn?.(`[bulk-updater] Failed to register RBAC permissions: ${err?.message || err}`);
|
|
12359
|
+
}
|
|
12104
12360
|
strapi.server.use(async (ctx, next) => {
|
|
12105
12361
|
try {
|
|
12106
12362
|
await next();
|
|
@@ -12264,6 +12520,7 @@ const index = {
|
|
|
12264
12520
|
}
|
|
12265
12521
|
},
|
|
12266
12522
|
routes,
|
|
12523
|
+
policies,
|
|
12267
12524
|
contentTypes,
|
|
12268
12525
|
controllers: {
|
|
12269
12526
|
bulkUpdater: bulkUpdaterController,
|
|
@@ -12280,12 +12537,14 @@ const index = {
|
|
|
12280
12537
|
}
|
|
12281
12538
|
};
|
|
12282
12539
|
export {
|
|
12540
|
+
BULK_UPDATER_PERMISSION_ACTIONS,
|
|
12283
12541
|
CURRENT_SCHEMA_VERSION,
|
|
12284
12542
|
EXPLICIT_CLEAR_TOKENS,
|
|
12285
12543
|
EXPLICIT_DELETE_KEY_TOKEN,
|
|
12286
12544
|
EXPLICIT_EMPTY_STRING_TOKEN,
|
|
12287
12545
|
FORBIDDEN_OBJECT_KEYS,
|
|
12288
12546
|
METADATA_COLUMN_KEY,
|
|
12547
|
+
PERMISSIONS,
|
|
12289
12548
|
SYSTEM_ATTRIBUTES,
|
|
12290
12549
|
applyOccurrenceUpdatesToDocument,
|
|
12291
12550
|
buildCollectionQueryFilters,
|