strapi-plugin-bulk-updater 1.7.1 → 1.7.2
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-BrBWtCjS.js → BulkUpdater-BdsfPqoX.js} +56 -18
- package/dist/_chunks/BulkUpdater-BdsfPqoX.js.map +1 -0
- package/dist/_chunks/{BulkUpdater-BQnhVw0j.mjs → BulkUpdater-KWmfElh6.mjs} +56 -18
- package/dist/_chunks/BulkUpdater-KWmfElh6.mjs.map +1 -0
- package/dist/_chunks/{SettingsPage-DYD6M988.mjs → SettingsPage-BdwchEyi.mjs} +2 -2
- package/dist/_chunks/{SettingsPage-DYD6M988.mjs.map → SettingsPage-BdwchEyi.mjs.map} +1 -1
- package/dist/_chunks/{SettingsPage-DsKfbhNd.js → SettingsPage-DqJ_zBde.js} +2 -2
- package/dist/_chunks/{SettingsPage-DsKfbhNd.js.map → SettingsPage-DqJ_zBde.js.map} +1 -1
- package/dist/_chunks/{ValidationRulesTab-BzS4_gcN.mjs → ValidationRulesTab-DUtycMm1.mjs} +2 -2
- package/dist/_chunks/{ValidationRulesTab-BzS4_gcN.mjs.map → ValidationRulesTab-DUtycMm1.mjs.map} +1 -1
- package/dist/_chunks/{ValidationRulesTab-DZw6CujQ.js → ValidationRulesTab-DVvVevbW.js} +2 -2
- package/dist/_chunks/{ValidationRulesTab-DZw6CujQ.js.map → ValidationRulesTab-DVvVevbW.js.map} +1 -1
- package/dist/_chunks/{index-BCOsNd1S.js → index-BZ5NTSJQ.js} +3 -3
- package/dist/_chunks/{index-BCOsNd1S.js.map → index-BZ5NTSJQ.js.map} +1 -1
- package/dist/_chunks/{index-CjbxZZjb.mjs → index-C9zsPQim.mjs} +3 -3
- package/dist/_chunks/{index-CjbxZZjb.mjs.map → index-C9zsPQim.mjs.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +425 -71
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +425 -71
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/_chunks/BulkUpdater-BQnhVw0j.mjs.map +0 -1
- package/dist/_chunks/BulkUpdater-BrBWtCjS.js.map +0 -1
package/dist/server/index.js
CHANGED
|
@@ -1117,7 +1117,8 @@ const auditController = ({ strapi }) => ({
|
|
|
1117
1117
|
const { batchId } = ctx.params;
|
|
1118
1118
|
const service = strapi.plugin("bulk-updater").service("audit");
|
|
1119
1119
|
const currentUser = ctx.state.user;
|
|
1120
|
-
const
|
|
1120
|
+
const confirmOverwrite = Boolean(ctx.request?.body?.confirmOverwrite);
|
|
1121
|
+
const result = await service.rollbackBatch(batchId, currentUser, { confirmOverwrite });
|
|
1121
1122
|
ctx.body = result;
|
|
1122
1123
|
} catch (err) {
|
|
1123
1124
|
ctx.status = 400;
|
|
@@ -1386,7 +1387,7 @@ const csvController = ({ strapi }) => ({
|
|
|
1386
1387
|
if (!ensureCsvAuthorized(ctx, { actions: [PERMISSIONS.csvPreFlightDryRun] }, strapi)) {
|
|
1387
1388
|
return;
|
|
1388
1389
|
}
|
|
1389
|
-
const { uid, rows, mode } = ctx.request.body;
|
|
1390
|
+
const { uid, rows, mode, originalHeaders } = ctx.request.body;
|
|
1390
1391
|
if (!uid) {
|
|
1391
1392
|
ctx.status = 400;
|
|
1392
1393
|
ctx.body = { success: false, error: "Target collection UID is required." };
|
|
@@ -1399,7 +1400,8 @@ const csvController = ({ strapi }) => ({
|
|
|
1399
1400
|
}
|
|
1400
1401
|
const csvService2 = strapi.plugin("bulk-updater").service("csv");
|
|
1401
1402
|
const result = await csvService2.validatePreflight(uid, rows, {
|
|
1402
|
-
mode: mode === "update" ? "update" : mode === "create_or_override" ? "create_or_override" : "auto"
|
|
1403
|
+
mode: mode === "update" ? "update" : mode === "create_or_override" ? "create_or_override" : "auto",
|
|
1404
|
+
originalHeaders: Array.isArray(originalHeaders) ? originalHeaders.map(String) : void 0
|
|
1403
1405
|
});
|
|
1404
1406
|
ctx.body = result;
|
|
1405
1407
|
} catch (err) {
|
|
@@ -2564,6 +2566,8 @@ function buildExportColumnPlan(strapi, uid, documents, options = {}) {
|
|
|
2564
2566
|
if (exportMode === "selective" && hasSelectedColumns) {
|
|
2565
2567
|
const columns2 = [];
|
|
2566
2568
|
const headers = [];
|
|
2569
|
+
const seenSelected = /* @__PURE__ */ new Set();
|
|
2570
|
+
const cleanSelectedColumns = [];
|
|
2567
2571
|
columns2.push({
|
|
2568
2572
|
header: "documentId",
|
|
2569
2573
|
kind: "system",
|
|
@@ -2579,50 +2583,61 @@ function buildExportColumnPlan(strapi, uid, documents, options = {}) {
|
|
|
2579
2583
|
headers.push("slug");
|
|
2580
2584
|
for (const rawCol of options.selectedColumns) {
|
|
2581
2585
|
const colName = String(rawCol).trim();
|
|
2582
|
-
if (!colName || colName === "documentId" || colName === "slug" || colName === "__bulk_updater_metadata" || colName === "_bulk_updater_metadata") {
|
|
2583
|
-
continue;
|
|
2584
|
-
}
|
|
2585
|
-
if (headers.includes(colName)) {
|
|
2586
|
+
if (!colName || colName === "documentId" || colName === "slug" || colName === "__bulk_updater_metadata" || colName === "_bulk_updater_metadata" || seenSelected.has(colName)) {
|
|
2586
2587
|
continue;
|
|
2587
2588
|
}
|
|
2589
|
+
seenSelected.add(colName);
|
|
2590
|
+
cleanSelectedColumns.push(colName);
|
|
2591
|
+
let baseDescriptor;
|
|
2588
2592
|
if (colName.includes(".")) {
|
|
2589
2593
|
const rootKey = colName.split(".")[0];
|
|
2590
2594
|
const rootField = schema.fields[rootKey];
|
|
2591
2595
|
const isRepeated = rootField?.category === "component_repeatable" || rootField?.category === "dynamiczone" || rootField?.rawType === "dynamiczone" || Array.isArray(documents) && documents.some((d) => Array.isArray(d?.[rootKey]));
|
|
2592
|
-
|
|
2593
|
-
header: colName,
|
|
2596
|
+
baseDescriptor = {
|
|
2594
2597
|
kind: "selective_nested",
|
|
2595
2598
|
rootKey,
|
|
2596
2599
|
isRepeatedNested: Boolean(isRepeated),
|
|
2597
2600
|
field: rootField
|
|
2598
|
-
}
|
|
2599
|
-
headers.push(colName);
|
|
2601
|
+
};
|
|
2600
2602
|
} else {
|
|
2601
2603
|
const field = schema.fields[colName];
|
|
2602
2604
|
if (field) {
|
|
2603
|
-
|
|
2604
|
-
header: colName,
|
|
2605
|
+
baseDescriptor = {
|
|
2605
2606
|
kind: "field",
|
|
2606
2607
|
rootKey: colName,
|
|
2607
2608
|
field
|
|
2608
|
-
}
|
|
2609
|
-
headers.push(colName);
|
|
2609
|
+
};
|
|
2610
2610
|
} else {
|
|
2611
|
-
|
|
2612
|
-
header: colName,
|
|
2611
|
+
baseDescriptor = {
|
|
2613
2612
|
kind: "selective_nested",
|
|
2614
2613
|
rootKey: colName,
|
|
2615
2614
|
isRepeatedNested: false
|
|
2616
|
-
}
|
|
2617
|
-
headers.push(colName);
|
|
2615
|
+
};
|
|
2618
2616
|
}
|
|
2619
2617
|
}
|
|
2618
|
+
const beforeHeader = `${colName}_before`;
|
|
2619
|
+
const targetHeader = `${colName}_target`;
|
|
2620
|
+
columns2.push({
|
|
2621
|
+
...baseDescriptor,
|
|
2622
|
+
header: beforeHeader,
|
|
2623
|
+
role: "before",
|
|
2624
|
+
targetKey: colName
|
|
2625
|
+
});
|
|
2626
|
+
headers.push(beforeHeader);
|
|
2627
|
+
columns2.push({
|
|
2628
|
+
...baseDescriptor,
|
|
2629
|
+
header: targetHeader,
|
|
2630
|
+
role: "target",
|
|
2631
|
+
targetKey: colName
|
|
2632
|
+
});
|
|
2633
|
+
headers.push(targetHeader);
|
|
2620
2634
|
}
|
|
2621
2635
|
return {
|
|
2622
2636
|
exportMode,
|
|
2637
|
+
columnLayout: "before_target",
|
|
2623
2638
|
columns: columns2,
|
|
2624
2639
|
headers,
|
|
2625
|
-
selectedColumns:
|
|
2640
|
+
selectedColumns: cleanSelectedColumns
|
|
2626
2641
|
};
|
|
2627
2642
|
}
|
|
2628
2643
|
const targetObjectField = resolveTargetObjectField(schema, exportMode);
|
|
@@ -2680,6 +2695,9 @@ function extractRowFlattenedMetadata(plan, doc) {
|
|
|
2680
2695
|
exportMode: plan.exportMode
|
|
2681
2696
|
};
|
|
2682
2697
|
if (plan.exportMode === "selective") {
|
|
2698
|
+
if (plan.columnLayout === "before_target") {
|
|
2699
|
+
out.columnLayout = "before_target";
|
|
2700
|
+
}
|
|
2683
2701
|
out.selectedColumns = plan.selectedColumns || plan.headers.filter((h) => h !== "documentId" && h !== "slug");
|
|
2684
2702
|
return out;
|
|
2685
2703
|
}
|
|
@@ -2730,8 +2748,9 @@ function serializePlannedCell(col, doc, serializeFieldFallback) {
|
|
|
2730
2748
|
return doc?.[col.header] ?? "";
|
|
2731
2749
|
}
|
|
2732
2750
|
if (col.kind === "selective_nested") {
|
|
2751
|
+
const lookupKey = col.targetKey || col.header;
|
|
2733
2752
|
if (col.isRepeatedNested) {
|
|
2734
|
-
const matches = getAllNestedValues(doc,
|
|
2753
|
+
const matches = getAllNestedValues(doc, lookupKey);
|
|
2735
2754
|
if (!matches || matches.length === 0) {
|
|
2736
2755
|
return "";
|
|
2737
2756
|
}
|
|
@@ -2750,7 +2769,7 @@ function serializePlannedCell(col, doc, serializeFieldFallback) {
|
|
|
2750
2769
|
});
|
|
2751
2770
|
return JSON.stringify(occurrences);
|
|
2752
2771
|
} else {
|
|
2753
|
-
const val = getDeepProp(doc,
|
|
2772
|
+
const val = getDeepProp(doc, lookupKey);
|
|
2754
2773
|
if (val === void 0 || val === null) return "";
|
|
2755
2774
|
if (val instanceof Date) return val.toISOString();
|
|
2756
2775
|
if (Array.isArray(val) || isPlainObject(val)) return JSON.stringify(val);
|
|
@@ -2841,8 +2860,20 @@ function inspectRowMetadataMode(rawRow) {
|
|
|
2841
2860
|
error: `Unsupported CSV exportMode "${parsed.exportMode}" in metadata.`
|
|
2842
2861
|
};
|
|
2843
2862
|
}
|
|
2863
|
+
let columnLayout;
|
|
2864
|
+
if (parsed.columnLayout !== void 0) {
|
|
2865
|
+
const rawLayout = String(parsed.columnLayout).trim().toLowerCase();
|
|
2866
|
+
if (rawLayout !== "before_target") {
|
|
2867
|
+
return {
|
|
2868
|
+
mode: rawMode,
|
|
2869
|
+
error: `Unsupported CSV columnLayout "${parsed.columnLayout}" in metadata.`
|
|
2870
|
+
};
|
|
2871
|
+
}
|
|
2872
|
+
columnLayout = "before_target";
|
|
2873
|
+
}
|
|
2844
2874
|
return {
|
|
2845
2875
|
mode: rawMode,
|
|
2876
|
+
...columnLayout ? { columnLayout } : {},
|
|
2846
2877
|
targetObjectField: typeof parsed.targetObjectField === "string" && parsed.targetObjectField.trim() ? parsed.targetObjectField.trim() : void 0,
|
|
2847
2878
|
targetObjectState: parsed.targetObjectState,
|
|
2848
2879
|
applicableFields: Array.isArray(parsed.applicableFields) ? parsed.applicableFields : void 0,
|
|
@@ -2868,6 +2899,189 @@ function detectCsvBatchExportMode(rows) {
|
|
|
2868
2899
|
const first = Array.from(seenModes)[0];
|
|
2869
2900
|
return { mode: first || "legacy" };
|
|
2870
2901
|
}
|
|
2902
|
+
const PRESERVED_SYSTEM_AND_STATUS_KEYS = /* @__PURE__ */ new Set([
|
|
2903
|
+
"__bulk_updater_metadata",
|
|
2904
|
+
"_bulk_updater_metadata",
|
|
2905
|
+
"documentId",
|
|
2906
|
+
"document_id",
|
|
2907
|
+
"Document ID",
|
|
2908
|
+
"Document Id",
|
|
2909
|
+
"docId",
|
|
2910
|
+
"id",
|
|
2911
|
+
"ID",
|
|
2912
|
+
"Id",
|
|
2913
|
+
"slug",
|
|
2914
|
+
"locale",
|
|
2915
|
+
"Locale",
|
|
2916
|
+
"strapi_locale",
|
|
2917
|
+
"status",
|
|
2918
|
+
"Status",
|
|
2919
|
+
"STATUS",
|
|
2920
|
+
"Published Status",
|
|
2921
|
+
"published_status",
|
|
2922
|
+
"strapi_status",
|
|
2923
|
+
"publishedAt",
|
|
2924
|
+
"published_at",
|
|
2925
|
+
"PublishedAt"
|
|
2926
|
+
]);
|
|
2927
|
+
function findDuplicateCsvHeaders(headers) {
|
|
2928
|
+
if (!Array.isArray(headers) || headers.length === 0) return [];
|
|
2929
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2930
|
+
const duplicates = [];
|
|
2931
|
+
for (const raw of headers) {
|
|
2932
|
+
const trimmed = String(raw || "").trim();
|
|
2933
|
+
if (!trimmed) continue;
|
|
2934
|
+
if (seen.has(trimmed)) {
|
|
2935
|
+
if (!duplicates.includes(trimmed)) {
|
|
2936
|
+
duplicates.push(trimmed);
|
|
2937
|
+
}
|
|
2938
|
+
} else {
|
|
2939
|
+
seen.add(trimmed);
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
return duplicates;
|
|
2943
|
+
}
|
|
2944
|
+
function hasCanonicalSchemaTarget(schema, key) {
|
|
2945
|
+
if (!schema || !key) return false;
|
|
2946
|
+
if (schema.fields && Object.prototype.hasOwnProperty.call(schema.fields, key)) {
|
|
2947
|
+
return true;
|
|
2948
|
+
}
|
|
2949
|
+
const bracketIdx = key.indexOf("[");
|
|
2950
|
+
const dotIdx = key.indexOf(".");
|
|
2951
|
+
let rootKey = key;
|
|
2952
|
+
if (bracketIdx > 0 && (dotIdx === -1 || bracketIdx < dotIdx)) {
|
|
2953
|
+
rootKey = key.slice(0, bracketIdx);
|
|
2954
|
+
} else if (dotIdx > 0) {
|
|
2955
|
+
rootKey = key.slice(0, dotIdx);
|
|
2956
|
+
}
|
|
2957
|
+
return Boolean(rootKey && schema.fields && Object.prototype.hasOwnProperty.call(schema.fields, rootKey));
|
|
2958
|
+
}
|
|
2959
|
+
function normalizeSelectiveBeforeTargetRow(rawRow, rowInfo, schema) {
|
|
2960
|
+
if (!rawRow || typeof rawRow !== "object") {
|
|
2961
|
+
return {
|
|
2962
|
+
normalizedRow: rawRow,
|
|
2963
|
+
isBeforeTarget: false,
|
|
2964
|
+
ignoredBeforeColumns: [],
|
|
2965
|
+
mappedTargetFields: [],
|
|
2966
|
+
errors: []
|
|
2967
|
+
};
|
|
2968
|
+
}
|
|
2969
|
+
if (rowInfo.mode === "selective" && rowInfo.columnLayout === "before_target") {
|
|
2970
|
+
const normalizedRow = {};
|
|
2971
|
+
const ignoredBeforeColumns = [];
|
|
2972
|
+
const mappedTargetFields = [];
|
|
2973
|
+
const errors = [];
|
|
2974
|
+
const selectedCols = Array.isArray(rowInfo.selectedColumns) ? rowInfo.selectedColumns.map((c) => String(c).trim()).filter(Boolean) : [];
|
|
2975
|
+
const beforeSet = /* @__PURE__ */ new Set();
|
|
2976
|
+
const targetMap = /* @__PURE__ */ new Map();
|
|
2977
|
+
for (const col of selectedCols) {
|
|
2978
|
+
beforeSet.add(`${col}_before`);
|
|
2979
|
+
targetMap.set(`${col}_target`, col);
|
|
2980
|
+
}
|
|
2981
|
+
if (selectedCols.length > 0) {
|
|
2982
|
+
const hasAnyTargetCol = selectedCols.some(
|
|
2983
|
+
(col) => Object.prototype.hasOwnProperty.call(rawRow, `${col}_target`)
|
|
2984
|
+
);
|
|
2985
|
+
const presentBeforeCols = selectedCols.filter(
|
|
2986
|
+
(col) => Object.prototype.hasOwnProperty.call(rawRow, `${col}_before`)
|
|
2987
|
+
);
|
|
2988
|
+
if (!hasAnyTargetCol && presentBeforeCols.length > 0) {
|
|
2989
|
+
const expectedTargets = presentBeforeCols.map((col) => `${col}_target`);
|
|
2990
|
+
errors.push(
|
|
2991
|
+
`Missing Target column(s) [${expectedTargets.join(", ")}] in Before/Target CSV. Import requires "<field>_target" headers.`
|
|
2992
|
+
);
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
for (const [k, v] of Object.entries(rawRow)) {
|
|
2996
|
+
if (PRESERVED_SYSTEM_AND_STATUS_KEYS.has(k)) {
|
|
2997
|
+
normalizedRow[k] = v;
|
|
2998
|
+
continue;
|
|
2999
|
+
}
|
|
3000
|
+
if (beforeSet.size > 0) {
|
|
3001
|
+
if (beforeSet.has(k)) {
|
|
3002
|
+
ignoredBeforeColumns.push(k);
|
|
3003
|
+
continue;
|
|
3004
|
+
}
|
|
3005
|
+
if (targetMap.has(k)) {
|
|
3006
|
+
const canonicalKey = targetMap.get(k);
|
|
3007
|
+
normalizedRow[canonicalKey] = v;
|
|
3008
|
+
mappedTargetFields.push(canonicalKey);
|
|
3009
|
+
}
|
|
3010
|
+
} else {
|
|
3011
|
+
if (k.endsWith("_before")) {
|
|
3012
|
+
ignoredBeforeColumns.push(k);
|
|
3013
|
+
continue;
|
|
3014
|
+
}
|
|
3015
|
+
if (k.endsWith("_target")) {
|
|
3016
|
+
const canonicalKey = k.slice(0, -7);
|
|
3017
|
+
if (canonicalKey) {
|
|
3018
|
+
normalizedRow[canonicalKey] = v;
|
|
3019
|
+
mappedTargetFields.push(canonicalKey);
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
}
|
|
3024
|
+
return {
|
|
3025
|
+
normalizedRow,
|
|
3026
|
+
isBeforeTarget: true,
|
|
3027
|
+
ignoredBeforeColumns,
|
|
3028
|
+
mappedTargetFields,
|
|
3029
|
+
errors
|
|
3030
|
+
};
|
|
3031
|
+
}
|
|
3032
|
+
if (rowInfo.mode === "legacy" && schema) {
|
|
3033
|
+
const pairedBases = /* @__PURE__ */ new Map();
|
|
3034
|
+
for (const key of Object.keys(rawRow)) {
|
|
3035
|
+
if (PRESERVED_SYSTEM_AND_STATUS_KEYS.has(key) || !key.endsWith("_target")) continue;
|
|
3036
|
+
const base = key.slice(0, -7);
|
|
3037
|
+
if (!base) continue;
|
|
3038
|
+
const beforeKey = `${base}_before`;
|
|
3039
|
+
const isLiteralTargetAttr = Boolean(schema.fields && Object.prototype.hasOwnProperty.call(schema.fields, key));
|
|
3040
|
+
const isLiteralBeforeAttr = Boolean(schema.fields && Object.prototype.hasOwnProperty.call(schema.fields, beforeKey));
|
|
3041
|
+
if (!isLiteralTargetAttr && !isLiteralBeforeAttr && Object.prototype.hasOwnProperty.call(rawRow, beforeKey) && hasCanonicalSchemaTarget(schema, base)) {
|
|
3042
|
+
pairedBases.set(base, { beforeKey, targetKey: key });
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
if (pairedBases.size > 0) {
|
|
3046
|
+
const beforeSet = /* @__PURE__ */ new Set();
|
|
3047
|
+
const targetMap = /* @__PURE__ */ new Map();
|
|
3048
|
+
for (const [base, pair] of pairedBases.entries()) {
|
|
3049
|
+
beforeSet.add(pair.beforeKey);
|
|
3050
|
+
targetMap.set(pair.targetKey, base);
|
|
3051
|
+
}
|
|
3052
|
+
const normalizedRow = {};
|
|
3053
|
+
const ignoredBeforeColumns = [];
|
|
3054
|
+
const mappedTargetFields = [];
|
|
3055
|
+
for (const [k, v] of Object.entries(rawRow)) {
|
|
3056
|
+
if (beforeSet.has(k)) {
|
|
3057
|
+
ignoredBeforeColumns.push(k);
|
|
3058
|
+
continue;
|
|
3059
|
+
}
|
|
3060
|
+
if (targetMap.has(k)) {
|
|
3061
|
+
const canonicalKey = targetMap.get(k);
|
|
3062
|
+
normalizedRow[canonicalKey] = v;
|
|
3063
|
+
mappedTargetFields.push(canonicalKey);
|
|
3064
|
+
continue;
|
|
3065
|
+
}
|
|
3066
|
+
normalizedRow[k] = v;
|
|
3067
|
+
}
|
|
3068
|
+
return {
|
|
3069
|
+
normalizedRow,
|
|
3070
|
+
isBeforeTarget: true,
|
|
3071
|
+
ignoredBeforeColumns,
|
|
3072
|
+
mappedTargetFields,
|
|
3073
|
+
errors: []
|
|
3074
|
+
};
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
return {
|
|
3078
|
+
normalizedRow: rawRow,
|
|
3079
|
+
isBeforeTarget: false,
|
|
3080
|
+
ignoredBeforeColumns: [],
|
|
3081
|
+
mappedTargetFields: [],
|
|
3082
|
+
errors: []
|
|
3083
|
+
};
|
|
3084
|
+
}
|
|
2871
3085
|
function parseFirstLevelCellValue(rawCell, annotatedType, existingPropValue) {
|
|
2872
3086
|
if (rawCell === null || rawCell === void 0) return { value: null };
|
|
2873
3087
|
if (typeof rawCell !== "string") return { value: rawCell };
|
|
@@ -3376,6 +3590,7 @@ function serializeDocumentsToCsv(strapi, uid, documents, options = {}) {
|
|
|
3376
3590
|
locale: doc.locale || void 0,
|
|
3377
3591
|
exportedAt,
|
|
3378
3592
|
...flattenedMeta.exportMode ? { exportMode: flattenedMeta.exportMode } : {},
|
|
3593
|
+
...flattenedMeta.columnLayout ? { columnLayout: flattenedMeta.columnLayout } : {},
|
|
3379
3594
|
...flattenedMeta.selectedColumns ? { selectedColumns: flattenedMeta.selectedColumns } : {},
|
|
3380
3595
|
...flattenedMeta.targetObjectField ? { targetObjectField: flattenedMeta.targetObjectField } : {},
|
|
3381
3596
|
...flattenedMeta.targetObjectState ? { targetObjectState: flattenedMeta.targetObjectState } : {},
|
|
@@ -3843,18 +4058,30 @@ async function prepareCsvRowMutation(strapi, uid, existingDoc, rawRow, options =
|
|
|
3843
4058
|
const warnings = [];
|
|
3844
4059
|
const isPartialUpdate = options.isPartialUpdate !== false;
|
|
3845
4060
|
const isCreate = options.isCreate !== void 0 ? options.isCreate : !existingDoc;
|
|
3846
|
-
const
|
|
4061
|
+
const rawUnescapedRow = {};
|
|
3847
4062
|
for (const [k, v] of Object.entries(rawRow || {})) {
|
|
3848
4063
|
let cleanVal = v;
|
|
3849
4064
|
if (typeof cleanVal === "string" && /^'[=+@-]/.test(cleanVal)) {
|
|
3850
4065
|
cleanVal = cleanVal.substring(1);
|
|
3851
4066
|
}
|
|
3852
|
-
|
|
4067
|
+
rawUnescapedRow[k] = cleanVal;
|
|
3853
4068
|
}
|
|
3854
|
-
const rowInfo = inspectRowMetadataMode(
|
|
4069
|
+
const rowInfo = inspectRowMetadataMode(rawUnescapedRow);
|
|
3855
4070
|
if (rowInfo.error) {
|
|
3856
4071
|
errors.push(rowInfo.error);
|
|
3857
4072
|
}
|
|
4073
|
+
const beforeTargetNorm = normalizeSelectiveBeforeTargetRow(rawUnescapedRow, rowInfo, schema);
|
|
4074
|
+
if (beforeTargetNorm.errors.length > 0) {
|
|
4075
|
+
errors.push(...beforeTargetNorm.errors);
|
|
4076
|
+
return {
|
|
4077
|
+
payload: {},
|
|
4078
|
+
errors,
|
|
4079
|
+
warnings,
|
|
4080
|
+
detectedMode: rowInfo.mode,
|
|
4081
|
+
rowMeta: rowInfo
|
|
4082
|
+
};
|
|
4083
|
+
}
|
|
4084
|
+
const unescapedRow = beforeTargetNorm.normalizedRow;
|
|
3858
4085
|
const detectedMode = rowInfo.mode;
|
|
3859
4086
|
if (options.expectedExportMode && detectedMode !== options.expectedExportMode) {
|
|
3860
4087
|
errors.push(
|
|
@@ -3984,6 +4211,18 @@ async function prepareCsvRowMutation(strapi, uid, existingDoc, rawRow, options =
|
|
|
3984
4211
|
}
|
|
3985
4212
|
} else if (field.category === "json") {
|
|
3986
4213
|
targetVal = parseFirstLevelCellValue(strCell, "object", currentVal).value;
|
|
4214
|
+
} else if (field.category === "blocks") {
|
|
4215
|
+
if (trimmed.startsWith("[") || trimmed.startsWith("{")) {
|
|
4216
|
+
try {
|
|
4217
|
+
const parsedBlocks = JSON.parse(trimmed);
|
|
4218
|
+
targetVal = Array.isArray(parsedBlocks) ? parsedBlocks : [parsedBlocks];
|
|
4219
|
+
} catch {
|
|
4220
|
+
errors.push(`Column "${colKey}": Invalid JSON blocks value.`);
|
|
4221
|
+
continue;
|
|
4222
|
+
}
|
|
4223
|
+
} else {
|
|
4224
|
+
targetVal = [{ type: "paragraph", children: [{ type: "text", text: strCell }] }];
|
|
4225
|
+
}
|
|
3987
4226
|
} else if (field.category === "relation_to_one") {
|
|
3988
4227
|
targetVal = resolveRelationPayload(strCell, false);
|
|
3989
4228
|
} else if (field.category === "relation_to_many") {
|
|
@@ -3995,7 +4234,24 @@ async function prepareCsvRowMutation(strapi, uid, existingDoc, rawRow, options =
|
|
|
3995
4234
|
} else {
|
|
3996
4235
|
targetVal = strCell;
|
|
3997
4236
|
}
|
|
3998
|
-
|
|
4237
|
+
let hasFieldChanged = true;
|
|
4238
|
+
if (field?.category === "relation_to_one" || field?.category === "relation_to_many") {
|
|
4239
|
+
if (targetVal && typeof targetVal === "object" && Array.isArray(targetVal.set) && !targetVal.connect && !targetVal.disconnect) {
|
|
4240
|
+
const existingDocIds = Array.isArray(currentVal) ? currentVal.map((item) => String(item?.documentId || item?.id || item)).filter(Boolean) : currentVal && typeof currentVal === "object" ? currentVal.documentId || currentVal.id ? [String(currentVal.documentId || currentVal.id)] : [] : currentVal !== null && currentVal !== void 0 && currentVal !== "" ? [String(currentVal)] : [];
|
|
4241
|
+
hasFieldChanged = !deepEqualValues(targetVal.set, existingDocIds);
|
|
4242
|
+
} else {
|
|
4243
|
+
hasFieldChanged = !deepEqualValues(targetVal, currentVal);
|
|
4244
|
+
}
|
|
4245
|
+
} else if (field?.category === "media_single") {
|
|
4246
|
+
const existingMediaId = currentVal && typeof currentVal === "object" ? currentVal.id ?? null : currentVal ?? null;
|
|
4247
|
+
hasFieldChanged = (targetVal ?? null) !== existingMediaId;
|
|
4248
|
+
} else if (field?.category === "media_to_many") {
|
|
4249
|
+
const existingMediaIds = Array.isArray(currentVal) ? currentVal.map((f) => f && typeof f === "object" ? f.id : f).filter((v) => v !== void 0 && v !== null) : [];
|
|
4250
|
+
hasFieldChanged = !deepEqualValues(Array.isArray(targetVal) ? targetVal : [], existingMediaIds);
|
|
4251
|
+
} else {
|
|
4252
|
+
hasFieldChanged = !deepEqualValues(targetVal, currentVal);
|
|
4253
|
+
}
|
|
4254
|
+
if (hasFieldChanged) {
|
|
3999
4255
|
payload[colKey] = targetVal;
|
|
4000
4256
|
hasRowChanges = true;
|
|
4001
4257
|
}
|
|
@@ -9347,6 +9603,96 @@ function withRollbackLock(fn) {
|
|
|
9347
9603
|
}
|
|
9348
9604
|
});
|
|
9349
9605
|
}
|
|
9606
|
+
function getDiffEntryKey(item) {
|
|
9607
|
+
const loc = item?.locale && item.locale !== "null" && item.locale !== "undefined" ? item.locale : "";
|
|
9608
|
+
return `${item.uid}@@@${item.documentId}@@@${loc}`;
|
|
9609
|
+
}
|
|
9610
|
+
function getRevertibleDiffs(diffs) {
|
|
9611
|
+
if (!Array.isArray(diffs)) return [];
|
|
9612
|
+
return diffs.filter(
|
|
9613
|
+
(item) => item?.status === "updated" && item?.uid && item?.documentId && item?.attribute
|
|
9614
|
+
);
|
|
9615
|
+
}
|
|
9616
|
+
function computeRollbackOverlap(sortedHistory, targetIdx) {
|
|
9617
|
+
const empty = {
|
|
9618
|
+
hasOverlap: false,
|
|
9619
|
+
newerActiveBatchIds: [],
|
|
9620
|
+
affectedDocumentIds: [],
|
|
9621
|
+
affectedEntryCount: 0
|
|
9622
|
+
};
|
|
9623
|
+
if (targetIdx <= 0 || targetIdx >= sortedHistory.length) {
|
|
9624
|
+
return empty;
|
|
9625
|
+
}
|
|
9626
|
+
const targetDiffs = getRevertibleDiffs(sortedHistory[targetIdx]?.diffs);
|
|
9627
|
+
if (targetDiffs.length === 0) {
|
|
9628
|
+
return empty;
|
|
9629
|
+
}
|
|
9630
|
+
const targetEntryKeys = new Set(targetDiffs.map(getDiffEntryKey));
|
|
9631
|
+
const newerActiveBatchIds = [];
|
|
9632
|
+
const affectedEntryKeySet = /* @__PURE__ */ new Set();
|
|
9633
|
+
const affectedDocumentIdSet = /* @__PURE__ */ new Set();
|
|
9634
|
+
for (let i = 0; i < targetIdx; i++) {
|
|
9635
|
+
const newer = sortedHistory[i];
|
|
9636
|
+
if (!newer || newer.isRolledBack) continue;
|
|
9637
|
+
const newerDiffs = getRevertibleDiffs(newer.diffs);
|
|
9638
|
+
let batchOverlaps = false;
|
|
9639
|
+
for (const nd of newerDiffs) {
|
|
9640
|
+
const key = getDiffEntryKey(nd);
|
|
9641
|
+
if (targetEntryKeys.has(key)) {
|
|
9642
|
+
batchOverlaps = true;
|
|
9643
|
+
affectedEntryKeySet.add(key);
|
|
9644
|
+
if (nd.documentId) affectedDocumentIdSet.add(String(nd.documentId));
|
|
9645
|
+
}
|
|
9646
|
+
}
|
|
9647
|
+
if (batchOverlaps && newer.batchId) {
|
|
9648
|
+
newerActiveBatchIds.push(String(newer.batchId));
|
|
9649
|
+
}
|
|
9650
|
+
}
|
|
9651
|
+
return {
|
|
9652
|
+
hasOverlap: newerActiveBatchIds.length > 0,
|
|
9653
|
+
newerActiveBatchIds,
|
|
9654
|
+
affectedDocumentIds: Array.from(affectedDocumentIdSet),
|
|
9655
|
+
affectedEntryCount: affectedEntryKeySet.size
|
|
9656
|
+
};
|
|
9657
|
+
}
|
|
9658
|
+
function isBatchRollbackEligible(rec) {
|
|
9659
|
+
if (!rec || rec.isRolledBack) return false;
|
|
9660
|
+
const rawDiffs = Array.isArray(rec.diffs) ? rec.diffs : [];
|
|
9661
|
+
if (rawDiffs.length === 0) return true;
|
|
9662
|
+
return getRevertibleDiffs(rawDiffs).length > 0;
|
|
9663
|
+
}
|
|
9664
|
+
function enrichAuditHistoryWithRollbackMeta(sortedHistory) {
|
|
9665
|
+
const latestRecord = sortedHistory.length > 0 ? sortedHistory[0] : null;
|
|
9666
|
+
return sortedHistory.map((rec, idx) => ({
|
|
9667
|
+
...rec,
|
|
9668
|
+
isLatestEligible: Boolean(
|
|
9669
|
+
latestRecord && rec.batchId === latestRecord.batchId && !latestRecord.isRolledBack
|
|
9670
|
+
),
|
|
9671
|
+
isRollbackEligible: isBatchRollbackEligible(rec),
|
|
9672
|
+
overlapWarning: !rec?.isRolledBack ? computeRollbackOverlap(sortedHistory, idx) : { hasOverlap: false, newerActiveBatchIds: [], affectedDocumentIds: [], affectedEntryCount: 0 }
|
|
9673
|
+
}));
|
|
9674
|
+
}
|
|
9675
|
+
function validateRollbackCandidate(sortedHistory, batchId, confirmOverwrite) {
|
|
9676
|
+
const targetIdx = sortedHistory.findIndex((r) => r.batchId === batchId);
|
|
9677
|
+
if (targetIdx === -1) {
|
|
9678
|
+
throw new Error(`Batch record with ID "${batchId}" was not found in audit trail.`);
|
|
9679
|
+
}
|
|
9680
|
+
const targetRecord = sortedHistory[targetIdx];
|
|
9681
|
+
if (targetRecord.isRolledBack) {
|
|
9682
|
+
throw new Error(`Batch "${batchId}" has already been rolled back.`);
|
|
9683
|
+
}
|
|
9684
|
+
const rawDiffs = Array.isArray(targetRecord.diffs) ? targetRecord.diffs : [];
|
|
9685
|
+
if (rawDiffs.length > 0 && getRevertibleDiffs(rawDiffs).length === 0) {
|
|
9686
|
+
throw new Error(`Batch "${batchId}" has no revertible updates to roll back.`);
|
|
9687
|
+
}
|
|
9688
|
+
const overlap = computeRollbackOverlap(sortedHistory, targetIdx);
|
|
9689
|
+
if (overlap.hasOverlap && !confirmOverwrite) {
|
|
9690
|
+
throw new Error(
|
|
9691
|
+
`Historical rollback of batch "${batchId}" overlaps newer active batch(es) [${overlap.newerActiveBatchIds.join(", ")}] on ${overlap.affectedEntryCount} entry/entries and will overwrite newer changes/status with pre-batch snapshots. Pass confirmOverwrite=true to proceed.`
|
|
9692
|
+
);
|
|
9693
|
+
}
|
|
9694
|
+
return { targetRecord, overlap };
|
|
9695
|
+
}
|
|
9350
9696
|
const auditService = ({ strapi }) => ({
|
|
9351
9697
|
/**
|
|
9352
9698
|
* Detects whether Strapi Enterprise Native Audit Log service is available.
|
|
@@ -9577,13 +9923,7 @@ const auditService = ({ strapi }) => ({
|
|
|
9577
9923
|
const stored = await store.get({}) || { history: [] };
|
|
9578
9924
|
const rawHistory = Array.isArray(stored.history) ? stored.history : [];
|
|
9579
9925
|
const sortedHistory = sortAuditRecordsDesc(rawHistory);
|
|
9580
|
-
const
|
|
9581
|
-
const history = sortedHistory.map((rec) => ({
|
|
9582
|
-
...rec,
|
|
9583
|
-
isLatestEligible: Boolean(
|
|
9584
|
-
latestRecord && rec.batchId === latestRecord.batchId && !latestRecord.isRolledBack
|
|
9585
|
-
)
|
|
9586
|
-
}));
|
|
9926
|
+
const history = enrichAuditHistoryWithRollbackMeta(sortedHistory);
|
|
9587
9927
|
return {
|
|
9588
9928
|
enabled: true,
|
|
9589
9929
|
mode: "store",
|
|
@@ -9629,13 +9969,7 @@ const auditService = ({ strapi }) => ({
|
|
|
9629
9969
|
createdAt: r.createdAt
|
|
9630
9970
|
}));
|
|
9631
9971
|
const sortedHistory = sortAuditRecordsDesc(normalized);
|
|
9632
|
-
const
|
|
9633
|
-
const history = sortedHistory.map((rec) => ({
|
|
9634
|
-
...rec,
|
|
9635
|
-
isLatestEligible: Boolean(
|
|
9636
|
-
latestRecord && rec.batchId === latestRecord.batchId && !latestRecord.isRolledBack
|
|
9637
|
-
)
|
|
9638
|
-
}));
|
|
9972
|
+
const history = enrichAuditHistoryWithRollbackMeta(sortedHistory);
|
|
9639
9973
|
return {
|
|
9640
9974
|
enabled: true,
|
|
9641
9975
|
mode: config.mode,
|
|
@@ -9890,11 +10224,11 @@ const auditService = ({ strapi }) => ({
|
|
|
9890
10224
|
});
|
|
9891
10225
|
},
|
|
9892
10226
|
/**
|
|
9893
|
-
* Performs deterministic rollback of
|
|
9894
|
-
*
|
|
9895
|
-
*
|
|
10227
|
+
* Performs deterministic rollback of an eligible batch (latest or historical).
|
|
10228
|
+
* Already rolled-back updates, non-revertible batches, and pending/failed/executing batches are rejected.
|
|
10229
|
+
* Historical batches overlapping newer active batches on shared entries require `confirmOverwrite: true`.
|
|
9896
10230
|
*/
|
|
9897
|
-
async rollbackBatch(batchId, currentUser) {
|
|
10231
|
+
async rollbackBatch(batchId, currentUser, options) {
|
|
9898
10232
|
return withRollbackLock(async () => {
|
|
9899
10233
|
const config = this.getAuditConfig();
|
|
9900
10234
|
if (!config.enabled) {
|
|
@@ -9933,17 +10267,11 @@ const auditService = ({ strapi }) => ({
|
|
|
9933
10267
|
throw new Error("No completed update records found in audit trail.");
|
|
9934
10268
|
}
|
|
9935
10269
|
const sortedHistory2 = sortAuditRecordsDesc(rawHistory);
|
|
9936
|
-
const targetRecord2
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
if (latestRecord2.batchId !== batchId) {
|
|
9942
|
-
throw new Error("Only the latest completed update can be rolled back. Older batch updates cannot be rolled back.");
|
|
9943
|
-
}
|
|
9944
|
-
if (targetRecord2.isRolledBack) {
|
|
9945
|
-
throw new Error(`Batch "${batchId}" has already been rolled back.`);
|
|
9946
|
-
}
|
|
10270
|
+
const { targetRecord: targetRecord2, overlap: overlap2 } = validateRollbackCandidate(
|
|
10271
|
+
sortedHistory2,
|
|
10272
|
+
batchId,
|
|
10273
|
+
options?.confirmOverwrite
|
|
10274
|
+
);
|
|
9947
10275
|
const diffs2 = Array.isArray(targetRecord2.diffs) ? targetRecord2.diffs : [];
|
|
9948
10276
|
const { revertedCount: revertedCount2, rollbackDetails: rollbackDetails2 } = await this.revertDiffItems(diffs2, currentUser?.id);
|
|
9949
10277
|
const recordIndex = rawHistory.findIndex((r) => r.batchId === batchId);
|
|
@@ -9978,6 +10306,7 @@ const auditService = ({ strapi }) => ({
|
|
|
9978
10306
|
success: true,
|
|
9979
10307
|
batchId,
|
|
9980
10308
|
revertedCount: revertedCount2,
|
|
10309
|
+
overwrittenBatchIds: overlap2.hasOverlap ? overlap2.newerActiveBatchIds : [],
|
|
9981
10310
|
details: rollbackDetails2
|
|
9982
10311
|
};
|
|
9983
10312
|
}
|
|
@@ -10010,17 +10339,11 @@ const auditService = ({ strapi }) => ({
|
|
|
10010
10339
|
createdAt: r.createdAt
|
|
10011
10340
|
}));
|
|
10012
10341
|
const sortedHistory = sortAuditRecordsDesc(normalizedHistory);
|
|
10013
|
-
const targetRecord =
|
|
10014
|
-
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
if (latestRecord.batchId !== batchId) {
|
|
10019
|
-
throw new Error("Only the latest completed update can be rolled back. Older batch updates cannot be rolled back.");
|
|
10020
|
-
}
|
|
10021
|
-
if (targetRecord.isRolledBack) {
|
|
10022
|
-
throw new Error(`Batch "${batchId}" has already been rolled back.`);
|
|
10023
|
-
}
|
|
10342
|
+
const { targetRecord, overlap } = validateRollbackCandidate(
|
|
10343
|
+
sortedHistory,
|
|
10344
|
+
batchId,
|
|
10345
|
+
options?.confirmOverwrite
|
|
10346
|
+
);
|
|
10024
10347
|
const diffs = Array.isArray(targetRecord.diffs) ? targetRecord.diffs : [];
|
|
10025
10348
|
const { revertedCount, rollbackDetails } = await this.revertDiffItems(diffs, currentUser?.id);
|
|
10026
10349
|
const updateData = {};
|
|
@@ -10055,6 +10378,7 @@ const auditService = ({ strapi }) => ({
|
|
|
10055
10378
|
success: true,
|
|
10056
10379
|
batchId,
|
|
10057
10380
|
revertedCount,
|
|
10381
|
+
overwrittenBatchIds: overlap.hasOverlap ? overlap.newerActiveBatchIds : [],
|
|
10058
10382
|
details: rollbackDetails
|
|
10059
10383
|
};
|
|
10060
10384
|
});
|
|
@@ -11065,8 +11389,10 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
|
|
|
11065
11389
|
failedRows: [],
|
|
11066
11390
|
diffs: []
|
|
11067
11391
|
};
|
|
11392
|
+
const duplicateHeaders = findDuplicateCsvHeaders(originalHeaders);
|
|
11068
11393
|
const batchModeInfo = detectCsvBatchExportMode(rows);
|
|
11069
|
-
|
|
11394
|
+
const batchLevelError = duplicateHeaders.length > 0 ? `Duplicate CSV column header(s) detected: [${duplicateHeaders.join(", ")}]. Each column header must be unique.` : batchModeInfo.error;
|
|
11395
|
+
if (batchLevelError) {
|
|
11070
11396
|
for (let i = 0; i < rows.length; i++) {
|
|
11071
11397
|
const rowNumber = startRowNumber + i;
|
|
11072
11398
|
const row = rows[i];
|
|
@@ -11077,7 +11403,7 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
|
|
|
11077
11403
|
stats,
|
|
11078
11404
|
rowNumber,
|
|
11079
11405
|
row,
|
|
11080
|
-
|
|
11406
|
+
batchLevelError,
|
|
11081
11407
|
docId || void 0,
|
|
11082
11408
|
originalHeaders
|
|
11083
11409
|
);
|
|
@@ -11086,11 +11412,11 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
|
|
|
11086
11412
|
collectionName: ct.info?.displayName || uid,
|
|
11087
11413
|
documentId: docId || `(Row #${rowNumber})`,
|
|
11088
11414
|
label: `Row #${rowNumber}`,
|
|
11089
|
-
attribute: "__bulk_updater_metadata",
|
|
11415
|
+
attribute: duplicateHeaders.length > 0 ? duplicateHeaders[0] : "__bulk_updater_metadata",
|
|
11090
11416
|
oldValue: null,
|
|
11091
11417
|
newValue: null,
|
|
11092
11418
|
status: "error",
|
|
11093
|
-
message:
|
|
11419
|
+
message: batchLevelError
|
|
11094
11420
|
});
|
|
11095
11421
|
}
|
|
11096
11422
|
return stats;
|
|
@@ -11912,6 +12238,7 @@ const csvService = ({ strapi }) => ({
|
|
|
11912
12238
|
}
|
|
11913
12239
|
const { mode = "auto" } = options;
|
|
11914
12240
|
const attrs = ct.attributes || {};
|
|
12241
|
+
const schema = discoverSchema(strapi, uid);
|
|
11915
12242
|
let validationRulesService2 = null;
|
|
11916
12243
|
let activeRules = [];
|
|
11917
12244
|
try {
|
|
@@ -11936,6 +12263,28 @@ const csvService = ({ strapi }) => ({
|
|
|
11936
12263
|
};
|
|
11937
12264
|
const errors = [];
|
|
11938
12265
|
const warnings = [];
|
|
12266
|
+
const duplicateHeaders = findDuplicateCsvHeaders(options.originalHeaders);
|
|
12267
|
+
if (duplicateHeaders.length > 0) {
|
|
12268
|
+
errors.push({
|
|
12269
|
+
row: 1,
|
|
12270
|
+
error: `Duplicate CSV column header(s) detected: [${duplicateHeaders.join(", ")}]. Each column header must be unique.`
|
|
12271
|
+
});
|
|
12272
|
+
return {
|
|
12273
|
+
success: true,
|
|
12274
|
+
detectedExportMode: "invalid",
|
|
12275
|
+
totalRows: rows.length,
|
|
12276
|
+
validRows: 0,
|
|
12277
|
+
estimatedUpdates: 0,
|
|
12278
|
+
estimatedCreates: 0,
|
|
12279
|
+
lifecycleStats,
|
|
12280
|
+
hasErrors: true,
|
|
12281
|
+
hasWarnings: false,
|
|
12282
|
+
errors,
|
|
12283
|
+
warnings: [],
|
|
12284
|
+
totalErrorCount: errors.length,
|
|
12285
|
+
totalWarningCount: 0
|
|
12286
|
+
};
|
|
12287
|
+
}
|
|
11939
12288
|
const batchModeInfo = detectCsvBatchExportMode(rows);
|
|
11940
12289
|
if (batchModeInfo.error) {
|
|
11941
12290
|
errors.push({
|
|
@@ -12049,7 +12398,10 @@ const csvService = ({ strapi }) => ({
|
|
|
12049
12398
|
}
|
|
12050
12399
|
}
|
|
12051
12400
|
}
|
|
12052
|
-
|
|
12401
|
+
const rowMetaInfo = inspectRowMetadataMode(row);
|
|
12402
|
+
const beforeTargetNorm = normalizeSelectiveBeforeTargetRow(row, rowMetaInfo, schema);
|
|
12403
|
+
const normalizedScanRow = beforeTargetNorm.normalizedRow;
|
|
12404
|
+
for (const [colKey, rawVal] of Object.entries(normalizedScanRow)) {
|
|
12053
12405
|
if (!rawVal || rawVal.trim() === "") continue;
|
|
12054
12406
|
const normalizedKey = colKey.toLowerCase().replace(/[\s_-]/g, "");
|
|
12055
12407
|
if (SYSTEM_FIELD_KEYS.has(normalizedKey)) continue;
|
|
@@ -12954,6 +13306,7 @@ exports.escapeCsvCell = escapeCsvCell;
|
|
|
12954
13306
|
exports.extractHeadingsFromRichText = extractHeadingsFromRichText;
|
|
12955
13307
|
exports.extractMetadataFromRow = extractMetadataFromRow;
|
|
12956
13308
|
exports.extractRowFlattenedMetadata = extractRowFlattenedMetadata;
|
|
13309
|
+
exports.findDuplicateCsvHeaders = findDuplicateCsvHeaders;
|
|
12957
13310
|
exports.formatErrorCsvFilename = formatErrorCsvFilename;
|
|
12958
13311
|
exports.formatErrorWithCause = formatErrorWithCause;
|
|
12959
13312
|
exports.formatRelationState = formatRelationState;
|
|
@@ -12968,6 +13321,7 @@ exports.isPlainObject = isPlainObject;
|
|
|
12968
13321
|
exports.isValidDocumentId = isValidDocumentId;
|
|
12969
13322
|
exports.normalizeExportMode = normalizeExportMode;
|
|
12970
13323
|
exports.normalizeRuleQuotas = normalizeRuleQuotas;
|
|
13324
|
+
exports.normalizeSelectiveBeforeTargetRow = normalizeSelectiveBeforeTargetRow;
|
|
12971
13325
|
exports.parseBoolean = parseBoolean;
|
|
12972
13326
|
exports.parseCsvToMatrix = parseCsvToMatrix;
|
|
12973
13327
|
exports.parseCsvToRecords = parseCsvToRecords;
|