strapi-plugin-bulk-updater 1.6.10 → 1.7.0

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.
Files changed (28) hide show
  1. package/dist/_chunks/{BulkUpdater-DISkZC1Y.mjs → BulkUpdater-CV49TvOV.mjs} +338 -136
  2. package/dist/_chunks/BulkUpdater-CV49TvOV.mjs.map +1 -0
  3. package/dist/_chunks/{BulkUpdater-BY8IXT4R.js → BulkUpdater-Cnzgw4UH.js} +336 -134
  4. package/dist/_chunks/BulkUpdater-Cnzgw4UH.js.map +1 -0
  5. package/dist/_chunks/{SettingsPage-D9vD1BKo.mjs → SettingsPage-DXRWLRp_.mjs} +2 -2
  6. package/dist/_chunks/{SettingsPage-D9vD1BKo.mjs.map → SettingsPage-DXRWLRp_.mjs.map} +1 -1
  7. package/dist/_chunks/{SettingsPage-vH-eanBJ.js → SettingsPage-w_Lz-N0V.js} +2 -2
  8. package/dist/_chunks/{SettingsPage-vH-eanBJ.js.map → SettingsPage-w_Lz-N0V.js.map} +1 -1
  9. package/dist/_chunks/{ValidationRulesTab-DdwR3lWq.mjs → ValidationRulesTab-eN_vH3TB.mjs} +22 -2
  10. package/dist/_chunks/ValidationRulesTab-eN_vH3TB.mjs.map +1 -0
  11. package/dist/_chunks/{ValidationRulesTab-r6S-ZFDp.js → ValidationRulesTab-of8bIzre.js} +22 -2
  12. package/dist/_chunks/ValidationRulesTab-of8bIzre.js.map +1 -0
  13. package/dist/_chunks/{index-AXTojFac.mjs → index-2DodYa70.mjs} +7 -3
  14. package/dist/_chunks/index-2DodYa70.mjs.map +1 -0
  15. package/dist/_chunks/{index-aoOgZpZE.js → index-C2HoRm23.js} +7 -3
  16. package/dist/_chunks/{index-AXTojFac.mjs.map → index-C2HoRm23.js.map} +1 -1
  17. package/dist/admin/index.js +1 -1
  18. package/dist/admin/index.mjs +1 -1
  19. package/dist/server/index.js +292 -81
  20. package/dist/server/index.js.map +1 -1
  21. package/dist/server/index.mjs +292 -81
  22. package/dist/server/index.mjs.map +1 -1
  23. package/package.json +1 -1
  24. package/dist/_chunks/BulkUpdater-BY8IXT4R.js.map +0 -1
  25. package/dist/_chunks/BulkUpdater-DISkZC1Y.mjs.map +0 -1
  26. package/dist/_chunks/ValidationRulesTab-DdwR3lWq.mjs.map +0 -1
  27. package/dist/_chunks/ValidationRulesTab-r6S-ZFDp.js.map +0 -1
  28. package/dist/_chunks/index-aoOgZpZE.js.map +0 -1
