@payloadcms/plugin-import-export 4.0.0-internal.4804abd → 4.0.0-internal.4c2ee12

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 (174) hide show
  1. package/dist/components/CollectionField/index.d.ts +3 -2
  2. package/dist/components/CollectionField/index.d.ts.map +1 -1
  3. package/dist/components/CollectionField/index.js.map +1 -1
  4. package/dist/components/ExportListMenuItem/index.d.ts.map +1 -1
  5. package/dist/components/ExportListMenuItem/index.js +14 -12
  6. package/dist/components/ExportListMenuItem/index.js.map +1 -1
  7. package/dist/components/ExportPreview/index.css +0 -3
  8. package/dist/components/ExportPreview/index.d.ts.map +1 -1
  9. package/dist/components/ExportPreview/index.js +11 -1
  10. package/dist/components/ExportPreview/index.js.map +1 -1
  11. package/dist/components/FieldsToExport/index.d.ts +3 -2
  12. package/dist/components/FieldsToExport/index.d.ts.map +1 -1
  13. package/dist/components/FieldsToExport/index.js +18 -15
  14. package/dist/components/FieldsToExport/index.js.map +1 -1
  15. package/dist/components/FieldsToExport/reduceFields.d.ts +6 -0
  16. package/dist/components/FieldsToExport/reduceFields.d.ts.map +1 -1
  17. package/dist/components/FieldsToExport/reduceFields.js +4 -0
  18. package/dist/components/FieldsToExport/reduceFields.js.map +1 -1
  19. package/dist/components/FormatField/index.d.ts +3 -2
  20. package/dist/components/FormatField/index.d.ts.map +1 -1
  21. package/dist/components/FormatField/index.js.map +1 -1
  22. package/dist/components/ImportListMenuItem/index.d.ts.map +1 -1
  23. package/dist/components/ImportListMenuItem/index.js +14 -12
  24. package/dist/components/ImportListMenuItem/index.js.map +1 -1
  25. package/dist/components/ImportPreview/index.css +0 -3
  26. package/dist/components/ImportPreview/index.d.ts.map +1 -1
  27. package/dist/components/ImportPreview/index.js +27 -8
  28. package/dist/components/ImportPreview/index.js.map +1 -1
  29. package/dist/components/LimitField/index.d.ts +3 -2
  30. package/dist/components/LimitField/index.d.ts.map +1 -1
  31. package/dist/components/LimitField/index.js.map +1 -1
  32. package/dist/components/LocaleField/index.d.ts +3 -2
  33. package/dist/components/LocaleField/index.d.ts.map +1 -1
  34. package/dist/components/LocaleField/index.js.map +1 -1
  35. package/dist/components/Page/index.d.ts +3 -2
  36. package/dist/components/Page/index.d.ts.map +1 -1
  37. package/dist/components/Page/index.js.map +1 -1
  38. package/dist/components/RelationshipCell/getRelationshipGroupKey.d.ts +7 -0
  39. package/dist/components/RelationshipCell/getRelationshipGroupKey.d.ts.map +1 -0
  40. package/dist/components/RelationshipCell/getRelationshipGroupKey.js +3 -0
  41. package/dist/components/RelationshipCell/getRelationshipGroupKey.js.map +1 -0
  42. package/dist/components/RelationshipCell/getRelationshipGroups.d.ts +43 -0
  43. package/dist/components/RelationshipCell/getRelationshipGroups.d.ts.map +1 -0
  44. package/dist/components/RelationshipCell/getRelationshipGroups.js +109 -0
  45. package/dist/components/RelationshipCell/getRelationshipGroups.js.map +1 -0
  46. package/dist/components/RelationshipCell/index.css +30 -0
  47. package/dist/components/RelationshipCell/index.d.ts +15 -0
  48. package/dist/components/RelationshipCell/index.d.ts.map +1 -0
  49. package/dist/components/RelationshipCell/index.js +57 -0
  50. package/dist/components/RelationshipCell/index.js.map +1 -0
  51. package/dist/components/SortBy/index.d.ts +3 -2
  52. package/dist/components/SortBy/index.d.ts.map +1 -1
  53. package/dist/components/SortBy/index.js.map +1 -1
  54. package/dist/components/SortOrder/index.d.ts +3 -2
  55. package/dist/components/SortOrder/index.d.ts.map +1 -1
  56. package/dist/components/SortOrder/index.js.map +1 -1
  57. package/dist/export/batchProcessor.d.ts +4 -3
  58. package/dist/export/batchProcessor.d.ts.map +1 -1
  59. package/dist/export/batchProcessor.js +6 -2
  60. package/dist/export/batchProcessor.js.map +1 -1
  61. package/dist/export/createExport.d.ts +4 -2
  62. package/dist/export/createExport.d.ts.map +1 -1
  63. package/dist/export/createExport.js +7 -2
  64. package/dist/export/createExport.js.map +1 -1
  65. package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
  66. package/dist/export/getCreateExportCollectionTask.js +11 -0
  67. package/dist/export/getCreateExportCollectionTask.js.map +1 -1
  68. package/dist/export/getExportCollection.d.ts.map +1 -1
  69. package/dist/export/getExportCollection.js +9 -4
  70. package/dist/export/getExportCollection.js.map +1 -1
  71. package/dist/export/getFields.d.ts.map +1 -1
  72. package/dist/export/handleDownload.d.ts.map +1 -1
  73. package/dist/export/handleDownload.js +7 -3
  74. package/dist/export/handleDownload.js.map +1 -1
  75. package/dist/export/handlePreview.d.ts.map +1 -1
  76. package/dist/export/handlePreview.js +24 -5
  77. package/dist/export/handlePreview.js.map +1 -1
  78. package/dist/exports/types.d.ts +1 -1
  79. package/dist/exports/types.d.ts.map +1 -1
  80. package/dist/exports/types.js.map +1 -1
  81. package/dist/import/batchProcessor.d.ts +4 -3
  82. package/dist/import/batchProcessor.d.ts.map +1 -1
  83. package/dist/import/batchProcessor.js +15 -8
  84. package/dist/import/batchProcessor.js.map +1 -1
  85. package/dist/import/createImport.d.ts +3 -2
  86. package/dist/import/createImport.d.ts.map +1 -1
  87. package/dist/import/createImport.js +8 -1
  88. package/dist/import/createImport.js.map +1 -1
  89. package/dist/import/getCreateImportCollectionTask.d.ts.map +1 -1
  90. package/dist/import/getCreateImportCollectionTask.js +5 -2
  91. package/dist/import/getCreateImportCollectionTask.js.map +1 -1
  92. package/dist/import/getFields.d.ts.map +1 -1
  93. package/dist/import/getImportCollection.d.ts.map +1 -1
  94. package/dist/import/getImportCollection.js +6 -4
  95. package/dist/import/getImportCollection.js.map +1 -1
  96. package/dist/import/handlePreview.d.ts.map +1 -1
  97. package/dist/import/handlePreview.js +5 -1
  98. package/dist/import/handlePreview.js.map +1 -1
  99. package/dist/index.d.ts +1 -2
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +6 -3
  102. package/dist/index.js.map +1 -1
  103. package/dist/translations/languages/en.d.ts.map +1 -1
  104. package/dist/types.d.ts +17 -1
  105. package/dist/types.d.ts.map +1 -1
  106. package/dist/types.js.map +1 -1
  107. package/dist/utilities/applyFieldHooks.d.ts.map +1 -1
  108. package/dist/utilities/buildDisabledFieldRegex.d.ts.map +1 -1
  109. package/dist/utilities/collectDisabledFieldPaths.d.ts.map +1 -1
  110. package/dist/utilities/fieldToRegex.d.ts.map +1 -1
  111. package/dist/utilities/flattenObject.d.ts.map +1 -1
  112. package/dist/utilities/flattenedFields.d.ts.map +1 -1
  113. package/dist/utilities/getExportFieldFunctions.d.ts.map +1 -1
  114. package/dist/utilities/getExportFieldFunctions.js +64 -27
  115. package/dist/utilities/getExportFieldFunctions.js.map +1 -1
  116. package/dist/utilities/getFileFromDoc.d.ts.map +1 -1
  117. package/dist/utilities/getFileFromDoc.js +3 -3
  118. package/dist/utilities/getFileFromDoc.js.map +1 -1
  119. package/dist/utilities/getFlattenedFieldKeys.d.ts.map +1 -1
  120. package/dist/utilities/getImportFieldFunctions.d.ts.map +1 -1
  121. package/dist/utilities/getPluginCollections.d.ts.map +1 -1
  122. package/dist/utilities/getSchemaColumns.d.ts.map +1 -1
  123. package/dist/utilities/getSelect.d.ts.map +1 -1
  124. package/dist/utilities/getSelect.js +11 -3
  125. package/dist/utilities/getSelect.js.map +1 -1
  126. package/dist/utilities/getSubmittedFormValues.d.ts +12 -0
  127. package/dist/utilities/getSubmittedFormValues.d.ts.map +1 -0
  128. package/dist/utilities/getSubmittedFormValues.js +24 -0
  129. package/dist/utilities/getSubmittedFormValues.js.map +1 -0
  130. package/dist/utilities/isPlainObject.d.ts.map +1 -1
  131. package/dist/utilities/parseCSV.d.ts.map +1 -1
  132. package/dist/utilities/parseJSON.d.ts.map +1 -1
  133. package/dist/utilities/polymorphicRel.d.ts.map +1 -1
  134. package/dist/utilities/processRichTextField.d.ts.map +1 -1
  135. package/dist/utilities/removeDisabledFields.d.ts.map +1 -1
  136. package/dist/utilities/setNestedValue.d.ts +2 -1
  137. package/dist/utilities/setNestedValue.d.ts.map +1 -1
  138. package/dist/utilities/setNestedValue.js +65 -34
  139. package/dist/utilities/setNestedValue.js.map +1 -1
  140. package/dist/utilities/sortHelpers.d.ts +1 -1
  141. package/dist/utilities/sortHelpers.d.ts.map +1 -1
  142. package/dist/utilities/unflattenObject.d.ts.map +1 -1
  143. package/dist/utilities/unflattenPostProcess.d.ts.map +1 -1
  144. package/dist/utilities/validateLimitValue.d.ts.map +1 -1
  145. package/license.md +1 -1
  146. package/package.json +9 -9
  147. package/dist/@types/assets.d.js +0 -2
  148. package/dist/@types/assets.d.js.map +0 -1
  149. package/dist/components/FieldsToExport/reduceFields.spec.js +0 -239
  150. package/dist/components/FieldsToExport/reduceFields.spec.js.map +0 -1
  151. package/dist/utilities/applyFieldHooks.spec.js +0 -205
  152. package/dist/utilities/applyFieldHooks.spec.js.map +0 -1
  153. package/dist/utilities/buildDisabledFieldRegex.spec.js +0 -64
  154. package/dist/utilities/buildDisabledFieldRegex.spec.js.map +0 -1
  155. package/dist/utilities/fieldToRegex.spec.js +0 -151
  156. package/dist/utilities/fieldToRegex.spec.js.map +0 -1
  157. package/dist/utilities/filterToSelectedFields.spec.js +0 -204
  158. package/dist/utilities/filterToSelectedFields.spec.js.map +0 -1
  159. package/dist/utilities/flattenObject.spec.js +0 -158
  160. package/dist/utilities/flattenObject.spec.js.map +0 -1
  161. package/dist/utilities/getExportFieldFunctions.spec.js +0 -50
  162. package/dist/utilities/getExportFieldFunctions.spec.js.map +0 -1
  163. package/dist/utilities/getImportFieldFunctions.spec.js +0 -167
  164. package/dist/utilities/getImportFieldFunctions.spec.js.map +0 -1
  165. package/dist/utilities/getSchemaColumns.spec.js +0 -157
  166. package/dist/utilities/getSchemaColumns.spec.js.map +0 -1
  167. package/dist/utilities/parseCSV.spec.js +0 -195
  168. package/dist/utilities/parseCSV.spec.js.map +0 -1
  169. package/dist/utilities/processRichTextField.spec.js +0 -308
  170. package/dist/utilities/processRichTextField.spec.js.map +0 -1
  171. package/dist/utilities/siblingDoc.spec.js +0 -278
  172. package/dist/utilities/siblingDoc.spec.js.map +0 -1
  173. package/dist/utilities/unflattenObject.spec.js +0 -819
  174. package/dist/utilities/unflattenObject.spec.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/import/getImportCollection.ts"],"sourcesContent":["import type { CollectionAfterChangeHook, CollectionConfig } from 'payload'\n\nimport { FileRetrievalError } from 'payload'\n\nimport type { ImportConfig, ImportExportPluginConfig } from '../types.js'\nimport type { ImportTaskInput } from './getCreateImportCollectionTask.js'\n\nimport { getFileFromDoc } from '../utilities/getFileFromDoc.js'\nimport { resolveLimit } from '../utilities/resolveLimit.js'\nimport { createImport } from './createImport.js'\nimport { getFields } from './getFields.js'\nimport { handlePreview } from './handlePreview.js'\n\nconst FALLBACK_BATCH_SIZE = 100\nconst FALLBACK_VERSION_STATUS = 'published'\n\nexport const getImportCollection = ({\n collectionSlugs,\n importConfig,\n pluginConfig,\n}: {\n /**\n * Collection slugs that this import collection supports.\n */\n collectionSlugs: string[]\n importConfig?: ImportConfig\n pluginConfig: ImportExportPluginConfig\n}): CollectionConfig => {\n const afterChange: CollectionAfterChangeHook[] = []\n\n const collection: CollectionConfig = {\n slug: 'imports',\n access: {\n update: () => false,\n },\n admin: {\n components: {\n edit: {\n SaveButton: '@payloadcms/plugin-import-export/rsc#ImportSaveButton',\n },\n },\n custom: {\n 'plugin-import-export': {\n collectionSlugs,\n },\n },\n disableCopyToLocale: true,\n group: false,\n useAsTitle: 'filename',\n },\n disableDuplicate: true,\n endpoints: [\n {\n handler: handlePreview,\n method: 'post',\n path: '/preview-data',\n },\n ],\n fields: getFields({ collectionSlugs }),\n hooks: {\n afterChange,\n },\n lockDocuments: false,\n upload: {\n filesRequiredOnCreate: true,\n hideFileInputOnCreate: false,\n hideRemoveFile: true,\n mimeTypes: ['text/csv', 'application/json'],\n },\n }\n\n afterChange.push(async ({ collection: collectionConfig, doc, operation, req }) => {\n if (operation !== 'create' || doc.status !== 'pending') {\n return doc\n }\n\n const targetCollection = req.payload.collections[doc.collectionSlug]\n const targetPluginConfig = targetCollection?.config.custom?.['plugin-import-export']\n\n const disableJobsQueue =\n targetPluginConfig?.importDisableJobsQueue ?? importConfig?.disableJobsQueue ?? false\n\n const debug = pluginConfig.debug || false\n\n if (debug) {\n req.payload.logger.info({\n collectionSlug: doc.collectionSlug,\n disableJobsQueue,\n docId: doc.id,\n msg: '[Import Sync Hook] Starting',\n transactionID: req.transactionID,\n })\n }\n\n if (!disableJobsQueue) {\n return doc\n }\n\n try {\n // Get file data from the uploaded document\n // First try req.file which is available during the same request (especially important for cloud storage)\n // Fall back to getFileFromDoc for cases where req.file isn't available\n let fileData: Buffer\n let fileMimetype: string\n\n if (req.file?.data) {\n fileData = req.file.data\n fileMimetype = req.file.mimetype || doc.mimeType\n\n if (!fileMimetype) {\n throw new FileRetrievalError(\n req.t,\n `Unable to determine mimetype for file: ${doc.filename}`,\n )\n }\n } else {\n const fileFromDoc = await getFileFromDoc({\n collectionConfig,\n doc: {\n filename: doc.filename,\n mimeType: doc.mimeType,\n url: doc.url,\n },\n req,\n })\n fileData = fileFromDoc.data\n fileMimetype = fileFromDoc.mimetype\n }\n\n const maxLimit = await resolveLimit({\n limit: targetPluginConfig?.importLimit,\n req,\n })\n const defaultVersionStatus =\n targetPluginConfig?.defaultVersionStatus ??\n importConfig?.defaultVersionStatus ??\n pluginConfig.defaultVersionStatus ??\n FALLBACK_VERSION_STATUS\n const batchSize =\n targetPluginConfig?.importBatchSize ??\n importConfig?.batchSize ??\n pluginConfig.batchSize ??\n FALLBACK_BATCH_SIZE\n\n const result = await createImport({\n id: doc.id,\n name: doc.filename || 'import',\n batchSize,\n collectionSlug: doc.collectionSlug,\n debug,\n defaultVersionStatus,\n file: {\n name: doc.filename,\n data: fileData,\n mimetype: fileMimetype,\n },\n format: fileMimetype === 'text/csv' ? 'csv' : 'json',\n importMode: doc.importMode || 'create',\n matchField: doc.matchField,\n maxLimit,\n req,\n userCollection: req?.user?.collection || req?.user?.user?.collection,\n userID: req?.user?.id || req?.user?.user?.id,\n })\n\n // Determine status\n let status: 'completed' | 'failed' | 'partial'\n if (result.errors.length === 0) {\n status = 'completed'\n } else if (result.imported + result.updated === 0) {\n status = 'failed'\n } else {\n status = 'partial'\n }\n\n const summary = {\n imported: result.imported,\n issueDetails:\n result.errors.length > 0\n ? result.errors.map((e) => ({\n data: e.doc,\n error: e.error,\n row: e.index + 1,\n }))\n : undefined,\n issues: result.errors.length,\n total: result.total,\n updated: result.updated,\n }\n\n // Try to update the document with results\n try {\n await req.payload.update({\n id: doc.id,\n collection: collectionConfig.slug,\n data: {\n status,\n summary,\n },\n overrideAccess: true,\n req,\n })\n } catch (updateErr) {\n // Update may fail if document not yet committed\n if (debug) {\n req.payload.logger.error({\n err: updateErr,\n msg: `Failed to update import document ${doc.id} with results`,\n })\n }\n }\n\n // Return updated doc for immediate response\n return {\n ...doc,\n status,\n summary,\n }\n } catch (err) {\n const summary = {\n imported: 0,\n issueDetails: [\n {\n data: {},\n error: err instanceof Error ? err.message : String(err),\n row: 0,\n },\n ],\n issues: 1,\n total: 0,\n updated: 0,\n }\n\n if (debug) {\n req.payload.logger.error({\n docId: doc.id,\n err,\n msg: '[Import Sync Hook] Import processing failed, attempting to update status',\n transactionID: req.transactionID,\n })\n }\n\n // Try to update document with error status\n try {\n if (debug) {\n req.payload.logger.info({\n collectionSlug: collectionConfig.slug,\n docId: doc.id,\n msg: '[Import Sync Hook] About to update document with failed status',\n })\n }\n await req.payload.update({\n id: doc.id,\n collection: collectionConfig.slug,\n data: {\n status: 'failed',\n summary,\n },\n overrideAccess: true,\n req,\n })\n if (debug) {\n req.payload.logger.info({\n docId: doc.id,\n msg: '[Import Sync Hook] Successfully updated document with failed status',\n })\n }\n } catch (updateErr) {\n // Update may fail if document not yet committed, log but continue\n // ALWAYS log this error to help debug Postgres issues\n req.payload.logger.error({\n err: updateErr,\n msg: `[Import Sync Hook] Failed to update import document ${doc.id} with error status`,\n transactionID: req.transactionID,\n })\n }\n\n if (debug) {\n req.payload.logger.info({\n docId: doc.id,\n msg: '[Import Sync Hook] Returning failed doc',\n status: 'failed',\n })\n }\n\n // Return error status for immediate response\n return {\n ...doc,\n status: 'failed',\n summary,\n }\n }\n })\n\n afterChange.push(async ({ collection: collectionConfig, doc, operation, req }) => {\n if (operation !== 'create') {\n return\n }\n\n const targetCollection = req.payload.collections[doc.collectionSlug]\n const targetPluginConfig = targetCollection?.config.custom?.['plugin-import-export']\n\n const disableJobsQueue =\n targetPluginConfig?.importDisableJobsQueue ?? importConfig?.disableJobsQueue ?? false\n\n if (pluginConfig.debug) {\n req.payload.logger.info({\n collectionSlug: doc.collectionSlug,\n disableJobsQueue,\n docId: doc.id,\n docStatus: doc.status,\n msg: '[Import Job Hook] Checking if should queue job',\n transactionID: req.transactionID,\n })\n }\n\n if (disableJobsQueue) {\n if (pluginConfig.debug) {\n req.payload.logger.info({\n docId: doc.id,\n msg: '[Import Job Hook] Skipping job queue (sync mode)',\n })\n }\n return\n }\n\n try {\n // Resolve maxLimit ahead of time since it may involve async config resolution\n const maxLimit = await resolveLimit({\n limit: targetPluginConfig?.importLimit,\n req,\n })\n const defaultVersionStatus =\n targetPluginConfig?.defaultVersionStatus ??\n importConfig?.defaultVersionStatus ??\n pluginConfig.defaultVersionStatus ??\n FALLBACK_VERSION_STATUS\n const batchSize =\n targetPluginConfig?.importBatchSize ??\n importConfig?.batchSize ??\n pluginConfig.batchSize ??\n FALLBACK_BATCH_SIZE\n\n const input: ImportTaskInput = {\n batchSize,\n debug: pluginConfig.debug,\n defaultVersionStatus,\n importCollection: collectionConfig.slug,\n importId: doc.id,\n maxLimit,\n userCollection: req.user?.collection || req?.user?.user?.collection,\n userID: req?.user?.id || req?.user?.user?.id,\n }\n\n await req.payload.jobs.queue({\n input,\n task: 'createCollectionImport',\n })\n } catch (err) {\n req.payload.logger.error({\n err,\n msg: `Failed to queue import job for document ${doc.id}`,\n })\n }\n })\n\n return collection\n}\n"],"names":["FileRetrievalError","getFileFromDoc","resolveLimit","createImport","getFields","handlePreview","FALLBACK_BATCH_SIZE","FALLBACK_VERSION_STATUS","getImportCollection","collectionSlugs","importConfig","pluginConfig","afterChange","collection","slug","access","update","admin","components","edit","SaveButton","custom","disableCopyToLocale","group","useAsTitle","disableDuplicate","endpoints","handler","method","path","fields","hooks","lockDocuments","upload","filesRequiredOnCreate","hideFileInputOnCreate","hideRemoveFile","mimeTypes","push","collectionConfig","doc","operation","req","status","targetCollection","payload","collections","collectionSlug","targetPluginConfig","config","disableJobsQueue","importDisableJobsQueue","debug","logger","info","docId","id","msg","transactionID","fileData","fileMimetype","file","data","mimetype","mimeType","t","filename","fileFromDoc","url","maxLimit","limit","importLimit","defaultVersionStatus","batchSize","importBatchSize","result","name","format","importMode","matchField","userCollection","user","userID","errors","length","imported","updated","summary","issueDetails","map","e","error","row","index","undefined","issues","total","overrideAccess","updateErr","err","Error","message","String","docStatus","input","importCollection","importId","jobs","queue","task"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,UAAS;AAK5C,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,YAAY,QAAQ,+BAA8B;AAC3D,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,aAAa,QAAQ,qBAAoB;AAElD,MAAMC,sBAAsB;AAC5B,MAAMC,0BAA0B;AAEhC,OAAO,MAAMC,sBAAsB,CAAC,EAClCC,eAAe,EACfC,YAAY,EACZC,YAAY,EAQb;IACC,MAAMC,cAA2C,EAAE;IAEnD,MAAMC,aAA+B;QACnCC,MAAM;QACNC,QAAQ;YACNC,QAAQ,IAAM;QAChB;QACAC,OAAO;YACLC,YAAY;gBACVC,MAAM;oBACJC,YAAY;gBACd;YACF;YACAC,QAAQ;gBACN,wBAAwB;oBACtBZ;gBACF;YACF;YACAa,qBAAqB;YACrBC,OAAO;YACPC,YAAY;QACd;QACAC,kBAAkB;QAClBC,WAAW;YACT;gBACEC,SAAStB;gBACTuB,QAAQ;gBACRC,MAAM;YACR;SAC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KAAK,CAAC,wCAAwC,EAAEjB,IAAIgB,EAAE,EAAE;YAC1D;QACF;IACF;IAEA,OAAO3C;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/import/getImportCollection.ts"],"sourcesContent":["import type { CollectionAfterChangeHook, CollectionConfig } from 'payload'\n\nimport { FileRetrievalError } from 'payload'\n\nimport type { ImportConfig, ImportExportPluginConfig } from '../types.js'\nimport type { ImportTaskInput } from './getCreateImportCollectionTask.js'\n\nimport { getFileFromDoc } from '../utilities/getFileFromDoc.js'\nimport { resolveLimit } from '../utilities/resolveLimit.js'\nimport { createImport } from './createImport.js'\nimport { getFields } from './getFields.js'\nimport { handlePreview } from './handlePreview.js'\n\nconst FALLBACK_BATCH_SIZE = 100\nconst FALLBACK_VERSION_STATUS = 'published'\n\nexport const getImportCollection = ({\n collectionSlugs,\n importConfig,\n pluginConfig,\n}: {\n /**\n * Collection slugs that this import collection supports.\n */\n collectionSlugs: string[]\n importConfig?: ImportConfig\n pluginConfig: ImportExportPluginConfig\n}): CollectionConfig => {\n const afterChange: CollectionAfterChangeHook[] = []\n\n const collection: CollectionConfig = {\n slug: 'imports',\n access: {\n update: () => false,\n },\n admin: {\n components: {\n edit: {\n SaveButton: '@payloadcms/plugin-import-export/rsc#ImportSaveButton',\n },\n },\n custom: {\n 'plugin-import-export': {\n collectionSlugs,\n },\n },\n disableCopyToLocale: true,\n group: false,\n useAsTitle: 'filename',\n },\n disableDuplicate: true,\n endpoints: [\n {\n handler: handlePreview,\n method: 'post',\n path: '/preview-data',\n },\n ],\n fields: getFields({ collectionSlugs }),\n hooks: {\n afterChange,\n },\n lockDocuments: false,\n upload: {\n filesRequiredOnCreate: true,\n hideFileInputOnCreate: false,\n hideRemoveFile: true,\n mimeTypes: ['text/csv', 'application/json'],\n },\n }\n\n afterChange.push(async ({ collection: collectionConfig, doc, operation, req }) => {\n if (operation !== 'create' || doc.status !== 'pending') {\n return doc\n }\n\n const targetCollection = req.payload.collections[doc.collectionSlug]\n const targetPluginConfig = targetCollection?.config.custom?.['plugin-import-export']\n\n const disableJobsQueue =\n targetPluginConfig?.importDisableJobsQueue ?? importConfig?.disableJobsQueue ?? false\n\n const debug = pluginConfig.debug || false\n\n if (debug) {\n req.payload.logger.info({\n collectionSlug: doc.collectionSlug,\n disableJobsQueue,\n docId: doc.id,\n msg: '[Import Sync Hook] Starting',\n transactionID: req.transactionID,\n })\n }\n\n if (!disableJobsQueue) {\n return doc\n }\n\n try {\n // Get file data from the uploaded document\n // First try req.file which is available during the same request (especially important for cloud storage)\n // Fall back to getFileFromDoc for cases where req.file isn't available\n let fileData: Buffer\n let fileMimetype: string\n\n if (req.file?.data) {\n fileData = req.file.data\n fileMimetype = req.file.mimetype || doc.mimeType\n\n if (!fileMimetype) {\n throw new FileRetrievalError(\n req.t,\n `Unable to determine mimetype for file: ${doc.filename}`,\n )\n }\n } else {\n const fileFromDoc = await getFileFromDoc({\n collectionConfig,\n doc: {\n filename: doc.filename,\n mimeType: doc.mimeType,\n url: doc.url,\n },\n req,\n })\n fileData = fileFromDoc.data\n fileMimetype = fileFromDoc.mimetype\n }\n\n const maxLimit = await resolveLimit({\n limit: targetPluginConfig?.importLimit,\n req,\n })\n const defaultVersionStatus =\n targetPluginConfig?.defaultVersionStatus ??\n importConfig?.defaultVersionStatus ??\n pluginConfig.defaultVersionStatus ??\n FALLBACK_VERSION_STATUS\n const batchSize =\n targetPluginConfig?.importBatchSize ??\n importConfig?.batchSize ??\n pluginConfig.batchSize ??\n FALLBACK_BATCH_SIZE\n\n const result = await createImport({\n id: doc.id,\n name: doc.filename || 'import',\n batchSize,\n collectionSlug: doc.collectionSlug,\n debug,\n defaultVersionStatus,\n file: {\n name: doc.filename,\n data: fileData,\n mimetype: fileMimetype,\n },\n format: fileMimetype === 'text/csv' ? 'csv' : 'json',\n importDoc: doc,\n importMode: doc.importMode || 'create',\n matchField: doc.matchField,\n maxLimit,\n req,\n userCollection: req?.user?.collection,\n userID: req?.user?.id,\n })\n\n // Determine status\n let status: 'completed' | 'failed' | 'partial'\n if (result.errors.length === 0) {\n status = 'completed'\n } else if (result.imported + result.updated === 0) {\n status = 'failed'\n } else {\n status = 'partial'\n }\n\n const summary = {\n imported: result.imported,\n issueDetails:\n result.errors.length > 0\n ? result.errors.map((e) => ({\n data: e.doc,\n error: e.error,\n row: e.index + 1,\n }))\n : undefined,\n issues: result.errors.length,\n total: result.total,\n updated: result.updated,\n }\n\n // Try to update the document with results\n try {\n await req.payload.update({\n id: doc.id,\n collection: collectionConfig.slug,\n data: {\n status,\n summary,\n },\n overrideAccess: true,\n req,\n })\n } catch (updateErr) {\n // Update may fail if document not yet committed\n if (debug) {\n req.payload.logger.error({\n err: updateErr,\n msg: `Failed to update import document ${doc.id} with results`,\n })\n }\n }\n\n // Return updated doc for immediate response\n return {\n ...doc,\n status,\n summary,\n }\n } catch (err) {\n const summary = {\n imported: 0,\n issueDetails: [\n {\n data: {},\n error: err instanceof Error ? err.message : String(err),\n row: 0,\n },\n ],\n issues: 1,\n total: 0,\n updated: 0,\n }\n\n if (debug) {\n req.payload.logger.error({\n docId: doc.id,\n err,\n msg: '[Import Sync Hook] Import processing failed, attempting to update status',\n transactionID: req.transactionID,\n })\n }\n\n // Try to update document with error status\n try {\n if (debug) {\n req.payload.logger.info({\n collectionSlug: collectionConfig.slug,\n docId: doc.id,\n msg: '[Import Sync Hook] About to update document with failed status',\n })\n }\n await req.payload.update({\n id: doc.id,\n collection: collectionConfig.slug,\n data: {\n status: 'failed',\n summary,\n },\n overrideAccess: true,\n req,\n })\n if (debug) {\n req.payload.logger.info({\n docId: doc.id,\n msg: '[Import Sync Hook] Successfully updated document with failed status',\n })\n }\n } catch (updateErr) {\n // Update may fail if document not yet committed, log but continue\n // ALWAYS log this error to help debug Postgres issues\n req.payload.logger.error({\n err: updateErr,\n msg: `[Import Sync Hook] Failed to update import document ${doc.id} with error status`,\n transactionID: req.transactionID,\n })\n }\n\n if (debug) {\n req.payload.logger.info({\n docId: doc.id,\n msg: '[Import Sync Hook] Returning failed doc',\n status: 'failed',\n })\n }\n\n // Return error status for immediate response\n return {\n ...doc,\n status: 'failed',\n summary,\n }\n }\n })\n\n afterChange.push(async ({ collection: collectionConfig, doc, operation, req }) => {\n if (operation !== 'create') {\n return\n }\n\n const targetCollection = req.payload.collections[doc.collectionSlug]\n const targetPluginConfig = targetCollection?.config.custom?.['plugin-import-export']\n\n const disableJobsQueue =\n targetPluginConfig?.importDisableJobsQueue ?? importConfig?.disableJobsQueue ?? false\n\n if (pluginConfig.debug) {\n req.payload.logger.info({\n collectionSlug: doc.collectionSlug,\n disableJobsQueue,\n docId: doc.id,\n docStatus: doc.status,\n msg: '[Import Job Hook] Checking if should queue job',\n transactionID: req.transactionID,\n })\n }\n\n if (disableJobsQueue) {\n if (pluginConfig.debug) {\n req.payload.logger.info({\n docId: doc.id,\n msg: '[Import Job Hook] Skipping job queue (sync mode)',\n })\n }\n return\n }\n\n try {\n // Resolve maxLimit ahead of time since it may involve async config resolution\n const maxLimit = await resolveLimit({\n limit: targetPluginConfig?.importLimit,\n req,\n })\n const defaultVersionStatus =\n targetPluginConfig?.defaultVersionStatus ??\n importConfig?.defaultVersionStatus ??\n pluginConfig.defaultVersionStatus ??\n FALLBACK_VERSION_STATUS\n const batchSize =\n targetPluginConfig?.importBatchSize ??\n importConfig?.batchSize ??\n pluginConfig.batchSize ??\n FALLBACK_BATCH_SIZE\n\n const input: ImportTaskInput = {\n batchSize,\n debug: pluginConfig.debug,\n defaultVersionStatus,\n importCollection: collectionConfig.slug,\n importId: doc.id,\n maxLimit,\n userCollection: req.user?.collection,\n userID: req?.user?.id,\n }\n\n await req.payload.jobs.queue({\n input,\n overrideAccess: true,\n task: 'createCollectionImport',\n })\n } catch (err) {\n req.payload.logger.error({\n err,\n msg: `Failed to queue import job for document ${doc.id}`,\n })\n }\n })\n\n return collection\n}\n"],"names":["FileRetrievalError","getFileFromDoc","resolveLimit","createImport","getFields","handlePreview","FALLBACK_BATCH_SIZE","FALLBACK_VERSION_STATUS","getImportCollection","collectionSlugs","importConfig","pluginConfig","afterChange","collection","slug","access","update","admin","components","edit","SaveButton","custom","disableCopyToLocale","group","useAsTitle","disableDuplicate","endpoints","handler","method","path","fields","hooks","lockDocuments","upload","filesRequiredOnCreate","hideFileInputOnCreate","hideRemoveFile","mimeTypes","push","collectionConfig","doc","operation","req","status","targetCollection","payload","collections","collectionSlug","targetPluginConfig","config","disableJobsQueue","importDisableJobsQueue","debug","logger","info","docId","id","msg","transactionID","fileData","fileMimetype","file","data","mimetype","mimeType","t","filename","fileFromDoc","url","maxLimit","limit","importLimit","defaultVersionStatus","batchSize","importBatchSize","result","name","format","importDoc","importMode","matchField","userCollection","user","userID","errors","length","imported","updated","summary","issueDetails","map","e","error","row","index","undefined","issues","total","overrideAccess","updateErr","err","Error","message","String","docStatus","input","importCollection","importId","jobs","queue","task"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,UAAS;AAK5C,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,YAAY,QAAQ,+BAA8B;AAC3D,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,aAAa,QAAQ,qBAAoB;AAElD,MAAMC,sBAAsB;AAC5B,MAAMC,0BAA0B;AAEhC,OAAO,MAAMC,sBAAsB,CAAC,EAClCC,eAAe,EACfC,YAAY,EACZC,YAAY,EAQb;IACC,MAAMC,cAA2C,EAAE;IAEnD,MAAMC,aAA+B;QACnCC,MAAM;QACNC,QAAQ;YACNC,QAAQ,IAAM;QAChB;QACAC,OAAO;YACLC,YAAY;gBACVC,MAAM;oBACJC,YAAY;gBACd;YACF;YACAC,QAAQ;gBACN,wBAAwB;oBACtBZ;gBACF;YACF;YACAa,qBAAqB;YACrBC,OAAO;YACPC,YAAY;QACd;QACAC,kBAAkB;QAClBC,WAAW;YACT;gBACEC,SAAStB;gBACTuB,QAAQ;gBACRC,MAAM;YACR;SACD;QACDC,QAAQ1B,UAA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file":"handlePreview.d.ts","sourceRoot":"","sources":["../../src/import/handlePreview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAoB7C,eAAO,MAAM,aAAa,GAAU,KAAK,cAAc,KAAG,OAAO,CAAC,QAAQ,CAuIzE,CAAA"}
1
+ {"version":3,"file":"handlePreview.d.ts","sourceRoot":"","sources":["../../src/import/handlePreview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAqB7C,eAAO,MAAM,aAAa,QAAe,cAAc,KAAG,OAAO,CAAC,QAAQ,CA4IzE,CAAA"}
@@ -2,6 +2,7 @@ import { addDataAndFileToRequest } from 'payload';
2
2
  import { DEFAULT_PREVIEW_LIMIT, MAX_PREVIEW_LIMIT, MIN_PREVIEW_LIMIT, MIN_PREVIEW_PAGE } from '../constants.js';
3
3
  import { applyFieldHooks } from '../utilities/applyFieldHooks.js';
4
4
  import { getImportFieldFunctions } from '../utilities/getImportFieldFunctions.js';
5
+ import { getSubmittedFormValues } from '../utilities/getSubmittedFormValues.js';
5
6
  import { parseCSV } from '../utilities/parseCSV.js';
6
7
  import { parseJSON } from '../utilities/parseJSON.js';
7
8
  import { removeDisabledFields } from '../utilities/removeDisabledFields.js';
@@ -9,7 +10,7 @@ import { resolveLimit } from '../utilities/resolveLimit.js';
9
10
  import { unflattenObject } from '../utilities/unflattenObject.js';
10
11
  export const handlePreview = async (req)=>{
11
12
  await addDataAndFileToRequest(req);
12
- const { collectionSlug, fileData, format, previewLimit: rawPreviewLimit = DEFAULT_PREVIEW_LIMIT, previewPage: rawPreviewPage = 1 } = req.data;
13
+ const { collectionSlug, fileData, format, formData, previewLimit: rawPreviewLimit = DEFAULT_PREVIEW_LIMIT, previewPage: rawPreviewPage = 1 } = req.data;
13
14
  // Validate and clamp pagination values to safe bounds
14
15
  const previewLimit = Math.max(MIN_PREVIEW_LIMIT, Math.min(rawPreviewLimit, MAX_PREVIEW_LIMIT));
15
16
  const previewPage = Math.max(MIN_PREVIEW_PAGE, rawPreviewPage);
@@ -82,6 +83,9 @@ export const handlePreview = async (req)=>{
82
83
  batchNumber: 1,
83
84
  data: parsedData,
84
85
  format: format ?? 'csv',
86
+ importDoc: getSubmittedFormValues({
87
+ formData: formData ?? {}
88
+ }),
85
89
  originalData: originalDocs,
86
90
  req,
87
91
  totalBatches: 1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/import/handlePreview.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport { addDataAndFileToRequest } from 'payload'\n\nimport type { ImportPreviewResponse } from '../types.js'\n\nimport {\n DEFAULT_PREVIEW_LIMIT,\n MAX_PREVIEW_LIMIT,\n MIN_PREVIEW_LIMIT,\n MIN_PREVIEW_PAGE,\n} from '../constants.js'\nimport { applyFieldHooks } from '../utilities/applyFieldHooks.js'\nimport { getImportFieldFunctions } from '../utilities/getImportFieldFunctions.js'\nimport { parseCSV } from '../utilities/parseCSV.js'\nimport { parseJSON } from '../utilities/parseJSON.js'\nimport { removeDisabledFields } from '../utilities/removeDisabledFields.js'\nimport { resolveLimit } from '../utilities/resolveLimit.js'\nimport { unflattenObject } from '../utilities/unflattenObject.js'\n\nexport const handlePreview = async (req: PayloadRequest): Promise<Response> => {\n await addDataAndFileToRequest(req)\n\n const {\n collectionSlug,\n fileData,\n format,\n previewLimit: rawPreviewLimit = DEFAULT_PREVIEW_LIMIT,\n previewPage: rawPreviewPage = 1,\n } = req.data as {\n collectionSlug: string\n fileData?: string\n format?: 'csv' | 'json'\n previewLimit?: number\n previewPage?: number\n }\n\n // Validate and clamp pagination values to safe bounds\n const previewLimit = Math.max(MIN_PREVIEW_LIMIT, Math.min(rawPreviewLimit, MAX_PREVIEW_LIMIT))\n const previewPage = Math.max(MIN_PREVIEW_PAGE, rawPreviewPage)\n\n const targetCollection = req.payload.collections[collectionSlug]\n if (!targetCollection) {\n return Response.json(\n { error: `Collection with slug ${collectionSlug} not found` },\n { status: 400 },\n )\n }\n\n // Resolve max limit from the collection config\n const pluginConfig = targetCollection.config.custom?.['plugin-import-export']\n const maxLimit = await resolveLimit({\n limit: pluginConfig?.importLimit,\n req,\n })\n\n if (!fileData) {\n return Response.json({ error: 'No file data provided' }, { status: 400 })\n }\n\n try {\n // Parse the file data\n let parsedData: Record<string, unknown>[]\n let originalDocs: Record<string, unknown>[] = []\n const buffer = Buffer.from(fileData, 'base64')\n\n const importFieldHooks = getImportFieldFunctions({\n fields: targetCollection.config.flattenedFields || [],\n })\n\n if (format === 'csv') {\n const rawData = await parseCSV({ data: buffer, req })\n originalDocs = rawData\n\n // Unflatten CSV data\n parsedData = rawData\n .map((doc) => {\n const unflattened = unflattenObject({\n data: doc,\n fields: targetCollection.config.flattenedFields ?? [],\n format: 'csv',\n importFieldHooks,\n req,\n })\n return unflattened ?? {}\n })\n .filter((doc) => doc && Object.keys(doc).length > 0)\n } else {\n const parsedDocs = parseJSON({ data: buffer, req })\n originalDocs = parsedDocs\n // Apply field-level import hooks for JSON format\n parsedData = parsedDocs.map((doc) =>\n applyFieldHooks({\n type: 'beforeImport',\n data: doc,\n fieldHooks: importFieldHooks,\n fields: targetCollection.config.flattenedFields ?? [],\n format: 'json',\n operation: 'import',\n req,\n }),\n )\n }\n\n const importHooks = targetCollection.config.custom?.['plugin-import-export']?.importHooks\n if (importHooks?.before && parsedData.length > 0) {\n const result = await importHooks.before({\n batchNumber: 1,\n data: parsedData as unknown as Parameters<typeof importHooks.before>[0]['data'],\n format: format ?? 'csv',\n originalData: originalDocs,\n req,\n totalBatches: 1,\n })\n parsedData = result as unknown as Record<string, unknown>[]\n }\n\n // Remove disabled fields from the documents\n const disabledFields =\n targetCollection.config.admin?.custom?.['plugin-import-export']?.disabledFields ?? []\n\n if (disabledFields.length > 0) {\n parsedData = parsedData.map((doc) => removeDisabledFields(doc, disabledFields))\n }\n\n // Calculate pagination\n const totalDocs = parsedData.length\n const totalPages = totalDocs === 0 ? 0 : Math.ceil(totalDocs / previewLimit)\n const startIndex = (previewPage - 1) * previewLimit\n const endIndex = startIndex + previewLimit\n const paginatedDocs = parsedData.slice(startIndex, endIndex)\n\n const hasNextPage = previewPage < totalPages\n const hasPrevPage = previewPage > 1\n\n // Check if the file exceeds the max limit\n const limitExceeded = typeof maxLimit === 'number' && maxLimit > 0 && totalDocs > maxLimit\n\n const response: ImportPreviewResponse = {\n docs: paginatedDocs,\n hasNextPage,\n hasPrevPage,\n limit: previewLimit,\n limitExceeded,\n maxLimit,\n page: previewPage,\n totalDocs,\n totalPages,\n }\n\n return Response.json(response)\n } catch (error) {\n req.payload.logger.error({ err: error, msg: 'Error parsing import preview data' })\n return Response.json({ error: 'Failed to parse file data' }, { status: 500 })\n }\n}\n"],"names":["addDataAndFileToRequest","DEFAULT_PREVIEW_LIMIT","MAX_PREVIEW_LIMIT","MIN_PREVIEW_LIMIT","MIN_PREVIEW_PAGE","applyFieldHooks","getImportFieldFunctions","parseCSV","parseJSON","removeDisabledFields","resolveLimit","unflattenObject","handlePreview","req","collectionSlug","fileData","format","previewLimit","rawPreviewLimit","previewPage","rawPreviewPage","data","Math","max","min","targetCollection","payload","collections","Response","json","error","status","pluginConfig","config","custom","maxLimit","limit","importLimit","parsedData","originalDocs","buffer","Buffer","from","importFieldHooks","fields","flattenedFields","rawData","map","doc","unflattened","filter","Object","keys","length","parsedDocs","type","fieldHooks","operation","importHooks","before","result","batchNumber","originalData","totalBatches","disabledFields","admin","totalDocs","totalPages","ceil","startIndex","endIndex","paginatedDocs","slice","hasNextPage","hasPrevPage","limitExceeded","response","docs","page","logger","err","msg"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ,UAAS;AAIjD,SACEC,qBAAqB,EACrBC,iBAAiB,EACjBC,iBAAiB,EACjBC,gBAAgB,QACX,kBAAiB;AACxB,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,uBAAuB,QAAQ,0CAAyC;AACjF,SAASC,QAAQ,QAAQ,2BAA0B;AAC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;QACvB,MAAME,YAAY5B,WAAWe,MAAM;QACnC,MAAMc,aAAaD,cAAc,IAAI,IAAI5C,KAAK8C,IAAI,CAACF,YAAYjD;QAC/D,MAAMoD,aAAa,AAAClD,CAAAA,cAAc,CAAA,IAAKF;QACvC,MAAMqD,WAAWD,aAAapD;QAC9B,MAAMsD,gBAAgBjC,WAAWkC,KAAK,CAACH,YAAYC;QAEnD,MAAMG,cAActD,cAAcgD;QAClC,MAAMO,cAAcvD,cAAc;QAElC,0CAA0C;QAC1C,MAAMwD,gBAAgB,OAAOxC,aAAa,YAAYA,WAAW,KAAK+B,YAAY/B;QAElF,MAAMyC,WAAkC;YACtCC,MAAMN;YACNE;YACAC;YACAtC,OAAOnB;YACP0D;YACAxC;YACA2C,MAAM3D;YACN+C;YACAC;QACF;QAEA,OAAOvC,SAASC,IAAI,CAAC+C;IACvB,EAAE,OAAO9C,OAAO;QACdjB,IAAIa,OAAO,CAACqD,MAAM,CAACjD,KAAK,CAAC;YAAEkD,KAAKlD;YAAOmD,KAAK;QAAoC;QAChF,OAAOrD,SAASC,IAAI,CAAC;YAAEC,OAAO;QAA4B,GAAG;YAAEC,QAAQ;QAAI;IAC7E;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/import/handlePreview.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport { addDataAndFileToRequest } from 'payload'\n\nimport type { ImportDoc, ImportPreviewResponse } from '../types.js'\n\nimport {\n DEFAULT_PREVIEW_LIMIT,\n MAX_PREVIEW_LIMIT,\n MIN_PREVIEW_LIMIT,\n MIN_PREVIEW_PAGE,\n} from '../constants.js'\nimport { applyFieldHooks } from '../utilities/applyFieldHooks.js'\nimport { getImportFieldFunctions } from '../utilities/getImportFieldFunctions.js'\nimport { getSubmittedFormValues } from '../utilities/getSubmittedFormValues.js'\nimport { parseCSV } from '../utilities/parseCSV.js'\nimport { parseJSON } from '../utilities/parseJSON.js'\nimport { removeDisabledFields } from '../utilities/removeDisabledFields.js'\nimport { resolveLimit } from '../utilities/resolveLimit.js'\nimport { unflattenObject } from '../utilities/unflattenObject.js'\n\nexport const handlePreview = async (req: PayloadRequest): Promise<Response> => {\n await addDataAndFileToRequest(req)\n\n const {\n collectionSlug,\n fileData,\n format,\n formData,\n previewLimit: rawPreviewLimit = DEFAULT_PREVIEW_LIMIT,\n previewPage: rawPreviewPage = 1,\n } = req.data as {\n collectionSlug: string\n fileData?: string\n format?: 'csv' | 'json'\n formData?: Record<string, unknown>\n previewLimit?: number\n previewPage?: number\n }\n\n // Validate and clamp pagination values to safe bounds\n const previewLimit = Math.max(MIN_PREVIEW_LIMIT, Math.min(rawPreviewLimit, MAX_PREVIEW_LIMIT))\n const previewPage = Math.max(MIN_PREVIEW_PAGE, rawPreviewPage)\n\n const targetCollection = req.payload.collections[collectionSlug]\n if (!targetCollection) {\n return Response.json(\n { error: `Collection with slug ${collectionSlug} not found` },\n { status: 400 },\n )\n }\n\n // Resolve max limit from the collection config\n const pluginConfig = targetCollection.config.custom?.['plugin-import-export']\n const maxLimit = await resolveLimit({\n limit: pluginConfig?.importLimit,\n req,\n })\n\n if (!fileData) {\n return Response.json({ error: 'No file data provided' }, { status: 400 })\n }\n\n try {\n // Parse the file data\n let parsedData: Record<string, unknown>[]\n let originalDocs: Record<string, unknown>[] = []\n const buffer = Buffer.from(fileData, 'base64')\n\n const importFieldHooks = getImportFieldFunctions({\n fields: targetCollection.config.flattenedFields || [],\n })\n\n if (format === 'csv') {\n const rawData = await parseCSV({ data: buffer, req })\n originalDocs = rawData\n\n // Unflatten CSV data\n parsedData = rawData\n .map((doc) => {\n const unflattened = unflattenObject({\n data: doc,\n fields: targetCollection.config.flattenedFields ?? [],\n format: 'csv',\n importFieldHooks,\n req,\n })\n return unflattened ?? {}\n })\n .filter((doc) => doc && Object.keys(doc).length > 0)\n } else {\n const parsedDocs = parseJSON({ data: buffer, req })\n originalDocs = parsedDocs\n // Apply field-level import hooks for JSON format\n parsedData = parsedDocs.map((doc) =>\n applyFieldHooks({\n type: 'beforeImport',\n data: doc,\n fieldHooks: importFieldHooks,\n fields: targetCollection.config.flattenedFields ?? [],\n format: 'json',\n operation: 'import',\n req,\n }),\n )\n }\n\n const importHooks = targetCollection.config.custom?.['plugin-import-export']?.importHooks\n if (importHooks?.before && parsedData.length > 0) {\n const result = await importHooks.before({\n batchNumber: 1,\n data: parsedData as unknown as Parameters<typeof importHooks.before>[0]['data'],\n format: format ?? 'csv',\n importDoc: getSubmittedFormValues({\n formData: formData ?? {},\n }) as ImportDoc,\n originalData: originalDocs,\n req,\n totalBatches: 1,\n })\n parsedData = result as unknown as Record<string, unknown>[]\n }\n\n // Remove disabled fields from the documents\n const disabledFields =\n targetCollection.config.admin?.custom?.['plugin-import-export']?.disabledFields ?? []\n\n if (disabledFields.length > 0) {\n parsedData = parsedData.map((doc) => removeDisabledFields(doc, disabledFields))\n }\n\n // Calculate pagination\n const totalDocs = parsedData.length\n const totalPages = totalDocs === 0 ? 0 : Math.ceil(totalDocs / previewLimit)\n const startIndex = (previewPage - 1) * previewLimit\n const endIndex = startIndex + previewLimit\n const paginatedDocs = parsedData.slice(startIndex, endIndex)\n\n const hasNextPage = previewPage < totalPages\n const hasPrevPage = previewPage > 1\n\n // Check if the file exceeds the max limit\n const limitExceeded = typeof maxLimit === 'number' && maxLimit > 0 && totalDocs > maxLimit\n\n const response: ImportPreviewResponse = {\n docs: paginatedDocs,\n hasNextPage,\n hasPrevPage,\n limit: previewLimit,\n limitExceeded,\n maxLimit,\n page: previewPage,\n totalDocs,\n totalPages,\n }\n\n return Response.json(response)\n } catch (error) {\n req.payload.logger.error({ err: error, msg: 'Error parsing import preview data' })\n return Response.json({ error: 'Failed to parse file data' }, { status: 500 })\n }\n}\n"],"names":["addDataAndFileToRequest","DEFAULT_PREVIEW_LIMIT","MAX_PREVIEW_LIMIT","MIN_PREVIEW_LIMIT","MIN_PREVIEW_PAGE","applyFieldHooks","getImportFieldFunctions","getSubmittedFormValues","parseCSV","parseJSON","removeDisabledFields","resolveLimit","unflattenObject","handlePreview","req","collectionSlug","fileData","format","formData","previewLimit","rawPreviewLimit","previewPage","rawPreviewPage","data","Math","max","min","targetCollection","payload","collections","Response","json","error","status","pluginConfig","config","custom","maxLimit","limit","importLimit","parsedData","originalDocs","buffer","Buffer","from","importFieldHooks","fields","flattenedFields","rawData","map","doc","unflattened","filter","Object","keys","length","parsedDocs","type","fieldHooks","operation","importHooks","before","result","batchNumber","importDoc","originalData","totalBatches","disabledFields","admin","totalDocs","totalPages","ceil","startIndex","endIndex","paginatedDocs","slice","hasNextPage","hasPrevPage","limitExceeded","response","docs","page","logger","err","msg"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ,UAAS;AAIjD,SACEC,qBAAqB,EACrBC,iBAAiB,EACjBC,iBAAiB,EACjBC,gBAAgB,QACX,kBAAiB;AACxB,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,uBAAuB,QAAQ,0CAAyC;AACjF,SAASC,sBAAsB,QAAQ,yCAAwC;AAC/E,SAASC,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,SAAS,QAAQ,4BAA2B;AACrD,SAASC,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,YAAY,QAAQ,+BAA8B;AAC3D,SAASC,eAAe,QAAQ,kCAAiC;AAEjE,OAAO,MAAMC,gBAAgB,OAAOC;IAClC,MAAMd,wBAAwBc;IAE9B,MAAM,EACJC,cAAc,EACdC,QAAQ,EACRC,MAAM,EACNC,QAAQ,EACRC,cAAcC,kBAAkBnB,qBAAqB,EACrDoB,aAAaC,iBAAiB,CAAC,EAChC,GAAGR,IAAIS,IAAI;IASZ,sDAAsD;IACtD,MAAMJ,eAAeK,KAAKC,GAAG,CAACtB,mBAAmBqB,KAAKE,GAAG,CAACN,iBAAiBlB;IAC3E,MAAMmB,cAAcG,KAAKC,GAAG,CAACrB,kBAAkBkB;IAE/C,MAAMK,mBAAmBb,IAAIc,OAAO,CAACC,WAAW,CAACd,eAAe;IAChE,IAAI,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,OAAOxC,SAASC,IAAI,CAACgD;IACvB,EAAE,OAAO/C,OAAO;QACdlB,IAAIc,OAAO,CAACsD,MAAM,CAAClD,KAAK,CAAC;YAAEmD,KAAKnD;YAAOoD,KAAK;QAAoC;QAChF,OAAOtD,SAASC,IAAI,CAAC;YAAEC,OAAO;QAA4B,GAAG;YAAEC,QAAQ;QAAI;IAC7E;AACF,EAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { Config } from 'payload';
2
1
  import type { ExportAfterHook, ExportBeforeHook, FieldBeforeExportHook, FieldBeforeImportHook, ImportAfterHook, ImportBeforeHook, ImportExportPluginConfig, Limit } from './types.js';
3
2
  /**
4
3
  * Adds CSV/JSON import and export functionality to selected collections.
@@ -10,7 +9,7 @@ import type { ExportAfterHook, ExportBeforeHook, FieldBeforeExportHook, FieldBef
10
9
  *
11
10
  * @see https://payloadcms.com/docs/plugins/import-export
12
11
  */
13
- export declare const importExportPlugin: (pluginConfig: ImportExportPluginConfig) => (config: Config) => Promise<Config>;
12
+ export declare const importExportPlugin: (options: ImportExportPluginConfig) => import("payload").Plugin;
14
13
  declare module 'payload' {
15
14
  interface FieldCustom {
16
15
  'plugin-import-export'?: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAKrC,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,KAAK,EAEN,MAAM,YAAY,CAAA;AAQnB;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAC5B,cAAc,wBAAwB,MAChC,QAAQ,MAAM,KAAG,OAAO,CAAC,MAAM,CAsMrC,CAAA;AAEH,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAiB,WAAW;QAC1B,sBAAsB,CAAC,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AE;gBAAE,KAAK,CAAC,EAAE,eAAe,CAAC;gBAAC,MAAM,CAAC,EAAE,gBAAgB,CAAA;aAAE,CAAA;YACpE;;;;eAIG;YACH,WAAW,CAAC,EAAE,KAAK,CAAA;YACnB;;;eAGG;YACH,eAAe,CAAC,EAAE,MAAM,CAAA;YACxB;;;eAGG;YACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;YAChC;;;eAGG;YACH,WAAW,CAAC,EAAE;gBAAE,KAAK,CAAC,EAAE,eAAe,CAAC;gBAAC,MAAM,CAAC,EAAE,gBAAgB,CAAA;aAAE,CAAA;YACpE;;;;eAIG;YACH,WAAW,CAAC,EAAE,KAAK,CAAA;SACpB,CAAA;KACF;CACF"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { deepMergeSimple } from 'payload';
1
+ import { deepMergeSimple, definePlugin } from 'payload';
2
2
  import { getCreateCollectionExportTask } from './export/getCreateExportCollectionTask.js';
3
3
  import { getCreateCollectionImportTask } from './import/getCreateImportCollectionTask.js';
4
4
  import { translations } from './translations/index.js';
@@ -13,7 +13,9 @@ import { getPluginCollections } from './utilities/getPluginCollections.js';
13
13
  * format, lifecycle hooks, override) live on each entry of `collections`.
14
14
  *
15
15
  * @see https://payloadcms.com/docs/plugins/import-export
16
- */ export const importExportPlugin = (pluginConfig)=>async (config)=>{
16
+ */ export const importExportPlugin = definePlugin({
17
+ slug: '@payloadcms/plugin-import-export',
18
+ plugin: async ({ config, options: pluginConfig })=>{
17
19
  // Get all export/import collections and the mappings from target collections to custom collections
18
20
  const { customExportSlugMap, customImportSlugMap, exportCollections, importCollections } = await getPluginCollections({
19
21
  config,
@@ -189,6 +191,7 @@ import { getPluginCollections } from './utilities/getPluginCollections.js';
189
191
  translations: deepMergeSimple(simplifiedTranslations, config.i18n?.translations ?? {})
190
192
  };
191
193
  return config;
192
- };
194
+ }
195
+ });
193
196
 
194
197
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload'\n\nimport { deepMergeSimple } from 'payload'\n\nimport type { PluginDefaultTranslationsObject } from './translations/types.js'\nimport type {\n ExportAfterHook,\n ExportBeforeHook,\n FieldBeforeExportHook,\n FieldBeforeImportHook,\n ImportAfterHook,\n ImportBeforeHook,\n ImportExportPluginConfig,\n Limit,\n PluginCollectionConfig,\n} from './types.js'\n\nimport { getCreateCollectionExportTask } from './export/getCreateExportCollectionTask.js'\nimport { getCreateCollectionImportTask } from './import/getCreateImportCollectionTask.js'\nimport { translations } from './translations/index.js'\nimport { collectDisabledFieldPaths } from './utilities/collectDisabledFieldPaths.js'\nimport { getPluginCollections } from './utilities/getPluginCollections.js'\n\n/**\n * Adds CSV/JSON import and export functionality to selected collections.\n *\n * Registers two upload collections (`exports`, `imports`) that drive the admin\n * UI flow, plus the `createCollectionExport` and `createCollectionImport` jobs\n * that run the work asynchronously. Per-collection settings (batch size, limits,\n * format, lifecycle hooks, override) live on each entry of `collections`.\n *\n * @see https://payloadcms.com/docs/plugins/import-export\n */\nexport const importExportPlugin =\n (pluginConfig: ImportExportPluginConfig) =>\n async (config: Config): Promise<Config> => {\n // Get all export/import collections and the mappings from target collections to custom collections\n const { customExportSlugMap, customImportSlugMap, exportCollections, importCollections } =\n await getPluginCollections({\n config,\n pluginConfig,\n })\n\n // Base collections are at index 0 (always present)\n const baseExportCollection = exportCollections[0]!\n const baseImportCollection = importCollections[0]!\n\n // Collect all export and import collection slugs for filtering\n const allExportSlugs = new Set(exportCollections.map((c) => c.slug))\n const allImportSlugs = new Set(importCollections.map((c) => c.slug))\n\n // Initialize collections array if needed\n if (!config.collections) {\n config.collections = []\n }\n\n // Push all export/import collections if their slugs don't already exist\n for (const collection of [...exportCollections, ...importCollections]) {\n const slugExists = config.collections.some((c) => c.slug === collection.slug)\n if (!slugExists) {\n config.collections.push(collection)\n }\n }\n\n // inject custom import export provider\n config.admin = config.admin || {}\n config.admin.components = config.admin.components || {}\n config.admin.components.providers = config.admin.components.providers || []\n config.admin.components.providers.push(\n '@payloadcms/plugin-import-export/rsc#ImportExportProvider',\n )\n\n // inject the createExport and createImport jobs into the config\n ;((config.jobs ??= {}).tasks ??= []).push(getCreateCollectionExportTask(config))\n config.jobs.tasks.push(getCreateCollectionImportTask(config))\n\n // Build a map of collection configs for quick lookup\n const collectionConfigMap = new Map<string, PluginCollectionConfig>()\n if (pluginConfig.collections) {\n for (const collectionConfig of pluginConfig.collections) {\n collectionConfigMap.set(collectionConfig.slug, collectionConfig)\n }\n }\n\n // Determine which collections to add import/export menu items to\n // Exclude all export and import collections\n const collectionsToUpdate = config.collections.filter(\n (c) => !allExportSlugs.has(c.slug) && !allImportSlugs.has(c.slug),\n )\n\n for (const collection of collectionsToUpdate) {\n // Get the plugin config for this collection (if specified)\n const collectionPluginConfig = collectionConfigMap.get(collection.slug)\n\n // If collections array is specified but this collection is not in it, skip\n if (\n pluginConfig.collections &&\n pluginConfig.collections.length > 0 &&\n !collectionPluginConfig\n ) {\n continue\n }\n\n // Determine which export/import collection to use for this collection\n const exportSlugForCollection =\n customExportSlugMap.get(collection.slug) || baseExportCollection.slug\n const importSlugForCollection =\n customImportSlugMap.get(collection.slug) || baseImportCollection.slug\n\n // Check if export/import are disabled for this collection\n const exportDisabled = collectionPluginConfig?.export === false\n const importDisabled = collectionPluginConfig?.import === false\n\n if (!collection.admin) {\n collection.admin = { components: { listMenuItems: [] } }\n }\n const components = collection.admin.components || {}\n if (!components.listMenuItems) {\n components.listMenuItems = []\n }\n\n // Add export menu item if not disabled\n if (!exportDisabled) {\n components.listMenuItems.push({\n clientProps: {\n collectionSlug: collection.slug,\n exportCollectionSlug: exportSlugForCollection,\n },\n path: '@payloadcms/plugin-import-export/rsc#ExportListMenuItem',\n })\n }\n\n // Add import menu item if not disabled\n if (!importDisabled) {\n components.listMenuItems.push({\n clientProps: {\n collectionSlug: collection.slug,\n importCollectionSlug: importSlugForCollection,\n },\n path: '@payloadcms/plugin-import-export/rsc#ImportListMenuItem',\n })\n }\n\n // Find fields explicitly marked as disabled for import/export\n const disabledFieldAccessors = collectDisabledFieldPaths(collection.fields)\n\n const exportConfig =\n typeof collectionPluginConfig?.export === 'object'\n ? collectionPluginConfig.export\n : undefined\n const exportFormat = exportConfig?.format\n const exportDisableJobsQueue = exportConfig?.disableJobsQueue\n const exportBatchSize = exportConfig?.batchSize\n const exportDisableSave = exportConfig?.disableSave\n const exportDisableDownload = exportConfig?.disableDownload\n\n const importConfig =\n typeof collectionPluginConfig?.import === 'object'\n ? collectionPluginConfig.import\n : undefined\n const importDisableJobsQueue = importConfig?.disableJobsQueue\n const importBatchSize = importConfig?.batchSize\n\n const exportLimit = exportConfig?.limit ?? pluginConfig.exportLimit\n const exportHooks = exportConfig?.hooks\n\n const importLimit = importConfig?.limit ?? pluginConfig.importLimit\n const importDefaultVersionStatus = importConfig?.defaultVersionStatus\n const importHooks = importConfig?.hooks\n\n collection.admin.custom = {\n ...(collection.admin.custom || {}),\n 'plugin-import-export': {\n ...(collection.admin.custom?.['plugin-import-export'] || {}),\n disabledFields: disabledFieldAccessors,\n ...(exportFormat !== undefined && { exportFormat }),\n ...(exportDisableSave !== undefined && { disableSave: exportDisableSave }),\n ...(exportDisableDownload !== undefined && { disableDownload: exportDisableDownload }),\n },\n }\n\n collection.custom = {\n ...(collection.custom || {}),\n 'plugin-import-export': {\n ...(collection.custom?.['plugin-import-export'] || {}),\n ...(exportLimit !== undefined && { exportLimit }),\n ...(exportDisableJobsQueue !== undefined && {\n exportDisableJobsQueue,\n }),\n ...(exportBatchSize !== undefined && { exportBatchSize }),\n ...(importLimit !== undefined && { importLimit }),\n ...(importDisableJobsQueue !== undefined && {\n importDisableJobsQueue,\n }),\n ...(importBatchSize !== undefined && { importBatchSize }),\n ...(importDefaultVersionStatus !== undefined && {\n defaultVersionStatus: importDefaultVersionStatus,\n }),\n ...(exportHooks !== undefined && { exportHooks }),\n ...(importHooks !== undefined && { importHooks }),\n },\n }\n\n collection.admin.components = components\n }\n\n if (!config.i18n) {\n config.i18n = {}\n }\n\n /**\n * Merge plugin translations — only for languages the user has enabled.\n * Plugins run before sanitize, so `supportedLanguages` may be undefined; sanitize will\n * default it to `{ en }`, so we mirror that here to avoid merging 30+ unused tables.\n */\n const supportedLanguageKeys = config.i18n?.supportedLanguages\n ? Object.keys(config.i18n.supportedLanguages)\n : ['en']\n\n const simplifiedTranslations: Record<string, PluginDefaultTranslationsObject> = {}\n for (const lang of supportedLanguageKeys) {\n const entry = translations[lang as keyof typeof translations]\n if (entry) {\n simplifiedTranslations[lang] = entry.translations\n }\n }\n\n config.i18n = {\n ...config.i18n,\n translations: deepMergeSimple(simplifiedTranslations, config.i18n?.translations ?? {}),\n }\n\n return config\n }\n\ndeclare module 'payload' {\n export interface FieldCustom {\n 'plugin-import-export'?: {\n /**\n * When `true` the field is **completely excluded** from the import-export plugin:\n * - It will not appear in the \"Fields to export\" selector.\n * - It is hidden from the preview list when no specific fields are chosen.\n * - Its data is omitted from the final CSV / JSON export.\n * @default false\n */\n disabled?: boolean\n /**\n * Field-level lifecycle hooks for import/export transformations.\n * Works for both CSV and JSON formats.\n */\n hooks?: {\n /**\n * Runs before a field value is exported. Return a transformed value,\n * `undefined` to use default behavior, or mutate `siblingData` to add\n * extra columns at the same level.\n */\n beforeExport?: FieldBeforeExportHook\n /**\n * Runs before a field value is imported. Return the transformed value.\n */\n beforeImport?: FieldBeforeImportHook\n }\n }\n }\n\n export interface CollectionAdminCustom {\n 'plugin-import-export'?: {\n /**\n * Array of collection slugs that this export/import collection can target.\n * Used by CollectionField to populate the dropdown options.\n */\n collectionSlugs?: string[]\n /**\n * Array of field paths that are disabled for import/export.\n * These paths are collected from fields marked with `custom['plugin-import-export'].disabled = true`.\n */\n disabledFields?: string[]\n /**\n * If true, disables the download button in the export preview UI.\n */\n disableDownload?: boolean\n /**\n * If true, disables the save button in the export preview UI.\n */\n disableSave?: boolean\n /**\n * When set, forces exports from this collection to use this format.\n * This value is read from the plugin config's `export.format` option.\n */\n exportFormat?: 'csv' | 'json'\n }\n }\n\n export interface CollectionCustom {\n /**\n * @internal\n * Server-side storage for resolved plugin config. Users should configure\n * import/export via `importExportPlugin({ collections: [{ slug, export: { ... }, import: { ... } }] })`.\n * These fields are populated automatically and are not part of the public\n * API — the names here intentionally diverge from the user-facing nested\n * `export.hooks` / `import.hooks` config and may change without notice.\n */\n 'plugin-import-export'?: {\n /**\n * @internal Default version status for imported documents when _status field is not provided.\n * Only applies to collections with versions enabled.\n * @default 'published'\n */\n defaultVersionStatus?: 'draft' | 'published'\n /**\n * Number of documents to process in each batch during export.\n * @default 100\n */\n exportBatchSize?: number\n /**\n * If true, disables the jobs queue for exports and runs them synchronously.\n * @default false\n */\n exportDisableJobsQueue?: boolean\n /**\n * Lifecycle hooks for export operations. Stored server-side since functions\n * cannot be serialized to the client.\n */\n exportHooks?: { after?: ExportAfterHook; before?: ExportBeforeHook }\n /**\n * Maximum number of documents that can be exported from this collection.\n * Set to 0 for unlimited (default). Can be a number or function.\n * Stored in collection.custom (server-only) since functions cannot be serialized to client.\n */\n exportLimit?: Limit\n /**\n * Number of documents to process in each batch during import.\n * @default 100\n */\n importBatchSize?: number\n /**\n * If true, disables the jobs queue for imports and runs them synchronously.\n * @default false\n */\n importDisableJobsQueue?: boolean\n /**\n * Lifecycle hooks for import operations. Stored server-side since functions\n * cannot be serialized to the client.\n */\n importHooks?: { after?: ImportAfterHook; before?: ImportBeforeHook }\n /**\n * Maximum number of documents that can be imported to this collection.\n * Set to 0 for unlimited (default). Can be a number or function.\n * Stored in collection.custom (server-only) since functions cannot be serialized to client.\n */\n importLimit?: Limit\n }\n }\n}\n"],"names":["deepMergeSimple","getCreateCollectionExportTask","getCreateCollectionImportTask","translations","collectDisabledFieldPaths","getPluginCollections","importExportPlugin","pluginConfig","config","customExportSlugMap","customImportSlugMap","exportCollections","importCollections","baseExportCollection","baseImportCollection","allExportSlugs","Set","map","c","slug","allImportSlugs","collections","collection","slugExists","some","push","admin","components","providers","jobs","tasks","collectionConfigMap","Map","collectionConfig","set","collectionsToUpdate","filter","has","collectionPluginConfig","get","length","exportSlugForCollection","importSlugForCollection","exportDisabled","export","importDisabled","import","listMenuItems","clientProps","collectionSlug","exportCollectionSlug","path","importCollectionSlug","disabledFieldAccessors","fields","exportConfig","undefined","exportFormat","format","exportDisableJobsQueue","disableJobsQueue","exportBatchSize","batchSize","exportDisableSave","disableSave","exportDisableDownload","disableDownload","importConfig","importDisableJobsQueue","importBatchSize","exportLimit","limit","exportHooks","hooks","importLimit","importDefaultVersionStatus","defaultVersionStatus","importHooks","custom","disabledFields","i18n","supportedLanguageKeys","supportedLanguages","Object","keys","simplifiedTranslations","lang","entry"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AAezC,SAASC,6BAA6B,QAAQ,4CAA2C;AACzF,SAASC,6BAA6B,QAAQ,4CAA2C;AACzF,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,oBAAoB,QAAQ,sCAAqC;AAE1E;;;;;;;;;CASC,GACD,OAAO,MAAMC,qBACX,CAACC,eACD,OAAOC;QACL,mGAAmG;QACnG,MAAM,EAAEC,mBAAmB,EAAEC,mBAAmB,EAAEC,iBAAiB,EAAEC,iBAAiB,EAAE,GACtF,MAAMP,qBAAqB;YACzBG;YACAD;QACF;QAEF,mDAAmD;QACnD,MAAMM,uBAAuBF,iBAAiB,CAAC,EAAE;QACjD,MAAMG,uBAAuBF,iBAAiB,CAAC,EAAE;QAEjD,+DAA+D;QAC/D,MAAMG,iBAAiB,IAAIC,IAAIL,kBAAkBM,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI;QAClE,MAAMC,iBAAiB,IAAIJ,IAAIJ,kBAAkBK,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI;QAElE,yCAAyC;QACzC,IAAI,CAACX,OAAOa,WAAW,EAAE;YACvBb,OAAOa,WAAW,GAA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1CY;oBACF,CAAC;oBACD,GAAIC,oBAAoBb,aAAa;wBAAEa;oBAAgB,CAAC;oBACxD,GAAIM,+BAA+BnB,aAAa;wBAC9CoB,sBAAsBD;oBACxB,CAAC;oBACD,GAAIH,gBAAgBhB,aAAa;wBAAEgB;oBAAY,CAAC;oBAChD,GAAIK,gBAAgBrB,aAAa;wBAAEqB;oBAAY,CAAC;gBAClD;YACF;YAEAvD,WAAWI,KAAK,CAACC,UAAU,GAAGA;QAChC;QAEA,IAAI,CAACnB,OAAOwE,IAAI,EAAE;YAChBxE,OAAOwE,IAAI,GAAG,CAAC;QACjB;QAEA;;;;KAIC,GACD,MAAMC,wBAAwBzE,OAAOwE,IAAI,EAAEE,qBACvCC,OAAOC,IAAI,CAAC5E,OAAOwE,IAAI,CAACE,kBAAkB,IAC1C;YAAC;SAAK;QAEV,MAAMG,yBAA0E,CAAC;QACjF,KAAK,MAAMC,QAAQL,sBAAuB;YACxC,MAAMM,QAAQpF,YAAY,CAACmF,KAAkC;YAC7D,IAAIC,OAAO;gBACTF,sBAAsB,CAACC,KAAK,GAAGC,MAAMpF,YAAY;YACnD;QACF;QAEAK,OAAOwE,IAAI,GAAG;YACZ,GAAGxE,OAAOwE,IAAI;YACd7E,cAAcH,gBAAgBqF,wBAAwB7E,OAAOwE,IAAI,EAAE7E,gBAAgB,CAAC;QACtF;QAEA,OAAOK;IACT,EAAC"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { deepMergeSimple, definePlugin } from 'payload'\n\nimport type { PluginDefaultTranslationsObject } from './translations/types.js'\nimport type {\n ExportAfterHook,\n ExportBeforeHook,\n FieldBeforeExportHook,\n FieldBeforeImportHook,\n ImportAfterHook,\n ImportBeforeHook,\n ImportExportPluginConfig,\n Limit,\n PluginCollectionConfig,\n} from './types.js'\n\nimport { getCreateCollectionExportTask } from './export/getCreateExportCollectionTask.js'\nimport { getCreateCollectionImportTask } from './import/getCreateImportCollectionTask.js'\nimport { translations } from './translations/index.js'\nimport { collectDisabledFieldPaths } from './utilities/collectDisabledFieldPaths.js'\nimport { getPluginCollections } from './utilities/getPluginCollections.js'\n\n/**\n * Adds CSV/JSON import and export functionality to selected collections.\n *\n * Registers two upload collections (`exports`, `imports`) that drive the admin\n * UI flow, plus the `createCollectionExport` and `createCollectionImport` jobs\n * that run the work asynchronously. Per-collection settings (batch size, limits,\n * format, lifecycle hooks, override) live on each entry of `collections`.\n *\n * @see https://payloadcms.com/docs/plugins/import-export\n */\nexport const importExportPlugin = definePlugin<ImportExportPluginConfig>({\n slug: '@payloadcms/plugin-import-export',\n plugin: async ({ config, options: pluginConfig }) => {\n // Get all export/import collections and the mappings from target collections to custom collections\n const { customExportSlugMap, customImportSlugMap, exportCollections, importCollections } =\n await getPluginCollections({\n config,\n pluginConfig,\n })\n\n // Base collections are at index 0 (always present)\n const baseExportCollection = exportCollections[0]!\n const baseImportCollection = importCollections[0]!\n\n // Collect all export and import collection slugs for filtering\n const allExportSlugs = new Set(exportCollections.map((c) => c.slug))\n const allImportSlugs = new Set(importCollections.map((c) => c.slug))\n\n // Initialize collections array if needed\n if (!config.collections) {\n config.collections = []\n }\n\n // Push all export/import collections if their slugs don't already exist\n for (const collection of [...exportCollections, ...importCollections]) {\n const slugExists = config.collections.some((c) => c.slug === collection.slug)\n if (!slugExists) {\n config.collections.push(collection)\n }\n }\n\n // inject custom import export provider\n config.admin = config.admin || {}\n config.admin.components = config.admin.components || {}\n config.admin.components.providers = config.admin.components.providers || []\n config.admin.components.providers.push(\n '@payloadcms/plugin-import-export/rsc#ImportExportProvider',\n )\n\n // inject the createExport and createImport jobs into the config\n ;((config.jobs ??= {}).tasks ??= []).push(getCreateCollectionExportTask(config))\n config.jobs.tasks.push(getCreateCollectionImportTask(config))\n\n // Build a map of collection configs for quick lookup\n const collectionConfigMap = new Map<string, PluginCollectionConfig>()\n if (pluginConfig.collections) {\n for (const collectionConfig of pluginConfig.collections) {\n collectionConfigMap.set(collectionConfig.slug, collectionConfig)\n }\n }\n\n // Determine which collections to add import/export menu items to\n // Exclude all export and import collections\n const collectionsToUpdate = config.collections.filter(\n (c) => !allExportSlugs.has(c.slug) && !allImportSlugs.has(c.slug),\n )\n\n for (const collection of collectionsToUpdate) {\n // Get the plugin config for this collection (if specified)\n const collectionPluginConfig = collectionConfigMap.get(collection.slug)\n\n // If collections array is specified but this collection is not in it, skip\n if (\n pluginConfig.collections &&\n pluginConfig.collections.length > 0 &&\n !collectionPluginConfig\n ) {\n continue\n }\n\n // Determine which export/import collection to use for this collection\n const exportSlugForCollection =\n customExportSlugMap.get(collection.slug) || baseExportCollection.slug\n const importSlugForCollection =\n customImportSlugMap.get(collection.slug) || baseImportCollection.slug\n\n // Check if export/import are disabled for this collection\n const exportDisabled = collectionPluginConfig?.export === false\n const importDisabled = collectionPluginConfig?.import === false\n\n if (!collection.admin) {\n collection.admin = { components: { listMenuItems: [] } }\n }\n const components = collection.admin.components || {}\n if (!components.listMenuItems) {\n components.listMenuItems = []\n }\n\n // Add export menu item if not disabled\n if (!exportDisabled) {\n components.listMenuItems.push({\n clientProps: {\n collectionSlug: collection.slug,\n exportCollectionSlug: exportSlugForCollection,\n },\n path: '@payloadcms/plugin-import-export/rsc#ExportListMenuItem',\n })\n }\n\n // Add import menu item if not disabled\n if (!importDisabled) {\n components.listMenuItems.push({\n clientProps: {\n collectionSlug: collection.slug,\n importCollectionSlug: importSlugForCollection,\n },\n path: '@payloadcms/plugin-import-export/rsc#ImportListMenuItem',\n })\n }\n\n // Find fields explicitly marked as disabled for import/export\n const disabledFieldAccessors = collectDisabledFieldPaths(collection.fields)\n\n const exportConfig =\n typeof collectionPluginConfig?.export === 'object'\n ? collectionPluginConfig.export\n : undefined\n const exportFormat = exportConfig?.format\n const exportDisableJobsQueue = exportConfig?.disableJobsQueue\n const exportBatchSize = exportConfig?.batchSize\n const exportDisableSave = exportConfig?.disableSave\n const exportDisableDownload = exportConfig?.disableDownload\n\n const importConfig =\n typeof collectionPluginConfig?.import === 'object'\n ? collectionPluginConfig.import\n : undefined\n const importDisableJobsQueue = importConfig?.disableJobsQueue\n const importBatchSize = importConfig?.batchSize\n\n const exportLimit = exportConfig?.limit ?? pluginConfig.exportLimit\n const exportHooks = exportConfig?.hooks\n\n const importLimit = importConfig?.limit ?? pluginConfig.importLimit\n const importDefaultVersionStatus = importConfig?.defaultVersionStatus\n const importHooks = importConfig?.hooks\n\n collection.admin.custom = {\n ...(collection.admin.custom || {}),\n 'plugin-import-export': {\n ...(collection.admin.custom?.['plugin-import-export'] || {}),\n disabledFields: disabledFieldAccessors,\n ...(exportFormat !== undefined && { exportFormat }),\n ...(exportDisableSave !== undefined && { disableSave: exportDisableSave }),\n ...(exportDisableDownload !== undefined && { disableDownload: exportDisableDownload }),\n },\n }\n\n collection.custom = {\n ...(collection.custom || {}),\n 'plugin-import-export': {\n ...(collection.custom?.['plugin-import-export'] || {}),\n ...(exportLimit !== undefined && { exportLimit }),\n ...(exportDisableJobsQueue !== undefined && {\n exportDisableJobsQueue,\n }),\n ...(exportBatchSize !== undefined && { exportBatchSize }),\n ...(importLimit !== undefined && { importLimit }),\n ...(importDisableJobsQueue !== undefined && {\n importDisableJobsQueue,\n }),\n ...(importBatchSize !== undefined && { importBatchSize }),\n ...(importDefaultVersionStatus !== undefined && {\n defaultVersionStatus: importDefaultVersionStatus,\n }),\n ...(exportHooks !== undefined && { exportHooks }),\n ...(importHooks !== undefined && { importHooks }),\n },\n }\n\n collection.admin.components = components\n }\n\n if (!config.i18n) {\n config.i18n = {}\n }\n\n /**\n * Merge plugin translations — only for languages the user has enabled.\n * Plugins run before sanitize, so `supportedLanguages` may be undefined; sanitize will\n * default it to `{ en }`, so we mirror that here to avoid merging 30+ unused tables.\n */\n const supportedLanguageKeys = config.i18n?.supportedLanguages\n ? Object.keys(config.i18n.supportedLanguages)\n : ['en']\n\n const simplifiedTranslations: Record<string, PluginDefaultTranslationsObject> = {}\n for (const lang of supportedLanguageKeys) {\n const entry = translations[lang as keyof typeof translations]\n if (entry) {\n simplifiedTranslations[lang] = entry.translations\n }\n }\n\n config.i18n = {\n ...config.i18n,\n translations: deepMergeSimple(simplifiedTranslations, config.i18n?.translations ?? {}),\n }\n\n return config\n },\n})\n\ndeclare module 'payload' {\n export interface FieldCustom {\n 'plugin-import-export'?: {\n /**\n * When `true` the field is **completely excluded** from the import-export plugin:\n * - It will not appear in the \"Fields to export\" selector.\n * - It is hidden from the preview list when no specific fields are chosen.\n * - Its data is omitted from the final CSV / JSON export.\n * @default false\n */\n disabled?: boolean\n /**\n * Field-level lifecycle hooks for import/export transformations.\n * Works for both CSV and JSON formats.\n */\n hooks?: {\n /**\n * Runs before a field value is exported. Return a transformed value,\n * `undefined` to use default behavior, or mutate `siblingData` to add\n * extra columns at the same level.\n */\n beforeExport?: FieldBeforeExportHook\n /**\n * Runs before a field value is imported. Return the transformed value.\n */\n beforeImport?: FieldBeforeImportHook\n }\n }\n }\n\n export interface CollectionAdminCustom {\n 'plugin-import-export'?: {\n /**\n * Array of collection slugs that this export/import collection can target.\n * Used by CollectionField to populate the dropdown options.\n */\n collectionSlugs?: string[]\n /**\n * Array of field paths that are disabled for import/export.\n * These paths are collected from fields marked with `custom['plugin-import-export'].disabled = true`.\n */\n disabledFields?: string[]\n /**\n * If true, disables the download button in the export preview UI.\n */\n disableDownload?: boolean\n /**\n * If true, disables the save button in the export preview UI.\n */\n disableSave?: boolean\n /**\n * When set, forces exports from this collection to use this format.\n * This value is read from the plugin config's `export.format` option.\n */\n exportFormat?: 'csv' | 'json'\n }\n }\n\n export interface CollectionCustom {\n /**\n * @internal\n * Server-side storage for resolved plugin config. Users should configure\n * import/export via `importExportPlugin({ collections: [{ slug, export: { ... }, import: { ... } }] })`.\n * These fields are populated automatically and are not part of the public\n * API — the names here intentionally diverge from the user-facing nested\n * `export.hooks` / `import.hooks` config and may change without notice.\n */\n 'plugin-import-export'?: {\n /**\n * @internal Default version status for imported documents when _status field is not provided.\n * Only applies to collections with versions enabled.\n * @default 'published'\n */\n defaultVersionStatus?: 'draft' | 'published'\n /**\n * Number of documents to process in each batch during export.\n * @default 100\n */\n exportBatchSize?: number\n /**\n * If true, disables the jobs queue for exports and runs them synchronously.\n * @default false\n */\n exportDisableJobsQueue?: boolean\n /**\n * Lifecycle hooks for export operations. Stored server-side since functions\n * cannot be serialized to the client.\n */\n exportHooks?: { after?: ExportAfterHook; before?: ExportBeforeHook }\n /**\n * Maximum number of documents that can be exported from this collection.\n * Set to 0 for unlimited (default). Can be a number or function.\n * Stored in collection.custom (server-only) since functions cannot be serialized to client.\n */\n exportLimit?: Limit\n /**\n * Number of documents to process in each batch during import.\n * @default 100\n */\n importBatchSize?: number\n /**\n * If true, disables the jobs queue for imports and runs them synchronously.\n * @default false\n */\n importDisableJobsQueue?: boolean\n /**\n * Lifecycle hooks for import operations. Stored server-side since functions\n * cannot be serialized to the client.\n */\n importHooks?: { after?: ImportAfterHook; before?: ImportBeforeHook }\n /**\n * Maximum number of documents that can be imported to this collection.\n * Set to 0 for unlimited (default). Can be a number or function.\n * Stored in collection.custom (server-only) since functions cannot be serialized to client.\n */\n importLimit?: Limit\n }\n }\n}\n"],"names":["deepMergeSimple","definePlugin","getCreateCollectionExportTask","getCreateCollectionImportTask","translations","collectDisabledFieldPaths","getPluginCollections","importExportPlugin","slug","plugin","config","options","pluginConfig","customExportSlugMap","customImportSlugMap","exportCollections","importCollections","baseExportCollection","baseImportCollection","allExportSlugs","Set","map","c","allImportSlugs","collections","collection","slugExists","some","push","admin","components","providers","jobs","tasks","collectionConfigMap","Map","collectionConfig","set","collectionsToUpdate","filter","has","collectionPluginConfig","get","length","exportSlugForCollection","importSlugForCollection","exportDisabled","export","importDisabled","import","listMenuItems","clientProps","collectionSlug","exportCollectionSlug","path","importCollectionSlug","disabledFieldAccessors","fields","exportConfig","undefined","exportFormat","format","exportDisableJobsQueue","disableJobsQueue","exportBatchSize","batchSize","exportDisableSave","disableSave","exportDisableDownload","disableDownload","importConfig","importDisableJobsQueue","importBatchSize","exportLimit","limit","exportHooks","hooks","importLimit","importDefaultVersionStatus","defaultVersionStatus","importHooks","custom","disabledFields","i18n","supportedLanguageKeys","supportedLanguages","Object","keys","simplifiedTranslations","lang","entry"],"mappings":"AAAA,SAASA,eAAe,EAAEC,YAAY,QAAQ,UAAS;AAevD,SAASC,6BAA6B,QAAQ,4CAA2C;AACzF,SAASC,6BAA6B,QAAQ,4CAA2C;AACzF,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,oBAAoB,QAAQ,sCAAqC;AAE1E;;;;;;;;;CASC,GACD,OAAO,MAAMC,qBAAqBN,aAAuC;IACvEO,MAAM;IACNC,QAAQ,OAAO,EAAEC,MAAM,EAAEC,SAASC,YAAY,EAAE;QAC9C,mGAAmG;QACnG,MAAM,EAAEC,mBAAmB,EAAEC,mBAAmB,EAAEC,iBAAiB,EAAEC,iBAAiB,EAAE,GACtF,MAAMV,qBAAqB;YACzBI;YACAE;QACF;QAEF,mDAAmD;QACnD,MAAMK,uBAAuBF,iBAAiB,CAAC,EAAE;QACjD,MAAMG,uBAAuBF,iBAAiB,CAAC,EAAE;QAEjD,+DAA+D;QAC/D,MAAMG,iBAAiB,IAAIC,IAAIL,kBAAkBM,GAAG,CAAC,CAACC,IAAMA,EAAEd,IAAI;QAClE,MAAMe,iBAAiB,IAAIH,IAAIJ,kBAAkBK,GAAG,CAAC,CAACC,IAAMA,EAAEd,IAAI;QAElE,yCAAyC;QACzC,IAAI,CAACE,OAAOc,WAAW,EAAE;YACvBd,OAAOc,WAAW,GAAG,EAAE;QACzB;QAEA,wEAAwE;QACxE,KAAK,MAAMC,cAAc;eAAIV;eAAsBC;SAAkB,CAAE;YACrE,MAAMU,aAAahB,OAAOc,WAAW,CAACG,IAAI,CAAC,CAACL,IAAMA,EAAEd,IAAI,KAAKiB,WAAWjB,IAAI;YAC5E,IAAI,CAACkB,YAAY;gBACfhB,OAAOc,WAAW,CAACI,IAAI,CAACH;YAC1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qB;oBAAY,CAAC;gBAClD;YACF;YAEAvD,WAAWI,KAAK,CAACC,UAAU,GAAGA;QAChC;QAEA,IAAI,CAACpB,OAAOyE,IAAI,EAAE;YAChBzE,OAAOyE,IAAI,GAAG,CAAC;QACjB;QAEA;;;;KAIC,GACD,MAAMC,wBAAwB1E,OAAOyE,IAAI,EAAEE,qBACvCC,OAAOC,IAAI,CAAC7E,OAAOyE,IAAI,CAACE,kBAAkB,IAC1C;YAAC;SAAK;QAEV,MAAMG,yBAA0E,CAAC;QACjF,KAAK,MAAMC,QAAQL,sBAAuB;YACxC,MAAMM,QAAQtF,YAAY,CAACqF,KAAkC;YAC7D,IAAIC,OAAO;gBACTF,sBAAsB,CAACC,KAAK,GAAGC,MAAMtF,YAAY;YACnD;QACF;QAEAM,OAAOyE,IAAI,GAAG;YACZ,GAAGzE,OAAOyE,IAAI;YACd/E,cAAcJ,gBAAgBwF,wBAAwB9E,OAAOyE,IAAI,EAAE/E,gBAAgB,CAAC;QACtF;QAEA,OAAOM;IACT;AACF,GAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../src/translations/languages/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4C1B,CAAA;AAED,eAAO,MAAM,EAAE,EAAE,cAGhB,CAAA"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../src/translations/languages/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,eAAO,MAAM,cAAc;IACzB,sBAAsB;QACpB,UAAU;QACV,kBAAkB;QAClB,iBAAiB;QACjB,iBAAiB;QACjB,mBAAmB;QACnB,aAAa;QACb,4BAA4B;QAC5B,mBAAmB;QACnB,oBAAoB;QACpB,oBAAoB;QACpB,oBAAoB;QACpB,+BAA+B;QAC/B,wBAAwB;QACxB,+BAA+B;QAC/B,+BAA+B;QAC/B,mBAAmB;QACnB,oBAAoB;QACpB,8BAA8B;QAC9B,wBAAwB;QACxB,kBAAkB;QAClB,kBAAkB;QAClB,4BAA4B;QAC5B,kBAAkB;QAClB,wBAAwB;QACxB,oBAAoB;QACpB,qBAAqB;QACrB,mBAAmB;QACnB,aAAa;QACb,WAAW;QACX,mBAAmB;QACnB,mBAAmB;QACnB,OAAO;QACP,IAAI;QACJ,eAAe;QACf,eAAe;QACf,6BAA6B;QAC7B,+BAA+B;QAC/B,iCAAiC;QACjC,WAAW;QACX,mBAAmB;QACnB,sBAAsB;;CAEzB,CAAA;AAED,eAAO,MAAM,EAAE,EAAE,cAGhB,CAAA"}
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CollectionConfig, CollectionSlug, DataFromCollectionSlug, PayloadRequest } from 'payload';
1
+ import type { CollectionConfig, CollectionSlug, DataFromCollectionSlug, JsonObject, PayloadRequest } from 'payload';
2
2
  /**
3
3
  * Function to dynamically determine the limit based on request context
4
4
  */
@@ -29,6 +29,14 @@ export type ImportResult = {
29
29
  total: number;
30
30
  updated: number;
31
31
  };
32
+ /** Export document or unsaved form values. `id` indicates a saved document. Treat as read-only. */
33
+ export type ExportDoc = {
34
+ id?: number | string;
35
+ } & JsonObject;
36
+ /** Import document or unsaved preview form values. `id` indicates a saved document. Treat as read-only. */
37
+ export type ImportDoc = {
38
+ id?: number | string;
39
+ } & JsonObject;
32
40
  /**
33
41
  * Hook called before each export batch is written to file.
34
42
  * Receives the transformed batch data and the original DB documents.
@@ -39,6 +47,8 @@ export type ExportBeforeHook<TSlug extends CollectionSlug = CollectionSlug> = (a
39
47
  batchNumber: number;
40
48
  /** Transformed batch — flat rows for CSV, nested docs for JSON. Modify and return this. */
41
49
  data: Record<string, unknown>[];
50
+ /** See {@link ExportDoc}. */
51
+ exportDoc: ExportDoc;
42
52
  /** Export format. Open-ended to support custom formats in the future. */
43
53
  format: 'csv' | 'json' | ({} & string);
44
54
  /**
@@ -63,6 +73,8 @@ export type ExportAfterHook = (args: {
63
73
  batchNumber: number;
64
74
  /** The batch data that was written */
65
75
  data: Record<string, unknown>[];
76
+ /** See {@link ExportDoc}. */
77
+ exportDoc: ExportDoc;
66
78
  /** Export format */
67
79
  format: 'csv' | 'json' | ({} & string);
68
80
  /** Raw DB documents before transformation */
@@ -88,6 +100,8 @@ export type ImportBeforeHook<TSlug extends CollectionSlug = CollectionSlug> = (a
88
100
  data: Partial<DataFromCollectionSlug<TSlug>>[];
89
101
  /** Import format. Open-ended to support custom formats in the future. */
90
102
  format: 'csv' | 'json' | ({} & string);
103
+ /** See {@link ImportDoc}. */
104
+ importDoc: ImportDoc;
91
105
  /** Raw parsed file rows before unflattening. Read-only reference. */
92
106
  originalData: Record<string, unknown>[];
93
107
  req: PayloadRequest;
@@ -103,6 +117,8 @@ export type ImportAfterHook = (args: {
103
117
  batchNumber: number;
104
118
  /** Import format */
105
119
  format: 'csv' | 'json' | ({} & string);
120
+ /** See {@link ImportDoc}. */
121
+ importDoc: ImportDoc;
106
122
  /**
107
123
  * Raw parsed file rows for this batch before unflattening and before-hook
108
124
  * transformation. For CSV this is the flat key/value row; for JSON this is
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,cAAc,EACf,MAAM,SAAS,CAAA;AAEhB;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEvF;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG,aAAa,GAAG,MAAM,CAAA;AAE1C;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,E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ACjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAC/B;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;CACxB,GAAG,qBAAqB,CAAA;AAEzB;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAC/B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,GAAG,qBAAqB,CAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionConfig,\n CollectionSlug,\n DataFromCollectionSlug,\n PayloadRequest,\n} from 'payload'\n\n/**\n * Function to dynamically determine the limit based on request context\n */\nexport type LimitFunction = (args: { req: PayloadRequest }) => number | Promise<number>\n\n/**\n * Limit configuration - either a hard number or a function.\n * Set to 0 for unlimited (no restriction). Default is 0.\n */\nexport type Limit = LimitFunction | number\n\n/**\n * Type for overriding import/export collection configurations\n */\nexport type CollectionOverride = ({\n collection,\n}: {\n collection: CollectionConfig\n}) => CollectionConfig | Promise<CollectionConfig>\n\n/**\n * Result of a completed import operation (or a single batch within one)\n */\nexport type ImportResult = {\n errors: Array<{\n doc: Record<string, unknown>\n error: string\n index: number\n }>\n imported: number\n total: number\n updated: number\n}\n\n/**\n * Hook called before each export batch is written to file.\n * Receives the transformed batch data and the original DB documents.\n * Return the modified data array — it replaces `data` for the write step.\n */\nexport type ExportBeforeHook<TSlug extends CollectionSlug = CollectionSlug> = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /** Transformed batch — flat rows for CSV, nested docs for JSON. Modify and return this. */\n data: Record<string, unknown>[]\n /** Export format. Open-ended to support custom formats in the future. */\n format: 'csv' | 'json' | ({} & string)\n /**\n * Raw DB documents before format-specific transformation. Read-only reference.\n *\n * Typed as a union so call sites that don't know the collection slug at\n * compile time (e.g. job tasks) don't need `as any` casts. To get the\n * narrower typed shape, declare your hook with a slug:\n * `const hook: ExportBeforeHook<'posts'> = (args) => { ... }`.\n */\n originalData: DataFromCollectionSlug<TSlug>[] | Record<string, unknown>[]\n req: PayloadRequest\n /** Total number of batches for this export operation */\n totalBatches: number\n}) => Promise<Record<string, unknown>[]> | Record<string, unknown>[]\n\n/**\n * Hook called after each export batch has been written to file.\n * For logging and observability only — return value is ignored.\n */\nexport type ExportAfterHook = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /** The batch data that was written */\n data: Record<string, unknown>[]\n /** Export format */\n format: 'csv' | 'json' | ({} & string)\n /** Raw DB documents before transformation */\n originalData: Record<string, unknown>[]\n req: PayloadRequest\n /** Total number of batches for this export operation */\n totalBatches: number\n}) => Promise<void> | void\n\n/**\n * Hook called before each import batch is written to the database.\n * Receives the processed (unflattened) documents and the raw file rows.\n * Return the modified documents array — it replaces `data` for the DB write step.\n */\nexport type ImportBeforeHook<TSlug extends CollectionSlug = CollectionSlug> = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /**\n * Unflattened documents ready to be written to the database. Modify and\n * return this. Typed as `Partial<...>` because rows from a CSV or JSON\n * import are not guaranteed to include every required field of the\n * collection — required fields are validated at write time.\n */\n data: Partial<DataFromCollectionSlug<TSlug>>[]\n /** Import format. Open-ended to support custom formats in the future. */\n format: 'csv' | 'json' | ({} & string)\n /** Raw parsed file rows before unflattening. Read-only reference. */\n originalData: Record<string, unknown>[]\n req: PayloadRequest\n /** Total number of batches for this import operation */\n totalBatches: number\n}) => Partial<DataFromCollectionSlug<TSlug>>[] | Promise<Partial<DataFromCollectionSlug<TSlug>>[]>\n\n/**\n * Hook called after each import batch has been written to the database.\n * For logging and observability only — return value is ignored.\n */\nexport type ImportAfterHook = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /** Import format */\n format: 'csv' | 'json' | ({} & string)\n /**\n * Raw parsed file rows for this batch before unflattening and before-hook\n * transformation. For CSV this is the flat key/value row; for JSON this is\n * the top-level parsed document. Read-only reference.\n */\n originalData: Record<string, unknown>[]\n req: PayloadRequest\n /** Result of this batch — counts and errors. Not the cumulative total. */\n result: ImportResult\n /** Total number of batches for this import operation */\n totalBatches: number\n}) => Promise<void> | void\n\n/**\n * Per-collection export configuration. Set on each entry of\n * ```\n * importExportPlugin({ collections: [{ slug, export: { ... } }] })\n * ```\n */\nexport type ExportConfig<TSlug extends CollectionSlug = CollectionSlug> = {\n /**\n * Number of documents to process in each batch during export. This config is applied to both jobs and synchronous exports.\n *\n * @default 100\n */\n batchSize?: number\n /**\n * If true, disables the download button in the export preview UI\n * @default false\n */\n disableDownload?: boolean\n /**\n * If true, disables the jobs queue for exports and runs them synchronously.\n * @default false\n */\n disableJobsQueue?: boolean\n /**\n * If true, disables the save button in the export preview UI\n * @default false\n */\n disableSave?: boolean\n /**\n * Forces a specific export format (`csv` or `json`) and hides the format dropdown from the UI.\n * When defined, this overrides the user's ability to choose a format manually.\n * If not set, the user can choose between CSV and JSON in the export UI.\n * @default undefined\n */\n format?: 'csv' | 'json'\n /**\n * Lifecycle hooks for export operations on this collection.\n * Hooks fire once per batch.\n */\n hooks?: {\n /**\n * Called after each batch is written to file. For logging/observability only.\n * Return value is ignored.\n */\n after?: ExportAfterHook\n /**\n * Called before each batch is written to file.\n * Return value replaces the batch data for the write step.\n */\n before?: ExportBeforeHook<TSlug>\n }\n /**\n * Maximum number of documents that can be exported in a single operation.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Overrides the global exportLimit if set.\n */\n limit?: Limit\n /**\n * Override the export collection for this collection.\n *\n * @default true\n */\n overrideCollection?: CollectionOverride\n}\n\n/**\n * Per-collection import configuration. Set on each entry of\n * ```\n * importExportPlugin({ collections: [{ slug, import: { ... } }] })\n * ```\n */\nexport type ImportConfig<TSlug extends CollectionSlug = CollectionSlug> = {\n /**\n * Number of documents to process in each batch during import. This config is applied to both jobs and synchronous imports.\n *\n * @default 100\n */\n batchSize?: number\n /**\n * Default version status for imported documents when _status field is not provided.\n * Only applies to collections with versions enabled.\n * @default 'published'\n */\n defaultVersionStatus?: 'draft' | 'published'\n /**\n * If true, disables the jobs queue for imports and runs them synchronously.\n * @default false\n */\n disableJobsQueue?: boolean\n /**\n * Lifecycle hooks for import operations on this collection.\n * Hooks fire once per batch.\n */\n hooks?: {\n /**\n * Called after each batch is written to the database. For logging/observability only.\n * Return value is ignored.\n */\n after?: ImportAfterHook\n /**\n * Called before each batch is written to the database.\n * Return value replaces the batch data for the DB write step.\n */\n before?: ImportBeforeHook<TSlug>\n }\n /**\n * Maximum number of documents that can be imported in a single operation.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Overrides the global importLimit if set.\n */\n limit?: Limit\n /**\n * Override the import collection for this collection.\n *\n * @default true\n */\n overrideCollection?: CollectionOverride\n}\n\n/**\n * Per-collection plugin entry. Identifies a target collection by `slug` and\n * configures its export/import behavior; either side can be disabled with `false`.\n */\nexport type PluginCollectionConfig<TSlug extends CollectionSlug = CollectionSlug> = {\n /**\n * Override the import collection for this collection or disable it entirely with `false`.\n *\n * @default true\n */\n export?: boolean | ExportConfig<TSlug>\n /**\n * Override the export collection for this collection or disable it entirely with `false`.\n *\n * @default true\n */\n import?: boolean | ImportConfig<TSlug>\n /**\n * Target collection's slug for import/export functionality\n */\n slug: TSlug\n}\n\n/**\n * Configuration options for the Import/Export plugin\n */\nexport type ImportExportPluginConfig = {\n /**\n * Global default batch size for both import and export operations.\n * Can be overridden at the collection level via `export.batchSize` or `import.batchSize`.\n * @default 100\n */\n batchSize?: number\n\n /**\n * Collections to include the Import/Export controls in.\n * If not specified, all collections will have import/export enabled.\n * @default undefined (all collections)\n */\n collections: PluginCollectionConfig<CollectionSlug>[]\n\n /**\n * Enable debug logging for troubleshooting import/export operations\n * @default false\n */\n debug?: boolean\n\n /**\n * Global default version status for imported documents when _status field is not provided.\n * Only applies to collections with versions enabled.\n * Can be overridden at the collection level via `import.defaultVersionStatus`.\n * @default 'published'\n */\n defaultVersionStatus?: 'draft' | 'published'\n\n /**\n * Global maximum for export operations.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Per-collection limits take precedence.\n */\n exportLimit?: Limit\n\n /**\n * Global maximum for import operations.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Per-collection limits take precedence.\n */\n importLimit?: Limit\n\n /**\n * Function to override the default export collection configuration.\n * Takes the default export collection and allows you to modify and return it.\n * Useful for adding access control, changing upload directory, etc.\n *\n * This can also be set at the collection level via `export` config.\n */\n overrideExportCollection?: CollectionOverride\n\n /**\n * Function to override the default import collection configuration.\n * Takes the default import collection and allows you to modify and return it.\n * Useful for adding access control, changing upload directory, etc.\n *\n * This can also be set at the collection level via `import` config.\n */\n overrideImportCollection?: CollectionOverride\n}\n\n/**\n * Field-level hook that runs before a field value is exported. Works for both\n * CSV and JSON. Return a value to replace the field, or `undefined` to fall\n * back to default behavior. Mutate `siblingData` to add or remove columns at\n * the same level.\n *\n * Return `null` (CSV only) when the hook has already written its replacement\n * columns to `siblingData` and default flattening should be skipped — used by\n * built-in handlers for polymorphic relationships to avoid duplicate columns.\n */\nexport type FieldBeforeExportHook = (args: {\n /** Runtime column path, underscore-separated (includes array indices, e.g. `items_0_note`). */\n columnName: string\n /** The top-level document being exported. */\n data: Record<string, unknown>\n format: 'csv' | 'json' | ({} & string)\n /** Writable output at the current level. CSV: the flat row accumulator. JSON: the sibling output object. */\n siblingData: Record<string, unknown>\n /** Read-only source at the current level, before any transformation. */\n siblingDoc: Record<string, unknown>\n value: unknown\n}) => unknown\n\n/**\n * Field-level hook that runs before a field value is imported. Works for both\n * CSV and JSON. Return the transformed value to use for this field.\n */\nexport type FieldBeforeImportHook = (args: {\n columnName: string\n /** Full flat row (CSV) or top-level parsed document (JSON). */\n data: Record<string, unknown>\n format: 'csv' | 'json' | ({} & string)\n /** Data at the current level. CSV: same reference as `data`. JSON: the parent-level object. */\n siblingData: Record<string, unknown>\n /** Read-only source at the current level, before any transformation. CSV: same as `data`. */\n siblingDoc: Record<string, unknown>\n value: unknown\n}) => unknown\n\n/** @internal */\nexport type ExportFieldHookEntry = { fn: FieldBeforeExportHook; type: 'beforeExport' }\n\n/** @internal */\nexport type ImportFieldHookEntry = { fn: FieldBeforeImportHook; type: 'beforeImport' }\n\n/**\n * Base pagination data returned from preview endpoints\n */\nexport type PreviewPaginationData = {\n /**\n * Whether there is a next page available\n */\n hasNextPage: boolean\n /**\n * Whether there is a previous page available\n */\n hasPrevPage: boolean\n /**\n * Number of documents per page\n */\n limit: number\n /**\n * The resolved max limit value (max documents allowed), if any\n */\n maxLimit?: number\n /**\n * Current page number (1-indexed)\n */\n page: number\n /**\n * Total number of documents\n */\n totalDocs: number\n /**\n * Total number of pages\n */\n totalPages: number\n}\n\n/**\n * Response from export preview endpoint\n */\nexport type ExportPreviewResponse = {\n /**\n * Column names for CSV format (undefined for JSON)\n */\n columns?: string[]\n /**\n * Preview documents (transformed for display)\n */\n docs: Record<string, unknown>[]\n /**\n * Actual count of docs that will be exported (respects export limit)\n */\n exportTotalDocs: number\n} & PreviewPaginationData\n\n/**\n * Response from import preview endpoint\n */\nexport type ImportPreviewResponse = {\n /**\n * Preview documents parsed from the import file\n */\n docs: Record<string, unknown>[]\n /**\n * Whether the file exceeds the max limit\n */\n limitExceeded?: boolean\n} & PreviewPaginationData\n"],"names":[],"mappings":"AAmbA;;CAEC,GACD,WASyB"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionConfig,\n CollectionSlug,\n DataFromCollectionSlug,\n JsonObject,\n PayloadRequest,\n} from 'payload'\n\n/**\n * Function to dynamically determine the limit based on request context\n */\nexport type LimitFunction = (args: { req: PayloadRequest }) => number | Promise<number>\n\n/**\n * Limit configuration - either a hard number or a function.\n * Set to 0 for unlimited (no restriction). Default is 0.\n */\nexport type Limit = LimitFunction | number\n\n/**\n * Type for overriding import/export collection configurations\n */\nexport type CollectionOverride = ({\n collection,\n}: {\n collection: CollectionConfig\n}) => CollectionConfig | Promise<CollectionConfig>\n\n/**\n * Result of a completed import operation (or a single batch within one)\n */\nexport type ImportResult = {\n errors: Array<{\n doc: Record<string, unknown>\n error: string\n index: number\n }>\n imported: number\n total: number\n updated: number\n}\n\n/** Export document or unsaved form values. `id` indicates a saved document. Treat as read-only. */\nexport type ExportDoc = { id?: number | string } & JsonObject\n\n/** Import document or unsaved preview form values. `id` indicates a saved document. Treat as read-only. */\nexport type ImportDoc = { id?: number | string } & JsonObject\n\n/**\n * Hook called before each export batch is written to file.\n * Receives the transformed batch data and the original DB documents.\n * Return the modified data array — it replaces `data` for the write step.\n */\nexport type ExportBeforeHook<TSlug extends CollectionSlug = CollectionSlug> = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /** Transformed batch — flat rows for CSV, nested docs for JSON. Modify and return this. */\n data: Record<string, unknown>[]\n /** See {@link ExportDoc}. */\n exportDoc: ExportDoc\n /** Export format. Open-ended to support custom formats in the future. */\n format: 'csv' | 'json' | ({} & string)\n /**\n * Raw DB documents before format-specific transformation. Read-only reference.\n *\n * Typed as a union so call sites that don't know the collection slug at\n * compile time (e.g. job tasks) don't need `as any` casts. To get the\n * narrower typed shape, declare your hook with a slug:\n * `const hook: ExportBeforeHook<'posts'> = (args) => { ... }`.\n */\n originalData: DataFromCollectionSlug<TSlug>[] | Record<string, unknown>[]\n req: PayloadRequest\n /** Total number of batches for this export operation */\n totalBatches: number\n}) => Promise<Record<string, unknown>[]> | Record<string, unknown>[]\n\n/**\n * Hook called after each export batch has been written to file.\n * For logging and observability only — return value is ignored.\n */\nexport type ExportAfterHook = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /** The batch data that was written */\n data: Record<string, unknown>[]\n /** See {@link ExportDoc}. */\n exportDoc: ExportDoc\n /** Export format */\n format: 'csv' | 'json' | ({} & string)\n /** Raw DB documents before transformation */\n originalData: Record<string, unknown>[]\n req: PayloadRequest\n /** Total number of batches for this export operation */\n totalBatches: number\n}) => Promise<void> | void\n\n/**\n * Hook called before each import batch is written to the database.\n * Receives the processed (unflattened) documents and the raw file rows.\n * Return the modified documents array — it replaces `data` for the DB write step.\n */\nexport type ImportBeforeHook<TSlug extends CollectionSlug = CollectionSlug> = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /**\n * Unflattened documents ready to be written to the database. Modify and\n * return this. Typed as `Partial<...>` because rows from a CSV or JSON\n * import are not guaranteed to include every required field of the\n * collection — required fields are validated at write time.\n */\n data: Partial<DataFromCollectionSlug<TSlug>>[]\n /** Import format. Open-ended to support custom formats in the future. */\n format: 'csv' | 'json' | ({} & string)\n /** See {@link ImportDoc}. */\n importDoc: ImportDoc\n /** Raw parsed file rows before unflattening. Read-only reference. */\n originalData: Record<string, unknown>[]\n req: PayloadRequest\n /** Total number of batches for this import operation */\n totalBatches: number\n}) => Partial<DataFromCollectionSlug<TSlug>>[] | Promise<Partial<DataFromCollectionSlug<TSlug>>[]>\n\n/**\n * Hook called after each import batch has been written to the database.\n * For logging and observability only — return value is ignored.\n */\nexport type ImportAfterHook = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /** Import format */\n format: 'csv' | 'json' | ({} & string)\n /** See {@link ImportDoc}. */\n importDoc: ImportDoc\n /**\n * Raw parsed file rows for this batch before unflattening and before-hook\n * transformation. For CSV this is the flat key/value row; for JSON this is\n * the top-level parsed document. Read-only reference.\n */\n originalData: Record<string, unknown>[]\n req: PayloadRequest\n /** Result of this batch — counts and errors. Not the cumulative total. */\n result: ImportResult\n /** Total number of batches for this import operation */\n totalBatches: number\n}) => Promise<void> | void\n\n/**\n * Per-collection export configuration. Set on each entry of\n * ```\n * importExportPlugin({ collections: [{ slug, export: { ... } }] })\n * ```\n */\nexport type ExportConfig<TSlug extends CollectionSlug = CollectionSlug> = {\n /**\n * Number of documents to process in each batch during export. This config is applied to both jobs and synchronous exports.\n *\n * @default 100\n */\n batchSize?: number\n /**\n * If true, disables the download button in the export preview UI\n * @default false\n */\n disableDownload?: boolean\n /**\n * If true, disables the jobs queue for exports and runs them synchronously.\n * @default false\n */\n disableJobsQueue?: boolean\n /**\n * If true, disables the save button in the export preview UI\n * @default false\n */\n disableSave?: boolean\n /**\n * Forces a specific export format (`csv` or `json`) and hides the format dropdown from the UI.\n * When defined, this overrides the user's ability to choose a format manually.\n * If not set, the user can choose between CSV and JSON in the export UI.\n * @default undefined\n */\n format?: 'csv' | 'json'\n /**\n * Lifecycle hooks for export operations on this collection.\n * Hooks fire once per batch.\n */\n hooks?: {\n /**\n * Called after each batch is written to file. For logging/observability only.\n * Return value is ignored.\n */\n after?: ExportAfterHook\n /**\n * Called before each batch is written to file.\n * Return value replaces the batch data for the write step.\n */\n before?: ExportBeforeHook<TSlug>\n }\n /**\n * Maximum number of documents that can be exported in a single operation.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Overrides the global exportLimit if set.\n */\n limit?: Limit\n /**\n * Override the export collection for this collection.\n *\n * @default true\n */\n overrideCollection?: CollectionOverride\n}\n\n/**\n * Per-collection import configuration. Set on each entry of\n * ```\n * importExportPlugin({ collections: [{ slug, import: { ... } }] })\n * ```\n */\nexport type ImportConfig<TSlug extends CollectionSlug = CollectionSlug> = {\n /**\n * Number of documents to process in each batch during import. This config is applied to both jobs and synchronous imports.\n *\n * @default 100\n */\n batchSize?: number\n /**\n * Default version status for imported documents when _status field is not provided.\n * Only applies to collections with versions enabled.\n * @default 'published'\n */\n defaultVersionStatus?: 'draft' | 'published'\n /**\n * If true, disables the jobs queue for imports and runs them synchronously.\n * @default false\n */\n disableJobsQueue?: boolean\n /**\n * Lifecycle hooks for import operations on this collection.\n * Hooks fire once per batch.\n */\n hooks?: {\n /**\n * Called after each batch is written to the database. For logging/observability only.\n * Return value is ignored.\n */\n after?: ImportAfterHook\n /**\n * Called before each batch is written to the database.\n * Return value replaces the batch data for the DB write step.\n */\n before?: ImportBeforeHook<TSlug>\n }\n /**\n * Maximum number of documents that can be imported in a single operation.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Overrides the global importLimit if set.\n */\n limit?: Limit\n /**\n * Override the import collection for this collection.\n *\n * @default true\n */\n overrideCollection?: CollectionOverride\n}\n\n/**\n * Per-collection plugin entry. Identifies a target collection by `slug` and\n * configures its export/import behavior; either side can be disabled with `false`.\n */\nexport type PluginCollectionConfig<TSlug extends CollectionSlug = CollectionSlug> = {\n /**\n * Override the import collection for this collection or disable it entirely with `false`.\n *\n * @default true\n */\n export?: boolean | ExportConfig<TSlug>\n /**\n * Override the export collection for this collection or disable it entirely with `false`.\n *\n * @default true\n */\n import?: boolean | ImportConfig<TSlug>\n /**\n * Target collection's slug for import/export functionality\n */\n slug: TSlug\n}\n\n/**\n * Configuration options for the Import/Export plugin\n */\nexport type ImportExportPluginConfig = {\n /**\n * Global default batch size for both import and export operations.\n * Can be overridden at the collection level via `export.batchSize` or `import.batchSize`.\n * @default 100\n */\n batchSize?: number\n\n /**\n * Collections to include the Import/Export controls in.\n * If not specified, all collections will have import/export enabled.\n * @default undefined (all collections)\n */\n collections: PluginCollectionConfig<CollectionSlug>[]\n\n /**\n * Enable debug logging for troubleshooting import/export operations\n * @default false\n */\n debug?: boolean\n\n /**\n * Global default version status for imported documents when _status field is not provided.\n * Only applies to collections with versions enabled.\n * Can be overridden at the collection level via `import.defaultVersionStatus`.\n * @default 'published'\n */\n defaultVersionStatus?: 'draft' | 'published'\n\n /**\n * Global maximum for export operations.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Per-collection limits take precedence.\n */\n exportLimit?: Limit\n\n /**\n * Global maximum for import operations.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Per-collection limits take precedence.\n */\n importLimit?: Limit\n\n /**\n * Function to override the default export collection configuration.\n * Takes the default export collection and allows you to modify and return it.\n * Useful for adding access control, changing upload directory, etc.\n *\n * This can also be set at the collection level via `export` config.\n */\n overrideExportCollection?: CollectionOverride\n\n /**\n * Function to override the default import collection configuration.\n * Takes the default import collection and allows you to modify and return it.\n * Useful for adding access control, changing upload directory, etc.\n *\n * This can also be set at the collection level via `import` config.\n */\n overrideImportCollection?: CollectionOverride\n}\n\n/**\n * Field-level hook that runs before a field value is exported. Works for both\n * CSV and JSON. Return a value to replace the field, or `undefined` to fall\n * back to default behavior. Mutate `siblingData` to add or remove columns at\n * the same level.\n *\n * Return `null` (CSV only) when the hook has already written its replacement\n * columns to `siblingData` and default flattening should be skipped — used by\n * built-in handlers for polymorphic relationships to avoid duplicate columns.\n */\nexport type FieldBeforeExportHook = (args: {\n /** Runtime column path, underscore-separated (includes array indices, e.g. `items_0_note`). */\n columnName: string\n /** The top-level document being exported. */\n data: Record<string, unknown>\n format: 'csv' | 'json' | ({} & string)\n /** Writable output at the current level. CSV: the flat row accumulator. JSON: the sibling output object. */\n siblingData: Record<string, unknown>\n /** Read-only source at the current level, before any transformation. */\n siblingDoc: Record<string, unknown>\n value: unknown\n}) => unknown\n\n/**\n * Field-level hook that runs before a field value is imported. Works for both\n * CSV and JSON. Return the transformed value to use for this field.\n */\nexport type FieldBeforeImportHook = (args: {\n columnName: string\n /** Full flat row (CSV) or top-level parsed document (JSON). */\n data: Record<string, unknown>\n format: 'csv' | 'json' | ({} & string)\n /** Data at the current level. CSV: same reference as `data`. JSON: the parent-level object. */\n siblingData: Record<string, unknown>\n /** Read-only source at the current level, before any transformation. CSV: same as `data`. */\n siblingDoc: Record<string, unknown>\n value: unknown\n}) => unknown\n\n/** @internal */\nexport type ExportFieldHookEntry = { fn: FieldBeforeExportHook; type: 'beforeExport' }\n\n/** @internal */\nexport type ImportFieldHookEntry = { fn: FieldBeforeImportHook; type: 'beforeImport' }\n\n/**\n * Base pagination data returned from preview endpoints\n */\nexport type PreviewPaginationData = {\n /**\n * Whether there is a next page available\n */\n hasNextPage: boolean\n /**\n * Whether there is a previous page available\n */\n hasPrevPage: boolean\n /**\n * Number of documents per page\n */\n limit: number\n /**\n * The resolved max limit value (max documents allowed), if any\n */\n maxLimit?: number\n /**\n * Current page number (1-indexed)\n */\n page: number\n /**\n * Total number of documents\n */\n totalDocs: number\n /**\n * Total number of pages\n */\n totalPages: number\n}\n\n/**\n * Response from export preview endpoint\n */\nexport type ExportPreviewResponse = {\n /**\n * Column names for CSV format (undefined for JSON)\n */\n columns?: string[]\n /**\n * Preview documents (transformed for display)\n */\n docs: Record<string, unknown>[]\n /**\n * Actual count of docs that will be exported (respects export limit)\n */\n exportTotalDocs: number\n} & PreviewPaginationData\n\n/**\n * Response from import preview endpoint\n */\nexport type ImportPreviewResponse = {\n /**\n * Preview documents parsed from the import file\n */\n docs: Record<string, unknown>[]\n /**\n * Whether the file exceeds the max limit\n */\n limitExceeded?: boolean\n} & PreviewPaginationData\n"],"names":[],"mappings":"AAkcA;;CAEC,GACD,WASyB"}
@@ -1 +1 @@
1
- {"version":3,"file":"applyFieldHooks.d.ts","sourceRoot":"","sources":["../../src/utilities/applyFieldHooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7E,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,aAAa,CAAA;AAIpB,MAAM,MAAM,SAAS,GAAG,qBAAqB,GAAG,qBAAqB,CAAA;AAErE,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG,oBAAoB,CAAA;AAKxE,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAC1C,MAAM,E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@@
1
- {"version":3,"file":"buildDisabledFieldRegex.d.ts","sourceRoot":"","sources":["../../src/utilities/buildDisabledFieldRegex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,GAAI,WAAW,MAAM,KAAG,MAyB3D,CAAA"}
1
+ {"version":3,"file":"buildDisabledFieldRegex.d.ts","sourceRoot":"","sources":["../../src/utilities/buildDisabledFieldRegex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,cAAe,MAAM,KAAG,MAyB3D,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"collectDisabledFieldPaths.d.ts","sourceRoot":"","sources":["../../src/utilities/collectDisabledFieldPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAKpC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,KAAK,EAAE,KAAG,MAAM,EAmEjE,CAAA"}
1
+ {"version":3,"file":"collectDisabledFieldPaths.d.ts","sourceRoot":"","sources":["../../src/utilities/collectDisabledFieldPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAKpC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,WAAY,KAAK,EAAE,KAAG,MAAM,EAmEjE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"fieldToRegex.d.ts","sourceRoot":"","sources":["../../src/utilities/fieldToRegex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAI,WAAW,MAAM,KAAG,MAoBhD,CAAA"}
1
+ {"version":3,"file":"fieldToRegex.d.ts","sourceRoot":"","sources":["../../src/utilities/fieldToRegex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,cAAe,MAAM,KAAG,MAoBhD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"flattenObject.d.ts","sourceRoot":"","sources":["../../src/utilities/flattenObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAMvD,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IACtD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,CAAA;IACtC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,wDAO3B,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CA2K/B,CAAA"}
1
+ {"version":3,"file":"flattenObject.d.ts","sourceRoot":"","sources":["../../src/utilities/flattenObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAMvD,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IACtD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,CAAA;IACtC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,aAAa,2DAOvB,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CA2K/B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"flattenedFields.d.ts","sourceRoot":"","sources":["../../src/utilities/flattenedFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,cAAc,KAAG,cAAc,EAAE,GAAG,SACjB,CAAA;AAEnE;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,OAAO;IAC7C,eAAe,CAAC,EAAE,cAAc,EAAE,CAAA;CACnC,KAAG,cAAc,EAAiC,CAAA;AAEnD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,EACvC,QAAQ,cAAc,EAAE,EACxB,YAAY,MAAM,EAClB,QAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,iBAAiB,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,KAChG,IA6BF,CAAA"}
1
+ {"version":3,"file":"flattenedFields.d.ts","sourceRoot":"","sources":["../../src/utilities/flattenedFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,UAAW,cAAc,KAAG,cAAc,EAAE,GAAG,SACjB,CAAA;AAEnE;;GAEG;AACH,eAAO,MAAM,uBAAuB,UAAW;IAC7C,eAAe,CAAC,EAAE,cAAc,EAAE,CAAA;CACnC,KAAG,cAAc,EAAiC,CAAA;AAEnD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,UAC/B,cAAc,EAAE,cACZ,MAAM,UACV,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACb,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,KAChG,IA6BF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getExportFieldFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/getExportFieldFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,oBAAoB,EAAyB,MAAM,aAAa,CAAA;AAK9E,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,cAAc,EAAE,CAAA;CACzB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAAI,YAAY,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAI7F,CAAA"}
1
+ {"version":3,"file":"getExportFieldFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/getExportFieldFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,oBAAoB,EAAyB,MAAM,aAAa,CAAA;AAK9E,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,cAAc,EAAE,CAAA;CACzB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,eAAgB,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAI7F,CAAA"}