strapi-plugin-bulk-updater 1.6.9 → 1.6.11
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-CKDhgvZ6.js → BulkUpdater-BSlEEUTV.js} +294 -116
- package/dist/_chunks/BulkUpdater-BSlEEUTV.js.map +1 -0
- package/dist/_chunks/{BulkUpdater-4E6M5K8J.mjs → BulkUpdater-CFStXO-q.mjs} +296 -118
- package/dist/_chunks/BulkUpdater-CFStXO-q.mjs.map +1 -0
- package/dist/_chunks/{ScopedQuotaSelectInput-BsBpmwun.js → ScopedQuotaSelectInput-BC2Ge-Iv.js} +9 -4
- package/dist/_chunks/ScopedQuotaSelectInput-BC2Ge-Iv.js.map +1 -0
- package/dist/_chunks/{ScopedQuotaSelectInput-YKdQgrPt.mjs → ScopedQuotaSelectInput-DPIIa3XO.mjs} +9 -4
- package/dist/_chunks/ScopedQuotaSelectInput-DPIIa3XO.mjs.map +1 -0
- package/dist/_chunks/{SettingsPage-Crh2syU4.js → SettingsPage-BgEO2BNP.js} +2 -2
- package/dist/_chunks/{SettingsPage-Crh2syU4.js.map → SettingsPage-BgEO2BNP.js.map} +1 -1
- package/dist/_chunks/{SettingsPage-BX9sCRmw.mjs → SettingsPage-BrfS4_qy.mjs} +2 -2
- package/dist/_chunks/{SettingsPage-BX9sCRmw.mjs.map → SettingsPage-BrfS4_qy.mjs.map} +1 -1
- package/dist/_chunks/{ValidationRulesTab-BqbENLpg.mjs → ValidationRulesTab-BslJyrBj.mjs} +146 -80
- package/dist/_chunks/ValidationRulesTab-BslJyrBj.mjs.map +1 -0
- package/dist/_chunks/{ValidationRulesTab-R1vlW2wY.js → ValidationRulesTab-Cs0YDlMx.js} +145 -79
- package/dist/_chunks/ValidationRulesTab-Cs0YDlMx.js.map +1 -0
- package/dist/_chunks/index-4eNIGyGu.mjs +229 -0
- package/dist/_chunks/index-4eNIGyGu.mjs.map +1 -0
- package/dist/_chunks/index-CjR6IZqM.js +230 -0
- package/dist/_chunks/index-CjR6IZqM.js.map +1 -0
- package/dist/admin/index.js +4 -196
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +4 -194
- package/dist/admin/index.mjs.map +1 -1
- package/dist/server/index.js +215 -21
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +215 -21
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/_chunks/BulkUpdater-4E6M5K8J.mjs.map +0 -1
- package/dist/_chunks/BulkUpdater-CKDhgvZ6.js.map +0 -1
- package/dist/_chunks/ScopedQuotaSelectInput-BsBpmwun.js.map +0 -1
- package/dist/_chunks/ScopedQuotaSelectInput-YKdQgrPt.mjs.map +0 -1
- package/dist/_chunks/ValidationRulesTab-BqbENLpg.mjs.map +0 -1
- package/dist/_chunks/ValidationRulesTab-R1vlW2wY.js.map +0 -1
package/dist/server/index.js
CHANGED
|
@@ -6,8 +6,9 @@ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
|
6
6
|
const crypto__default = /* @__PURE__ */ _interopDefault(crypto);
|
|
7
7
|
const PLUGIN_ID = "bulk-updater";
|
|
8
8
|
const PERMISSIONS = {
|
|
9
|
-
// General
|
|
9
|
+
// General (support both .read and .access aliases)
|
|
10
10
|
read: `plugin::${PLUGIN_ID}.read`,
|
|
11
|
+
access: `plugin::${PLUGIN_ID}.access`,
|
|
11
12
|
// Workspace
|
|
12
13
|
workspaceView: `plugin::${PLUGIN_ID}.workspace.view`,
|
|
13
14
|
workspaceExecute: `plugin::${PLUGIN_ID}.workspace.execute`,
|
|
@@ -466,10 +467,16 @@ const hasPermissions = (policyContext, config, { strapi } = {}) => {
|
|
|
466
467
|
}
|
|
467
468
|
const user = ctx?.state?.user;
|
|
468
469
|
const userAbility = ctx?.state?.userAbility;
|
|
469
|
-
|
|
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) {
|
|
470
474
|
return true;
|
|
471
475
|
}
|
|
472
476
|
if (userAbility && typeof userAbility.can === "function") {
|
|
477
|
+
if (userAbility.can("manage", "all") || userAbility.can("*")) {
|
|
478
|
+
return true;
|
|
479
|
+
}
|
|
473
480
|
const isAllowed2 = mode === "any" ? actions.some((act) => userAbility.can(act)) : actions.every((act) => userAbility.can(act));
|
|
474
481
|
if (isAllowed2) {
|
|
475
482
|
return true;
|
|
@@ -488,7 +495,7 @@ const hasPermissions = (policyContext, config, { strapi } = {}) => {
|
|
|
488
495
|
return false;
|
|
489
496
|
}
|
|
490
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) : [];
|
|
491
|
-
if (permissions.includes("*")) {
|
|
498
|
+
if (permissions.includes("*") || permissions.includes("admin::all")) {
|
|
492
499
|
return true;
|
|
493
500
|
}
|
|
494
501
|
const isAllowed = mode === "any" ? actions.some((act) => permissions.includes(act)) : actions.every((act) => permissions.includes(act));
|
|
@@ -1594,6 +1601,37 @@ function filterAndEnrichRules(strapi, collectionUid, activeRules) {
|
|
|
1594
1601
|
}
|
|
1595
1602
|
return effectiveRules;
|
|
1596
1603
|
}
|
|
1604
|
+
function normalizeRuleQuotas(quotas) {
|
|
1605
|
+
const result = {};
|
|
1606
|
+
if (!quotas) return result;
|
|
1607
|
+
if (Array.isArray(quotas)) {
|
|
1608
|
+
for (const item of quotas) {
|
|
1609
|
+
if (item && typeof item === "object") {
|
|
1610
|
+
const key = item.key || item.option || item.name || item.val || item.value;
|
|
1611
|
+
const max = item.maxAllowed ?? item.max ?? item.quota ?? item.limit ?? item.value;
|
|
1612
|
+
if (key && max !== void 0) {
|
|
1613
|
+
result[String(key).trim().toLowerCase()] = Math.max(1, parseInt(String(max), 10) || 1);
|
|
1614
|
+
}
|
|
1615
|
+
} else if (typeof item === "string" && item.trim()) {
|
|
1616
|
+
result[item.trim().toLowerCase()] = 1;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
} else if (typeof quotas === "object") {
|
|
1620
|
+
for (const [k, v] of Object.entries(quotas)) {
|
|
1621
|
+
if (v && typeof v === "object" && ("key" in v || "maxAllowed" in v || "value" in v)) {
|
|
1622
|
+
const item = v;
|
|
1623
|
+
const key = item.key || item.option || item.name || k;
|
|
1624
|
+
const max = item.maxAllowed ?? item.max ?? item.quota ?? item.value;
|
|
1625
|
+
if (key && max !== void 0) {
|
|
1626
|
+
result[String(key).trim().toLowerCase()] = Math.max(1, parseInt(String(max), 10) || 1);
|
|
1627
|
+
}
|
|
1628
|
+
} else {
|
|
1629
|
+
result[String(k).trim().toLowerCase()] = Math.max(1, parseInt(String(v), 10) || 1);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
return result;
|
|
1634
|
+
}
|
|
1597
1635
|
async function validateEntityQuotas(strapi, collectionUid, entity, customRules) {
|
|
1598
1636
|
if (!entity || typeof entity !== "object") {
|
|
1599
1637
|
return { isValid: true };
|
|
@@ -1678,7 +1716,8 @@ async function validateEntityQuotas(strapi, collectionUid, entity, customRules)
|
|
|
1678
1716
|
for (const rule of effectiveRules) {
|
|
1679
1717
|
const ruleCounts = structuredCounts[rule.id] || {};
|
|
1680
1718
|
const rtRuleCounts = richTextCounts[rule.id] || {};
|
|
1681
|
-
|
|
1719
|
+
const effectiveQuotas = normalizeRuleQuotas(rule.quotas);
|
|
1720
|
+
for (const [quotaKey, maxAllowed] of Object.entries(effectiveQuotas)) {
|
|
1682
1721
|
const lowerVal = quotaKey.toLowerCase().trim();
|
|
1683
1722
|
const structCount = ruleCounts[lowerVal] || 0;
|
|
1684
1723
|
const rtCount = rule.includeRichTextHtml ? rtRuleCounts[lowerVal] || 0 : 0;
|
|
@@ -1725,19 +1764,38 @@ const validationRulesService = ({ strapi }) => ({
|
|
|
1725
1764
|
await store.set({ value: { rules: DEFAULT_RULES } });
|
|
1726
1765
|
return DEFAULT_RULES;
|
|
1727
1766
|
}
|
|
1728
|
-
|
|
1767
|
+
let needsResave = false;
|
|
1768
|
+
const sanitizedRules = stored.rules.map((rule) => {
|
|
1769
|
+
const normalizedQuotas = normalizeRuleQuotas(rule.quotas);
|
|
1770
|
+
if (Array.isArray(rule.quotas)) {
|
|
1771
|
+
needsResave = true;
|
|
1772
|
+
}
|
|
1773
|
+
return {
|
|
1774
|
+
...rule,
|
|
1775
|
+
quotas: normalizedQuotas
|
|
1776
|
+
};
|
|
1777
|
+
});
|
|
1778
|
+
if (needsResave) {
|
|
1779
|
+
try {
|
|
1780
|
+
await store.set({ value: { rules: sanitizedRules } });
|
|
1781
|
+
} catch (err) {
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
return sanitizedRules;
|
|
1729
1785
|
},
|
|
1730
1786
|
async saveRule(ruleData) {
|
|
1731
1787
|
const store = await this.getStore();
|
|
1732
1788
|
const rules = await this.getRules();
|
|
1733
1789
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1734
1790
|
let savedRule;
|
|
1791
|
+
const normalizedQuotas = normalizeRuleQuotas(ruleData.quotas || { h1: 1 });
|
|
1735
1792
|
if (ruleData.id) {
|
|
1736
1793
|
const index2 = rules.findIndex((r) => r.id === ruleData.id);
|
|
1737
1794
|
if (index2 !== -1) {
|
|
1738
1795
|
savedRule = {
|
|
1739
1796
|
...rules[index2],
|
|
1740
1797
|
...ruleData,
|
|
1798
|
+
quotas: normalizedQuotas,
|
|
1741
1799
|
collectionUid: ruleData.collectionUid !== void 0 ? ruleData.collectionUid : rules[index2].collectionUid || "*",
|
|
1742
1800
|
includeRichTextHtml: ruleData.includeRichTextHtml !== void 0 ? Boolean(ruleData.includeRichTextHtml) : Boolean(rules[index2].includeRichTextHtml),
|
|
1743
1801
|
richTextFields: Array.isArray(ruleData.richTextFields) ? ruleData.richTextFields : rules[index2].richTextFields || [],
|
|
@@ -1751,7 +1809,7 @@ const validationRulesService = ({ strapi }) => ({
|
|
|
1751
1809
|
description: ruleData.description || "",
|
|
1752
1810
|
collectionUid: ruleData.collectionUid || "*",
|
|
1753
1811
|
targetField: ruleData.targetField || "headingLevel",
|
|
1754
|
-
quotas:
|
|
1812
|
+
quotas: normalizedQuotas,
|
|
1755
1813
|
exceededAction: ruleData.exceededAction || "disable",
|
|
1756
1814
|
enabled: ruleData.enabled ?? true,
|
|
1757
1815
|
scope: ruleData.scope || "entry",
|
|
@@ -1770,7 +1828,7 @@ const validationRulesService = ({ strapi }) => ({
|
|
|
1770
1828
|
description: ruleData.description || "",
|
|
1771
1829
|
collectionUid: ruleData.collectionUid || "*",
|
|
1772
1830
|
targetField: ruleData.targetField || "headingLevel",
|
|
1773
|
-
quotas:
|
|
1831
|
+
quotas: normalizedQuotas,
|
|
1774
1832
|
exceededAction: ruleData.exceededAction || "disable",
|
|
1775
1833
|
enabled: ruleData.enabled ?? true,
|
|
1776
1834
|
scope: ruleData.scope || "entry",
|
|
@@ -1814,7 +1872,7 @@ const validationRulesService = ({ strapi }) => ({
|
|
|
1814
1872
|
throw new Error(`Validation rule ${ruleId} not found`);
|
|
1815
1873
|
}
|
|
1816
1874
|
const targetField = rule.targetField;
|
|
1817
|
-
const quotas = rule.quotas
|
|
1875
|
+
const quotas = normalizeRuleQuotas(rule.quotas);
|
|
1818
1876
|
const violations = [];
|
|
1819
1877
|
let totalScanned = 0;
|
|
1820
1878
|
const allContentTypes = strapi.contentTypes || {};
|
|
@@ -4365,17 +4423,63 @@ function enumerateOccurrences(contentType, allComponents, entity, attrPath) {
|
|
|
4365
4423
|
walk(contentType, entity, parts, [], false, void 0, void 0, void 0, true);
|
|
4366
4424
|
return results;
|
|
4367
4425
|
}
|
|
4426
|
+
function resolveRelationDisplayLabel(r) {
|
|
4427
|
+
if (!r || typeof r !== "object") return String(r ?? "");
|
|
4428
|
+
if (r.label && typeof r.label === "string" && r.label.trim()) return r.label.trim();
|
|
4429
|
+
const candidates = [
|
|
4430
|
+
"name",
|
|
4431
|
+
"title",
|
|
4432
|
+
"authorName",
|
|
4433
|
+
"label",
|
|
4434
|
+
"heading",
|
|
4435
|
+
"subject",
|
|
4436
|
+
"fullName",
|
|
4437
|
+
"username",
|
|
4438
|
+
"email",
|
|
4439
|
+
"slug"
|
|
4440
|
+
];
|
|
4441
|
+
for (const field of candidates) {
|
|
4442
|
+
if (r[field] !== void 0 && r[field] !== null && String(r[field]).trim() !== "") {
|
|
4443
|
+
return String(r[field]).trim();
|
|
4444
|
+
}
|
|
4445
|
+
}
|
|
4446
|
+
if (r.firstname || r.lastname) {
|
|
4447
|
+
const fn = [r.firstname, r.lastname].filter(Boolean).join(" ").trim();
|
|
4448
|
+
if (fn) return fn;
|
|
4449
|
+
}
|
|
4450
|
+
const systemKeys = /* @__PURE__ */ new Set([
|
|
4451
|
+
"id",
|
|
4452
|
+
"documentId",
|
|
4453
|
+
"createdAt",
|
|
4454
|
+
"updatedAt",
|
|
4455
|
+
"publishedAt",
|
|
4456
|
+
"locale",
|
|
4457
|
+
"createdBy",
|
|
4458
|
+
"updatedBy",
|
|
4459
|
+
"__component"
|
|
4460
|
+
]);
|
|
4461
|
+
for (const [k, v] of Object.entries(r)) {
|
|
4462
|
+
if (!systemKeys.has(k) && typeof v === "string" && v.trim() !== "") {
|
|
4463
|
+
return v.trim();
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
return r.documentId || (r.id !== void 0 && r.id !== null ? `Entry #${r.id}` : "");
|
|
4467
|
+
}
|
|
4368
4468
|
function formatRelationState(currentRel, isMulti) {
|
|
4369
4469
|
if (isMulti && Array.isArray(currentRel)) {
|
|
4370
4470
|
const oldDocIds = currentRel.map((r) => r?.documentId).filter(Boolean);
|
|
4371
|
-
const oldDisplay = currentRel.map((r) => r
|
|
4471
|
+
const oldDisplay = currentRel.map((r) => resolveRelationDisplayLabel(r)).filter(Boolean).join(", ") || "(unlinked / none)";
|
|
4372
4472
|
return { oldDocIds, oldDisplay };
|
|
4373
4473
|
}
|
|
4374
4474
|
if (currentRel && typeof currentRel === "object") {
|
|
4375
4475
|
const oldDocIds = currentRel.documentId ? [currentRel.documentId] : [];
|
|
4376
|
-
const oldDisplay = currentRel
|
|
4476
|
+
const oldDisplay = resolveRelationDisplayLabel(currentRel) || "(unlinked / none)";
|
|
4377
4477
|
return { oldDocIds, oldDisplay };
|
|
4378
4478
|
}
|
|
4479
|
+
if (typeof currentRel === "string" && currentRel.trim()) {
|
|
4480
|
+
const docId = currentRel.trim();
|
|
4481
|
+
return { oldDocIds: [docId], oldDisplay: resolveRelationDisplayLabel(docId) };
|
|
4482
|
+
}
|
|
4379
4483
|
return { oldDocIds: [], oldDisplay: "(unlinked / none)" };
|
|
4380
4484
|
}
|
|
4381
4485
|
function resolveRelationCommand(rawValue, isMulti, forComponentNested = false) {
|
|
@@ -4963,6 +5067,9 @@ const modelsCache = /* @__PURE__ */ new Map();
|
|
|
4963
5067
|
const MAX_QUERY_CACHE_SIZE = 500;
|
|
4964
5068
|
const CACHE_TTL_MS = 60 * 1e3;
|
|
4965
5069
|
let staticSchemaCache = null;
|
|
5070
|
+
function clearStaticSchemaCache() {
|
|
5071
|
+
staticSchemaCache = null;
|
|
5072
|
+
}
|
|
4966
5073
|
function formatEntryRecord(entry) {
|
|
4967
5074
|
if (!entry || typeof entry !== "object") return entry;
|
|
4968
5075
|
const formatted = {
|
|
@@ -5256,9 +5363,26 @@ function buildDeepPopulate(attributes, allComponents, depth = 0) {
|
|
|
5256
5363
|
populate[key] = true;
|
|
5257
5364
|
}
|
|
5258
5365
|
} else if (def.type === "dynamiczone") {
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5366
|
+
const dzComps = Array.isArray(def.components) ? def.components : [];
|
|
5367
|
+
const onPopulate = {};
|
|
5368
|
+
for (const compUid of dzComps) {
|
|
5369
|
+
const comp = allComponents?.[compUid];
|
|
5370
|
+
if (comp?.attributes) {
|
|
5371
|
+
const subPopulate = buildDeepPopulate(comp.attributes, allComponents, depth + 1);
|
|
5372
|
+
if (subPopulate && Object.keys(subPopulate).length > 0) {
|
|
5373
|
+
onPopulate[compUid] = { populate: subPopulate };
|
|
5374
|
+
}
|
|
5375
|
+
}
|
|
5376
|
+
}
|
|
5377
|
+
if (Object.keys(onPopulate).length > 0) {
|
|
5378
|
+
populate[key] = {
|
|
5379
|
+
on: onPopulate
|
|
5380
|
+
};
|
|
5381
|
+
} else {
|
|
5382
|
+
populate[key] = {
|
|
5383
|
+
populate: "*"
|
|
5384
|
+
};
|
|
5385
|
+
}
|
|
5262
5386
|
} else if (def.type === "relation" || def.type === "media") {
|
|
5263
5387
|
populate[key] = true;
|
|
5264
5388
|
}
|
|
@@ -5322,6 +5446,22 @@ function discoverComponentAttributes(strapi, compUid, prefix, currentDepth, maxD
|
|
|
5322
5446
|
};
|
|
5323
5447
|
relationsByAttr[fullPath] = relMeta;
|
|
5324
5448
|
allRelationsMeta[fullPath] = relMeta;
|
|
5449
|
+
if (prefix && !relationsByAttr[prefix]) {
|
|
5450
|
+
relationsByAttr[prefix] = relMeta;
|
|
5451
|
+
}
|
|
5452
|
+
if (compUid) {
|
|
5453
|
+
const compClean = compUid.includes(".") ? compUid.split(".")[1] : compUid;
|
|
5454
|
+
const compCleanUnder = compClean.replace(/-/g, "_");
|
|
5455
|
+
const compCleanHyphen = compClean.replace(/_/g, "-");
|
|
5456
|
+
const aliases = /* @__PURE__ */ new Set([compUid, compClean, compCleanUnder, compCleanHyphen]);
|
|
5457
|
+
for (const alias of aliases) {
|
|
5458
|
+
const aliasSub = `${alias}.${subKey}`;
|
|
5459
|
+
if (!relationsByAttr[aliasSub]) relationsByAttr[aliasSub] = relMeta;
|
|
5460
|
+
if (!relationsByAttr[alias]) relationsByAttr[alias] = relMeta;
|
|
5461
|
+
if (!allRelationsMeta[aliasSub]) allRelationsMeta[aliasSub] = relMeta;
|
|
5462
|
+
if (!allRelationsMeta[alias]) allRelationsMeta[alias] = relMeta;
|
|
5463
|
+
}
|
|
5464
|
+
}
|
|
5325
5465
|
attributesMeta[fullPath] = buildRichAttributeMeta(subAttr, {
|
|
5326
5466
|
depth: currentDepth,
|
|
5327
5467
|
type: "relation",
|
|
@@ -5379,7 +5519,10 @@ function getAllNestedValues(obj, path) {
|
|
|
5379
5519
|
rootTarget.forEach((item, idx) => {
|
|
5380
5520
|
if (!item || typeof item !== "object") return;
|
|
5381
5521
|
if (parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) return;
|
|
5382
|
-
|
|
5522
|
+
const itemComp = item.__component;
|
|
5523
|
+
const targetComp = parsed.targetComponentUid;
|
|
5524
|
+
const compMatches = !targetComp || itemComp === targetComp || itemComp && (itemComp.toLowerCase() === targetComp.toLowerCase() || itemComp.split(".")[1]?.toLowerCase() === targetComp.toLowerCase() || itemComp.toLowerCase().replace(/[-_]/g, "") === targetComp.toLowerCase().replace(/[-_]/g, ""));
|
|
5525
|
+
if (!compMatches) return;
|
|
5383
5526
|
const compSchema = global.strapi?.components?.[item.__component];
|
|
5384
5527
|
const fieldInSchema = tail.length > 0 && compSchema?.attributes ? tail[0] in compSchema.attributes : false;
|
|
5385
5528
|
if (tail.length > 0) {
|
|
@@ -6377,10 +6520,10 @@ async function executeBatchInternal(strapi, {
|
|
|
6377
6520
|
let oldDisplay = "";
|
|
6378
6521
|
if (isMulti && Array.isArray(currentRel)) {
|
|
6379
6522
|
oldDocIds = currentRel.map((r) => r.documentId).filter(Boolean);
|
|
6380
|
-
oldDisplay = currentRel.map((r) => r
|
|
6523
|
+
oldDisplay = currentRel.map((r) => resolveRelationDisplayLabel(r)).join(", ") || "(empty)";
|
|
6381
6524
|
} else if (currentRel) {
|
|
6382
6525
|
oldDocIds = currentRel.documentId ? [currentRel.documentId] : [];
|
|
6383
|
-
oldDisplay = currentRel
|
|
6526
|
+
oldDisplay = resolveRelationDisplayLabel(currentRel) || "(empty)";
|
|
6384
6527
|
} else {
|
|
6385
6528
|
oldDisplay = "(unlinked / none)";
|
|
6386
6529
|
}
|
|
@@ -7392,7 +7535,7 @@ const bulkUpdaterService = ({ strapi }) => {
|
|
|
7392
7535
|
if (v === void 0 || v === null) return false;
|
|
7393
7536
|
if (Array.isArray(v)) return v.some(testSingleValue);
|
|
7394
7537
|
if (typeof v === "object") {
|
|
7395
|
-
return testSingleValue(v.name) || testSingleValue(v.title) || testSingleValue(v.email) || testSingleValue(v.username) || testSingleValue(v.documentId) || testSingleValue(v.id) || testSingleValue(v.slug);
|
|
7538
|
+
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);
|
|
7396
7539
|
}
|
|
7397
7540
|
const valStr = String(v).trim().toLowerCase();
|
|
7398
7541
|
switch (normOp) {
|
|
@@ -7496,8 +7639,43 @@ const bulkUpdaterService = ({ strapi }) => {
|
|
|
7496
7639
|
limit: 100,
|
|
7497
7640
|
sort: { createdAt: "desc" }
|
|
7498
7641
|
});
|
|
7642
|
+
const targetCt = strapi.contentTypes[targetUid];
|
|
7643
|
+
const mainField = targetCt?.info?.mainField;
|
|
7644
|
+
const schemaAttrs = targetCt?.attributes || {};
|
|
7645
|
+
const candidateFields = [
|
|
7646
|
+
"name",
|
|
7647
|
+
"title",
|
|
7648
|
+
"authorName",
|
|
7649
|
+
"label",
|
|
7650
|
+
"heading",
|
|
7651
|
+
"subject",
|
|
7652
|
+
"fullName",
|
|
7653
|
+
"username",
|
|
7654
|
+
"email",
|
|
7655
|
+
"slug"
|
|
7656
|
+
];
|
|
7657
|
+
const systemAttrs = ["createdAt", "updatedAt", "publishedAt", "locale", "createdBy", "updatedBy"];
|
|
7658
|
+
const stringAttr = Object.keys(schemaAttrs).find(
|
|
7659
|
+
(k) => !systemAttrs.includes(k) && ["string", "text", "uid"].includes(schemaAttrs[k]?.type)
|
|
7660
|
+
);
|
|
7499
7661
|
const options = (docs || []).map((doc) => {
|
|
7500
|
-
|
|
7662
|
+
let label = "";
|
|
7663
|
+
if (mainField && doc[mainField] !== void 0 && doc[mainField] !== null && String(doc[mainField]).trim() !== "") {
|
|
7664
|
+
label = String(doc[mainField]).trim();
|
|
7665
|
+
} else {
|
|
7666
|
+
for (const cand of candidateFields) {
|
|
7667
|
+
if (doc[cand] !== void 0 && doc[cand] !== null && String(doc[cand]).trim() !== "") {
|
|
7668
|
+
label = String(doc[cand]).trim();
|
|
7669
|
+
break;
|
|
7670
|
+
}
|
|
7671
|
+
}
|
|
7672
|
+
if (!label && stringAttr && doc[stringAttr] !== void 0 && doc[stringAttr] !== null && String(doc[stringAttr]).trim() !== "") {
|
|
7673
|
+
label = String(doc[stringAttr]).trim();
|
|
7674
|
+
}
|
|
7675
|
+
}
|
|
7676
|
+
if (!label) {
|
|
7677
|
+
label = `Entry #${doc.id || doc.documentId}`;
|
|
7678
|
+
}
|
|
7501
7679
|
return {
|
|
7502
7680
|
documentId: doc.documentId,
|
|
7503
7681
|
label
|
|
@@ -7885,10 +8063,10 @@ const bulkUpdaterService = ({ strapi }) => {
|
|
|
7885
8063
|
let oldDisplay = "";
|
|
7886
8064
|
if (isMulti && Array.isArray(currentRel)) {
|
|
7887
8065
|
oldDocIds = currentRel.map((r) => r.documentId).filter(Boolean);
|
|
7888
|
-
oldDisplay = currentRel.map((r) => r
|
|
8066
|
+
oldDisplay = currentRel.map((r) => resolveRelationDisplayLabel(r)).join(", ") || "(empty)";
|
|
7889
8067
|
} else if (currentRel) {
|
|
7890
8068
|
oldDocIds = currentRel.documentId ? [currentRel.documentId] : [];
|
|
7891
|
-
oldDisplay = currentRel
|
|
8069
|
+
oldDisplay = resolveRelationDisplayLabel(currentRel) || "(empty)";
|
|
7892
8070
|
} else {
|
|
7893
8071
|
oldDisplay = "(unlinked / none)";
|
|
7894
8072
|
}
|
|
@@ -12346,11 +12524,23 @@ const index = {
|
|
|
12346
12524
|
plugin: "bulk-updater",
|
|
12347
12525
|
type: "string"
|
|
12348
12526
|
});
|
|
12527
|
+
try {
|
|
12528
|
+
const actionProvider = strapi.service?.("admin::permission")?.actionProvider || strapi.admin?.services?.permission?.actionProvider;
|
|
12529
|
+
if (actionProvider?.registerMany) {
|
|
12530
|
+
actionProvider.registerMany(BULK_UPDATER_PERMISSION_ACTIONS);
|
|
12531
|
+
} else if (actionProvider?.register) {
|
|
12532
|
+
for (const action of BULK_UPDATER_PERMISSION_ACTIONS) {
|
|
12533
|
+
actionProvider.register(action);
|
|
12534
|
+
}
|
|
12535
|
+
}
|
|
12536
|
+
} catch (err) {
|
|
12537
|
+
strapi.log?.warn?.(`[bulk-updater] Early permission registration: ${err?.message || err}`);
|
|
12538
|
+
}
|
|
12349
12539
|
},
|
|
12350
12540
|
bootstrap({ strapi }) {
|
|
12351
12541
|
installUndiciCrashGuard(strapi);
|
|
12352
12542
|
try {
|
|
12353
|
-
const actionProvider = strapi.admin?.services?.permission?.actionProvider;
|
|
12543
|
+
const actionProvider = strapi.service?.("admin::permission")?.actionProvider || strapi.admin?.services?.permission?.actionProvider;
|
|
12354
12544
|
if (actionProvider?.registerMany) {
|
|
12355
12545
|
actionProvider.registerMany(BULK_UPDATER_PERMISSION_ACTIONS);
|
|
12356
12546
|
} else if (actionProvider?.register) {
|
|
@@ -12557,6 +12747,7 @@ exports.buildExportColumnPlan = buildExportColumnPlan;
|
|
|
12557
12747
|
exports.buildLosslessPopulate = buildLosslessPopulate;
|
|
12558
12748
|
exports.buildRichAttributeMeta = buildRichAttributeMeta;
|
|
12559
12749
|
exports.classifyAttribute = classifyAttribute;
|
|
12750
|
+
exports.clearStaticSchemaCache = clearStaticSchemaCache;
|
|
12560
12751
|
exports.coerceAndValidateFieldValue = coerceAndValidateFieldValue;
|
|
12561
12752
|
exports.deepCloneValue = deepCloneValue;
|
|
12562
12753
|
exports.deepEqualValues = deepEqualValues;
|
|
@@ -12572,6 +12763,7 @@ exports.extractMetadataFromRow = extractMetadataFromRow;
|
|
|
12572
12763
|
exports.extractRowFlattenedMetadata = extractRowFlattenedMetadata;
|
|
12573
12764
|
exports.formatErrorCsvFilename = formatErrorCsvFilename;
|
|
12574
12765
|
exports.formatErrorWithCause = formatErrorWithCause;
|
|
12766
|
+
exports.formatRelationState = formatRelationState;
|
|
12575
12767
|
exports.getActiveBulkOperationCount = getActiveBulkOperationCount;
|
|
12576
12768
|
exports.getAllNestedValues = getAllNestedValues;
|
|
12577
12769
|
exports.getBatchConcurrency = getBatchConcurrency;
|
|
@@ -12582,6 +12774,7 @@ exports.isFetchFailedError = isFetchFailedError;
|
|
|
12582
12774
|
exports.isPlainObject = isPlainObject;
|
|
12583
12775
|
exports.isValidDocumentId = isValidDocumentId;
|
|
12584
12776
|
exports.normalizeExportMode = normalizeExportMode;
|
|
12777
|
+
exports.normalizeRuleQuotas = normalizeRuleQuotas;
|
|
12585
12778
|
exports.parseBoolean = parseBoolean;
|
|
12586
12779
|
exports.parseCsvToMatrix = parseCsvToMatrix;
|
|
12587
12780
|
exports.parseCsvToRecords = parseCsvToRecords;
|
|
@@ -12594,6 +12787,7 @@ exports.resolveComponentPayload = resolveComponentPayload;
|
|
|
12594
12787
|
exports.resolveDynamicZonePayload = resolveDynamicZonePayload;
|
|
12595
12788
|
exports.resolveErrorColumnName = resolveErrorColumnName;
|
|
12596
12789
|
exports.resolveMediaIds = resolveMediaIds;
|
|
12790
|
+
exports.resolveRelationDisplayLabel = resolveRelationDisplayLabel;
|
|
12597
12791
|
exports.resolveRelationPayload = resolveRelationPayload;
|
|
12598
12792
|
exports.resolveTargetObjectField = resolveTargetObjectField;
|
|
12599
12793
|
exports.sanitizeSensitiveErrorText = sanitizeSensitiveErrorText;
|