@@ -9,6 +9,10 @@ const PERMISSIONS = {
9
9
  workspaceView: `plugin::${PLUGIN_ID}.workspace.view`,
10
10
  workspaceExecute: `plugin::${PLUGIN_ID}.workspace.execute`,
11
11
  workspacePublish: `plugin::${PLUGIN_ID}.workspace.publish`,
12
+ workspaceSubmitForChecker: `plugin::${PLUGIN_ID}.workspace.submit-for-checker`,
13
+ workspaceForceRunNow: `plugin::${PLUGIN_ID}.workspace.force-run-now`,
14
+ workspaceQueueForOffPeak: `plugin::${PLUGIN_ID}.workspace.queue-for-off-peak`,
15
+ workspaceProceedToExecute: `plugin::${PLUGIN_ID}.workspace.proceed-to-execute`,
12
16
  // CSV Management
13
17
  csvExport: `plugin::${PLUGIN_ID}.csv.export`,
14
18
  csvImport: `plugin::${PLUGIN_ID}.csv.import`,
@@ -56,6 +60,34 @@ const BULK_UPDATER_PERMISSION_ACTIONS = [
56
60
  pluginName: PLUGIN_ID,
57
61
  subCategory: "Workspace"
58
62
  },
63
+ {
64
+ section: "plugins",
65
+ displayName: "Submit For Checker",
66
+ uid: "workspace.submit-for-checker",
67
+ pluginName: PLUGIN_ID,
68
+ subCategory: "Workspace"
69
+ },
70
+ {
71
+ section: "plugins",
72
+ displayName: "Force Run Now",
73
+ uid: "workspace.force-run-now",
74
+ pluginName: PLUGIN_ID,
75
+ subCategory: "Workspace"
76
+ },
77
+ {
78
+ section: "plugins",
79
+ displayName: "Queue For Off-Peak",
80
+ uid: "workspace.queue-for-off-peak",
81
+ pluginName: PLUGIN_ID,
82
+ subCategory: "Workspace"
83
+ },
84
+ {
85
+ section: "plugins",
86
+ displayName: "Proceed to Execute",
87
+ uid: "workspace.proceed-to-execute",
88
+ pluginName: PLUGIN_ID,
89
+ subCategory: "Workspace"
90
+ },
59
91
  {
60
92
  section: "plugins",
61
93
  displayName: "Export CSV & Templates",
@@ -141,6 +173,118 @@ const BULK_UPDATER_PERMISSION_ACTIONS = [
141
173
  subCategory: "Settings"
142
174
  }
143
175
  ];
176
+ const BATCH_UPDATE_POLICY_CONFIG = {
177
+ actions: [
178
+ PERMISSIONS.workspaceExecute,
179
+ PERMISSIONS.workspaceSubmitForChecker,
180
+ PERMISSIONS.workspaceForceRunNow,
181
+ PERMISSIONS.workspaceQueueForOffPeak,
182
+ PERMISSIONS.workspaceProceedToExecute
183
+ ],
184
+ mode: "any",
185
+ enforceBatchUpdateExecutionMode: true
186
+ };
187
+ function resolveBatchUpdateRequiredPermissions(body) {
188
+ const rawMode = body?.executionMode;
189
+ const effectiveMode = rawMode === void 0 ? "immediate" : rawMode;
190
+ if (typeof effectiveMode !== "string" || !["maker_checker", "queue_offpeak", "immediate"].includes(effectiveMode)) {
191
+ return {
192
+ valid: false,
193
+ actions: [],
194
+ reason: `Unsupported or unauthorized execution mode "${String(rawMode)}".`
195
+ };
196
+ }
197
+ const required = [];
198
+ if (effectiveMode === "maker_checker") {
199
+ required.push(PERMISSIONS.workspaceSubmitForChecker);
200
+ } else if (effectiveMode === "queue_offpeak") {
201
+ required.push(PERMISSIONS.workspaceQueueForOffPeak);
202
+ } else {
203
+ required.push(PERMISSIONS.workspaceForceRunNow);
204
+ }
205
+ const isPreviewInitiated = body?.initiatedFromPreview === true || body?.initiatedFromPreview === "true" || body?.source === "preview" || body?.executionSource === "preview";
206
+ if (isPreviewInitiated) {
207
+ required.push(PERMISSIONS.workspaceProceedToExecute);
208
+ }
209
+ return { valid: true, actions: required };
210
+ }
211
+ function setForbiddenResponse(ctx, message = "You do not have permission to perform this action.") {
212
+ if (ctx) {
213
+ ctx.status = 403;
214
+ ctx.body = {
215
+ data: null,
216
+ error: {
217
+ status: 403,
218
+ name: "ForbiddenError",
219
+ message
220
+ }
221
+ };
222
+ }
223
+ }
224
+ const hasPermissionsPolicy = (policyContext, config, { strapi } = {}) => {
225
+ const ctx = policyContext?.isSelect ? policyContext : policyContext?.context || policyContext;
226
+ let actions = [];
227
+ let mode = "all";
228
+ let enforceBatchMode = false;
229
+ if (Array.isArray(config)) {
230
+ actions = config;
231
+ } else if (config && typeof config === "object") {
232
+ actions = Array.isArray(config.actions) ? config.actions : [];
233
+ if (config.mode === "any") {
234
+ mode = "any";
235
+ }
236
+ enforceBatchMode = Boolean(config.enforceBatchUpdateExecutionMode);
237
+ } else if (typeof config === "string") {
238
+ actions = [config];
239
+ }
240
+ const user = ctx?.state?.user;
241
+ const userAbility = ctx?.state?.userAbility;
242
+ const isSuperAdmin = Boolean(
243
+ user?.isSuperAdmin === true || Array.isArray(user?.roles) && user.roles.some((r) => r?.code === "strapi-super-admin" || r?.name === "Super Admin")
244
+ );
245
+ if (isSuperAdmin) {
246
+ return true;
247
+ }
248
+ let batchModeActions = null;
249
+ if (enforceBatchMode) {
250
+ const resolved = resolveBatchUpdateRequiredPermissions(ctx?.request?.body);
251
+ if (!resolved.valid) {
252
+ setForbiddenResponse(ctx, resolved.reason || "You do not have permission to perform this action.");
253
+ return false;
254
+ }
255
+ batchModeActions = resolved.actions;
256
+ }
257
+ if ((!actions || actions.length === 0) && (!batchModeActions || batchModeActions.length === 0)) {
258
+ return true;
259
+ }
260
+ const evaluateActions = (reqActions, evalMode) => {
261
+ if (!reqActions || reqActions.length === 0) return true;
262
+ if (userAbility && typeof userAbility.can === "function") {
263
+ if (userAbility.can("manage", "all") || userAbility.can("*")) {
264
+ return true;
265
+ }
266
+ return evalMode === "any" ? reqActions.some((act) => userAbility.can(act)) : reqActions.every((act) => userAbility.can(act));
267
+ }
268
+ 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) : [];
269
+ if (permissions.includes("*") || permissions.includes("admin::all")) {
270
+ return true;
271
+ }
272
+ return evalMode === "any" ? reqActions.some((act) => permissions.includes(act)) : reqActions.every((act) => permissions.includes(act));
273
+ };
274
+ const baseAllowed = evaluateActions(actions, mode);
275
+ if (!baseAllowed) {
276
+ setForbiddenResponse(ctx);
277
+ return false;
278
+ }
279
+ if (batchModeActions && !evaluateActions(batchModeActions, "all")) {
280
+ setForbiddenResponse(
281
+ ctx,
282
+ `You do not have permission to perform this batch update action (required: ${batchModeActions.join(", ")}).`
283
+ );
284
+ return false;
285
+ }
286
+ return true;
287
+ };
144
288
  function requirePermissions(actions, mode = "all") {
145
289
  return [
146
290
  {
@@ -210,7 +354,12 @@ const routes = {
210
354
  path: "/batch-update",
211
355
  handler: "bulkUpdater.batchUpdate",
212
356
  config: {
213
- policies: requirePermissions(PERMISSIONS.workspaceExecute)
357
+ policies: [
358
+ {
359
+ name: "plugin::bulk-updater.hasPermissions",
360
+ config: BATCH_UPDATE_POLICY_CONFIG
361
+ }
362
+ ]
214
363
  }
215
364
  },
216
365
  {
@@ -444,75 +593,8 @@ const routes = {
444
593
  ]
445
594
  }
446
595
  };
447
- const hasPermissions = (policyContext, config, { strapi } = {}) => {
448
- const ctx = policyContext?.isSelect ? policyContext : policyContext?.context || policyContext;
449
- let actions = [];
450
- let mode = "all";
451
- if (Array.isArray(config)) {
452
- actions = config;
453
- } else if (config && typeof config === "object") {
454
- actions = Array.isArray(config.actions) ? config.actions : [];
455
- if (config.mode === "any") {
456
- mode = "any";
457
- }
458
- } else if (typeof config === "string") {
459
- actions = [config];
460
- }
461
- if (!actions || actions.length === 0) {
462
- return true;
463
- }
464
- const user = ctx?.state?.user;
465
- const userAbility = ctx?.state?.userAbility;
466
- const isSuperAdmin = Boolean(
467
- user?.isSuperAdmin === true || Array.isArray(user?.roles) && user.roles.some((r) => r?.code === "strapi-super-admin" || r?.name === "Super Admin")
468
- );
469
- if (isSuperAdmin) {
470
- return true;
471
- }
472
- if (userAbility && typeof userAbility.can === "function") {
473
- if (userAbility.can("manage", "all") || userAbility.can("*")) {
474
- return true;
475
- }
476
- const isAllowed2 = mode === "any" ? actions.some((act) => userAbility.can(act)) : actions.every((act) => userAbility.can(act));
477
- if (isAllowed2) {
478
- return true;
479
- }
480
- if (ctx) {
481
- ctx.status = 403;
482
- ctx.body = {
483
- data: null,
484
- error: {
485
- status: 403,
486
- name: "ForbiddenError",
487
- message: "You do not have permission to perform this action."
488
- }
489
- };
490
- }
491
- return false;
492
- }
493
- 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) : [];
494
- if (permissions.includes("*") || permissions.includes("admin::all")) {
495
- return true;
496
- }
497
- const isAllowed = mode === "any" ? actions.some((act) => permissions.includes(act)) : actions.every((act) => permissions.includes(act));
498
- if (isAllowed) {
499
- return true;
500
- }
501
- if (ctx) {
502
- ctx.status = 403;
503
- ctx.body = {
504
- data: null,
505
- error: {
506
- status: 403,
507
- name: "ForbiddenError",
508
- message: "You do not have permission to perform this action."
509
- }
510
- };
511
- }
512
- return false;
513
- };
514
596
  const policies = {
515
- hasPermissions
597
+ hasPermissions: hasPermissionsPolicy
516
598
  };
517
599
  const auditLog = {
518
600
  collectionName: "bulk_updater_audit_logs",
@@ -789,6 +871,12 @@ const bulkUpdaterController = ({ strapi }) => ({
789
871
  try {
790
872
  const service = strapi.plugin("bulk-updater").service("bulkUpdater");
791
873
  const currentUser = ctx.state.user;
874
+ const hasAuthContext = Boolean(
875
+ ctx?.state?.userAbility || Array.isArray(ctx?.state?.permissions) || Array.isArray(ctx?.state?.user?.permissions) || ctx?.state?.user?.isSuperAdmin !== void 0
876
+ );
877
+ if (hasAuthContext && !hasPermissionsPolicy(ctx, BATCH_UPDATE_POLICY_CONFIG, { strapi })) {
878
+ return;
879
+ }
792
880
  const result = await service.batchUpdate(ctx.request.body || {}, currentUser);
793
881
  ctx.body = result;
794
882
  } catch (err) {
@@ -4419,17 +4507,63 @@ function enumerateOccurrences(contentType, allComponents, entity, attrPath) {
4419
4507
  walk(contentType, entity, parts, [], false, void 0, void 0, void 0, true);
4420
4508
  return results;
4421
4509
  }
4510
+ function resolveRelationDisplayLabel(r) {
4511
+ if (!r || typeof r !== "object") return String(r ?? "");
4512
+ if (r.label && typeof r.label === "string" && r.label.trim()) return r.label.trim();
4513
+ const candidates = [
4514
+ "name",
4515
+ "title",
4516
+ "authorName",
4517
+ "label",
4518
+ "heading",
4519
+ "subject",
4520
+ "fullName",
4521
+ "username",
4522
+ "email",
4523
+ "slug"
4524
+ ];
4525
+ for (const field of candidates) {
4526
+ if (r[field] !== void 0 && r[field] !== null && String(r[field]).trim() !== "") {
4527
+ return String(r[field]).trim();
4528
+ }
4529
+ }
4530
+ if (r.firstname || r.lastname) {
4531
+ const fn = [r.firstname, r.lastname].filter(Boolean).join(" ").trim();
4532
+ if (fn) return fn;
4533
+ }
4534
+ const systemKeys = /* @__PURE__ */ new Set([
4535
+ "id",
4536
+ "documentId",
4537
+ "createdAt",
4538
+ "updatedAt",
4539
+ "publishedAt",
4540
+ "locale",
4541
+ "createdBy",
4542
+ "updatedBy",
4543
+ "__component"
4544
+ ]);
4545
+ for (const [k, v] of Object.entries(r)) {
4546
+ if (!systemKeys.has(k) && typeof v === "string" && v.trim() !== "") {
4547
+ return v.trim();
4548
+ }
4549
+ }
4550
+ return r.documentId || (r.id !== void 0 && r.id !== null ? `Entry #${r.id}` : "");
4551
+ }
4422
4552
  function formatRelationState(currentRel, isMulti) {
4423
4553
  if (isMulti && Array.isArray(currentRel)) {
4424
4554
  const oldDocIds = currentRel.map((r) => r?.documentId).filter(Boolean);
4425
- const oldDisplay = currentRel.map((r) => r?.name || r?.title || r?.email || r?.username || r?.documentId).filter(Boolean).join(", ") || "(unlinked / none)";
4555
+ const oldDisplay = currentRel.map((r) => resolveRelationDisplayLabel(r)).filter(Boolean).join(", ") || "(unlinked / none)";
4426
4556
  return { oldDocIds, oldDisplay };
4427
4557
  }
4428
4558
  if (currentRel && typeof currentRel === "object") {
4429
4559
  const oldDocIds = currentRel.documentId ? [currentRel.documentId] : [];
4430
- const oldDisplay = currentRel.name || currentRel.title || currentRel.email || currentRel.username || currentRel.documentId || "(unlinked / none)";
4560
+ const oldDisplay = resolveRelationDisplayLabel(currentRel) || "(unlinked / none)";
4431
4561
  return { oldDocIds, oldDisplay };
4432
4562
  }
4563
+ if (typeof currentRel === "string" && currentRel.trim()) {
4564
+ const docId = currentRel.trim();
4565
+ return { oldDocIds: [docId], oldDisplay: resolveRelationDisplayLabel(docId) };
4566
+ }
4433
4567
  return { oldDocIds: [], oldDisplay: "(unlinked / none)" };
4434
4568
  }
4435
4569
  function resolveRelationCommand(rawValue, isMulti, forComponentNested = false) {
@@ -5017,6 +5151,9 @@ const modelsCache = /* @__PURE__ */ new Map();
5017
5151
  const MAX_QUERY_CACHE_SIZE = 500;
5018
5152
  const CACHE_TTL_MS = 60 * 1e3;
5019
5153
  let staticSchemaCache = null;
5154
+ function clearStaticSchemaCache() {
5155
+ staticSchemaCache = null;
5156
+ }
5020
5157
  function formatEntryRecord(entry) {
5021
5158
  if (!entry || typeof entry !== "object") return entry;
5022
5159
  const formatted = {
@@ -5310,9 +5447,26 @@ function buildDeepPopulate(attributes, allComponents, depth = 0) {
5310
5447
  populate[key] = true;
5311
5448
  }
5312
5449
  } else if (def.type === "dynamiczone") {
5313
- populate[key] = {
5314
- populate: "*"
5315
- };
5450
+ const dzComps = Array.isArray(def.components) ? def.components : [];
5451
+ const onPopulate = {};
5452
+ for (const compUid of dzComps) {
5453
+ const comp = allComponents?.[compUid];
5454
+ if (comp?.attributes) {
5455
+ const subPopulate = buildDeepPopulate(comp.attributes, allComponents, depth + 1);
5456
+ if (subPopulate && Object.keys(subPopulate).length > 0) {
5457
+ onPopulate[compUid] = { populate: subPopulate };
5458
+ }
5459
+ }
5460
+ }
5461
+ if (Object.keys(onPopulate).length > 0) {
5462
+ populate[key] = {
5463
+ on: onPopulate
5464
+ };
5465
+ } else {
5466
+ populate[key] = {
5467
+ populate: "*"
5468
+ };
5469
+ }
5316
5470
  } else if (def.type === "relation" || def.type === "media") {
5317
5471
  populate[key] = true;
5318
5472
  }
@@ -5376,6 +5530,22 @@ function discoverComponentAttributes(strapi, compUid, prefix, currentDepth, maxD
5376
5530
  };
5377
5531
  relationsByAttr[fullPath] = relMeta;
5378
5532
  allRelationsMeta[fullPath] = relMeta;
5533
+ if (prefix && !relationsByAttr[prefix]) {
5534
+ relationsByAttr[prefix] = relMeta;
5535
+ }
5536
+ if (compUid) {
5537
+ const compClean = compUid.includes(".") ? compUid.split(".")[1] : compUid;
5538
+ const compCleanUnder = compClean.replace(/-/g, "_");
5539
+ const compCleanHyphen = compClean.replace(/_/g, "-");
5540
+ const aliases = /* @__PURE__ */ new Set([compUid, compClean, compCleanUnder, compCleanHyphen]);
5541
+ for (const alias of aliases) {
5542
+ const aliasSub = `${alias}.${subKey}`;
5543
+ if (!relationsByAttr[aliasSub]) relationsByAttr[aliasSub] = relMeta;
5544
+ if (!relationsByAttr[alias]) relationsByAttr[alias] = relMeta;
5545
+ if (!allRelationsMeta[aliasSub]) allRelationsMeta[aliasSub] = relMeta;
5546
+ if (!allRelationsMeta[alias]) allRelationsMeta[alias] = relMeta;
5547
+ }
5548
+ }
5379
5549
  attributesMeta[fullPath] = buildRichAttributeMeta(subAttr, {
5380
5550
  depth: currentDepth,
5381
5551
  type: "relation",
@@ -5433,7 +5603,10 @@ function getAllNestedValues(obj, path) {
5433
5603
  rootTarget.forEach((item, idx) => {
5434
5604
  if (!item || typeof item !== "object") return;
5435
5605
  if (parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) return;
5436
- if (parsed.targetComponentUid && item.__component !== parsed.targetComponentUid) return;
5606
+ const itemComp = item.__component;
5607
+ const targetComp = parsed.targetComponentUid;
5608
+ const compMatches = !targetComp || itemComp === targetComp || itemComp && (itemComp.toLowerCase() === targetComp.toLowerCase() || itemComp.split(".")[1]?.toLowerCase() === targetComp.toLowerCase() || itemComp.toLowerCase().replace(/[-_]/g, "") === targetComp.toLowerCase().replace(/[-_]/g, ""));
5609
+ if (!compMatches) return;
5437
5610
  const compSchema = global.strapi?.components?.[item.__component];
5438
5611
  const fieldInSchema = tail.length > 0 && compSchema?.attributes ? tail[0] in compSchema.attributes : false;
5439
5612
  if (tail.length > 0) {
@@ -6431,10 +6604,10 @@ async function executeBatchInternal(strapi, {
6431
6604
  let oldDisplay = "";
6432
6605
  if (isMulti && Array.isArray(currentRel)) {
6433
6606
  oldDocIds = currentRel.map((r) => r.documentId).filter(Boolean);
6434
- oldDisplay = currentRel.map((r) => r.name || r.title || r.email || r.documentId).join(", ") || "(empty)";
6607
+ oldDisplay = currentRel.map((r) => resolveRelationDisplayLabel(r)).join(", ") || "(empty)";
6435
6608
  } else if (currentRel) {
6436
6609
  oldDocIds = currentRel.documentId ? [currentRel.documentId] : [];
6437
- oldDisplay = currentRel.name || currentRel.title || currentRel.email || currentRel.documentId || "(empty)";
6610
+ oldDisplay = resolveRelationDisplayLabel(currentRel) || "(empty)";
6438
6611
  } else {
6439
6612
  oldDisplay = "(unlinked / none)";
6440
6613
  }
@@ -7446,7 +7619,7 @@ const bulkUpdaterService = ({ strapi }) => {
7446
7619
  if (v === void 0 || v === null) return false;
7447
7620
  if (Array.isArray(v)) return v.some(testSingleValue);
7448
7621
  if (typeof v === "object") {
7449
- return testSingleValue(v.name) || testSingleValue(v.title) || testSingleValue(v.email) || testSingleValue(v.username) || testSingleValue(v.documentId) || testSingleValue(v.id) || testSingleValue(v.slug);
7622
+ return testSingleValue(v.name) || testSingleValue(v.title) || testSingleValue(v.authorName) || testSingleValue(v.label) || testSingleValue(v.email) || testSingleValue(v.username) || testSingleValue(v.documentId) || testSingleValue(v.id) || testSingleValue(v.slug);
7450
7623
  }
7451
7624
  const valStr = String(v).trim().toLowerCase();
7452
7625
  switch (normOp) {
@@ -7550,8 +7723,43 @@ const bulkUpdaterService = ({ strapi }) => {
7550
7723
  limit: 100,
7551
7724
  sort: { createdAt: "desc" }
7552
7725
  });
7726
+ const targetCt = strapi.contentTypes[targetUid];
7727
+ const mainField = targetCt?.info?.mainField;
7728
+ const schemaAttrs = targetCt?.attributes || {};
7729
+ const candidateFields = [
7730
+ "name",
7731
+ "title",
7732
+ "authorName",
7733
+ "label",
7734
+ "heading",
7735
+ "subject",
7736
+ "fullName",
7737
+ "username",
7738
+ "email",
7739
+ "slug"
7740
+ ];
7741
+ const systemAttrs = ["createdAt", "updatedAt", "publishedAt", "locale", "createdBy", "updatedBy"];
7742
+ const stringAttr = Object.keys(schemaAttrs).find(
7743
+ (k) => !systemAttrs.includes(k) && ["string", "text", "uid"].includes(schemaAttrs[k]?.type)
7744
+ );
7553
7745
  const options = (docs || []).map((doc) => {
7554
- const label = doc.name || doc.title || doc.email || doc.username || `Entry #${doc.id || doc.documentId}`;
7746
+ let label = "";
7747
+ if (mainField && doc[mainField] !== void 0 && doc[mainField] !== null && String(doc[mainField]).trim() !== "") {
7748
+ label = String(doc[mainField]).trim();
7749
+ } else {
7750
+ for (const cand of candidateFields) {
7751
+ if (doc[cand] !== void 0 && doc[cand] !== null && String(doc[cand]).trim() !== "") {
7752
+ label = String(doc[cand]).trim();
7753
+ break;
7754
+ }
7755
+ }
7756
+ if (!label && stringAttr && doc[stringAttr] !== void 0 && doc[stringAttr] !== null && String(doc[stringAttr]).trim() !== "") {
7757
+ label = String(doc[stringAttr]).trim();
7758
+ }
7759
+ }
7760
+ if (!label) {
7761
+ label = `Entry #${doc.id || doc.documentId}`;
7762
+ }
7555
7763
  return {
7556
7764
  documentId: doc.documentId,
7557
7765
  label
@@ -7939,10 +8147,10 @@ const bulkUpdaterService = ({ strapi }) => {
7939
8147
  let oldDisplay = "";
7940
8148
  if (isMulti && Array.isArray(currentRel)) {
7941
8149
  oldDocIds = currentRel.map((r) => r.documentId).filter(Boolean);
7942
- oldDisplay = currentRel.map((r) => r.name || r.title || r.email || r.documentId).join(", ") || "(empty)";
8150
+ oldDisplay = currentRel.map((r) => resolveRelationDisplayLabel(r)).join(", ") || "(empty)";
7943
8151
  } else if (currentRel) {
7944
8152
  oldDocIds = currentRel.documentId ? [currentRel.documentId] : [];
7945
- oldDisplay = currentRel.name || currentRel.title || currentRel.email || currentRel.documentId || "(empty)";
8153
+ oldDisplay = resolveRelationDisplayLabel(currentRel) || "(empty)";
7946
8154
  } else {
7947
8155
  oldDisplay = "(unlinked / none)";
7948
8156
  }
@@ -12624,6 +12832,7 @@ export {
12624
12832
  buildLosslessPopulate,
12625
12833
  buildRichAttributeMeta,
12626
12834
  classifyAttribute,
12835
+ clearStaticSchemaCache,
12627
12836
  coerceAndValidateFieldValue,
12628
12837
  deepCloneValue,
12629
12838
  deepEqualValues,
@@ -12639,6 +12848,7 @@ export {
12639
12848
  extractRowFlattenedMetadata,
12640
12849
  formatErrorCsvFilename,
12641
12850
  formatErrorWithCause,
12851
+ formatRelationState,
12642
12852
  getActiveBulkOperationCount,
12643
12853
  getAllNestedValues,
12644
12854
  getBatchConcurrency,
@@ -12662,6 +12872,7 @@ export {
12662
12872
  resolveDynamicZonePayload,
12663
12873
  resolveErrorColumnName,
12664
12874
  resolveMediaIds,
12875
+ resolveRelationDisplayLabel,
12665
12876
  resolveRelationPayload,
12666
12877
  resolveTargetObjectField,
12667
12878
  sanitizeSensitiveErrorText,