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