@payloadcms/plugin-import-export 3.78.0-internal-debug.f663370 → 3.78.0-internal.ab11ffa
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.
- package/dist/components/ExportSaveButton/index.d.ts.map +1 -1
- package/dist/components/ExportSaveButton/index.js +11 -6
- package/dist/components/ExportSaveButton/index.js.map +1 -1
- package/dist/components/FormatField/index.d.ts +3 -0
- package/dist/components/FormatField/index.d.ts.map +1 -0
- package/dist/components/FormatField/index.js +95 -0
- package/dist/components/FormatField/index.js.map +1 -0
- package/dist/export/createExport.d.ts.map +1 -1
- package/dist/export/createExport.js +44 -16
- package/dist/export/createExport.js.map +1 -1
- package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
- package/dist/export/getCreateExportCollectionTask.js +105 -24
- package/dist/export/getCreateExportCollectionTask.js.map +1 -1
- package/dist/export/getExportCollection.d.ts.map +1 -1
- package/dist/export/getExportCollection.js +75 -66
- package/dist/export/getExportCollection.js.map +1 -1
- package/dist/export/getFields.d.ts.map +1 -1
- package/dist/export/getFields.js +4 -7
- package/dist/export/getFields.js.map +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.d.ts.map +1 -1
- package/dist/exports/rsc.js +1 -0
- package/dist/exports/rsc.js.map +1 -1
- package/dist/import/batchProcessor.d.ts.map +1 -1
- package/dist/import/batchProcessor.js +11 -5
- package/dist/import/batchProcessor.js.map +1 -1
- package/dist/import/createImport.d.ts.map +1 -1
- package/dist/import/createImport.js +2 -1
- package/dist/import/createImport.js.map +1 -1
- package/dist/import/getImportCollection.d.ts.map +1 -1
- package/dist/import/getImportCollection.js +229 -181
- package/dist/import/getImportCollection.js.map +1 -1
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -16
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/getPluginCollections.d.ts +4 -1
- package/dist/utilities/getPluginCollections.d.ts.map +1 -1
- package/dist/utilities/getPluginCollections.js +4 -43
- package/dist/utilities/getPluginCollections.js.map +1 -1
- package/dist/utilities/unflattenObject.d.ts.map +1 -1
- package/dist/utilities/unflattenObject.js +5 -0
- package/dist/utilities/unflattenObject.js.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/import/batchProcessor.ts"],"sourcesContent":["import type { PayloadRequest, TypedUser } from 'payload'\n\nimport type { ImportMode, ImportResult } 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 documents: Record<string, unknown>[]\n importMode: ImportMode\n matchField?: string\n req: PayloadRequest\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 first locale's data for initial create/update, and stores\n * remaining locales for subsequent update calls.\n *\n * @returns\n * - flatData: Document with first 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): {\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 firstLocale = localeKeys[0]\n if (firstLocale) {\n flatData[key] = valueObj[firstLocale]\n for (const locale of localeKeys) {\n if (locale !== firstLocale) {\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,\n user,\n}: ProcessImportBatchOptions): Promise<ImportBatchResult> {\n const result: ImportBatchResult = {\n failed: [],\n successful: [],\n }\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 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\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 // Remove _status from data - it's controlled via draft option\n delete createData._status\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 )\n\n if (hasMultiLocale) {\n // Create with default locale data\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: flatData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n\n // Update for other locales\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n const localeReq = { ...req, locale }\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: localeReq,\n user,\n })\n } catch (error) {\n // Log but don't fail the entire import if a locale update fails\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 )\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 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,\n user,\n })\n\n // Update for other locales\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n // Clone the request with the specific locale\n const localeReq = { ...req, locale }\n await req.payload.update({\n id: existingDoc.id as number | string,\n collection: collectionSlug,\n data: localeData,\n depth: 0,\n // Don't specify draft - this creates a new draft for versioned collections\n overrideAccess: false,\n req: localeReq,\n user,\n })\n } catch (error) {\n // Log but don't fail the entire import if a locale update fails\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 // Remove _status from data - it's controlled via draft option\n delete createData._status\n }\n\n // Check if we have multi-locale data and extract it\n const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(\n createData,\n configuredLocales,\n )\n\n if (hasMultiLocale) {\n // Create with default locale data\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: flatData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n\n // Update for other locales\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n // Clone the request with the specific locale\n const localeReq = { ...req, locale }\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: localeReq,\n })\n } catch (error) {\n // Log but don't fail the entire import if a locale update fails\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 { collectionSlug, documents, importMode, matchField, req, user } = processOptions\n const batches = createBatches(documents, processorOptions.batchSize)\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 batchResult = await processImportBatch({\n batch: currentBatch,\n batchIndex: i,\n collectionSlug,\n importMode,\n matchField,\n options: processorOptions,\n req,\n user,\n })\n\n // Update results\n for (const success of batchResult.successful) {\n if (success.operation === 'created') {\n result.imported++\n } else if (success.operation === 'updated') {\n result.updated++\n } else {\n // Fallback\n if (importMode === 'create') {\n result.imported++\n } else {\n result.updated++\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\n return result\n }\n\n return {\n processImport,\n }\n}\n"],"names":["categorizeError","createBatches","extractErrorMessage","extractMultiLocaleData","data","configuredLocales","flatData","localeUpdates","hasMultiLocale","length","localeSet","Set","key","value","Object","entries","Array","isArray","valueObj","localeKeys","keys","filter","k","has","firstLocale","locale","processImportBatch","batch","batchIndex","collectionSlug","importMode","matchField","options","req","user","result","failed","successful","collectionEntry","payload","collections","collectionConfig","config","collectionHasVersions","Boolean","versions","hasCustomIdField","customIDType","localization","localeCodes","undefined","startingRowNumber","batchSize","i","document","rowNumber","savedDocument","existingDocResult","createData","id","draftOption","statusValue","_status","defaultVersionStatus","isPublished","debug","logger","info","msg","willSetDraft","title","titleIsNull","titleType","create","collection","draft","overrideAccess","localeData","localeReq","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","batches","imported","total","updated","currentBatch","batchResult","success","doc"],"mappings":"AAIA,SAEEA,eAAe,EACfC,aAAa,EACbC,mBAAmB,QACd,oCAAmC;AA6C1C;;;;;;;;;;;CAWC,GACD,SAASC,uBACPC,IAA6B,EAC7BC,iBAA4B;IAM5B,MAAMC,WAAoC,CAAC;IAC3C,MAAMC,gBAAyD,CAAC;IAChE,IAAIC,iBAAiB;IAErB,IAAI,CAACH,qBAAqBA,kBAAkBI,MAAM,KAAK,GAAG;QACxD,OAAO;YAAEH,UAAU;gBAAE,GAAGF,IAAI;YAAC;YAAGI,gBAAgB;YAAOD,eAAe,CAAC;QAAE;IAC3E;IAEA,MAAMG,YAAY,IAAIC,IAAIN;IAE1B,KAAK,MAAM,CAACO,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACX,MAAO;QAC/C,IAAIS,SAAS,OAAOA,UAAU,YAAY,CAACG,MAAMC,OAAO,CAACJ,QAAQ;YAC/D,MAAMK,WAAWL;YACjB,MAAMM,aAAaL,OAAOM,IAAI,CAACF,UAAUG,MAAM,CAAC,CAACC,IAAMZ,UAAUa,GAAG,CAACD;YAErE,IAAIH,WAAWV,MAAM,GAAG,GAAG;gBACzBD,iBAAiB;gBACjB,MAAMgB,cAAcL,UAAU,CAAC,EAAE;gBACjC,IAAIK,aAAa;oBACflB,QAAQ,CAACM,IAAI,GAAGM,QAAQ,CAACM,YAAY;oBACrC,KAAK,MAAMC,UAAUN,WAAY;wBAC/B,IAAIM,WAAWD,aAAa;4BAC1B,IAAI,CAACjB,aAAa,CAACkB,OAAO,EAAE;gCAC1BlB,aAAa,CAACkB,OAAO,GAAG,CAAC;4BAC3B;4BACAlB,aAAa,CAACkB,OAAO,CAACb,IAAI,GAAGM,QAAQ,CAACO,OAAO;wBAC/C;oBACF;gBACF;YACF,OAAO;gBACLnB,QAAQ,CAACM,IAAI,GAAGC;YAClB;QACF,OAAO;YACLP,QAAQ,CAACM,IAAI,GAAGC;QAClB;IACF;IAEA,OAAO;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BAAiB;YACjB,KAAK,MAAM0G,WAAWD,YAAYtG,UAAU,CAAE;gBAC5C,IAAIuG,QAAQxB,SAAS,KAAK,WAAW;oBACnCjF,OAAOoG,QAAQ;gBACjB,OAAO,IAAIK,QAAQxB,SAAS,KAAK,WAAW;oBAC1CjF,OAAOsG,OAAO;gBAChB,OAAO;oBACL,WAAW;oBACX,IAAI3G,eAAe,UAAU;wBAC3BK,OAAOoG,QAAQ;oBACjB,OAAO;wBACLpG,OAAOsG,OAAO;oBAChB;gBACF;YACF;YAEA,KAAK,MAAMzD,SAAS2D,YAAYvG,MAAM,CAAE;gBACtCD,OAAO0F,MAAM,CAACR,IAAI,CAAC;oBACjBwB,KAAK7D,MAAMyC,YAAY;oBACvBzC,OAAOA,MAAMA,KAAK;oBAClBsC,OAAOtC,MAAMzB,SAAS,GAAG;gBAC3B;YACF;QACF;QAEA,OAAOpB;IACT;IAEA,OAAO;QACLgG;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/import/batchProcessor.ts"],"sourcesContent":["import type { PayloadRequest, TypedUser } from 'payload'\n\nimport { isolateObjectProperty } from 'payload'\n\nimport type { ImportMode, ImportResult } 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 documents: Record<string, unknown>[]\n importMode: ImportMode\n matchField?: string\n req: PayloadRequest\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 first locale's data for initial create/update, and stores\n * remaining locales for subsequent update calls.\n *\n * @returns\n * - flatData: Document with first 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): {\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 firstLocale = localeKeys[0]\n if (firstLocale) {\n flatData[key] = valueObj[firstLocale]\n for (const locale of localeKeys) {\n if (locale !== firstLocale) {\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 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 )\n\n if (hasMultiLocale) {\n // Create with default locale data\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: flatData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n\n // Update for other locales\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n const localeReq = { ...req, locale }\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: localeReq,\n user,\n })\n } catch (error) {\n // Log but don't fail the entire import if a locale update fails\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 )\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 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,\n user,\n })\n\n // Update for other locales\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n // Clone the request with the specific locale\n const localeReq = { ...req, locale }\n await req.payload.update({\n id: existingDoc.id as number | string,\n collection: collectionSlug,\n data: localeData,\n depth: 0,\n // Don't specify draft - this creates a new draft for versioned collections\n overrideAccess: false,\n req: localeReq,\n user,\n })\n } catch (error) {\n // Log but don't fail the entire import if a locale update fails\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 )\n\n if (hasMultiLocale) {\n // Create with default locale data\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: flatData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n\n // Update for other locales\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n // Clone the request with the specific locale\n const localeReq = { ...req, locale }\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: localeReq,\n })\n } catch (error) {\n // Log but don't fail the entire import if a locale update fails\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 { collectionSlug, documents, importMode, matchField, req, user } = processOptions\n const batches = createBatches(documents, processorOptions.batchSize)\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 batchResult = await processImportBatch({\n batch: currentBatch,\n batchIndex: i,\n collectionSlug,\n importMode,\n matchField,\n options: processorOptions,\n req,\n user,\n })\n\n // Update results\n for (const success of batchResult.successful) {\n if (success.operation === 'created') {\n result.imported++\n } else if (success.operation === 'updated') {\n result.updated++\n } else {\n // Fallback\n if (importMode === 'create') {\n result.imported++\n } else {\n result.updated++\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\n return result\n }\n\n return {\n processImport,\n }\n}\n"],"names":["isolateObjectProperty","categorizeError","createBatches","extractErrorMessage","extractMultiLocaleData","data","configuredLocales","flatData","localeUpdates","hasMultiLocale","length","localeSet","Set","key","value","Object","entries","Array","isArray","valueObj","localeKeys","keys","filter","k","has","firstLocale","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","create","collection","draft","overrideAccess","localeData","localeReq","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","batches","imported","total","updated","currentBatch","batchResult","success","doc"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,UAAS;AAI/C,SAEEC,eAAe,EACfC,aAAa,EACbC,mBAAmB,QACd,oCAAmC;AA6C1C;;;;;;;;;;;CAWC,GACD,SAASC,uBACPC,IAA6B,EAC7BC,iBAA4B;IAM5B,MAAMC,WAAoC,CAAC;IAC3C,MAAMC,gBAAyD,CAAC;IAChE,IAAIC,iBAAiB;IAErB,IAAI,CAACH,qBAAqBA,kBAAkBI,MAAM,KAAK,GAAG;QACxD,OAAO;YAAEH,UAAU;gBAAE,GAAGF,IAAI;YAAC;YAAGI,gBAAgB;YAAOD,eAAe,CAAC;QAAE;IAC3E;IAEA,MAAMG,YAAY,IAAIC,IAAIN;IAE1B,KAAK,MAAM,CAACO,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACX,MAAO;QAC/C,IAAIS,SAAS,OAAOA,UAAU,YAAY,CAACG,MAAMC,OAAO,CAACJ,QAAQ;YAC/D,MAAMK,WAAWL;YACjB,MAAMM,aA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,KAAK,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC5B,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,MAAM,CAAA;KACd,CAAC,CAAA;IACF,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,YAAY,6IAatB,gBAAgB,KAAG,OAAO,CAAC,YAAY,CA0MzC,CAAA"}
|
|
@@ -10,7 +10,8 @@ export const createImport = async ({ batchSize = 100, collectionSlug, debug = fa
|
|
|
10
10
|
if (userCollection && userID) {
|
|
11
11
|
user = await req.payload.findByID({
|
|
12
12
|
id: userID,
|
|
13
|
-
collection: userCollection
|
|
13
|
+
collection: userCollection,
|
|
14
|
+
req
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
if (!user) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/import/createImport.ts"],"sourcesContent":["import type { PayloadRequest, TypedUser } from 'payload'\n\nimport { APIError } from 'payload'\n\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 type ImportResult = {\n errors: Array<{\n doc: Record<string, unknown>\n error: string\n index: number\n }>\n imported: number\n total: number\n updated: number\n}\n\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 })) 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 message: '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 message: 'File info',\n mimeType: file.mimetype,\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 // Get fromCSV functions for field transformations\n const fromCSVFunctions = getImportFieldFunctions({\n fields: collectionConfig.flattenedFields || [],\n })\n\n // Parse the file data\n let documents: Record<string, unknown>[]\n if (format === 'csv') {\n const rawData = await parseCSV({\n data: file.data,\n req,\n })\n\n // Debug logging\n if (debug && rawData.length > 0) {\n req.payload.logger.info({\n firstRow: rawData[0], // Show the complete first row\n msg: 'Parsed CSV data - FULL',\n })\n req.payload.logger.info({\n msg: 'Parsed CSV data',\n rows: rawData.map((row, i) => ({\n excerpt: row.excerpt,\n hasManyNumber: row.hasManyNumber, // Add this to see what we get from CSV\n hasOnePolymorphic_id: row.hasOnePolymorphic_id,\n hasOnePolymorphic_relationTo: row.hasOnePolymorphic_relationTo,\n index: i,\n title: row.title,\n })),\n })\n }\n\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 fromCSVFunctions,\n req,\n })\n return unflattened ?? {}\n })\n .filter((doc) => doc && Object.keys(doc).length > 0)\n\n // Debug after unflatten\n if (debug && documents.length > 0) {\n req.payload.logger.info({\n msg: 'After unflatten',\n rows: documents.map((row, i) => ({\n hasManyNumber: row.hasManyNumber, // Add this to see the actual value\n hasManyPolymorphic: row.hasManyPolymorphic,\n hasOnePolymorphic: row.hasOnePolymorphic,\n hasTitle: 'title' in row,\n index: i,\n title: row.title,\n })),\n })\n }\n\n if (debug) {\n req.payload.logger.debug({\n documentCount: documents.length,\n message: 'After unflattening CSV',\n rawDataCount: rawData.length,\n })\n\n // Debug: show a sample of raw vs unflattened\n if (rawData.length > 0 && documents.length > 0) {\n req.payload.logger.debug({\n message: 'Sample data transformation',\n raw: Object.keys(rawData[0] || {}).filter((k) => k.includes('localized')),\n unflattened: JSON.stringify(documents[0], null, 2),\n })\n }\n }\n } else {\n documents = parseJSON({ data: file.data, req })\n }\n\n if (debug) {\n req.payload.logger.debug({\n message: `Parsed ${documents.length} documents from ${format} file`,\n })\n if (documents.length > 0) {\n req.payload.logger.debug({\n doc: documents[0],\n message: '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 message: 'Processing import in batches',\n })\n }\n\n // Create batch processor\n const processor = createImportBatchProcessor({\n batchSize,\n defaultVersionStatus,\n })\n\n // Process import with batch processor\n const result = await processor.processImport({\n collectionSlug,\n documents,\n importMode,\n matchField,\n req,\n user,\n })\n\n if (debug) {\n req.payload.logger.info({\n errors: result.errors.length,\n imported: result.imported,\n message: 'Import completed',\n total: result.total,\n updated: result.updated,\n })\n }\n\n return result\n}\n"],"names":["APIError","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","message","transactionID","data","fileName","name","fileSize","length","mimeType","mimetype","collectionConfig","config","collections","find","slug","disabledFields","admin","custom","fromCSVFunctions","fields","flattenedFields","documents","rawData","info","firstRow","msg","rows","map","row","i","excerpt","hasManyNumber","hasOnePolymorphic_id","hasOnePolymorphic_relationTo","index","title","doc","unflattened","filter","Object","keys","hasManyPolymorphic","hasOnePolymorphic","hasTitle","documentCount","rawDataCount","raw","k","includes","JSON","stringify","processor","result","processImport","errors","imported","total","updated"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,UAAS;AAElC,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;AAqDhE,OAAO,MAAMC,eAAe,OAAO,EACjCC,YAAY,GAAG,EACfC,cAAc,EACdC,QAAQ,KAAK,EACbC,uB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,EAAE8C,UAAUd,MAAM,CAAC,wBAAwB,EAAEhB,UAAU,EAC7E,KACA,MACA;IAEJ;IAEA,4CAA4C;IAC5C,IAAIwB,eAAeR,MAAM,GAAG,GAAG;QAC7Bc,YAAYA,UAAUM,GAAG,CAAC,CAACS,MAAQzD,qBAAqByD,KAAKrB;IAC/D;IAEA,IAAI9B,OAAO;QACTO,IAAII,OAAO,CAACI,MAAM,CAACf,KAAK,CAAC;YACvBF;YACA6D,eAAevB,UAAUd,MAAM;YAC/BN,SAAS;QACX;IACF;IAEA,yBAAyB;IACzB,MAAMkD,YAAYtE,2BAA2B;QAC3CE;QACAG;IACF;IAEA,sCAAsC;IACtC,MAAMkE,SAAS,MAAMD,UAAUE,aAAa,CAAC;QAC3CrE;QACAqC;QACAhC;QACAC;QACAE;QACAG;IACF;IAEA,IAAIV,OAAO;QACTO,IAAII,OAAO,CAACI,MAAM,CAACuB,IAAI,CAAC;YACtB+B,QAAQF,OAAOE,MAAM,CAAC/C,MAAM;YAC5BgD,UAAUH,OAAOG,QAAQ;YACzBtD,SAAS;YACTuD,OAAOJ,OAAOI,KAAK;YACnBC,SAASL,OAAOK,OAAO;QACzB;IACF;IAEA,OAAOL;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/import/createImport.ts"],"sourcesContent":["import type { PayloadRequest, TypedUser } from 'payload'\n\nimport { APIError } from 'payload'\n\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 type ImportResult = {\n errors: Array<{\n doc: Record<string, unknown>\n error: string\n index: number\n }>\n imported: number\n total: number\n updated: number\n}\n\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 message: '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 message: 'File info',\n mimeType: file.mimetype,\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 // Get fromCSV functions for field transformations\n const fromCSVFunctions = getImportFieldFunctions({\n fields: collectionConfig.flattenedFields || [],\n })\n\n // Parse the file data\n let documents: Record<string, unknown>[]\n if (format === 'csv') {\n const rawData = await parseCSV({\n data: file.data,\n req,\n })\n\n // Debug logging\n if (debug && rawData.length > 0) {\n req.payload.logger.info({\n firstRow: rawData[0], // Show the complete first row\n msg: 'Parsed CSV data - FULL',\n })\n req.payload.logger.info({\n msg: 'Parsed CSV data',\n rows: rawData.map((row, i) => ({\n excerpt: row.excerpt,\n hasManyNumber: row.hasManyNumber, // Add this to see what we get from CSV\n hasOnePolymorphic_id: row.hasOnePolymorphic_id,\n hasOnePolymorphic_relationTo: row.hasOnePolymorphic_relationTo,\n index: i,\n title: row.title,\n })),\n })\n }\n\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 fromCSVFunctions,\n req,\n })\n return unflattened ?? {}\n })\n .filter((doc) => doc && Object.keys(doc).length > 0)\n\n // Debug after unflatten\n if (debug && documents.length > 0) {\n req.payload.logger.info({\n msg: 'After unflatten',\n rows: documents.map((row, i) => ({\n hasManyNumber: row.hasManyNumber, // Add this to see the actual value\n hasManyPolymorphic: row.hasManyPolymorphic,\n hasOnePolymorphic: row.hasOnePolymorphic,\n hasTitle: 'title' in row,\n index: i,\n title: row.title,\n })),\n })\n }\n\n if (debug) {\n req.payload.logger.debug({\n documentCount: documents.length,\n message: 'After unflattening CSV',\n rawDataCount: rawData.length,\n })\n\n // Debug: show a sample of raw vs unflattened\n if (rawData.length > 0 && documents.length > 0) {\n req.payload.logger.debug({\n message: 'Sample data transformation',\n raw: Object.keys(rawData[0] || {}).filter((k) => k.includes('localized')),\n unflattened: JSON.stringify(documents[0], null, 2),\n })\n }\n }\n } else {\n documents = parseJSON({ data: file.data, req })\n }\n\n if (debug) {\n req.payload.logger.debug({\n message: `Parsed ${documents.length} documents from ${format} file`,\n })\n if (documents.length > 0) {\n req.payload.logger.debug({\n doc: documents[0],\n message: '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 message: 'Processing import in batches',\n })\n }\n\n // Create batch processor\n const processor = createImportBatchProcessor({\n batchSize,\n defaultVersionStatus,\n })\n\n // Process import with batch processor\n const result = await processor.processImport({\n collectionSlug,\n documents,\n importMode,\n matchField,\n req,\n user,\n })\n\n if (debug) {\n req.payload.logger.info({\n errors: result.errors.length,\n imported: result.imported,\n message: 'Import completed',\n total: result.total,\n updated: result.updated,\n })\n }\n\n return result\n}\n"],"names":["APIError","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","message","transactionID","data","fileName","name","fileSize","length","mimeType","mimetype","collectionConfig","config","collections","find","slug","disabledFields","admin","custom","fromCSVFunctions","fields","flattenedFields","documents","rawData","info","firstRow","msg","rows","map","row","i","excerpt","hasManyNumber","hasOnePolymorphic_id","hasOnePolymorphic_relationTo","index","title","doc","unflattened","filter","Object","keys","hasManyPolymorphic","hasOnePolymorphic","hasTitle","documentCount","rawDataCount","raw","k","includes","JSON","stringify","processor","result","processImport","errors","imported","total","updated"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,UAAS;AAElC,SAASC,uBAAuB,QAAQ,0CAAyC;AACjF,SAASC,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,SAAS,QAAQ,4BAA2B;AACrD,SAASC,oBAAoB,QAAQ,uCAAsC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CAAC,EAAE;gBACjBpB,SAAS;YACX;QACF;IACF;IAEA,yDAAyD;IACzD,IAAI,OAAOV,aAAa,YAAYA,WAAW,KAAK8B,UAAUd,MAAM,GAAGhB,UAAU;QAC/E,MAAM,IAAIhB,SACR,CAAC,qBAAqB,EAAE8C,UAAUd,MAAM,CAAC,wBAAwB,EAAEhB,UAAU,EAC7E,KACA,MACA;IAEJ;IAEA,4CAA4C;IAC5C,IAAIwB,eAAeR,MAAM,GAAG,GAAG;QAC7Bc,YAAYA,UAAUM,GAAG,CAAC,CAACS,MAAQzD,qBAAqByD,KAAKrB;IAC/D;IAEA,IAAI9B,OAAO;QACTO,IAAII,OAAO,CAACI,MAAM,CAACf,KAAK,CAAC;YACvBF;YACA6D,eAAevB,UAAUd,MAAM;YAC/BN,SAAS;QACX;IACF;IAEA,yBAAyB;IACzB,MAAMkD,YAAYtE,2BAA2B;QAC3CE;QACAG;IACF;IAEA,sCAAsC;IACtC,MAAMkE,SAAS,MAAMD,UAAUE,aAAa,CAAC;QAC3CrE;QACAqC;QACAhC;QACAC;QACAE;QACAG;IACF;IAEA,IAAIV,OAAO;QACTO,IAAII,OAAO,CAACI,MAAM,CAACuB,IAAI,CAAC;YACtB+B,QAAQF,OAAOE,MAAM,CAAC/C,MAAM;YAC5BgD,UAAUH,OAAOG,QAAQ;YACzBtD,SAAS;YACTuD,OAAOJ,OAAOI,KAAK;YACnBC,SAASL,OAAOK,OAAO;QACzB;IACF;IAEA,OAAOL;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getImportCollection.d.ts","sourceRoot":"","sources":["../../src/import/getImportCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"getImportCollection.d.ts","sourceRoot":"","sources":["../../src/import/getImportCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6B,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI1E,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAYzE,eAAO,MAAM,mBAAmB,qDAI7B;IACD;;OAEG;IACH,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,YAAY,EAAE,wBAAwB,CAAA;CACvC,KAAG,gBAoVH,CAAA"}
|