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