@payloadcms/plugin-import-export 3.77.0-canary.7 → 3.77.0-internal-debug.98d2e4d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/components/CollectionField/index.d.ts +2 -2
  2. package/dist/components/CollectionField/index.d.ts.map +1 -1
  3. package/dist/components/CollectionField/index.js +5 -28
  4. package/dist/components/CollectionField/index.js.map +1 -1
  5. package/dist/components/CollectionSelectField/index.d.ts +13 -0
  6. package/dist/components/CollectionSelectField/index.d.ts.map +1 -0
  7. package/dist/components/CollectionSelectField/index.js +159 -0
  8. package/dist/components/CollectionSelectField/index.js.map +1 -0
  9. package/dist/components/ExportListMenuItem/index.d.ts.map +1 -1
  10. package/dist/components/ExportListMenuItem/index.js +5 -1
  11. package/dist/components/ExportListMenuItem/index.js.map +1 -1
  12. package/dist/components/ExportPreview/index.d.ts.map +1 -1
  13. package/dist/components/ExportPreview/index.js.map +1 -1
  14. package/dist/components/FieldsToExport/index.js +1 -1
  15. package/dist/components/FieldsToExport/index.js.map +1 -1
  16. package/dist/components/ImportPreview/index.d.ts.map +1 -1
  17. package/dist/components/ImportPreview/index.js +50 -30
  18. package/dist/components/ImportPreview/index.js.map +1 -1
  19. package/dist/export/createExport.d.ts +1 -2
  20. package/dist/export/createExport.d.ts.map +1 -1
  21. package/dist/export/createExport.js +2 -1
  22. package/dist/export/createExport.js.map +1 -1
  23. package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
  24. package/dist/export/getCreateExportCollectionTask.js +12 -1
  25. package/dist/export/getCreateExportCollectionTask.js.map +1 -1
  26. package/dist/export/getExportCollection.d.ts +5 -1
  27. package/dist/export/getExportCollection.d.ts.map +1 -1
  28. package/dist/export/getExportCollection.js +20 -5
  29. package/dist/export/getExportCollection.js.map +1 -1
  30. package/dist/export/getFields.d.ts +7 -1
  31. package/dist/export/getFields.d.ts.map +1 -1
  32. package/dist/export/getFields.js +15 -3
  33. package/dist/export/getFields.js.map +1 -1
  34. package/dist/exports/rsc.d.ts +0 -1
  35. package/dist/exports/rsc.d.ts.map +1 -1
  36. package/dist/exports/rsc.js +0 -1
  37. package/dist/exports/rsc.js.map +1 -1
  38. package/dist/import/batchProcessor.d.ts.map +1 -1
  39. package/dist/import/batchProcessor.js +9 -3
  40. package/dist/import/batchProcessor.js.map +1 -1
  41. package/dist/import/getFields.d.ts +7 -3
  42. package/dist/import/getFields.d.ts.map +1 -1
  43. package/dist/import/getFields.js +12 -7
  44. package/dist/import/getFields.js.map +1 -1
  45. package/dist/import/getImportCollection.d.ts +6 -3
  46. package/dist/import/getImportCollection.d.ts.map +1 -1
  47. package/dist/import/getImportCollection.js +7 -4
  48. package/dist/import/getImportCollection.js.map +1 -1
  49. package/dist/index.d.ts +5 -0
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +2 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/utilities/getFilename.d.ts +1 -1
  54. package/dist/utilities/getFilename.js +3 -3
  55. package/dist/utilities/getFilename.js.map +1 -1
  56. package/dist/utilities/getPluginCollections.d.ts.map +1 -1
  57. package/dist/utilities/getPluginCollections.js +106 -34
  58. package/dist/utilities/getPluginCollections.js.map +1 -1
  59. package/dist/utilities/getSchemaColumns.d.ts.map +1 -1
  60. package/dist/utilities/getSchemaColumns.js +9 -56
  61. package/dist/utilities/getSchemaColumns.js.map +1 -1
  62. package/dist/utilities/getSchemaColumns.spec.js +157 -0
  63. package/dist/utilities/getSchemaColumns.spec.js.map +1 -0
  64. package/dist/utilities/parseCSV.d.ts.map +1 -1
  65. package/dist/utilities/parseCSV.js +1 -0
  66. package/dist/utilities/parseCSV.js.map +1 -1
  67. package/dist/utilities/parseCSV.spec.js +26 -0
  68. package/dist/utilities/parseCSV.spec.js.map +1 -1
  69. package/package.json +7 -7
  70. package/dist/components/ImportCollectionField/index.d.ts +0 -3
  71. package/dist/components/ImportCollectionField/index.d.ts.map +0 -1
  72. package/dist/components/ImportCollectionField/index.js +0 -17
  73. package/dist/components/ImportCollectionField/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/export/getFields.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\nimport type { Config, Field, SelectField } from 'payload'\n\nimport { getFilename } from '../utilities/getFilename.js'\nimport { validateLimitValue } from '../utilities/validateLimitValue.js'\n\ntype GetFieldsOptions = {\n /**\n * Force a specific format, hiding the format dropdown\n */\n format?: 'csv' | 'json'\n}\n\nexport const getFields = (config: Config, options?: GetFieldsOptions): Field[] => {\n const format = options?.format\n let localeField: SelectField | undefined\n if (config.localization) {\n localeField = {\n name: 'locale',\n type: 'select',\n admin: {\n width: '25%',\n },\n defaultValue: 'all',\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-locale-label'),\n options: [\n {\n label: ({ t }) => t('general:allLocales'),\n value: 'all',\n },\n ...config.localization.locales.map((locale) => ({\n label: typeof locale === 'string' ? locale : locale.label,\n value: typeof locale === 'string' ? locale : locale.code,\n })),\n ],\n }\n }\n\n return [\n {\n type: 'collapsible',\n fields: [\n {\n name: 'name',\n type: 'text',\n defaultValue: () => getFilename(),\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-name-label'),\n },\n {\n type: 'row',\n fields: [\n {\n name: 'format',\n type: 'select',\n admin: {\n readOnly: Boolean(format),\n width: '33.3333%',\n },\n defaultValue: format ?? 'csv',\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-format-label'),\n options: format\n ? [\n {\n label: format.toUpperCase(),\n value: format,\n },\n ]\n : [\n {\n label: 'CSV',\n value: 'csv',\n },\n {\n label: 'JSON',\n value: 'json',\n },\n ],\n required: true,\n },\n {\n name: 'limit',\n type: 'number',\n admin: {\n placeholder: 'No limit',\n step: 100,\n width: '33.3333%',\n },\n validate: (value: null | number | undefined, { req }: { req: { t: TFunction } }) => {\n return validateLimitValue(value, req.t) ?? true\n },\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-limit-label'),\n },\n {\n name: 'page',\n type: 'number',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#Page',\n },\n condition: ({ limit }) => {\n // Show the page field only if limit is set\n return typeof limit === 'number' && limit !== 0\n },\n width: '33.3333%',\n },\n defaultValue: 1,\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-page-label'),\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'sort',\n type: 'text',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#SortBy',\n },\n },\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-sort-label'),\n },\n {\n name: 'sortOrder',\n type: 'select',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#SortOrder',\n },\n // Only show when `sort` has a value\n condition: ({ sort }) => typeof sort === 'string' && sort.trim().length > 0,\n },\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-sort-order-label'),\n options: [\n { label: 'Ascending', value: 'asc' },\n { label: 'Descending', value: 'desc' },\n ],\n },\n ...(localeField ? [localeField] : []),\n {\n name: 'drafts',\n type: 'select',\n admin: {\n condition: (data) => {\n const collectionConfig = (config.collections ?? []).find(\n (collection) => collection.slug === data.collectionSlug,\n )\n return Boolean(\n typeof collectionConfig?.versions === 'object' &&\n collectionConfig?.versions?.drafts,\n )\n },\n width: '25%',\n },\n defaultValue: 'yes',\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-drafts-label'),\n options: [\n {\n label: ({ t }) => t('general:yes'),\n value: 'yes',\n },\n {\n label: ({ t }) => t('general:no'),\n value: 'no',\n },\n ],\n },\n // {\n // name: 'depth',\n // type: 'number',\n // // @ts-expect-error - this is not correctly typed in plugins right now\n // label: ({ t }) => t('plugin-import-export:field-depth-label'),\n // admin: {\n // width: '33%',\n // },\n // defaultValue: 1,\n // required: true,\n // },\n ],\n },\n {\n name: 'selectionToUse',\n type: 'radio',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#SelectionToUseField',\n },\n },\n options: [\n {\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:selectionToUse-currentSelection'),\n value: 'currentSelection',\n },\n {\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:selectionToUse-currentFilters'),\n value: 'currentFilters',\n },\n {\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:selectionToUse-allDocuments'),\n value: 'all',\n },\n ],\n virtual: true,\n },\n {\n name: 'fields',\n type: 'text',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#FieldsToExport',\n },\n },\n hasMany: true,\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-fields-label'),\n },\n {\n name: 'collectionSlug',\n type: 'text',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#CollectionField',\n },\n },\n required: true,\n },\n {\n name: 'where',\n type: 'json',\n admin: {\n hidden: true,\n },\n defaultValue: {},\n hooks: {\n beforeValidate: [\n ({ value }) => {\n return value ?? {}\n },\n ],\n },\n },\n ],\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:exportOptions'),\n },\n {\n name: 'preview',\n type: 'ui',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#ExportPreview',\n },\n },\n },\n ]\n}\n"],"names":["getFilename","validateLimitValue","getFields","config","options","format","localeField","localization","name","type","admin","width","defaultValue","label","t","value","locales","map","locale","code","fields","readOnly","Boolean","toUpperCase","required","placeholder","step","validate","req","components","Field","condition","limit","sort","trim","length","data","collectionConfig","collections","find","collection","slug","collectionSlug","versions","drafts","virtual","hasMany","hidden","hooks","before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NC,MAAM;oBACNC,OAAO;wBACLqC,QAAQ;oBACV;oBACAnC,cAAc,CAAC;oBACfoC,OAAO;wBACLC,gBAAgB;4BACd,CAAC,EAAElC,KAAK,EAAE;gCACR,OAAOA,SAAS,CAAC;4BACnB;yBACD;oBACH;gBACF;aACD;YACD,sEAAsE;YACtEF,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;QACtB;QACA;YACEN,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLmB,YAAY;oBACVC,OAAO;gBACT;YACF;QACF;KACD;AACH,EAAC"}
1
+ {"version":3,"sources":["../../src/export/getFields.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\nimport type { Config, Field, PayloadRequest, SelectField } from 'payload'\n\nimport { getFilename } from '../utilities/getFilename.js'\nimport { validateLimitValue } from '../utilities/validateLimitValue.js'\n\ntype GetFieldsOptions = {\n /**\n * Collection slugs that this export collection supports.\n * Used for schema/types and as the options in the select field.\n */\n collectionSlugs: string[]\n config: Config\n /**\n * Force a specific format, hiding the format dropdown\n */\n format?: 'csv' | 'json'\n}\n\nexport const getFields = (options: GetFieldsOptions): Field[] => {\n const { collectionSlugs, config, format } = options\n\n let localeField: SelectField | undefined\n\n if (config.localization) {\n localeField = {\n name: 'locale',\n type: 'select',\n admin: {\n width: '25%',\n },\n defaultValue: 'all',\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-locale-label'),\n options: [\n {\n label: ({ t }) => t('general:allLocales'),\n value: 'all',\n },\n ...config.localization.locales.map((locale) => ({\n label: typeof locale === 'string' ? locale : locale.label,\n value: typeof locale === 'string' ? locale : locale.code,\n })),\n ],\n }\n }\n\n return [\n {\n type: 'collapsible',\n fields: [\n {\n name: 'name',\n type: 'text',\n defaultValue: () => getFilename(),\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-name-label'),\n },\n {\n type: 'row',\n fields: [\n {\n name: 'format',\n type: 'select',\n admin: {\n readOnly: Boolean(format),\n width: '33.3333%',\n },\n defaultValue: format ?? 'csv',\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-format-label'),\n options: format\n ? [\n {\n label: format.toUpperCase(),\n value: format,\n },\n ]\n : [\n {\n label: 'CSV',\n value: 'csv',\n },\n {\n label: 'JSON',\n value: 'json',\n },\n ],\n required: true,\n },\n {\n name: 'limit',\n type: 'number',\n admin: {\n placeholder: 'No limit',\n step: 100,\n width: '33.3333%',\n },\n validate: (value: null | number | undefined, { req }: { req: { t: TFunction } }) => {\n return validateLimitValue(value, req.t) ?? true\n },\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-limit-label'),\n },\n {\n name: 'page',\n type: 'number',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#Page',\n },\n condition: ({ limit }) => {\n // Show the page field only if limit is set\n return typeof limit === 'number' && limit !== 0\n },\n width: '33.3333%',\n },\n defaultValue: 1,\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-page-label'),\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'sort',\n type: 'text',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#SortBy',\n },\n },\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-sort-label'),\n },\n {\n name: 'sortOrder',\n type: 'select',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#SortOrder',\n },\n // Only show when `sort` has a value\n condition: ({ sort }) => typeof sort === 'string' && sort.trim().length > 0,\n },\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-sort-order-label'),\n options: [\n { label: 'Ascending', value: 'asc' },\n { label: 'Descending', value: 'desc' },\n ],\n },\n ...(localeField ? [localeField] : []),\n {\n name: 'drafts',\n type: 'select',\n admin: {\n condition: (data) => {\n const collectionConfig = (config.collections ?? []).find(\n (collection) => collection.slug === data.collectionSlug,\n )\n return Boolean(\n typeof collectionConfig?.versions === 'object' &&\n collectionConfig?.versions?.drafts,\n )\n },\n width: '25%',\n },\n defaultValue: 'yes',\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-drafts-label'),\n options: [\n {\n label: ({ t }) => t('general:yes'),\n value: 'yes',\n },\n {\n label: ({ t }) => t('general:no'),\n value: 'no',\n },\n ],\n },\n // {\n // name: 'depth',\n // type: 'number',\n // // @ts-expect-error - this is not correctly typed in plugins right now\n // label: ({ t }) => t('plugin-import-export:field-depth-label'),\n // admin: {\n // width: '33%',\n // },\n // defaultValue: 1,\n // required: true,\n // },\n ],\n },\n {\n name: 'selectionToUse',\n type: 'radio',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#SelectionToUseField',\n },\n },\n options: [\n {\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:selectionToUse-currentSelection'),\n value: 'currentSelection',\n },\n {\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:selectionToUse-currentFilters'),\n value: 'currentFilters',\n },\n {\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:selectionToUse-allDocuments'),\n value: 'all',\n },\n ],\n virtual: true,\n },\n {\n name: 'fields',\n type: 'text',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#FieldsToExport',\n },\n },\n hasMany: true,\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-fields-label'),\n },\n {\n name: 'collectionSlug',\n type: 'text',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#CollectionField',\n },\n },\n defaultValue: collectionSlugs[0],\n required: true,\n validate: (value: null | string | undefined, { req }: { req: PayloadRequest }) => {\n if (!value) {\n return 'Collection is required'\n }\n // Validate that the collection exists\n const collectionExists = req?.payload?.collections?.[value]\n if (!collectionExists) {\n return `Collection \"${value}\" does not exist`\n }\n return true\n },\n },\n {\n name: 'where',\n type: 'json',\n admin: {\n hidden: true,\n },\n defaultValue: {},\n hooks: {\n beforeValidate: [\n ({ value }) => {\n return value ?? {}\n },\n ],\n },\n },\n ],\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:exportOptions'),\n },\n {\n name: 'preview',\n type: 'ui',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#ExportPreview',\n },\n },\n },\n ]\n}\n"],"names":["getFilename","validateLimitValue","getFields","options","collectionSlugs","config","format","localeField","localization","name","type","admin","width","defaultValue","label","t","value","locales","map","locale","code","fields","readOnly","Boolean","toUpperCase","required","placeholder","step","validate","req","components","Field","condition","limit","sort","trim","length","data","collectionConfig","collections","find","collection","slug","collectionSlug","versions","drafts","virtual","hasMany","collectionExists","payload","hidden","hooks","beforeValidate"],"mappings":"AAGA,SAASA,WAAW,QAAQ,8BAA6B;AACzD,SAASC,kBAAkB,QAAQ,qCAAoC;AAevE,OAAO,MAAMC,YAAY,CAACC;IACxB,MAAM,EAAEC,eAAe,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGH;IAE5C,IAAII;IAEJ,IAAIF,OAAOG,YAAY,EAAE;QACvBD,cAAc;YACZE,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,OAAO;YACT;YACAC,cAAc;YACd,sEAAsE;YACtEC,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;YACpBZ,SAAS;gBACP;oBACEW,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;oBACpBC,OAAO;gBACT;mBACGX,OAAOG,YAAY,CAACS,OAAO,CAACC,GAAG,CAAC,CAACC,SAAY,CAAA;wBAC9CL,OAAO,OAAOK,WAAW,WAAWA,SAASA,OAAOL,KAAK;wBACzDE,OAAO,OAAOG,WAAW,WAAWA,SAASA,OAAOC,IAAI;oBAC1D,CAA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YAAY;oBACVC,OAAO;gBACT;YACF;QACF;KACD;AACH,EAAC"}
@@ -3,7 +3,6 @@ export { ExportListMenuItem } from '../components/ExportListMenuItem/index.js';
3
3
  export { ExportPreview } from '../components/ExportPreview/index.js';
4
4
  export { ExportSaveButton } from '../components/ExportSaveButton/index.js';
5
5
  export { FieldsToExport } from '../components/FieldsToExport/index.js';
6
- export { ImportCollectionField } from '../components/ImportCollectionField/index.js';
7
6
  export { ImportExportProvider } from '../components/ImportExportProvider/index.js';
8
7
  export { ImportListMenuItem } from '../components/ImportListMenuItem/index.js';
9
8
  export { ImportPreview } from '../components/ImportPreview/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../src/exports/rsc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAA;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAA;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAA;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAA;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA"}
1
+ {"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../src/exports/rsc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAA;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAA;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAA;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA"}
@@ -3,7 +3,6 @@ export { ExportListMenuItem } from '../components/ExportListMenuItem/index.js';
3
3
  export { ExportPreview } from '../components/ExportPreview/index.js';
4
4
  export { ExportSaveButton } from '../components/ExportSaveButton/index.js';
5
5
  export { FieldsToExport } from '../components/FieldsToExport/index.js';
6
- export { ImportCollectionField } from '../components/ImportCollectionField/index.js';
7
6
  export { ImportExportProvider } from '../components/ImportExportProvider/index.js';
8
7
  export { ImportListMenuItem } from '../components/ImportListMenuItem/index.js';
9
8
  export { ImportPreview } from '../components/ImportPreview/index.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/rsc.ts"],"sourcesContent":["export { CollectionField } from '../components/CollectionField/index.js'\nexport { ExportListMenuItem } from '../components/ExportListMenuItem/index.js'\nexport { ExportPreview } from '../components/ExportPreview/index.js'\nexport { ExportSaveButton } from '../components/ExportSaveButton/index.js'\nexport { FieldsToExport } from '../components/FieldsToExport/index.js'\nexport { ImportCollectionField } from '../components/ImportCollectionField/index.js'\nexport { ImportExportProvider } from '../components/ImportExportProvider/index.js'\nexport { ImportListMenuItem } from '../components/ImportListMenuItem/index.js'\nexport { ImportPreview } from '../components/ImportPreview/index.js'\nexport { ImportSaveButton } from '../components/ImportSaveButton/index.js'\nexport { Page } from '../components/Page/index.js'\nexport { SelectionToUseField } from '../components/SelectionToUseField/index.js'\nexport { SortBy } from '../components/SortBy/index.js'\nexport { SortOrder } from '../components/SortOrder/index.js'\n"],"names":["CollectionField","ExportListMenuItem","ExportPreview","ExportSaveButton","FieldsToExport","ImportCollectionField","ImportExportProvider","ImportListMenuItem","ImportPreview","ImportSaveButton","Page","SelectionToUseField","SortBy","SortOrder"],"mappings":"AAAA,SAASA,eAAe,QAAQ,yCAAwC;AACxE,SAASC,kBAAkB,QAAQ,4CAA2C;AAC9E,SAASC,aAAa,QAAQ,uCAAsC;AACpE,SAASC,gBAAgB,QAAQ,0CAAyC;AAC1E,SAASC,cAAc,QAAQ,wCAAuC;AACtE,SAASC,qBAAqB,QAAQ,+CAA8C;AACpF,SAASC,oBAAoB,QAAQ,8CAA6C;AAClF,SAASC,kBAAkB,QAAQ,4CAA2C;AAC9E,SAASC,aAAa,QAAQ,uCAAsC;AACpE,SAASC,gBAAgB,QAAQ,0CAAyC;AAC1E,SAASC,IAAI,QAAQ,8BAA6B;AAClD,SAASC,mBAAmB,QAAQ,6CAA4C;AAChF,SAASC,MAAM,QAAQ,gCAA+B;AACtD,SAASC,SAAS,QAAQ,mCAAkC"}
1
+ {"version":3,"sources":["../../src/exports/rsc.ts"],"sourcesContent":["export { CollectionField } from '../components/CollectionField/index.js'\nexport { ExportListMenuItem } from '../components/ExportListMenuItem/index.js'\nexport { ExportPreview } from '../components/ExportPreview/index.js'\nexport { ExportSaveButton } from '../components/ExportSaveButton/index.js'\nexport { FieldsToExport } from '../components/FieldsToExport/index.js'\nexport { ImportExportProvider } from '../components/ImportExportProvider/index.js'\nexport { ImportListMenuItem } from '../components/ImportListMenuItem/index.js'\nexport { ImportPreview } from '../components/ImportPreview/index.js'\nexport { ImportSaveButton } from '../components/ImportSaveButton/index.js'\nexport { Page } from '../components/Page/index.js'\nexport { SelectionToUseField } from '../components/SelectionToUseField/index.js'\nexport { SortBy } from '../components/SortBy/index.js'\nexport { SortOrder } from '../components/SortOrder/index.js'\n"],"names":["CollectionField","ExportListMenuItem","ExportPreview","ExportSaveButton","FieldsToExport","ImportExportProvider","ImportListMenuItem","ImportPreview","ImportSaveButton","Page","SelectionToUseField","SortBy","SortOrder"],"mappings":"AAAA,SAASA,eAAe,QAAQ,yCAAwC;AACxE,SAASC,kBAAkB,QAAQ,4CAA2C;AAC9E,SAASC,aAAa,QAAQ,uCAAsC;AACpE,SAASC,gBAAgB,QAAQ,0CAAyC;AAC1E,SAASC,cAAc,QAAQ,wCAAuC;AACtE,SAASC,oBAAoB,QAAQ,8CAA6C;AAClF,SAASC,kBAAkB,QAAQ,4CAA2C;AAC9E,SAASC,aAAa,QAAQ,uCAAsC;AACpE,SAASC,gBAAgB,QAAQ,0CAAyC;AAC1E,SAASC,IAAI,QAAQ,8BAA6B;AAClD,SAASC,mBAAmB,QAAQ,6CAA4C;AAChF,SAASC,MAAM,QAAQ,gCAA+B;AACtD,SAASC,SAAS,QAAQ,mCAAkC"}
@@ -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;AAExD,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,SA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,8 +70,10 @@ import { categorizeError, createBatches, extractErrorMessage } from '../utilitie
70
70
  failed: [],
71
71
  successful: []
72
72
  };
73
- const collectionConfig = req.payload.collections[collectionSlug]?.config;
73
+ const collectionEntry = req.payload.collections[collectionSlug];
74
+ const collectionConfig = collectionEntry?.config;
74
75
  const collectionHasVersions = Boolean(collectionConfig?.versions);
76
+ const hasCustomIdField = Boolean(collectionEntry?.customIDType);
75
77
  const configuredLocales = req.payload.config.localization ? req.payload.config.localization.localeCodes : undefined;
76
78
  const startingRowNumber = batchIndex * options.batchSize;
77
79
  for(let i = 0; i < batch.length; i++){
@@ -87,7 +89,9 @@ import { categorizeError, createBatches, extractErrorMessage } from '../utilitie
87
89
  const createData = {
88
90
  ...document
89
91
  };
90
- delete createData.id;
92
+ if (!hasCustomIdField) {
93
+ delete createData.id;
94
+ }
91
95
  let draftOption;
92
96
  if (collectionHasVersions) {
93
97
  const statusValue = createData._status || options.defaultVersionStatus;
@@ -342,7 +346,9 @@ import { categorizeError, createBatches, extractErrorMessage } from '../utilitie
342
346
  const createData = {
343
347
  ...document
344
348
  };
345
- delete createData.id;
349
+ if (!hasCustomIdField) {
350
+ delete createData.id;
351
+ }
346
352
  // Only handle _status for versioned collections
347
353
  let draftOption;
348
354
  if (collectionHasVersions) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/import/batchProcessor.ts"],"sourcesContent":["import type { PayloadRequest, TypedUser } from 'payload'\n\nimport type { ImportMode, ImportResult } from './createImport.js'\n\nimport {\n type BatchError,\n categorizeError,\n createBatches,\n extractErrorMessage,\n} from '../utilities/useBatchProcessor.js'\n\n/**\n * Import-specific batch processor options\n */\nexport interface ImportBatchProcessorOptions {\n batchSize?: number\n defaultVersionStatus?: 'draft' | 'published'\n}\n\n/**\n * Import-specific error type extending the generic BatchError\n */\nexport interface ImportError extends BatchError<Record<string, unknown>> {\n documentData: Record<string, unknown>\n field?: string\n fieldLabel?: string\n rowNumber: number // 1-indexed for user clarity\n}\n\n/**\n * Result from processing a single import batch\n */\nexport interface ImportBatchResult {\n failed: Array<ImportError>\n successful: Array<{\n document: Record<string, unknown>\n index: number\n operation?: 'created' | 'updated'\n result: Record<string, unknown>\n }>\n}\n\n/**\n * Options for processing an import operation\n */\nexport interface ImportProcessOptions {\n collectionSlug: string\n documents: Record<string, unknown>[]\n importMode: ImportMode\n matchField?: string\n req: PayloadRequest\n user?: TypedUser\n}\n\n/**\n * Separates multi-locale data from a document for sequential locale updates.\n *\n * When a field has locale-keyed values (e.g., { title: { en: 'Hello', es: 'Hola' } }),\n * this extracts the first locale's data for initial create/update, and stores\n * remaining locales for subsequent update calls.\n *\n * @returns\n * - flatData: Document with first locale values extracted (for initial operation)\n * - hasMultiLocale: Whether any multi-locale fields were found\n * - localeUpdates: Map of locale -> field data for follow-up updates\n */\nfunction extractMultiLocaleData(\n data: Record<string, unknown>,\n configuredLocales?: string[],\n): {\n flatData: Record<string, unknown>\n hasMultiLocale: boolean\n localeUpdates: Record<string, Record<string, unknown>>\n} {\n const flatData: Record<string, unknown> = {}\n const localeUpdates: Record<string, Record<string, unknown>> = {}\n let hasMultiLocale = false\n\n if (!configuredLocales || configuredLocales.length === 0) {\n return { flatData: { ...data }, hasMultiLocale: false, localeUpdates: {} }\n }\n\n const localeSet = new Set(configuredLocales)\n\n for (const [key, value] of Object.entries(data)) {\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const valueObj = value as Record<string, unknown>\n const localeKeys = Object.keys(valueObj).filter((k) => localeSet.has(k))\n\n if (localeKeys.length > 0) {\n hasMultiLocale = true\n const firstLocale = localeKeys[0]\n if (firstLocale) {\n flatData[key] = valueObj[firstLocale]\n for (const locale of localeKeys) {\n if (locale !== firstLocale) {\n if (!localeUpdates[locale]) {\n localeUpdates[locale] = {}\n }\n localeUpdates[locale][key] = valueObj[locale]\n }\n }\n }\n } else {\n flatData[key] = value\n }\n } else {\n flatData[key] = value\n }\n }\n\n return { flatData, hasMultiLocale, localeUpdates }\n}\n\ntype ProcessImportBatchOptions = {\n batch: Record<string, unknown>[]\n batchIndex: number\n collectionSlug: string\n importMode: ImportMode\n matchField: string | undefined\n options: { batchSize: number; defaultVersionStatus: 'draft' | 'published' }\n req: PayloadRequest\n user?: TypedUser\n}\n\n/**\n * Processes a batch of documents for import based on the import mode.\n *\n * For each document in the batch:\n * - create: Creates a new document (removes any existing ID)\n * - update: Finds existing document by matchField and updates it\n * - upsert: Updates if found, creates if not found\n *\n * Handles versioned collections, multi-locale data, and MongoDB ObjectID validation.\n * Continues processing remaining documents even if individual imports fail.\n */\nasync function processImportBatch({\n batch,\n batchIndex,\n collectionSlug,\n importMode,\n matchField,\n options,\n req,\n user,\n}: ProcessImportBatchOptions): Promise<ImportBatchResult> {\n const result: ImportBatchResult = {\n failed: [],\n successful: [],\n }\n\n const collectionConfig = req.payload.collections[collectionSlug]?.config\n const collectionHasVersions = Boolean(collectionConfig?.versions)\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 delete createData.id\n\n let draftOption: boolean | undefined\n if (collectionHasVersions) {\n const statusValue = createData._status || options.defaultVersionStatus\n const isPublished = statusValue !== 'draft'\n draftOption = !isPublished\n\n if (req.payload.config.debug) {\n req.payload.logger.info({\n _status: createData._status,\n isPublished,\n msg: 'Status handling in create',\n willSetDraft: draftOption,\n })\n }\n\n // Remove _status from data - it's controlled via draft option\n delete createData._status\n }\n\n if (req.payload.config.debug && 'title' in createData) {\n req.payload.logger.info({\n msg: 'Creating document',\n title: createData.title,\n titleIsNull: createData.title === null,\n titleType: typeof createData.title,\n })\n }\n\n // Check if we have multi-locale data and extract it\n const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(\n createData,\n configuredLocales,\n )\n\n if (hasMultiLocale) {\n // Create with default locale data\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: flatData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n\n // Update for other locales\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n const localeReq = { ...req, locale }\n await req.payload.update({\n id: savedDocument.id as number | string,\n collection: collectionSlug,\n data: localeData,\n draft: collectionHasVersions ? false : undefined,\n overrideAccess: false,\n req: localeReq,\n user,\n })\n } catch (error) {\n // Log but don't fail the entire import if a locale update fails\n req.payload.logger.error({\n err: error,\n msg: `Failed to update locale ${locale} for document ${String(savedDocument.id)}`,\n })\n }\n }\n }\n } else {\n // No multi-locale data, create normally\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: createData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n }\n } else if (importMode === 'update' || importMode === 'upsert') {\n const matchValue = document[matchField || 'id']\n if (!matchValue) {\n throw new Error(`Match field \"${matchField || 'id'}\" not found in document`)\n }\n\n // Special handling for ID field with MongoDB\n // If matching by 'id' and it's not a valid ObjectID format, handle specially\n const isMatchingById = (matchField || 'id') === 'id'\n\n // Check if it's a valid MongoDB ObjectID format (24 hex chars)\n // Note: matchValue could be string, number, or ObjectID object\n let matchValueStr: string\n if (typeof matchValue === 'object' && matchValue !== null) {\n matchValueStr = JSON.stringify(matchValue)\n } else if (typeof matchValue === 'string') {\n matchValueStr = matchValue\n } else if (typeof matchValue === 'number') {\n matchValueStr = matchValue.toString()\n } else {\n // For other types, use JSON.stringify\n matchValueStr = JSON.stringify(matchValue)\n }\n const isValidObjectIdFormat = /^[0-9a-f]{24}$/i.test(matchValueStr)\n\n try {\n existingDocResult = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: 1,\n overrideAccess: false,\n req,\n user,\n where: {\n [matchField || 'id']: {\n equals: matchValue,\n },\n },\n })\n } catch (error) {\n // MongoDB may throw for invalid ObjectID format - handle gracefully for upsert\n if (isMatchingById && importMode === 'upsert' && !isValidObjectIdFormat) {\n existingDocResult = { docs: [] }\n } else if (isMatchingById && importMode === 'update' && !isValidObjectIdFormat) {\n throw new Error(`Invalid ID format for update: ${matchValueStr}`)\n } else {\n throw error\n }\n }\n\n if (existingDocResult.docs.length > 0) {\n const existingDoc = existingDocResult.docs[0]\n if (!existingDoc) {\n throw new Error(`Document not found`)\n }\n\n // Debug: log what we found\n if (req.payload.config.debug) {\n req.payload.logger.info({\n existingId: existingDoc.id,\n existingStatus: existingDoc._status,\n existingTitle: existingDoc.title,\n incomingDocument: document,\n mode: importMode,\n msg: 'Found existing document for update',\n })\n }\n\n const updateData = { ...document }\n // Remove ID and internal fields from update data\n delete updateData.id\n delete updateData._id\n delete updateData.createdAt\n delete updateData.updatedAt\n\n // Check if we have multi-locale data and extract it\n const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(\n updateData,\n configuredLocales,\n )\n\n if (req.payload.config.debug) {\n req.payload.logger.info({\n existingId: existingDoc.id,\n hasMultiLocale,\n mode: importMode,\n msg: 'Updating document in upsert/update mode',\n updateData: Object.keys(hasMultiLocale ? flatData : updateData).reduce(\n (acc, key) => {\n const val = (hasMultiLocale ? flatData : updateData)[key]\n acc[key] =\n typeof val === 'string' && val.length > 50 ? val.substring(0, 50) + '...' : val\n return acc\n },\n {} as Record<string, unknown>,\n ),\n })\n }\n\n if (hasMultiLocale) {\n // Update with default locale data\n savedDocument = await req.payload.update({\n id: existingDoc.id as number | string,\n collection: collectionSlug,\n data: flatData,\n depth: 0,\n // Don't specify draft - this creates a new draft for versioned collections\n overrideAccess: false,\n req,\n user,\n })\n\n // Update for other locales\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n // Clone the request with the specific locale\n const localeReq = { ...req, locale }\n await req.payload.update({\n id: existingDoc.id as number | string,\n collection: collectionSlug,\n data: localeData,\n depth: 0,\n // Don't specify draft - this creates a new draft for versioned collections\n overrideAccess: false,\n req: localeReq,\n user,\n })\n } catch (error) {\n // Log but don't fail the entire import if a locale update fails\n req.payload.logger.error({\n err: error,\n msg: `Failed to update locale ${locale} for document ${String(existingDoc.id)}`,\n })\n }\n }\n }\n } else {\n // No multi-locale data, update normally\n try {\n // Extra debug: log before update\n if (req.payload.config.debug) {\n req.payload.logger.info({\n existingId: existingDoc.id,\n existingTitle: existingDoc.title,\n msg: 'About to update document',\n newData: updateData,\n })\n }\n\n // Update the document - don't specify draft to let Payload handle versions properly\n // This will create a new draft version for collections with versions enabled\n savedDocument = await req.payload.update({\n id: existingDoc.id as number | string,\n collection: collectionSlug,\n data: updateData,\n depth: 0,\n // Don't specify draft - this creates a new draft for versioned collections\n overrideAccess: false,\n req,\n user,\n })\n\n if (req.payload.config.debug && savedDocument) {\n req.payload.logger.info({\n id: savedDocument.id,\n msg: 'Update completed',\n status: savedDocument._status,\n title: savedDocument.title,\n })\n }\n } catch (updateError) {\n req.payload.logger.error({\n id: existingDoc.id,\n err: updateError,\n msg: 'Update failed',\n })\n throw updateError\n }\n }\n } else if (importMode === 'upsert') {\n // Create new in upsert mode\n if (req.payload.config.debug) {\n req.payload.logger.info({\n document,\n matchField: matchField || 'id',\n matchValue: document[matchField || 'id'],\n msg: 'No existing document found, creating new in upsert mode',\n })\n }\n\n const createData = { ...document }\n delete createData.id\n\n // Only handle _status for versioned collections\n let draftOption: boolean | undefined\n if (collectionHasVersions) {\n // Use defaultVersionStatus from config if _status not provided\n const statusValue = createData._status || options.defaultVersionStatus\n const isPublished = statusValue !== 'draft'\n draftOption = !isPublished\n // Remove _status from data - it's controlled via draft option\n delete createData._status\n }\n\n // Check if we have multi-locale data and extract it\n const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(\n createData,\n configuredLocales,\n )\n\n if (hasMultiLocale) {\n // Create with default locale data\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: flatData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n\n // Update for other locales\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n // Clone the request with the specific locale\n const localeReq = { ...req, locale }\n await req.payload.update({\n id: savedDocument.id as number | string,\n collection: collectionSlug,\n data: localeData,\n draft: collectionHasVersions ? false : undefined,\n overrideAccess: false,\n req: localeReq,\n })\n } catch (error) {\n // Log but don't fail the entire import if a locale update fails\n req.payload.logger.error({\n err: error,\n msg: `Failed to update locale ${locale} for document ${String(savedDocument.id)}`,\n })\n }\n }\n }\n } else {\n // No multi-locale data, create normally\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: createData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n }\n } else {\n // Update mode but document not found\n let matchValueDisplay: string\n if (typeof matchValue === 'object' && matchValue !== null) {\n matchValueDisplay = JSON.stringify(matchValue)\n } else if (typeof matchValue === 'string') {\n matchValueDisplay = matchValue\n } else if (typeof matchValue === 'number') {\n matchValueDisplay = matchValue.toString()\n } else {\n // For other types, use JSON.stringify to avoid [object Object]\n matchValueDisplay = JSON.stringify(matchValue)\n }\n throw new Error(`Document with ${matchField || 'id'}=\"${matchValueDisplay}\" not found`)\n }\n } else {\n throw new Error(`Unknown import mode: ${String(importMode)}`)\n }\n\n if (savedDocument) {\n // Determine operation type for proper counting\n let operation: 'created' | 'updated' | undefined\n if (importMode === 'create') {\n operation = 'created'\n } else if (importMode === 'update') {\n operation = 'updated'\n } else if (importMode === 'upsert') {\n if (existingDocResult && existingDocResult.docs.length > 0) {\n operation = 'updated'\n } else {\n operation = 'created'\n }\n }\n\n result.successful.push({\n document,\n index: rowNumber - 1, // Store as 0-indexed\n operation,\n result: savedDocument,\n })\n }\n } catch (error) {\n const importError: ImportError = {\n type: categorizeError(error),\n documentData: document || {},\n error: extractErrorMessage(error),\n item: document || {},\n itemIndex: rowNumber - 1,\n rowNumber,\n }\n\n // Try to extract field information from validation errors\n if (error && typeof error === 'object' && 'data' in error) {\n const errorData = error as { data?: { errors?: Array<{ path?: string }> } }\n if (errorData.data?.errors && Array.isArray(errorData.data.errors)) {\n const firstError = errorData.data.errors[0]\n if (firstError?.path) {\n importError.field = firstError.path\n }\n }\n }\n\n result.failed.push(importError)\n // Always continue processing all rows\n }\n }\n\n return result\n}\n\nexport function createImportBatchProcessor(options: ImportBatchProcessorOptions = {}) {\n const processorOptions = {\n batchSize: options.batchSize ?? 100,\n defaultVersionStatus: options.defaultVersionStatus ?? 'published',\n }\n\n const processImport = async (processOptions: ImportProcessOptions): Promise<ImportResult> => {\n const { collectionSlug, documents, importMode, matchField, req, user } = processOptions\n const batches = createBatches(documents, processorOptions.batchSize)\n\n const result: ImportResult = {\n errors: [],\n imported: 0,\n total: documents.length,\n updated: 0,\n }\n\n for (let i = 0; i < batches.length; i++) {\n const currentBatch = batches[i]\n if (!currentBatch) {\n continue\n }\n\n const batchResult = await processImportBatch({\n batch: currentBatch,\n batchIndex: i,\n collectionSlug,\n importMode,\n matchField,\n options: processorOptions,\n req,\n user,\n })\n\n // Update results\n for (const success of batchResult.successful) {\n if (success.operation === 'created') {\n result.imported++\n } else if (success.operation === 'updated') {\n result.updated++\n } else {\n // Fallback\n if (importMode === 'create') {\n result.imported++\n } else {\n result.updated++\n }\n }\n }\n\n for (const error of batchResult.failed) {\n result.errors.push({\n doc: error.documentData,\n error: error.error,\n index: error.rowNumber - 1, // Convert back to 0-indexed\n })\n }\n }\n\n return result\n }\n\n return {\n processImport,\n }\n}\n"],"names":["categorizeError","createBatches","extractErrorMessage","extractMultiLocaleData","data","configuredLocales","flatData","localeUpdates","hasMultiLocale","length","localeSet","Set","key","value","Object","entries","Array","isArray","valueObj","localeKeys","keys","filter","k","has","firstLocale","locale","processImportBatch","batch","batchIndex","collectionSlug","importMode","matchField","options","req","user","result","failed","successful","collectionConfig","payload","collections","config","collectionHasVersions","Boolean","versions","localization","localeCodes","undefined","startingRowNumber","batchSize","i","document","rowNumber","savedDocument","existingDocResult","createData","id","draftOption","statusValue","_status","defaultVersionStatus","isPublished","debug","logger","info","msg","willSetDraft","title","titleIsNull","titleType","create","collection","draft","overrideAccess","localeData","localeReq","update","error","err","String","matchValue","Error","isMatchingById","matchValueStr","JSON","stringify","toString","isValidObjectIdFormat","test","find","depth","limit","where","equals","docs","existingDoc","existingId","existingStatus","existingTitle","incomingDocument","mode","updateData","_id","createdAt","updatedAt","reduce","acc","val","substring","newData","status","updateError","matchValueDisplay","operation","push","index","importError","type","documentData","item","itemIndex","errorData","errors","firstError","path","field","createImportBatchProcessor","processorOptions","processImport","processOptions","documents","batches","imported","total","updated","currentBatch","batchResult","success","doc"],"mappings":"AAIA,SAEEA,eAAe,EACfC,aAAa,EACbC,mBAAmB,QACd,oCAAmC;AA6C1C;;;;;;;;;;;CAWC,GACD,SAASC,uBACPC,IAA6B,EAC7BC,iBAA4B;IAM5B,MAAMC,WAAoC,CAAC;IAC3C,MAAMC,gBAAyD,CAAC;IAChE,IAAIC,iBAAiB;IAErB,IAAI,CAACH,qBAAqBA,kBAAkBI,MAAM,KAAK,GAAG;QACxD,OAAO;YAAEH,UAAU;gBAAE,GAAGF,IAAI;YAAC;YAAGI,gBAAgB;YAAOD,eAAe,CAAC;QAAE;IAC3E;IAEA,MAAMG,YAAY,IAAIC,IAAIN;IAE1B,KAAK,MAAM,CAACO,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACX,MAAO;QAC/C,IAAIS,SAAS,OAAOA,UAAU,YAAY,CAACG,MAAMC,OAAO,CAACJ,QAAQ;YAC/D,MAAMK,WAAWL;YACjB,MAAMM,aAAaL,OAAOM,IAAI,CAACF,UAAUG,MAAM,CAAC,CAACC,IAAMZ,UAAUa,GAAG,CAACD;YAErE,IAAIH,WAAWV,MAAM,GAAG,GAAG;gBACzBD,iBAAiB;gBACjB,MAAMgB,cAAcL,UAAU,CAAC,EAAE;gBACjC,IAAIK,aA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,IAAI,GAAGA,IAAIiF,QAAQ1H,MAAM,EAAEyC,IAAK;YACvC,MAAMqF,eAAeJ,OAAO,CAACjF,EAAE;YAC/B,IAAI,CAACqF,cAAc;gBACjB;YACF;YAEA,MAAMC,cAAc,MAAM9G,mBAAmB;gBAC3CC,OAAO4G;gBACP3G,YAAYsB;gBACZrB;gBACAC;gBACAC;gBACAC,SAAS+F;gBACT9F;gBACAC;YACF;YAEA,iBAAiB;YACjB,KAAK,MAAMuG,WAAWD,YAAYnG,UAAU,CAAE;gBAC5C,IAAIoG,QAAQxB,SAAS,KAAK,WAAW;oBACnC9E,OAAOiG,QAAQ;gBACjB,OAAO,IAAIK,QAAQxB,SAAS,KAAK,WAAW;oBAC1C9E,OAAOmG,OAAO;gBAChB,OAAO;oBACL,WAAW;oBACX,IAAIxG,eAAe,UAAU;wBAC3BK,OAAOiG,QAAQ;oBACjB,OAAO;wBACLjG,OAAOmG,OAAO;oBAChB;gBACF;YACF;YAEA,KAAK,MAAMzD,SAAS2D,YAAYpG,MAAM,CAAE;gBACtCD,OAAOuF,MAAM,CAACR,IAAI,CAAC;oBACjBwB,KAAK7D,MAAMyC,YAAY;oBACvBzC,OAAOA,MAAMA,KAAK;oBAClBsC,OAAOtC,MAAMzB,SAAS,GAAG;gBAC3B;YACF;QACF;QAEA,OAAOjB;IACT;IAEA,OAAO;QACL6F;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/import/batchProcessor.ts"],"sourcesContent":["import type { PayloadRequest, TypedUser } from 'payload'\n\nimport type { ImportMode, ImportResult } from './createImport.js'\n\nimport {\n type BatchError,\n categorizeError,\n createBatches,\n extractErrorMessage,\n} from '../utilities/useBatchProcessor.js'\n\n/**\n * Import-specific batch processor options\n */\nexport interface ImportBatchProcessorOptions {\n batchSize?: number\n defaultVersionStatus?: 'draft' | 'published'\n}\n\n/**\n * Import-specific error type extending the generic BatchError\n */\nexport interface ImportError extends BatchError<Record<string, unknown>> {\n documentData: Record<string, unknown>\n field?: string\n fieldLabel?: string\n rowNumber: number // 1-indexed for user clarity\n}\n\n/**\n * Result from processing a single import batch\n */\nexport interface ImportBatchResult {\n failed: Array<ImportError>\n successful: Array<{\n document: Record<string, unknown>\n index: number\n operation?: 'created' | 'updated'\n result: Record<string, unknown>\n }>\n}\n\n/**\n * Options for processing an import operation\n */\nexport interface ImportProcessOptions {\n collectionSlug: string\n documents: Record<string, unknown>[]\n importMode: ImportMode\n matchField?: string\n req: PayloadRequest\n user?: TypedUser\n}\n\n/**\n * Separates multi-locale data from a document for sequential locale updates.\n *\n * When a field has locale-keyed values (e.g., { title: { en: 'Hello', es: 'Hola' } }),\n * this extracts the first locale's data for initial create/update, and stores\n * remaining locales for subsequent update calls.\n *\n * @returns\n * - flatData: Document with first locale values extracted (for initial operation)\n * - hasMultiLocale: Whether any multi-locale fields were found\n * - localeUpdates: Map of locale -> field data for follow-up updates\n */\nfunction extractMultiLocaleData(\n data: Record<string, unknown>,\n configuredLocales?: string[],\n): {\n flatData: Record<string, unknown>\n hasMultiLocale: boolean\n localeUpdates: Record<string, Record<string, unknown>>\n} {\n const flatData: Record<string, unknown> = {}\n const localeUpdates: Record<string, Record<string, unknown>> = {}\n let hasMultiLocale = false\n\n if (!configuredLocales || configuredLocales.length === 0) {\n return { flatData: { ...data }, hasMultiLocale: false, localeUpdates: {} }\n }\n\n const localeSet = new Set(configuredLocales)\n\n for (const [key, value] of Object.entries(data)) {\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const valueObj = value as Record<string, unknown>\n const localeKeys = Object.keys(valueObj).filter((k) => localeSet.has(k))\n\n if (localeKeys.length > 0) {\n hasMultiLocale = true\n const firstLocale = localeKeys[0]\n if (firstLocale) {\n flatData[key] = valueObj[firstLocale]\n for (const locale of localeKeys) {\n if (locale !== firstLocale) {\n if (!localeUpdates[locale]) {\n localeUpdates[locale] = {}\n }\n localeUpdates[locale][key] = valueObj[locale]\n }\n }\n }\n } else {\n flatData[key] = value\n }\n } else {\n flatData[key] = value\n }\n }\n\n return { flatData, hasMultiLocale, localeUpdates }\n}\n\ntype ProcessImportBatchOptions = {\n batch: Record<string, unknown>[]\n batchIndex: number\n collectionSlug: string\n importMode: ImportMode\n matchField: string | undefined\n options: { batchSize: number; defaultVersionStatus: 'draft' | 'published' }\n req: PayloadRequest\n user?: TypedUser\n}\n\n/**\n * Processes a batch of documents for import based on the import mode.\n *\n * For each document in the batch:\n * - create: Creates a new document (removes any existing ID)\n * - update: Finds existing document by matchField and updates it\n * - upsert: Updates if found, creates if not found\n *\n * Handles versioned collections, multi-locale data, and MongoDB ObjectID validation.\n * Continues processing remaining documents even if individual imports fail.\n */\nasync function processImportBatch({\n batch,\n batchIndex,\n collectionSlug,\n importMode,\n matchField,\n options,\n req,\n user,\n}: ProcessImportBatchOptions): Promise<ImportBatchResult> {\n const result: ImportBatchResult = {\n failed: [],\n successful: [],\n }\n\n const collectionEntry = req.payload.collections[collectionSlug]\n\n const collectionConfig = collectionEntry?.config\n const collectionHasVersions = Boolean(collectionConfig?.versions)\n const hasCustomIdField = Boolean(collectionEntry?.customIDType)\n\n const configuredLocales = req.payload.config.localization\n ? req.payload.config.localization.localeCodes\n : undefined\n\n const startingRowNumber = batchIndex * options.batchSize\n\n for (let i = 0; i < batch.length; i++) {\n const document = batch[i]\n if (!document) {\n continue\n }\n const rowNumber = startingRowNumber + i + 1\n\n try {\n let savedDocument: Record<string, unknown> | undefined\n let existingDocResult: { docs: Array<Record<string, unknown>> } | undefined\n\n if (importMode === 'create') {\n const createData = { ...document }\n if (!hasCustomIdField) {\n delete createData.id\n }\n\n let draftOption: boolean | undefined\n if (collectionHasVersions) {\n const statusValue = createData._status || options.defaultVersionStatus\n const isPublished = statusValue !== 'draft'\n draftOption = !isPublished\n\n if (req.payload.config.debug) {\n req.payload.logger.info({\n _status: createData._status,\n isPublished,\n msg: 'Status handling in create',\n willSetDraft: draftOption,\n })\n }\n\n // Remove _status from data - it's controlled via draft option\n delete createData._status\n }\n\n if (req.payload.config.debug && 'title' in createData) {\n req.payload.logger.info({\n msg: 'Creating document',\n title: createData.title,\n titleIsNull: createData.title === null,\n titleType: typeof createData.title,\n })\n }\n\n // Check if we have multi-locale data and extract it\n const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(\n createData,\n configuredLocales,\n )\n\n if (hasMultiLocale) {\n // Create with default locale data\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: flatData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n\n // Update for other locales\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n const localeReq = { ...req, locale }\n await req.payload.update({\n id: savedDocument.id as number | string,\n collection: collectionSlug,\n data: localeData,\n draft: collectionHasVersions ? false : undefined,\n overrideAccess: false,\n req: localeReq,\n user,\n })\n } catch (error) {\n // Log but don't fail the entire import if a locale update fails\n req.payload.logger.error({\n err: error,\n msg: `Failed to update locale ${locale} for document ${String(savedDocument.id)}`,\n })\n }\n }\n }\n } else {\n // No multi-locale data, create normally\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: createData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n }\n } else if (importMode === 'update' || importMode === 'upsert') {\n const matchValue = document[matchField || 'id']\n if (!matchValue) {\n throw new Error(`Match field \"${matchField || 'id'}\" not found in document`)\n }\n\n // Special handling for ID field with MongoDB\n // If matching by 'id' and it's not a valid ObjectID format, handle specially\n const isMatchingById = (matchField || 'id') === 'id'\n\n // Check if it's a valid MongoDB ObjectID format (24 hex chars)\n // Note: matchValue could be string, number, or ObjectID object\n let matchValueStr: string\n if (typeof matchValue === 'object' && matchValue !== null) {\n matchValueStr = JSON.stringify(matchValue)\n } else if (typeof matchValue === 'string') {\n matchValueStr = matchValue\n } else if (typeof matchValue === 'number') {\n matchValueStr = matchValue.toString()\n } else {\n // For other types, use JSON.stringify\n matchValueStr = JSON.stringify(matchValue)\n }\n const isValidObjectIdFormat = /^[0-9a-f]{24}$/i.test(matchValueStr)\n\n try {\n existingDocResult = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: 1,\n overrideAccess: false,\n req,\n user,\n where: {\n [matchField || 'id']: {\n equals: matchValue,\n },\n },\n })\n } catch (error) {\n // MongoDB may throw for invalid ObjectID format - handle gracefully for upsert\n if (isMatchingById && importMode === 'upsert' && !isValidObjectIdFormat) {\n existingDocResult = { docs: [] }\n } else if (isMatchingById && importMode === 'update' && !isValidObjectIdFormat) {\n throw new Error(`Invalid ID format for update: ${matchValueStr}`)\n } else {\n throw error\n }\n }\n\n if (existingDocResult.docs.length > 0) {\n const existingDoc = existingDocResult.docs[0]\n if (!existingDoc) {\n throw new Error(`Document not found`)\n }\n\n // Debug: log what we found\n if (req.payload.config.debug) {\n req.payload.logger.info({\n existingId: existingDoc.id,\n existingStatus: existingDoc._status,\n existingTitle: existingDoc.title,\n incomingDocument: document,\n mode: importMode,\n msg: 'Found existing document for update',\n })\n }\n\n const updateData = { ...document }\n // Remove ID and internal fields from update data\n delete updateData.id\n delete updateData._id\n delete updateData.createdAt\n delete updateData.updatedAt\n\n // Check if we have multi-locale data and extract it\n const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(\n updateData,\n configuredLocales,\n )\n\n if (req.payload.config.debug) {\n req.payload.logger.info({\n existingId: existingDoc.id,\n hasMultiLocale,\n mode: importMode,\n msg: 'Updating document in upsert/update mode',\n updateData: Object.keys(hasMultiLocale ? flatData : updateData).reduce(\n (acc, key) => {\n const val = (hasMultiLocale ? flatData : updateData)[key]\n acc[key] =\n typeof val === 'string' && val.length > 50 ? val.substring(0, 50) + '...' : val\n return acc\n },\n {} as Record<string, unknown>,\n ),\n })\n }\n\n if (hasMultiLocale) {\n // Update with default locale data\n savedDocument = await req.payload.update({\n id: existingDoc.id as number | string,\n collection: collectionSlug,\n data: flatData,\n depth: 0,\n // Don't specify draft - this creates a new draft for versioned collections\n overrideAccess: false,\n req,\n user,\n })\n\n // Update for other locales\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n // Clone the request with the specific locale\n const localeReq = { ...req, locale }\n await req.payload.update({\n id: existingDoc.id as number | string,\n collection: collectionSlug,\n data: localeData,\n depth: 0,\n // Don't specify draft - this creates a new draft for versioned collections\n overrideAccess: false,\n req: localeReq,\n user,\n })\n } catch (error) {\n // Log but don't fail the entire import if a locale update fails\n req.payload.logger.error({\n err: error,\n msg: `Failed to update locale ${locale} for document ${String(existingDoc.id)}`,\n })\n }\n }\n }\n } else {\n // No multi-locale data, update normally\n try {\n // Extra debug: log before update\n if (req.payload.config.debug) {\n req.payload.logger.info({\n existingId: existingDoc.id,\n existingTitle: existingDoc.title,\n msg: 'About to update document',\n newData: updateData,\n })\n }\n\n // Update the document - don't specify draft to let Payload handle versions properly\n // This will create a new draft version for collections with versions enabled\n savedDocument = await req.payload.update({\n id: existingDoc.id as number | string,\n collection: collectionSlug,\n data: updateData,\n depth: 0,\n // Don't specify draft - this creates a new draft for versioned collections\n overrideAccess: false,\n req,\n user,\n })\n\n if (req.payload.config.debug && savedDocument) {\n req.payload.logger.info({\n id: savedDocument.id,\n msg: 'Update completed',\n status: savedDocument._status,\n title: savedDocument.title,\n })\n }\n } catch (updateError) {\n req.payload.logger.error({\n id: existingDoc.id,\n err: updateError,\n msg: 'Update failed',\n })\n throw updateError\n }\n }\n } else if (importMode === 'upsert') {\n // Create new in upsert mode\n if (req.payload.config.debug) {\n req.payload.logger.info({\n document,\n matchField: matchField || 'id',\n matchValue: document[matchField || 'id'],\n msg: 'No existing document found, creating new in upsert mode',\n })\n }\n\n const createData = { ...document }\n if (!hasCustomIdField) {\n delete createData.id\n }\n\n // Only handle _status for versioned collections\n let draftOption: boolean | undefined\n if (collectionHasVersions) {\n // Use defaultVersionStatus from config if _status not provided\n const statusValue = createData._status || options.defaultVersionStatus\n const isPublished = statusValue !== 'draft'\n draftOption = !isPublished\n // Remove _status from data - it's controlled via draft option\n delete createData._status\n }\n\n // Check if we have multi-locale data and extract it\n const { flatData, hasMultiLocale, localeUpdates } = extractMultiLocaleData(\n createData,\n configuredLocales,\n )\n\n if (hasMultiLocale) {\n // Create with default locale data\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: flatData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n\n // Update for other locales\n if (savedDocument && Object.keys(localeUpdates).length > 0) {\n for (const [locale, localeData] of Object.entries(localeUpdates)) {\n try {\n // Clone the request with the specific locale\n const localeReq = { ...req, locale }\n await req.payload.update({\n id: savedDocument.id as number | string,\n collection: collectionSlug,\n data: localeData,\n draft: collectionHasVersions ? false : undefined,\n overrideAccess: false,\n req: localeReq,\n })\n } catch (error) {\n // Log but don't fail the entire import if a locale update fails\n req.payload.logger.error({\n err: error,\n msg: `Failed to update locale ${locale} for document ${String(savedDocument.id)}`,\n })\n }\n }\n }\n } else {\n // No multi-locale data, create normally\n savedDocument = await req.payload.create({\n collection: collectionSlug,\n data: createData,\n draft: draftOption,\n overrideAccess: false,\n req,\n user,\n })\n }\n } else {\n // Update mode but document not found\n let matchValueDisplay: string\n if (typeof matchValue === 'object' && matchValue !== null) {\n matchValueDisplay = JSON.stringify(matchValue)\n } else if (typeof matchValue === 'string') {\n matchValueDisplay = matchValue\n } else if (typeof matchValue === 'number') {\n matchValueDisplay = matchValue.toString()\n } else {\n // For other types, use JSON.stringify to avoid [object Object]\n matchValueDisplay = JSON.stringify(matchValue)\n }\n throw new Error(`Document with ${matchField || 'id'}=\"${matchValueDisplay}\" not found`)\n }\n } else {\n throw new Error(`Unknown import mode: ${String(importMode)}`)\n }\n\n if (savedDocument) {\n // Determine operation type for proper counting\n let operation: 'created' | 'updated' | undefined\n if (importMode === 'create') {\n operation = 'created'\n } else if (importMode === 'update') {\n operation = 'updated'\n } else if (importMode === 'upsert') {\n if (existingDocResult && existingDocResult.docs.length > 0) {\n operation = 'updated'\n } else {\n operation = 'created'\n }\n }\n\n result.successful.push({\n document,\n index: rowNumber - 1, // Store as 0-indexed\n operation,\n result: savedDocument,\n })\n }\n } catch (error) {\n const importError: ImportError = {\n type: categorizeError(error),\n documentData: document || {},\n error: extractErrorMessage(error),\n item: document || {},\n itemIndex: rowNumber - 1,\n rowNumber,\n }\n\n // Try to extract field information from validation errors\n if (error && typeof error === 'object' && 'data' in error) {\n const errorData = error as { data?: { errors?: Array<{ path?: string }> } }\n if (errorData.data?.errors && Array.isArray(errorData.data.errors)) {\n const firstError = errorData.data.errors[0]\n if (firstError?.path) {\n importError.field = firstError.path\n }\n }\n }\n\n result.failed.push(importError)\n // Always continue processing all rows\n }\n }\n\n return result\n}\n\nexport function createImportBatchProcessor(options: ImportBatchProcessorOptions = {}) {\n const processorOptions = {\n batchSize: options.batchSize ?? 100,\n defaultVersionStatus: options.defaultVersionStatus ?? 'published',\n }\n\n const processImport = async (processOptions: ImportProcessOptions): Promise<ImportResult> => {\n const { collectionSlug, documents, importMode, matchField, req, user } = processOptions\n const batches = createBatches(documents, processorOptions.batchSize)\n\n const result: ImportResult = {\n errors: [],\n imported: 0,\n total: documents.length,\n updated: 0,\n }\n\n for (let i = 0; i < batches.length; i++) {\n const currentBatch = batches[i]\n if (!currentBatch) {\n continue\n }\n\n const batchResult = await processImportBatch({\n batch: currentBatch,\n batchIndex: i,\n collectionSlug,\n importMode,\n matchField,\n options: processorOptions,\n req,\n user,\n })\n\n // Update results\n for (const success of batchResult.successful) {\n if (success.operation === 'created') {\n result.imported++\n } else if (success.operation === 'updated') {\n result.updated++\n } else {\n // Fallback\n if (importMode === 'create') {\n result.imported++\n } else {\n result.updated++\n }\n }\n }\n\n for (const error of batchResult.failed) {\n result.errors.push({\n doc: error.documentData,\n error: error.error,\n index: error.rowNumber - 1, // Convert back to 0-indexed\n })\n }\n }\n\n return result\n }\n\n return {\n processImport,\n }\n}\n"],"names":["categorizeError","createBatches","extractErrorMessage","extractMultiLocaleData","data","configuredLocales","flatData","localeUpdates","hasMultiLocale","length","localeSet","Set","key","value","Object","entries","Array","isArray","valueObj","localeKeys","keys","filter","k","has","firstLocale","locale","processImportBatch","batch","batchIndex","collectionSlug","importMode","matchField","options","req","user","result","failed","successful","collectionEntry","payload","collections","collectionConfig","config","collectionHasVersions","Boolean","versions","hasCustomIdField","customIDType","localization","localeCodes","undefined","startingRowNumber","batchSize","i","document","rowNumber","savedDocument","existingDocResult","createData","id","draftOption","statusValue","_status","defaultVersionStatus","isPublished","debug","logger","info","msg","willSetDraft","title","titleIsNull","titleType","create","collection","draft","overrideAccess","localeData","localeReq","update","error","err","String","matchValue","Error","isMatchingById","matchValueStr","JSON","stringify","toString","isValidObjectIdFormat","test","find","depth","limit","where","equals","docs","existingDoc","existingId","existingStatus","existingTitle","incomingDocument","mode","updateData","_id","createdAt","updatedAt","reduce","acc","val","substring","newData","status","updateError","matchValueDisplay","operation","push","index","importError","type","documentData","item","itemIndex","errorData","errors","firstError","path","field","createImportBatchProcessor","processorOptions","processImport","processOptions","documents","batches","imported","total","updated","currentBatch","batchResult","success","doc"],"mappings":"AAIA,SAEEA,eAAe,EACfC,aAAa,EACbC,mBAAmB,QACd,oCAAmC;AA6C1C;;;;;;;;;;;CAWC,GACD,SAASC,uBACPC,IAA6B,EAC7BC,iBAA4B;IAM5B,MAAMC,WAAoC,CAAC;IAC3C,MAAMC,gBAAyD,CAAC;IAChE,IAAIC,iBAAiB;IAErB,IAAI,CAACH,qBAAqBA,kBAAkBI,MAAM,KAAK,GAAG;QACxD,OAAO;YAAEH,UAAU;gBAAE,GAAGF,IAAI;YAAC;YAAGI,gBAAgB;YAAOD,eAAe,CAAC;QAAE;IAC3E;IAEA,MAAMG,YAAY,IAAIC,IAAIN;IAE1B,KAAK,MAAM,CAACO,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACX,MAAO;QAC/C,IAAIS,SAAS,OAAOA,UAAU,YAAY,CAACG,MAAMC,OAAO,CAACJ,QAAQ;YAC/D,MAAMK,WAAWL;YACjB,MAAMM,aAAaL,OAAOM,IA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type { Field } from 'payload';
2
2
  type GetFieldsOptions = {
3
- collectionSlugs?: string[];
3
+ /**
4
+ * Collection slugs that this import collection supports.
5
+ * Used for schema/types and as the options in the select field.
6
+ */
7
+ collectionSlugs: string[];
4
8
  };
5
- export declare const getFields: (config: Config, options?: GetFieldsOptions) => Field[];
9
+ export declare const getFields: (options: GetFieldsOptions) => Field[];
6
10
  export {};
7
11
  //# sourceMappingURL=getFields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getFields.d.ts","sourceRoot":"","sources":["../../src/import/getFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE5C,KAAK,gBAAgB,GAAG;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,SAAS,WAAY,MAAM,YAAY,gBAAgB,KAAG,KAAK,EAuJ3E,CAAA"}
1
+ {"version":3,"file":"getFields.d.ts","sourceRoot":"","sources":["../../src/import/getFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAkB,MAAM,SAAS,CAAA;AAEpD,KAAK,gBAAgB,GAAG;IACtB;;;OAGG;IACH,eAAe,EAAE,MAAM,EAAE,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,SAAS,YAAa,gBAAgB,KAAG,KAAK,EA0J1D,CAAA"}
@@ -1,22 +1,27 @@
1
- export const getFields = (config, options)=>{
2
- const collectionOptions = options?.collectionSlugs || config.collections?.map(({ slug })=>slug) || [];
1
+ export const getFields = (options)=>{
2
+ const { collectionSlugs } = options;
3
3
  return [
4
4
  {
5
5
  name: 'collectionSlug',
6
- type: 'select',
7
- options: collectionOptions,
8
- required: true,
6
+ type: 'text',
9
7
  admin: {
10
8
  components: {
11
- Field: '@payloadcms/plugin-import-export/rsc#ImportCollectionField'
9
+ Field: '@payloadcms/plugin-import-export/rsc#CollectionField'
12
10
  }
13
11
  },
12
+ defaultValue: collectionSlugs[0],
14
13
  // @ts-expect-error - this is not correctly typed in plugins right now
15
14
  label: ({ t })=>t('plugin-import-export:field-collectionSlug-label'),
16
- validate: (value)=>{
15
+ required: true,
16
+ validate: (value, { req })=>{
17
17
  if (!value) {
18
18
  return 'Collection is required';
19
19
  }
20
+ // Validate that the collection exists
21
+ const collectionExists = req?.payload?.collections?.[value];
22
+ if (!collectionExists) {
23
+ return `Collection "${value}" does not exist`;
24
+ }
20
25
  return true;
21
26
  }
22
27
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/import/getFields.ts"],"sourcesContent":["import type { Config, Field } from 'payload'\n\ntype GetFieldsOptions = {\n collectionSlugs?: string[]\n}\n\nexport const getFields = (config: Config, options?: GetFieldsOptions): Field[] => {\n const collectionOptions =\n options?.collectionSlugs || config.collections?.map(({ slug }) => slug) || []\n\n return [\n {\n name: 'collectionSlug',\n type: 'select',\n options: collectionOptions,\n required: true,\n\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#ImportCollectionField',\n },\n },\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-collectionSlug-label'),\n validate: (value: any) => {\n if (!value) {\n return 'Collection is required'\n }\n return true\n },\n },\n {\n name: 'importMode',\n type: 'select',\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-importMode-label'),\n options: [\n {\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-importMode-create-label'),\n value: 'create',\n },\n {\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-importMode-update-label'),\n value: 'update',\n },\n {\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-importMode-upsert-label'),\n value: 'upsert',\n },\n ],\n },\n {\n name: 'matchField',\n type: 'text',\n admin: {\n condition: (_, siblingData) => siblingData?.importMode !== 'create',\n // @ts-expect-error - this is not correctly typed in plugins right now\n description: ({ t }) => t('plugin-import-export:field-matchField-description'),\n },\n defaultValue: 'id',\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-matchField-label'),\n },\n {\n name: 'status',\n type: 'select',\n admin: {\n readOnly: true,\n },\n defaultValue: 'pending',\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-status-label'),\n options: [\n {\n label: 'Pending',\n value: 'pending',\n },\n {\n label: 'Completed',\n value: 'completed',\n },\n {\n label: 'Partial',\n value: 'partial',\n },\n {\n label: 'Failed',\n value: 'failed',\n },\n ],\n },\n {\n name: 'summary',\n type: 'group',\n admin: {\n condition: (data) =>\n data?.status === 'completed' || data?.status === 'partial' || data?.status === 'failed',\n },\n fields: [\n {\n name: 'imported',\n type: 'number',\n admin: {\n readOnly: true,\n },\n label: 'Imported',\n },\n {\n name: 'updated',\n type: 'number',\n admin: {\n readOnly: true,\n },\n label: 'Updated',\n },\n {\n name: 'total',\n type: 'number',\n admin: {\n readOnly: true,\n },\n label: 'Total',\n },\n {\n name: 'issues',\n type: 'number',\n admin: {\n readOnly: true,\n },\n label: 'Issues',\n },\n {\n name: 'issueDetails',\n type: 'json',\n admin: {\n condition: (_, siblingData) => siblingData?.issues > 0,\n readOnly: true,\n },\n label: 'Issue Details',\n },\n ],\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-summary-label'),\n },\n {\n name: 'preview',\n type: 'ui',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#ImportPreview',\n },\n },\n },\n ]\n}\n"],"names":["getFields","config","options","collectionOptions","collectionSlugs","collections","map","slug","name","type","required","admin","components","Field","label","t","validate","value","condition","_","siblingData","importMode","description","defaultValue","readOnly","data","status","fields","issues"],"mappings":"AAMA,OAAO,MAAMA,YAAY,CAACC,QAAgBC;IACxC,MAAMC,oBACJD,SAASE,mBAAmBH,OAAOI,WAAW,EAAEC,IAAI,CA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AO;oBACPG,OAAO;gBACT;aACD;QACH;QACA;YACET,MAAM;YACNC,MAAM;YACNE,OAAO;gBACLO,WAAW,CAACO,OACVA,MAAMC,WAAW,eAAeD,MAAMC,WAAW,aAAaD,MAAMC,WAAW;YACnF;YACAC,QAAQ;gBACN;oBACEnB,MAAM;oBACNC,MAAM;oBACNE,OAAO;wBACLa,UAAU;oBACZ;oBACAV,OAAO;gBACT;gBACA;oBACEN,MAAM;oBACNC,MAAM;oBACNE,OAAO;wBACLa,UAAU;oBACZ;oBACAV,OAAO;gBACT;gBACA;oBACEN,MAAM;oBACNC,MAAM;oBACNE,OAAO;wBACLa,UAAU;oBACZ;oBACAV,OAAO;gBACT;gBACA;oBACEN,MAAM;oBACNC,MAAM;oBACNE,OAAO;wBACLa,UAAU;oBACZ;oBACAV,OAAO;gBACT;gBACA;oBACEN,MAAM;oBACNC,MAAM;oBACNE,OAAO;wBACLO,WAAW,CAACC,GAAGC,cAAgBA,aAAaQ,SAAS;wBACrDJ,UAAU;oBACZ;oBACAV,OAAO;gBACT;aACD;YACD,sEAAsE;YACtEA,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;QACtB;QACA;YACEP,MAAM;YACNC,MAAM;YACNE,OAAO;gBACLC,YAAY;oBACVC,OAAO;gBACT;YACF;QACF;KACD;AACH,EAAC"}
1
+ {"version":3,"sources":["../../src/import/getFields.ts"],"sourcesContent":["import type { Field, PayloadRequest } from 'payload'\n\ntype GetFieldsOptions = {\n /**\n * Collection slugs that this import collection supports.\n * Used for schema/types and as the options in the select field.\n */\n collectionSlugs: string[]\n}\n\nexport const getFields = (options: GetFieldsOptions): Field[] => {\n const { collectionSlugs } = options\n\n return [\n {\n name: 'collectionSlug',\n type: 'text',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#CollectionField',\n },\n },\n defaultValue: collectionSlugs[0],\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-collectionSlug-label'),\n required: true,\n validate: (value: null | string | undefined, { req }: { req: PayloadRequest }) => {\n if (!value) {\n return 'Collection is required'\n }\n // Validate that the collection exists\n const collectionExists = req?.payload?.collections?.[value]\n if (!collectionExists) {\n return `Collection \"${value}\" does not exist`\n }\n return true\n },\n },\n {\n name: 'importMode',\n type: 'select',\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-importMode-label'),\n options: [\n {\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-importMode-create-label'),\n value: 'create',\n },\n {\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-importMode-update-label'),\n value: 'update',\n },\n {\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-importMode-upsert-label'),\n value: 'upsert',\n },\n ],\n },\n {\n name: 'matchField',\n type: 'text',\n admin: {\n condition: (_, siblingData) => siblingData?.importMode !== 'create',\n // @ts-expect-error - this is not correctly typed in plugins right now\n description: ({ t }) => t('plugin-import-export:field-matchField-description'),\n },\n defaultValue: 'id',\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-matchField-label'),\n },\n {\n name: 'status',\n type: 'select',\n admin: {\n readOnly: true,\n },\n defaultValue: 'pending',\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-status-label'),\n options: [\n {\n label: 'Pending',\n value: 'pending',\n },\n {\n label: 'Completed',\n value: 'completed',\n },\n {\n label: 'Partial',\n value: 'partial',\n },\n {\n label: 'Failed',\n value: 'failed',\n },\n ],\n },\n {\n name: 'summary',\n type: 'group',\n admin: {\n condition: (data) =>\n data?.status === 'completed' || data?.status === 'partial' || data?.status === 'failed',\n },\n fields: [\n {\n name: 'imported',\n type: 'number',\n admin: {\n readOnly: true,\n },\n label: 'Imported',\n },\n {\n name: 'updated',\n type: 'number',\n admin: {\n readOnly: true,\n },\n label: 'Updated',\n },\n {\n name: 'total',\n type: 'number',\n admin: {\n readOnly: true,\n },\n label: 'Total',\n },\n {\n name: 'issues',\n type: 'number',\n admin: {\n readOnly: true,\n },\n label: 'Issues',\n },\n {\n name: 'issueDetails',\n type: 'json',\n admin: {\n condition: (_, siblingData) => siblingData?.issues > 0,\n readOnly: true,\n },\n label: 'Issue Details',\n },\n ],\n // @ts-expect-error - this is not correctly typed in plugins right now\n label: ({ t }) => t('plugin-import-export:field-summary-label'),\n },\n {\n name: 'preview',\n type: 'ui',\n admin: {\n components: {\n Field: '@payloadcms/plugin-import-export/rsc#ImportPreview',\n },\n },\n },\n ]\n}\n"],"names":["getFields","options","collectionSlugs","name","type","admin","components","Field","defaultValue","label","t","required","validate","value","req","collectionExists","payload","collections","condition","_","siblingData","importMode","description","readOnly","data","status","fields","issues"],"mappings":"AAUA,OAAO,MAAMA,YAAY,CAACC;IACxB,MAAM,EAAEC,eAAe,EAAE,GAAGD;IAE5B,OAAO;QACL;YACEE,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,YAAY;oBACVC,OAAO;gBACT;YACF;YACAC,cAAcN,eAAe,CAAC,EAAE;YAChC,sEAAsE;YACtEO,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;YACpBC,UAAU;YACVC,UAAU,CAACC,OAAkC,EAAEC,GAAG,EAA2B;gBAC3E,IAAI,CAACD,OAAO;oBACV,OAAO;gBACT;gBACA,sCAAsC;gBACtC,MAAME,mBAAmBD,KAAKE,SAASC,aAAa,CAACJ,MAAM;gBAC3D,IAAI,CAACE,kBAAkB;oBACrB,OAAO,CAAC,YAAY,EAAEF,MAAM,gBAAgB,CAAC;gBAC/C;gBACA,OAAO;YACT;QACF;QACA;YACEV,MAAM;YACNC,MAAM;YACN,sEAAsE;YACtEK,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;YACpBT,SAAS;gBACP;oBACE,sEAAsE;oBACtEQ,OAAO,CAAC,EAAEC,CAAC,EAAE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MAAM;oBACNC,OAAO;wBACLkB,UAAU;oBACZ;oBACAd,OAAO;gBACT;gBACA;oBACEN,MAAM;oBACNC,MAAM;oBACNC,OAAO;wBACLa,WAAW,CAACC,GAAGC,cAAgBA,aAAaO,SAAS;wBACrDJ,UAAU;oBACZ;oBACAd,OAAO;gBACT;aACD;YACD,sEAAsE;YACtEA,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;QACtB;QACA;YACEP,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,YAAY;oBACVC,OAAO;gBACT;YACF;QACF;KACD;AACH,EAAC"}
@@ -1,7 +1,10 @@
1
- import type { CollectionConfig, Config } from 'payload';
1
+ import type { CollectionConfig } from 'payload';
2
2
  import type { ImportConfig, ImportExportPluginConfig } from '../types.js';
3
- export declare const getImportCollection: ({ config, importConfig, pluginConfig, }: {
4
- config: Config;
3
+ export declare const getImportCollection: ({ collectionSlugs, importConfig, pluginConfig, }: {
4
+ /**
5
+ * Collection slugs that this import collection supports.
6
+ */
7
+ collectionSlugs: string[];
5
8
  importConfig?: ImportConfig;
6
9
  pluginConfig: ImportExportPluginConfig;
7
10
  }) => CollectionConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"getImportCollection.d.ts","sourceRoot":"","sources":["../../src/import/getImportCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,gBAAgB,EAChB,MAAM,EACP,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAwB,EAAS,MAAM,aAAa,CAAA;AAShF,eAAO,MAAM,mBAAmB,4CAI7B;IACD,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,YAAY,EAAE,wBAAwB,CAAA;CACvC,KAAG,gBA2QH,CAAA"}
1
+ {"version":3,"file":"getImportCollection.d.ts","sourceRoot":"","sources":["../../src/import/getImportCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAwB,EAAS,MAAM,aAAa,CAAA;AAShF,eAAO,MAAM,mBAAmB,qDAI7B;IACD;;OAEG;IACH,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,YAAY,EAAE,wBAAwB,CAAA;CACvC,KAAG,gBA6QH,CAAA"}
@@ -4,15 +4,13 @@ import { resolveLimit } from '../utilities/resolveLimit.js';
4
4
  import { createImport } from './createImport.js';
5
5
  import { getFields } from './getFields.js';
6
6
  import { handlePreview } from './handlePreview.js';
7
- export const getImportCollection = ({ config, importConfig, pluginConfig })=>{
7
+ export const getImportCollection = ({ collectionSlugs, importConfig, pluginConfig })=>{
8
8
  const beforeOperation = [];
9
9
  const afterChange = [];
10
10
  // Extract import-specific settings
11
11
  const disableJobsQueue = importConfig?.disableJobsQueue ?? false;
12
12
  const batchSize = importConfig?.batchSize ?? 100;
13
13
  const defaultVersionStatus = importConfig?.defaultVersionStatus ?? 'published';
14
- // Get collection slugs for the dropdown
15
- const collectionSlugs = pluginConfig.collections?.map((c)=>c.slug);
16
14
  const collection = {
17
15
  slug: 'imports',
18
16
  access: {
@@ -24,6 +22,11 @@ export const getImportCollection = ({ config, importConfig, pluginConfig })=>{
24
22
  SaveButton: '@payloadcms/plugin-import-export/rsc#ImportSaveButton'
25
23
  }
26
24
  },
25
+ custom: {
26
+ 'plugin-import-export': {
27
+ collectionSlugs
28
+ }
29
+ },
27
30
  disableCopyToLocale: true,
28
31
  group: false,
29
32
  useAsTitle: 'filename'
@@ -36,7 +39,7 @@ export const getImportCollection = ({ config, importConfig, pluginConfig })=>{
36
39
  path: '/preview-data'
37
40
  }
38
41
  ],
39
- fields: getFields(config, {
42
+ fields: getFields({
40
43
  collectionSlugs
41
44
  }),
42
45
  hooks: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/import/getImportCollection.ts"],"sourcesContent":["import type {\n CollectionAfterChangeHook,\n CollectionBeforeOperationHook,\n CollectionConfig,\n Config,\n} from 'payload'\n\nimport { FileRetrievalError } from 'payload'\n\nimport type { ImportConfig, ImportExportPluginConfig, Limit } from '../types.js'\nimport type { ImportTaskInput } from './getCreateImportCollectionTask.js'\n\nimport { getFileFromDoc } from '../utilities/getFileFromDoc.js'\nimport { resolveLimit } from '../utilities/resolveLimit.js'\nimport { createImport } from './createImport.js'\nimport { getFields } from './getFields.js'\nimport { handlePreview } from './handlePreview.js'\n\nexport const getImportCollection = ({\n config,\n importConfig,\n pluginConfig,\n}: {\n config: Config\n importConfig?: ImportConfig\n pluginConfig: ImportExportPluginConfig\n}): CollectionConfig => {\n const beforeOperation: CollectionBeforeOperationHook[] = []\n const afterChange: CollectionAfterChangeHook[] = []\n\n // Extract import-specific settings\n const disableJobsQueue = importConfig?.disableJobsQueue ?? false\n const batchSize = importConfig?.batchSize ?? 100\n const defaultVersionStatus = importConfig?.defaultVersionStatus ?? 'published'\n\n // Get collection slugs for the dropdown\n const collectionSlugs = pluginConfig.collections?.map((c) => c.slug)\n\n const collection: CollectionConfig = {\n slug: 'imports',\n access: {\n update: () => false,\n },\n admin: {\n components: {\n edit: {\n SaveButton: '@payloadcms/plugin-import-export/rsc#ImportSaveButton',\n },\n },\n disableCopyToLocale: true,\n group: false,\n useAsTitle: 'filename',\n },\n disableDuplicate: true,\n endpoints: [\n {\n handler: handlePreview,\n method: 'post',\n path: '/preview-data',\n },\n ],\n fields: getFields(config, { collectionSlugs }),\n hooks: {\n afterChange,\n beforeOperation,\n },\n lockDocuments: false,\n upload: {\n filesRequiredOnCreate: true,\n hideFileInputOnCreate: false,\n hideRemoveFile: true,\n mimeTypes: ['text/csv', 'application/json'],\n },\n }\n\n if (disableJobsQueue) {\n // Process the import synchronously after the document (with file) has been created\n afterChange.push(async ({ collection: collectionConfig, doc, operation, req }) => {\n if (operation !== 'create' || doc.status !== 'pending') {\n return doc\n }\n\n const debug = pluginConfig.debug || false\n\n try {\n // Get file data from the uploaded document\n // First try req.file which is available during the same request (especially important for cloud storage)\n // Fall back to getFileFromDoc for cases where req.file isn't available\n let fileData: Buffer\n let fileMimetype: string\n\n if (req.file?.data) {\n fileData = req.file.data\n fileMimetype = req.file.mimetype || doc.mimeType\n\n if (!fileMimetype) {\n throw new FileRetrievalError(\n req.t,\n `Unable to determine mimetype for file: ${doc.filename}`,\n )\n }\n } else {\n const fileFromDoc = await getFileFromDoc({\n collectionConfig,\n doc: {\n filename: doc.filename,\n mimeType: doc.mimeType,\n url: doc.url,\n },\n req,\n })\n fileData = fileFromDoc.data\n fileMimetype = fileFromDoc.mimetype\n }\n\n const targetCollection = req.payload.collections[doc.collectionSlug]\n const importLimitConfig: Limit | undefined =\n targetCollection?.config.custom?.['plugin-import-export']?.importLimit\n const maxLimit = await resolveLimit({\n limit: importLimitConfig,\n req,\n })\n\n const result = await createImport({\n id: doc.id,\n name: doc.filename || 'import',\n batchSize,\n collectionSlug: doc.collectionSlug,\n debug,\n defaultVersionStatus,\n file: {\n name: doc.filename,\n data: fileData,\n mimetype: fileMimetype,\n },\n format: fileMimetype === 'text/csv' ? 'csv' : 'json',\n importMode: doc.importMode || 'create',\n matchField: doc.matchField,\n maxLimit,\n req,\n userCollection: req?.user?.collection || req?.user?.user?.collection,\n userID: req?.user?.id || req?.user?.user?.id,\n })\n\n // Determine status\n let status: 'completed' | 'failed' | 'partial'\n if (result.errors.length === 0) {\n status = 'completed'\n } else if (result.imported + result.updated === 0) {\n status = 'failed'\n } else {\n status = 'partial'\n }\n\n const summary = {\n imported: result.imported,\n issueDetails:\n result.errors.length > 0\n ? result.errors.map((e) => ({\n data: e.doc,\n error: e.error,\n row: e.index + 1,\n }))\n : undefined,\n issues: result.errors.length,\n total: result.total,\n updated: result.updated,\n }\n\n // Try to update the document with results (may fail due to transaction timing)\n try {\n await req.payload.update({\n id: doc.id,\n collection: collectionConfig.slug,\n data: {\n status,\n summary,\n },\n overrideAccess: true,\n req,\n })\n } catch (updateErr) {\n // Update may fail if document not yet committed, log but continue\n if (debug) {\n req.payload.logger.error({\n err: updateErr,\n msg: `Failed to update import document ${doc.id} with results`,\n })\n }\n }\n\n // Return updated doc for immediate response\n return {\n ...doc,\n status,\n summary,\n }\n } catch (err) {\n const summary = {\n imported: 0,\n issueDetails: [\n {\n data: {},\n error: err instanceof Error ? err.message : String(err),\n row: 0,\n },\n ],\n issues: 1,\n total: 0,\n updated: 0,\n }\n\n // Try to update document with error status\n try {\n await req.payload.update({\n id: doc.id,\n collection: collectionConfig.slug,\n data: {\n status: 'failed',\n summary,\n },\n overrideAccess: true,\n req,\n })\n } catch (updateErr) {\n // Update may fail if document not yet committed, log but continue\n if (debug) {\n req.payload.logger.error({\n err: updateErr,\n msg: `Failed to update import document ${doc.id} with error status`,\n })\n }\n }\n\n if (debug) {\n req.payload.logger.error({\n err,\n msg: 'Import processing failed',\n })\n }\n\n // Return error status for immediate response\n return {\n ...doc,\n status: 'failed',\n summary,\n }\n }\n })\n } else {\n // When jobs queue is enabled, queue the import as a job\n // The job handler will fetch the file from storage using getFileFromDoc\n afterChange.push(async ({ collection: collectionConfig, doc, operation, req }) => {\n if (operation !== 'create') {\n return\n }\n\n try {\n // Resolve maxLimit ahead of time since it may involve async config resolution\n const targetCollection = req.payload.collections[doc.collectionSlug]\n const importLimitConfig: Limit | undefined =\n targetCollection?.config.custom?.['plugin-import-export']?.importLimit\n const maxLimit = await resolveLimit({\n limit: importLimitConfig,\n req,\n })\n\n // Only pass minimal data to the job - the handler will fetch the file from storage\n const input: ImportTaskInput = {\n batchSize,\n debug: pluginConfig.debug,\n defaultVersionStatus,\n importCollection: collectionConfig.slug,\n importId: doc.id,\n maxLimit,\n userCollection: req.user?.collection || req?.user?.user?.collection,\n userID: req?.user?.id || req?.user?.user?.id,\n }\n\n await req.payload.jobs.queue({\n input,\n task: 'createCollectionImport',\n })\n } catch (err) {\n req.payload.logger.error({\n err,\n msg: `Failed to queue import job for document ${doc.id}`,\n })\n }\n })\n }\n\n return collection\n}\n"],"names":["FileRetrievalError","getFileFromDoc","resolveLimit","createImport","getFields","handlePreview","getImportCollection","config","importConfig","pluginConfig","beforeOperation","afterChange","disableJobsQueue","batchSize","defaultVersionStatus","collectionSlugs","collections","map","c","slug","collection","access","update","admin","components","edit","SaveButton","disableCopyToLocale","group","useAsTitle","disableDuplicate","endpoints","handler","method","path","fields","hooks","lockDocuments","upload","filesRequiredOnCreate","hideFileInputOnCreate","hideRemoveFile","mimeTypes","push","collectionConfig","doc","operation","req","status","debug","fileData","fileMimetype","file","data","mimetype","mimeType","t","filename","fileFromDoc","url","targetCollection","payload","collectionSlug","importLimitConfig","custom","importLimit","maxLimit","limit","result","id","name","format","importMode","matchField","userCollection","user","userID","errors","length","imported","updated","summary","issueDetails","e","error","row","index","undefined","issues","total","overrideAccess","updateErr","logger","err","msg","Error","message","String","input","importCollection","importId","jobs","queue","task"],"mappings":"AAOA,SAASA,kBAAkB,QAAQ,UAAS;AAK5C,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,YAAY,QAAQ,+BAA8B;AAC3D,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,aAAa,QAAQ,qBAAoB;AAElD,OAAO,MAAMC,sBAAsB,CAAC,EAClCC,MAAM,EACNC,YAAY,EACZC,YAAY,EAKb;IACC,MAAMC,kBAAmD,EAAE;IAC3D,MAAMC,cAA2C,EAAE;IAEnD,mCAAmC;IACnC,MAAMC,mBAAmBJ,cAAcI,oBAAoB;IAC3D,MAAMC,YAAYL,cAAcK,aAAa;IAC7C,MAAMC,uBAAuBN,cAAcM,wBAAwB;IAEnE,wCAAwC;IACxC,MAAMC,kBAAkBN,aAAaO,WAAW,EAAEC,IAAI,CAACC,IAAMA,EAAEC,IAAI;IAEnE,MAAMC,aAA+B;QACnCD,MAAM;QACNE,QAAQ;YACNC,QAAQ,IAAM;QAChB;QACAC,OAAO;YACLC,YAAY;gBAC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ACF;QACF;IACF;IAEA,OAAOjD;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/import/getImportCollection.ts"],"sourcesContent":["import type {\n CollectionAfterChangeHook,\n CollectionBeforeOperationHook,\n CollectionConfig,\n} from 'payload'\n\nimport { FileRetrievalError } from 'payload'\n\nimport type { ImportConfig, ImportExportPluginConfig, Limit } from '../types.js'\nimport type { ImportTaskInput } from './getCreateImportCollectionTask.js'\n\nimport { getFileFromDoc } from '../utilities/getFileFromDoc.js'\nimport { resolveLimit } from '../utilities/resolveLimit.js'\nimport { createImport } from './createImport.js'\nimport { getFields } from './getFields.js'\nimport { handlePreview } from './handlePreview.js'\n\nexport const getImportCollection = ({\n collectionSlugs,\n importConfig,\n pluginConfig,\n}: {\n /**\n * Collection slugs that this import collection supports.\n */\n collectionSlugs: string[]\n importConfig?: ImportConfig\n pluginConfig: ImportExportPluginConfig\n}): CollectionConfig => {\n const beforeOperation: CollectionBeforeOperationHook[] = []\n const afterChange: CollectionAfterChangeHook[] = []\n\n // Extract import-specific settings\n const disableJobsQueue = importConfig?.disableJobsQueue ?? false\n const batchSize = importConfig?.batchSize ?? 100\n const defaultVersionStatus = importConfig?.defaultVersionStatus ?? 'published'\n\n const collection: CollectionConfig = {\n slug: 'imports',\n access: {\n update: () => false,\n },\n admin: {\n components: {\n edit: {\n SaveButton: '@payloadcms/plugin-import-export/rsc#ImportSaveButton',\n },\n },\n custom: {\n 'plugin-import-export': {\n collectionSlugs,\n },\n },\n disableCopyToLocale: true,\n group: false,\n useAsTitle: 'filename',\n },\n disableDuplicate: true,\n endpoints: [\n {\n handler: handlePreview,\n method: 'post',\n path: '/preview-data',\n },\n ],\n fields: getFields({ collectionSlugs }),\n hooks: {\n afterChange,\n beforeOperation,\n },\n lockDocuments: false,\n upload: {\n filesRequiredOnCreate: true,\n hideFileInputOnCreate: false,\n hideRemoveFile: true,\n mimeTypes: ['text/csv', 'application/json'],\n },\n }\n\n if (disableJobsQueue) {\n // Process the import synchronously after the document (with file) has been created\n afterChange.push(async ({ collection: collectionConfig, doc, operation, req }) => {\n if (operation !== 'create' || doc.status !== 'pending') {\n return doc\n }\n\n const debug = pluginConfig.debug || false\n\n try {\n // Get file data from the uploaded document\n // First try req.file which is available during the same request (especially important for cloud storage)\n // Fall back to getFileFromDoc for cases where req.file isn't available\n let fileData: Buffer\n let fileMimetype: string\n\n if (req.file?.data) {\n fileData = req.file.data\n fileMimetype = req.file.mimetype || doc.mimeType\n\n if (!fileMimetype) {\n throw new FileRetrievalError(\n req.t,\n `Unable to determine mimetype for file: ${doc.filename}`,\n )\n }\n } else {\n const fileFromDoc = await getFileFromDoc({\n collectionConfig,\n doc: {\n filename: doc.filename,\n mimeType: doc.mimeType,\n url: doc.url,\n },\n req,\n })\n fileData = fileFromDoc.data\n fileMimetype = fileFromDoc.mimetype\n }\n\n const targetCollection = req.payload.collections[doc.collectionSlug]\n const importLimitConfig: Limit | undefined =\n targetCollection?.config.custom?.['plugin-import-export']?.importLimit\n const maxLimit = await resolveLimit({\n limit: importLimitConfig,\n req,\n })\n\n const result = await createImport({\n id: doc.id,\n name: doc.filename || 'import',\n batchSize,\n collectionSlug: doc.collectionSlug,\n debug,\n defaultVersionStatus,\n file: {\n name: doc.filename,\n data: fileData,\n mimetype: fileMimetype,\n },\n format: fileMimetype === 'text/csv' ? 'csv' : 'json',\n importMode: doc.importMode || 'create',\n matchField: doc.matchField,\n maxLimit,\n req,\n userCollection: req?.user?.collection || req?.user?.user?.collection,\n userID: req?.user?.id || req?.user?.user?.id,\n })\n\n // Determine status\n let status: 'completed' | 'failed' | 'partial'\n if (result.errors.length === 0) {\n status = 'completed'\n } else if (result.imported + result.updated === 0) {\n status = 'failed'\n } else {\n status = 'partial'\n }\n\n const summary = {\n imported: result.imported,\n issueDetails:\n result.errors.length > 0\n ? result.errors.map((e) => ({\n data: e.doc,\n error: e.error,\n row: e.index + 1,\n }))\n : undefined,\n issues: result.errors.length,\n total: result.total,\n updated: result.updated,\n }\n\n // Try to update the document with results (may fail due to transaction timing)\n try {\n await req.payload.update({\n id: doc.id,\n collection: collectionConfig.slug,\n data: {\n status,\n summary,\n },\n overrideAccess: true,\n req,\n })\n } catch (updateErr) {\n // Update may fail if document not yet committed, log but continue\n if (debug) {\n req.payload.logger.error({\n err: updateErr,\n msg: `Failed to update import document ${doc.id} with results`,\n })\n }\n }\n\n // Return updated doc for immediate response\n return {\n ...doc,\n status,\n summary,\n }\n } catch (err) {\n const summary = {\n imported: 0,\n issueDetails: [\n {\n data: {},\n error: err instanceof Error ? err.message : String(err),\n row: 0,\n },\n ],\n issues: 1,\n total: 0,\n updated: 0,\n }\n\n // Try to update document with error status\n try {\n await req.payload.update({\n id: doc.id,\n collection: collectionConfig.slug,\n data: {\n status: 'failed',\n summary,\n },\n overrideAccess: true,\n req,\n })\n } catch (updateErr) {\n // Update may fail if document not yet committed, log but continue\n if (debug) {\n req.payload.logger.error({\n err: updateErr,\n msg: `Failed to update import document ${doc.id} with error status`,\n })\n }\n }\n\n if (debug) {\n req.payload.logger.error({\n err,\n msg: 'Import processing failed',\n })\n }\n\n // Return error status for immediate response\n return {\n ...doc,\n status: 'failed',\n summary,\n }\n }\n })\n } else {\n // When jobs queue is enabled, queue the import as a job\n // The job handler will fetch the file from storage using getFileFromDoc\n afterChange.push(async ({ collection: collectionConfig, doc, operation, req }) => {\n if (operation !== 'create') {\n return\n }\n\n try {\n // Resolve maxLimit ahead of time since it may involve async config resolution\n const targetCollection = req.payload.collections[doc.collectionSlug]\n const importLimitConfig: Limit | undefined =\n targetCollection?.config.custom?.['plugin-import-export']?.importLimit\n const maxLimit = await resolveLimit({\n limit: importLimitConfig,\n req,\n })\n\n // Only pass minimal data to the job - the handler will fetch the file from storage\n const input: ImportTaskInput = {\n batchSize,\n debug: pluginConfig.debug,\n defaultVersionStatus,\n importCollection: collectionConfig.slug,\n importId: doc.id,\n maxLimit,\n userCollection: req.user?.collection || req?.user?.user?.collection,\n userID: req?.user?.id || req?.user?.user?.id,\n }\n\n await req.payload.jobs.queue({\n input,\n task: 'createCollectionImport',\n })\n } catch (err) {\n req.payload.logger.error({\n err,\n msg: `Failed to queue import job for document ${doc.id}`,\n })\n }\n })\n }\n\n return collection\n}\n"],"names":["FileRetrievalError","getFileFromDoc","resolveLimit","createImport","getFields","handlePreview","getImportCollection","collectionSlugs","importConfig","pluginConfig","beforeOperation","afterChange","disableJobsQueue","batchSize","defaultVersionStatus","collection","slug","access","update","admin","components","edit","SaveButton","custom","disableCopyToLocale","group","useAsTitle","disableDuplicate","endpoints","handler","method","path","fields","hooks","lockDocuments","upload","filesRequiredOnCreate","hideFileInputOnCreate","hideRemoveFile","mimeTypes","push","collectionConfig","doc","operation","req","status","debug","fileData","fileMimetype","file","data","mimetype","mimeType","t","filename","fileFromDoc","url","targetCollection","payload","collections","collectionSlug","importLimitConfig","config","importLimit","maxLimit","limit","result","id","name","format","importMode","matchField","userCollection","user","userID","errors","length","imported","updated","summary","issueDetails","map","e","error","row","index","undefined","issues","total","overrideAccess","updateErr","logger","err","msg","Error","message","String","input","importCollection","importId","jobs","queue","task"],"mappings":"AAMA,SAASA,kBAAkB,QAAQ,UAAS;AAK5C,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,YAAY,QAAQ,+BAA8B;AAC3D,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,aAAa,QAAQ,qBAAoB;AAElD,OAAO,MAAMC,sBAAsB,CAAC,EAClCC,eAAe,EACfC,YAAY,EACZC,YAAY,EAQb;IACC,MAAMC,kBAAmD,EAAE;IAC3D,MAAMC,cAA2C,EAAE;IAEnD,mCAAmC;IACnC,MAAMC,mBAAmBJ,cAAcI,oBAAoB;IAC3D,MAAMC,YAAYL,cAAcK,aAAa;IAC7C,MAAMC,uBAAuBN,cAAcM,wBAAwB;IAEnE,MAAMC,aAA+B;QACnCC,MAAM;QACNC,QAAQ;YACNC,QAAQ,IAAM;QAChB;QACAC,OAAO;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EAAEnD,IAAIyB,EAAE,EAAE;gBAC1D;YACF;QACF;IACF;IAEA,OAAOpD;AACT,EAAC"}
package/dist/index.d.ts CHANGED
@@ -21,6 +21,11 @@ declare module 'payload' {
21
21
  }
22
22
  interface CollectionAdminCustom {
23
23
  'plugin-import-export'?: {
24
+ /**
25
+ * Array of collection slugs that this export/import collection can target.
26
+ * Used by CollectionField to populate the dropdown options.
27
+ */
28
+ collectionSlugs?: string[];
24
29
  /**
25
30
  * Array of field paths that are disabled for import/export.
26
31
  * These paths are collected from fields marked with `custom['plugin-import-export'].disabled = true`.