@payloadcms/plugin-import-export 3.77.0-internal.9837b1e → 3.77.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/components/CollectionField/index.d.ts +2 -2
  2. package/dist/components/CollectionField/index.d.ts.map +1 -1
  3. package/dist/components/CollectionField/index.js +5 -28
  4. package/dist/components/CollectionField/index.js.map +1 -1
  5. package/dist/components/CollectionSelectField/index.d.ts +13 -0
  6. package/dist/components/CollectionSelectField/index.d.ts.map +1 -0
  7. package/dist/components/CollectionSelectField/index.js +159 -0
  8. package/dist/components/CollectionSelectField/index.js.map +1 -0
  9. package/dist/components/ExportListMenuItem/index.d.ts.map +1 -1
  10. package/dist/components/ExportListMenuItem/index.js +5 -1
  11. package/dist/components/ExportListMenuItem/index.js.map +1 -1
  12. package/dist/components/ExportPreview/index.d.ts.map +1 -1
  13. package/dist/components/ExportPreview/index.js.map +1 -1
  14. package/dist/components/FieldsToExport/index.js +1 -1
  15. package/dist/components/FieldsToExport/index.js.map +1 -1
  16. package/dist/components/ImportPreview/index.d.ts.map +1 -1
  17. package/dist/components/ImportPreview/index.js +50 -30
  18. package/dist/components/ImportPreview/index.js.map +1 -1
  19. package/dist/export/createExport.d.ts +1 -2
  20. package/dist/export/createExport.d.ts.map +1 -1
  21. package/dist/export/createExport.js +2 -1
  22. package/dist/export/createExport.js.map +1 -1
  23. package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
  24. package/dist/export/getCreateExportCollectionTask.js +12 -1
  25. package/dist/export/getCreateExportCollectionTask.js.map +1 -1
  26. package/dist/export/getExportCollection.d.ts +5 -1
  27. package/dist/export/getExportCollection.d.ts.map +1 -1
  28. package/dist/export/getExportCollection.js +20 -5
  29. package/dist/export/getExportCollection.js.map +1 -1
  30. package/dist/export/getFields.d.ts +7 -1
  31. package/dist/export/getFields.d.ts.map +1 -1
  32. package/dist/export/getFields.js +15 -3
  33. package/dist/export/getFields.js.map +1 -1
  34. package/dist/exports/rsc.d.ts +0 -1
  35. package/dist/exports/rsc.d.ts.map +1 -1
  36. package/dist/exports/rsc.js +0 -1
  37. package/dist/exports/rsc.js.map +1 -1
  38. package/dist/import/batchProcessor.d.ts.map +1 -1
  39. package/dist/import/batchProcessor.js +9 -3
  40. package/dist/import/batchProcessor.js.map +1 -1
  41. package/dist/import/getFields.d.ts +7 -3
  42. package/dist/import/getFields.d.ts.map +1 -1
  43. package/dist/import/getFields.js +12 -7
  44. package/dist/import/getFields.js.map +1 -1
  45. package/dist/import/getImportCollection.d.ts +6 -3
  46. package/dist/import/getImportCollection.d.ts.map +1 -1
  47. package/dist/import/getImportCollection.js +7 -4
  48. package/dist/import/getImportCollection.js.map +1 -1
  49. package/dist/index.d.ts +5 -0
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +2 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/utilities/collectTimezoneCompanionFields.d.ts +24 -0
  54. package/dist/utilities/collectTimezoneCompanionFields.d.ts.map +1 -0
  55. package/dist/utilities/collectTimezoneCompanionFields.js +89 -0
  56. package/dist/utilities/collectTimezoneCompanionFields.js.map +1 -0
  57. package/dist/utilities/collectTimezoneCompanionFields.spec.js +319 -0
  58. package/dist/utilities/collectTimezoneCompanionFields.spec.js.map +1 -0
  59. package/dist/utilities/getFilename.d.ts +1 -1
  60. package/dist/utilities/getFilename.js +3 -3
  61. package/dist/utilities/getFilename.js.map +1 -1
  62. package/dist/utilities/getPluginCollections.d.ts.map +1 -1
  63. package/dist/utilities/getPluginCollections.js +106 -34
  64. package/dist/utilities/getPluginCollections.js.map +1 -1
  65. package/dist/utilities/getSchemaColumns.d.ts.map +1 -1
  66. package/dist/utilities/getSchemaColumns.js +9 -56
  67. package/dist/utilities/getSchemaColumns.js.map +1 -1
  68. package/dist/utilities/getSchemaColumns.spec.js +157 -0
  69. package/dist/utilities/getSchemaColumns.spec.js.map +1 -0
  70. package/dist/utilities/parseCSV.d.ts.map +1 -1
  71. package/dist/utilities/parseCSV.js +1 -0
  72. package/dist/utilities/parseCSV.js.map +1 -1
  73. package/dist/utilities/parseCSV.spec.js +26 -0
  74. package/dist/utilities/parseCSV.spec.js.map +1 -1
  75. package/package.json +7 -7
@@ -13,12 +13,27 @@ import { getImportCollection } from '../import/getImportCollection.js';
13
13
  * @param pluginConfig - The import/export plugin config
14
14
  * @returns Object containing arrays of export and import collections
