@payloadcms/plugin-import-export 3.79.0-canary.3 → 3.79.0-canary.4
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 +2 -19
- package/dist/components/ExportSaveButton/index.js.map +1 -1
- package/dist/export/createExport.js +4 -4
- package/dist/export/createExport.js.map +1 -1
- package/dist/import/batchProcessor.d.ts.map +1 -1
- package/dist/import/batchProcessor.js +26 -13
- package/dist/import/batchProcessor.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ExportSaveButton/index.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ExportSaveButton/index.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAwGpC,CAAA"}
|
|
@@ -63,28 +63,11 @@ export const ExportSaveButton = ()=>{
|
|
|
63
63
|
}
|
|
64
64
|
throw new Error(errorMsg);
|
|
65
65
|
}
|
|
66
|
-
const
|
|
67
|
-
const reader = fileStream?.getReader();
|
|
68
|
-
const decoder = new TextDecoder();
|
|
69
|
-
let result = '';
|
|
70
|
-
while(reader){
|
|
71
|
-
const { done, value } = await reader.read();
|
|
72
|
-
if (done) {
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
result += decoder.decode(value, {
|
|
76
|
-
stream: true
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
const blob = new Blob([
|
|
80
|
-
result
|
|
81
|
-
], {
|
|
82
|
-
type: 'text/plain'
|
|
83
|
-
});
|
|
66
|
+
const blob = await response.blob();
|
|
84
67
|
const url = URL.createObjectURL(blob);
|
|
85
68
|
const a = document.createElement('a');
|
|
86
69
|
a.href = url;
|
|
87
|
-
a.download = `${data.name}.${data.format}`;
|
|
70
|
+
a.download = `${data.name}-${data.collectionSlug}.${data.format}`;
|
|
88
71
|
document.body.appendChild(a);
|
|
89
72
|
a.click();
|
|
90
73
|
document.body.removeChild(a);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ExportSaveButton/index.tsx"],"sourcesContent":["'use client'\n\nimport {\n Button,\n SaveButton,\n toast,\n Translation,\n useConfig,\n useField,\n useForm,\n useFormModified,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport type {\n PluginImportExportTranslationKeys,\n PluginImportExportTranslations,\n} from '../../translations/index.js'\n\nexport const ExportSaveButton: React.FC = () => {\n const { t } = useTranslation<PluginImportExportTranslations, PluginImportExportTranslationKeys>()\n const {\n config: {\n routes: { api },\n },\n getEntityConfig,\n } = useConfig()\n\n const { getData, setModified } = useForm()\n const modified = useFormModified()\n\n const { value: targetCollectionSlug } = useField<string>({ path: 'collectionSlug' })\n\n const targetCollectionConfig = getEntityConfig({ collectionSlug: targetCollectionSlug })\n const targetPluginConfig = targetCollectionConfig?.admin?.custom?.['plugin-import-export']\n\n const exportsCollectionConfig = getEntityConfig({ collectionSlug: 'exports' })\n\n const disableSave =\n targetPluginConfig?.disableSave ?? exportsCollectionConfig?.admin?.custom?.disableSave === true\n\n const disableDownload =\n targetPluginConfig?.disableDownload ??\n exportsCollectionConfig?.admin?.custom?.disableDownload === true\n\n const label = t('general:save')\n\n const handleDownload = async () => {\n let timeoutID: null | ReturnType<typeof setTimeout> = null\n let toastID: null | number | string = null\n\n try {\n setModified(false)\n const data = getData()\n\n // Set a timeout to show toast if the request takes longer than 200ms\n timeoutID = setTimeout(() => {\n toastID = toast.success('Your export is being processed...')\n }, 200)\n\n const response = await fetch(\n formatAdminURL({\n apiRoute: api,\n path: '/exports/download',\n }),\n {\n body: JSON.stringify({\n data,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n },\n )\n\n if (timeoutID) {\n clearTimeout(timeoutID)\n }\n\n if (toastID) {\n toast.dismiss(toastID)\n }\n\n if (!response.ok) {\n // Try to parse the error message from the JSON response\n let errorMsg = 'Failed to download file'\n try {\n const errorJson = await response.json()\n if (errorJson?.errors?.[0]?.message) {\n errorMsg = errorJson.errors[0].message\n }\n } catch {\n // Ignore JSON parse errors, fallback to generic message\n }\n throw new Error(errorMsg)\n }\n\n const
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ExportSaveButton/index.tsx"],"sourcesContent":["'use client'\n\nimport {\n Button,\n SaveButton,\n toast,\n Translation,\n useConfig,\n useField,\n useForm,\n useFormModified,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport type {\n PluginImportExportTranslationKeys,\n PluginImportExportTranslations,\n} from '../../translations/index.js'\n\nexport const ExportSaveButton: React.FC = () => {\n const { t } = useTranslation<PluginImportExportTranslations, PluginImportExportTranslationKeys>()\n const {\n config: {\n routes: { api },\n },\n getEntityConfig,\n } = useConfig()\n\n const { getData, setModified } = useForm()\n const modified = useFormModified()\n\n const { value: targetCollectionSlug } = useField<string>({ path: 'collectionSlug' })\n\n const targetCollectionConfig = getEntityConfig({ collectionSlug: targetCollectionSlug })\n const targetPluginConfig = targetCollectionConfig?.admin?.custom?.['plugin-import-export']\n\n const exportsCollectionConfig = getEntityConfig({ collectionSlug: 'exports' })\n\n const disableSave =\n targetPluginConfig?.disableSave ?? exportsCollectionConfig?.admin?.custom?.disableSave === true\n\n const disableDownload =\n targetPluginConfig?.disableDownload ??\n exportsCollectionConfig?.admin?.custom?.disableDownload === true\n\n const label = t('general:save')\n\n const handleDownload = async () => {\n let timeoutID: null | ReturnType<typeof setTimeout> = null\n let toastID: null | number | string = null\n\n try {\n setModified(false)\n const data = getData()\n\n // Set a timeout to show toast if the request takes longer than 200ms\n timeoutID = setTimeout(() => {\n toastID = toast.success('Your export is being processed...')\n }, 200)\n\n const response = await fetch(\n formatAdminURL({\n apiRoute: api,\n path: '/exports/download',\n }),\n {\n body: JSON.stringify({\n data,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n },\n )\n\n if (timeoutID) {\n clearTimeout(timeoutID)\n }\n\n if (toastID) {\n toast.dismiss(toastID)\n }\n\n if (!response.ok) {\n // Try to parse the error message from the JSON response\n let errorMsg = 'Failed to download file'\n try {\n const errorJson = await response.json()\n if (errorJson?.errors?.[0]?.message) {\n errorMsg = errorJson.errors[0].message\n }\n } catch {\n // Ignore JSON parse errors, fallback to generic message\n }\n throw new Error(errorMsg)\n }\n\n const blob = await response.blob()\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n a.download = `${data.name}-${data.collectionSlug}.${data.format}`\n document.body.appendChild(a)\n a.click()\n document.body.removeChild(a)\n URL.revokeObjectURL(url)\n } catch (error: any) {\n toast.error(error.message || 'Error downloading file')\n }\n }\n\n return (\n <React.Fragment>\n {!disableSave && <SaveButton label={label} />}\n {!disableDownload && (\n <Button disabled={!modified} onClick={handleDownload} size=\"medium\" type=\"button\">\n <Translation i18nKey=\"upload:download\" t={t} />\n </Button>\n )}\n </React.Fragment>\n )\n}\n"],"names":["Button","SaveButton","toast","Translation","useConfig","useField","useForm","useFormModified","useTranslation","formatAdminURL","React","ExportSaveButton","t","config","routes","api","getEntityConfig","getData","setModified","modified","value","targetCollectionSlug","path","targetCollectionConfig","collectionSlug","targetPluginConfig","admin","custom","exportsCollectionConfig","disableSave","disableDownload","label","handleDownload","timeoutID","toastID","data","setTimeout","success","response","fetch","apiRoute","body","JSON","stringify","credentials","headers","method","clearTimeout","dismiss","ok","errorMsg","errorJson","json","errors","message","Error","blob","url","URL","createObjectURL","a","document","createElement","href","download","name","format","appendChild","click","removeChild","revokeObjectURL","error","Fragment","disabled","onClick","size","type","i18nKey"],"mappings":"AAAA;;AAEA,SACEA,MAAM,EACNC,UAAU,EACVC,KAAK,EACLC,WAAW,EACXC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPC,eAAe,EACfC,cAAc,QACT,iBAAgB;AACvB,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,WAAW,QAAO;AAOzB,OAAO,MAAMC,mBAA6B;IACxC,MAAM,EAAEC,CAAC,EAAE,GAAGJ;IACd,MAAM,EACJK,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EAChB,EACDC,eAAe,EAChB,GAAGZ;IAEJ,MAAM,EAAEa,OAAO,EAAEC,WAAW,EAAE,GAAGZ;IACjC,MAAMa,WAAWZ;IAEjB,MAAM,EAAEa,OAAOC,oBAAoB,EAAE,GAAGhB,SAAiB;QAAEiB,MAAM;IAAiB;IAElF,MAAMC,yBAAyBP,gBAAgB;QAAEQ,gBAAgBH;IAAqB;IACtF,MAAMI,qBAAqBF,wBAAwBG,OAAOC,QAAQ,CAAC,uBAAuB;IAE1F,MAAMC,0BAA0BZ,gBAAgB;QAAEQ,gBAAgB;IAAU;IAE5E,MAAMK,cACJJ,oBAAoBI,eAAeD,yBAAyBF,OAAOC,QAAQE,gBAAgB;IAE7F,MAAMC,kBACJL,oBAAoBK,mBACpBF,yBAAyBF,OAAOC,QAAQG,oBAAoB;IAE9D,MAAMC,QAAQnB,EAAE;IAEhB,MAAMoB,iBAAiB;QACrB,IAAIC,YAAkD;QACtD,IAAIC,UAAkC;QAEtC,IAAI;YACFhB,YAAY;YACZ,MAAMiB,OAAOlB;YAEb,qEAAqE;YACrEgB,YAAYG,WAAW;gBACrBF,UAAUhC,MAAMmC,OAAO,CAAC;YAC1B,GAAG;YAEH,MAAMC,WAAW,MAAMC,MACrB9B,eAAe;gBACb+B,UAAUzB;gBACVO,MAAM;YACR,IACA;gBACEmB,MAAMC,KAAKC,SAAS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"}
|
|
@@ -292,7 +292,7 @@ export const createExport = async (args)=>{
|
|
|
292
292
|
return new Response(Readable.toWeb(stream), {
|
|
293
293
|
headers: {
|
|
294
294
|
'Content-Disposition': `attachment; filename="${name}"`,
|
|
295
|
-
'Content-Type': isCSV ? 'text/csv' : 'application/json'
|
|
295
|
+
'Content-Type': isCSV ? 'text/csv; charset=utf-8' : 'application/json'
|
|
296
296
|
}
|
|
297
297
|
});
|
|
298
298
|
}
|
|
@@ -376,7 +376,7 @@ export const createExport = async (args)=>{
|
|
|
376
376
|
req.file = {
|
|
377
377
|
name,
|
|
378
378
|
data: buffer,
|
|
379
|
-
mimetype: isCSV ? 'text/csv' : 'application/json',
|
|
379
|
+
mimetype: isCSV ? 'text/csv; charset=utf-8' : 'application/json',
|
|
380
380
|
size: buffer.length
|
|
381
381
|
};
|
|
382
382
|
} else {
|
|
@@ -387,7 +387,7 @@ export const createExport = async (args)=>{
|
|
|
387
387
|
exportCollection,
|
|
388
388
|
fileName: name,
|
|
389
389
|
fileSize: buffer.length,
|
|
390
|
-
mimeType: isCSV ? 'text/csv' : 'application/json'
|
|
390
|
+
mimeType: isCSV ? 'text/csv; charset=utf-8' : 'application/json'
|
|
391
391
|
});
|
|
392
392
|
}
|
|
393
393
|
try {
|
|
@@ -398,7 +398,7 @@ export const createExport = async (args)=>{
|
|
|
398
398
|
file: {
|
|
399
399
|
name,
|
|
400
400
|
data: buffer,
|
|
401
|
-
mimetype: isCSV ? 'text/csv' : 'application/json',
|
|
401
|
+
mimetype: isCSV ? 'text/csv; charset=utf-8' : 'application/json',
|
|
402
402
|
size: buffer.length
|
|
403
403
|
},
|
|
404
404
|
// Override access only here so that we can be sure the export collection itself is updated as expected
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/export/createExport.ts"],"sourcesContent":["/* eslint-disable perfectionist/sort-objects */\nimport type { PayloadRequest, Sort, TypedUser, Where } from 'payload'\n\nimport { stringify } from 'csv-stringify/sync'\nimport { APIError } from 'payload'\nimport { Readable } from 'stream'\n\nimport { buildDisabledFieldRegex } from '../utilities/buildDisabledFieldRegex.js'\nimport { flattenObject } from '../utilities/flattenObject.js'\nimport { getExportFieldFunctions } from '../utilities/getExportFieldFunctions.js'\nimport { getFilename } from '../utilities/getFilename.js'\nimport { getSchemaColumns, mergeColumns } from '../utilities/getSchemaColumns.js'\nimport { getSelect } from '../utilities/getSelect.js'\nimport { validateLimitValue } from '../utilities/validateLimitValue.js'\nimport { createExportBatchProcessor, type ExportFindArgs } from './batchProcessor.js'\n\nexport type Export = {\n /**\n * Number of documents to process in each batch during export\n * @default 100\n */\n batchSize?: number\n collectionSlug: string\n /**\n * If true, enables debug logging\n */\n debug?: boolean\n drafts?: 'no' | 'yes'\n exportCollection: string\n fields?: string[]\n format: 'csv' | 'json'\n globals?: string[]\n id: number | string\n limit?: number\n locale?: string\n /**\n * Maximum number of documents that can be exported in a single operation.\n * This value has already been resolved from the plugin config.\n */\n maxLimit?: number\n name: string\n page?: number\n sort?: Sort\n userCollection: string\n userID: number | string\n where?: Where\n}\n\nexport type CreateExportArgs = {\n /**\n * If true, stream the file instead of saving it\n */\n download?: boolean\n req: PayloadRequest\n} & Export\n\nexport const createExport = async (args: CreateExportArgs) => {\n const {\n id,\n name: nameArg,\n batchSize = 100,\n collectionSlug,\n debug = false,\n download,\n drafts: draftsFromInput,\n exportCollection,\n fields,\n format,\n limit: incomingLimit,\n maxLimit,\n locale: localeFromInput,\n page,\n req,\n sort,\n userCollection,\n userID,\n where: whereFromInput = {},\n } = args\n const { locale: localeFromReq, payload } = req\n\n if (debug) {\n req.payload.logger.debug({\n msg: '[createExport] Starting export process',\n exportDocId: id,\n exportName: nameArg,\n collectionSlug,\n exportCollection,\n draft: draftsFromInput,\n fields,\n format,\n })\n }\n\n const locale = localeFromInput ?? localeFromReq\n const collectionConfig = payload.config.collections.find(({ slug }) => slug === collectionSlug)\n\n if (!collectionConfig) {\n throw new APIError(`Collection with slug ${collectionSlug} not found.`)\n }\n\n let user: TypedUser | undefined\n\n if (userCollection && userID) {\n user = (await req.payload.findByID({\n id: userID,\n collection: userCollection,\n overrideAccess: true,\n })) as TypedUser\n }\n\n if (!user && req.user) {\n user = req?.user?.id ? req.user : req?.user?.user\n }\n\n if (!user) {\n throw new APIError('User authentication is required to create exports.')\n }\n\n const draft = draftsFromInput === 'yes'\n const hasVersions = Boolean(collectionConfig.versions)\n\n // Only filter by _status for versioned collections\n const publishedWhere: Where = hasVersions ? { _status: { equals: 'published' } } : {}\n\n const where: Where = {\n and: [whereFromInput, draft ? {} : publishedWhere],\n }\n\n const baseName = nameArg ?? getFilename()\n const name = `${baseName}-${collectionSlug}.${format}`\n const isCSV = format === 'csv'\n const select = Array.isArray(fields) && fields.length > 0 ? getSelect(fields) : undefined\n\n if (debug) {\n req.payload.logger.debug({ message: 'Export configuration:', name, isCSV, locale })\n }\n\n // Determine maximum export documents:\n // 1. If maxLimit is defined, it sets the absolute ceiling\n // 2. User's limit is applied but clamped to maxLimit if it exceeds it\n let maxExportDocuments: number | undefined\n\n if (typeof maxLimit === 'number' && maxLimit > 0) {\n if (typeof incomingLimit === 'number' && incomingLimit > 0) {\n // User provided a limit - clamp it to maxLimit\n maxExportDocuments = Math.min(incomingLimit, maxLimit)\n } else {\n // No user limit - use maxLimit as the ceiling\n maxExportDocuments = maxLimit\n }\n } else {\n // No maxLimit - use user's limit if provided\n maxExportDocuments =\n typeof incomingLimit === 'number' && incomingLimit > 0 ? incomingLimit : undefined\n }\n\n // Try to count documents - if access is denied, treat as 0 documents\n let totalDocs = 0\n let accessDenied = false\n try {\n const countResult = await payload.count({\n collection: collectionSlug,\n user,\n locale,\n overrideAccess: false,\n })\n totalDocs = countResult.totalDocs\n } catch (error) {\n // Access denied - user can't read from this collection\n // We'll create an empty export file\n accessDenied = true\n if (debug) {\n req.payload.logger.debug({\n message: 'Access denied for collection, creating empty export',\n collectionSlug,\n })\n }\n }\n\n const totalPages = Math.max(1, Math.ceil(totalDocs / batchSize))\n const requestedPage = page || 1\n const adjustedPage = requestedPage > totalPages ? 1 : requestedPage\n\n const findArgs = {\n collection: collectionSlug,\n depth: 1,\n draft,\n limit: batchSize,\n locale,\n overrideAccess: false,\n page: 0,\n select,\n sort,\n user,\n where,\n }\n\n if (debug) {\n req.payload.logger.debug({ message: 'Find arguments:', findArgs })\n }\n\n const toCSVFunctions = getExportFieldFunctions({\n fields: collectionConfig.flattenedFields,\n })\n\n const disabledFields =\n collectionConfig.admin?.custom?.['plugin-import-export']?.disabledFields ?? []\n\n const disabledMatchers = disabledFields.map(buildDisabledFieldRegex)\n\n const filterDisabledCSV = (row: Record<string, unknown>): Record<string, unknown> => {\n const filtered: Record<string, unknown> = {}\n\n for (const [key, value] of Object.entries(row)) {\n const isDisabled = disabledMatchers.some((matcher) => matcher.test(key))\n if (!isDisabled) {\n filtered[key] = value\n }\n }\n\n return filtered\n }\n\n const filterDisabledJSON = (doc: any, parentPath = ''): any => {\n if (Array.isArray(doc)) {\n return doc.map((item) => filterDisabledJSON(item, parentPath))\n }\n\n if (typeof doc !== 'object' || doc === null) {\n return doc\n }\n\n const filtered: Record<string, any> = {}\n for (const [key, value] of Object.entries(doc)) {\n const currentPath = parentPath ? `${parentPath}.${key}` : key\n\n // Only remove if this exact path is disabled\n const isDisabled = disabledFields.includes(currentPath)\n\n if (!isDisabled) {\n filtered[key] = filterDisabledJSON(value, currentPath)\n }\n }\n\n return filtered\n }\n\n if (download) {\n const limitErrorMsg = validateLimitValue(incomingLimit, req.t)\n if (limitErrorMsg) {\n throw new APIError(limitErrorMsg)\n }\n\n // Get schema-based columns first (provides base ordering and handles empty exports)\n let schemaColumns: string[] = []\n if (isCSV) {\n const localeCodes =\n locale === 'all' && payload.config.localization\n ? payload.config.localization.localeCodes\n : undefined\n\n schemaColumns = getSchemaColumns({\n collectionConfig,\n disabledFields,\n fields,\n locale,\n localeCodes,\n })\n\n if (debug) {\n req.payload.logger.debug({\n columnCount: schemaColumns.length,\n msg: 'Schema-based column inference complete',\n })\n }\n }\n\n // allColumns will be finalized after first batch (schema + data columns merged)\n let allColumns: string[] = []\n let columnsFinalized = false\n\n const encoder = new TextEncoder()\n let isFirstBatch = true\n let currentBatchPage = adjustedPage\n let fetched = 0\n const maxDocs =\n typeof maxExportDocuments === 'number' ? maxExportDocuments : Number.POSITIVE_INFINITY\n\n const stream = new Readable({\n async read() {\n const remaining = Math.max(0, maxDocs - fetched)\n\n if (remaining === 0) {\n if (!isCSV) {\n // If first batch with no remaining, output empty array; otherwise just close\n this.push(encoder.encode(isFirstBatch ? '[]' : ']'))\n }\n this.push(null)\n return\n }\n\n const result = await payload.find({\n ...findArgs,\n page: currentBatchPage,\n limit: Math.min(batchSize, remaining),\n })\n\n if (debug) {\n req.payload.logger.debug(\n `Streaming batch ${currentBatchPage} with ${result.docs.length} docs`,\n )\n }\n\n if (result.docs.length === 0) {\n // Close JSON array properly if JSON\n if (!isCSV) {\n // If first batch with no docs, output empty array; otherwise just close\n this.push(encoder.encode(isFirstBatch ? '[]' : ']'))\n }\n this.push(null)\n return\n }\n\n if (isCSV) {\n // --- CSV Streaming ---\n const batchRows = result.docs.map((doc) =>\n filterDisabledCSV(\n flattenObject({\n doc,\n fields,\n toCSVFunctions,\n }),\n ),\n )\n\n // On first batch, discover additional columns from data and merge with schema\n if (!columnsFinalized) {\n const dataColumns: string[] = []\n const seenCols = new Set<string>()\n for (const row of batchRows) {\n for (const key of Object.keys(row)) {\n if (!seenCols.has(key)) {\n seenCols.add(key)\n dataColumns.push(key)\n }\n }\n }\n // Merge schema columns with data-discovered columns\n allColumns = mergeColumns(schemaColumns, dataColumns)\n columnsFinalized = true\n\n if (debug) {\n req.payload.logger.debug({\n dataColumnsCount: dataColumns.length,\n finalColumnsCount: allColumns.length,\n msg: 'Merged schema and data columns',\n })\n }\n }\n\n const paddedRows = batchRows.map((row) => {\n const fullRow: Record<string, unknown> = {}\n for (const col of allColumns) {\n fullRow[col] = row[col] ?? ''\n }\n return fullRow\n })\n\n const csvString = stringify(paddedRows, {\n bom: isFirstBatch,\n header: isFirstBatch,\n columns: allColumns,\n })\n\n this.push(encoder.encode(csvString))\n } else {\n // --- JSON Streaming ---\n const batchRows = result.docs.map((doc) => filterDisabledJSON(doc))\n\n // Convert each filtered/flattened row into JSON string\n const batchJSON = batchRows.map((row) => JSON.stringify(row)).join(',')\n\n if (isFirstBatch) {\n this.push(encoder.encode('[' + batchJSON))\n } else {\n this.push(encoder.encode(',' + batchJSON))\n }\n }\n\n fetched += result.docs.length\n isFirstBatch = false\n currentBatchPage += 1\n\n if (!result.hasNextPage || fetched >= maxDocs) {\n if (debug) {\n req.payload.logger.debug('Stream complete - no more pages')\n }\n if (!isCSV) {\n this.push(encoder.encode(']'))\n }\n this.push(null) // End the stream\n }\n },\n })\n\n return new Response(Readable.toWeb(stream) as ReadableStream, {\n headers: {\n 'Content-Disposition': `attachment; filename=\"${name}\"`,\n 'Content-Type': isCSV ? 'text/csv' : 'application/json',\n },\n })\n }\n\n // Non-download path (buffered export)\n if (debug) {\n req.payload.logger.debug('Starting file generation')\n }\n\n // Create export batch processor\n const processor = createExportBatchProcessor({ batchSize, debug })\n\n // Transform function based on format\n const transformDoc = (doc: unknown) =>\n isCSV\n ? filterDisabledCSV(\n flattenObject({\n doc,\n fields,\n toCSVFunctions,\n }),\n )\n : filterDisabledJSON(doc)\n\n // Skip fetching if access was denied - we'll create an empty export\n let exportResult = {\n columns: [] as string[],\n docs: [] as Record<string, unknown>[],\n fetchedCount: 0,\n }\n\n if (!accessDenied) {\n exportResult = await processor.processExport({\n collectionSlug,\n findArgs: findArgs as ExportFindArgs,\n format,\n maxDocs:\n typeof maxExportDocuments === 'number' ? maxExportDocuments : Number.POSITIVE_INFINITY,\n req,\n startPage: adjustedPage,\n transformDoc,\n })\n }\n\n const { columns: dataColumns, docs: rows } = exportResult\n const outputData: string[] = []\n\n // Prepare final output\n if (isCSV) {\n // Get schema-based columns for consistent ordering\n const localeCodes =\n locale === 'all' && payload.config.localization\n ? payload.config.localization.localeCodes\n : undefined\n\n const schemaColumns = getSchemaColumns({\n collectionConfig,\n disabledFields,\n fields,\n locale,\n localeCodes,\n })\n\n // Merge schema columns with data-discovered columns\n // Schema provides ordering, data provides additional columns (e.g., array indices > 0)\n const finalColumns = mergeColumns(schemaColumns, dataColumns)\n\n const paddedRows = rows.map((row) => {\n const fullRow: Record<string, unknown> = {}\n for (const col of finalColumns) {\n fullRow[col] = row[col] ?? ''\n }\n return fullRow\n })\n\n // Always output CSV with header, even if empty\n outputData.push(\n stringify(paddedRows, {\n bom: true,\n header: true,\n columns: finalColumns,\n }),\n )\n } else {\n // JSON format\n outputData.push(rows.map((doc) => JSON.stringify(doc)).join(',\\n'))\n }\n\n // Ensure we always have valid content for the file\n // For JSON, empty exports produce \"[]\"\n // For CSV, if completely empty (no columns, no rows), produce at least a newline to ensure file creation\n const content = format === 'json' ? `[${outputData.join(',')}]` : outputData.join('')\n const buffer = Buffer.from(content.length > 0 ? content : '\\n')\n if (debug) {\n req.payload.logger.debug(`${format} file generation complete`)\n }\n\n if (!id) {\n if (debug) {\n req.payload.logger.debug('Creating new export file')\n }\n req.file = {\n name,\n data: buffer,\n mimetype: isCSV ? 'text/csv' : 'application/json',\n size: buffer.length,\n }\n } else {\n if (debug) {\n req.payload.logger.debug({\n msg: '[createExport] Updating export document with file',\n exportDocId: id,\n exportCollection,\n fileName: name,\n fileSize: buffer.length,\n mimeType: isCSV ? 'text/csv' : 'application/json',\n })\n }\n try {\n await req.payload.update({\n id,\n collection: exportCollection,\n data: {},\n file: {\n name,\n data: buffer,\n mimetype: isCSV ? 'text/csv' : 'application/json',\n size: buffer.length,\n },\n // Override access only here so that we can be sure the export collection itself is updated as expected\n overrideAccess: true,\n req,\n })\n } catch (error) {\n const errorDetails =\n error instanceof Error\n ? {\n message: error.message,\n name: error.name,\n stack: error.stack,\n // @ts-expect-error - data might exist on Payload errors\n data: error.data,\n }\n : error\n req.payload.logger.error({\n msg: '[createExport] Failed to update export document with file',\n err: errorDetails,\n exportDocId: id,\n exportCollection,\n fileName: name,\n })\n throw error\n }\n }\n if (debug) {\n req.payload.logger.debug('Export process completed successfully')\n }\n}\n"],"names":["stringify","APIError","Readable","buildDisabledFieldRegex","flattenObject","getExportFieldFunctions","getFilename","getSchemaColumns","mergeColumns","getSelect","validateLimitValue","createExportBatchProcessor","createExport","args","id","name","nameArg","batchSize","collectionSlug","debug","download","drafts","draftsFromInput","exportCollection","fields","format","limit","incomingLimit","maxLimit","locale","localeFromInput","page","req","sort","userCollection","userID","where","whereFromInput","localeFromReq","payload","logger","msg","exportDocId","exportName","draft","collectionConfig","config","collections","find","slug","user","findByID","collection","overrideAccess","hasVersions","Boolean","versions","publishedWhere","_status","equals","and","baseName","isCSV","select","Array","isArray","length","undefined","message","maxExportDocuments","Math","min","totalDocs","accessDenied","countResult","count","error","totalPages","max","ceil","requestedPage","adjustedPage","findArgs","depth","toCSVFunctions","flattenedFields","disabledFields","admin","custom","disabledMatchers","map","filterDisabledCSV","row","filtered","key","value","Object","entries","isDisabled","some","matcher","test","filterDisabledJSON","doc","parentPath","item","currentPath","includes","limitErrorMsg","t","schemaColumns","localeCodes","localization","columnCount","allColumns","columnsFinalized","encoder","TextEncoder","isFirstBatch","currentBatchPage","fetched","maxDocs","Number","POSITIVE_INFINITY","stream","read","remaining","push","encode","result","docs","batchRows","dataColumns","seenCols","Set","keys","has","add","dataColumnsCount","finalColumnsCount","paddedRows","fullRow","col","csvString","bom","header","columns","batchJSON","JSON","join","hasNextPage","Response","toWeb","headers","processor","transformDoc","exportResult","fetchedCount","processExport","startPage","rows","outputData","finalColumns","content","buffer","Buffer","from","file","data","mimetype","size","fileName","fileSize","mimeType","update","errorDetails","Error","stack","err"],"mappings":"AAAA,6CAA6C,GAG7C,SAASA,SAAS,QAAQ,qBAAoB;AAC9C,SAASC,QAAQ,QAAQ,UAAS;AAClC,SAASC,QAAQ,QAAQ,SAAQ;AAEjC,SAASC,uBAAuB,QAAQ,0CAAyC;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AC;gBACvBsB,KAAK;gBACLC,aAAa5B;gBACbS;gBACAoJ,UAAU5J;gBACV6J,UAAUR,OAAOlG,MAAM;gBACvB2G,UAAU/G,QAAQ,aAAa;YACjC;QACF;QACA,IAAI;YACF,MAAM9B,IAAIO,OAAO,CAACuI,MAAM,CAAC;gBACvBhK;gBACAsC,YAAY7B;gBACZiJ,MAAM,CAAC;gBACPD,MAAM;oBACJxJ;oBACAyJ,MAAMJ;oBACNK,UAAU3G,QAAQ,aAAa;oBAC/B4G,MAAMN,OAAOlG,MAAM;gBACrB;gBACA,uGAAuG;gBACvGb,gBAAgB;gBAChBrB;YACF;QACF,EAAE,OAAO4C,OAAO;YACd,MAAMmG,eACJnG,iBAAiBoG,QACb;gBACE5G,SAASQ,MAAMR,OAAO;gBACtBrD,MAAM6D,MAAM7D,IAAI;gBAChBkK,OAAOrG,MAAMqG,KAAK;gBAClB,wDAAwD;gBACxDT,MAAM5F,MAAM4F,IAAI;YAClB,IACA5F;YACN5C,IAAIO,OAAO,CAACC,MAAM,CAACoC,KAAK,CAAC;gBACvBnC,KAAK;gBACLyI,KAAKH;gBACLrI,aAAa5B;gBACbS;gBACAoJ,UAAU5J;YACZ;YACA,MAAM6D;QACR;IACF;IACA,IAAIzD,OAAO;QACTa,IAAIO,OAAO,CAACC,MAAM,CAACrB,KAAK,CAAC;IAC3B;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/export/createExport.ts"],"sourcesContent":["/* eslint-disable perfectionist/sort-objects */\nimport type { PayloadRequest, Sort, TypedUser, Where } from 'payload'\n\nimport { stringify } from 'csv-stringify/sync'\nimport { APIError } from 'payload'\nimport { Readable } from 'stream'\n\nimport { buildDisabledFieldRegex } from '../utilities/buildDisabledFieldRegex.js'\nimport { flattenObject } from '../utilities/flattenObject.js'\nimport { getExportFieldFunctions } from '../utilities/getExportFieldFunctions.js'\nimport { getFilename } from '../utilities/getFilename.js'\nimport { getSchemaColumns, mergeColumns } from '../utilities/getSchemaColumns.js'\nimport { getSelect } from '../utilities/getSelect.js'\nimport { validateLimitValue } from '../utilities/validateLimitValue.js'\nimport { createExportBatchProcessor, type ExportFindArgs } from './batchProcessor.js'\n\nexport type Export = {\n /**\n * Number of documents to process in each batch during export\n * @default 100\n */\n batchSize?: number\n collectionSlug: string\n /**\n * If true, enables debug logging\n */\n debug?: boolean\n drafts?: 'no' | 'yes'\n exportCollection: string\n fields?: string[]\n format: 'csv' | 'json'\n globals?: string[]\n id: number | string\n limit?: number\n locale?: string\n /**\n * Maximum number of documents that can be exported in a single operation.\n * This value has already been resolved from the plugin config.\n */\n maxLimit?: number\n name: string\n page?: number\n sort?: Sort\n userCollection: string\n userID: number | string\n where?: Where\n}\n\nexport type CreateExportArgs = {\n /**\n * If true, stream the file instead of saving it\n */\n download?: boolean\n req: PayloadRequest\n} & Export\n\nexport const createExport = async (args: CreateExportArgs) => {\n const {\n id,\n name: nameArg,\n batchSize = 100,\n collectionSlug,\n debug = false,\n download,\n drafts: draftsFromInput,\n exportCollection,\n fields,\n format,\n limit: incomingLimit,\n maxLimit,\n locale: localeFromInput,\n page,\n req,\n sort,\n userCollection,\n userID,\n where: whereFromInput = {},\n } = args\n const { locale: localeFromReq, payload } = req\n\n if (debug) {\n req.payload.logger.debug({\n msg: '[createExport] Starting export process',\n exportDocId: id,\n exportName: nameArg,\n collectionSlug,\n exportCollection,\n draft: draftsFromInput,\n fields,\n format,\n })\n }\n\n const locale = localeFromInput ?? localeFromReq\n const collectionConfig = payload.config.collections.find(({ slug }) => slug === collectionSlug)\n\n if (!collectionConfig) {\n throw new APIError(`Collection with slug ${collectionSlug} not found.`)\n }\n\n let user: TypedUser | undefined\n\n if (userCollection && userID) {\n user = (await req.payload.findByID({\n id: userID,\n collection: userCollection,\n overrideAccess: true,\n })) as TypedUser\n }\n\n if (!user && req.user) {\n user = req?.user?.id ? req.user : req?.user?.user\n }\n\n if (!user) {\n throw new APIError('User authentication is required to create exports.')\n }\n\n const draft = draftsFromInput === 'yes'\n const hasVersions = Boolean(collectionConfig.versions)\n\n // Only filter by _status for versioned collections\n const publishedWhere: Where = hasVersions ? { _status: { equals: 'published' } } : {}\n\n const where: Where = {\n and: [whereFromInput, draft ? {} : publishedWhere],\n }\n\n const baseName = nameArg ?? getFilename()\n const name = `${baseName}-${collectionSlug}.${format}`\n const isCSV = format === 'csv'\n const select = Array.isArray(fields) && fields.length > 0 ? getSelect(fields) : undefined\n\n if (debug) {\n req.payload.logger.debug({ message: 'Export configuration:', name, isCSV, locale })\n }\n\n // Determine maximum export documents:\n // 1. If maxLimit is defined, it sets the absolute ceiling\n // 2. User's limit is applied but clamped to maxLimit if it exceeds it\n let maxExportDocuments: number | undefined\n\n if (typeof maxLimit === 'number' && maxLimit > 0) {\n if (typeof incomingLimit === 'number' && incomingLimit > 0) {\n // User provided a limit - clamp it to maxLimit\n maxExportDocuments = Math.min(incomingLimit, maxLimit)\n } else {\n // No user limit - use maxLimit as the ceiling\n maxExportDocuments = maxLimit\n }\n } else {\n // No maxLimit - use user's limit if provided\n maxExportDocuments =\n typeof incomingLimit === 'number' && incomingLimit > 0 ? incomingLimit : undefined\n }\n\n // Try to count documents - if access is denied, treat as 0 documents\n let totalDocs = 0\n let accessDenied = false\n try {\n const countResult = await payload.count({\n collection: collectionSlug,\n user,\n locale,\n overrideAccess: false,\n })\n totalDocs = countResult.totalDocs\n } catch (error) {\n // Access denied - user can't read from this collection\n // We'll create an empty export file\n accessDenied = true\n if (debug) {\n req.payload.logger.debug({\n message: 'Access denied for collection, creating empty export',\n collectionSlug,\n })\n }\n }\n\n const totalPages = Math.max(1, Math.ceil(totalDocs / batchSize))\n const requestedPage = page || 1\n const adjustedPage = requestedPage > totalPages ? 1 : requestedPage\n\n const findArgs = {\n collection: collectionSlug,\n depth: 1,\n draft,\n limit: batchSize,\n locale,\n overrideAccess: false,\n page: 0,\n select,\n sort,\n user,\n where,\n }\n\n if (debug) {\n req.payload.logger.debug({ message: 'Find arguments:', findArgs })\n }\n\n const toCSVFunctions = getExportFieldFunctions({\n fields: collectionConfig.flattenedFields,\n })\n\n const disabledFields =\n collectionConfig.admin?.custom?.['plugin-import-export']?.disabledFields ?? []\n\n const disabledMatchers = disabledFields.map(buildDisabledFieldRegex)\n\n const filterDisabledCSV = (row: Record<string, unknown>): Record<string, unknown> => {\n const filtered: Record<string, unknown> = {}\n\n for (const [key, value] of Object.entries(row)) {\n const isDisabled = disabledMatchers.some((matcher) => matcher.test(key))\n if (!isDisabled) {\n filtered[key] = value\n }\n }\n\n return filtered\n }\n\n const filterDisabledJSON = (doc: any, parentPath = ''): any => {\n if (Array.isArray(doc)) {\n return doc.map((item) => filterDisabledJSON(item, parentPath))\n }\n\n if (typeof doc !== 'object' || doc === null) {\n return doc\n }\n\n const filtered: Record<string, any> = {}\n for (const [key, value] of Object.entries(doc)) {\n const currentPath = parentPath ? `${parentPath}.${key}` : key\n\n // Only remove if this exact path is disabled\n const isDisabled = disabledFields.includes(currentPath)\n\n if (!isDisabled) {\n filtered[key] = filterDisabledJSON(value, currentPath)\n }\n }\n\n return filtered\n }\n\n if (download) {\n const limitErrorMsg = validateLimitValue(incomingLimit, req.t)\n if (limitErrorMsg) {\n throw new APIError(limitErrorMsg)\n }\n\n // Get schema-based columns first (provides base ordering and handles empty exports)\n let schemaColumns: string[] = []\n if (isCSV) {\n const localeCodes =\n locale === 'all' && payload.config.localization\n ? payload.config.localization.localeCodes\n : undefined\n\n schemaColumns = getSchemaColumns({\n collectionConfig,\n disabledFields,\n fields,\n locale,\n localeCodes,\n })\n\n if (debug) {\n req.payload.logger.debug({\n columnCount: schemaColumns.length,\n msg: 'Schema-based column inference complete',\n })\n }\n }\n\n // allColumns will be finalized after first batch (schema + data columns merged)\n let allColumns: string[] = []\n let columnsFinalized = false\n\n const encoder = new TextEncoder()\n let isFirstBatch = true\n let currentBatchPage = adjustedPage\n let fetched = 0\n const maxDocs =\n typeof maxExportDocuments === 'number' ? maxExportDocuments : Number.POSITIVE_INFINITY\n\n const stream = new Readable({\n async read() {\n const remaining = Math.max(0, maxDocs - fetched)\n\n if (remaining === 0) {\n if (!isCSV) {\n // If first batch with no remaining, output empty array; otherwise just close\n this.push(encoder.encode(isFirstBatch ? '[]' : ']'))\n }\n this.push(null)\n return\n }\n\n const result = await payload.find({\n ...findArgs,\n page: currentBatchPage,\n limit: Math.min(batchSize, remaining),\n })\n\n if (debug) {\n req.payload.logger.debug(\n `Streaming batch ${currentBatchPage} with ${result.docs.length} docs`,\n )\n }\n\n if (result.docs.length === 0) {\n // Close JSON array properly if JSON\n if (!isCSV) {\n // If first batch with no docs, output empty array; otherwise just close\n this.push(encoder.encode(isFirstBatch ? '[]' : ']'))\n }\n this.push(null)\n return\n }\n\n if (isCSV) {\n // --- CSV Streaming ---\n const batchRows = result.docs.map((doc) =>\n filterDisabledCSV(\n flattenObject({\n doc,\n fields,\n toCSVFunctions,\n }),\n ),\n )\n\n // On first batch, discover additional columns from data and merge with schema\n if (!columnsFinalized) {\n const dataColumns: string[] = []\n const seenCols = new Set<string>()\n for (const row of batchRows) {\n for (const key of Object.keys(row)) {\n if (!seenCols.has(key)) {\n seenCols.add(key)\n dataColumns.push(key)\n }\n }\n }\n // Merge schema columns with data-discovered columns\n allColumns = mergeColumns(schemaColumns, dataColumns)\n columnsFinalized = true\n\n if (debug) {\n req.payload.logger.debug({\n dataColumnsCount: dataColumns.length,\n finalColumnsCount: allColumns.length,\n msg: 'Merged schema and data columns',\n })\n }\n }\n\n const paddedRows = batchRows.map((row) => {\n const fullRow: Record<string, unknown> = {}\n for (const col of allColumns) {\n fullRow[col] = row[col] ?? ''\n }\n return fullRow\n })\n\n const csvString = stringify(paddedRows, {\n bom: isFirstBatch,\n header: isFirstBatch,\n columns: allColumns,\n })\n\n this.push(encoder.encode(csvString))\n } else {\n // --- JSON Streaming ---\n const batchRows = result.docs.map((doc) => filterDisabledJSON(doc))\n\n // Convert each filtered/flattened row into JSON string\n const batchJSON = batchRows.map((row) => JSON.stringify(row)).join(',')\n\n if (isFirstBatch) {\n this.push(encoder.encode('[' + batchJSON))\n } else {\n this.push(encoder.encode(',' + batchJSON))\n }\n }\n\n fetched += result.docs.length\n isFirstBatch = false\n currentBatchPage += 1\n\n if (!result.hasNextPage || fetched >= maxDocs) {\n if (debug) {\n req.payload.logger.debug('Stream complete - no more pages')\n }\n if (!isCSV) {\n this.push(encoder.encode(']'))\n }\n this.push(null) // End the stream\n }\n },\n })\n\n return new Response(Readable.toWeb(stream) as ReadableStream, {\n headers: {\n 'Content-Disposition': `attachment; filename=\"${name}\"`,\n 'Content-Type': isCSV ? 'text/csv; charset=utf-8' : 'application/json',\n },\n })\n }\n\n // Non-download path (buffered export)\n if (debug) {\n req.payload.logger.debug('Starting file generation')\n }\n\n // Create export batch processor\n const processor = createExportBatchProcessor({ batchSize, debug })\n\n // Transform function based on format\n const transformDoc = (doc: unknown) =>\n isCSV\n ? filterDisabledCSV(\n flattenObject({\n doc,\n fields,\n toCSVFunctions,\n }),\n )\n : filterDisabledJSON(doc)\n\n // Skip fetching if access was denied - we'll create an empty export\n let exportResult = {\n columns: [] as string[],\n docs: [] as Record<string, unknown>[],\n fetchedCount: 0,\n }\n\n if (!accessDenied) {\n exportResult = await processor.processExport({\n collectionSlug,\n findArgs: findArgs as ExportFindArgs,\n format,\n maxDocs:\n typeof maxExportDocuments === 'number' ? maxExportDocuments : Number.POSITIVE_INFINITY,\n req,\n startPage: adjustedPage,\n transformDoc,\n })\n }\n\n const { columns: dataColumns, docs: rows } = exportResult\n const outputData: string[] = []\n\n // Prepare final output\n if (isCSV) {\n // Get schema-based columns for consistent ordering\n const localeCodes =\n locale === 'all' && payload.config.localization\n ? payload.config.localization.localeCodes\n : undefined\n\n const schemaColumns = getSchemaColumns({\n collectionConfig,\n disabledFields,\n fields,\n locale,\n localeCodes,\n })\n\n // Merge schema columns with data-discovered columns\n // Schema provides ordering, data provides additional columns (e.g., array indices > 0)\n const finalColumns = mergeColumns(schemaColumns, dataColumns)\n\n const paddedRows = rows.map((row) => {\n const fullRow: Record<string, unknown> = {}\n for (const col of finalColumns) {\n fullRow[col] = row[col] ?? ''\n }\n return fullRow\n })\n\n // Always output CSV with header, even if empty\n outputData.push(\n stringify(paddedRows, {\n bom: true,\n header: true,\n columns: finalColumns,\n }),\n )\n } else {\n // JSON format\n outputData.push(rows.map((doc) => JSON.stringify(doc)).join(',\\n'))\n }\n\n // Ensure we always have valid content for the file\n // For JSON, empty exports produce \"[]\"\n // For CSV, if completely empty (no columns, no rows), produce at least a newline to ensure file creation\n const content = format === 'json' ? `[${outputData.join(',')}]` : outputData.join('')\n const buffer = Buffer.from(content.length > 0 ? content : '\\n')\n if (debug) {\n req.payload.logger.debug(`${format} file generation complete`)\n }\n\n if (!id) {\n if (debug) {\n req.payload.logger.debug('Creating new export file')\n }\n req.file = {\n name,\n data: buffer,\n mimetype: isCSV ? 'text/csv; charset=utf-8' : 'application/json',\n size: buffer.length,\n }\n } else {\n if (debug) {\n req.payload.logger.debug({\n msg: '[createExport] Updating export document with file',\n exportDocId: id,\n exportCollection,\n fileName: name,\n fileSize: buffer.length,\n mimeType: isCSV ? 'text/csv; charset=utf-8' : 'application/json',\n })\n }\n try {\n await req.payload.update({\n id,\n collection: exportCollection,\n data: {},\n file: {\n name,\n data: buffer,\n mimetype: isCSV ? 'text/csv; charset=utf-8' : 'application/json',\n size: buffer.length,\n },\n // Override access only here so that we can be sure the export collection itself is updated as expected\n overrideAccess: true,\n req,\n })\n } catch (error) {\n const errorDetails =\n error instanceof Error\n ? {\n message: error.message,\n name: error.name,\n stack: error.stack,\n // @ts-expect-error - data might exist on Payload errors\n data: error.data,\n }\n : error\n req.payload.logger.error({\n msg: '[createExport] Failed to update export document with file',\n err: errorDetails,\n exportDocId: id,\n exportCollection,\n fileName: name,\n })\n throw error\n }\n }\n if (debug) {\n req.payload.logger.debug('Export process completed successfully')\n }\n}\n"],"names":["stringify","APIError","Readable","buildDisabledFieldRegex","flattenObject","getExportFieldFunctions","getFilename","getSchemaColumns","mergeColumns","getSelect","validateLimitValue","createExportBatchProcessor","createExport","args","id","name","nameArg","batchSize","collectionSlug","debug","download","drafts","draftsFromInput","exportCollection","fields","format","limit","incomingLimit","maxLimit","locale","localeFromInput","page","req","sort","userCollection","userID","where","whereFromInput","localeFromReq","payload","logger","msg","exportDocId","exportName","draft","collectionConfig","config","collections","find","slug","user","findByID","collection","overrideAccess","hasVersions","Boolean","versions","publishedWhere","_status","equals","and","baseName","isCSV","select","Array","isArray","length","undefined","message","maxExportDocuments","Math","min","totalDocs","accessDenied","countResult","count","error","totalPages","max","ceil","requestedPage","adjustedPage","findArgs","depth","toCSVFunctions","flattenedFields","disabledFields","admin","custom","disabledMatchers","map","filterDisabledCSV","row","filtered","key","value","Object","entries","isDisabled","some","matcher","test","filterDisabledJSON","doc","parentPath","item","currentPath","includes","limitErrorMsg","t","schemaColumns","localeCodes","localization","columnCount","allColumns","columnsFinalized","encoder","TextEncoder","isFirstBatch","currentBatchPage","fetched","maxDocs","Number","POSITIVE_INFINITY","stream","read","remaining","push","encode","result","docs","batchRows","dataColumns","seenCols","Set","keys","has","add","dataColumnsCount","finalColumnsCount","paddedRows","fullRow","col","csvString","bom","header","columns","batchJSON","JSON","join","hasNextPage","Response","toWeb","headers","processor","transformDoc","exportResult","fetchedCount","processExport","startPage","rows","outputData","finalColumns","content","buffer","Buffer","from","file","data","mimetype","size","fileName","fileSize","mimeType","update","errorDetails","Error","stack","err"],"mappings":"AAAA,6CAA6C,GAG7C,SAASA,SAAS,QAAQ,qBAAoB;AAC9C,SAASC,QAAQ,QAAQ,UAAS;AAClC,SAASC,QAAQ,QAAQ,SAAQ;AAEjC,SAASC,uBAAuB,QAAQ,0CAAyC;AACjF,SAASC,aAAa,QAAQ,gCAA+B;AAC7D,SAASC,uBAAuB,QAAQ,0CAAyC;AACjF,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,gBAAgB,EAAEC,YAAY,QAAQ,mCAAkC;AACjF,SAASC,SAAS,QAAQ,4BAA2B;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M,CAAC;gBACvBhK;gBACAsC,YAAY7B;gBACZiJ,MAAM,CAAC;gBACPD,MAAM;oBACJxJ;oBACAyJ,MAAMJ;oBACNK,UAAU3G,QAAQ,4BAA4B;oBAC9C4G,MAAMN,OAAOlG,MAAM;gBACrB;gBACA,uGAAuG;gBACvGb,gBAAgB;gBAChBrB;YACF;QACF,EAAE,OAAO4C,OAAO;YACd,MAAMmG,eACJnG,iBAAiBoG,QACb;gBACE5G,SAASQ,MAAMR,OAAO;gBACtBrD,MAAM6D,MAAM7D,IAAI;gBAChBkK,OAAOrG,MAAMqG,KAAK;gBAClB,wDAAwD;gBACxDT,MAAM5F,MAAM4F,IAAI;YAClB,IACA5F;YACN5C,IAAIO,OAAO,CAACC,MAAM,CAACoC,KAAK,CAAC;gBACvBnC,KAAK;gBACLyI,KAAKH;gBACLrI,aAAa5B;gBACbS;gBACAoJ,UAAU5J;YACZ;YACA,MAAM6D;QACR;IACF;IACA,IAAIzD,OAAO;QACTa,IAAIO,OAAO,CAACC,MAAM,CAACrB,KAAK,CAAC;IAC3B;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batchProcessor.d.ts","sourceRoot":"","sources":["../../src/import/batchProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIxD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEjE,OAAO,EACL,KAAK,UAAU,EAIhB,MAAM,mCAAmC,CAAA;AAE1C;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oBAAoB,CAAC,EAAE,OAAO,GAAG,WAAW,CAAA;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtE,YAAY,EAAE,MAAM,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AAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,CAAA;IAC1B,UAAU,EAAE,KAAK,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QACjC,KAAK,EAAE,MAAM,CAAA;QACb,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;QACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAChC,CAAC,CAAA;CACH;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACpC,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB;AAuiBD,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,2BAAgC;oCAMrC,oBAAoB,KAAG,OAAO,CAAC,YAAY,CAAC;EA2D1F"}
|
|
@@ -4,14 +4,14 @@ import { categorizeError, createBatches, extractErrorMessage } from '../utilitie
|
|
|
4
4
|
* Separates multi-locale data from a document for sequential locale updates.
|
|
5
5
|
*
|
|
6
6
|
* When a field has locale-keyed values (e.g., { title: { en: 'Hello', es: 'Hola' } }),
|
|
7
|
-
* this extracts the
|
|
7
|
+
* this extracts the default locale's data for initial create/update, and stores
|
|
8
8
|
* remaining locales for subsequent update calls.
|
|
9
9
|
*
|
|
10
10
|
* @returns
|
|
11
|
-
* - flatData: Document with
|
|
11
|
+
* - flatData: Document with default locale values extracted (for initial operation)
|
|
12
12
|
* - hasMultiLocale: Whether any multi-locale fields were found
|
|
13
13
|
* - localeUpdates: Map of locale -> field data for follow-up updates
|
|
14
|
-
*/ function extractMultiLocaleData(data, configuredLocales) {
|
|
14
|
+
*/ function extractMultiLocaleData(data, configuredLocales, defaultLocale) {
|
|
15
15
|
const flatData = {};
|
|
16
16
|
const localeUpdates = {};
|
|
17
17
|
let hasMultiLocale = false;
|
|
@@ -31,11 +31,11 @@ import { categorizeError, createBatches, extractErrorMessage } from '../utilitie
|
|
|
31
31
|
const localeKeys = Object.keys(valueObj).filter((k)=>localeSet.has(k));
|
|
32
32
|
if (localeKeys.length > 0) {
|
|
33
33
|
hasMultiLocale = true;
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
flatData[key] = valueObj[
|
|
34
|
+
const baseLocale = defaultLocale && localeKeys.includes(defaultLocale) ? defaultLocale : localeKeys[0];
|
|
35
|
+
if (baseLocale) {
|
|
36
|
+
flatData[key] = valueObj[baseLocale];
|
|
37
37
|
for (const locale of localeKeys){
|
|
38
|
-
if (locale !==
|
|
38
|
+
if (locale !== baseLocale) {
|
|
39
39
|
if (!localeUpdates[locale]) {
|
|
40
40
|
localeUpdates[locale] = {};
|
|
41
41
|
}
|
|
@@ -83,6 +83,7 @@ import { categorizeError, createBatches, extractErrorMessage } from '../utilitie
|
|
|
83
83
|
const collectionHasVersions = Boolean(collectionConfig?.versions);
|
|
84
84
|
const hasCustomIdField = Boolean(collectionEntry?.customIDType);
|
|
85
85
|
const configuredLocales = req.payload.config.localization ? req.payload.config.localization.localeCodes : undefined;
|
|
86
|
+
const defaultLocale = req.payload.config.localization ? req.payload.config.localization.defaultLocale : undefined;
|
|
86
87
|
const startingRowNumber = batchIndex * options.batchSize;
|
|
87
88
|
for(let i = 0; i < batch.length; i++){
|
|
88
89
|
const document = batch[i];
|
|
@@ -124,15 +125,19 @@ import { categorizeError, createBatches, extractErrorMessage } from '../utilitie
|
|
|
124
125
|
});
|
|
125
126
|
}
|
|
126
127
|
// Check if we have multi-locale data and extract it
|
|
127
|
-
const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(createData, configuredLocales);
|
|
128
|
+
const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(createData, configuredLocales, defaultLocale);
|
|
128
129
|
if (hasMultiLocale) {
|
|
129
130
|
// Create with default locale data
|
|
131
|
+
const defaultLocaleReq = defaultLocale ? {
|
|
132
|
+
...req,
|
|
133
|
+
locale: defaultLocale
|
|
134
|
+
} : req;
|
|
130
135
|
savedDocument = await req.payload.create({
|
|
131
136
|
collection: collectionSlug,
|
|
132
137
|
data: flatData,
|
|
133
138
|
draft: draftOption,
|
|
134
139
|
overrideAccess: false,
|
|
135
|
-
req,
|
|
140
|
+
req: defaultLocaleReq,
|
|
136
141
|
user
|
|
137
142
|
});
|
|
138
143
|
// Update for other locales
|
|
@@ -245,7 +250,7 @@ import { categorizeError, createBatches, extractErrorMessage } from '../utilitie
|
|
|
245
250
|
delete updateData.createdAt;
|
|
246
251
|
delete updateData.updatedAt;
|
|
247
252
|
// Check if we have multi-locale data and extract it
|
|
248
|
-
const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(updateData, configuredLocales);
|
|
253
|
+
const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(updateData, configuredLocales, defaultLocale);
|
|
249
254
|
if (req.payload.config.debug) {
|
|
250
255
|
req.payload.logger.info({
|
|
251
256
|
existingId: existingDoc.id,
|
|
@@ -261,6 +266,10 @@ import { categorizeError, createBatches, extractErrorMessage } from '../utilitie
|
|
|
261
266
|
}
|
|
262
267
|
if (hasMultiLocale) {
|
|
263
268
|
// Update with default locale data
|
|
269
|
+
const defaultLocaleReq = defaultLocale ? {
|
|
270
|
+
...req,
|
|
271
|
+
locale: defaultLocale
|
|
272
|
+
} : req;
|
|
264
273
|
savedDocument = await req.payload.update({
|
|
265
274
|
id: existingDoc.id,
|
|
266
275
|
collection: collectionSlug,
|
|
@@ -268,7 +277,7 @@ import { categorizeError, createBatches, extractErrorMessage } from '../utilitie
|
|
|
268
277
|
depth: 0,
|
|
269
278
|
// Don't specify draft - this creates a new draft for versioned collections
|
|
270
279
|
overrideAccess: false,
|
|
271
|
-
req,
|
|
280
|
+
req: defaultLocaleReq,
|
|
272
281
|
user
|
|
273
282
|
});
|
|
274
283
|
// Update for other locales
|
|
@@ -366,15 +375,19 @@ import { categorizeError, createBatches, extractErrorMessage } from '../utilitie
|
|
|
366
375
|
createData._status = statusValue;
|
|
367
376
|
}
|
|
368
377
|
// Check if we have multi-locale data and extract it
|
|
369
|
-
const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(createData, configuredLocales);
|
|
378
|
+
const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(createData, configuredLocales, defaultLocale);
|
|
370
379
|
if (hasMultiLocale) {
|
|
371
380
|
// Create with default locale data
|
|
381
|
+
const defaultLocaleReq = defaultLocale ? {
|
|
382
|
+
...req,
|
|
383
|
+
locale: defaultLocale
|
|
384
|
+
} : req;
|
|
372
385
|
savedDocument = await req.payload.create({
|
|
373
386
|
collection: collectionSlug,
|
|
374
387
|
data: flatData,
|
|
375
388
|
draft: draftOption,
|
|
376
389
|
overrideAccess: false,
|
|
377
|
-
req,
|
|
390
|
+
req: defaultLocaleReq,
|
|
378
391
|
user
|
|
379
392
|
});
|
|
380
393
|
// Update for other locales
|
|
@@ -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 { 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,q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QAAQxB,SAAS,KAAK,WAAW;oBAC1ClF,OAAOuG,OAAO;gBAChB,OAAO;oBACL,WAAW;oBACX,IAAI7G,eAAe,UAAU;wBAC3BM,OAAOqG,QAAQ;oBACjB,OAAO;wBACLrG,OAAOuG,OAAO;oBAChB;gBACF;YACF;YAEA,KAAK,MAAMzD,SAAS2D,YAAYxG,MAAM,CAAE;gBACtCD,OAAO2F,MAAM,CAACR,IAAI,CAAC;oBACjBwB,KAAK7D,MAAMyC,YAAY;oBACvBzC,OAAOA,MAAMA,KAAK;oBAClBsC,OAAOtC,MAAMzB,SAAS,GAAG;gBAC3B;YACF;QACF;QAEA,OAAOrB;IACT;IAEA,OAAO;QACLiG;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 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 // 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 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 // 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 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 // 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","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","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,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;I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AE+C,IAAK;YACvC,MAAMsF,eAAeJ,OAAO,CAAClF,EAAE;YAC/B,IAAI,CAACsF,cAAc;gBACjB;YACF;YAEA,MAAMC,cAAc,MAAMpH,mBAAmB;gBAC3CC,OAAOkH;gBACPjH,YAAY2B;gBACZ1B;gBACAC;gBACAC;gBACAC,SAASqG;gBACTpG;gBACAE;YACF;YAEA,iBAAiB;YACjB,KAAK,MAAM4G,WAAWD,YAAYxG,UAAU,CAAE;gBAC5C,IAAIyG,QAAQxB,SAAS,KAAK,WAAW;oBACnCnF,OAAOsG,QAAQ;gBACjB,OAAO,IAAIK,QAAQxB,SAAS,KAAK,WAAW;oBAC1CnF,OAAOwG,OAAO;gBAChB,OAAO;oBACL,WAAW;oBACX,IAAI9G,eAAe,UAAU;wBAC3BM,OAAOsG,QAAQ;oBACjB,OAAO;wBACLtG,OAAOwG,OAAO;oBAChB;gBACF;YACF;YAEA,KAAK,MAAMzD,SAAS2D,YAAYzG,MAAM,CAAE;gBACtCD,OAAO4F,MAAM,CAACR,IAAI,CAAC;oBACjBwB,KAAK7D,MAAMyC,YAAY;oBACvBzC,OAAOA,MAAMA,KAAK;oBAClBsC,OAAOtC,MAAM1B,SAAS,GAAG;gBAC3B;YACF;QACF;QAEA,OAAOrB;IACT;IAEA,OAAO;QACLkG;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-import-export",
|
|
3
|
-
"version": "3.79.0-canary.
|
|
3
|
+
"version": "3.79.0-canary.4",
|
|
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": "7.0.2",
|
|
67
|
-
"@payloadcms/translations": "3.79.0-canary.
|
|
68
|
-
"@payloadcms/ui": "3.79.0-canary.
|
|
67
|
+
"@payloadcms/translations": "3.79.0-canary.4",
|
|
68
|
+
"@payloadcms/ui": "3.79.0-canary.4"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@payloadcms/eslint-config": "3.28.0",
|
|
72
|
-
"@payloadcms/ui": "3.79.0-canary.
|
|
73
|
-
"payload": "3.79.0-canary.
|
|
72
|
+
"@payloadcms/ui": "3.79.0-canary.4",
|
|
73
|
+
"payload": "3.79.0-canary.4"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@payloadcms/ui": "3.79.0-canary.
|
|
77
|
-
"payload": "3.79.0-canary.
|
|
76
|
+
"@payloadcms/ui": "3.79.0-canary.4",
|
|
77
|
+
"payload": "3.79.0-canary.4"
|
|
78
78
|
},
|
|
79
79
|
"homepage:": "https://payloadcms.com",
|
|
80
80
|
"scripts": {
|