strapi-plugin-bulk-updater 1.6.0 → 1.6.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.
@@ -657,8 +657,8 @@ const csvController = ({ strapi }) => ({
657
657
  async exportCollection(ctx) {
658
658
  try {
659
659
  const { uid } = ctx.params;
660
- const { search, attribute, searchAttribute, filterOperator, filterQuery, limit, documentIds } = {
661
- ...ctx.query,
660
+ const { search, attribute, searchAttribute, filterOperator, filterQuery, limit, documentIds, exportMode } = {
661
+ ...ctx.query || {},
662
662
  ...ctx.request?.body || {}
663
663
  };
664
664
  const csvService2 = strapi.plugin("bulk-updater").service("csv");
@@ -673,7 +673,8 @@ const csvController = ({ strapi }) => ({
673
673
  filterOperator: filterOperator ? String(filterOperator) : void 0,
674
674
  filterQuery: filterQuery !== void 0 ? String(filterQuery) : void 0,
675
675
  limit: limit ? Number(limit) : void 0,
676
- documentIds: parsedDocIds
676
+ documentIds: parsedDocIds,
677
+ exportMode: exportMode ? String(exportMode) : void 0
677
678
  });
678
679
  ctx.body = {
679
680
  success: true,
@@ -1728,6 +1729,636 @@ function discoverSchema(strapi, uid) {
1728
1729
  allExportKeys
1729
1730
  };
1730
1731
  }
1732
+ const EXPLICIT_CLEAR_TOKENS = /* @__PURE__ */ new Set(["__CLEAR__", "__NULL__"]);
1733
+ const EXPLICIT_EMPTY_STRING_TOKEN = "__EMPTY__";
1734
+ const EXPLICIT_DELETE_KEY_TOKEN = "__DELETE__";
1735
+ const FORBIDDEN_OBJECT_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
1736
+ function normalizeExportMode(raw) {
1737
+ const val = String(raw || "").trim().toLowerCase();
1738
+ if (val === "metafields") return "metafields";
1739
+ if (val === "topbarconfig") return "topbarconfig";
1740
+ return "all";
1741
+ }
1742
+ function isPlainObject(val) {
1743
+ if (val === null || typeof val !== "object" || Array.isArray(val)) return false;
1744
+ if (val instanceof Date || val instanceof RegExp) return false;
1745
+ const proto = Object.getPrototypeOf(val);
1746
+ return proto === Object.prototype || proto === null;
1747
+ }
1748
+ function deepCloneValue(val) {
1749
+ if (val === null || val === void 0 || typeof val !== "object") {
1750
+ return val;
1751
+ }
1752
+ if (val instanceof Date) {
1753
+ return new Date(val.getTime());
1754
+ }
1755
+ if (Array.isArray(val)) {
1756
+ return val.map((item) => deepCloneValue(item));
1757
+ }
1758
+ if (isPlainObject(val)) {
1759
+ const out = {};
1760
+ for (const [k, v] of Object.entries(val)) {
1761
+ if (FORBIDDEN_OBJECT_KEYS.has(k)) continue;
1762
+ out[k] = deepCloneValue(v);
1763
+ }
1764
+ return out;
1765
+ }
1766
+ return val;
1767
+ }
1768
+ function deepEqualValues(a, b) {
1769
+ if (a === b) return true;
1770
+ if (a === null || b === null || a === void 0 || b === void 0) return false;
1771
+ if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime();
1772
+ if (Array.isArray(a) && Array.isArray(b)) {
1773
+ if (a.length !== b.length) return false;
1774
+ for (let i = 0; i < a.length; i++) {
1775
+ if (!deepEqualValues(a[i], b[i])) return false;
1776
+ }
1777
+ return true;
1778
+ }
1779
+ if (isPlainObject(a) && isPlainObject(b)) {
1780
+ const keysA = Object.keys(a).filter((k) => !FORBIDDEN_OBJECT_KEYS.has(k));
1781
+ const keysB = Object.keys(b).filter((k) => !FORBIDDEN_OBJECT_KEYS.has(k));
1782
+ if (keysA.length !== keysB.length) return false;
1783
+ for (const k of keysA) {
1784
+ if (!Object.prototype.hasOwnProperty.call(b, k)) return false;
1785
+ if (!deepEqualValues(a[k], b[k])) return false;
1786
+ }
1787
+ return true;
1788
+ }
1789
+ return false;
1790
+ }
1791
+ function isSafePropKey(segment) {
1792
+ return Boolean(segment) && !FORBIDDEN_OBJECT_KEYS.has(segment) && !segment.includes(".");
1793
+ }
1794
+ function resolveTargetObjectField(schema, exportMode) {
1795
+ if (exportMode === "all") return void 0;
1796
+ const keys = Object.keys(schema.fields || {});
1797
+ const exactMatch = keys.find((k) => k === exportMode);
1798
+ if (exactMatch) return exactMatch;
1799
+ const normalizedTarget = exportMode.toLowerCase().replace(/[_-]/g, "");
1800
+ return keys.find((k) => k.toLowerCase().replace(/[_-]/g, "") === normalizedTarget);
1801
+ }
1802
+ function classifyLeafType(val) {
1803
+ if (val === null) return "null";
1804
+ if (Array.isArray(val)) return "array";
1805
+ if (isPlainObject(val)) return "object";
1806
+ if (typeof val === "number") return "number";
1807
+ if (typeof val === "boolean") return "boolean";
1808
+ return "string";
1809
+ }
1810
+ function needsTypeAnnotation(val) {
1811
+ if (val === null) return true;
1812
+ if (Array.isArray(val) || isPlainObject(val)) return true;
1813
+ if (typeof val === "number" || typeof val === "boolean") return true;
1814
+ if (typeof val === "string") {
1815
+ const trimmed = val.trim();
1816
+ if (val === "" || trimmed === "null" || trimmed === "true" || trimmed === "false" || trimmed.startsWith("[") || trimmed.startsWith("{") || /^-?\d+(?:\.\d+)?$/.test(trimmed)) {
1817
+ return true;
1818
+ }
1819
+ }
1820
+ return false;
1821
+ }
1822
+ function collectFirstLevelObjectColumns(strapi, rootKey, field, documents, blockedNames) {
1823
+ const result = [];
1824
+ const seenProps = /* @__PURE__ */ new Set();
1825
+ if (field.category === "component_single" && field.componentUid) {
1826
+ const comp = strapi.components?.[field.componentUid];
1827
+ if (comp?.attributes) {
1828
+ for (const [subKey, subDef] of Object.entries(comp.attributes)) {
1829
+ if (!isSafePropKey(subKey)) continue;
1830
+ const norm = subKey.toLowerCase().replace(/[\s_-]/g, "");
1831
+ if (SYSTEM_ATTRIBUTES.has(norm) || subKey === "id" || subKey === "__component") continue;
1832
+ const header = `${rootKey}.${subKey}`;
1833
+ if (blockedNames.has(header) || seenProps.has(subKey)) continue;
1834
+ seenProps.add(subKey);
1835
+ result.push({
1836
+ header,
1837
+ kind: "flattened_first_level",
1838
+ rootKey,
1839
+ propKey: subKey,
1840
+ field,
1841
+ componentSubDef: subDef
1842
+ });
1843
+ }
1844
+ }
1845
+ }
1846
+ for (const doc of documents) {
1847
+ const obj = doc?.[rootKey];
1848
+ if (obj === null || obj === void 0) continue;
1849
+ if (!isPlainObject(obj)) {
1850
+ if (field.category === "json") {
1851
+ return [];
1852
+ }
1853
+ continue;
1854
+ }
1855
+ for (const propKey of Object.keys(obj)) {
1856
+ if (!isSafePropKey(propKey)) continue;
1857
+ const header = `${rootKey}.${propKey}`;
1858
+ if (blockedNames.has(header) || seenProps.has(propKey)) continue;
1859
+ seenProps.add(propKey);
1860
+ result.push({
1861
+ header,
1862
+ kind: "flattened_first_level",
1863
+ rootKey,
1864
+ propKey,
1865
+ field
1866
+ });
1867
+ }
1868
+ }
1869
+ return result;
1870
+ }
1871
+ function buildExportColumnPlan(strapi, uid, documents, options = {}) {
1872
+ const schema = options.schema || discoverSchema(strapi, uid);
1873
+ const exportMode = normalizeExportMode(options.exportMode);
1874
+ const targetObjectField = resolveTargetObjectField(schema, exportMode);
1875
+ const topLevelNames = new Set(schema.allExportKeys);
1876
+ const columns = [];
1877
+ for (const key of schema.allExportKeys) {
1878
+ if (key === "documentId" || key === "locale") {
1879
+ columns.push({
1880
+ header: key,
1881
+ kind: "system",
1882
+ rootKey: key
1883
+ });
1884
+ continue;
1885
+ }
1886
+ const field = schema.fields[key];
1887
+ if (!field) {
1888
+ columns.push({
1889
+ header: key,
1890
+ kind: "field",
1891
+ rootKey: key
1892
+ });
1893
+ continue;
1894
+ }
1895
+ if (exportMode !== "all" && targetObjectField && key === targetObjectField) {
1896
+ if (field.category === "json" || field.category === "component_single") {
1897
+ const firstLevelCols = collectFirstLevelObjectColumns(
1898
+ strapi,
1899
+ key,
1900
+ field,
1901
+ documents,
1902
+ topLevelNames
1903
+ );
1904
+ if (firstLevelCols.length > 0) {
1905
+ columns.push(...firstLevelCols);
1906
+ continue;
1907
+ }
1908
+ }
1909
+ }
1910
+ columns.push({
1911
+ header: key,
1912
+ kind: "field",
1913
+ rootKey: key,
1914
+ field
1915
+ });
1916
+ }
1917
+ return {
1918
+ exportMode,
1919
+ targetObjectField,
1920
+ columns,
1921
+ headers: columns.map((c) => c.header)
1922
+ };
1923
+ }
1924
+ function extractRowFlattenedMetadata(plan, doc) {
1925
+ const out = {
1926
+ exportMode: plan.exportMode
1927
+ };
1928
+ if (plan.exportMode === "all" || !plan.targetObjectField) {
1929
+ return out;
1930
+ }
1931
+ const rootKey = plan.targetObjectField;
1932
+ out.targetObjectField = rootKey;
1933
+ const hasOwn = doc && typeof doc === "object" && Object.prototype.hasOwnProperty.call(doc, rootKey);
1934
+ const rawVal = hasOwn ? doc[rootKey] : void 0;
1935
+ if (!hasOwn || rawVal === void 0) {
1936
+ out.targetObjectState = "absent";
1937
+ out.applicableFields = [];
1938
+ return out;
1939
+ }
1940
+ if (rawVal === null) {
1941
+ out.targetObjectState = "null";
1942
+ out.applicableFields = [];
1943
+ return out;
1944
+ }
1945
+ if (isPlainObject(rawVal)) {
1946
+ const keys = Object.keys(rawVal);
1947
+ out.targetObjectState = keys.length === 0 ? "empty_object" : "present";
1948
+ out.applicableFields = [rootKey];
1949
+ const flatTypes = {};
1950
+ for (const col of plan.columns) {
1951
+ if (col.kind !== "flattened_first_level" || !col.propKey) continue;
1952
+ if (!Object.prototype.hasOwnProperty.call(rawVal, col.propKey)) continue;
1953
+ const leafVal = rawVal[col.propKey];
1954
+ if (leafVal !== void 0 && needsTypeAnnotation(leafVal)) {
1955
+ flatTypes[col.header] = classifyLeafType(leafVal);
1956
+ }
1957
+ }
1958
+ if (Object.keys(flatTypes).length > 0) {
1959
+ out.flatTypes = flatTypes;
1960
+ }
1961
+ return out;
1962
+ }
1963
+ out.targetObjectState = "present";
1964
+ out.applicableFields = [rootKey];
1965
+ return out;
1966
+ }
1967
+ function serializePlannedCell(col, doc, serializeFieldFallback) {
1968
+ if (col.kind === "system") {
1969
+ if (col.header === "documentId") return doc?.documentId || doc?.id || "";
1970
+ if (col.header === "locale") return doc?.locale || "";
1971
+ return doc?.[col.header] ?? "";
1972
+ }
1973
+ if (col.kind === "flattened_first_level" && col.propKey) {
1974
+ const rootObj = doc?.[col.rootKey];
1975
+ if (!isPlainObject(rootObj) || !Object.prototype.hasOwnProperty.call(rootObj, col.propKey)) {
1976
+ return "";
1977
+ }
1978
+ const val = rootObj[col.propKey];
1979
+ if (val === void 0 || val === null) return "";
1980
+ const subDef = col.componentSubDef || {};
1981
+ const subType = String(subDef.type || "").toLowerCase();
1982
+ if (subType === "media") {
1983
+ return serializeFieldFallback(val, {
1984
+ key: col.header,
1985
+ label: col.header,
1986
+ category: subDef.multiple ? "media_to_many" : "media_single",
1987
+ rawType: "media",
1988
+ multiple: Boolean(subDef.multiple)
1989
+ });
1990
+ }
1991
+ if (subType === "relation") {
1992
+ const isToMany = String(subDef.relation || "").toLowerCase().endsWith("many");
1993
+ return serializeFieldFallback(val, {
1994
+ key: col.header,
1995
+ label: col.header,
1996
+ category: isToMany ? "relation_to_many" : "relation_to_one",
1997
+ rawType: "relation",
1998
+ relationType: subDef.relation
1999
+ });
2000
+ }
2001
+ if (val instanceof Date) return val.toISOString();
2002
+ if (Array.isArray(val) || isPlainObject(val)) {
2003
+ return JSON.stringify(val);
2004
+ }
2005
+ if (typeof val === "boolean") return val ? "true" : "false";
2006
+ if (typeof val === "number") return Number.isFinite(val) ? String(val) : "";
2007
+ return String(val);
2008
+ }
2009
+ const rawValue = doc?.[col.rootKey];
2010
+ if (col.field) {
2011
+ return serializeFieldFallback(rawValue, col.field);
2012
+ }
2013
+ return rawValue;
2014
+ }
2015
+ function inspectRowMetadataMode(rawRow) {
2016
+ if (!rawRow || typeof rawRow !== "object") {
2017
+ return { mode: "legacy" };
2018
+ }
2019
+ const rawMetaCell = rawRow["__bulk_updater_metadata"] !== void 0 ? rawRow["__bulk_updater_metadata"] : rawRow["_bulk_updater_metadata"];
2020
+ if (rawMetaCell === void 0 || rawMetaCell === null || String(rawMetaCell).trim() === "") {
2021
+ return { mode: "legacy" };
2022
+ }
2023
+ let parsed = rawMetaCell;
2024
+ if (typeof rawMetaCell === "string") {
2025
+ try {
2026
+ parsed = JSON.parse(rawMetaCell);
2027
+ } catch {
2028
+ return {
2029
+ mode: "legacy",
2030
+ error: "Corrupted __bulk_updater_metadata cell: invalid JSON."
2031
+ };
2032
+ }
2033
+ }
2034
+ if (!isPlainObject(parsed)) {
2035
+ return {
2036
+ mode: "legacy",
2037
+ error: "Corrupted __bulk_updater_metadata cell: expected JSON object."
2038
+ };
2039
+ }
2040
+ if (parsed.exportMode === void 0) {
2041
+ return {
2042
+ mode: "legacy",
2043
+ applicableFields: Array.isArray(parsed.applicableFields) ? parsed.applicableFields : void 0,
2044
+ flatTypes: isPlainObject(parsed.flatTypes) ? parsed.flatTypes : void 0
2045
+ };
2046
+ }
2047
+ const rawMode = String(parsed.exportMode).trim().toLowerCase();
2048
+ if (rawMode !== "all" && rawMode !== "metafields" && rawMode !== "topbarconfig") {
2049
+ return {
2050
+ mode: "legacy",
2051
+ error: `Unsupported CSV exportMode "${parsed.exportMode}" in metadata.`
2052
+ };
2053
+ }
2054
+ return {
2055
+ mode: rawMode,
2056
+ targetObjectField: typeof parsed.targetObjectField === "string" && parsed.targetObjectField.trim() ? parsed.targetObjectField.trim() : void 0,
2057
+ targetObjectState: parsed.targetObjectState,
2058
+ applicableFields: Array.isArray(parsed.applicableFields) ? parsed.applicableFields : void 0,
2059
+ flatTypes: isPlainObject(parsed.flatTypes) ? parsed.flatTypes : void 0
2060
+ };
2061
+ }
2062
+ function detectCsvBatchExportMode(rows) {
2063
+ const seenModes = /* @__PURE__ */ new Set();
2064
+ for (let i = 0; i < rows.length; i++) {
2065
+ const info = inspectRowMetadataMode(rows[i]);
2066
+ if (info.error) {
2067
+ return { mode: "legacy", error: `Row ${i + 2}: ${info.error}` };
2068
+ }
2069
+ seenModes.add(info.mode);
2070
+ }
2071
+ if (seenModes.size > 1) {
2072
+ return {
2073
+ mode: "legacy",
2074
+ error: `Inconsistent CSV export modes detected across rows (${Array.from(seenModes).join(", ")}). Re-export the file cleanly before importing.`
2075
+ };
2076
+ }
2077
+ const first = Array.from(seenModes)[0];
2078
+ return { mode: first || "legacy" };
2079
+ }
2080
+ function parseFirstLevelCellValue(rawCell, annotatedType, existingPropValue) {
2081
+ if (rawCell === null || rawCell === void 0) return { value: null };
2082
+ if (typeof rawCell !== "string") return { value: rawCell };
2083
+ const trimmed = rawCell.trim();
2084
+ if (EXPLICIT_CLEAR_TOKENS.has(trimmed)) {
2085
+ return { value: null };
2086
+ }
2087
+ if (trimmed === EXPLICIT_EMPTY_STRING_TOKEN) {
2088
+ return { value: "" };
2089
+ }
2090
+ if (annotatedType === "string") {
2091
+ return { value: rawCell };
2092
+ }
2093
+ if (annotatedType === "object" || isPlainObject(existingPropValue)) {
2094
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
2095
+ try {
2096
+ return { value: JSON.parse(trimmed) };
2097
+ } catch {
2098
+ return {
2099
+ value: rawCell,
2100
+ error: `Invalid JSON object value: "${rawCell}"`
2101
+ };
2102
+ }
2103
+ }
2104
+ }
2105
+ if (annotatedType === "array" || Array.isArray(existingPropValue)) {
2106
+ if (trimmed.startsWith("[")) {
2107
+ try {
2108
+ const parsed = JSON.parse(trimmed);
2109
+ return { value: parsed };
2110
+ } catch {
2111
+ return {
2112
+ value: rawCell,
2113
+ error: `Invalid JSON array value: "${rawCell}"`
2114
+ };
2115
+ }
2116
+ }
2117
+ }
2118
+ if (annotatedType === "number" || typeof existingPropValue === "number") {
2119
+ if (/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(trimmed)) {
2120
+ const num = Number(trimmed);
2121
+ if (Number.isFinite(num)) return { value: num };
2122
+ }
2123
+ }
2124
+ if (annotatedType === "boolean" || typeof existingPropValue === "boolean") {
2125
+ const low = trimmed.toLowerCase();
2126
+ if (low === "true") return { value: true };
2127
+ if (low === "false") return { value: false };
2128
+ }
2129
+ if (typeof existingPropValue === "string") {
2130
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
2131
+ try {
2132
+ return { value: JSON.parse(trimmed) };
2133
+ } catch {
2134
+ }
2135
+ }
2136
+ return { value: rawCell };
2137
+ }
2138
+ if (trimmed === "null") return { value: null };
2139
+ if (trimmed === "true") return { value: true };
2140
+ if (trimmed === "false") return { value: false };
2141
+ if (/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(trimmed)) {
2142
+ const num = Number(trimmed);
2143
+ if (Number.isFinite(num)) return { value: num };
2144
+ }
2145
+ if (trimmed.startsWith("[") && trimmed.endsWith("]") || trimmed.startsWith("{") && trimmed.endsWith("}")) {
2146
+ try {
2147
+ return { value: JSON.parse(trimmed) };
2148
+ } catch {
2149
+ }
2150
+ }
2151
+ return { value: rawCell };
2152
+ }
2153
+ function reconstructTargetedFirstLevelObject(params) {
2154
+ const {
2155
+ targetAttr,
2156
+ exportMode,
2157
+ existingDoc,
2158
+ docIdForError,
2159
+ rawRow,
2160
+ rowMeta,
2161
+ isAttrRequired = false
2162
+ } = params;
2163
+ const prefix = `${targetAttr}.`;
2164
+ const firstLevelEntries = [];
2165
+ const invalidNestedColumns = [];
2166
+ for (const [colKey, val] of Object.entries(rawRow)) {
2167
+ if (!colKey.startsWith(prefix)) continue;
2168
+ const propKey = colKey.slice(prefix.length);
2169
+ if (!propKey) continue;
2170
+ if (propKey.includes(".")) {
2171
+ if (val !== void 0 && val !== null && String(val) !== "") {
2172
+ invalidNestedColumns.push(colKey);
2173
+ }
2174
+ continue;
2175
+ }
2176
+ if (!isSafePropKey(propKey)) continue;
2177
+ firstLevelEntries.push([colKey, propKey, val]);
2178
+ }
2179
+ if (invalidNestedColumns.length > 0) {
2180
+ return {
2181
+ shouldSet: false,
2182
+ value: void 0,
2183
+ errors: [
2184
+ `Deeply nested column(s) [${invalidNestedColumns.join(", ")}] are not valid in "${exportMode}" one-level targeted mode.`
2185
+ ]
2186
+ };
2187
+ }
2188
+ const directRawVal = targetAttr in rawRow ? rawRow[targetAttr] : void 0;
2189
+ const directTrimmed = typeof directRawVal === "string" ? directRawVal.trim() : "";
2190
+ const hasNonEmptyFirstLevelEdit = firstLevelEntries.some(
2191
+ ([, , val]) => val !== void 0 && val !== null && String(val) !== ""
2192
+ );
2193
+ if (existingDoc) {
2194
+ const existingObj = existingDoc[targetAttr];
2195
+ const hasObjectOnRecord = isPlainObject(existingObj);
2196
+ if (!hasObjectOnRecord) {
2197
+ const attemptedDirectEdit = directRawVal !== void 0 && directRawVal !== null && directTrimmed !== "";
2198
+ if (!hasNonEmptyFirstLevelEdit && !attemptedDirectEdit) {
2199
+ return { shouldSet: false, value: void 0, errors: [] };
2200
+ }
2201
+ if (!isAttrRequired) {
2202
+ const recordRef = docIdForError || existingDoc.documentId || existingDoc.id || "record";
2203
+ return {
2204
+ shouldSet: false,
2205
+ value: void 0,
2206
+ errors: [
2207
+ `Field "${targetAttr}" is not applicable or absent on document "${recordRef}". Targeted "${exportMode}" import will not create a new "${targetAttr}" object automatically.`
2208
+ ]
2209
+ };
2210
+ }
2211
+ }
2212
+ } else {
2213
+ if (!hasNonEmptyFirstLevelEdit && (!directTrimmed || directTrimmed === "")) {
2214
+ return { shouldSet: false, value: void 0, errors: [] };
2215
+ }
2216
+ }
2217
+ const base = isPlainObject(existingDoc?.[targetAttr]) ? deepCloneValue(existingDoc[targetAttr]) : {};
2218
+ const errors2 = [];
2219
+ let appliedAnyModification = false;
2220
+ if (firstLevelEntries.length === 0 && directRawVal !== void 0 && directRawVal !== null && directTrimmed !== "") {
2221
+ if (EXPLICIT_CLEAR_TOKENS.has(directTrimmed) || directTrimmed === "null") {
2222
+ return { shouldSet: true, value: null, errors: [] };
2223
+ }
2224
+ try {
2225
+ const parsedDirect = typeof directRawVal === "string" ? JSON.parse(directRawVal) : directRawVal;
2226
+ if (isPlainObject(parsedDirect)) {
2227
+ return {
2228
+ shouldSet: true,
2229
+ value: { ...base, ...deepCloneValue(parsedDirect) },
2230
+ errors: []
2231
+ };
2232
+ }
2233
+ return { shouldSet: true, value: parsedDirect, errors: [] };
2234
+ } catch {
2235
+ return {
2236
+ shouldSet: false,
2237
+ value: void 0,
2238
+ errors: [`Column "${targetAttr}" contains invalid JSON: "${directRawVal}"`]
2239
+ };
2240
+ }
2241
+ }
2242
+ for (const [colKey, propKey, rawCell] of firstLevelEntries) {
2243
+ if (rawCell === void 0 || rawCell === null) continue;
2244
+ const strCell = String(rawCell);
2245
+ const trimmed = strCell.trim();
2246
+ if (trimmed === EXPLICIT_DELETE_KEY_TOKEN) {
2247
+ if (Object.prototype.hasOwnProperty.call(base, propKey)) {
2248
+ delete base[propKey];
2249
+ appliedAnyModification = true;
2250
+ }
2251
+ continue;
2252
+ }
2253
+ if (EXPLICIT_CLEAR_TOKENS.has(trimmed)) {
2254
+ base[propKey] = null;
2255
+ appliedAnyModification = true;
2256
+ continue;
2257
+ }
2258
+ if (strCell === "") {
2259
+ continue;
2260
+ }
2261
+ const annotatedType = rowMeta.flatTypes?.[colKey];
2262
+ const existingPropValue = isPlainObject(existingDoc?.[targetAttr]) ? existingDoc[targetAttr][propKey] : void 0;
2263
+ const parsed = parseFirstLevelCellValue(strCell, annotatedType, existingPropValue);
2264
+ if (parsed.error) {
2265
+ errors2.push(`Column "${colKey}": ${parsed.error}`);
2266
+ continue;
2267
+ }
2268
+ base[propKey] = parsed.value;
2269
+ appliedAnyModification = true;
2270
+ }
2271
+ if (errors2.length > 0) {
2272
+ return { shouldSet: false, value: void 0, errors: errors2 };
2273
+ }
2274
+ if (!appliedAnyModification) {
2275
+ return { shouldSet: false, value: void 0, errors: [] };
2276
+ }
2277
+ if (existingDoc && isPlainObject(existingDoc[targetAttr]) && deepEqualValues(base, existingDoc[targetAttr])) {
2278
+ return { shouldSet: false, value: void 0, errors: [] };
2279
+ }
2280
+ return { shouldSet: true, value: base, errors: [] };
2281
+ }
2282
+ function validateRecordSchemaConstraints(strapi, uid, existingDoc, payload, rawRow, options) {
2283
+ const ct = strapi.contentTypes?.[uid];
2284
+ if (!ct) return { errors: [], warnings: [] };
2285
+ const attrs = ct.attributes || {};
2286
+ const errors2 = [];
2287
+ const warnings = [];
2288
+ const isTargeted = options.detectedMode === "metafields" || options.detectedMode === "topbarconfig";
2289
+ const isMissingRequiredValue = (val) => val === void 0 || val === null || typeof val === "string" && val.trim() === "";
2290
+ if (!isTargeted || options.isCreate) {
2291
+ for (const [attrName, attrDef] of Object.entries(attrs)) {
2292
+ if (!attrDef?.required) continue;
2293
+ const norm = attrName.toLowerCase().replace(/[\s_-]/g, "");
2294
+ if (SYSTEM_ATTRIBUTES.has(norm)) continue;
2295
+ if (options.isCreate) {
2296
+ if (isMissingRequiredValue(payload[attrName])) {
2297
+ errors2.push(`Missing mandatory field "${attrName}".`);
2298
+ }
2299
+ } else if (attrName in payload && isMissingRequiredValue(payload[attrName])) {
2300
+ errors2.push(`Mandatory field "${attrName}" cannot be empty or cleared.`);
2301
+ }
2302
+ }
2303
+ } else if (options.targetObjectField) {
2304
+ const tDef = attrs[options.targetObjectField];
2305
+ if (tDef?.required && options.targetObjectField in payload && isMissingRequiredValue(payload[options.targetObjectField])) {
2306
+ errors2.push(`Mandatory field "${options.targetObjectField}" cannot be empty or cleared.`);
2307
+ }
2308
+ }
2309
+ const validateComponentRequired = (compUid, valueObj, pathPrefix) => {
2310
+ const comp = strapi.components?.[compUid];
2311
+ if (!comp?.attributes || !isPlainObject(valueObj)) return;
2312
+ for (const [subKey, subDef] of Object.entries(comp.attributes)) {
2313
+ const subPath = `${pathPrefix}.${subKey}`;
2314
+ const subVal = valueObj[subKey];
2315
+ if (subDef?.required && isMissingRequiredValue(subVal)) {
2316
+ errors2.push(`Missing mandatory field "${subPath}".`);
2317
+ }
2318
+ if (subDef?.type === "component" && !subDef.repeatable && subDef.component && isPlainObject(subVal)) {
2319
+ validateComponentRequired(subDef.component, subVal, subPath);
2320
+ }
2321
+ }
2322
+ };
2323
+ for (const [attrName, attrDef] of Object.entries(attrs)) {
2324
+ if (attrDef?.type === "component" && !attrDef.repeatable && attrDef.component) {
2325
+ const nextCompVal = payload[attrName];
2326
+ if (isPlainObject(nextCompVal)) {
2327
+ validateComponentRequired(attrDef.component, nextCompVal, attrName);
2328
+ }
2329
+ }
2330
+ }
2331
+ if (isTargeted && options.targetObjectField) {
2332
+ const tDef = attrs[options.targetObjectField];
2333
+ if (tDef?.type === "component" && !tDef.repeatable && tDef.component && strapi.components?.[tDef.component]) {
2334
+ const compAttrs = strapi.components[tDef.component].attributes || {};
2335
+ const prefix = `${options.targetObjectField}.`;
2336
+ for (const [colKey, rawVal] of Object.entries(rawRow)) {
2337
+ if (!colKey.startsWith(prefix)) continue;
2338
+ const propKey = colKey.slice(prefix.length);
2339
+ const subDef = compAttrs[propKey];
2340
+ const trimmed = rawVal === void 0 || rawVal === null ? "" : String(rawVal).trim();
2341
+ if (!subDef || !trimmed || EXPLICIT_CLEAR_TOKENS.has(trimmed) || trimmed === EXPLICIT_DELETE_KEY_TOKEN || trimmed === EXPLICIT_EMPTY_STRING_TOKEN) {
2342
+ continue;
2343
+ }
2344
+ if (subDef.type === "integer" || subDef.type === "biginteger") {
2345
+ if (!/^-?\d+$/.test(trimmed)) {
2346
+ errors2.push(`Column "${colKey}" expects an integer, received: "${rawVal}"`);
2347
+ }
2348
+ } else if (subDef.type === "float" || subDef.type === "decimal") {
2349
+ if (isNaN(Number(trimmed))) {
2350
+ errors2.push(`Column "${colKey}" expects a numeric float/decimal, received: "${rawVal}"`);
2351
+ }
2352
+ } else if (subDef.type === "enumeration" && Array.isArray(subDef.enum)) {
2353
+ if (!subDef.enum.includes(trimmed)) {
2354
+ warnings.push(`Column "${colKey}" value "${rawVal}" is not in defined enum options: [${subDef.enum.join(", ")}]`);
2355
+ }
2356
+ }
2357
+ }
2358
+ }
2359
+ }
2360
+ return { errors: errors2, warnings };
2361
+ }
1731
2362
  function isValidDocumentId(val) {
1732
2363
  if (!val || typeof val !== "string") return false;
1733
2364
  const trimmed = val.trim();
@@ -1942,7 +2573,37 @@ async function resolveComponentPayload(strapi, compUid, rawVal, existingVal = {}
1942
2573
  result[attrName] = parseNumeric(fieldVal, false);
1943
2574
  } else if (type === "boolean") {
1944
2575
  result[attrName] = parseBoolean(fieldVal);
1945
- } else if (type === "json" || type === "blocks") {
2576
+ } else if (type === "json") {
2577
+ if (isPlainObject(fieldVal) && isPlainObject(existingVal?.[attrName])) {
2578
+ const deepMergePlain = (base, patch) => {
2579
+ if (!isPlainObject(base) || !isPlainObject(patch)) return patch;
2580
+ const next = deepCloneValue(base);
2581
+ for (const [k, v] of Object.entries(patch)) {
2582
+ if (isPlainObject(v) && isPlainObject(next[k])) {
2583
+ next[k] = deepMergePlain(next[k], v);
2584
+ } else {
2585
+ next[k] = parseFirstLevelCellValue(v, void 0, next[k]).value;
2586
+ }
2587
+ }
2588
+ return next;
2589
+ };
2590
+ result[attrName] = deepMergePlain(existingVal[attrName], fieldVal);
2591
+ } else if (isPlainObject(fieldVal)) {
2592
+ const parsedObj = {};
2593
+ for (const [k, v] of Object.entries(fieldVal)) {
2594
+ parsedObj[k] = isPlainObject(v) ? deepCloneValue(v) : parseFirstLevelCellValue(v).value;
2595
+ }
2596
+ result[attrName] = parsedObj;
2597
+ } else if (typeof fieldVal === "string") {
2598
+ try {
2599
+ result[attrName] = JSON.parse(fieldVal);
2600
+ } catch {
2601
+ result[attrName] = fieldVal;
2602
+ }
2603
+ } else {
2604
+ result[attrName] = fieldVal;
2605
+ }
2606
+ } else if (type === "blocks") {
1946
2607
  if (typeof fieldVal === "string") {
1947
2608
  try {
1948
2609
  result[attrName] = JSON.parse(fieldVal);
@@ -1989,29 +2650,164 @@ async function resolveDynamicZonePayload(strapi, allowedComponents, rawVal, exis
1989
2650
  }
1990
2651
  return resolvedBlocks;
1991
2652
  }
1992
- async function buildDocumentUpdatePayload(strapi, uid, existingDoc, rawRow, options = {}) {
2653
+ const UNSAFE_PROP_NAMES = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
2654
+ function buildLegacyNestedPatchFromDots(attrName, dotEntries) {
2655
+ const patch = {};
2656
+ let hasEffectiveEdits = false;
2657
+ const prefix = `${attrName}.`;
2658
+ for (const [fullKey, rawVal] of dotEntries) {
2659
+ if (!fullKey.startsWith(prefix)) continue;
2660
+ if (rawVal === void 0 || rawVal === null || rawVal === "") continue;
2661
+ const segments = fullKey.slice(prefix.length).split(".").filter(Boolean);
2662
+ if (segments.length === 0 || segments.some((s) => UNSAFE_PROP_NAMES.has(s))) continue;
2663
+ const strVal = String(rawVal);
2664
+ const trimmed = strVal.trim();
2665
+ if (trimmed === EXPLICIT_DELETE_KEY_TOKEN) continue;
2666
+ const parsedValue = EXPLICIT_CLEAR_TOKENS.has(trimmed) ? null : trimmed === EXPLICIT_EMPTY_STRING_TOKEN ? "" : parseFirstLevelCellValue(strVal).value;
2667
+ let cursor = patch;
2668
+ for (let i = 0; i < segments.length - 1; i++) {
2669
+ const seg = segments[i];
2670
+ if (!isPlainObject(cursor[seg])) {
2671
+ cursor[seg] = {};
2672
+ }
2673
+ cursor = cursor[seg];
2674
+ }
2675
+ cursor[segments[segments.length - 1]] = parsedValue;
2676
+ hasEffectiveEdits = true;
2677
+ }
2678
+ return { hasEffectiveEdits, patch };
2679
+ }
2680
+ async function prepareCsvRowMutation(strapi, uid, existingDoc, rawRow, options = {}) {
1993
2681
  const schema = discoverSchema(strapi, uid);
1994
2682
  const payload = {};
2683
+ const errors2 = [];
2684
+ const warnings = [];
2685
+ const isPartialUpdate = options.isPartialUpdate !== false;
2686
+ const isCreate = options.isCreate !== void 0 ? options.isCreate : !existingDoc;
1995
2687
  const unescapedRow = {};
1996
- for (const [k, v] of Object.entries(rawRow)) {
2688
+ for (const [k, v] of Object.entries(rawRow || {})) {
1997
2689
  let cleanVal = v;
1998
2690
  if (typeof cleanVal === "string" && /^'[=+@-]/.test(cleanVal)) {
1999
2691
  cleanVal = cleanVal.substring(1);
2000
2692
  }
2001
2693
  unescapedRow[k] = cleanVal;
2002
2694
  }
2003
- const dotNotationMap = {};
2695
+ const rowInfo = inspectRowMetadataMode(unescapedRow);
2696
+ if (rowInfo.error) {
2697
+ errors2.push(rowInfo.error);
2698
+ }
2699
+ const detectedMode = rowInfo.mode;
2700
+ if (options.expectedExportMode && detectedMode !== options.expectedExportMode) {
2701
+ errors2.push(
2702
+ `Row exportMode "${detectedMode}" conflicts with batch exportMode "${options.expectedExportMode}".`
2703
+ );
2704
+ }
2705
+ const isTargetedMode = detectedMode === "metafields" || detectedMode === "topbarconfig";
2706
+ const targetAttr = isTargetedMode ? rowInfo.targetObjectField || resolveTargetObjectField(schema, detectedMode) || detectedMode : void 0;
2707
+ if (isTargetedMode && targetAttr && !isCreate) {
2708
+ const targetField = schema.fields[targetAttr];
2709
+ if (!targetField || targetField.category !== "json" && targetField.category !== "component_single") {
2710
+ errors2.push(
2711
+ `Target object field "${targetAttr}" for exportMode "${detectedMode}" was not found as an object/component attribute on "${uid}".`
2712
+ );
2713
+ return {
2714
+ payload,
2715
+ errors: errors2,
2716
+ warnings,
2717
+ detectedMode,
2718
+ targetObjectField: targetAttr,
2719
+ rowMeta: rowInfo
2720
+ };
2721
+ }
2722
+ const ctAttr = strapi.contentTypes?.[uid]?.attributes?.[targetAttr];
2723
+ const reconstructed = reconstructTargetedFirstLevelObject({
2724
+ targetAttr,
2725
+ exportMode: detectedMode,
2726
+ existingDoc,
2727
+ docIdForError: options.docIdForError,
2728
+ rawRow: unescapedRow,
2729
+ rowMeta: rowInfo,
2730
+ isAttrRequired: Boolean(ctAttr?.required)
2731
+ });
2732
+ if (reconstructed.errors.length > 0) {
2733
+ errors2.push(...reconstructed.errors);
2734
+ }
2735
+ if (reconstructed.shouldSet) {
2736
+ if (targetField.category === "component_single" && targetField.componentUid && isPlainObject(reconstructed.value)) {
2737
+ payload[targetAttr] = await resolveComponentPayload(
2738
+ strapi,
2739
+ targetField.componentUid,
2740
+ reconstructed.value,
2741
+ existingDoc?.[targetAttr] || {}
2742
+ );
2743
+ } else {
2744
+ payload[targetAttr] = reconstructed.value;
2745
+ }
2746
+ }
2747
+ const schemaCheck2 = validateRecordSchemaConstraints(
2748
+ strapi,
2749
+ uid,
2750
+ existingDoc,
2751
+ payload,
2752
+ unescapedRow,
2753
+ {
2754
+ isCreate: false,
2755
+ detectedMode,
2756
+ targetObjectField: targetAttr
2757
+ }
2758
+ );
2759
+ errors2.push(...schemaCheck2.errors);
2760
+ warnings.push(...schemaCheck2.warnings);
2761
+ return {
2762
+ payload,
2763
+ errors: errors2,
2764
+ warnings,
2765
+ detectedMode,
2766
+ targetObjectField: targetAttr,
2767
+ rowMeta: rowInfo
2768
+ };
2769
+ }
2770
+ const dotEntriesByAttr = {};
2004
2771
  for (const [k, v] of Object.entries(unescapedRow)) {
2005
- if (k.includes(".")) {
2006
- const [parent, ...rest] = k.split(".");
2007
- const child = rest.join(".");
2008
- if (!dotNotationMap[parent]) dotNotationMap[parent] = {};
2009
- dotNotationMap[parent][child] = v;
2772
+ const firstDot = k.indexOf(".");
2773
+ if (firstDot > 0) {
2774
+ const parent = k.slice(0, firstDot);
2775
+ if (!dotEntriesByAttr[parent]) dotEntriesByAttr[parent] = [];
2776
+ dotEntriesByAttr[parent].push([k, v]);
2010
2777
  }
2011
2778
  }
2012
2779
  for (const [attrName, field] of Object.entries(schema.fields)) {
2013
2780
  const hasDirectKey = attrName in unescapedRow;
2014
- const hasDotKeys = Boolean(dotNotationMap[attrName]);
2781
+ const dotEntries = dotEntriesByAttr[attrName] || [];
2782
+ const hasDotKeys = dotEntries.length > 0;
2783
+ if (isTargetedMode && isCreate && targetAttr === attrName) {
2784
+ const ctAttr = strapi.contentTypes?.[uid]?.attributes?.[targetAttr];
2785
+ const reconstructed = reconstructTargetedFirstLevelObject({
2786
+ targetAttr,
2787
+ exportMode: detectedMode,
2788
+ existingDoc: null,
2789
+ docIdForError: options.docIdForError,
2790
+ rawRow: unescapedRow,
2791
+ rowMeta: rowInfo,
2792
+ isAttrRequired: Boolean(ctAttr?.required)
2793
+ });
2794
+ if (reconstructed.errors.length > 0) {
2795
+ errors2.push(...reconstructed.errors);
2796
+ }
2797
+ if (reconstructed.shouldSet) {
2798
+ if (field.category === "component_single" && field.componentUid && isPlainObject(reconstructed.value)) {
2799
+ payload[attrName] = await resolveComponentPayload(
2800
+ strapi,
2801
+ field.componentUid,
2802
+ reconstructed.value,
2803
+ {}
2804
+ );
2805
+ } else {
2806
+ payload[attrName] = reconstructed.value;
2807
+ }
2808
+ }
2809
+ continue;
2810
+ }
2015
2811
  if (!hasDirectKey && !hasDotKeys) {
2016
2812
  continue;
2017
2813
  }
@@ -2057,12 +2853,43 @@ async function buildDocumentUpdatePayload(strapi, uid, existingDoc, rawRow, opti
2057
2853
  break;
2058
2854
  }
2059
2855
  case "json": {
2060
- if (rawVal === void 0 || rawVal === "" || rawVal === null) {
2061
- payload[attrName] = null;
2062
- } else {
2063
- try {
2064
- payload[attrName] = JSON.parse(rawVal);
2065
- } catch {
2856
+ if (hasDotKeys) {
2857
+ const { hasEffectiveEdits, patch } = buildLegacyNestedPatchFromDots(
2858
+ attrName,
2859
+ dotEntries
2860
+ );
2861
+ if (hasEffectiveEdits) {
2862
+ const mergeDeep = (base, p) => {
2863
+ if (!isPlainObject(base) || !isPlainObject(p)) return p;
2864
+ const next = deepCloneValue(base);
2865
+ for (const [k, v] of Object.entries(p)) {
2866
+ if (isPlainObject(v) && isPlainObject(next[k])) {
2867
+ next[k] = mergeDeep(next[k], v);
2868
+ } else {
2869
+ next[k] = deepCloneValue(v);
2870
+ }
2871
+ }
2872
+ return next;
2873
+ };
2874
+ payload[attrName] = isPlainObject(existingDoc?.[attrName]) ? mergeDeep(existingDoc[attrName], patch) : patch;
2875
+ break;
2876
+ }
2877
+ }
2878
+ if (hasDirectKey) {
2879
+ const trimmed = typeof rawVal === "string" ? rawVal.trim() : "";
2880
+ if (rawVal === void 0 || rawVal === null || rawVal === "") {
2881
+ if (!isPartialUpdate) {
2882
+ payload[attrName] = null;
2883
+ }
2884
+ } else if (EXPLICIT_CLEAR_TOKENS.has(trimmed) || trimmed === "null") {
2885
+ payload[attrName] = null;
2886
+ } else if (typeof rawVal === "string") {
2887
+ try {
2888
+ payload[attrName] = JSON.parse(rawVal);
2889
+ } catch {
2890
+ payload[attrName] = rawVal;
2891
+ }
2892
+ } else {
2066
2893
  payload[attrName] = rawVal;
2067
2894
  }
2068
2895
  }
@@ -2070,19 +2897,42 @@ async function buildDocumentUpdatePayload(strapi, uid, existingDoc, rawRow, opti
2070
2897
  }
2071
2898
  case "component_single": {
2072
2899
  if (field.componentUid) {
2073
- let compInput = rawVal;
2900
+ const directTrimmed = typeof rawVal === "string" ? rawVal.trim() : "";
2074
2901
  if (hasDotKeys) {
2075
- compInput = { ...existingDoc?.[attrName] || {}, ...dotNotationMap[attrName] };
2076
- }
2077
- if (compInput === "" || compInput === null) {
2078
- payload[attrName] = null;
2079
- } else {
2080
- payload[attrName] = await resolveComponentPayload(
2081
- strapi,
2082
- field.componentUid,
2083
- compInput,
2084
- existingDoc?.[attrName] || {}
2902
+ const { hasEffectiveEdits, patch } = buildLegacyNestedPatchFromDots(
2903
+ attrName,
2904
+ dotEntries
2085
2905
  );
2906
+ if (hasEffectiveEdits) {
2907
+ payload[attrName] = await resolveComponentPayload(
2908
+ strapi,
2909
+ field.componentUid,
2910
+ patch,
2911
+ existingDoc?.[attrName] || {}
2912
+ );
2913
+ } else if (hasDirectKey && rawVal !== "" && rawVal !== void 0 && rawVal !== null) {
2914
+ if (EXPLICIT_CLEAR_TOKENS.has(directTrimmed) || directTrimmed === "null") {
2915
+ payload[attrName] = null;
2916
+ } else {
2917
+ payload[attrName] = await resolveComponentPayload(
2918
+ strapi,
2919
+ field.componentUid,
2920
+ rawVal,
2921
+ existingDoc?.[attrName] || {}
2922
+ );
2923
+ }
2924
+ }
2925
+ } else if (hasDirectKey) {
2926
+ if (EXPLICIT_CLEAR_TOKENS.has(directTrimmed) || directTrimmed === "null") {
2927
+ payload[attrName] = null;
2928
+ } else if (rawVal !== "" && rawVal !== null && rawVal !== void 0) {
2929
+ payload[attrName] = await resolveComponentPayload(
2930
+ strapi,
2931
+ field.componentUid,
2932
+ rawVal,
2933
+ existingDoc?.[attrName] || {}
2934
+ );
2935
+ }
2086
2936
  }
2087
2937
  }
2088
2938
  break;
@@ -2150,7 +3000,32 @@ async function buildDocumentUpdatePayload(strapi, uid, existingDoc, rawRow, opti
2150
3000
  payload[attrName] = rawVal;
2151
3001
  }
2152
3002
  }
2153
- return payload;
3003
+ const schemaCheck = validateRecordSchemaConstraints(
3004
+ strapi,
3005
+ uid,
3006
+ existingDoc,
3007
+ payload,
3008
+ unescapedRow,
3009
+ {
3010
+ isCreate,
3011
+ detectedMode,
3012
+ targetObjectField: targetAttr
3013
+ }
3014
+ );
3015
+ errors2.push(...schemaCheck.errors);
3016
+ warnings.push(...schemaCheck.warnings);
3017
+ return {
3018
+ payload,
3019
+ errors: errors2,
3020
+ warnings,
3021
+ detectedMode,
3022
+ targetObjectField: targetAttr,
3023
+ rowMeta: rowInfo
3024
+ };
3025
+ }
3026
+ async function buildDocumentUpdatePayload(strapi, uid, existingDoc, rawRow, options = {}) {
3027
+ const plan = await prepareCsvRowMutation(strapi, uid, existingDoc, rawRow, options);
3028
+ return plan.payload;
2154
3029
  }
2155
3030
  function formatComponentDisplayName(compUid) {
2156
3031
  if (!compUid) return "Component";
@@ -7802,37 +8677,33 @@ function serializeFieldValue(value, field) {
7802
8677
  return typeof value === "object" ? JSON.stringify(value) : String(value);
7803
8678
  }
7804
8679
  }
7805
- function serializeDocumentsToCsv(strapi, uid, documents) {
7806
- const schema = discoverSchema(strapi, uid);
7807
- const headers = [METADATA_COLUMN_KEY, ...schema.allExportKeys];
8680
+ function serializeDocumentsToCsv(strapi, uid, documents, options = {}) {
8681
+ const schema = options.schema || discoverSchema(strapi, uid);
8682
+ const exportMode = normalizeExportMode(options.exportMode);
8683
+ const plan = buildExportColumnPlan(strapi, uid, documents || [], { schema, exportMode });
8684
+ const headers = [METADATA_COLUMN_KEY, ...plan.headers];
7808
8685
  const lines = [];
7809
8686
  lines.push(headers.map(escapeCsvCell).join(","));
7810
- const exportedAt = (/* @__PURE__ */ new Date()).toISOString();
8687
+ const exportedAt = options.exportedAt || (/* @__PURE__ */ new Date()).toISOString();
7811
8688
  for (const doc of documents) {
7812
8689
  const rowValues = [];
8690
+ const flattenedMeta = extractRowFlattenedMetadata(plan, doc);
7813
8691
  const metadata = {
7814
8692
  schemaVersion: CURRENT_SCHEMA_VERSION,
7815
8693
  contentType: uid,
7816
8694
  documentId: String(doc.documentId || doc.id || ""),
7817
8695
  locale: doc.locale || void 0,
7818
- exportedAt
8696
+ exportedAt,
8697
+ ...flattenedMeta.exportMode ? { exportMode: flattenedMeta.exportMode } : {},
8698
+ ...flattenedMeta.targetObjectField ? { targetObjectField: flattenedMeta.targetObjectField } : {},
8699
+ ...flattenedMeta.targetObjectState ? { targetObjectState: flattenedMeta.targetObjectState } : {},
8700
+ ...flattenedMeta.applicableFields ? { applicableFields: flattenedMeta.applicableFields } : {},
8701
+ ...flattenedMeta.flatTypes ? { flatTypes: flattenedMeta.flatTypes } : {}
7819
8702
  };
7820
8703
  rowValues.push(escapeCsvCell(metadata));
7821
- for (const key of schema.allExportKeys) {
7822
- if (key === "documentId") {
7823
- rowValues.push(escapeCsvCell(doc.documentId || doc.id || ""));
7824
- } else if (key === "locale") {
7825
- rowValues.push(escapeCsvCell(doc.locale || ""));
7826
- } else {
7827
- const field = schema.fields[key];
7828
- const rawValue = doc[key];
7829
- if (field) {
7830
- const serialized = serializeFieldValue(rawValue, field);
7831
- rowValues.push(escapeCsvCell(serialized));
7832
- } else {
7833
- rowValues.push(escapeCsvCell(rawValue));
7834
- }
7835
- }
8704
+ for (const col of plan.columns) {
8705
+ const cellValue = serializePlannedCell(col, doc, serializeFieldValue);
8706
+ rowValues.push(escapeCsvCell(cellValue));
7836
8707
  }
7837
8708
  lines.push(rowValues.join(","));
7838
8709
  }
@@ -8541,13 +9412,44 @@ function formatValueDisplay(val) {
8541
9412
  }
8542
9413
  async function executeUpdateMutation(strapi, ct, uid, existing, row, rowNumber, options, effectiveLocale, isEditing, isDraftAndPublish, publishedCounterparts, stats, actionLabel = "Updated") {
8543
9414
  const resolvedDocId = existing.documentId;
8544
- const updatePayload = await buildDocumentUpdatePayload(
9415
+ const mutationPlan = await prepareCsvRowMutation(
8545
9416
  strapi,
8546
9417
  uid,
8547
9418
  existing,
8548
9419
  row,
8549
- { isPartialUpdate: options.mode === "update" }
9420
+ {
9421
+ isPartialUpdate: options.mode === "update",
9422
+ isCreate: false,
9423
+ expectedExportMode: options.expectedExportMode,
9424
+ docIdForError: resolvedDocId
9425
+ }
8550
9426
  );
9427
+ const updatePayload = mutationPlan.payload;
9428
+ if (mutationPlan.errors.length > 0) {
9429
+ const errMsg = mutationPlan.errors[0];
9430
+ stats.skipped++;
9431
+ if (stats.failed !== void 0) stats.failed++;
9432
+ recordFailedCsvRow(
9433
+ stats,
9434
+ rowNumber,
9435
+ row,
9436
+ errMsg,
9437
+ resolvedDocId,
9438
+ options.originalHeaders
9439
+ );
9440
+ stats.diffs.push({
9441
+ uid,
9442
+ collectionName: ct.info?.displayName || uid,
9443
+ documentId: resolvedDocId,
9444
+ label: existing.title || existing.name || `Entry #${resolvedDocId}`,
9445
+ attribute: mutationPlan.targetObjectField || "",
9446
+ oldValue: null,
9447
+ newValue: null,
9448
+ status: "error",
9449
+ message: errMsg
9450
+ });
9451
+ return;
9452
+ }
8551
9453
  if (Object.keys(updatePayload).length === 0) {
8552
9454
  stats.skipped++;
8553
9455
  stats.diffs.push({
@@ -8681,13 +9583,44 @@ async function executeUpdateMutation(strapi, ct, uid, existing, row, rowNumber,
8681
9583
  }
8682
9584
  }
8683
9585
  async function executeCreateMutation(strapi, ct, uid, docId, row, rowNumber, options, effectiveLocale, isEditing, isDraftAndPublish, stats) {
8684
- const createPayload = await buildDocumentUpdatePayload(
9586
+ const mutationPlan = await prepareCsvRowMutation(
8685
9587
  strapi,
8686
9588
  uid,
8687
9589
  null,
8688
9590
  row,
8689
- {}
9591
+ {
9592
+ isPartialUpdate: false,
9593
+ isCreate: true,
9594
+ expectedExportMode: options.expectedExportMode,
9595
+ docIdForError: docId || `row-${rowNumber}`
9596
+ }
8690
9597
  );
9598
+ const createPayload = mutationPlan.payload;
9599
+ if (mutationPlan.errors.length > 0) {
9600
+ const errMsg = mutationPlan.errors[0];
9601
+ stats.skipped++;
9602
+ if (stats.failed !== void 0) stats.failed++;
9603
+ recordFailedCsvRow(
9604
+ stats,
9605
+ rowNumber,
9606
+ row,
9607
+ errMsg,
9608
+ docId || "new",
9609
+ options.originalHeaders
9610
+ );
9611
+ stats.diffs.push({
9612
+ uid,
9613
+ collectionName: ct.info?.displayName || uid,
9614
+ documentId: docId || "new",
9615
+ label: `Row ${rowNumber}`,
9616
+ attribute: "",
9617
+ oldValue: null,
9618
+ newValue: null,
9619
+ status: "error",
9620
+ message: errMsg
9621
+ });
9622
+ return;
9623
+ }
8691
9624
  const valResultNew = await validateEntityQuotas(strapi, uid, createPayload);
8692
9625
  if (!valResultNew.isValid) {
8693
9626
  stats.skipped++;
@@ -8790,6 +9723,40 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
8790
9723
  failedRows: [],
8791
9724
  diffs: []
8792
9725
  };
9726
+ const batchModeInfo = detectCsvBatchExportMode(rows);
9727
+ if (batchModeInfo.error) {
9728
+ for (let i = 0; i < rows.length; i++) {
9729
+ const rowNumber = startRowNumber + i;
9730
+ const row = rows[i];
9731
+ const docId = extractDocId(row);
9732
+ stats.skipped++;
9733
+ if (stats.failed !== void 0) stats.failed++;
9734
+ recordFailedCsvRow(
9735
+ stats,
9736
+ rowNumber,
9737
+ row,
9738
+ batchModeInfo.error,
9739
+ docId || void 0,
9740
+ originalHeaders
9741
+ );
9742
+ stats.diffs.push({
9743
+ uid,
9744
+ collectionName: ct.info?.displayName || uid,
9745
+ documentId: docId || `(Row #${rowNumber})`,
9746
+ label: `Row #${rowNumber}`,
9747
+ attribute: "__bulk_updater_metadata",
9748
+ oldValue: null,
9749
+ newValue: null,
9750
+ status: "error",
9751
+ message: batchModeInfo.error
9752
+ });
9753
+ }
9754
+ return stats;
9755
+ }
9756
+ const rowOptions = {
9757
+ ...options,
9758
+ expectedExportMode: batchModeInfo.mode
9759
+ };
8793
9760
  for (let i = 0; i < rows.length; i++) {
8794
9761
  const rowNumber = startRowNumber + i;
8795
9762
  const row = rows[i];
@@ -8842,7 +9809,7 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
8842
9809
  existing,
8843
9810
  row,
8844
9811
  rowNumber,
8845
- options,
9812
+ rowOptions,
8846
9813
  effectiveLocale,
8847
9814
  isEditing,
8848
9815
  isDraftAndPublish,
@@ -8863,7 +9830,7 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
8863
9830
  existing,
8864
9831
  row,
8865
9832
  rowNumber,
8866
- options,
9833
+ rowOptions,
8867
9834
  effectiveLocale,
8868
9835
  isEditing,
8869
9836
  isDraftAndPublish,
@@ -8879,7 +9846,7 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
8879
9846
  docId,
8880
9847
  row,
8881
9848
  rowNumber,
8882
- options,
9849
+ rowOptions,
8883
9850
  effectiveLocale,
8884
9851
  isEditing,
8885
9852
  isDraftAndPublish,
@@ -8899,7 +9866,7 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
8899
9866
  existing,
8900
9867
  row,
8901
9868
  rowNumber,
8902
- options,
9869
+ rowOptions,
8903
9870
  effectiveLocale,
8904
9871
  isEditing,
8905
9872
  isDraftAndPublish,
@@ -8915,7 +9882,7 @@ async function processCsvRows(strapi, ct, uid, rows, startRowNumber, options) {
8915
9882
  docId,
8916
9883
  row,
8917
9884
  rowNumber,
8918
- options,
9885
+ rowOptions,
8919
9886
  effectiveLocale,
8920
9887
  isEditing,
8921
9888
  isDraftAndPublish,
@@ -9096,9 +10063,7 @@ const csvService = ({ strapi }) => ({
9096
10063
  }
9097
10064
  const schema = discoverSchema(strapi, uid);
9098
10065
  const deepPopulate = buildLosslessPopulate(strapi, uid);
9099
- const headers = [METADATA_COLUMN_KEY, ...schema.allExportKeys];
9100
- const lines = [];
9101
- lines.push(headers.map(escapeCsvCell).join(","));
10066
+ const exportMode = normalizeExportMode(options.exportMode);
9102
10067
  const filterMeta = buildCollectionQueryFilters(strapi, ct, {
9103
10068
  attribute: options.attribute,
9104
10069
  searchAttribute: options.searchAttribute || options.attribute,
@@ -9108,11 +10073,13 @@ const csvService = ({ strapi }) => ({
9108
10073
  documentIds: options.documentIds
9109
10074
  });
9110
10075
  if (!filterMeta.colHasAttribute && filterMeta.normOp && filterMeta.normOp !== "none") {
10076
+ const emptySerialized = serializeDocumentsToCsv(strapi, uid, [], { schema, exportMode });
9111
10077
  return {
9112
10078
  filename: `${ct.info?.singularName || uid}_export_${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.csv`,
9113
- csvContent: "\uFEFF" + lines.join("\r\n") + "\r\n",
10079
+ csvContent: emptySerialized.csvContent,
9114
10080
  count: 0,
9115
- fields: headers
10081
+ fields: emptySerialized.headers,
10082
+ exportMode
9116
10083
  };
9117
10084
  }
9118
10085
  const filters = filterMeta.filters;
@@ -9167,7 +10134,7 @@ const csvService = ({ strapi }) => ({
9167
10134
  };
9168
10135
  return matches.some((m) => testSingleValue(m.value));
9169
10136
  };
9170
- let totalExported = 0;
10137
+ const exportedDocs = [];
9171
10138
  const maxLimit = options.limit && options.limit > 0 ? options.limit : Infinity;
9172
10139
  const BATCH_SIZE = 200;
9173
10140
  const exportedAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -9180,35 +10147,14 @@ const csvService = ({ strapi }) => ({
9180
10147
  }
9181
10148
  const doc = await strapi.documents(uid).findFirst(findFirstArgs);
9182
10149
  if (doc && passesDzFilter(doc)) {
9183
- const rowValues = [];
9184
- const metadata = {
9185
- schemaVersion: CURRENT_SCHEMA_VERSION,
9186
- contentType: uid,
9187
- documentId: String(doc.documentId || doc.id || ""),
9188
- locale: doc.locale || void 0,
9189
- exportedAt
9190
- };
9191
- rowValues.push(escapeCsvCell(metadata));
9192
- for (const key of schema.allExportKeys) {
9193
- if (key === "documentId") {
9194
- rowValues.push(escapeCsvCell(doc.documentId || doc.id || ""));
9195
- } else if (key === "locale") {
9196
- rowValues.push(escapeCsvCell(doc.locale || ""));
9197
- } else {
9198
- const field = schema.fields[key];
9199
- const rawVal = doc[key];
9200
- rowValues.push(escapeCsvCell(field ? serializeFieldValue(rawVal, field) : rawVal));
9201
- }
9202
- }
9203
- lines.push(rowValues.join(","));
9204
- totalExported = 1;
10150
+ exportedDocs.push(doc);
9205
10151
  }
9206
10152
  } else {
9207
10153
  let currentPage = 1;
9208
10154
  let hasMore = true;
9209
10155
  const sortClause = ct.attributes?.createdAt ? { createdAt: "desc" } : ct.attributes?.id ? { id: "desc" } : void 0;
9210
- while (hasMore && totalExported < maxLimit) {
9211
- const remaining = maxLimit - totalExported;
10156
+ while (hasMore && exportedDocs.length < maxLimit) {
10157
+ const remaining = maxLimit - exportedDocs.length;
9212
10158
  const currentBatchLimit = Math.min(BATCH_SIZE, remaining);
9213
10159
  const findPageArgs = {
9214
10160
  filters: Object.keys(filters).length > 0 ? filters : void 0,
@@ -9230,29 +10176,8 @@ const csvService = ({ strapi }) => ({
9230
10176
  if (!passesDzFilter(entry)) {
9231
10177
  continue;
9232
10178
  }
9233
- const rowValues = [];
9234
- const metadata = {
9235
- schemaVersion: CURRENT_SCHEMA_VERSION,
9236
- contentType: uid,
9237
- documentId: String(entry.documentId || entry.id || ""),
9238
- locale: entry.locale || void 0,
9239
- exportedAt
9240
- };
9241
- rowValues.push(escapeCsvCell(metadata));
9242
- for (const key of schema.allExportKeys) {
9243
- if (key === "documentId") {
9244
- rowValues.push(escapeCsvCell(entry.documentId || entry.id || ""));
9245
- } else if (key === "locale") {
9246
- rowValues.push(escapeCsvCell(entry.locale || ""));
9247
- } else {
9248
- const field = schema.fields[key];
9249
- const rawVal = entry[key];
9250
- rowValues.push(escapeCsvCell(field ? serializeFieldValue(rawVal, field) : rawVal));
9251
- }
9252
- }
9253
- lines.push(rowValues.join(","));
9254
- totalExported++;
9255
- if (totalExported >= maxLimit) {
10179
+ exportedDocs.push(entry);
10180
+ if (exportedDocs.length >= maxLimit) {
9256
10181
  hasMore = false;
9257
10182
  break;
9258
10183
  }
@@ -9265,13 +10190,18 @@ const csvService = ({ strapi }) => ({
9265
10190
  await new Promise((resolve) => setImmediate(resolve));
9266
10191
  }
9267
10192
  }
9268
- const csvContent = "\uFEFF" + lines.join("\r\n") + "\r\n";
10193
+ const serialized = serializeDocumentsToCsv(strapi, uid, exportedDocs, {
10194
+ exportedAt,
10195
+ schema,
10196
+ exportMode
10197
+ });
9269
10198
  const filename = `${ct.info?.singularName || uid}_export_${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.csv`;
9270
10199
  return {
9271
10200
  filename,
9272
- csvContent,
9273
- count: totalExported,
9274
- fields: headers
10201
+ csvContent: serialized.csvContent,
10202
+ count: serialized.count,
10203
+ fields: serialized.headers,
10204
+ exportMode
9275
10205
  };
9276
10206
  },
9277
10207
  async exportViolationsCsv(ruleId) {
@@ -9646,6 +10576,28 @@ const csvService = ({ strapi }) => ({
9646
10576
  };
9647
10577
  const errors2 = [];
9648
10578
  const warnings = [];
10579
+ const batchModeInfo = detectCsvBatchExportMode(rows);
10580
+ if (batchModeInfo.error) {
10581
+ errors2.push({
10582
+ row: 1,
10583
+ error: batchModeInfo.error
10584
+ });
10585
+ return {
10586
+ success: true,
10587
+ detectedExportMode: "invalid",
10588
+ totalRows: rows.length,
10589
+ validRows: 0,
10590
+ estimatedUpdates: 0,
10591
+ estimatedCreates: 0,
10592
+ lifecycleStats,
10593
+ hasErrors: true,
10594
+ hasWarnings: false,
10595
+ errors: errors2,
10596
+ warnings: [],
10597
+ totalErrorCount: errors2.length,
10598
+ totalWarningCount: 0
10599
+ };
10600
+ }
9649
10601
  const docIdsInPreflight = rows.map((r) => extractDocId(r)).filter(Boolean);
9650
10602
  const publishedCounterparts = /* @__PURE__ */ new Map();
9651
10603
  if (isDraftAndPublish && docIdsInPreflight.length > 0) {
@@ -9808,18 +10760,48 @@ const csvService = ({ strapi }) => ({
9808
10760
  }
9809
10761
  }
9810
10762
  }
9811
- if (activeRules.length > 0) {
9812
- let proposedPayload = {};
10763
+ const isRowCreate = mode === "create_or_override" ? !existing : !existing && mode !== "update";
10764
+ let proposedPayload = {};
10765
+ if (!(mode === "update" && (!docId || !existing))) {
9813
10766
  try {
9814
- proposedPayload = await buildDocumentUpdatePayload(
10767
+ const mutationPlan = await prepareCsvRowMutation(
9815
10768
  strapi,
9816
10769
  uid,
9817
10770
  existing,
9818
10771
  row,
9819
- { isPartialUpdate: mode === "update" }
10772
+ {
10773
+ isPartialUpdate: mode === "update",
10774
+ isCreate: isRowCreate,
10775
+ expectedExportMode: batchModeInfo.mode,
10776
+ docIdForError: docId || `row-${rowNumber}`
10777
+ }
9820
10778
  );
9821
- } catch {
10779
+ proposedPayload = mutationPlan.payload;
10780
+ for (const errStr of mutationPlan.errors) {
10781
+ errors2.push({
10782
+ row: rowNumber,
10783
+ documentId: docId || void 0,
10784
+ error: errStr
10785
+ });
10786
+ rowHasError = true;
10787
+ }
10788
+ for (const warnStr of mutationPlan.warnings) {
10789
+ warnings.push({
10790
+ row: rowNumber,
10791
+ documentId: docId || void 0,
10792
+ warning: warnStr
10793
+ });
10794
+ }
10795
+ } catch (prepErr) {
10796
+ errors2.push({
10797
+ row: rowNumber,
10798
+ documentId: docId || void 0,
10799
+ error: prepErr?.message || "Failed to reconstruct CSV payload."
10800
+ });
10801
+ rowHasError = true;
9822
10802
  }
10803
+ }
10804
+ if (activeRules.length > 0) {
9823
10805
  const proposedEntity = existing ? deepMergeEntities(existing, proposedPayload) : proposedPayload;
9824
10806
  const valResult = await validateEntityQuotas(strapi, uid, proposedEntity, activeRules);
9825
10807
  if (!valResult.isValid) {
@@ -9837,6 +10819,7 @@ const csvService = ({ strapi }) => ({
9837
10819
  }
9838
10820
  return {
9839
10821
  success: true,
10822
+ detectedExportMode: batchModeInfo.mode,
9840
10823
  totalRows: rows.length,
9841
10824
  validRows,
9842
10825
  estimatedUpdates,
@@ -9861,6 +10844,37 @@ const csvService = ({ strapi }) => ({
9861
10844
  }
9862
10845
  const attrs = ct.attributes || {};
9863
10846
  const { mode = "auto" } = options;
10847
+ const batchModeInfo = detectCsvBatchExportMode(rows);
10848
+ if (batchModeInfo.error) {
10849
+ return {
10850
+ success: true,
10851
+ detectedExportMode: "invalid",
10852
+ summary: {
10853
+ total: rows.length,
10854
+ willUpdate: 0,
10855
+ willCreate: 0,
10856
+ unchanged: 0,
10857
+ skipped: rows.length
10858
+ },
10859
+ diffs: [
10860
+ {
10861
+ uid,
10862
+ collectionName: ct.info?.displayName || uid,
10863
+ documentId: "(batch)",
10864
+ label: "CSV Export Mode Check",
10865
+ attribute: "__bulk_updater_metadata",
10866
+ oldValue: null,
10867
+ newValue: null,
10868
+ oldDisplay: "—",
10869
+ newDisplay: "—",
10870
+ hasChange: false,
10871
+ status: "error",
10872
+ action: "skip",
10873
+ message: batchModeInfo.error
10874
+ }
10875
+ ]
10876
+ };
10877
+ }
9864
10878
  const diffs = [];
9865
10879
  let willUpdateCount = 0;
9866
10880
  let willCreateCount = 0;
@@ -9906,13 +10920,39 @@ const csvService = ({ strapi }) => ({
9906
10920
  });
9907
10921
  continue;
9908
10922
  }
9909
- const payload = await buildDocumentUpdatePayload(
10923
+ const isRowCreate = !existing;
10924
+ const mutationPlan = await prepareCsvRowMutation(
9910
10925
  strapi,
9911
10926
  uid,
9912
10927
  existing,
9913
10928
  row,
9914
- {}
10929
+ {
10930
+ isPartialUpdate: mode === "update",
10931
+ isCreate: isRowCreate,
10932
+ expectedExportMode: batchModeInfo.mode,
10933
+ docIdForError: docId || `row-${rowNumber}`
10934
+ }
9915
10935
  );
10936
+ if (mutationPlan.errors.length > 0) {
10937
+ skippedCount++;
10938
+ diffs.push({
10939
+ uid,
10940
+ collectionName: ct.info?.displayName || uid,
10941
+ documentId: existing?.documentId || docId || `(Row #${rowNumber})`,
10942
+ label: existing?.title || existing?.name || existing?.slug || `Row #${rowNumber}`,
10943
+ attribute: mutationPlan.targetObjectField || "(validation)",
10944
+ oldValue: null,
10945
+ newValue: null,
10946
+ oldDisplay: "—",
10947
+ newDisplay: "—",
10948
+ hasChange: false,
10949
+ status: "error",
10950
+ action: "skip",
10951
+ message: mutationPlan.errors.join(" | ")
10952
+ });
10953
+ continue;
10954
+ }
10955
+ const payload = mutationPlan.payload;
9916
10956
  if (existing) {
9917
10957
  const resolvedDocId = existing.documentId || docId;
9918
10958
  const entryLabel = existing.title || existing.name || existing.slug || `Entry #${resolvedDocId}`;
@@ -9944,7 +10984,7 @@ const csvService = ({ strapi }) => ({
9944
10984
  }
9945
10985
  const oldDisplay = formatValueDisplay(oldVal);
9946
10986
  const newDisplay = formatValueDisplay(newVal);
9947
- const hasChange = String(oldVal ?? "") !== String(newVal ?? "");
10987
+ const hasChange = typeof oldVal === "object" && oldVal !== null || typeof newVal === "object" && newVal !== null ? oldDisplay !== newDisplay : String(oldVal ?? "") !== String(newVal ?? "");
9948
10988
  if (hasChange) {
9949
10989
  rowHasChanges = true;
9950
10990
  }
@@ -10015,6 +11055,7 @@ const csvService = ({ strapi }) => ({
10015
11055
  }
10016
11056
  return {
10017
11057
  success: true,
11058
+ detectedExportMode: batchModeInfo.mode,
10018
11059
  summary: {
10019
11060
  total: rows.length,
10020
11061
  willUpdate: willUpdateCount,
@@ -10492,42 +11533,60 @@ const index = {
10492
11533
  };
10493
11534
  export {
10494
11535
  CURRENT_SCHEMA_VERSION,
11536
+ EXPLICIT_CLEAR_TOKENS,
11537
+ EXPLICIT_DELETE_KEY_TOKEN,
11538
+ EXPLICIT_EMPTY_STRING_TOKEN,
11539
+ FORBIDDEN_OBJECT_KEYS,
10495
11540
  METADATA_COLUMN_KEY,
10496
11541
  SYSTEM_ATTRIBUTES,
10497
11542
  applyOccurrenceUpdatesToDocument,
10498
11543
  buildCollectionQueryFilters,
10499
11544
  buildDocumentUpdatePayload,
10500
11545
  buildErrorCsv,
11546
+ buildExportColumnPlan,
10501
11547
  buildLosslessPopulate,
10502
11548
  buildRichAttributeMeta,
10503
11549
  classifyAttribute,
10504
11550
  coerceAndValidateFieldValue,
11551
+ deepCloneValue,
11552
+ deepEqualValues,
10505
11553
  deepMergeEntities,
10506
11554
  index as default,
11555
+ detectCsvBatchExportMode,
10507
11556
  discoverComponentFields,
10508
11557
  discoverSchema,
10509
11558
  enumerateOccurrences,
10510
11559
  escapeCsvCell,
10511
11560
  extractHeadingsFromRichText,
10512
11561
  extractMetadataFromRow,
11562
+ extractRowFlattenedMetadata,
10513
11563
  formatErrorCsvFilename,
10514
11564
  getAllNestedValues,
11565
+ inspectRowMetadataMode,
11566
+ isPlainObject,
10515
11567
  isValidDocumentId,
11568
+ normalizeExportMode,
10516
11569
  parseBoolean,
10517
11570
  parseCsvToMatrix,
10518
11571
  parseCsvToRecords,
11572
+ parseFirstLevelCellValue,
10519
11573
  parseNumeric,
11574
+ prepareCsvRowMutation,
11575
+ reconstructTargetedFirstLevelObject,
10520
11576
  resolveBatchTargets,
10521
11577
  resolveComponentPayload,
10522
11578
  resolveDynamicZonePayload,
10523
11579
  resolveErrorColumnName,
10524
11580
  resolveMediaIds,
10525
11581
  resolveRelationPayload,
11582
+ resolveTargetObjectField,
10526
11583
  sanitizeUserErrorMessage,
10527
11584
  serializeDocumentsToCsv,
10528
11585
  serializeFieldValue,
11586
+ serializePlannedCell,
10529
11587
  sortAuditRecordsDesc,
10530
11588
  validateEntityQuotas,
11589
+ validateRecordSchemaConstraints,
10531
11590
  verifyDocumentIntegrity,
10532
11591
  withRollbackLock
10533
11592
  };