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
@@ -13,6 +13,10 @@ const PERMISSIONS = {
13
13
  workspaceView: `plugin::${PLUGIN_ID}.workspace.view`,
14
14
  workspaceExecute: `plugin::${PLUGIN_ID}.workspace.execute`,
15
15
  workspacePublish: `plugin::${PLUGIN_ID}.workspace.publish`,
16
+ workspaceSubmitForChecker: `plugin::${PLUGIN_ID}.workspace.submit-for-checker`,
17
+ workspaceForceRunNow: `plugin::${PLUGIN_ID}.workspace.force-run-now`,
18
+ workspaceQueueForOffPeak: `plugin::${PLUGIN_ID}.workspace.queue-for-off-peak`,
19
+ workspaceProceedToExecute: `plugin::${PLUGIN_ID}.workspace.proceed-to-execute`,
16
20
  // CSV Management
17
21
  csvExport: `plugin::${PLUGIN_ID}.csv.export`,
18
22
  csvImport: `plugin::${PLUGIN_ID}.csv.import`,
@@ -60,6 +64,34 @@ const BULK_UPDATER_PERMISSION_ACTIONS = [
60
64
  pluginName: PLUGIN_ID,
61
65
  subCategory: "Workspace"
62
66
  },
67
+ {
68
+ section: "plugins",
69
+ displayName: "Submit For Checker",
70
+ uid: "workspace.submit-for-checker",
71
+ pluginName: PLUGIN_ID,
72
+ subCategory: "Workspace"
73
+ },
74
+ {
75
+ section: "plugins",
76
+ displayName: "Force Run Now",
77
+ uid: "workspace.force-run-now",
78
+ pluginName: PLUGIN_ID,
79
+ subCategory: "Workspace"
80
+ },
81
+ {
82
+ section: "plugins",
83
+ displayName: "Queue For Off-Peak",
84
+ uid: "workspace.queue-for-off-peak",
85
+ pluginName: PLUGIN_ID,
86
+ subCategory: "Workspace"
87
+ },
88
+ {
89
+ section: "plugins",
90
+ displayName: "Proceed to Execute",
91
+ uid: "workspace.proceed-to-execute",
92
+ pluginName: PLUGIN_ID,
93
+ subCategory: "Workspace"
94
+ },
63
95
  {
64
96
  section: "plugins",
65
97
  displayName: "Export CSV & Templates",
@@ -145,6 +177,118 @@ const BULK_UPDATER_PERMISSION_ACTIONS = [
145
177
  subCategory: "Settings"
146
178
  }
147
179
  ];
180
+ const BATCH_UPDATE_POLICY_CONFIG = {
181
+ actions: [
182
+ PERMISSIONS.workspaceExecute,
183
+ PERMISSIONS.workspaceSubmitForChecker,
184
+ PERMISSIONS.workspaceForceRunNow,
185
+ PERMISSIONS.workspaceQueueForOffPeak,
186
+ PERMISSIONS.workspaceProceedToExecute
187
+ ],
188
+ mode: "any",
189
+ enforceBatchUpdateExecutionMode: true
190
+ };
191
+ function resolveBatchUpdateRequiredPermissions(body) {
192
+ const rawMode = body?.executionMode;
193
+ const effectiveMode = rawMode === void 0 ? "immediate" : rawMode;
194
+ if (typeof effectiveMode !== "string" || !["maker_checker", "queue_offpeak", "immediate"].includes(effectiveMode)) {
195
+ return {
196
+ valid: false,
197
+ actions: [],
198
+ reason: `Unsupported or unauthorized execution mode "${String(rawMode)}".`
199
+ };
200
+ }
201
+ const required = [];
202
+ if (effectiveMode === "maker_checker") {
203
+ required.push(PERMISSIONS.workspaceSubmitForChecker);
204
+ } else if (effectiveMode === "queue_offpeak") {
205
+ required.push(PERMISSIONS.workspaceQueueForOffPeak);
206
+ } else {
207
+ required.push(PERMISSIONS.workspaceForceRunNow);
208
+ }
209
+ const isPreviewInitiated = body?.initiatedFromPreview === true || body?.initiatedFromPreview === "true" || body?.source === "preview" || body?.executionSource === "preview";
210
+ if (isPreviewInitiated) {
211
+ required.push(PERMISSIONS.workspaceProceedToExecute);
212
+ }
213
+ return { valid: true, actions: required };
214
+ }
215
+ function setForbiddenResponse(ctx, message = "You do not have permission to perform this action.") {
216
+ if (ctx) {
217
+ ctx.status = 403;
218
+ ctx.body = {
219
+ data: null,
220
+ error: {
221
+ status: 403,
222
+ name: "ForbiddenError",
223
+ message
224
+ }
225
+ };
226
+ }
227
+ }
228
+ const hasPermissionsPolicy = (policyContext, config, { strapi } = {}) => {
229
+ const ctx = policyContext?.isSelect ? policyContext : policyContext?.context || policyContext;
230
+ let actions = [];
231
+ let mode = "all";
232
+ let enforceBatchMode = false;
233
+ if (Array.isArray(config)) {
234
+ actions = config;
235
+ } else if (config && typeof config === "object") {
236
+ actions = Array.isArray(config.actions) ? config.actions : [];
237
+ if (config.mode === "any") {
238
+ mode = "any";
239
+ }
240
+ enforceBatchMode = Boolean(config.enforceBatchUpdateExecutionMode);
241
+ } else if (typeof config === "string") {
242
+ actions = [config];
243
+ }
244
+ const user = ctx?.state?.user;
245
+ const userAbility = ctx?.state?.userAbility;
246
+ const isSuperAdmin = Boolean(
247
+ user?.isSuperAdmin === true || Array.isArray(user?.roles) && user.roles.some((r) => r?.code === "strapi-super-admin" || r?.name === "Super Admin")
248
+ );
249
+ if (isSuperAdmin) {
250
+ return true;
251
+ }
252
+ let batchModeActions = null;
253
+ if (enforceBatchMode) {
254
+ const resolved = resolveBatchUpdateRequiredPermissions(ctx?.request?.body);
255
+ if (!resolved.valid) {
256
+ setForbiddenResponse(ctx, resolved.reason || "You do not have permission to perform this action.");
257
+ return false;
258
+ }
259
+ batchModeActions = resolved.actions;
260
+ }
261
+ if ((!actions || actions.length === 0) && (!batchModeActions || batchModeActions.length === 0)) {
262
+ return true;
263
+ }
264
+ const evaluateActions = (reqActions, evalMode) => {
265
+ if (!reqActions || reqActions.length === 0) return true;
266
+ if (userAbility && typeof userAbility.can === "function") {
267
+ if (userAbility.can("manage", "all") || userAbility.can("*")) {
268
+ return true;
269
+ }
270
+ return evalMode === "any" ? reqActions.some((act) => userAbility.can(act)) : reqActions.every((act) => userAbility.can(act));
271
+ }
272
+ 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) : [];
273
+ if (permissions.includes("*") || permissions.includes("admin::all")) {
274
+ return true;
275
+ }
276
+ return evalMode === "any" ? reqActions.some((act) => permissions.includes(act)) : reqActions.every((act) => permissions.includes(act));
277
+ };
278
+ const baseAllowed = evaluateActions(actions, mode);
279
+ if (!baseAllowed) {
280
+ setForbiddenResponse(ctx);
281
+ return false;
282
+ }
283
+ if (batchModeActions && !evaluateActions(batchModeActions, "all")) {
284
+ setForbiddenResponse(
285
+ ctx,
286
+ `You do not have permission to perform this batch update action (required: ${batchModeActions.join(", ")}).`
287
+ );
288
+ return false;
289
+ }
290
+ return true;
291
+ };
148
292
  function requirePermissions(actions, mode = "all") {
149
293
  return [
150
294
  {
@@ -214,7 +358,12 @@ const routes = {
214
358
  path: "/batch-update",
215
359
  handler: "bulkUpdater.batchUpdate",
216
360
  config: {
217
- policies: requirePermissions(PERMISSIONS.workspaceExecute)
361
+ policies: [
362
+ {
363
+ name: "plugin::bulk-updater.hasPermissions",
364
+ config: BATCH_UPDATE_POLICY_CONFIG
365
+ }
366
+ ]
218
367
  }
219
368
  },
220
369
  {
@@ -448,75 +597,8 @@ const routes = {
448
597
  ]
449
598
  }
450
599
  };
451
- const hasPermissions = (policyContext, config, { strapi } = {}) => {
452
- const ctx = policyContext?.isSelect ? policyContext : policyContext?.context || policyContext;
453
- let actions = [];
454
- let mode = "all";
455
- if (Array.isArray(config)) {
456
- actions = config;
457
- } else if (config && typeof config === "object") {
458
- actions = Array.isArray(config.actions) ? config.actions : [];
459
- if (config.mode === "any") {
460
- mode = "any";
461
- }
462
- } else if (typeof config === "string") {
463
- actions = [config];
464
- }
465
- if (!actions || actions.length === 0) {
466
- return true;
467
- }
468
- const user = ctx?.state?.user;
469
- const userAbility = ctx?.state?.userAbility;
470
- const isSuperAdmin = Boolean(
471
- user?.isSuperAdmin === true || Array.isArray(user?.roles) && user.roles.some((r) => r?.code === "strapi-super-admin" || r?.name === "Super Admin")
472
- );
473
- if (isSuperAdmin) {
474
- return true;
475
- }
476
- if (userAbility && typeof userAbility.can === "function") {
477
- if (userAbility.can("manage", "all") || userAbility.can("*")) {
478
- return true;
479
- }
480
- const isAllowed2 = mode === "any" ? actions.some((act) => userAbility.can(act)) : actions.every((act) => userAbility.can(act));
481
- if (isAllowed2) {
482
- return true;
483
- }
484
- if (ctx) {
485
- ctx.status = 403;
486
- ctx.body = {
487
- data: null,
488
- error: {
489
- status: 403,
490
- name: "ForbiddenError",
491
- message: "You do not have permission to perform this action."
492
- }
493
- };
494
- }
495
- return false;
496
- }
497
- 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) : [];
498
- if (permissions.includes("*") || permissions.includes("admin::all")) {
499
- return true;
500
- }
501
- const isAllowed = mode === "any" ? actions.some((act) => permissions.includes(act)) : actions.every((act) => permissions.includes(act));
502
- if (isAllowed) {
503
- return true;
504
- }
505
- if (ctx) {
506
- ctx.status = 403;
507
- ctx.body = {
508
- data: null,
509
- error: {
510
- status: 403,
511
- name: "ForbiddenError",
512
- message: "You do not have permission to perform this action."
513
- }
514
- };
515
- }
516
- return false;
517
- };
518
600
  const policies = {
519
- hasPermissions
601
+ hasPermissions: hasPermissionsPolicy
520
602
  };
521
603
  const auditLog = {
522
604
  collectionName: "bulk_updater_audit_logs",
@@ -793,6 +875,12 @@ const bulkUpdaterController = ({ strapi }) => ({
793
875
  try {
794
876
  const service = strapi.plugin("bulk-updater").service("bulkUpdater");
795
877
  const currentUser = ctx.state.user;
878
+ const hasAuthContext = Boolean(
879
+ ctx?.state?.userAbility || Array.isArray(ctx?.state?.permissions) || Array.isArray(ctx?.state?.user?.permissions) || ctx?.state?.user?.isSuperAdmin !== void 0
880
+ );
881
+ if (hasAuthContext && !hasPermissionsPolicy(ctx, BATCH_UPDATE_POLICY_CONFIG, { strapi })) {
882
+ return;
883
+ }
796
884
  const result = await service.batchUpdate(ctx.request.body || {}, currentUser);
797
885
  ctx.body = result;
798
886
  } catch (err) {
@@ -4423,17 +4511,63 @@ function enumerateOccurrences(contentType, allComponents, entity, attrPath) {
4423
4511
  walk(contentType, entity, parts, [], false, void 0, void 0, void 0, true);
4424
4512
  return results;
4425
4513
  }
4514
+ function resolveRelationDisplayLabel(r) {
4515
+ if (!r || typeof r !== "object") return String(r ?? "");
4516
+ if (r.label && typeof r.label === "string" && r.label.trim()) return r.label.trim();
4517
+ const candidates = [
4518
+ "name",
4519
+ "title",
4520
+ "authorName",
4521
+ "label",
4522
+ "heading",
4523
+ "subject",
4524
+ "fullName",
4525
+ "username",
4526
+ "email",
4527
+ "slug"
4528
+ ];
4529
+ for (const field of candidates) {
4530
+ if (r[field] !== void 0 && r[field] !== null && String(r[field]).trim() !== "") {
4531
+ return String(r[field]).trim();
4532
+ }
4533
+ }
4534
+ if (r.firstname || r.lastname) {
4535
+ const fn = [r.firstname, r.lastname].filter(Boolean).join(" ").trim();
4536
+ if (fn) return fn;
4537
+ }
4538
+ const systemKeys = /* @__PURE__ */ new Set([
4539
+ "id",
4540
+ "documentId",
4541
+ "createdAt",
4542
+ "updatedAt",
4543
+ "publishedAt",
4544
+ "locale",
4545
+ "createdBy",
4546
+ "updatedBy",
4547
+ "__component"
4548
+ ]);
4549
+ for (const [k, v] of Object.entries(r)) {
4550
+ if (!systemKeys.has(k) && typeof v === "string" && v.trim() !== "") {
4551
+ return v.trim();
4552
+ }
4553
+ }
4554
+ return r.documentId || (r.id !== void 0 && r.id !== null ? `Entry #${r.id}` : "");
4555
+ }
4426
4556
  function formatRelationState(currentRel, isMulti) {
4427
4557
  if (isMulti && Array.isArray(currentRel)) {
4428
4558
  const oldDocIds = currentRel.map((r) => r?.documentId).filter(Boolean);
4429
- const oldDisplay = currentRel.map((r) => r?.name || r?.title || r?.email || r?.username || r?.documentId).filter(Boolean).join(", ") || "(unlinked / none)";
4559
+ const oldDisplay = currentRel.map((r) => resolveRelationDisplayLabel(r)).filter(Boolean).join(", ") || "(unlinked / none)";
4430
4560
  return { oldDocIds, oldDisplay };
4431
4561
  }
4432
4562
  if (currentRel && typeof currentRel === "object") {
4433
4563
  const oldDocIds = currentRel.documentId ? [currentRel.documentId] : [];
4434
- const oldDisplay = currentRel.name || currentRel.title || currentRel.email || currentRel.username || currentRel.documentId || "(unlinked / none)";
4564
+ const oldDisplay = resolveRelationDisplayLabel(currentRel) || "(unlinked / none)";
4435
4565
  return { oldDocIds, oldDisplay };
4436
4566
  }
4567
+ if (typeof currentRel === "string" && currentRel.trim()) {
4568
+ const docId = currentRel.trim();
4569
+ return { oldDocIds: [docId], oldDisplay: resolveRelationDisplayLabel(docId) };
4570
+ }
4437
4571
  return { oldDocIds: [], oldDisplay: "(unlinked / none)" };
4438
4572
  }
4439
4573
  function resolveRelationCommand(rawValue, isMulti, forComponentNested = false) {
@@ -5021,6 +5155,9 @@ const modelsCache = /* @__PURE__ */ new Map();
5021
5155
  const MAX_QUERY_CACHE_SIZE = 500;
5022
5156
  const CACHE_TTL_MS = 60 * 1e3;
5023
5157
  let staticSchemaCache = null;
5158
+ function clearStaticSchemaCache() {
5159
+ staticSchemaCache = null;
5160
+ }
5024
5161
  function formatEntryRecord(entry) {
5025
5162
  if (!entry || typeof entry !== "object") return entry;
5026
5163
  const formatted = {
@@ -5314,9 +5451,26 @@ function buildDeepPopulate(attributes, allComponents, depth = 0) {
5314
5451
  populate[key] = true;
5315
5452
  }
5316
5453
  } else if (def.type === "dynamiczone") {
5317
- populate[key] = {
5318
- populate: "*"
5319
- };
5454
+ const dzComps = Array.isArray(def.components) ? def.components : [];
5455
+ const onPopulate = {};
5456
+ for (const compUid of dzComps) {
5457
+ const comp = allComponents?.[compUid];
5458
+ if (comp?.attributes) {
5459
+ const subPopulate = buildDeepPopulate(comp.attributes, allComponents, depth + 1);
5460
+ if (subPopulate && Object.keys(subPopulate).length > 0) {
5461
+ onPopulate[compUid] = { populate: subPopulate };
5462
+ }
5463
+ }
5464
+ }
5465
+ if (Object.keys(onPopulate).length > 0) {
5466
+ populate[key] = {
5467
+ on: onPopulate
5468
+ };
5469
+ } else {
5470
+ populate[key] = {
5471
+ populate: "*"
5472
+ };
5473
+ }
5320
5474
  } else if (def.type === "relation" || def.type === "media") {
5321
5475
  populate[key] = true;
5322
5476
  }
@@ -5380,6 +5534,22 @@ function discoverComponentAttributes(strapi, compUid, prefix, currentDepth, maxD
5380
5534
  };
5381
5535
  relationsByAttr[fullPath] = relMeta;
5382
5536
  allRelationsMeta[fullPath] = relMeta;
5537
+ if (prefix && !relationsByAttr[prefix]) {
5538
+ relationsByAttr[prefix] = relMeta;
5539
+ }
5540
+ if (compUid) {
5541
+ const compClean = compUid.includes(".") ? compUid.split(".")[1] : compUid;
5542
+ const compCleanUnder = compClean.replace(/-/g, "_");
5543
+ const compCleanHyphen = compClean.replace(/_/g, "-");
5544
+ const aliases = /* @__PURE__ */ new Set([compUid, compClean, compCleanUnder, compCleanHyphen]);
5545
+ for (const alias of aliases) {
5546
+ const aliasSub = `${alias}.${subKey}`;
5547
+ if (!relationsByAttr[aliasSub]) relationsByAttr[aliasSub] = relMeta;
5548
+ if (!relationsByAttr[alias]) relationsByAttr[alias] = relMeta;
5549
+ if (!allRelationsMeta[aliasSub]) allRelationsMeta[aliasSub] = relMeta;
5550
+ if (!allRelationsMeta[alias]) allRelationsMeta[alias] = relMeta;
5551
+ }
5552
+ }
5383
5553
  attributesMeta[fullPath] = buildRichAttributeMeta(subAttr, {
5384
5554
  depth: currentDepth,
5385
5555
  type: "relation",
@@ -5437,7 +5607,10 @@ function getAllNestedValues(obj, path) {
5437
5607
  rootTarget.forEach((item, idx) => {
5438
5608
  if (!item || typeof item !== "object") return;
5439
5609
  if (parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) return;
5440
- if (parsed.targetComponentUid && item.__component !== parsed.targetComponentUid) return;
5610
+ const itemComp = item.__component;
5611
+ const targetComp = parsed.targetComponentUid;
5612
+ const compMatches = !targetComp || itemComp === targetComp || itemComp && (itemComp.toLowerCase() === targetComp.toLowerCase() || itemComp.split(".")[1]?.toLowerCase() === targetComp.toLowerCase() || itemComp.toLowerCase().replace(/[-_]/g, "") === targetComp.toLowerCase().replace(/[-_]/g, ""));
5613
+ if (!compMatches) return;
5441
5614
  const compSchema = global.strapi?.components?.[item.__component];
5442
5615
  const fieldInSchema = tail.length > 0 && compSchema?.attributes ? tail[0] in compSchema.attributes : false;
5443
5616
  if (tail.length > 0) {
@@ -6435,10 +6608,10 @@ async function executeBatchInternal(strapi, {
6435
6608
  let oldDisplay = "";
6436
6609
  if (isMulti && Array.isArray(currentRel)) {
6437
6610
  oldDocIds = currentRel.map((r) => r.documentId).filter(Boolean);
6438
- oldDisplay = currentRel.map((r) => r.name || r.title || r.email || r.documentId).join(", ") || "(empty)";
6611
+ oldDisplay = currentRel.map((r) => resolveRelationDisplayLabel(r)).join(", ") || "(empty)";
6439
6612
  } else if (currentRel) {
6440
6613
  oldDocIds = currentRel.documentId ? [currentRel.documentId] : [];
6441
- oldDisplay = currentRel.name || currentRel.title || currentRel.email || currentRel.documentId || "(empty)";
6614
+ oldDisplay = resolveRelationDisplayLabel(currentRel) || "(empty)";
6442
6615
  } else {
6443
6616
  oldDisplay = "(unlinked / none)";
6444
6617
  }
@@ -7450,7 +7623,7 @@ const bulkUpdaterService = ({ strapi }) => {
7450
7623
  if (v === void 0 || v === null) return false;
7451
7624
  if (Array.isArray(v)) return v.some(testSingleValue);
7452
7625
  if (typeof v === "object") {
7453
- return testSingleValue(v.name) || testSingleValue(v.title) || testSingleValue(v.email) || testSingleValue(v.username) || testSingleValue(v.documentId) || testSingleValue(v.id) || testSingleValue(v.slug);
7626
+ 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);
7454
7627
  }
7455
7628
  const valStr = String(v).trim().toLowerCase();
7456
7629
  switch (normOp) {
@@ -7554,8 +7727,43 @@ const bulkUpdaterService = ({ strapi }) => {
7554
7727
  limit: 100,
7555
7728
  sort: { createdAt: "desc" }
7556
7729
  });
7730
+ const targetCt = strapi.contentTypes[targetUid];
7731
+ const mainField = targetCt?.info?.mainField;
7732
+ const schemaAttrs = targetCt?.attributes || {};
7733
+ const candidateFields = [
7734
+ "name",
7735
+ "title",
7736
+ "authorName",
7737
+ "label",
7738
+ "heading",
7739
+ "subject",
7740
+ "fullName",
7741
+ "username",
7742
+ "email",
7743
+ "slug"
7744
+ ];
7745
+ const systemAttrs = ["createdAt", "updatedAt", "publishedAt", "locale", "createdBy", "updatedBy"];
7746
+ const stringAttr = Object.keys(schemaAttrs).find(
7747
+ (k) => !systemAttrs.includes(k) && ["string", "text", "uid"].includes(schemaAttrs[k]?.type)
7748
+ );
7557
7749
  const options = (docs || []).map((doc) => {
7558
- const label = doc.name || doc.title || doc.email || doc.username || `Entry #${doc.id || doc.documentId}`;
7750
+ let label = "";
7751
+ if (mainField && doc[mainField] !== void 0 && doc[mainField] !== null && String(doc[mainField]).trim() !== "") {
7752
+ label = String(doc[mainField]).trim();
7753
+ } else {
7754
+ for (const cand of candidateFields) {
7755
+ if (doc[cand] !== void 0 && doc[cand] !== null && String(doc[cand]).trim() !== "") {
7756
+ label = String(doc[cand]).trim();
7757
+ break;
7758
+ }
7759
+ }
7760
+ if (!label && stringAttr && doc[stringAttr] !== void 0 && doc[stringAttr] !== null && String(doc[stringAttr]).trim() !== "") {
7761
+ label = String(doc[stringAttr]).trim();
7762
+ }
7763
+ }
7764
+ if (!label) {
7765
+ label = `Entry #${doc.id || doc.documentId}`;
7766
+ }
7559
7767
  return {
7560
7768
  documentId: doc.documentId,
7561
7769
  label
@@ -7943,10 +8151,10 @@ const bulkUpdaterService = ({ strapi }) => {
7943
8151
  let oldDisplay = "";
7944
8152
  if (isMulti && Array.isArray(currentRel)) {
7945
8153
  oldDocIds = currentRel.map((r) => r.documentId).filter(Boolean);
7946
- oldDisplay = currentRel.map((r) => r.name || r.title || r.email || r.documentId).join(", ") || "(empty)";
8154
+ oldDisplay = currentRel.map((r) => resolveRelationDisplayLabel(r)).join(", ") || "(empty)";
7947
8155
  } else if (currentRel) {
7948
8156
  oldDocIds = currentRel.documentId ? [currentRel.documentId] : [];
7949
- oldDisplay = currentRel.name || currentRel.title || currentRel.email || currentRel.documentId || "(empty)";
8157
+ oldDisplay = resolveRelationDisplayLabel(currentRel) || "(empty)";
7950
8158
  } else {
7951
8159
  oldDisplay = "(unlinked / none)";
7952
8160
  }
@@ -12627,6 +12835,7 @@ exports.buildExportColumnPlan = buildExportColumnPlan;
12627
12835
  exports.buildLosslessPopulate = buildLosslessPopulate;
12628
12836
  exports.buildRichAttributeMeta = buildRichAttributeMeta;
12629
12837
  exports.classifyAttribute = classifyAttribute;
12838
+ exports.clearStaticSchemaCache = clearStaticSchemaCache;
12630
12839
  exports.coerceAndValidateFieldValue = coerceAndValidateFieldValue;
12631
12840
  exports.deepCloneValue = deepCloneValue;
12632
12841
  exports.deepEqualValues = deepEqualValues;
@@ -12642,6 +12851,7 @@ exports.extractMetadataFromRow = extractMetadataFromRow;
12642
12851
  exports.extractRowFlattenedMetadata = extractRowFlattenedMetadata;
12643
12852
  exports.formatErrorCsvFilename = formatErrorCsvFilename;
12644
12853
  exports.formatErrorWithCause = formatErrorWithCause;
12854
+ exports.formatRelationState = formatRelationState;
12645
12855
  exports.getActiveBulkOperationCount = getActiveBulkOperationCount;
12646
12856
  exports.getAllNestedValues = getAllNestedValues;
12647
12857
  exports.getBatchConcurrency = getBatchConcurrency;
@@ -12665,6 +12875,7 @@ exports.resolveComponentPayload = resolveComponentPayload;
12665
12875
  exports.resolveDynamicZonePayload = resolveDynamicZonePayload;
12666
12876
  exports.resolveErrorColumnName = resolveErrorColumnName;
12667
12877
  exports.resolveMediaIds = resolveMediaIds;
12878
+ exports.resolveRelationDisplayLabel = resolveRelationDisplayLabel;
12668
12879
  exports.resolveRelationPayload = resolveRelationPayload;
12669
12880
  exports.resolveTargetObjectField = resolveTargetObjectField;
12670
12881
  exports.sanitizeSensitiveErrorText = sanitizeSensitiveErrorText;