15
15
  */ export const getPluginCollections = async ({ config, pluginConfig })=>{
16
+ // Calculate collection slugs for base export/import collections
17
+ // If pluginConfig.collections is provided, filter by export/import !== false
18
+ // Otherwise, use all config collections
19
+ let baseExportSlugs;
20
+ let baseImportSlugs;
21
+ if (pluginConfig.collections && pluginConfig.collections.length > 0) {
22
+ baseExportSlugs = pluginConfig.collections.filter((c)=>c.export !== false).map((c)=>c.slug);
23
+ baseImportSlugs = pluginConfig.collections.filter((c)=>c.import !== false).map((c)=>c.slug);
24
+ } else {
25
+ // Fall back to all collections
26
+ const allSlugs = config.collections?.map((c)=>c.slug) || [];
27
+ baseExportSlugs = allSlugs;
28
+ baseImportSlugs = allSlugs;
29
+ }
16
30
  let baseExportCollection = getExportCollection({
31
+ collectionSlugs: baseExportSlugs,
17
32
  config,
18
33
  pluginConfig
19
34
  });
20
35
  let baseImportCollection = getImportCollection({
21
- config,
36
+ collectionSlugs: baseImportSlugs,
22
37
  pluginConfig
23
38
  });
24
39
  if (pluginConfig.overrideExportCollection && typeof pluginConfig.overrideExportCollection === 'function') {
@@ -40,58 +55,84 @@ import { getImportCollection } from '../import/getImportCollection.js';
40
55
  for (const collectionConfig of pluginConfig.collections){
41
56
  const exportConfig = typeof collectionConfig.export === 'object' ? collectionConfig.export : undefined;
42
57
  if (exportConfig?.overrideCollection) {
43
- // Generate a collection with this export config's settings (like disableJobsQueue)
44
- const collectionWithSettings = getExportCollection({
58
+ // Create collection specific to this target collection
59
+ const collection = getExportCollection({
60
+ collectionSlugs: [
61
+ collectionConfig.slug
62
+ ],
45
63
  config,
46
64
  exportConfig,
47
65
  pluginConfig
48
66
  });
49
- const customExport = await exportConfig.overrideCollection({
50
- collection: collectionWithSettings
67
+ // Call override once to determine user intent
68
+ const overridden = await exportConfig.overrideCollection({
69
+ collection
51
70
  });
52
71
  // If the slug changed, this is a separate collection; otherwise it modifies the base
53
- if (customExport.slug !== baseExportCollection.slug) {
54
- // Store the source collection slug so CollectionField can use it as default
55
- customExport.admin = {
56
- ...customExport.admin,
57
- custom: {
58
- ...customExport.admin?.custom,
59
- defaultCollectionSlug: collectionConfig.slug
72
+ if (overridden.slug !== baseExportCollection.slug) {
73
+ exportCollections.push(overridden);
74
+ customExportSlugMap.set(collectionConfig.slug, overridden.slug);
75
+ } else {
76
+ // Slug didn't change - merge settings into base collection while preserving all slugs
77
+ baseExportCollection = {
78
+ ...baseExportCollection,
79
+ ...overridden,
80
+ admin: {
81
+ ...baseExportCollection.admin,
82
+ ...overridden.admin,
83
+ custom: {
84
+ ...baseExportCollection.admin?.custom,
85
+ ...overridden.admin?.custom,
86
+ 'plugin-import-export': {
87
+ ...overridden.admin?.custom?.['plugin-import-export'],
88
+ ...baseExportCollection.admin?.custom?.['plugin-import-export'],
89
+ // Ensure base collection's slug list is preserved
90
+ collectionSlugs: baseExportCollection.admin?.custom?.['plugin-import-export']?.collectionSlugs
91
+ }
92
+ }
60
93
  }
61
94
  };
62
- exportCollections.push(customExport);
63
- customExportSlugMap.set(collectionConfig.slug, customExport.slug);
64
- } else {
65
- baseExportCollection = customExport;
66
95
  }
67
96
  }
68
97
  const importConf = typeof collectionConfig.import === 'object' ? collectionConfig.import : undefined;
69
98
  if (importConf?.overrideCollection) {
70
- // Generate a collection with this import config's settings (like disableJobsQueue)
71
- const collectionWithSettings = getImportCollection({
72
- config,
99
+ // Create collection specific to this target collection
100
+ const collection = getImportCollection({
101
+ collectionSlugs: [
102
+ collectionConfig.slug
103
+ ],
73
104
  importConfig: importConf,
74
105
  pluginConfig
75
106
  });
76
- const customImport = await importConf.overrideCollection({
77
- collection: collectionWithSettings
107
+ // Call override once to determine user intent
108
+ const overridden = await importConf.overrideCollection({
109
+ collection
78
110
  });
79
111
  // If the slug changed, this is a separate collection; otherwise it modifies the base
80
- if (customImport.slug !== baseImportCollection.slug) {
81
- // Store the source collection slug so CollectionField can use it as default
82
- customImport.admin = {
83
- ...customImport.admin,
84
- custom: {
85
- ...customImport.admin?.custom,
86
- defaultCollectionSlug: collectionConfig.slug
87
- }
88
- };
89
- importCollections.push(customImport);
112
+ if (overridden.slug !== baseImportCollection.slug) {
113
+ importCollections.push(overridden);
90
114
  // Map this target collection to its custom import collection
91
- customImportSlugMap.set(collectionConfig.slug, customImport.slug);
115
+ customImportSlugMap.set(collectionConfig.slug, overridden.slug);
92
116
  } else {
93
- // Full override - replace the base
94
- baseImportCollection = customImport;
117
+ // Slug didn't change - merge settings into base collection while preserving all slugs
118
+ baseImportCollection = {
119
+ ...baseImportCollection,
120
+ ...overridden,
121
+ admin: {
122
+ ...baseImportCollection.admin,
123
+ ...overridden.admin,
124
+ custom: {
125
+ ...baseImportCollection.admin?.custom,
126
+ ...overridden.admin?.custom,
127
+ 'plugin-import-export': {
128
+ ...overridden.admin?.custom?.['plugin-import-export'],
129
+ ...baseImportCollection.admin?.custom?.['plugin-import-export'],
130
+ // Ensure base collection's slug list is preserved
131
+ collectionSlugs: baseImportCollection.admin?.custom?.['plugin-import-export']?.collectionSlugs
132
+ }
133
+ }
134
+ }
135
+ };
95
136
  }
96
137
  }
97
138
  }
@@ -138,6 +179,37 @@ import { getImportCollection } from '../import/getImportCollection.js';
138
179
  };
139
180
  }
140
181
  }
182
+ // Filter out slugs that have custom export/import collections from the base collections
183
+ // Collections with custom collections should ONLY be exportable/importable through those
184
+ const filteredExportSlugs = baseExportSlugs.filter((slug)=>!customExportSlugMap.has(slug));
185
+ const filteredImportSlugs = baseImportSlugs.filter((slug)=>!customImportSlugMap.has(slug));
186
+ // Update base collections with filtered slugs
187
+ baseExportCollection = {
188
+ ...baseExportCollection,
189
+ admin: {
190
+ ...baseExportCollection.admin,
191
+ custom: {
192
+ ...baseExportCollection.admin?.custom,
193
+ 'plugin-import-export': {
194
+ ...baseExportCollection.admin?.custom?.['plugin-import-export'],
195
+ collectionSlugs: filteredExportSlugs
196
+ }
197
+ }
198
+ }
199
+ };
200
+ baseImportCollection = {
201
+ ...baseImportCollection,
202
+ admin: {
203
+ ...baseImportCollection.admin,
204
+ custom: {
205
+ ...baseImportCollection.admin?.custom,
206
+ 'plugin-import-export': {
207
+ ...baseImportCollection.admin?.custom?.['plugin-import-export'],
208
+ collectionSlugs: filteredImportSlugs
209
+ }
210
+ }
211
+ }
212
+ };
141
213
  exportCollections.unshift(baseExportCollection);
142
214
  importCollections.unshift(baseImportCollection);
143
215
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getPluginCollections.ts"],"sourcesContent":["import type { CollectionConfig, Config } from 'payload'\n\nimport type { ExportConfig, ImportConfig, ImportExportPluginConfig } from '../types.js'\n\nimport { getExportCollection } from '../export/getExportCollection.js'\nimport { getImportCollection } from '../import/getImportCollection.js'\n\nexport type PluginCollectionsResult = {\n /**\n * Map from target collection slug to the export collection slug to use for it.\n * Only contains entries for collections with custom export collection overrides.\n */\n customExportSlugMap: Map<string, string>\n /**\n * Map from target collection slug to the import collection slug to use for it.\n * Only contains entries for collections with custom import collection overrides.\n */\n customImportSlugMap: Map<string, string>\n /**\n * All export collections (base + any per-collection overrides)\n */\n exportCollections: CollectionConfig[]\n /**\n * All import collections (base + any per-collection overrides)\n */\n importCollections: CollectionConfig[]\n}\n\n/**\n * Processes the plugin config and returns export/import collections.\n *\n * - Creates the base export and import collections\n * - Applies top-level overrideExportCollection/overrideImportCollection if provided\n * - For each collection in `pluginConfig.collections` that has a function override\n * for `export` or `import`, applies the override to create customized collections\n * - Applies settings from collections without overrideCollection to the base collection\n *\n * @param config - The Payload config\n * @param pluginConfig - The import/export plugin config\n * @returns Object containing arrays of export and import collections\n */\nexport const getPluginCollections = async ({\n config,\n pluginConfig,\n}: {\n config: Config\n pluginConfig: ImportExportPluginConfig\n}): Promise<PluginCollectionsResult> => {\n let baseExportCollection = getExportCollection({\n config,\n pluginConfig,\n })\n let baseImportCollection = getImportCollection({\n config,\n pluginConfig,\n })\n\n if (\n pluginConfig.overrideExportCollection &&\n typeof pluginConfig.overrideExportCollection === 'function'\n ) {\n baseExportCollection = await pluginConfig.overrideExportCollection({\n collection: baseExportCollection,\n })\n }\n\n if (\n pluginConfig.overrideImportCollection &&\n typeof pluginConfig.overrideImportCollection === 'function'\n ) {\n baseImportCollection = await pluginConfig.overrideImportCollection({\n collection: baseImportCollection,\n })\n }\n\n const exportCollections: CollectionConfig[] = []\n const importCollections: CollectionConfig[] = []\n\n const customExportSlugMap = new Map<string, string>()\n const customImportSlugMap = new Map<string, string>()\n\n // Process each collection config for custom collection overrides\n if (pluginConfig.collections && pluginConfig.collections.length > 0) {\n for (const collectionConfig of pluginConfig.collections) {\n const exportConfig =\n typeof collectionConfig.export === 'object' ? collectionConfig.export : undefined\n if (exportConfig?.overrideCollection) {\n // Generate a collection with this export config's settings (like disableJobsQueue)\n const collectionWithSettings = getExportCollection({\n config,\n exportConfig,\n pluginConfig,\n })\n\n const customExport = await exportConfig.overrideCollection({\n collection: collectionWithSettings,\n })\n\n // If the slug changed, this is a separate collection; otherwise it modifies the base\n if (customExport.slug !== baseExportCollection.slug) {\n // Store the source collection slug so CollectionField can use it as default\n customExport.admin = {\n ...customExport.admin,\n custom: {\n ...customExport.admin?.custom,\n defaultCollectionSlug: collectionConfig.slug,\n },\n }\n exportCollections.push(customExport)\n customExportSlugMap.set(collectionConfig.slug, customExport.slug)\n } else {\n baseExportCollection = customExport\n }\n }\n\n const importConf =\n typeof collectionConfig.import === 'object' ? collectionConfig.import : undefined\n if (importConf?.overrideCollection) {\n // Generate a collection with this import config's settings (like disableJobsQueue)\n const collectionWithSettings = getImportCollection({\n config,\n importConfig: importConf,\n pluginConfig,\n })\n\n const customImport = await importConf.overrideCollection({\n collection: collectionWithSettings,\n })\n\n // If the slug changed, this is a separate collection; otherwise it modifies the base\n if (customImport.slug !== baseImportCollection.slug) {\n // Store the source collection slug so CollectionField can use it as default\n customImport.admin = {\n ...customImport.admin,\n custom: {\n ...customImport.admin?.custom,\n defaultCollectionSlug: collectionConfig.slug,\n },\n }\n importCollections.push(customImport)\n // Map this target collection to its custom import collection\n customImportSlugMap.set(collectionConfig.slug, customImport.slug)\n } else {\n // Full override - replace the base\n baseImportCollection = customImport\n }\n }\n }\n }\n\n // Apply settings from collections without overrideCollection to the base collection\n // This is done AFTER all overrides so these settings take precedence\n if (pluginConfig.collections && pluginConfig.collections.length > 0) {\n let mergedExportSettings: Partial<ExportConfig> = {}\n let mergedImportSettings: Partial<ImportConfig> = {}\n\n for (const collectionConfig of pluginConfig.collections) {\n const exportConf =\n typeof collectionConfig.export === 'object' ? collectionConfig.export : undefined\n const importConf =\n typeof collectionConfig.import === 'object' ? collectionConfig.import : undefined\n\n if (exportConf && !exportConf.overrideCollection) {\n mergedExportSettings = { ...mergedExportSettings, ...exportConf }\n }\n if (importConf && !importConf.overrideCollection) {\n mergedImportSettings = { ...mergedImportSettings, ...importConf }\n }\n }\n\n if (\n mergedExportSettings.format !== undefined ||\n mergedExportSettings.disableSave !== undefined ||\n mergedExportSettings.disableDownload !== undefined\n ) {\n baseExportCollection = {\n ...baseExportCollection,\n admin: {\n ...baseExportCollection.admin,\n custom: {\n ...baseExportCollection.admin?.custom,\n ...(mergedExportSettings.disableDownload !== undefined && {\n disableDownload: mergedExportSettings.disableDownload,\n }),\n ...(mergedExportSettings.disableSave !== undefined && {\n disableSave: mergedExportSettings.disableSave,\n }),\n ...(mergedExportSettings.format !== undefined && {\n format: mergedExportSettings.format,\n }),\n },\n },\n }\n }\n }\n\n exportCollections.unshift(baseExportCollection)\n importCollections.unshift(baseImportCollection)\n\n return {\n customExportSlugMap,\n customImportSlugMap,\n exportCollections,\n importCollections,\n }\n}\n"],"names":["getExportCollection","getImportCollection","getPluginCollections","config","pluginConfig","baseExportCollection","baseImportCollection","overrideExportCollection","collection","overrideImportCollection","exportCollections","importCollections","customExportSlugMap","Map","customImportSlugMap","collections","length","collectionConfig","exportConfig","export","undefined","overrideCollection","collectionWithSettings","customExport","slug","admin","custom","defaultCollectionSlug","push","set","importConf","import","importConfig","customImport","mergedExportSettings","mergedImportSettings","exportConf","format","disableSave","disableDownload","unshift"],"mappings":"AAIA,SAASA,mBAAmB,QAAQ,mCAAkC;AACtE,SAASC,mBAAmB,QAAQ,mCAAkC;AAuBtE;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,uBAAuB,OAAO,EACzCC,MAAM,EACNC,YAAY,EAIb;IACC,IAAIC,uBAAuBL,oBAAoB;QAC7CG;QACAC;IACF;IACA,IAAIE,uBAAuBL,oBAAoB;QAC7CE;QACAC;IACF;IAEA,IACEA,aAAaG,wBAAwB,IACrC,OAAOH,aAAaG,wBAAwB,KAAK,YACjD;QACAF,uBAAuB,MAAMD,aAAaG,wBAAwB,CAAC;YACjEC,YAAYH;QACd;IACF;IAEA,IACED,aAAaK,wBAAwB,IACrC,OAAOL,aAAaK,wBAAwB,KAAK,YACjD;QACAH,uBAAuB,MAAMF,aAAaK,wBAAwB,CAAC;YACjED,YAAYF;QACd;IACF;IAEA,MAAMI,oBAAwC,EAAE;IAChD,MAAMC,oBAAwC,EAAE;IAEhD,MAAMC,sBAAsB,IAAIC;IAChC,MAAMC,sBAAsB,IAAID;IAEhC,iEAAiE;IACjE,IAAIT,aAAaW,WAAW,IAAIX,aAAaW,WAAW,CAACC,MAAM,GAAG,GAAG;QACnE,KAAK,MAAMC,oBAAoBb,aAAaW,WAAW,CAAE;YACvD,MAAMG,eACJ,OAAOD,iBAAiBE,MAAM,KAAK,WAAWF,iBAAiBE,MAAM,GAAGC;YAC1E,IAAIF,cAAcG,oBAAoB;gBACpC,mFAAmF;gBACnF,MAAMC,yBAAyBtB,oBAAoB;oBACjDG;oBACAe;oBACAd;gB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+ {"version":3,"sources":["../../src/utilities/getPluginCollections.ts"],"sourcesContent":["import type { CollectionConfig, Config } from 'payload'\n\nimport type { ExportConfig, ImportConfig, ImportExportPluginConfig } from '../types.js'\n\nimport { getExportCollection } from '../export/getExportCollection.js'\nimport { getImportCollection } from '../import/getImportCollection.js'\n\nexport type PluginCollectionsResult = {\n /**\n * Map from target collection slug to the export collection slug to use for it.\n * Only contains entries for collections with custom export collection overrides.\n */\n customExportSlugMap: Map<string, string>\n /**\n * Map from target collection slug to the import collection slug to use for it.\n * Only contains entries for collections with custom import collection overrides.\n */\n customImportSlugMap: Map<string, string>\n /**\n * All export collections (base + any per-collection overrides)\n */\n exportCollections: CollectionConfig[]\n /**\n * All import collections (base + any per-collection overrides)\n */\n importCollections: CollectionConfig[]\n}\n\n/**\n * Processes the plugin config and returns export/import collections.\n *\n * - Creates the base export and import collections\n * - Applies top-level overrideExportCollection/overrideImportCollection if provided\n * - For each collection in `pluginConfig.collections` that has a function override\n * for `export` or `import`, applies the override to create customized collections\n * - Applies settings from collections without overrideCollection to the base collection\n *\n * @param config - The Payload config\n * @param pluginConfig - The import/export plugin config\n * @returns Object containing arrays of export and import collections\n */\nexport const getPluginCollections = async ({\n config,\n pluginConfig,\n}: {\n config: Config\n pluginConfig: ImportExportPluginConfig\n}): Promise<PluginCollectionsResult> => {\n // Calculate collection slugs for base export/import collections\n // If pluginConfig.collections is provided, filter by export/import !== false\n // Otherwise, use all config collections\n let baseExportSlugs: string[]\n let baseImportSlugs: string[]\n\n if (pluginConfig.collections && pluginConfig.collections.length > 0) {\n baseExportSlugs = pluginConfig.collections.filter((c) => c.export !== false).map((c) => c.slug)\n baseImportSlugs = pluginConfig.collections.filter((c) => c.import !== false).map((c) => c.slug)\n } else {\n // Fall back to all collections\n const allSlugs = config.collections?.map((c) => c.slug) || []\n baseExportSlugs = allSlugs\n baseImportSlugs = allSlugs\n }\n\n let baseExportCollection = getExportCollection({\n collectionSlugs: baseExportSlugs,\n config,\n pluginConfig,\n })\n let baseImportCollection = getImportCollection({\n collectionSlugs: baseImportSlugs,\n pluginConfig,\n })\n\n if (\n pluginConfig.overrideExportCollection &&\n typeof pluginConfig.overrideExportCollection === 'function'\n ) {\n baseExportCollection = await pluginConfig.overrideExportCollection({\n collection: baseExportCollection,\n })\n }\n\n if (\n pluginConfig.overrideImportCollection &&\n typeof pluginConfig.overrideImportCollection === 'function'\n ) {\n baseImportCollection = await pluginConfig.overrideImportCollection({\n collection: baseImportCollection,\n })\n }\n\n const exportCollections: CollectionConfig[] = []\n const importCollections: CollectionConfig[] = []\n\n const customExportSlugMap = new Map<string, string>()\n const customImportSlugMap = new Map<string, string>()\n\n // Process each collection config for custom collection overrides\n if (pluginConfig.collections && pluginConfig.collections.length > 0) {\n for (const collectionConfig of pluginConfig.collections) {\n const exportConfig =\n typeof collectionConfig.export === 'object' ? collectionConfig.export : undefined\n\n if (exportConfig?.overrideCollection) {\n // Create collection specific to this target collection\n const collection = getExportCollection({\n collectionSlugs: [collectionConfig.slug],\n config,\n exportConfig,\n pluginConfig,\n })\n\n // Call override once to determine user intent\n const overridden = await exportConfig.overrideCollection({ collection })\n\n // If the slug changed, this is a separate collection; otherwise it modifies the base\n if (overridden.slug !== baseExportCollection.slug) {\n exportCollections.push(overridden)\n customExportSlugMap.set(collectionConfig.slug, overridden.slug)\n } else {\n // Slug didn't change - merge settings into base collection while preserving all slugs\n baseExportCollection = {\n ...baseExportCollection,\n ...overridden,\n admin: {\n ...baseExportCollection.admin,\n ...overridden.admin,\n custom: {\n ...baseExportCollection.admin?.custom,\n ...overridden.admin?.custom,\n 'plugin-import-export': {\n ...overridden.admin?.custom?.['plugin-import-export'],\n ...baseExportCollection.admin?.custom?.['plugin-import-export'],\n // Ensure base collection's slug list is preserved\n collectionSlugs:\n baseExportCollection.admin?.custom?.['plugin-import-export']?.collectionSlugs,\n },\n },\n },\n }\n }\n }\n\n const importConf =\n typeof collectionConfig.import === 'object' ? collectionConfig.import : undefined\n\n if (importConf?.overrideCollection) {\n // Create collection specific to this target collection\n const collection = getImportCollection({\n collectionSlugs: [collectionConfig.slug],\n importConfig: importConf,\n pluginConfig,\n })\n\n // Call override once to determine user intent\n const overridden = await importConf.overrideCollection({ collection })\n\n // If the slug changed, this is a separate collection; otherwise it modifies the base\n if (overridden.slug !== baseImportCollection.slug) {\n importCollections.push(overridden)\n // Map this target collection to its custom import collection\n customImportSlugMap.set(collectionConfig.slug, overridden.slug)\n } else {\n // Slug didn't change - merge settings into base collection while preserving all slugs\n baseImportCollection = {\n ...baseImportCollection,\n ...overridden,\n admin: {\n ...baseImportCollection.admin,\n ...overridden.admin,\n custom: {\n ...baseImportCollection.admin?.custom,\n ...overridden.admin?.custom,\n 'plugin-import-export': {\n ...overridden.admin?.custom?.['plugin-import-export'],\n ...baseImportCollection.admin?.custom?.['plugin-import-export'],\n // Ensure base collection's slug list is preserved\n collectionSlugs:\n baseImportCollection.admin?.custom?.['plugin-import-export']?.collectionSlugs,\n },\n },\n },\n }\n }\n }\n }\n }\n\n // Apply settings from collections without overrideCollection to the base collection\n // This is done AFTER all overrides so these settings take precedence\n if (pluginConfig.collections && pluginConfig.collections.length > 0) {\n let mergedExportSettings: Partial<ExportConfig> = {}\n let mergedImportSettings: Partial<ImportConfig> = {}\n\n for (const collectionConfig of pluginConfig.collections) {\n const exportConf =\n typeof collectionConfig.export === 'object' ? collectionConfig.export : undefined\n const importConf =\n typeof collectionConfig.import === 'object' ? collectionConfig.import : undefined\n\n if (exportConf && !exportConf.overrideCollection) {\n mergedExportSettings = { ...mergedExportSettings, ...exportConf }\n }\n if (importConf && !importConf.overrideCollection) {\n mergedImportSettings = { ...mergedImportSettings, ...importConf }\n }\n }\n\n if (\n mergedExportSettings.format !== undefined ||\n mergedExportSettings.disableSave !== undefined ||\n mergedExportSettings.disableDownload !== undefined\n ) {\n baseExportCollection = {\n ...baseExportCollection,\n admin: {\n ...baseExportCollection.admin,\n custom: {\n ...baseExportCollection.admin?.custom,\n ...(mergedExportSettings.disableDownload !== undefined && {\n disableDownload: mergedExportSettings.disableDownload,\n }),\n ...(mergedExportSettings.disableSave !== undefined && {\n disableSave: mergedExportSettings.disableSave,\n }),\n ...(mergedExportSettings.format !== undefined && {\n format: mergedExportSettings.format,\n }),\n },\n },\n }\n }\n }\n\n // Filter out slugs that have custom export/import collections from the base collections\n // Collections with custom collections should ONLY be exportable/importable through those\n const filteredExportSlugs = baseExportSlugs.filter((slug) => !customExportSlugMap.has(slug))\n const filteredImportSlugs = baseImportSlugs.filter((slug) => !customImportSlugMap.has(slug))\n\n // Update base collections with filtered slugs\n baseExportCollection = {\n ...baseExportCollection,\n admin: {\n ...baseExportCollection.admin,\n custom: {\n ...baseExportCollection.admin?.custom,\n 'plugin-import-export': {\n ...baseExportCollection.admin?.custom?.['plugin-import-export'],\n collectionSlugs: filteredExportSlugs,\n },\n },\n },\n }\n\n baseImportCollection = {\n ...baseImportCollection,\n admin: {\n ...baseImportCollection.admin,\n custom: {\n ...baseImportCollection.admin?.custom,\n 'plugin-import-export': {\n ...baseImportCollection.admin?.custom?.['plugin-import-export'],\n collectionSlugs: filteredImportSlugs,\n },\n },\n },\n }\n\n exportCollections.unshift(baseExportCollection)\n importCollections.unshift(baseImportCollection)\n\n return {\n customExportSlugMap,\n customImportSlugMap,\n exportCollections,\n importCollections,\n }\n}\n"],"names":["getExportCollection","getImportCollection","getPluginCollections","config","pluginConfig","baseExportSlugs","baseImportSlugs","collections","length","filter","c","export","map","slug","import","allSlugs","baseExportCollection","collectionSlugs","baseImportCollection","overrideExportCollection","collection","overrideImportCollection","exportCollections","importCollections","customExportSlugMap","Map","customImportSlugMap","collectionConfig","exportConfig","undefined","overrideCollection","overridden","push","set","admin","custom","importConf","importConfig","mergedExportSettings","mergedImportSettings","exportConf","format","disableSave","disableDownload","filteredExportSlugs","has","filteredImportSlugs","unshift"],"mappings":"AAIA,SAASA,mBAAmB,QAAQ,mCAAkC;AACtE,SAASC,mBAAmB,QAAQ,mCAAkC;AAuBtE;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M,EAAE,CAmC5F"}
1
+ {"version":3,"file":"getSchemaColumns.d.ts","sourceRoot":"","sources":["../../src/utilities/getSchemaColumns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAIxD,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,uFAM1B,oBAAoB,KAAG,MAAM,EAmC/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,kBAAmB,MAAM,EAAE,eAAe,MAAM,EAAE,KAAG,MAAM,EAqEnF,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAmC5F"}
@@ -11,36 +11,27 @@ import { getFlattenedFieldKeys } from './getFlattenedFieldKeys.js';
11
11
  * - Works for empty exports
12
12
  * - Ensures proper column ordering
13
13
  */ export const getSchemaColumns = ({ collectionConfig, disabledFields = [], fields: selectedFields, locale, localeCodes })=>{
14
- const hasVersions = Boolean(collectionConfig.versions);
15
- // Determine if we need locale expansion
16
14
  const expandLocales = locale === 'all' && localeCodes && localeCodes.length > 0;
17
- // Get all possible columns from schema (excludes system fields like id, createdAt, updatedAt)
18
15
  let schemaColumns = getFlattenedFieldKeys(collectionConfig.flattenedFields, '', expandLocales ? {
19
16
  localeCodes
20
17
  } : {});
21
- // Add system fields that aren't in flattenedFields
22
- const systemFields = [
23
- 'id',
24
- 'createdAt',
25
- 'updatedAt'
26
- ];
27
- schemaColumns = [
28
- ...systemFields,
29
- ...schemaColumns
30
- ];
31
- // Filter to user-selected fields if specified
18
+ // Add id if not present in schema
19
+ const hasIdField = schemaColumns.includes('id');
20
+ if (!hasIdField) {
21
+ schemaColumns = [
22
+ 'id',
23
+ ...schemaColumns
24
+ ];
25
+ }
32
26
  if (selectedFields && selectedFields.length > 0) {
33
27
  schemaColumns = filterToSelectedFields(schemaColumns, selectedFields);
34
28
  }
35
- // Remove disabled fields
36
29
  if (disabledFields.length > 0) {
37
30
  const disabledSet = new Set();
38
31
  for (const path of disabledFields){
39
- // Convert dot notation to underscore and add to set
40
32
  disabledSet.add(path.replace(/\./g, '_'));
41
33
  }
42
34
  schemaColumns = schemaColumns.filter((col)=>{
43
- // Check if column matches any disabled path
44
35
  for (const disabled of disabledSet){
45
36
  if (col === disabled || col.startsWith(`${disabled}_`)) {
46
37
  return false;
@@ -49,41 +40,7 @@ import { getFlattenedFieldKeys } from './getFlattenedFieldKeys.js';
49
40
  return true;
50
41
  });
51
42
  }
52
- // When user has selected specific fields, preserve their ordering
53
- // filterToSelectedFields() already returns columns in user's specified order
54
- if (selectedFields && selectedFields.length > 0) {
55
- return schemaColumns;
56
- }
57
- // No fields selected - apply default ordering (id first, timestamps last)
58
- const orderedColumns = [];
59
- // 1. ID always first
60
- if (schemaColumns.includes('id')) {
61
- orderedColumns.push('id');
62
- }
63
- // 2. Status field for versioned collections
64
- if (hasVersions) {
65
- orderedColumns.push('_status');
66
- }
67
- // 3. All other fields (excluding id, timestamps, status)
68
- const excludeFromMiddle = new Set([
69
- '_status',
70
- 'createdAt',
71
- 'id',
72
- 'updatedAt'
73
- ]);
74
- for (const col of schemaColumns){
75
- if (!excludeFromMiddle.has(col)) {
76
- orderedColumns.push(col);
77
- }
78
- }
79
- // 4. Timestamps at the end
80
- if (schemaColumns.includes('createdAt')) {
81
- orderedColumns.push('createdAt');
82
- }
83
- if (schemaColumns.includes('updatedAt')) {
84
- orderedColumns.push('updatedAt');
85
- }
86
- return orderedColumns;
43
+ return schemaColumns;
87
44
  };
88
45
  /**
89
46
  * Merges schema-derived columns with data-discovered columns.
@@ -95,12 +52,9 @@ import { getFlattenedFieldKeys } from './getFlattenedFieldKeys.js';
95
52
  ];
96
53
  const schemaSet = new Set(schemaColumns);
97
54
  const insertedDerived = new Map();
98
- // Add any data columns not in schema (preserves schema ordering, appends new ones)
99
55
  for (const col of dataColumns){
100
56
  if (!schemaSet.has(col)) {
101
57
  let inserted = false;
102
- // Check if this is a derived column from a schema column (e.g., field_id, field_email)
103
- // Pattern: schemaCol_suffix where suffix is NOT a number (array indices are handled separately)
104
58
  for (const schemaCol of schemaColumns){
105
59
  if (col.startsWith(`${schemaCol}_`)) {
106
60
  const suffix = col.slice(schemaCol.length + 1);
@@ -137,7 +91,6 @@ import { getFlattenedFieldKeys } from './getFlattenedFieldKeys.js';
137
91
  }
138
92
  }
139
93
  }
140
- // Otherwise append at the end (before timestamps)
141
94
  const createdAtIdx = result.indexOf('createdAt');
142
95
  if (createdAtIdx !== -1) {
143
96
  result.splice(createdAtIdx, 0, col);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getSchemaColumns.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from 'payload'\n\nimport { getFlattenedFieldKeys } from './getFlattenedFieldKeys.js'\n\nexport type GetSchemaColumnsArgs = {\n /**\n * The collection configuration to derive columns from\n */\n collectionConfig: SanitizedCollectionConfig\n /**\n * Array of disabled field paths from plugin config\n */\n disabledFields?: string[]\n /**\n * User-selected fields to export. If provided, only these fields (and their nested fields) will be included.\n */\n fields?: string[]\n /**\n * The locale to export. When 'all', localized fields are expanded to include all locale suffixes.\n */\n locale?: null | string\n /**\n * Available locale codes from config. Required when locale='all'.\n */\n localeCodes?: string[]\n}\n\n/**\n * Derives CSV column names from the collection schema.\n * This provides a base set of columns from field definitions.\n *\n * Note: For arrays/blocks with multiple items, the schema only generates index 0.\n * Additional indices from actual data should be merged with these columns.\n *\n * Benefits:\n * - Provides consistent base columns\n * - Works for empty exports\n * - Ensures proper column ordering\n */\nexport const getSchemaColumns = ({\n collectionConfig,\n disabledFields = [],\n fields: selectedFields,\n locale,\n localeCodes,\n}: GetSchemaColumnsArgs): string[] => {\n const hasVersions = Boolean(collectionConfig.versions)\n\n // Determine if we need locale expansion\n const expandLocales = locale === 'all' && localeCodes && localeCodes.length > 0\n\n // Get all possible columns from schema (excludes system fields like id, createdAt, updatedAt)\n let schemaColumns = getFlattenedFieldKeys(\n collectionConfig.flattenedFields,\n '',\n expandLocales ? { localeCodes } : {},\n )\n\n // Add system fields that aren't in flattenedFields\n const systemFields = ['id', 'createdAt', 'updatedAt']\n schemaColumns = [...systemFields, ...schemaColumns]\n\n // Filter to user-selected fields if specified\n if (selectedFields && selectedFields.length > 0) {\n schemaColumns = filterToSelectedFields(schemaColumns, selectedFields)\n }\n\n // Remove disabled fields\n if (disabledFields.length > 0) {\n const disabledSet = new Set<string>()\n for (const path of disabledFields) {\n // Convert dot notation to underscore and add to set\n disabledSet.add(path.replace(/\\./g, '_'))\n }\n schemaColumns = schemaColumns.filter((col) => {\n // Check if column matches any disabled path\n for (const disabled of disabledSet) {\n if (col === disabled || col.startsWith(`${disabled}_`)) {\n return false\n }\n }\n return true\n })\n }\n\n // When user has selected specific fields, preserve their ordering\n // filterToSelectedFields() already returns columns in user's specified order\n if (selectedFields && selectedFields.length > 0) {\n return schemaColumns\n }\n\n // No fields selected - apply default ordering (id first, timestamps last)\n const orderedColumns: string[] = []\n\n // 1. ID always first\n if (schemaColumns.includes('id')) {\n orderedColumns.push('id')\n }\n\n // 2. Status field for versioned collections\n if (hasVersions) {\n orderedColumns.push('_status')\n }\n\n // 3. All other fields (excluding id, timestamps, status)\n const excludeFromMiddle = new Set(['_status', 'createdAt', 'id', 'updatedAt'])\n for (const col of schemaColumns) {\n if (!excludeFromMiddle.has(col)) {\n orderedColumns.push(col)\n }\n }\n\n // 4. Timestamps at the end\n if (schemaColumns.includes('createdAt')) {\n orderedColumns.push('createdAt')\n }\n if (schemaColumns.includes('updatedAt')) {\n orderedColumns.push('updatedAt')\n }\n\n return orderedColumns\n}\n\n/**\n * Merges schema-derived columns with data-discovered columns.\n * Schema columns provide the base ordering, data columns add any additional\n * columns (e.g., array indices beyond 0, dynamic fields, derived columns from toCSV).\n */\nexport const mergeColumns = (schemaColumns: string[], dataColumns: string[]): string[] => {\n const result = [...schemaColumns]\n const schemaSet = new Set(schemaColumns)\n const insertedDerived = new Map<string, string[]>()\n\n // Add any data columns not in schema (preserves schema ordering, appends new ones)\n for (const col of dataColumns) {\n if (!schemaSet.has(col)) {\n let inserted = false\n\n // Check if this is a derived column from a schema column (e.g., field_id, field_email)\n // Pattern: schemaCol_suffix where suffix is NOT a number (array indices are handled separately)\n for (const schemaCol of schemaColumns) {\n if (col.startsWith(`${schemaCol}_`)) {\n const suffix = col.slice(schemaCol.length + 1)\n // Skip if suffix starts with a digit (array index pattern like field_0_*)\n if (!/^\\d/.test(suffix)) {\n const baseIdx = result.indexOf(schemaCol)\n if (baseIdx !== -1) {\n const derivedList = insertedDerived.get(schemaCol) || []\n const insertIdx = baseIdx + 1 + derivedList.length\n result.splice(insertIdx, 0, col)\n derivedList.push(col)\n insertedDerived.set(schemaCol, derivedList)\n schemaSet.add(col)\n inserted = true\n break\n }\n }\n }\n }\n\n if (!inserted) {\n // Check for array indices (e.g., field_1_*), insert after field_0_*\n const match = col.match(/^(.+?)_(\\d+)(_.*)?$/)\n if (match) {\n const [, basePath, index, suffix] = match\n if (basePath && index) {\n const prevIndex = parseInt(index, 10) - 1\n const prevCol = `${basePath}_${prevIndex}${suffix ?? ''}`\n const prevIdx = result.indexOf(prevCol)\n if (prevIdx !== -1) {\n // Insert after the previous index column\n result.splice(prevIdx + 1, 0, col)\n schemaSet.add(col)\n continue\n }\n }\n }\n\n // Otherwise append at the end (before timestamps)\n const createdAtIdx = result.indexOf('createdAt')\n if (createdAtIdx !== -1) {\n result.splice(createdAtIdx, 0, col)\n } else {\n result.push(col)\n }\n schemaSet.add(col)\n }\n }\n }\n\n // Remove schema columns that were fully replaced by toCSV-derived columns (e.g. \"user\" → \"user_id\", \"user_email\")\n for (const [schemaCol, derivedCols] of insertedDerived) {\n if (!dataColumns.includes(schemaCol) && derivedCols.length > 0) {\n const idx = result.indexOf(schemaCol)\n if (idx !== -1) {\n result.splice(idx, 1)\n }\n }\n }\n\n return result\n}\n\n/**\n * Filters schema columns to only include those matching user-selected fields.\n * Preserves the order specified by the user in selectedFields.\n *\n * Container fields (groups, arrays, blocks) don't produce their own column, so we prefix-expand\n * to find their children (e.g., 'group' → 'group_name', 'group_age').\n * Leaf fields (date, text, select) produce an exact column, so we only match exactly to avoid\n * including siblings with similar prefixes (e.g., 'dateWithTimezone' won't pull 'dateWithTimezone_tz').\n */\nexport function filterToSelectedFields(columns: string[], selectedFields: string[]): string[] {\n const result: string[] = []\n const columnsSet = new Set(columns)\n\n // Convert selected fields to underscore notation patterns\n const patterns = selectedFields.map((field) => {\n const underscored = field.replace(/\\./g, '_')\n return {\n exact: underscored,\n original: field,\n prefix: `${underscored}_`,\n }\n })\n\n // Iterate through user-specified fields in order to preserve their ordering\n for (const pattern of patterns) {\n const hasExactColumn = columnsSet.has(pattern.exact)\n\n if (hasExactColumn && !result.includes(pattern.exact)) {\n result.push(pattern.exact)\n }\n\n // Only prefix-expand if no exact column match exists (containers need expansion, leaves don't)\n if (!hasExactColumn) {\n for (const column of columns) {\n if (column.startsWith(pattern.prefix)) {\n if (!result.includes(column)) {\n result.push(column)\n }\n }\n }\n }\n }\n\n return result\n}\n"],"names":["getFlattenedFieldKeys","getSchemaColumns","collectionConfig","disabledFields","fields","selectedFields","locale","localeCodes","hasVersions","Boolean","versions","expandLocales","length","schemaColumns","flattenedFields","systemFields","filterToSelectedFields","disabledSet","Set","path","add","replace","filter","col","disabled","startsWith","orderedColumns","includes","push","excludeFromMiddle","has","mergeColumns","dataColumns","result","schemaSet","insertedDerived","Map","inserted","schemaCol","suffix","slice","test","baseIdx","indexOf","derivedList","get","insertIdx","splice","set","match","basePath","index","prevIndex","parseInt","prevCol","prevIdx","createdAtIdx","derivedCols","idx","columns","columnsSet","patterns","map","field","underscored","exact","original","prefix","pattern","hasExactColumn","column"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,6BAA4B;AAyBlE;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,mBAAmB,CAAC,EAC/BC,gBAAgB,EAChBC,iBAAiB,EAAE,EACnBC,QAAQC,cAAc,EACtBC,MAAM,EACNC,WAAW,EACU;IACrB,MAAMC,cAAcC,QAAQP,iBAAiBQ,QAAQ;IAErD,wCAAwC;IACxC,MAAMC,gBAAgBL,WAAW,SAASC,eAAeA,YAAYK,MAAM,GAAG;IAE9E,8FAA8F;IAC9F,IAAIC,gBAAgBb,sBAClBE,iBAAiBY,eAAe,EAChC,IACAH,gBAAgB;QAAEJ;IAAY,IAAI,CAAC;IAGrC,mDAAmD;IACnD,MAAMQ,eAAe;QAAC;QAAM;QAAa;KAAY;IACrDF,gBAAgB;WAAIE;WAAiBF;KAAc;IAEnD,8CAA8C;IAC9C,IAAIR,kBAAkBA,eAAeO,MAAM,GAAG,GAAG;QAC/CC,gBAAgBG,uBAAuBH,eAAeR;IACxD;IAEA,yBAAyB;IACzB,IAAIF,eAAeS,MAAM,GAAG,GAAG;QAC7B,MAAMK,cAAc,IAAIC;QACxB,KAAK,MAAMC,QAAQhB,eAAgB;YACjC,oDAAoD;YACpDc,YAAYG,GAAG,CAACD,KAAKE,OAAO,CAAC,OAAO;QACtC;QACAR,gBAAgBA,cAAcS,MAAM,CAAC,CAACC;YACpC,4CAA4C;YAC5C,KAAK,MAAMC,YAAYP,YAAa;gBAClC,IAAIM,QAAQC,YAAYD,IAAIE,UAAU,CAAC,GAAGD,SAAS,CAAC,CAAC,GAAG;oBACtD,OAAO;gBACT;YACF;YACA,OAAO;QACT;IACF;IAEA,kEAA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Q,CAAC,GAAG;gBACdzB,OAAOc,MAAM,CAACW,KAAK;YACrB;QACF;IACF;IAEA,OAAOzB;AACT,EAAC;AAED;;;;;;;;CAQC,GACD,OAAO,SAASjB,uBAAuB2C,OAAiB,EAAEtD,cAAwB;IAChF,MAAM4B,SAAmB,EAAE;IAC3B,MAAM2B,aAAa,IAAI1C,IAAIyC;IAE3B,0DAA0D;IAC1D,MAAME,WAAWxD,eAAeyD,GAAG,CAAC,CAACC;QACnC,MAAMC,cAAcD,MAAM1C,OAAO,CAAC,OAAO;QACzC,OAAO;YACL4C,OAAOD;YACPE,UAAUH;YACVI,QAAQ,GAAGH,YAAY,CAAC,CAAC;QAC3B;IACF;IAEA,4EAA4E;IAC5E,KAAK,MAAMI,WAAWP,SAAU;QAC9B,MAAMQ,iBAAiBT,WAAW9B,GAAG,CAACsC,QAAQH,KAAK;QAEnD,IAAII,kBAAkB,CAACpC,OAAON,QAAQ,CAACyC,QAAQH,KAAK,GAAG;YACrDhC,OAAOL,IAAI,CAACwC,QAAQH,KAAK;QAC3B;QAEA,+FAA+F;QAC/F,IAAI,CAACI,gBAAgB;YACnB,KAAK,MAAMC,UAAUX,QAAS;gBAC5B,IAAIW,OAAO7C,UAAU,CAAC2C,QAAQD,MAAM,GAAG;oBACrC,IAAI,CAAClC,OAAON,QAAQ,CAAC2C,SAAS;wBAC5BrC,OAAOL,IAAI,CAAC0C;oBACd;gBACF;YACF;QACF;IACF;IAEA,OAAOrC;AACT"}
1
+ {"version":3,"sources":["../../src/utilities/getSchemaColumns.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from 'payload'\n\nimport { getFlattenedFieldKeys } from './getFlattenedFieldKeys.js'\n\nexport type GetSchemaColumnsArgs = {\n /**\n * The collection configuration to derive columns from\n */\n collectionConfig: SanitizedCollectionConfig\n /**\n * Array of disabled field paths from plugin config\n */\n disabledFields?: string[]\n /**\n * User-selected fields to export. If provided, only these fields (and their nested fields) will be included.\n */\n fields?: string[]\n /**\n * The locale to export. When 'all', localized fields are expanded to include all locale suffixes.\n */\n locale?: null | string\n /**\n * Available locale codes from config. Required when locale='all'.\n */\n localeCodes?: string[]\n}\n\n/**\n * Derives CSV column names from the collection schema.\n * This provides a base set of columns from field definitions.\n *\n * Note: For arrays/blocks with multiple items, the schema only generates index 0.\n * Additional indices from actual data should be merged with these columns.\n *\n * Benefits:\n * - Provides consistent base columns\n * - Works for empty exports\n * - Ensures proper column ordering\n */\nexport const getSchemaColumns = ({\n collectionConfig,\n disabledFields = [],\n fields: selectedFields,\n locale,\n localeCodes,\n}: GetSchemaColumnsArgs): string[] => {\n const expandLocales = locale === 'all' && localeCodes && localeCodes.length > 0\n\n let schemaColumns = getFlattenedFieldKeys(\n collectionConfig.flattenedFields,\n '',\n expandLocales ? { localeCodes } : {},\n )\n\n // Add id if not present in schema\n const hasIdField = schemaColumns.includes('id')\n if (!hasIdField) {\n schemaColumns = ['id', ...schemaColumns]\n }\n\n if (selectedFields && selectedFields.length > 0) {\n schemaColumns = filterToSelectedFields(schemaColumns, selectedFields)\n }\n\n if (disabledFields.length > 0) {\n const disabledSet = new Set<string>()\n for (const path of disabledFields) {\n disabledSet.add(path.replace(/\\./g, '_'))\n }\n schemaColumns = schemaColumns.filter((col) => {\n for (const disabled of disabledSet) {\n if (col === disabled || col.startsWith(`${disabled}_`)) {\n return false\n }\n }\n return true\n })\n }\n\n return schemaColumns\n}\n\n/**\n * Merges schema-derived columns with data-discovered columns.\n * Schema columns provide the base ordering, data columns add any additional\n * columns (e.g., array indices beyond 0, dynamic fields, derived columns from toCSV).\n */\nexport const mergeColumns = (schemaColumns: string[], dataColumns: string[]): string[] => {\n const result = [...schemaColumns]\n const schemaSet = new Set(schemaColumns)\n const insertedDerived = new Map<string, string[]>()\n\n for (const col of dataColumns) {\n if (!schemaSet.has(col)) {\n let inserted = false\n\n for (const schemaCol of schemaColumns) {\n if (col.startsWith(`${schemaCol}_`)) {\n const suffix = col.slice(schemaCol.length + 1)\n // Skip if suffix starts with a digit (array index pattern like field_0_*)\n if (!/^\\d/.test(suffix)) {\n const baseIdx = result.indexOf(schemaCol)\n if (baseIdx !== -1) {\n const derivedList = insertedDerived.get(schemaCol) || []\n const insertIdx = baseIdx + 1 + derivedList.length\n result.splice(insertIdx, 0, col)\n derivedList.push(col)\n insertedDerived.set(schemaCol, derivedList)\n schemaSet.add(col)\n inserted = true\n break\n }\n }\n }\n }\n\n if (!inserted) {\n // Check for array indices (e.g., field_1_*), insert after field_0_*\n const match = col.match(/^(.+?)_(\\d+)(_.*)?$/)\n if (match) {\n const [, basePath, index, suffix] = match\n if (basePath && index) {\n const prevIndex = parseInt(index, 10) - 1\n const prevCol = `${basePath}_${prevIndex}${suffix ?? ''}`\n const prevIdx = result.indexOf(prevCol)\n if (prevIdx !== -1) {\n // Insert after the previous index column\n result.splice(prevIdx + 1, 0, col)\n schemaSet.add(col)\n continue\n }\n }\n }\n\n const createdAtIdx = result.indexOf('createdAt')\n if (createdAtIdx !== -1) {\n result.splice(createdAtIdx, 0, col)\n } else {\n result.push(col)\n }\n schemaSet.add(col)\n }\n }\n }\n\n // Remove schema columns that were fully replaced by toCSV-derived columns (e.g. \"user\" → \"user_id\", \"user_email\")\n for (const [schemaCol, derivedCols] of insertedDerived) {\n if (!dataColumns.includes(schemaCol) && derivedCols.length > 0) {\n const idx = result.indexOf(schemaCol)\n if (idx !== -1) {\n result.splice(idx, 1)\n }\n }\n }\n\n return result\n}\n\n/**\n * Filters schema columns to only include those matching user-selected fields.\n * Preserves the order specified by the user in selectedFields.\n *\n * Container fields (groups, arrays, blocks) don't produce their own column, so we prefix-expand\n * to find their children (e.g., 'group' → 'group_name', 'group_age').\n * Leaf fields (date, text, select) produce an exact column, so we only match exactly to avoid\n * including siblings with similar prefixes (e.g., 'dateWithTimezone' won't pull 'dateWithTimezone_tz').\n */\nexport function filterToSelectedFields(columns: string[], selectedFields: string[]): string[] {\n const result: string[] = []\n const columnsSet = new Set(columns)\n\n // Convert selected fields to underscore notation patterns\n const patterns = selectedFields.map((field) => {\n const underscored = field.replace(/\\./g, '_')\n return {\n exact: underscored,\n original: field,\n prefix: `${underscored}_`,\n }\n })\n\n // Iterate through user-specified fields in order to preserve their ordering\n for (const pattern of patterns) {\n const hasExactColumn = columnsSet.has(pattern.exact)\n\n if (hasExactColumn && !result.includes(pattern.exact)) {\n result.push(pattern.exact)\n }\n\n // Only prefix-expand if no exact column match exists (containers need expansion, leaves don't)\n if (!hasExactColumn) {\n for (const column of columns) {\n if (column.startsWith(pattern.prefix)) {\n if (!result.includes(column)) {\n result.push(column)\n }\n }\n }\n }\n }\n\n return result\n}\n"],"names":["getFlattenedFieldKeys","getSchemaColumns","collectionConfig","disabledFields","fields","selectedFields","locale","localeCodes","expandLocales","length","schemaColumns","flattenedFields","hasIdField","includes","filterToSelectedFields","disabledSet","Set","path","add","replace","filter","col","disabled","startsWith","mergeColumns","dataColumns","result","schemaSet","insertedDerived","Map","has","inserted","schemaCol","suffix","slice","test","baseIdx","indexOf","derivedList","get","insertIdx","splice","push","set","match","basePath","index","prevIndex","parseInt","prevCol","prevIdx","createdAtIdx","derivedCols","idx","columns","columnsSet","patterns","map","field","underscored","exact","original","prefix","pattern","hasExactColumn","column"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,6BAA4B;AAyBlE;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,mBAAmB,CAAC,EAC/BC,gBAAgB,EAChBC,iBAAiB,EAAE,EACnBC,QAAQC,cAAc,EACtBC,MAAM,EACNC,WAAW,EACU;IACrB,MAAMC,gBAAgBF,WAAW,SAASC,eAAeA,YAAYE,MAAM,GAAG;IAE9E,IAAIC,gBAAgBV,sBAClBE,iBAAiBS,eAAe,EAChC,IACAH,gBAAgB;QAAED;IAAY,IAAI,CAAC;IAGrC,kCAAkC;IAClC,MAAMK,aAAaF,cAAcG,QAAQ,CAAC;IAC1C,IAAI,CAACD,YAAY;QACfF,gBAAgB;YAAC;eAASA;SAAc;IAC1C;IAEA,IAAIL,k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AG,CAAC,CAACC;QACnC,MAAMC,cAAcD,MAAMvC,OAAO,CAAC,OAAO;QACzC,OAAO;YACLyC,OAAOD;YACPE,UAAUH;YACVI,QAAQ,GAAGH,YAAY,CAAC,CAAC;QAC3B;IACF;IAEA,4EAA4E;IAC5E,KAAK,MAAMI,WAAWP,SAAU;QAC9B,MAAMQ,iBAAiBT,WAAWzB,GAAG,CAACiC,QAAQH,KAAK;QAEnD,IAAII,kBAAkB,CAACtC,OAAOb,QAAQ,CAACkD,QAAQH,KAAK,GAAG;YACrDlC,OAAOgB,IAAI,CAACqB,QAAQH,KAAK;QAC3B;QAEA,+FAA+F;QAC/F,IAAI,CAACI,gBAAgB;YACnB,KAAK,MAAMC,UAAUX,QAAS;gBAC5B,IAAIW,OAAO1C,UAAU,CAACwC,QAAQD,MAAM,GAAG;oBACrC,IAAI,CAACpC,OAAOb,QAAQ,CAACoD,SAAS;wBAC5BvC,OAAOgB,IAAI,CAACuB;oBACd;gBACF;YACF;QACF;IACF;IAEA,OAAOvC;AACT"}
@@ -0,0 +1,157 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { getSchemaColumns } from './getSchemaColumns.js';
3
+ function createCollectionConfig(flattenedFields, options) {
4
+ return {
5
+ flattenedFields,
6
+ timestamps: options?.timestamps ?? true,
7
+ trash: options?.trash ?? false,
8
+ versions: options?.versions
9
+ };
10
+ }
11
+ describe('getSchemaColumns', ()=>{
12
+ describe('fields from flattenedFields', ()=>{
13
+ it('should include all fields present in flattenedFields in their natural order', ()=>{
14
+ const flattenedFields = [
15
+ {
16
+ name: 'id',
17
+ type: 'number'
18
+ },
19
+ {
20
+ name: 'title',
21
+ type: 'text'
22
+ },
23
+ {
24
+ name: 'createdAt',
25
+ type: 'date'
26
+ },
27
+ {
28
+ name: 'updatedAt',
29
+ type: 'date'
30
+ }
31
+ ];
32
+ const collectionConfig = createCollectionConfig(flattenedFields);
33
+ const result = getSchemaColumns({
34
+ collectionConfig
35
+ });
36
+ expect(result).toEqual([
37
+ 'id',
38
+ 'title',
39
+ 'createdAt',
40
+ 'updatedAt'
41
+ ]);
42
+ });
43
+ it('should include custom id field when defined in flattenedFields', ()=>{
44
+ const flattenedFields = [
45
+ {
46
+ name: 'id',
47
+ type: 'text'
48
+ },
49
+ {
50
+ name: 'title',
51
+ type: 'text'
52
+ },
53
+ {
54
+ name: 'createdAt',
55
+ type: 'date'
56
+ },
57
+ {
58
+ name: 'updatedAt',
59
+ type: 'date'
60
+ }
61
+ ];
62
+ const collectionConfig = createCollectionConfig(flattenedFields);
63
+ const result = getSchemaColumns({
64
+ collectionConfig
65
+ });
66
+ expect(result).toContain('id');
67
+ });
68
+ it('should not include createdAt or updatedAt when timestamps disabled (not in flattenedFields)', ()=>{
69
+ const flattenedFields = [
70
+ {
71
+ name: 'id',
72
+ type: 'number'
73
+ },
74
+ {
75
+ name: 'title',
76
+ type: 'text'
77
+ }
78
+ ];
79
+ const collectionConfig = createCollectionConfig(flattenedFields, {
80
+ timestamps: false
81
+ });
82
+ const result = getSchemaColumns({
83
+ collectionConfig
84
+ });
85
+ expect(result).toContain('id');
86
+ expect(result).toContain('title');
87
+ expect(result).not.toContain('createdAt');
88
+ expect(result).not.toContain('updatedAt');
89
+ });
90
+ it('should include deletedAt when present in flattenedFields (trash enabled)', ()=>{
91
+ const flattenedFields = [
92
+ {
93
+ name: 'id',
94
+ type: 'number'
95
+ },
96
+ {
97
+ name: 'title',
98
+ type: 'text'
99
+ },
100
+ {
101
+ name: 'createdAt',
102
+ type: 'date'
103
+ },
104
+ {
105
+ name: 'updatedAt',
106
+ type: 'date'
107
+ },
108
+ {
109
+ name: 'deletedAt',
110
+ type: 'date'
111
+ }
112
+ ];
113
+ const collectionConfig = createCollectionConfig(flattenedFields);
114
+ const result = getSchemaColumns({
115
+ collectionConfig
116
+ });
117
+ expect(result).toContain('deletedAt');
118
+ });
119
+ it('should add id when missing from flattenedFields (Payload core limitation)', ()=>{
120
+ const flattenedFields = [
121
+ {
122
+ name: 'title',
123
+ type: 'text'
124
+ },
125
+ {
126
+ name: 'excerpt',
127
+ type: 'textarea'
128
+ },
129
+ {
130
+ name: 'createdAt',
131
+ type: 'date'
132
+ },
133
+ {
134
+ name: 'updatedAt',
135
+ type: 'date'
136
+ }
137
+ ];
138
+ const collectionConfig = createCollectionConfig(flattenedFields);
139
+ const result = getSchemaColumns({
140
+ collectionConfig
141
+ });
142
+ // id is added because Payload core doesn't add it to flattenedFields
143
+ // but it exists on every document
144
+ expect(result).toContain('id');
145
+ expect(result[0]).toBe('id');
146
+ expect(result).toEqual([
147
+ 'id',
148
+ 'title',
149
+ 'excerpt',
150
+ 'createdAt',
151
+ 'updatedAt'
152
+ ]);
153
+ });
154
+ });
155
+ });
156
+
157
+ //# sourceMappingURL=getSchemaColumns.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/getSchemaColumns.spec.ts"],"sourcesContent":["import type { FlattenedField, SanitizedCollectionConfig } from 'payload'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { getSchemaColumns } from './getSchemaColumns.js'\n\nfunction createCollectionConfig(\n flattenedFields: FlattenedField[],\n options?: { timestamps?: boolean; trash?: boolean; versions?: unknown },\n): SanitizedCollectionConfig {\n return {\n flattenedFields,\n timestamps: options?.timestamps ?? true,\n trash: options?.trash ?? false,\n versions: options?.versions,\n } as SanitizedCollectionConfig\n}\n\ndescribe('getSchemaColumns', () => {\n describe('fields from flattenedFields', () => {\n it('should include all fields present in flattenedFields in their natural order', () => {\n const flattenedFields: FlattenedField[] = [\n { name: 'id', type: 'number' },\n { name: 'title', type: 'text' },\n { name: 'createdAt', type: 'date' },\n { name: 'updatedAt', type: 'date' },\n ]\n\n const collectionConfig = createCollectionConfig(flattenedFields)\n const result = getSchemaColumns({ collectionConfig })\n\n expect(result).toEqual(['id', 'title', 'createdAt', 'updatedAt'])\n })\n\n it('should include custom id field when defined in flattenedFields', () => {\n const flattenedFields: FlattenedField[] = [\n { name: 'id', type: 'text' },\n { name: 'title', type: 'text' },\n { name: 'createdAt', type: 'date' },\n { name: 'updatedAt', type: 'date' },\n ]\n\n const collectionConfig = createCollectionConfig(flattenedFields)\n const result = getSchemaColumns({ collectionConfig })\n\n expect(result).toContain('id')\n })\n\n it('should not include createdAt or updatedAt when timestamps disabled (not in flattenedFields)', () => {\n const flattenedFields: FlattenedField[] = [\n { name: 'id', type: 'number' },\n { name: 'title', type: 'text' },\n ]\n\n const collectionConfig = createCollectionConfig(flattenedFields, { timestamps: false })\n const result = getSchemaColumns({ collectionConfig })\n\n expect(result).toContain('id')\n expect(result).toContain('title')\n expect(result).not.toContain('createdAt')\n expect(result).not.toContain('updatedAt')\n })\n\n it('should include deletedAt when present in flattenedFields (trash enabled)', () => {\n const flattenedFields: FlattenedField[] = [\n { name: 'id', type: 'number' },\n { name: 'title', type: 'text' },\n { name: 'createdAt', type: 'date' },\n { name: 'updatedAt', type: 'date' },\n { name: 'deletedAt', type: 'date' },\n ]\n\n const collectionConfig = createCollectionConfig(flattenedFields)\n const result = getSchemaColumns({ collectionConfig })\n\n expect(result).toContain('deletedAt')\n })\n\n it('should add id when missing from flattenedFields (Payload core limitation)', () => {\n const flattenedFields: FlattenedField[] = [\n { name: 'title', type: 'text' },\n { name: 'excerpt', type: 'textarea' },\n { name: 'createdAt', type: 'date' },\n { name: 'updatedAt', type: 'date' },\n ]\n\n const collectionConfig = createCollectionConfig(flattenedFields)\n const result = getSchemaColumns({ collectionConfig })\n\n // id is added because Payload core doesn't add it to flattenedFields\n // but it exists on every document\n expect(result).toContain('id')\n expect(result[0]).toBe('id')\n expect(result).toEqual(['id', 'title', 'excerpt', 'createdAt', 'updatedAt'])\n })\n })\n})\n"],"names":["describe","expect","it","getSchemaColumns","createCollectionConfig","flattenedFields","options","timestamps","trash","versions","name","type","collectionConfig","result","toEqual","toContain","not","toBe"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,gBAAgB,QA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AA;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,kBAAyB,YAAY,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CA6D7F,CAAA"}
1
+ {"version":3,"file":"parseCSV.d.ts","sourceRoot":"","sources":["../../src/utilities/parseCSV.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,kBAAyB,YAAY,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CA8D7F,CAAA"}
@@ -6,6 +6,7 @@ import { parse } from 'csv-parse';
6
6
  return new Promise((resolve, reject)=>{
7
7
  const records = [];
8
8
  const parser = parse({
9
+ bom: true,
9
10
  cast: (value, _context)=>{
10
11
  // Empty strings become undefined to preserve existing data during updates
11
12
  if (value === '') {