@payloadcms/plugin-import-export 4.0.0-internal.688c4d0 → 4.0.0-internal.811e0a4

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 (59) hide show
  1. package/dist/components/ExportPreview/index.css +55 -0
  2. package/dist/components/ExportPreview/index.d.ts +1 -1
  3. package/dist/components/ExportPreview/index.d.ts.map +1 -1
  4. package/dist/components/ExportPreview/index.js +1 -1
  5. package/dist/components/ExportPreview/index.js.map +1 -1
  6. package/dist/components/FormatField/index.d.ts.map +1 -1
  7. package/dist/components/FormatField/index.js +6 -3
  8. package/dist/components/FormatField/index.js.map +1 -1
  9. package/dist/components/ImportPreview/index.css +48 -0
  10. package/dist/components/ImportPreview/index.d.ts +1 -1
  11. package/dist/components/ImportPreview/index.d.ts.map +1 -1
  12. package/dist/components/ImportPreview/index.js +1 -1
  13. package/dist/components/ImportPreview/index.js.map +1 -1
  14. package/dist/components/Page/index.d.ts +1 -1
  15. package/dist/components/Page/index.d.ts.map +1 -1
  16. package/dist/components/Page/index.js +1 -1
  17. package/dist/components/Page/index.js.map +1 -1
  18. package/dist/components/SortBy/index.css +9 -0
  19. package/dist/components/SortBy/index.d.ts +1 -1
  20. package/dist/components/SortBy/index.d.ts.map +1 -1
  21. package/dist/components/SortBy/index.js +1 -2
  22. package/dist/components/SortBy/index.js.map +1 -1
  23. package/dist/components/SortOrder/index.css +9 -0
  24. package/dist/components/SortOrder/index.d.ts +1 -1
  25. package/dist/components/SortOrder/index.d.ts.map +1 -1
  26. package/dist/components/SortOrder/index.js +1 -2
  27. package/dist/components/SortOrder/index.js.map +1 -1
  28. package/dist/export/batchProcessor.d.ts +2 -2
  29. package/dist/export/batchProcessor.d.ts.map +1 -1
  30. package/dist/export/batchProcessor.js.map +1 -1
  31. package/dist/export/createExport.d.ts +2 -2
  32. package/dist/export/createExport.d.ts.map +1 -1
  33. package/dist/export/createExport.js +1 -1
  34. package/dist/export/createExport.js.map +1 -1
  35. package/dist/export/getExportCollection.js +4 -4
  36. package/dist/export/getExportCollection.js.map +1 -1
  37. package/dist/export/handleDownload.js +2 -2
  38. package/dist/export/handleDownload.js.map +1 -1
  39. package/dist/import/batchProcessor.d.ts +2 -2
  40. package/dist/import/batchProcessor.d.ts.map +1 -1
  41. package/dist/import/batchProcessor.js.map +1 -1
  42. package/dist/import/createImport.d.ts.map +1 -1
  43. package/dist/import/createImport.js.map +1 -1
  44. package/dist/import/getImportCollection.js +4 -4
  45. package/dist/import/getImportCollection.js.map +1 -1
  46. package/dist/index.d.ts +1 -2
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +6 -3
  49. package/dist/index.js.map +1 -1
  50. package/license.md +1 -1
  51. package/package.json +7 -7
  52. package/dist/@types/assets.d.js +0 -2
  53. package/dist/@types/assets.d.js.map +0 -1
  54. package/dist/components/ExportPreview/index.scss +0 -48
  55. package/dist/components/FieldsToExport/index.scss +0 -0
  56. package/dist/components/ImportPreview/index.scss +0 -41
  57. package/dist/components/SortBy/index.scss +0 -3
  58. package/dist/components/SortOrder/index.scss +0 -3
  59. /package/dist/components/Page/{index.scss → index.css} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/import/batchProcessor.ts"],"sourcesContent":["import type { PayloadRequest, TypedUser } from 'payload'\n\nimport { isolateObjectProperty } from 'payload'\n\nimport type { ImportAfterHook, ImportBeforeHook, ImportResult } from '../types.js'\nimport type { ImportMode } from './createImport.js'\n\nimport {\n type BatchError,\n categorizeError,\n createBatches,\n extractErrorMessage,\n} from '../utilities/useBatchProcessor.js'\n\n/**\n * Import-specific batch processor options\n */\nexport interface ImportBatchProcessorOptions {\n batchSize?: number\n defaultVersionStatus?: 'draft' | 'published'\n}\n\n/**\n * Import-specific error type extending the generic BatchError\n */\nexport interface ImportError extends BatchError<Record<string, unknown>> {\n documentData: Record<string, unknown>\n field?: string\n fieldLabel?: string\n rowNumber: number // 1-indexed for user clarity\n}\n\n/**\n * Result from processing a single import batch\n */\nexport interface ImportBatchResult {\n failed: Array<ImportError>\n successful: Array<{\n document: Record<string, unknown>\n index: number\n operation?: 'created' | 'updated'\n result: Record<string, unknown>\n }>\n}\n\n/**\n * Options for processing an import operation\n */\nexport interface ImportProcessOptions {\n collectionSlug: string\n docs: Record<string, unknown>[]\n /** Export format — passed through to hook args */\n format?: 'csv' | 'json'\n /** Lifecycle hooks for this import operation */\n hooks?: {\n after?: ImportAfterHook\n before?: ImportBeforeHook\n }\n importMode: ImportMode\n matchField?: string\n /** Raw parsed rows before unflattening — used as originalData in hooks */\n originalDocs?: Record<string, unknown>[]\n req: PayloadRequest\n /** Total number of batches (pre-computed for hook args) */\n totalBatches?: number\n user?: TypedUser\n}\n\n/**\n * Separates multi-locale data from a document for sequential locale updates.\n *\n * When a field has locale-keyed values (e.g., { title: { en: 'Hello', es: 'Hola' } }),\n * this extracts the default locale's data for initial create/update, and stores\n * remaining locales for subsequent update calls.\n *\n * @returns\n * - flatData: Document with default locale values extracted (for initial operation)\n * - hasMultiLocale: Whether any multi-locale fields were found\n * - localeUpdates: Map of locale -> field data for follow-up updates\n */\nfunction extractMultiLocaleData(\n data: Record<string, unknown>,\n configuredLocales?: string[],\n defaultLocale?: string,\n): {\n flatData: Record<string, unknown>\n hasMultiLocale: boolean\n localeUpdates: Record<string, Record<string, unknown>>\n} {\n const flatData: Record<string, unknown> = {}\n const localeUpdates: Record<string, Record<string, unknown>> = {}\n let hasMultiLocale = false\n\n if (!configuredLocales || configuredLocales.length === 0) {\n return { flatData: { ...data }, hasMultiLocale: false, localeUpdates: {} }\n }\n\n const localeSet = new Set(configuredLocales)\n\n for (const [key, value] of Object.entries(data)) {\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const valueObj = value as Record<string, unknown>\n const localeKeys = Object.keys(valueObj).filter((k) => localeSet.has(k))\n\n if (localeKeys.length > 0) {\n hasMultiLocale = true\n const baseLocale =\n defaultLocale && localeKeys.includes(defaultLocale) ? defaultLocale : localeKeys[0]\n if (baseLocale) {\n flatData[key] = valueObj[baseLocale]\n for (const locale of localeKeys) {\n if (locale !== baseLocale) {\n if (!localeUpdates[locale]) {\n localeUpdates[locale] = {}\n }\n localeUpdates[locale][key] = valueObj[locale]\n }\n }\n }\n } else {\n flatData[key] = value\n }\n } else {\n flatData[key] = value\n }\n }\n\n return { flatData, hasMultiLocale, localeUpdates }\n}\n\ntype ProcessImportBatchOptions = {\n batch: Record<string, unknown>[]\n batchIndex: number\n collectionSlug: string\n importMode: ImportMode\n matchField: string | undefined\n options: { batchSize: number; defaultVersionStatus: 'draft' | 'published' }\n req: PayloadRequest\n user?: TypedUser\n}\n\n/**\n * Processes a batch of documents for import based on the import mode.\n *\n * For each document in the batch:\n * - create: Creates a new document (removes any existing ID)\n * - update: Finds existing document by matchField and updates it\n * - upsert: Updates if found, creates if not found\n *\n * Handles versioned collections, multi-locale data, and MongoDB ObjectID validation.\n * Continues processing remaining documents even if individual imports fail.\n */\nasync function processImportBatch({\n batch,\n batchIndex,\n collectionSlug,\n importMode,\n matchField,\n options,\n req: reqFromArgs,\n user,\n}: ProcessImportBatchOptions): Promise<ImportBatchResult> {\n const result: ImportBatchResult = {\n failed: [],\n successful: [],\n }\n // Create a request proxy that isolates the transactionID property, then clear it.\n // This is critical because if a nested operation fails (e.g., Forbidden due to access control),\n // Payload's error handling calls killTransaction(req), which would kill the parent's transaction\n // if we shared the same transaction. By isolating and clearing transactionID, each nested\n // operation either uses no transaction or starts its own, independent of the parent.\n const req = isolateObjectProperty(reqFromArgs, 'transactionID')\n req.transactionID = undefined\n\n const collectionEntry = req.payload.collections[collectionSlug]\n\n const collectionConfig = collectionEntry?.config\n const collectionHasVersions = Boolean(collectionConfig?.versions)\n const hasCustomIdField = Boolean(collectionEntry?.customIDType)\n\n const configuredLocales = req.payload.config.localization\n ? req.payload.config.localization.localeCodes\n : undefined\n\n const defaultLocale = req.payload.config.localization\n ? req.payload.config.localization.defaultLocale\n : undefined\n\n const startingRowNumber = batchIndex * options.batchSize\n\n for (let i = 0; i < batch.length; i++) {\n const document = batch[i]\n if (!document) {\n continue\n }\n const rowNumber = startingRowNumber + i + 1\n\n try {\n let savedDocument: Record<string, unknown> | undefined\n let existingDocResult: { docs: Array<Record<string, unknown>> } | undefined\n\n if (importMode === 'create') {\n const createData = { ...document }\n if (!hasCustomIdField) {\n delete createData.id\n }\n\n let draftOption: boolean | undefined\n if (collectionHasVersions) {\n const statusValue = createData._status || options.defaultVersionStatus\n const isPublished = statusValue !== 'draft'\n draftOption = !isPublished\n createData._status = statusValue\n\n if (req.payload.config.debug) {\n req.payload.logger.info({\n _status: createData._status,\n isPublished,\n msg: 'Status handling in create',\n willSetDraft: draftOption,\n })\n }\n }\n\n if (req.payload.config.debug && 'title' in createData) {\n req.payload.logger.info({\n msg: 'Creating document',\n title: createData.title,\n titleIsNull: createData.title === null,\n titleType: typeof createData.title,\n })\n }\n\n // Check if we have multi-locale data and extract it\n const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(\n createData,\n configuredLocales,\n defaultLocale,\n )\n\n if (hasMultiLocale) {\n // Create with default locale data\n const defaultLocaleReq = defaultLocale ? { ...req, locale: defaultLocale } : req\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: flatData,\n draft: draftOption,\n overrideAccess: false,\n req: defaultLocaleReq,\n user,\n })\n\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n await req.payload.update({\n id: savedDocument.id as number | string,\n collection: collectionSlug,\n data: localeData,\n draft: collectionHasVersions ? false : undefined,\n overrideAccess: false,\n req: { ...req, locale },\n user,\n })\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `Failed to update locale ${locale} for document ${String(savedDocument.id)}`,\n })\n }\n }\n }\n } else {\n // No multi-locale data, create normally\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: createData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n }\n } else if (importMode === 'update' || importMode === 'upsert') {\n const matchValue = document[matchField || 'id']\n if (!matchValue) {\n throw new Error(`Match field \"${matchField || 'id'}\" not found in document`)\n }\n\n // Special handling for ID field with MongoDB\n // If matching by 'id' and it's not a valid ObjectID format, handle specially\n const isMatchingById = (matchField || 'id') === 'id'\n\n // Check if it's a valid MongoDB ObjectID format (24 hex chars)\n // Note: matchValue could be string, number, or ObjectID object\n let matchValueStr: string\n if (typeof matchValue === 'object' && matchValue !== null) {\n matchValueStr = JSON.stringify(matchValue)\n } else if (typeof matchValue === 'string') {\n matchValueStr = matchValue\n } else if (typeof matchValue === 'number') {\n matchValueStr = matchValue.toString()\n } else {\n // For other types, use JSON.stringify\n matchValueStr = JSON.stringify(matchValue)\n }\n const isValidObjectIdFormat = /^[0-9a-f]{24}$/i.test(matchValueStr)\n\n try {\n existingDocResult = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: 1,\n overrideAccess: false,\n req,\n user,\n where: {\n [matchField || 'id']: {\n equals: matchValue,\n },\n },\n })\n } catch (error) {\n // MongoDB may throw for invalid ObjectID format - handle gracefully for upsert\n if (isMatchingById && importMode === 'upsert' && !isValidObjectIdFormat) {\n existingDocResult = { docs: [] }\n } else if (isMatchingById && importMode === 'update' && !isValidObjectIdFormat) {\n throw new Error(`Invalid ID format for update: ${matchValueStr}`)\n } else {\n throw error\n }\n }\n\n if (existingDocResult.docs.length > 0) {\n const existingDoc = existingDocResult.docs[0]\n if (!existingDoc) {\n throw new Error(`Document not found`)\n }\n\n // Debug: log what we found\n if (req.payload.config.debug) {\n req.payload.logger.info({\n existingId: existingDoc.id,\n existingStatus: existingDoc._status,\n existingTitle: existingDoc.title,\n incomingDocument: document,\n mode: importMode,\n msg: 'Found existing document for update',\n })\n }\n\n const updateData = { ...document }\n // Remove ID and internal fields from update data\n delete updateData.id\n delete updateData._id\n delete updateData.createdAt\n delete updateData.updatedAt\n\n // Check if we have multi-locale data and extract it\n const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(\n updateData,\n configuredLocales,\n defaultLocale,\n )\n\n if (req.payload.config.debug) {\n req.payload.logger.info({\n existingId: existingDoc.id,\n hasMultiLocale,\n mode: importMode,\n msg: 'Updating document in upsert/update mode',\n updateData: Object.keys(hasMultiLocale ? flatData : updateData).reduce(\n (acc, key) => {\n const val = (hasMultiLocale ? flatData : updateData)[key]\n acc[key] =\n typeof val === 'string' && val.length > 50 ? val.substring(0, 50) + '...' : val\n return acc\n },\n {} as Record<string, unknown>,\n ),\n })\n }\n\n if (hasMultiLocale) {\n // Update with default locale data\n const defaultLocaleReq = defaultLocale ? { ...req, locale: defaultLocale } : req\n savedDocument = await req.payload.update({\n id: existingDoc.id as number | string,\n collection: collectionSlug,\n data: flatData,\n depth: 0,\n // Don't specify draft - this creates a new draft for versioned collections\n overrideAccess: false,\n req: defaultLocaleReq,\n user,\n })\n\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n await req.payload.update({\n id: existingDoc.id as number | string,\n collection: collectionSlug,\n data: localeData,\n depth: 0,\n overrideAccess: false,\n req: { ...req, locale },\n user,\n })\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `Failed to update locale ${locale} for document ${String(existingDoc.id)}`,\n })\n }\n }\n }\n } else {\n // No multi-locale data, update normally\n try {\n // Extra debug: log before update\n if (req.payload.config.debug) {\n req.payload.logger.info({\n existingId: existingDoc.id,\n existingTitle: existingDoc.title,\n msg: 'About to update document',\n newData: updateData,\n })\n }\n\n // Update the document - don't specify draft to let Payload handle versions properly\n // This will create a new draft version for collections with versions enabled\n savedDocument = await req.payload.update({\n id: existingDoc.id as number | string,\n collection: collectionSlug,\n data: updateData,\n depth: 0,\n // Don't specify draft - this creates a new draft for versioned collections\n overrideAccess: false,\n req,\n user,\n })\n\n if (req.payload.config.debug && savedDocument) {\n req.payload.logger.info({\n id: savedDocument.id,\n msg: 'Update completed',\n status: savedDocument._status,\n title: savedDocument.title,\n })\n }\n } catch (updateError) {\n req.payload.logger.error({\n id: existingDoc.id,\n err: updateError,\n msg: 'Update failed',\n })\n throw updateError\n }\n }\n } else if (importMode === 'upsert') {\n // Create new in upsert mode\n if (req.payload.config.debug) {\n req.payload.logger.info({\n document,\n matchField: matchField || 'id',\n matchValue: document[matchField || 'id'],\n msg: 'No existing document found, creating new in upsert mode',\n })\n }\n\n const createData = { ...document }\n if (!hasCustomIdField) {\n delete createData.id\n }\n\n // Only handle _status for versioned collections\n let draftOption: boolean | undefined\n if (collectionHasVersions) {\n // Use defaultVersionStatus from config if _status not provided\n const statusValue = createData._status || options.defaultVersionStatus\n const isPublished = statusValue !== 'draft'\n draftOption = !isPublished\n createData._status = statusValue\n }\n\n // Check if we have multi-locale data and extract it\n const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(\n createData,\n configuredLocales,\n defaultLocale,\n )\n\n if (hasMultiLocale) {\n // Create with default locale data\n const defaultLocaleReq = defaultLocale ? { ...req, locale: defaultLocale } : req\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: flatData,\n draft: draftOption,\n overrideAccess: false,\n req: defaultLocaleReq,\n user,\n })\n\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n await req.payload.update({\n id: savedDocument.id as number | string,\n collection: collectionSlug,\n data: localeData,\n draft: collectionHasVersions ? false : undefined,\n overrideAccess: false,\n req: { ...req, locale },\n user,\n })\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `Failed to update locale ${locale} for document ${String(savedDocument.id)}`,\n })\n }\n }\n }\n } else {\n // No multi-locale data, create normally\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: createData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n }\n } else {\n // Update mode but document not found\n let matchValueDisplay: string\n if (typeof matchValue === 'object' && matchValue !== null) {\n matchValueDisplay = JSON.stringify(matchValue)\n } else if (typeof matchValue === 'string') {\n matchValueDisplay = matchValue\n } else if (typeof matchValue === 'number') {\n matchValueDisplay = matchValue.toString()\n } else {\n // For other types, use JSON.stringify to avoid [object Object]\n matchValueDisplay = JSON.stringify(matchValue)\n }\n throw new Error(`Document with ${matchField || 'id'}=\"${matchValueDisplay}\" not found`)\n }\n } else {\n throw new Error(`Unknown import mode: ${String(importMode)}`)\n }\n\n if (savedDocument) {\n // Determine operation type for proper counting\n let operation: 'created' | 'updated' | undefined\n if (importMode === 'create') {\n operation = 'created'\n } else if (importMode === 'update') {\n operation = 'updated'\n } else if (importMode === 'upsert') {\n if (existingDocResult && existingDocResult.docs.length > 0) {\n operation = 'updated'\n } else {\n operation = 'created'\n }\n }\n\n result.successful.push({\n document,\n index: rowNumber - 1, // Store as 0-indexed\n operation,\n result: savedDocument,\n })\n }\n } catch (error) {\n const importError: ImportError = {\n type: categorizeError(error),\n documentData: document || {},\n error: extractErrorMessage(error),\n item: document || {},\n itemIndex: rowNumber - 1,\n rowNumber,\n }\n\n // Try to extract field information from validation errors\n if (error && typeof error === 'object' && 'data' in error) {\n const errorData = error as { data?: { errors?: Array<{ path?: string }> } }\n if (errorData.data?.errors && Array.isArray(errorData.data.errors)) {\n const firstError = errorData.data.errors[0]\n if (firstError?.path) {\n importError.field = firstError.path\n }\n }\n }\n\n result.failed.push(importError)\n // Always continue processing all rows\n }\n }\n\n return result\n}\n\nexport function createImportBatchProcessor(options: ImportBatchProcessorOptions = {}) {\n const processorOptions = {\n batchSize: options.batchSize ?? 100,\n defaultVersionStatus: options.defaultVersionStatus ?? 'published',\n }\n\n const processImport = async (processOptions: ImportProcessOptions): Promise<ImportResult> => {\n const {\n collectionSlug,\n docs: documents,\n format = 'csv',\n hooks,\n importMode,\n matchField,\n originalDocs: originalDocs,\n req,\n totalBatches: totalBatchesFromOptions,\n user,\n } = processOptions\n const batches = createBatches(documents, processorOptions.batchSize)\n const totalBatches = totalBatchesFromOptions ?? batches.length\n\n const result: ImportResult = {\n errors: [],\n imported: 0,\n total: documents.length,\n updated: 0,\n }\n\n for (let i = 0; i < batches.length; i++) {\n const currentBatch = batches[i]\n if (!currentBatch) {\n continue\n }\n\n const batchNumber = i + 1\n const batchStart = i * processorOptions.batchSize\n const originalBatch = originalDocs\n ? originalDocs.slice(batchStart, batchStart + currentBatch.length)\n : currentBatch\n\n const batchToProcess: Record<string, unknown>[] =\n hooks?.before && currentBatch.length > 0\n ? ((await hooks.before({\n batchNumber,\n data: currentBatch as Parameters<ImportBeforeHook>[0]['data'],\n format,\n originalData: originalBatch,\n req,\n totalBatches,\n })) as Record<string, unknown>[])\n : currentBatch\n\n const batchResult = await processImportBatch({\n batch: batchToProcess,\n batchIndex: i,\n collectionSlug,\n importMode,\n matchField,\n options: processorOptions,\n req,\n user,\n })\n\n let batchImported = 0\n let batchUpdated = 0\n for (const success of batchResult.successful) {\n if (success.operation === 'created') {\n result.imported++\n batchImported++\n } else if (success.operation === 'updated') {\n result.updated++\n batchUpdated++\n } else {\n // Fallback\n if (importMode === 'create') {\n result.imported++\n batchImported++\n } else {\n result.updated++\n batchUpdated++\n }\n }\n }\n\n for (const error of batchResult.failed) {\n result.errors.push({\n doc: error.documentData,\n error: error.error,\n index: error.rowNumber - 1, // Convert back to 0-indexed\n })\n }\n\n if (hooks?.after) {\n const batchHookResult: ImportResult = {\n errors:\n batchResult.failed.length > 0 ? result.errors.slice(-batchResult.failed.length) : [],\n imported: batchImported,\n total: batchToProcess.length,\n updated: batchUpdated,\n }\n await hooks.after({\n batchNumber,\n format,\n originalData: originalBatch,\n req,\n result: batchHookResult,\n totalBatches,\n })\n }\n }\n\n return result\n }\n\n return {\n processImport,\n }\n}\n"],"names":["isolateObjectProperty","categorizeError","createBatches","extractErrorMessage","extractMultiLocaleData","data","configuredLocales","defaultLocale","flatData","localeUpdates","hasMultiLocale","length","localeSet","Set","key","value","Object","entries","Array","isArray","valueObj","localeKeys","keys","filter","k","has","baseLocale","includes","locale","processImportBatch","batch","batchIndex","collectionSlug","importMode","matchField","options","req","reqFromArgs","user","result","failed","successful","transactionID","undefined","collectionEntry","payload","collections","collectionConfig","config","collectionHasVersions","Boolean","versions","hasCustomIdField","customIDType","localization","localeCodes","startingRowNumber","batchSize","i","document","rowNumber","savedDocument","existingDocResult","createData","id","draftOption","statusValue","_status","defaultVersionStatus","isPublished","debug","logger","info","msg","willSetDraft","title","titleIsNull","titleType","defaultLocaleReq","create","collection","draft","overrideAccess","localeData","update","error","err","String","matchValue","Error","isMatchingById","matchValueStr","JSON","stringify","toString","isValidObjectIdFormat","test","find","depth","limit","where","equals","docs","existingDoc","existingId","existingStatus","existingTitle","incomingDocument","mode","updateData","_id","createdAt","updatedAt","reduce","acc","val","substring","newData","status","updateError","matchValueDisplay","operation","push","index","importError","type","documentData","item","itemIndex","errorData","errors","firstError","path","field","createImportBatchProcessor","processorOptions","processImport","processOptions","documents","format","hooks","originalDocs","totalBatches","totalBatchesFromOptions","batches","imported","total","updated","currentBatch","batchNumber","batchStart","originalBatch","slice","batchToProcess","before","originalData","batchResult","batchImported","batchUpdated","success","doc","after","batchHookResult"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,UAAS;AAK/C,SAEEC,eAAe,EACfC,aAAa,EACbC,mBAAmB,QACd,oCAAmC;AAwD1C;;;;;;;;;;;CAWC,GACD,SAASC,uBACPC,IAA6B,EAC7BC,iBAA4B,EAC5BC,aAAsB;IAMtB,MAAMC,WAAoC,CAAC;IAC3C,MAAMC,gBAAyD,CAAC;IAChE,IAAIC,iBAAiB;IAErB,IAAI,CAACJ,qBAAqBA,kBAAkBK,MAAM,KAAK,GAAG;QACxD,OAAO;YAAEH,UAAU;gBAAE,GAAGH,IAAI;YAAC;YAAGK,gBAAgB;YAAOD,eAAe,CAAC;QAAE;IAC3E;IAEA,MAAMG,YAAY,IAAIC,IAAIP;IAE1B,KAAK,MAAM,CAACQ,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACZ,MAAO;QAC/C,IAAIU,SAAS,OAAOA,UAAU,YAAY,CAACG,MAAMC,OA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J;oBACdnH;oBACAG,QAAQ2H;oBACRpB;gBACF;YACF;QACF;QAEA,OAAOvG;IACT;IAEA,OAAO;QACLiG;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/import/batchProcessor.ts"],"sourcesContent":["import type { PayloadRequest, User } from 'payload'\n\nimport { isolateObjectProperty } from 'payload'\n\nimport type { ImportAfterHook, ImportBeforeHook, ImportResult } from '../types.js'\nimport type { ImportMode } from './createImport.js'\n\nimport {\n type BatchError,\n categorizeError,\n createBatches,\n extractErrorMessage,\n} from '../utilities/useBatchProcessor.js'\n\n/**\n * Import-specific batch processor options\n */\nexport interface ImportBatchProcessorOptions {\n batchSize?: number\n defaultVersionStatus?: 'draft' | 'published'\n}\n\n/**\n * Import-specific error type extending the generic BatchError\n */\nexport interface ImportError extends BatchError<Record<string, unknown>> {\n documentData: Record<string, unknown>\n field?: string\n fieldLabel?: string\n rowNumber: number // 1-indexed for user clarity\n}\n\n/**\n * Result from processing a single import batch\n */\nexport interface ImportBatchResult {\n failed: Array<ImportError>\n successful: Array<{\n document: Record<string, unknown>\n index: number\n operation?: 'created' | 'updated'\n result: Record<string, unknown>\n }>\n}\n\n/**\n * Options for processing an import operation\n */\nexport interface ImportProcessOptions {\n collectionSlug: string\n docs: Record<string, unknown>[]\n /** Export format — passed through to hook args */\n format?: 'csv' | 'json'\n /** Lifecycle hooks for this import operation */\n hooks?: {\n after?: ImportAfterHook\n before?: ImportBeforeHook\n }\n importMode: ImportMode\n matchField?: string\n /** Raw parsed rows before unflattening — used as originalData in hooks */\n originalDocs?: Record<string, unknown>[]\n req: PayloadRequest\n /** Total number of batches (pre-computed for hook args) */\n totalBatches?: number\n user?: User\n}\n\n/**\n * Separates multi-locale data from a document for sequential locale updates.\n *\n * When a field has locale-keyed values (e.g., { title: { en: 'Hello', es: 'Hola' } }),\n * this extracts the default locale's data for initial create/update, and stores\n * remaining locales for subsequent update calls.\n *\n * @returns\n * - flatData: Document with default locale values extracted (for initial operation)\n * - hasMultiLocale: Whether any multi-locale fields were found\n * - localeUpdates: Map of locale -> field data for follow-up updates\n */\nfunction extractMultiLocaleData(\n data: Record<string, unknown>,\n configuredLocales?: string[],\n defaultLocale?: string,\n): {\n flatData: Record<string, unknown>\n hasMultiLocale: boolean\n localeUpdates: Record<string, Record<string, unknown>>\n} {\n const flatData: Record<string, unknown> = {}\n const localeUpdates: Record<string, Record<string, unknown>> = {}\n let hasMultiLocale = false\n\n if (!configuredLocales || configuredLocales.length === 0) {\n return { flatData: { ...data }, hasMultiLocale: false, localeUpdates: {} }\n }\n\n const localeSet = new Set(configuredLocales)\n\n for (const [key, value] of Object.entries(data)) {\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const valueObj = value as Record<string, unknown>\n const localeKeys = Object.keys(valueObj).filter((k) => localeSet.has(k))\n\n if (localeKeys.length > 0) {\n hasMultiLocale = true\n const baseLocale =\n defaultLocale && localeKeys.includes(defaultLocale) ? defaultLocale : localeKeys[0]\n if (baseLocale) {\n flatData[key] = valueObj[baseLocale]\n for (const locale of localeKeys) {\n if (locale !== baseLocale) {\n if (!localeUpdates[locale]) {\n localeUpdates[locale] = {}\n }\n localeUpdates[locale][key] = valueObj[locale]\n }\n }\n }\n } else {\n flatData[key] = value\n }\n } else {\n flatData[key] = value\n }\n }\n\n return { flatData, hasMultiLocale, localeUpdates }\n}\n\ntype ProcessImportBatchOptions = {\n batch: Record<string, unknown>[]\n batchIndex: number\n collectionSlug: string\n importMode: ImportMode\n matchField: string | undefined\n options: { batchSize: number; defaultVersionStatus: 'draft' | 'published' }\n req: PayloadRequest\n user?: User\n}\n\n/**\n * Processes a batch of documents for import based on the import mode.\n *\n * For each document in the batch:\n * - create: Creates a new document (removes any existing ID)\n * - update: Finds existing document by matchField and updates it\n * - upsert: Updates if found, creates if not found\n *\n * Handles versioned collections, multi-locale data, and MongoDB ObjectID validation.\n * Continues processing remaining documents even if individual imports fail.\n */\nasync function processImportBatch({\n batch,\n batchIndex,\n collectionSlug,\n importMode,\n matchField,\n options,\n req: reqFromArgs,\n user,\n}: ProcessImportBatchOptions): Promise<ImportBatchResult> {\n const result: ImportBatchResult = {\n failed: [],\n successful: [],\n }\n // Create a request proxy that isolates the transactionID property, then clear it.\n // This is critical because if a nested operation fails (e.g., Forbidden due to access control),\n // Payload's error handling calls killTransaction(req), which would kill the parent's transaction\n // if we shared the same transaction. By isolating and clearing transactionID, each nested\n // operation either uses no transaction or starts its own, independent of the parent.\n const req = isolateObjectProperty(reqFromArgs, 'transactionID')\n req.transactionID = undefined\n\n const collectionEntry = req.payload.collections[collectionSlug]\n\n const collectionConfig = collectionEntry?.config\n const collectionHasVersions = Boolean(collectionConfig?.versions)\n const hasCustomIdField = Boolean(collectionEntry?.customIDType)\n\n const configuredLocales = req.payload.config.localization\n ? req.payload.config.localization.localeCodes\n : undefined\n\n const defaultLocale = req.payload.config.localization\n ? req.payload.config.localization.defaultLocale\n : undefined\n\n const startingRowNumber = batchIndex * options.batchSize\n\n for (let i = 0; i < batch.length; i++) {\n const document = batch[i]\n if (!document) {\n continue\n }\n const rowNumber = startingRowNumber + i + 1\n\n try {\n let savedDocument: Record<string, unknown> | undefined\n let existingDocResult: { docs: Array<Record<string, unknown>> } | undefined\n\n if (importMode === 'create') {\n const createData = { ...document }\n if (!hasCustomIdField) {\n delete createData.id\n }\n\n let draftOption: boolean | undefined\n if (collectionHasVersions) {\n const statusValue = createData._status || options.defaultVersionStatus\n const isPublished = statusValue !== 'draft'\n draftOption = !isPublished\n createData._status = statusValue\n\n if (req.payload.config.debug) {\n req.payload.logger.info({\n _status: createData._status,\n isPublished,\n msg: 'Status handling in create',\n willSetDraft: draftOption,\n })\n }\n }\n\n if (req.payload.config.debug && 'title' in createData) {\n req.payload.logger.info({\n msg: 'Creating document',\n title: createData.title,\n titleIsNull: createData.title === null,\n titleType: typeof createData.title,\n })\n }\n\n // Check if we have multi-locale data and extract it\n const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(\n createData,\n configuredLocales,\n defaultLocale,\n )\n\n if (hasMultiLocale) {\n // Create with default locale data\n const defaultLocaleReq = defaultLocale ? { ...req, locale: defaultLocale } : req\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: flatData,\n draft: draftOption,\n overrideAccess: false,\n req: defaultLocaleReq,\n user,\n })\n\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n await req.payload.update({\n id: savedDocument.id as number | string,\n collection: collectionSlug,\n data: localeData,\n draft: collectionHasVersions ? false : undefined,\n overrideAccess: false,\n req: { ...req, locale },\n user,\n })\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `Failed to update locale ${locale} for document ${String(savedDocument.id)}`,\n })\n }\n }\n }\n } else {\n // No multi-locale data, create normally\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: createData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n }\n } else if (importMode === 'update' || importMode === 'upsert') {\n const matchValue = document[matchField || 'id']\n if (!matchValue) {\n throw new Error(`Match field \"${matchField || 'id'}\" not found in document`)\n }\n\n // Special handling for ID field with MongoDB\n // If matching by 'id' and it's not a valid ObjectID format, handle specially\n const isMatchingById = (matchField || 'id') === 'id'\n\n // Check if it's a valid MongoDB ObjectID format (24 hex chars)\n // Note: matchValue could be string, number, or ObjectID object\n let matchValueStr: string\n if (typeof matchValue === 'object' && matchValue !== null) {\n matchValueStr = JSON.stringify(matchValue)\n } else if (typeof matchValue === 'string') {\n matchValueStr = matchValue\n } else if (typeof matchValue === 'number') {\n matchValueStr = matchValue.toString()\n } else {\n // For other types, use JSON.stringify\n matchValueStr = JSON.stringify(matchValue)\n }\n const isValidObjectIdFormat = /^[0-9a-f]{24}$/i.test(matchValueStr)\n\n try {\n existingDocResult = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: 1,\n overrideAccess: false,\n req,\n user,\n where: {\n [matchField || 'id']: {\n equals: matchValue,\n },\n },\n })\n } catch (error) {\n // MongoDB may throw for invalid ObjectID format - handle gracefully for upsert\n if (isMatchingById && importMode === 'upsert' && !isValidObjectIdFormat) {\n existingDocResult = { docs: [] }\n } else if (isMatchingById && importMode === 'update' && !isValidObjectIdFormat) {\n throw new Error(`Invalid ID format for update: ${matchValueStr}`)\n } else {\n throw error\n }\n }\n\n if (existingDocResult.docs.length > 0) {\n const existingDoc = existingDocResult.docs[0]\n if (!existingDoc) {\n throw new Error(`Document not found`)\n }\n\n // Debug: log what we found\n if (req.payload.config.debug) {\n req.payload.logger.info({\n existingId: existingDoc.id,\n existingStatus: existingDoc._status,\n existingTitle: existingDoc.title,\n incomingDocument: document,\n mode: importMode,\n msg: 'Found existing document for update',\n })\n }\n\n const updateData = { ...document }\n // Remove ID and internal fields from update data\n delete updateData.id\n delete updateData._id\n delete updateData.createdAt\n delete updateData.updatedAt\n\n // Check if we have multi-locale data and extract it\n const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(\n updateData,\n configuredLocales,\n defaultLocale,\n )\n\n if (req.payload.config.debug) {\n req.payload.logger.info({\n existingId: existingDoc.id,\n hasMultiLocale,\n mode: importMode,\n msg: 'Updating document in upsert/update mode',\n updateData: Object.keys(hasMultiLocale ? flatData : updateData).reduce(\n (acc, key) => {\n const val = (hasMultiLocale ? flatData : updateData)[key]\n acc[key] =\n typeof val === 'string' && val.length > 50 ? val.substring(0, 50) + '...' : val\n return acc\n },\n {} as Record<string, unknown>,\n ),\n })\n }\n\n if (hasMultiLocale) {\n // Update with default locale data\n const defaultLocaleReq = defaultLocale ? { ...req, locale: defaultLocale } : req\n savedDocument = await req.payload.update({\n id: existingDoc.id as number | string,\n collection: collectionSlug,\n data: flatData,\n depth: 0,\n // Don't specify draft - this creates a new draft for versioned collections\n overrideAccess: false,\n req: defaultLocaleReq,\n user,\n })\n\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n await req.payload.update({\n id: existingDoc.id as number | string,\n collection: collectionSlug,\n data: localeData,\n depth: 0,\n overrideAccess: false,\n req: { ...req, locale },\n user,\n })\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `Failed to update locale ${locale} for document ${String(existingDoc.id)}`,\n })\n }\n }\n }\n } else {\n // No multi-locale data, update normally\n try {\n // Extra debug: log before update\n if (req.payload.config.debug) {\n req.payload.logger.info({\n existingId: existingDoc.id,\n existingTitle: existingDoc.title,\n msg: 'About to update document',\n newData: updateData,\n })\n }\n\n // Update the document - don't specify draft to let Payload handle versions properly\n // This will create a new draft version for collections with versions enabled\n savedDocument = await req.payload.update({\n id: existingDoc.id as number | string,\n collection: collectionSlug,\n data: updateData,\n depth: 0,\n // Don't specify draft - this creates a new draft for versioned collections\n overrideAccess: false,\n req,\n user,\n })\n\n if (req.payload.config.debug && savedDocument) {\n req.payload.logger.info({\n id: savedDocument.id,\n msg: 'Update completed',\n status: savedDocument._status,\n title: savedDocument.title,\n })\n }\n } catch (updateError) {\n req.payload.logger.error({\n id: existingDoc.id,\n err: updateError,\n msg: 'Update failed',\n })\n throw updateError\n }\n }\n } else if (importMode === 'upsert') {\n // Create new in upsert mode\n if (req.payload.config.debug) {\n req.payload.logger.info({\n document,\n matchField: matchField || 'id',\n matchValue: document[matchField || 'id'],\n msg: 'No existing document found, creating new in upsert mode',\n })\n }\n\n const createData = { ...document }\n if (!hasCustomIdField) {\n delete createData.id\n }\n\n // Only handle _status for versioned collections\n let draftOption: boolean | undefined\n if (collectionHasVersions) {\n // Use defaultVersionStatus from config if _status not provided\n const statusValue = createData._status || options.defaultVersionStatus\n const isPublished = statusValue !== 'draft'\n draftOption = !isPublished\n createData._status = statusValue\n }\n\n // Check if we have multi-locale data and extract it\n const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(\n createData,\n configuredLocales,\n defaultLocale,\n )\n\n if (hasMultiLocale) {\n // Create with default locale data\n const defaultLocaleReq = defaultLocale ? { ...req, locale: defaultLocale } : req\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: flatData,\n draft: draftOption,\n overrideAccess: false,\n req: defaultLocaleReq,\n user,\n })\n\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n await req.payload.update({\n id: savedDocument.id as number | string,\n collection: collectionSlug,\n data: localeData,\n draft: collectionHasVersions ? false : undefined,\n overrideAccess: false,\n req: { ...req, locale },\n user,\n })\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `Failed to update locale ${locale} for document ${String(savedDocument.id)}`,\n })\n }\n }\n }\n } else {\n // No multi-locale data, create normally\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: createData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n }\n } else {\n // Update mode but document not found\n let matchValueDisplay: string\n if (typeof matchValue === 'object' && matchValue !== null) {\n matchValueDisplay = JSON.stringify(matchValue)\n } else if (typeof matchValue === 'string') {\n matchValueDisplay = matchValue\n } else if (typeof matchValue === 'number') {\n matchValueDisplay = matchValue.toString()\n } else {\n // For other types, use JSON.stringify to avoid [object Object]\n matchValueDisplay = JSON.stringify(matchValue)\n }\n throw new Error(`Document with ${matchField || 'id'}=\"${matchValueDisplay}\" not found`)\n }\n } else {\n throw new Error(`Unknown import mode: ${String(importMode)}`)\n }\n\n if (savedDocument) {\n // Determine operation type for proper counting\n let operation: 'created' | 'updated' | undefined\n if (importMode === 'create') {\n operation = 'created'\n } else if (importMode === 'update') {\n operation = 'updated'\n } else if (importMode === 'upsert') {\n if (existingDocResult && existingDocResult.docs.length > 0) {\n operation = 'updated'\n } else {\n operation = 'created'\n }\n }\n\n result.successful.push({\n document,\n index: rowNumber - 1, // Store as 0-indexed\n operation,\n result: savedDocument,\n })\n }\n } catch (error) {\n const importError: ImportError = {\n type: categorizeError(error),\n documentData: document || {},\n error: extractErrorMessage(error),\n item: document || {},\n itemIndex: rowNumber - 1,\n rowNumber,\n }\n\n // Try to extract field information from validation errors\n if (error && typeof error === 'object' && 'data' in error) {\n const errorData = error as { data?: { errors?: Array<{ path?: string }> } }\n if (errorData.data?.errors && Array.isArray(errorData.data.errors)) {\n const firstError = errorData.data.errors[0]\n if (firstError?.path) {\n importError.field = firstError.path\n }\n }\n }\n\n result.failed.push(importError)\n // Always continue processing all rows\n }\n }\n\n return result\n}\n\nexport function createImportBatchProcessor(options: ImportBatchProcessorOptions = {}) {\n const processorOptions = {\n batchSize: options.batchSize ?? 100,\n defaultVersionStatus: options.defaultVersionStatus ?? 'published',\n }\n\n const processImport = async (processOptions: ImportProcessOptions): Promise<ImportResult> => {\n const {\n collectionSlug,\n docs: documents,\n format = 'csv',\n hooks,\n importMode,\n matchField,\n originalDocs: originalDocs,\n req,\n totalBatches: totalBatchesFromOptions,\n user,\n } = processOptions\n const batches = createBatches(documents, processorOptions.batchSize)\n const totalBatches = totalBatchesFromOptions ?? batches.length\n\n const result: ImportResult = {\n errors: [],\n imported: 0,\n total: documents.length,\n updated: 0,\n }\n\n for (let i = 0; i < batches.length; i++) {\n const currentBatch = batches[i]\n if (!currentBatch) {\n continue\n }\n\n const batchNumber = i + 1\n const batchStart = i * processorOptions.batchSize\n const originalBatch = originalDocs\n ? originalDocs.slice(batchStart, batchStart + currentBatch.length)\n : currentBatch\n\n const batchToProcess: Record<string, unknown>[] =\n hooks?.before && currentBatch.length > 0\n ? ((await hooks.before({\n batchNumber,\n data: currentBatch as Parameters<ImportBeforeHook>[0]['data'],\n format,\n originalData: originalBatch,\n req,\n totalBatches,\n })) as Record<string, unknown>[])\n : currentBatch\n\n const batchResult = await processImportBatch({\n batch: batchToProcess,\n batchIndex: i,\n collectionSlug,\n importMode,\n matchField,\n options: processorOptions,\n req,\n user,\n })\n\n let batchImported = 0\n let batchUpdated = 0\n for (const success of batchResult.successful) {\n if (success.operation === 'created') {\n result.imported++\n batchImported++\n } else if (success.operation === 'updated') {\n result.updated++\n batchUpdated++\n } else {\n // Fallback\n if (importMode === 'create') {\n result.imported++\n batchImported++\n } else {\n result.updated++\n batchUpdated++\n }\n }\n }\n\n for (const error of batchResult.failed) {\n result.errors.push({\n doc: error.documentData,\n error: error.error,\n index: error.rowNumber - 1, // Convert back to 0-indexed\n })\n }\n\n if (hooks?.after) {\n const batchHookResult: ImportResult = {\n errors:\n batchResult.failed.length > 0 ? result.errors.slice(-batchResult.failed.length) : [],\n imported: batchImported,\n total: batchToProcess.length,\n updated: batchUpdated,\n }\n await hooks.after({\n batchNumber,\n format,\n originalData: originalBatch,\n req,\n result: batchHookResult,\n totalBatches,\n })\n }\n }\n\n return result\n }\n\n return {\n processImport,\n }\n}\n"],"names":["isolateObjectProperty","categorizeError","createBatches","extractErrorMessage","extractMultiLocaleData","data","configuredLocales","defaultLocale","flatData","localeUpdates","hasMultiLocale","length","localeSet","Set","key","value","Object","entries","Array","isArray","valueObj","localeKeys","keys","filter","k","has","baseLocale","includes","locale","processImportBatch","batch","batchIndex","collectionSlug","importMode","matchField","options","req","reqFromArgs","user","result","failed","successful","transactionID","undefined","collectionEntry","payload","collections","collectionConfig","config","collectionHasVersions","Boolean","versions","hasCustomIdField","customIDType","localization","localeCodes","startingRowNumber","batchSize","i","document","rowNumber","savedDocument","existingDocResult","createData","id","draftOption","statusValue","_status","defaultVersionStatus","isPublished","debug","logger","info","msg","willSetDraft","title","titleIsNull","titleType","defaultLocaleReq","create","collection","draft","overrideAccess","localeData","update","error","err","String","matchValue","Error","isMatchingById","matchValueStr","JSON","stringify","toString","isValidObjectIdFormat","test","find","depth","limit","where","equals","docs","existingDoc","existingId","existingStatus","existingTitle","incomingDocument","mode","updateData","_id","createdAt","updatedAt","reduce","acc","val","substring","newData","status","updateError","matchValueDisplay","operation","push","index","importError","type","documentData","item","itemIndex","errorData","errors","firstError","path","field","createImportBatchProcessor","processorOptions","processImport","processOptions","documents","format","hooks","originalDocs","totalBatches","totalBatchesFromOptions","batches","imported","total","updated","currentBatch","batchNumber","batchStart","originalBatch","slice","batchToProcess","before","originalData","batchResult","batchImported","batchUpdated","success","doc","after","batch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Y;oBACF,OAAO;wBACLtH,OAAO4G,OAAO;wBACdW;oBACF;gBACF;YACF;YAEA,KAAK,MAAMzE,SAASuE,YAAYpH,MAAM,CAAE;gBACtCD,OAAO2F,MAAM,CAACR,IAAI,CAAC;oBACjBsC,KAAK3E,MAAMyC,YAAY;oBACvBzC,OAAOA,MAAMA,KAAK;oBAClBsC,OAAOtC,MAAMzB,SAAS,GAAG;gBAC3B;YACF;YAEA,IAAIgF,OAAOqB,OAAO;gBAChB,MAAMC,kBAAgC;oBACpChC,QACE0B,YAAYpH,MAAM,CAAC7B,MAAM,GAAG,IAAI4B,OAAO2F,MAAM,CAACsB,KAAK,CAAC,CAACI,YAAYpH,MAAM,CAAC7B,MAAM,IAAI,EAAE;oBACtFsI,UAAUY;oBACVX,OAAOO,eAAe9I,MAAM;oBAC5BwI,SAASW;gBACX;gBACA,MAAMlB,MAAMqB,KAAK,CAAC;oBAChBZ;oBACAV;oBACAgB,cAAcJ;oBACdnH;oBACAG,QAAQ2H;oBACRpB;gBACF;YACF;QACF;QAEA,OAAOvG;IACT;IAEA,OAAO;QACLiG;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"createImport.d.ts","sourceRoot":"","sources":["../../src/import/createImport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,SAAS,CAAA;AAIxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAU/C,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEvD,MAAM,MAAM,MAAM,GAAG;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE;QACL,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,EAAE,MAAM,CAAA;QAChB,IAAI,EAAE,MAAM,CAAA;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AE,UAAU,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,oBAAoB,CAAC,EAAE,OAAO,GAAG,WAAW,CAAA;IAC5C,GAAG,EAAE,cAAc,CAAA;CACpB,GAAG,MAAM,CAAA;AAEV,eAAO,MAAM,YAAY,GAAU,0IAahC,gBAAgB,KAAG,OAAO,CAAC,YAAY,CAuLzC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/import/createImport.ts"],"sourcesContent":["import type { PayloadRequest, TypedUser } from 'payload'\n\nimport { APIError } from 'payload'\n\nimport type { ImportResult } from '../types.js'\n\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 { unflattenObject } from '../utilities/unflattenObject.js'\nimport { createImportBatchProcessor } from './batchProcessor.js'\n\nexport type ImportMode = 'create' | 'update' | 'upsert'\n\nexport type Import = {\n /**\n * Number of documents to process in each batch during import\n * @default 100\n */\n batchSize?: number\n collectionSlug: string\n /**\n * If true, enabled debug logging\n */\n debug?: boolean\n file?: {\n data: Buffer\n mimetype: string\n name: string\n }\n format: 'csv' | 'json'\n id?: number | string\n /**\n * Import mode: create, update or upset\n */\n importMode: ImportMode\n matchField?: string\n /**\n * Maximum number of documents that can be imported in a single operation.\n * This value has already been resolved from the plugin config.\n */\n maxLimit?: number\n name: string\n userCollection?: string\n userID?: number | string\n}\n\nexport type CreateImportArgs = {\n defaultVersionStatus?: 'draft' | 'published'\n req: PayloadRequest\n} & Import\n\nexport const createImport = async ({\n batchSize = 100,\n collectionSlug,\n debug = false,\n defaultVersionStatus = 'published',\n file,\n format,\n importMode = 'create',\n matchField = 'id',\n maxLimit,\n req,\n userCollection,\n userID,\n}: CreateImportArgs): Promise<ImportResult> => {\n let user: TypedUser | undefined\n\n if (userCollection && userID) {\n user = (await req.payload.findByID({\n id: userID,\n collection: userCollection,\n req,\n })) as TypedUser\n }\n\n if (!user) {\n throw new APIError('User is required for import operations', 401, null, true)\n }\n\n if (debug) {\n req.payload.logger.debug({\n collectionSlug,\n format,\n importMode,\n matchField,\n msg: 'Starting import process with args:',\n transactionID: req.transactionID, // Log transaction ID to verify we're in same transaction\n })\n }\n\n if (!collectionSlug) {\n throw new APIError('Collection slug is required', 400, null, true)\n }\n\n if (!file || !file?.data) {\n throw new APIError('No file data provided for import', 400, null, true)\n }\n\n if (debug) {\n req.payload.logger.debug({\n fileName: file.name,\n fileSize: file.data.length,\n mimeType: file.mimetype,\n msg: 'File info',\n })\n }\n\n const collectionConfig = req.payload.config.collections.find(\n ({ slug }) => slug === collectionSlug,\n )\n\n if (!collectionConfig) {\n if (!collectionSlug) {\n throw new APIError('Collection slug is required', 400, null, true)\n }\n throw new APIError(`Collection with slug ${collectionSlug} not found`, 400, null, true)\n }\n\n // Get disabled fields configuration\n const disabledFields =\n collectionConfig.admin?.custom?.['plugin-import-export']?.disabledFields ?? []\n\n const importHooks = collectionConfig.custom?.['plugin-import-export']?.importHooks\n\n // Get beforeImport functions for field transformations\n const importFieldHooks = getImportFieldFunctions({\n fields: collectionConfig.flattenedFields || [],\n })\n\n // Parse the file data\n let originalDocs: Record<string, unknown>[] | undefined\n let documents: Record<string, unknown>[]\n if (format === 'csv') {\n const rawData = await parseCSV({\n data: file.data,\n req,\n })\n\n originalDocs = rawData\n documents = rawData\n\n // Unflatten CSV data\n documents = documents\n .map((doc) => {\n const unflattened = unflattenObject({\n data: doc,\n fields: collectionConfig.flattenedFields ?? [],\n format,\n importFieldHooks,\n req,\n })\n return unflattened ?? {}\n })\n .filter((doc) => doc && Object.keys(doc).length > 0)\n\n if (debug) {\n req.payload.logger.debug({\n documentCount: documents.length,\n msg: 'After unflattening CSV',\n rawDataCount: rawData.length,\n })\n }\n } else {\n const parsedDocs = parseJSON({ data: file.data, req })\n originalDocs = parsedDocs\n // Apply field-level import hooks for JSON format\n documents = parsedDocs.map((doc) =>\n applyFieldHooks({\n type: 'beforeImport',\n data: doc,\n fieldHooks: importFieldHooks,\n fields: collectionConfig.flattenedFields ?? [],\n format,\n operation: 'import',\n req,\n }),\n )\n }\n\n if (debug) {\n req.payload.logger.debug({\n msg: `Parsed ${documents.length} documents from ${format} file`,\n })\n if (documents.length > 0) {\n req.payload.logger.debug({\n doc: documents[0],\n msg: 'First document sample:',\n })\n }\n }\n\n // Enforce maxLimit before processing to save memory/time\n if (typeof maxLimit === 'number' && maxLimit > 0 && documents.length > maxLimit) {\n throw new APIError(\n `Import file contains ${documents.length} documents but limit is ${maxLimit}`,\n 400,\n null,\n true,\n )\n }\n\n // Remove disabled fields from all documents\n if (disabledFields.length > 0) {\n documents = documents.map((doc) => removeDisabledFields(doc, disabledFields))\n }\n\n if (debug) {\n req.payload.logger.debug({\n batchSize,\n documentCount: documents.length,\n msg: 'Processing import in batches',\n })\n }\n\n // Create batch processor\n const processor = createImportBatchProcessor({\n batchSize,\n defaultVersionStatus,\n })\n\n const totalBatches = documents.length > 0 ? Math.ceil(documents.length / batchSize) : 1\n\n // Process import with batch processor\n const result = await processor.processImport({\n collectionSlug,\n docs: documents,\n format,\n hooks: importHooks,\n importMode,\n matchField,\n originalDocs,\n req,\n totalBatches,\n user,\n })\n\n if (debug) {\n req.payload.logger.info({\n errors: result.errors.length,\n imported: result.imported,\n msg: 'Import completed',\n total: result.total,\n updated: result.updated,\n })\n }\n\n return result\n}\n"],"names":["APIError","applyFieldHooks","getImportFieldFunctions","parseCSV","parseJSON","removeDisabledFields","unflattenObject","createImportBatchProcessor","createImport","batchSize","collectionSlug","debug","defaultVersionStatus","file","format","importMode","matchField","maxLimit","req","userCollection","userID","user","payload","findByID","id","collection","logger","msg","transactionID","data","fileName","name","fileSize","length","mimeType","mimetype","collectionConfig","config","collections","find","slug","disabledFields","admin","custom","importHooks","importFieldHooks","fields","flattenedFields","originalDocs","documents","rawData","map","doc","unflattened","filter","Object","keys","documentCount","rawDataCount","parsedDocs","type","fieldHooks","operation","processor","totalBatches","Math","ceil","result","processImport","docs","hooks","info","errors","imported","total","updated"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,UAAS;AAIlC,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,uBAAuB,QAAQ,0CAAyC;AACjF,SAASC,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,SAAS,QAAQ,4BAA2B;AACrD,SAASC,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,0BAA0B,QAAQ,sBAAqB;AA0ChE,OAAO,MAAMC,eAAe,OAAO,EACjCC,YAAY,GAAG,EACfC,cAAc,EACdC,QAAQ,KAAK,EACbC,uBAAuB,WAAW,EAClCC,IAAI,EACJC,MAAM,EACNC,aAAa,QAAQ,EACrBC,aAAa,IAAI,EACjBC,QAAQ,EACRC,GAAG,EACHC,cAAc,EACdC,MAAM,EACW;IACjB,IAAIC;IAEJ,IAAIF,kBAAkBC,QAAQ;QAC5BC,OAAQ,MAAMH,IAAII,OAAO,CAACC,QAAQ,CAAC;YACjCC,IAAIJ;YACJK,YAAYN;YACZD;QACF;IACF;IAEA,IAAI,CAACG,MAAM;QACT,MAAM,IAAIrB,SAAS,0CAA0C,KAAK,MAAM;IAC1E;IAEA,IAAIW,OAAO;QACTO,IAAII,OAAO,CAACI,MAAM,CAACf,KAAK,CAAC;YACvBD;YACAI;YACAC;YACAC;YACAW,KAAK;YACLC,eAAeV,IAAIU,aAAa;QAClC;IACF;IAEA,IAAI,CAAClB,gBAAgB;QACnB,MAA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,MAAQ/C,qBAAqB+C,KAAKX;IAC/D;IAEA,IAAI9B,OAAO;QACTO,IAAII,OAAO,CAACI,MAAM,CAACf,KAAK,CAAC;YACvBF;YACAgD,eAAeR,UAAUhB,MAAM;YAC/BN,KAAK;QACP;IACF;IAEA,yBAAyB;IACzB,MAAMoC,YAAYxD,2BAA2B;QAC3CE;QACAG;IACF;IAEA,MAAMoD,eAAef,UAAUhB,MAAM,GAAG,IAAIgC,KAAKC,IAAI,CAACjB,UAAUhB,MAAM,GAAGxB,aAAa;IAEtF,sCAAsC;IACtC,MAAM0D,SAAS,MAAMJ,UAAUK,aAAa,CAAC;QAC3C1D;QACA2D,MAAMpB;QACNnC;QACAwD,OAAO1B;QACP7B;QACAC;QACAgC;QACA9B;QACA8C;QACA3C;IACF;IAEA,IAAIV,OAAO;QACTO,IAAII,OAAO,CAACI,MAAM,CAAC6C,IAAI,CAAC;YACtBC,QAAQL,OAAOK,MAAM,CAACvC,MAAM;YAC5BwC,UAAUN,OAAOM,QAAQ;YACzB9C,KAAK;YACL+C,OAAOP,OAAOO,KAAK;YACnBC,SAASR,OAAOQ,OAAO;QACzB;IACF;IAEA,OAAOR;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/import/createImport.ts"],"sourcesContent":["import type { PayloadRequest, User } from 'payload'\n\nimport { APIError } from 'payload'\n\nimport type { ImportResult } from '../types.js'\n\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 { unflattenObject } from '../utilities/unflattenObject.js'\nimport { createImportBatchProcessor } from './batchProcessor.js'\n\nexport type ImportMode = 'create' | 'update' | 'upsert'\n\nexport type Import = {\n /**\n * Number of documents to process in each batch during import\n * @default 100\n */\n batchSize?: number\n collectionSlug: string\n /**\n * If true, enabled debug logging\n */\n debug?: boolean\n file?: {\n data: Buffer\n mimetype: string\n name: string\n }\n format: 'csv' | 'json'\n id?: number | string\n /**\n * Import mode: create, update or upset\n */\n importMode: ImportMode\n matchField?: string\n /**\n * Maximum number of documents that can be imported in a single operation.\n * This value has already been resolved from the plugin config.\n */\n maxLimit?: number\n name: string\n userCollection?: string\n userID?: number | string\n}\n\nexport type CreateImportArgs = {\n defaultVersionStatus?: 'draft' | 'published'\n req: PayloadRequest\n} & Import\n\nexport const createImport = async ({\n batchSize = 100,\n collectionSlug,\n debug = false,\n defaultVersionStatus = 'published',\n file,\n format,\n importMode = 'create',\n matchField = 'id',\n maxLimit,\n req,\n userCollection,\n userID,\n}: CreateImportArgs): Promise<ImportResult> => {\n let user: undefined | User\n\n if (userCollection && userID) {\n user = (await req.payload.findByID({\n id: userID,\n collection: userCollection,\n req,\n })) as User\n }\n\n if (!user) {\n throw new APIError('User is required for import operations', 401, null, true)\n }\n\n if (debug) {\n req.payload.logger.debug({\n collectionSlug,\n format,\n importMode,\n matchField,\n msg: 'Starting import process with args:',\n transactionID: req.transactionID, // Log transaction ID to verify we're in same transaction\n })\n }\n\n if (!collectionSlug) {\n throw new APIError('Collection slug is required', 400, null, true)\n }\n\n if (!file || !file?.data) {\n throw new APIError('No file data provided for import', 400, null, true)\n }\n\n if (debug) {\n req.payload.logger.debug({\n fileName: file.name,\n fileSize: file.data.length,\n mimeType: file.mimetype,\n msg: 'File info',\n })\n }\n\n const collectionConfig = req.payload.config.collections.find(\n ({ slug }) => slug === collectionSlug,\n )\n\n if (!collectionConfig) {\n if (!collectionSlug) {\n throw new APIError('Collection slug is required', 400, null, true)\n }\n throw new APIError(`Collection with slug ${collectionSlug} not found`, 400, null, true)\n }\n\n // Get disabled fields configuration\n const disabledFields =\n collectionConfig.admin?.custom?.['plugin-import-export']?.disabledFields ?? []\n\n const importHooks = collectionConfig.custom?.['plugin-import-export']?.importHooks\n\n // Get beforeImport functions for field transformations\n const importFieldHooks = getImportFieldFunctions({\n fields: collectionConfig.flattenedFields || [],\n })\n\n // Parse the file data\n let originalDocs: Record<string, unknown>[] | undefined\n let documents: Record<string, unknown>[]\n if (format === 'csv') {\n const rawData = await parseCSV({\n data: file.data,\n req,\n })\n\n originalDocs = rawData\n documents = rawData\n\n // Unflatten CSV data\n documents = documents\n .map((doc) => {\n const unflattened = unflattenObject({\n data: doc,\n fields: collectionConfig.flattenedFields ?? [],\n format,\n importFieldHooks,\n req,\n })\n return unflattened ?? {}\n })\n .filter((doc) => doc && Object.keys(doc).length > 0)\n\n if (debug) {\n req.payload.logger.debug({\n documentCount: documents.length,\n msg: 'After unflattening CSV',\n rawDataCount: rawData.length,\n })\n }\n } else {\n const parsedDocs = parseJSON({ data: file.data, req })\n originalDocs = parsedDocs\n // Apply field-level import hooks for JSON format\n documents = parsedDocs.map((doc) =>\n applyFieldHooks({\n type: 'beforeImport',\n data: doc,\n fieldHooks: importFieldHooks,\n fields: collectionConfig.flattenedFields ?? [],\n format,\n operation: 'import',\n req,\n }),\n )\n }\n\n if (debug) {\n req.payload.logger.debug({\n msg: `Parsed ${documents.length} documents from ${format} file`,\n })\n if (documents.length > 0) {\n req.payload.logger.debug({\n doc: documents[0],\n msg: 'First document sample:',\n })\n }\n }\n\n // Enforce maxLimit before processing to save memory/time\n if (typeof maxLimit === 'number' && maxLimit > 0 && documents.length > maxLimit) {\n throw new APIError(\n `Import file contains ${documents.length} documents but limit is ${maxLimit}`,\n 400,\n null,\n true,\n )\n }\n\n // Remove disabled fields from all documents\n if (disabledFields.length > 0) {\n documents = documents.map((doc) => removeDisabledFields(doc, disabledFields))\n }\n\n if (debug) {\n req.payload.logger.debug({\n batchSize,\n documentCount: documents.length,\n msg: 'Processing import in batches',\n })\n }\n\n // Create batch processor\n const processor = createImportBatchProcessor({\n batchSize,\n defaultVersionStatus,\n })\n\n const totalBatches = documents.length > 0 ? Math.ceil(documents.length / batchSize) : 1\n\n // Process import with batch processor\n const result = await processor.processImport({\n collectionSlug,\n docs: documents,\n format,\n hooks: importHooks,\n importMode,\n matchField,\n originalDocs,\n req,\n totalBatches,\n user,\n })\n\n if (debug) {\n req.payload.logger.info({\n errors: result.errors.length,\n imported: result.imported,\n msg: 'Import completed',\n total: result.total,\n updated: result.updated,\n })\n }\n\n return result\n}\n"],"names":["APIError","applyFieldHooks","getImportFieldFunctions","parseCSV","parseJSON","removeDisabledFields","unflattenObject","createImportBatchProcessor","createImport","batchSize","collectionSlug","debug","defaultVersionStatus","file","format","importMode","matchField","maxLimit","req","userCollection","userID","user","payload","findByID","id","collection","logger","msg","transactionID","data","fileName","name","fileSize","length","mimeType","mimetype","collectionConfig","config","collections","find","slug","disabledFields","admin","custom","importHooks","importFieldHooks","fields","flattenedFields","originalDocs","documents","rawData","map","doc","unflattened","filter","Object","keys","documentCount","rawDataCount","parsedDocs","type","fieldHooks","operation","processor","totalBatches","Math","ceil","result","processImport","docs","hooks","info","errors","imported","total","updated"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,UAAS;AAIlC,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,uBAAuB,QAAQ,0CAAyC;AACjF,SAASC,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,SAAS,QAAQ,4BAA2B;AACrD,SAASC,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,0BAA0B,QAAQ,sBAAqB;AA0ChE,OAAO,MAAMC,eAAe,OAAO,EACjCC,YAAY,GAAG,EACfC,cAAc,EACdC,QAAQ,KAAK,EACbC,uBAAuB,WAAW,EAClCC,IAAI,EACJC,MAAM,EACNC,aAAa,QAAQ,EACrBC,aAAa,IAAI,EACjBC,QAAQ,EACRC,GAAG,EACHC,cAAc,EACdC,MAAM,EACW;IACjB,IAAIC;IAEJ,IAAIF,kBAAkBC,QAAQ;QAC5BC,OAAQ,MAAMH,IAAII,OAAO,CAACC,QAAQ,CAAC;YACjCC,IAAIJ;YACJK,YAAYN;YACZD;QACF;IACF;I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AAW,KAAKgC,UAAUhB,MAAM,GAAGhB,UAAU;QAC/E,MAAM,IAAIjB,SACR,CAAC,qBAAqB,EAAEiD,UAAUhB,MAAM,CAAC,wBAAwB,EAAEhB,UAAU,EAC7E,KACA,MACA;IAEJ;IAEA,4CAA4C;IAC5C,IAAIwB,eAAeR,MAAM,GAAG,GAAG;QAC7BgB,YAAYA,UAAUE,GAAG,CAAC,CAACC,MAAQ/C,qBAAqB+C,KAAKX;IAC/D;IAEA,IAAI9B,OAAO;QACTO,IAAII,OAAO,CAACI,MAAM,CAACf,KAAK,CAAC;YACvBF;YACAgD,eAAeR,UAAUhB,MAAM;YAC/BN,KAAK;QACP;IACF;IAEA,yBAAyB;IACzB,MAAMoC,YAAYxD,2BAA2B;QAC3CE;QACAG;IACF;IAEA,MAAMoD,eAAef,UAAUhB,MAAM,GAAG,IAAIgC,KAAKC,IAAI,CAACjB,UAAUhB,MAAM,GAAGxB,aAAa;IAEtF,sCAAsC;IACtC,MAAM0D,SAAS,MAAMJ,UAAUK,aAAa,CAAC;QAC3C1D;QACA2D,MAAMpB;QACNnC;QACAwD,OAAO1B;QACP7B;QACAC;QACAgC;QACA9B;QACA8C;QACA3C;IACF;IAEA,IAAIV,OAAO;QACTO,IAAII,OAAO,CAACI,MAAM,CAAC6C,IAAI,CAAC;YACtBC,QAAQL,OAAOK,MAAM,CAACvC,MAAM;YAC5BwC,UAAUN,OAAOM,QAAQ;YACzB9C,KAAK;YACL+C,OAAOP,OAAOO,KAAK;YACnBC,SAASR,OAAOQ,OAAO;QACzB;IACF;IAEA,OAAOR;AACT,EAAC"}
@@ -121,8 +121,8 @@ export const getImportCollection = ({ collectionSlugs, importConfig, pluginConfi
121
121
  matchField: doc.matchField,
122
122
  maxLimit,
123
123
  req,
124
- userCollection: req?.user?.collection || req?.user?.user?.collection,
125
- userID: req?.user?.id || req?.user?.user?.id
124
+ userCollection: req?.user?.collection,
125
+ userID: req?.user?.id
126
126
  });
127
127
  // Determine status
128
128
  let status;
@@ -283,8 +283,8 @@ export const getImportCollection = ({ collectionSlugs, importConfig, pluginConfi
283
283
  importCollection: collectionConfig.slug,
284
284
  importId: doc.id,
285
285
  maxLimit,
286
- userCollection: req.user?.collection || req?.user?.user?.collection,
287
- userID: req?.user?.id || req?.user?.user?.id
286
+ userCollection: req.user?.collection,
287
+ userID: req?.user?.id
288
288
  };
289
289
  await req.payload.jobs.queue({
290
290
  input,
@@ -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;gBAC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YAEA,MAAMd,IAAIG,OAAO,CAAC8D,IAAI,CAACC,KAAK,CAAC;gBAC3BJ;gBACAK,MAAM;YACR;QACF,EAAE,OAAOV,KAAK;YACZzD,IAAIG,OAAO,CAACQ,MAAM,CAACsC,KAAK,CAAC;gBACvBQ;gBACA1C,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 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 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;YAC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,KAAK,CAAC,wCAAwC,EAAEjB,IAAIgB,EAAE,EAAE;YAC1D;QACF;IACF;IAEA,OAAO3C;AACT,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,EAAE;YACvB;;;;;;eAMG;YACH,QAAQ,CAAC,EAAE,OAAO,CAAA;YAClB;;;eAGG;YACH,KAAK,CAAC,EAAE;gBACN;;;;mBAIG;gBACH,YAAY,CAAC,EAAE,qBAAqB,CAAA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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,GAAG,EAAE;QACzB;QAEA,wEAAwE;QACxE,KAAK,MAAMC,cAAc;eAAIX;eAAsBC;SAAkB,CAAE;YACrE,MAAMW,aAAaf,OAAOa,WAAW,CAACG,IAAI,CAAC,CAACN,IAAMA,EAA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gBhB,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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ACjB;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"}
package/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2018-2024 Payload CMS, Inc. <info@payloadcms.com>
3
+ Copyright (c) 2018-2026 Payload CMS, LLC <info@payloadcms.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-import-export",
3
- "version": "4.0.0-internal.688c4d0",
3
+ "version": "4.0.0-internal.811e0a4",
4
4
  "description": "Import-Export plugin for Payload",
5
5
  "keywords": [
6
6
  "payload",
@@ -64,17 +64,17 @@
64
64
  "csv-parse": "5.6.0",
65
65
  "csv-stringify": "6.5.2",
66
66
  "qs-esm": "8.0.1",
67
- "@payloadcms/translations": "4.0.0-internal.688c4d0",
68
- "@payloadcms/ui": "4.0.0-internal.688c4d0"
67
+ "@payloadcms/translations": "4.0.0-internal.811e0a4",
68
+ "@payloadcms/ui": "4.0.0-internal.811e0a4"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@payloadcms/eslint-config": "3.28.0",
72
- "payload": "4.0.0-internal.688c4d0",
73
- "@payloadcms/ui": "4.0.0-internal.688c4d0"
72
+ "@payloadcms/ui": "4.0.0-internal.811e0a4",
73
+ "payload": "4.0.0-internal.811e0a4"
74
74
  },
75
75
  "peerDependencies": {
76
- "payload": "4.0.0-internal.688c4d0",
77
- "@payloadcms/ui": "4.0.0-internal.688c4d0"
76
+ "@payloadcms/ui": "4.0.0-internal.811e0a4",
77
+ "payload": "4.0.0-internal.811e0a4"
78
78
  },
79
79
  "homepage:": "https://payloadcms.com",
80
80
  "scripts": {
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=assets.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/@types/assets.d.ts"],"names":[],"mappings":""}