@payloadcms/plugin-import-export 3.78.0-canary.5 → 3.78.0-canary.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ExportSaveButton/index.d.ts.map +1 -1
- package/dist/components/ExportSaveButton/index.js +11 -6
- package/dist/components/ExportSaveButton/index.js.map +1 -1
- package/dist/components/FormatField/index.d.ts +3 -0
- package/dist/components/FormatField/index.d.ts.map +1 -0
- package/dist/components/FormatField/index.js +95 -0
- package/dist/components/FormatField/index.js.map +1 -0
- package/dist/export/createExport.d.ts.map +1 -1
- package/dist/export/createExport.js +44 -16
- package/dist/export/createExport.js.map +1 -1
- package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
- package/dist/export/getCreateExportCollectionTask.js +105 -24
- package/dist/export/getCreateExportCollectionTask.js.map +1 -1
- package/dist/export/getExportCollection.d.ts.map +1 -1
- package/dist/export/getExportCollection.js +75 -66
- package/dist/export/getExportCollection.js.map +1 -1
- package/dist/export/getFields.d.ts.map +1 -1
- package/dist/export/getFields.js +4 -7
- package/dist/export/getFields.js.map +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.d.ts.map +1 -1
- package/dist/exports/rsc.js +1 -0
- package/dist/exports/rsc.js.map +1 -1
- package/dist/import/batchProcessor.d.ts.map +1 -1
- package/dist/import/batchProcessor.js +11 -5
- package/dist/import/batchProcessor.js.map +1 -1
- package/dist/import/createImport.d.ts.map +1 -1
- package/dist/import/createImport.js +2 -1
- package/dist/import/createImport.js.map +1 -1
- package/dist/import/getImportCollection.d.ts.map +1 -1
- package/dist/import/getImportCollection.js +229 -181
- package/dist/import/getImportCollection.js.map +1 -1
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -16
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/getPluginCollections.d.ts +4 -1
- package/dist/utilities/getPluginCollections.d.ts.map +1 -1
- package/dist/utilities/getPluginCollections.js +4 -43
- package/dist/utilities/getPluginCollections.js.map +1 -1
- package/dist/utilities/unflattenObject.d.ts.map +1 -1
- package/dist/utilities/unflattenObject.js +5 -0
- package/dist/utilities/unflattenObject.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -95,11 +95,16 @@ export const importExportPlugin = (pluginConfig)=>async (config)=>{
|
|
|
95
95
|
const disabledFieldAccessors = collectDisabledFieldPaths(collection.fields);
|
|
96
96
|
const exportConfig = typeof collectionPluginConfig?.export === 'object' ? collectionPluginConfig.export : undefined;
|
|
97
97
|
const exportFormat = exportConfig?.format;
|
|
98
|
+
const exportDisableJobsQueue = exportConfig?.disableJobsQueue;
|
|
99
|
+
const exportBatchSize = exportConfig?.batchSize;
|
|
100
|
+
const exportDisableSave = exportConfig?.disableSave;
|
|
101
|
+
const exportDisableDownload = exportConfig?.disableDownload;
|
|
98
102
|
const importConfig = typeof collectionPluginConfig?.import === 'object' ? collectionPluginConfig.import : undefined;
|
|
103
|
+
const importDisableJobsQueue = importConfig?.disableJobsQueue;
|
|
104
|
+
const importBatchSize = importConfig?.batchSize;
|
|
99
105
|
const exportLimit = exportConfig?.limit ?? pluginConfig.exportLimit;
|
|
100
106
|
const importLimit = importConfig?.limit ?? pluginConfig.importLimit;
|
|
101
|
-
|
|
102
|
-
// Note: limits are stored in collection.custom (server-only) because they can be functions
|
|
107
|
+
const importDefaultVersionStatus = importConfig?.defaultVersionStatus;
|
|
103
108
|
collection.admin.custom = {
|
|
104
109
|
...collection.admin.custom || {},
|
|
105
110
|
'plugin-import-export': {
|
|
@@ -107,24 +112,42 @@ export const importExportPlugin = (pluginConfig)=>async (config)=>{
|
|
|
107
112
|
disabledFields: disabledFieldAccessors,
|
|
108
113
|
...exportFormat !== undefined && {
|
|
109
114
|
exportFormat
|
|
115
|
+
},
|
|
116
|
+
...exportDisableSave !== undefined && {
|
|
117
|
+
disableSave: exportDisableSave
|
|
118
|
+
},
|
|
119
|
+
...exportDisableDownload !== undefined && {
|
|
120
|
+
disableDownload: exportDisableDownload
|
|
110
121
|
}
|
|
111
122
|
}
|
|
112
123
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
...collection.custom || {},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
collection.custom = {
|
|
125
|
+
...collection.custom || {},
|
|
126
|
+
'plugin-import-export': {
|
|
127
|
+
...collection.custom?.['plugin-import-export'] || {},
|
|
128
|
+
...exportLimit !== undefined && {
|
|
129
|
+
exportLimit
|
|
130
|
+
},
|
|
131
|
+
...exportDisableJobsQueue !== undefined && {
|
|
132
|
+
exportDisableJobsQueue
|
|
133
|
+
},
|
|
134
|
+
...exportBatchSize !== undefined && {
|
|
135
|
+
exportBatchSize
|
|
136
|
+
},
|
|
137
|
+
...importLimit !== undefined && {
|
|
138
|
+
importLimit
|
|
139
|
+
},
|
|
140
|
+
...importDisableJobsQueue !== undefined && {
|
|
141
|
+
importDisableJobsQueue
|
|
142
|
+
},
|
|
143
|
+
...importBatchSize !== undefined && {
|
|
144
|
+
importBatchSize
|
|
145
|
+
},
|
|
146
|
+
...importDefaultVersionStatus !== undefined && {
|
|
147
|
+
defaultVersionStatus: importDefaultVersionStatus
|
|
125
148
|
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
128
151
|
collection.admin.components = components;
|
|
129
152
|
}
|
|
130
153
|
if (!config.i18n) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload'\n\nimport { deepMergeSimple } from 'payload'\n\nimport type { PluginDefaultTranslationsObject } from './translations/types.js'\nimport type {\n FromCSVFunction,\n ImportExportPluginConfig,\n Limit,\n PluginCollectionConfig,\n ToCSVFunction,\n} from './types.js'\n\nimport { getCreateCollectionExportTask } from './export/getCreateExportCollectionTask.js'\nimport { getCreateCollectionImportTask } from './import/getCreateImportCollectionTask.js'\nimport { translations } from './translations/index.js'\nimport { collectDisabledFieldPaths } from './utilities/collectDisabledFieldPaths.js'\nimport { getPluginCollections } from './utilities/getPluginCollections.js'\n\nexport const importExportPlugin =\n (pluginConfig: ImportExportPluginConfig) =>\n async (config: Config): Promise<Config> => {\n // Get all export/import collections and the mappings from target collections to custom collections\n const { customExportSlugMap, customImportSlugMap, exportCollections, importCollections } =\n await getPluginCollections({\n config,\n pluginConfig,\n })\n\n // Base collections are at index 0 (always present)\n const baseExportCollection = exportCollections[0]!\n const baseImportCollection = importCollections[0]!\n\n // Collect all export and import collection slugs for filtering\n const allExportSlugs = new Set(exportCollections.map((c) => c.slug))\n const allImportSlugs = new Set(importCollections.map((c) => c.slug))\n\n // Initialize collections array if needed\n if (!config.collections) {\n config.collections = []\n }\n\n // Push all export/import collections if their slugs don't already exist\n for (const collection of [...exportCollections, ...importCollections]) {\n const slugExists = config.collections.some((c) => c.slug === collection.slug)\n if (!slugExists) {\n config.collections.push(collection)\n }\n }\n\n // inject custom import export provider\n config.admin = config.admin || {}\n config.admin.components = config.admin.components || {}\n config.admin.components.providers = config.admin.components.providers || []\n config.admin.components.providers.push(\n '@payloadcms/plugin-import-export/rsc#ImportExportProvider',\n )\n\n // inject the createExport and createImport jobs into the config\n ;((config.jobs ??= {}).tasks ??= []).push(getCreateCollectionExportTask(config))\n config.jobs.tasks.push(getCreateCollectionImportTask(config))\n\n // Build a map of collection configs for quick lookup\n const collectionConfigMap = new Map<string, PluginCollectionConfig>()\n if (pluginConfig.collections) {\n for (const collectionConfig of pluginConfig.collections) {\n collectionConfigMap.set(collectionConfig.slug, collectionConfig)\n }\n }\n\n // Determine which collections to add import/export menu items to\n // Exclude all export and import collections\n const collectionsToUpdate = config.collections.filter(\n (c) => !allExportSlugs.has(c.slug) && !allImportSlugs.has(c.slug),\n )\n\n for (const collection of collectionsToUpdate) {\n // Get the plugin config for this collection (if specified)\n const collectionPluginConfig = collectionConfigMap.get(collection.slug)\n\n // If collections array is specified but this collection is not in it, skip\n if (\n pluginConfig.collections &&\n pluginConfig.collections.length > 0 &&\n !collectionPluginConfig\n ) {\n continue\n }\n\n // Determine which export/import collection to use for this collection\n const exportSlugForCollection =\n customExportSlugMap.get(collection.slug) || baseExportCollection.slug\n const importSlugForCollection =\n customImportSlugMap.get(collection.slug) || baseImportCollection.slug\n\n // Check if export/import are disabled for this collection\n const exportDisabled = collectionPluginConfig?.export === false\n const importDisabled = collectionPluginConfig?.import === false\n\n if (!collection.admin) {\n collection.admin = { components: { listMenuItems: [] } }\n }\n const components = collection.admin.components || {}\n if (!components.listMenuItems) {\n components.listMenuItems = []\n }\n\n // Add export menu item if not disabled\n if (!exportDisabled) {\n components.listMenuItems.push({\n clientProps: {\n collectionSlug: collection.slug,\n exportCollectionSlug: exportSlugForCollection,\n },\n path: '@payloadcms/plugin-import-export/rsc#ExportListMenuItem',\n })\n }\n\n // Add import menu item if not disabled\n if (!importDisabled) {\n components.listMenuItems.push({\n clientProps: {\n collectionSlug: collection.slug,\n importCollectionSlug: importSlugForCollection,\n },\n path: '@payloadcms/plugin-import-export/rsc#ImportListMenuItem',\n })\n }\n\n // Find fields explicitly marked as disabled for import/export\n const disabledFieldAccessors = collectDisabledFieldPaths(collection.fields)\n\n const exportConfig =\n typeof collectionPluginConfig?.export === 'object'\n ? collectionPluginConfig.export\n : undefined\n const exportFormat = exportConfig?.format\n\n const importConfig =\n typeof collectionPluginConfig?.import === 'object'\n ? collectionPluginConfig.import\n : undefined\n\n const exportLimit = exportConfig?.limit ?? pluginConfig.exportLimit\n\n const importLimit = importConfig?.limit ?? pluginConfig.importLimit\n\n // Store disabled field accessors and export format in the admin config for use in the UI\n // Note: limits are stored in collection.custom (server-only) because they can be functions\n collection.admin.custom = {\n ...(collection.admin.custom || {}),\n 'plugin-import-export': {\n ...(collection.admin.custom?.['plugin-import-export'] || {}),\n disabledFields: disabledFieldAccessors,\n ...(exportFormat !== undefined && { exportFormat }),\n },\n }\n\n // Store limits in collection.custom (server-only) since they can be functions\n if (exportLimit !== undefined || importLimit !== undefined) {\n collection.custom = {\n ...(collection.custom || {}),\n 'plugin-import-export': {\n ...(collection.custom?.['plugin-import-export'] || {}),\n ...(exportLimit !== undefined && { exportLimit }),\n ...(importLimit !== undefined && { importLimit }),\n },\n }\n }\n\n collection.admin.components = components\n }\n\n if (!config.i18n) {\n config.i18n = {}\n }\n\n /**\n * Merge plugin translations\n */\n const simplifiedTranslations = Object.entries(translations).reduce(\n (acc, [key, value]) => {\n acc[key] = value.translations\n return acc\n },\n {} as Record<string, PluginDefaultTranslationsObject>,\n )\n\n config.i18n = {\n ...config.i18n,\n translations: deepMergeSimple(simplifiedTranslations, config.i18n?.translations ?? {}),\n }\n\n return config\n }\n\ndeclare module 'payload' {\n export interface FieldCustom {\n 'plugin-import-export'?: {\n /**\n * When `true` the field is **completely excluded** from the import-export plugin:\n * - It will not appear in the \"Fields to export\" selector.\n * - It is hidden from the preview list when no specific fields are chosen.\n * - Its data is omitted from the final CSV / JSON export.\n * @default false\n */\n disabled?: boolean\n fromCSV?: FromCSVFunction\n /**\n * Custom function used to modify the outgoing csv data by manipulating the data, siblingData or by returning the desired value\n */\n toCSV?: ToCSVFunction\n }\n }\n\n export interface CollectionAdminCustom {\n 'plugin-import-export'?: {\n /**\n * Array of collection slugs that this export/import collection can target.\n * Used by CollectionField to populate the dropdown options.\n */\n collectionSlugs?: string[]\n /**\n * Array of field paths that are disabled for import/export.\n * These paths are collected from fields marked with `custom['plugin-import-export'].disabled = true`.\n */\n disabledFields?: string[]\n /**\n * When set, forces exports from this collection to use this format.\n * This value is read from the plugin config's `export.format` option.\n */\n exportFormat?: 'csv' | 'json'\n }\n }\n\n export interface CollectionCustom {\n 'plugin-import-export'?: {\n /**\n * Maximum number of documents that can be exported from this collection.\n * Set to 0 for unlimited (default). Can be a number or function.\n * Stored in collection.custom (server-only) since functions cannot be serialized to client.\n */\n exportLimit?: Limit\n /**\n * Maximum number of documents that can be imported to this collection.\n * Set to 0 for unlimited (default). Can be a number or function.\n * Stored in collection.custom (server-only) since functions cannot be serialized to client.\n */\n importLimit?: Limit\n }\n }\n}\n"],"names":["deepMergeSimple","getCreateCollectionExportTask","getCreateCollectionImportTask","translations","collectDisabledFieldPaths","getPluginCollections","importExportPlugin","pluginConfig","config","customExportSlugMap","customImportSlugMap","exportCollections","importCollections","baseExportCollection","baseImportCollection","allExportSlugs","Set","map","c","slug","allImportSlugs","collections","collection","slugExists","some","push","admin","components","providers","jobs","tasks","collectionConfigMap","Map","collectionConfig","set","collectionsToUpdate","filter","has","collectionPluginConfig","get","length","exportSlugForCollection","importSlugForCollection","exportDisabled","export","importDisabled","import","listMenuItems","clientProps","collectionSlug","exportCollectionSlug","path","importCollectionSlug","disabledFieldAccessors","fields","exportConfig","undefined","exportFormat","format","importConfig","exportLimit","limit","importLimit","custom","disabledFields","i18n","simplifiedTranslations","Object","entries","reduce","acc","key","value"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AAWzC,SAASC,6BAA6B,QAAQ,4CAA2C;AACzF,SAASC,6BAA6B,QAAQ,4CAA2C;AACzF,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,oBAAoB,QAAQ,sCAAqC;AAE1E,OAAO,MAAMC,qBACX,CAACC,eACD,OAAOC;QACL,mGAAmG;QACnG,MAAM,EAAEC,mBAAmB,EAAEC,mBAAmB,EAAEC,iBAAiB,EAAEC,iBAAiB,EAAE,GACtF,MAAMP,qBAAqB;YACzBG;YACAD;QACF;QAEF,mDAAmD;QACnD,MAAMM,uBAAuBF,iBAAiB,CAAC,EAAE;QACjD,MAAMG,uBAAuBF,iBAAiB,CAAC,EAAE;QAEjD,+DAA+D;QAC/D,MAA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ckE,MAAM,CAChE,CAACC,KAAK,CAACC,KAAKC,MAAM;YAChBF,GAAG,CAACC,IAAI,GAAGC,MAAMrE,YAAY;YAC7B,OAAOmE;QACT,GACA,CAAC;QAGH9D,OAAOyD,IAAI,GAAG;YACZ,GAAGzD,OAAOyD,IAAI;YACd9D,cAAcH,gBAAgBkE,wBAAwB1D,OAAOyD,IAAI,EAAE9D,gBAAgB,CAAC;QACtF;QAEA,OAAOK;IACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload'\n\nimport { deepMergeSimple } from 'payload'\n\nimport type { PluginDefaultTranslationsObject } from './translations/types.js'\nimport type {\n FromCSVFunction,\n ImportExportPluginConfig,\n Limit,\n PluginCollectionConfig,\n ToCSVFunction,\n} from './types.js'\n\nimport { getCreateCollectionExportTask } from './export/getCreateExportCollectionTask.js'\nimport { getCreateCollectionImportTask } from './import/getCreateImportCollectionTask.js'\nimport { translations } from './translations/index.js'\nimport { collectDisabledFieldPaths } from './utilities/collectDisabledFieldPaths.js'\nimport { getPluginCollections } from './utilities/getPluginCollections.js'\n\nexport const importExportPlugin =\n (pluginConfig: ImportExportPluginConfig) =>\n async (config: Config): Promise<Config> => {\n // Get all export/import collections and the mappings from target collections to custom collections\n const { customExportSlugMap, customImportSlugMap, exportCollections, importCollections } =\n await getPluginCollections({\n config,\n pluginConfig,\n })\n\n // Base collections are at index 0 (always present)\n const baseExportCollection = exportCollections[0]!\n const baseImportCollection = importCollections[0]!\n\n // Collect all export and import collection slugs for filtering\n const allExportSlugs = new Set(exportCollections.map((c) => c.slug))\n const allImportSlugs = new Set(importCollections.map((c) => c.slug))\n\n // Initialize collections array if needed\n if (!config.collections) {\n config.collections = []\n }\n\n // Push all export/import collections if their slugs don't already exist\n for (const collection of [...exportCollections, ...importCollections]) {\n const slugExists = config.collections.some((c) => c.slug === collection.slug)\n if (!slugExists) {\n config.collections.push(collection)\n }\n }\n\n // inject custom import export provider\n config.admin = config.admin || {}\n config.admin.components = config.admin.components || {}\n config.admin.components.providers = config.admin.components.providers || []\n config.admin.components.providers.push(\n '@payloadcms/plugin-import-export/rsc#ImportExportProvider',\n )\n\n // inject the createExport and createImport jobs into the config\n ;((config.jobs ??= {}).tasks ??= []).push(getCreateCollectionExportTask(config))\n config.jobs.tasks.push(getCreateCollectionImportTask(config))\n\n // Build a map of collection configs for quick lookup\n const collectionConfigMap = new Map<string, PluginCollectionConfig>()\n if (pluginConfig.collections) {\n for (const collectionConfig of pluginConfig.collections) {\n collectionConfigMap.set(collectionConfig.slug, collectionConfig)\n }\n }\n\n // Determine which collections to add import/export menu items to\n // Exclude all export and import collections\n const collectionsToUpdate = config.collections.filter(\n (c) => !allExportSlugs.has(c.slug) && !allImportSlugs.has(c.slug),\n )\n\n for (const collection of collectionsToUpdate) {\n // Get the plugin config for this collection (if specified)\n const collectionPluginConfig = collectionConfigMap.get(collection.slug)\n\n // If collections array is specified but this collection is not in it, skip\n if (\n pluginConfig.collections &&\n pluginConfig.collections.length > 0 &&\n !collectionPluginConfig\n ) {\n continue\n }\n\n // Determine which export/import collection to use for this collection\n const exportSlugForCollection =\n customExportSlugMap.get(collection.slug) || baseExportCollection.slug\n const importSlugForCollection =\n customImportSlugMap.get(collection.slug) || baseImportCollection.slug\n\n // Check if export/import are disabled for this collection\n const exportDisabled = collectionPluginConfig?.export === false\n const importDisabled = collectionPluginConfig?.import === false\n\n if (!collection.admin) {\n collection.admin = { components: { listMenuItems: [] } }\n }\n const components = collection.admin.components || {}\n if (!components.listMenuItems) {\n components.listMenuItems = []\n }\n\n // Add export menu item if not disabled\n if (!exportDisabled) {\n components.listMenuItems.push({\n clientProps: {\n collectionSlug: collection.slug,\n exportCollectionSlug: exportSlugForCollection,\n },\n path: '@payloadcms/plugin-import-export/rsc#ExportListMenuItem',\n })\n }\n\n // Add import menu item if not disabled\n if (!importDisabled) {\n components.listMenuItems.push({\n clientProps: {\n collectionSlug: collection.slug,\n importCollectionSlug: importSlugForCollection,\n },\n path: '@payloadcms/plugin-import-export/rsc#ImportListMenuItem',\n })\n }\n\n // Find fields explicitly marked as disabled for import/export\n const disabledFieldAccessors = collectDisabledFieldPaths(collection.fields)\n\n const exportConfig =\n typeof collectionPluginConfig?.export === 'object'\n ? collectionPluginConfig.export\n : undefined\n const exportFormat = exportConfig?.format\n const exportDisableJobsQueue = exportConfig?.disableJobsQueue\n const exportBatchSize = exportConfig?.batchSize\n const exportDisableSave = exportConfig?.disableSave\n const exportDisableDownload = exportConfig?.disableDownload\n\n const importConfig =\n typeof collectionPluginConfig?.import === 'object'\n ? collectionPluginConfig.import\n : undefined\n const importDisableJobsQueue = importConfig?.disableJobsQueue\n const importBatchSize = importConfig?.batchSize\n\n const exportLimit = exportConfig?.limit ?? pluginConfig.exportLimit\n\n const importLimit = importConfig?.limit ?? pluginConfig.importLimit\n const importDefaultVersionStatus = importConfig?.defaultVersionStatus\n\n collection.admin.custom = {\n ...(collection.admin.custom || {}),\n 'plugin-import-export': {\n ...(collection.admin.custom?.['plugin-import-export'] || {}),\n disabledFields: disabledFieldAccessors,\n ...(exportFormat !== undefined && { exportFormat }),\n ...(exportDisableSave !== undefined && { disableSave: exportDisableSave }),\n ...(exportDisableDownload !== undefined && { disableDownload: exportDisableDownload }),\n },\n }\n\n collection.custom = {\n ...(collection.custom || {}),\n 'plugin-import-export': {\n ...(collection.custom?.['plugin-import-export'] || {}),\n ...(exportLimit !== undefined && { exportLimit }),\n ...(exportDisableJobsQueue !== undefined && {\n exportDisableJobsQueue,\n }),\n ...(exportBatchSize !== undefined && { exportBatchSize }),\n ...(importLimit !== undefined && { importLimit }),\n ...(importDisableJobsQueue !== undefined && {\n importDisableJobsQueue,\n }),\n ...(importBatchSize !== undefined && { importBatchSize }),\n ...(importDefaultVersionStatus !== undefined && {\n defaultVersionStatus: importDefaultVersionStatus,\n }),\n },\n }\n\n collection.admin.components = components\n }\n\n if (!config.i18n) {\n config.i18n = {}\n }\n\n /**\n * Merge plugin translations\n */\n const simplifiedTranslations = Object.entries(translations).reduce(\n (acc, [key, value]) => {\n acc[key] = value.translations\n return acc\n },\n {} as Record<string, PluginDefaultTranslationsObject>,\n )\n\n config.i18n = {\n ...config.i18n,\n translations: deepMergeSimple(simplifiedTranslations, config.i18n?.translations ?? {}),\n }\n\n return config\n }\n\ndeclare module 'payload' {\n export interface FieldCustom {\n 'plugin-import-export'?: {\n /**\n * When `true` the field is **completely excluded** from the import-export plugin:\n * - It will not appear in the \"Fields to export\" selector.\n * - It is hidden from the preview list when no specific fields are chosen.\n * - Its data is omitted from the final CSV / JSON export.\n * @default false\n */\n disabled?: boolean\n fromCSV?: FromCSVFunction\n /**\n * Custom function used to modify the outgoing csv data by manipulating the data, siblingData or by returning the desired value\n */\n toCSV?: ToCSVFunction\n }\n }\n\n export interface CollectionAdminCustom {\n 'plugin-import-export'?: {\n /**\n * Array of collection slugs that this export/import collection can target.\n * Used by CollectionField to populate the dropdown options.\n */\n collectionSlugs?: string[]\n /**\n * Array of field paths that are disabled for import/export.\n * These paths are collected from fields marked with `custom['plugin-import-export'].disabled = true`.\n */\n disabledFields?: string[]\n /**\n * If true, disables the download button in the export preview UI.\n */\n disableDownload?: boolean\n /**\n * If true, disables the save button in the export preview UI.\n */\n disableSave?: boolean\n /**\n * When set, forces exports from this collection to use this format.\n * This value is read from the plugin config's `export.format` option.\n */\n exportFormat?: 'csv' | 'json'\n }\n }\n\n export interface CollectionCustom {\n 'plugin-import-export'?: {\n /**\n * Default version status for imported documents when _status field is not provided.\n * Only applies to collections with versions enabled.\n * @default 'published'\n */\n defaultVersionStatus?: 'draft' | 'published'\n /**\n * Number of documents to process in each batch during export.\n * @default 100\n */\n exportBatchSize?: number\n /**\n * If true, disables the jobs queue for exports and runs them synchronously.\n * @default false\n */\n exportDisableJobsQueue?: boolean\n /**\n * Maximum number of documents that can be exported from this collection.\n * Set to 0 for unlimited (default). Can be a number or function.\n * Stored in collection.custom (server-only) since functions cannot be serialized to client.\n */\n exportLimit?: Limit\n /**\n * Number of documents to process in each batch during import.\n * @default 100\n */\n importBatchSize?: number\n /**\n * If true, disables the jobs queue for imports and runs them synchronously.\n * @default false\n */\n importDisableJobsQueue?: boolean\n /**\n * Maximum number of documents that can be imported to this collection.\n * Set to 0 for unlimited (default). Can be a number or function.\n * Stored in collection.custom (server-only) since functions cannot be serialized to client.\n */\n importLimit?: Limit\n }\n }\n}\n"],"names":["deepMergeSimple","getCreateCollectionExportTask","getCreateCollectionImportTask","translations","collectDisabledFieldPaths","getPluginCollections","importExportPlugin","pluginConfig","config","customExportSlugMap","customImportSlugMap","exportCollections","importCollections","baseExportCollection","baseImportCollection","allExportSlugs","Set","map","c","slug","allImportSlugs","collections","collection","slugExists","some","push","admin","components","providers","jobs","tasks","collectionConfigMap","Map","collectionConfig","set","collectionsToUpdate","filter","has","collectionPluginConfig","get","length","exportSlugForCollection","importSlugForCollection","exportDisabled","export","importDisabled","import","listMenuItems","clientProps","collectionSlug","exportCollectionSlug","path","importCollectionSlug","disabledFieldAccessors","fields","exportConfig","undefined","exportFormat","format","exportDisableJobsQueue","disableJobsQueue","exportBatchSize","batchSize","exportDisableSave","disableSave","exportDisableDownload","disableDownload","importConfig","importDisableJobsQueue","importBatchSize","exportLimit","limit","importLimit","importDefaultVersionStatus","defaultVersionStatus","custom","disabledFields","i18n","simplifiedTranslations","Object","entries","reduce","acc","key","value"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AAWzC,SAASC,6BAA6B,QAAQ,4CAA2C;AACzF,SAASC,6BAA6B,QAAQ,4CAA2C;AACzF,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,oBAAoB,QAAQ,sCAAqC;AAE1E,OAAO,MAAMC,qBACX,CAACC,eACD,OAAOC;QACL,mGAAmG;QACnG,MAAM,EAAEC,mBAAmB,EAAEC,mBAAmB,EAAEC,iBAAiB,EAAEC,iBAAiB,EAAE,GACtF,MAAMP,qBAAqB;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BAC3B,wBAAwB;oBACtB,GAAIrD,WAAWqD,MAAM,EAAE,CAAC,uBAAuB,IAAI,CAAC,CAAC;oBACrD,GAAIL,gBAAgBd,aAAa;wBAAEc;oBAAY,CAAC;oBAChD,GAAIX,2BAA2BH,aAAa;wBAC1CG;oBACF,CAAC;oBACD,GAAIE,oBAAoBL,aAAa;wBAAEK;oBAAgB,CAAC;oBACxD,GAAIW,gBAAgBhB,aAAa;wBAAEgB;oBAAY,CAAC;oBAChD,GAAIJ,2BAA2BZ,aAAa;wBAC1CY;oBACF,CAAC;oBACD,GAAIC,oBAAoBb,aAAa;wBAAEa;oBAAgB,CAAC;oBACxD,GAAII,+BAA+BjB,aAAa;wBAC9CkB,sBAAsBD;oBACxB,CAAC;gBACH;YACF;YAEAnD,WAAWI,KAAK,CAACC,UAAU,GAAGA;QAChC;QAEA,IAAI,CAACnB,OAAOqE,IAAI,EAAE;YAChBrE,OAAOqE,IAAI,GAAG,CAAC;QACjB;QAEA;;KAEC,GACD,MAAMC,yBAAyBC,OAAOC,OAAO,CAAC7E,cAAc8E,MAAM,CAChE,CAACC,KAAK,CAACC,KAAKC,MAAM;YAChBF,GAAG,CAACC,IAAI,GAAGC,MAAMjF,YAAY;YAC7B,OAAO+E;QACT,GACA,CAAC;QAGH1E,OAAOqE,IAAI,GAAG;YACZ,GAAGrE,OAAOqE,IAAI;YACd1E,cAAcH,gBAAgB8E,wBAAwBtE,OAAOqE,IAAI,EAAE1E,gBAAgB,CAAC;QACtF;QAEA,OAAOK;IACT,EAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -111,6 +111,12 @@ export type PluginCollectionConfig = {
|
|
|
111
111
|
* Configuration options for the Import/Export plugin
|
|
112
112
|
*/
|
|
113
113
|
export type ImportExportPluginConfig = {
|
|
114
|
+
/**
|
|
115
|
+
* Global default batch size for both import and export operations.
|
|
116
|
+
* Can be overridden at the collection level via `export.batchSize` or `import.batchSize`.
|
|
117
|
+
* @default 100
|
|
118
|
+
*/
|
|
119
|
+
batchSize?: number;
|
|
114
120
|
/**
|
|
115
121
|
* Collections to include the Import/Export controls in.
|
|
116
122
|
* If not specified, all collections will have import/export enabled.
|
|
@@ -122,6 +128,13 @@ export type ImportExportPluginConfig = {
|
|
|
122
128
|
* @default false
|
|
123
129
|
*/
|
|
124
130
|
debug?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Global default version status for imported documents when _status field is not provided.
|
|
133
|
+
* Only applies to collections with versions enabled.
|
|
134
|
+
* Can be overridden at the collection level via `import.defaultVersionStatus`.
|
|
135
|
+
* @default 'published'
|
|
136
|
+
*/
|
|
137
|
+
defaultVersionStatus?: 'draft' | 'published';
|
|
125
138
|
/**
|
|
126
139
|
* Global maximum for export operations.
|
|
127
140
|
* Can be a number or a function that returns a number based on request context.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE/E;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEvF;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG,aAAa,GAAG,MAAM,CAAA;AAE1C;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,EAChC,UAAU,GACX,EAAE;IACD,UAAU,EAAE,gBAAgB,CAAA;CAC7B,KAAK,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAElD,MAAM,MAAM,YAAY,GAAG;IACzB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;OAGG;IACH,gBAAgB,CAAC,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ent":["import type { CollectionConfig, CollectionSlug, PayloadRequest } from 'payload'\n\n/**\n * Function to dynamically determine the limit based on request context\n */\nexport type LimitFunction = (args: { req: PayloadRequest }) => number | Promise<number>\n\n/**\n * Limit configuration - either a hard number or a function.\n * Set to 0 for unlimited (no restriction). Default is 0.\n */\nexport type Limit = LimitFunction | number\n\n/**\n * Type for overriding import/export collection configurations\n */\nexport type CollectionOverride = ({\n collection,\n}: {\n collection: CollectionConfig\n}) => CollectionConfig | Promise<CollectionConfig>\n\nexport type ExportConfig = {\n /**\n * Number of documents to process in each batch during export. This config is applied to both jobs and synchronous exports.\n *\n * @default 100\n */\n batchSize?: number\n /**\n * If true, disables the download button in the export preview UI\n * @default false\n */\n disableDownload?: boolean\n /**\n * If true, disables the jobs queue for exports and runs them synchronously.\n * @default false\n */\n disableJobsQueue?: boolean\n /**\n * If true, disables the save button in the export preview UI\n * @default false\n */\n disableSave?: boolean\n /**\n * Forces a specific export format (`csv` or `json`) and hides the format dropdown from the UI.\n * When defined, this overrides the user's ability to choose a format manually.\n * If not set, the user can choose between CSV and JSON in the export UI.\n * @default undefined\n */\n format?: 'csv' | 'json'\n /**\n * Maximum number of documents that can be exported in a single operation.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Overrides the global exportLimit if set.\n */\n limit?: Limit\n /**\n * Override the export collection for this collection.\n *\n * @default true\n */\n overrideCollection?: CollectionOverride\n}\n\nexport type ImportConfig = {\n /**\n * Number of documents to process in each batch during import. This config is applied to both jobs and synchronous imports.\n *\n * @default 100\n */\n batchSize?: number\n /**\n * Default version status for imported documents when _status field is not provided.\n * Only applies to collections with versions enabled.\n * @default 'published'\n */\n defaultVersionStatus?: 'draft' | 'published'\n /**\n * If true, disables the jobs queue for imports and runs them synchronously.\n * @default false\n */\n disableJobsQueue?: boolean\n /**\n * Maximum number of documents that can be imported in a single operation.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Overrides the global importLimit if set.\n */\n limit?: Limit\n /**\n * Override the import collection for this collection.\n *\n * @default true\n */\n overrideCollection?: CollectionOverride\n}\n\nexport type PluginCollectionConfig = {\n /**\n * Override the import collection for this collection or disable it entirely with `false`.\n *\n * @default true\n */\n export?: boolean | ExportConfig\n /**\n * Override the export collection for this collection or disable it entirely with `false`.\n *\n * @default true\n */\n import?: boolean | ImportConfig\n /**\n * Target collection's slug for import/export functionality\n */\n slug: CollectionSlug\n}\n\n/**\n * Configuration options for the Import/Export plugin\n */\nexport type ImportExportPluginConfig = {\n /**\n * Collections to include the Import/Export controls in.\n * If not specified, all collections will have import/export enabled.\n * @default undefined (all collections)\n */\n collections: PluginCollectionConfig[]\n\n /**\n * Enable debug logging for troubleshooting import/export operations\n * @default false\n */\n debug?: boolean\n\n /**\n * Global maximum for export operations.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Per-collection limits take precedence.\n */\n exportLimit?: Limit\n\n /**\n * Global maximum for import operations.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Per-collection limits take precedence.\n */\n importLimit?: Limit\n\n /**\n * Function to override the default export collection configuration.\n * Takes the default export collection and allows you to modify and return it.\n * Useful for adding access control, changing upload directory, etc.\n *\n * This can also be set at the collection level via `export` config.\n */\n overrideExportCollection?: CollectionOverride\n\n /**\n * Function to override the default import collection configuration.\n * Takes the default import collection and allows you to modify and return it.\n * Useful for adding access control, changing upload directory, etc.\n *\n * This can also be set at the collection level via `import` config.\n */\n overrideImportCollection?: CollectionOverride\n}\n\n/**\n * Custom function used to modify the outgoing csv data by manipulating the data, siblingData or by returning the desired value\n */\nexport type ToCSVFunction = (args: {\n /**\n * The path of the column for the field, for arrays this includes the index (zero-based)\n */\n columnName: string\n /**\n * Alias for `row`, the object that accumulates CSV output.\n * Use this to write additional fields into the exported row.\n */\n data: Record<string, unknown>\n /**\n * The top level document\n */\n doc: Document\n /**\n * The object data that can be manipulated to assign data to the CSV\n */\n row: Record<string, unknown>\n /**\n * The document data at the level where it belongs\n */\n siblingDoc: Record<string, unknown>\n /**\n * The data for the field.\n */\n value: unknown\n}) => unknown\n\n/**\n * Custom function used to transform incoming CSV data during import\n */\nexport type FromCSVFunction = (args: {\n /**\n * The path of the column for the field\n */\n columnName: string\n /**\n * The current row data being processed\n */\n data: Record<string, unknown>\n /**\n * The value being imported for this field\n */\n value: unknown\n}) => unknown\n\n/**\n * Base pagination data returned from preview endpoints\n */\nexport type PreviewPaginationData = {\n /**\n * Whether there is a next page available\n */\n hasNextPage: boolean\n /**\n * Whether there is a previous page available\n */\n hasPrevPage: boolean\n /**\n * Number of documents per page\n */\n limit: number\n /**\n * The resolved max limit value (max documents allowed), if any\n */\n maxLimit?: number\n /**\n * Current page number (1-indexed)\n */\n page: number\n /**\n * Total number of documents\n */\n totalDocs: number\n /**\n * Total number of pages\n */\n totalPages: number\n}\n\n/**\n * Response from export preview endpoint\n */\nexport type ExportPreviewResponse = {\n /**\n * Column names for CSV format (undefined for JSON)\n */\n columns?: string[]\n /**\n * Preview documents (transformed for display)\n */\n docs: Record<string, unknown>[]\n /**\n * Actual count of docs that will be exported (respects export limit)\n */\n exportTotalDocs: number\n} & PreviewPaginationData\n\n/**\n * Response from import preview endpoint\n */\nexport type ImportPreviewResponse = {\n /**\n * Preview documents parsed from the import file\n */\n docs: Record<string, unknown>[]\n /**\n * Whether the file exceeds the max limit\n */\n limitExceeded?: boolean\n} & PreviewPaginationData\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { CollectionConfig, CollectionSlug, PayloadRequest } from 'payload'\n\n/**\n * Function to dynamically determine the limit based on request context\n */\nexport type LimitFunction = (args: { req: PayloadRequest }) => number | Promise<number>\n\n/**\n * Limit configuration - either a hard number or a function.\n * Set to 0 for unlimited (no restriction). Default is 0.\n */\nexport type Limit = LimitFunction | number\n\n/**\n * Type for overriding import/export collection configurations\n */\nexport type CollectionOverride = ({\n collection,\n}: {\n collection: CollectionConfig\n}) => CollectionConfig | Promise<CollectionConfig>\n\nexport type ExportConfig = {\n /**\n * Number of documents to process in each batch during export. This config is applied to both jobs and synchronous exports.\n *\n * @default 100\n */\n batchSize?: number\n /**\n * If true, disables the download button in the export preview UI\n * @default false\n */\n disableDownload?: boolean\n /**\n * If true, disables the jobs queue for exports and runs them synchronously.\n * @default false\n */\n disableJobsQueue?: boolean\n /**\n * If true, disables the save button in the export preview UI\n * @default false\n */\n disableSave?: boolean\n /**\n * Forces a specific export format (`csv` or `json`) and hides the format dropdown from the UI.\n * When defined, this overrides the user's ability to choose a format manually.\n * If not set, the user can choose between CSV and JSON in the export UI.\n * @default undefined\n */\n format?: 'csv' | 'json'\n /**\n * Maximum number of documents that can be exported in a single operation.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Overrides the global exportLimit if set.\n */\n limit?: Limit\n /**\n * Override the export collection for this collection.\n *\n * @default true\n */\n overrideCollection?: CollectionOverride\n}\n\nexport type ImportConfig = {\n /**\n * Number of documents to process in each batch during import. This config is applied to both jobs and synchronous imports.\n *\n * @default 100\n */\n batchSize?: number\n /**\n * Default version status for imported documents when _status field is not provided.\n * Only applies to collections with versions enabled.\n * @default 'published'\n */\n defaultVersionStatus?: 'draft' | 'published'\n /**\n * If true, disables the jobs queue for imports and runs them synchronously.\n * @default false\n */\n disableJobsQueue?: boolean\n /**\n * Maximum number of documents that can be imported in a single operation.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Overrides the global importLimit if set.\n */\n limit?: Limit\n /**\n * Override the import collection for this collection.\n *\n * @default true\n */\n overrideCollection?: CollectionOverride\n}\n\nexport type PluginCollectionConfig = {\n /**\n * Override the import collection for this collection or disable it entirely with `false`.\n *\n * @default true\n */\n export?: boolean | ExportConfig\n /**\n * Override the export collection for this collection or disable it entirely with `false`.\n *\n * @default true\n */\n import?: boolean | ImportConfig\n /**\n * Target collection's slug for import/export functionality\n */\n slug: CollectionSlug\n}\n\n/**\n * Configuration options for the Import/Export plugin\n */\nexport type ImportExportPluginConfig = {\n /**\n * Global default batch size for both import and export operations.\n * Can be overridden at the collection level via `export.batchSize` or `import.batchSize`.\n * @default 100\n */\n batchSize?: number\n\n /**\n * Collections to include the Import/Export controls in.\n * If not specified, all collections will have import/export enabled.\n * @default undefined (all collections)\n */\n collections: PluginCollectionConfig[]\n\n /**\n * Enable debug logging for troubleshooting import/export operations\n * @default false\n */\n debug?: boolean\n\n /**\n * Global default version status for imported documents when _status field is not provided.\n * Only applies to collections with versions enabled.\n * Can be overridden at the collection level via `import.defaultVersionStatus`.\n * @default 'published'\n */\n defaultVersionStatus?: 'draft' | 'published'\n\n /**\n * Global maximum for export operations.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Per-collection limits take precedence.\n */\n exportLimit?: Limit\n\n /**\n * Global maximum for import operations.\n * Can be a number or a function that returns a number based on request context.\n * Set to 0 for unlimited (default). Per-collection limits take precedence.\n */\n importLimit?: Limit\n\n /**\n * Function to override the default export collection configuration.\n * Takes the default export collection and allows you to modify and return it.\n * Useful for adding access control, changing upload directory, etc.\n *\n * This can also be set at the collection level via `export` config.\n */\n overrideExportCollection?: CollectionOverride\n\n /**\n * Function to override the default import collection configuration.\n * Takes the default import collection and allows you to modify and return it.\n * Useful for adding access control, changing upload directory, etc.\n *\n * This can also be set at the collection level via `import` config.\n */\n overrideImportCollection?: CollectionOverride\n}\n\n/**\n * Custom function used to modify the outgoing csv data by manipulating the data, siblingData or by returning the desired value\n */\nexport type ToCSVFunction = (args: {\n /**\n * The path of the column for the field, for arrays this includes the index (zero-based)\n */\n columnName: string\n /**\n * Alias for `row`, the object that accumulates CSV output.\n * Use this to write additional fields into the exported row.\n */\n data: Record<string, unknown>\n /**\n * The top level document\n */\n doc: Document\n /**\n * The object data that can be manipulated to assign data to the CSV\n */\n row: Record<string, unknown>\n /**\n * The document data at the level where it belongs\n */\n siblingDoc: Record<string, unknown>\n /**\n * The data for the field.\n */\n value: unknown\n}) => unknown\n\n/**\n * Custom function used to transform incoming CSV data during import\n */\nexport type FromCSVFunction = (args: {\n /**\n * The path of the column for the field\n */\n columnName: string\n /**\n * The current row data being processed\n */\n data: Record<string, unknown>\n /**\n * The value being imported for this field\n */\n value: unknown\n}) => unknown\n\n/**\n * Base pagination data returned from preview endpoints\n */\nexport type PreviewPaginationData = {\n /**\n * Whether there is a next page available\n */\n hasNextPage: boolean\n /**\n * Whether there is a previous page available\n */\n hasPrevPage: boolean\n /**\n * Number of documents per page\n */\n limit: number\n /**\n * The resolved max limit value (max documents allowed), if any\n */\n maxLimit?: number\n /**\n * Current page number (1-indexed)\n */\n page: number\n /**\n * Total number of documents\n */\n totalDocs: number\n /**\n * Total number of pages\n */\n totalPages: number\n}\n\n/**\n * Response from export preview endpoint\n */\nexport type ExportPreviewResponse = {\n /**\n * Column names for CSV format (undefined for JSON)\n */\n columns?: string[]\n /**\n * Preview documents (transformed for display)\n */\n docs: Record<string, unknown>[]\n /**\n * Actual count of docs that will be exported (respects export limit)\n */\n exportTotalDocs: number\n} & PreviewPaginationData\n\n/**\n * Response from import preview endpoint\n */\nexport type ImportPreviewResponse = {\n /**\n * Preview documents parsed from the import file\n */\n docs: Record<string, unknown>[]\n /**\n * Whether the file exceeds the max limit\n */\n limitExceeded?: boolean\n} & PreviewPaginationData\n"],"names":[],"mappings":"AA0RA;;CAEC,GACD,WASyB"}
|
|
@@ -27,7 +27,10 @@ export type PluginCollectionsResult = {
|
|
|
27
27
|
* - Applies top-level overrideExportCollection/overrideImportCollection if provided
|
|
28
28
|
* - For each collection in `pluginConfig.collections` that has a function override
|
|
29
29
|
* for `export` or `import`, applies the override to create customized collections
|
|
30
|
-
*
|
|
30
|
+
*
|
|
31
|
+
* Note: Per-collection settings (disableJobsQueue, batchSize, etc.) are stored on the
|
|
32
|
+
* target collection's `custom['plugin-import-export']` and looked up dynamically at
|
|
33
|
+
* runtime in the export/import hooks.
|
|
31
34
|
*
|
|
32
35
|
* @param config - The Payload config
|
|
33
36
|
* @param pluginConfig - The import/export plugin config
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPluginCollections.d.ts","sourceRoot":"","sources":["../../src/utilities/getPluginCollections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEvD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"getPluginCollections.d.ts","sourceRoot":"","sources":["../../src/utilities/getPluginCollections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAK3D,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;OAGG;IACH,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC;;;OAGG;IACH,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC;;OAEG;IACH,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;IACrC;;OAEG;IACH,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;CACtC,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,8BAG9B;IACD,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,wBAAwB,CAAA;CACvC,KAAG,OAAO,CAAC,uBAAuB,CAyLlC,CAAA"}
|
|
@@ -7,7 +7,10 @@ import { getImportCollection } from '../import/getImportCollection.js';
|
|
|
7
7
|
* - Applies top-level overrideExportCollection/overrideImportCollection if provided
|
|
8
8
|
* - For each collection in `pluginConfig.collections` that has a function override
|
|
9
9
|
* for `export` or `import`, applies the override to create customized collections
|
|
10
|
-
*
|
|
10
|
+
*
|
|
11
|
+
* Note: Per-collection settings (disableJobsQueue, batchSize, etc.) are stored on the
|
|
12
|
+
* target collection's `custom['plugin-import-export']` and looked up dynamically at
|
|
13
|
+
* runtime in the export/import hooks.
|
|
11
14
|
*
|
|
12
15
|
* @param config - The Payload config
|
|
13
16
|
* @param pluginConfig - The import/export plugin config
|
|
@@ -137,48 +140,6 @@ import { getImportCollection } from '../import/getImportCollection.js';
|
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
|
-
// Apply settings from collections without overrideCollection to the base collection
|
|
141
|
-
// This is done AFTER all overrides so these settings take precedence
|
|
142
|
-
if (pluginConfig.collections && pluginConfig.collections.length > 0) {
|
|
143
|
-
let mergedExportSettings = {};
|
|
144
|
-
let mergedImportSettings = {};
|
|
145
|
-
for (const collectionConfig of pluginConfig.collections){
|
|
146
|
-
const exportConf = typeof collectionConfig.export === 'object' ? collectionConfig.export : undefined;
|
|
147
|
-
const importConf = typeof collectionConfig.import === 'object' ? collectionConfig.import : undefined;
|
|
148
|
-
if (exportConf && !exportConf.overrideCollection) {
|
|
149
|
-
mergedExportSettings = {
|
|
150
|
-
...mergedExportSettings,
|
|
151
|
-
...exportConf
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
if (importConf && !importConf.overrideCollection) {
|
|
155
|
-
mergedImportSettings = {
|
|
156
|
-
...mergedImportSettings,
|
|
157
|
-
...importConf
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (mergedExportSettings.format !== undefined || mergedExportSettings.disableSave !== undefined || mergedExportSettings.disableDownload !== undefined) {
|
|
162
|
-
baseExportCollection = {
|
|
163
|
-
...baseExportCollection,
|
|
164
|
-
admin: {
|
|
165
|
-
...baseExportCollection.admin,
|
|
166
|
-
custom: {
|
|
167
|
-
...baseExportCollection.admin?.custom,
|
|
168
|
-
...mergedExportSettings.disableDownload !== undefined && {
|
|
169
|
-
disableDownload: mergedExportSettings.disableDownload
|
|
170
|
-
},
|
|
171
|
-
...mergedExportSettings.disableSave !== undefined && {
|
|
172
|
-
disableSave: mergedExportSettings.disableSave
|
|
173
|
-
},
|
|
174
|
-
...mergedExportSettings.format !== undefined && {
|
|
175
|
-
format: mergedExportSettings.format
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
143
|
// Filter out slugs that have custom export/import collections from the base collections
|
|
183
144
|
// Collections with custom collections should ONLY be exportable/importable through those
|
|
184
145
|
const filteredExportSlugs = baseExportSlugs.filter((slug)=>!customExportSlugMap.has(slug));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/getPluginCollections.ts"],"sourcesContent":["import type { CollectionConfig, Config } from 'payload'\n\nimport type { ExportConfig, ImportConfig, ImportExportPluginConfig } from '../types.js'\n\nimport { getExportCollection } from '../export/getExportCollection.js'\nimport { getImportCollection } from '../import/getImportCollection.js'\n\nexport type PluginCollectionsResult = {\n /**\n * Map from target collection slug to the export collection slug to use for it.\n * Only contains entries for collections with custom export collection overrides.\n */\n customExportSlugMap: Map<string, string>\n /**\n * Map from target collection slug to the import collection slug to use for it.\n * Only contains entries for collections with custom import collection overrides.\n */\n customImportSlugMap: Map<string, string>\n /**\n * All export collections (base + any per-collection overrides)\n */\n exportCollections: CollectionConfig[]\n /**\n * All import collections (base + any per-collection overrides)\n */\n importCollections: CollectionConfig[]\n}\n\n/**\n * Processes the plugin config and returns export/import collections.\n *\n * - Creates the base export and import collections\n * - Applies top-level overrideExportCollection/overrideImportCollection if provided\n * - For each collection in `pluginConfig.collections` that has a function override\n * for `export` or `import`, applies the override to create customized collections\n * - Applies settings from collections without overrideCollection to the base collection\n *\n * @param config - The Payload config\n * @param pluginConfig - The import/export plugin config\n * @returns Object containing arrays of export and import collections\n */\nexport const getPluginCollections = async ({\n config,\n pluginConfig,\n}: {\n config: Config\n pluginConfig: ImportExportPluginConfig\n}): Promise<PluginCollectionsResult> => {\n // Calculate collection slugs for base export/import collections\n // If pluginConfig.collections is provided, filter by export/import !== false\n // Otherwise, use all config collections\n let baseExportSlugs: string[]\n let baseImportSlugs: string[]\n\n if (pluginConfig.collections && pluginConfig.collections.length > 0) {\n baseExportSlugs = pluginConfig.collections.filter((c) => c.export !== false).map((c) => c.slug)\n baseImportSlugs = pluginConfig.collections.filter((c) => c.import !== false).map((c) => c.slug)\n } else {\n // Fall back to all collections\n const allSlugs = config.collections?.map((c) => c.slug) || []\n baseExportSlugs = allSlugs\n baseImportSlugs = allSlugs\n }\n\n let baseExportCollection = getExportCollection({\n collectionSlugs: baseExportSlugs,\n config,\n pluginConfig,\n })\n let baseImportCollection = getImportCollection({\n collectionSlugs: baseImportSlugs,\n pluginConfig,\n })\n\n if (\n pluginConfig.overrideExportCollection &&\n typeof pluginConfig.overrideExportCollection === 'function'\n ) {\n baseExportCollection = await pluginConfig.overrideExportCollection({\n collection: baseExportCollection,\n })\n }\n\n if (\n pluginConfig.overrideImportCollection &&\n typeof pluginConfig.overrideImportCollection === 'function'\n ) {\n baseImportCollection = await pluginConfig.overrideImportCollection({\n collection: baseImportCollection,\n })\n }\n\n const exportCollections: CollectionConfig[] = []\n const importCollections: CollectionConfig[] = []\n\n const customExportSlugMap = new Map<string, string>()\n const customImportSlugMap = new Map<string, string>()\n\n // Process each collection config for custom collection overrides\n if (pluginConfig.collections && pluginConfig.collections.length > 0) {\n for (const collectionConfig of pluginConfig.collections) {\n const exportConfig =\n typeof collectionConfig.export === 'object' ? collectionConfig.export : undefined\n\n if (exportConfig?.overrideCollection) {\n // Create collection specific to this target collection\n const collection = getExportCollection({\n collectionSlugs: [collectionConfig.slug],\n config,\n exportConfig,\n pluginConfig,\n })\n\n // Call override once to determine user intent\n const overridden = await exportConfig.overrideCollection({ collection })\n\n // If the slug changed, this is a separate collection; otherwise it modifies the base\n if (overridden.slug !== baseExportCollection.slug) {\n exportCollections.push(overridden)\n customExportSlugMap.set(collectionConfig.slug, overridden.slug)\n } else {\n // Slug didn't change - merge settings into base collection while preserving all slugs\n baseExportCollection = {\n ...baseExportCollection,\n ...overridden,\n admin: {\n ...baseExportCollection.admin,\n ...overridden.admin,\n custom: {\n ...baseExportCollection.admin?.custom,\n ...overridden.admin?.custom,\n 'plugin-import-export': {\n ...overridden.admin?.custom?.['plugin-import-export'],\n ...baseExportCollection.admin?.custom?.['plugin-import-export'],\n // Ensure base collection's slug list is preserved\n collectionSlugs:\n baseExportCollection.admin?.custom?.['plugin-import-export']?.collectionSlugs,\n },\n },\n },\n }\n }\n }\n\n const importConf =\n typeof collectionConfig.import === 'object' ? collectionConfig.import : undefined\n\n if (importConf?.overrideCollection) {\n // Create collection specific to this target collection\n const collection = getImportCollection({\n collectionSlugs: [collectionConfig.slug],\n importConfig: importConf,\n pluginConfig,\n })\n\n // Call override once to determine user intent\n const overridden = await importConf.overrideCollection({ collection })\n\n // If the slug changed, this is a separate collection; otherwise it modifies the base\n if (overridden.slug !== baseImportCollection.slug) {\n importCollections.push(overridden)\n // Map this target collection to its custom import collection\n customImportSlugMap.set(collectionConfig.slug, overridden.slug)\n } else {\n // Slug didn't change - merge settings into base collection while preserving all slugs\n baseImportCollection = {\n ...baseImportCollection,\n ...overridden,\n admin: {\n ...baseImportCollection.admin,\n ...overridden.admin,\n custom: {\n ...baseImportCollection.admin?.custom,\n ...overridden.admin?.custom,\n 'plugin-import-export': {\n ...overridden.admin?.custom?.['plugin-import-export'],\n ...baseImportCollection.admin?.custom?.['plugin-import-export'],\n // Ensure base collection's slug list is preserved\n collectionSlugs:\n baseImportCollection.admin?.custom?.['plugin-import-export']?.collectionSlugs,\n },\n },\n },\n }\n }\n }\n }\n }\n\n // Apply settings from collections without overrideCollection to the base collection\n // This is done AFTER all overrides so these settings take precedence\n if (pluginConfig.collections && pluginConfig.collections.length > 0) {\n let mergedExportSettings: Partial<ExportConfig> = {}\n let mergedImportSettings: Partial<ImportConfig> = {}\n\n for (const collectionConfig of pluginConfig.collections) {\n const exportConf =\n typeof collectionConfig.export === 'object' ? collectionConfig.export : undefined\n const importConf =\n typeof collectionConfig.import === 'object' ? collectionConfig.import : undefined\n\n if (exportConf && !exportConf.overrideCollection) {\n mergedExportSettings = { ...mergedExportSettings, ...exportConf }\n }\n if (importConf && !importConf.overrideCollection) {\n mergedImportSettings = { ...mergedImportSettings, ...importConf }\n }\n }\n\n if (\n mergedExportSettings.format !== undefined ||\n mergedExportSettings.disableSave !== undefined ||\n mergedExportSettings.disableDownload !== undefined\n ) {\n baseExportCollection = {\n ...baseExportCollection,\n admin: {\n ...baseExportCollection.admin,\n custom: {\n ...baseExportCollection.admin?.custom,\n ...(mergedExportSettings.disableDownload !== undefined && {\n disableDownload: mergedExportSettings.disableDownload,\n }),\n ...(mergedExportSettings.disableSave !== undefined && {\n disableSave: mergedExportSettings.disableSave,\n }),\n ...(mergedExportSettings.format !== undefined && {\n format: mergedExportSettings.format,\n }),\n },\n },\n }\n }\n }\n\n // Filter out slugs that have custom export/import collections from the base collections\n // Collections with custom collections should ONLY be exportable/importable through those\n const filteredExportSlugs = baseExportSlugs.filter((slug) => !customExportSlugMap.has(slug))\n const filteredImportSlugs = baseImportSlugs.filter((slug) => !customImportSlugMap.has(slug))\n\n // Update base collections with filtered slugs\n baseExportCollection = {\n ...baseExportCollection,\n admin: {\n ...baseExportCollection.admin,\n custom: {\n ...baseExportCollection.admin?.custom,\n 'plugin-import-export': {\n ...baseExportCollection.admin?.custom?.['plugin-import-export'],\n collectionSlugs: filteredExportSlugs,\n },\n },\n },\n }\n\n baseImportCollection = {\n ...baseImportCollection,\n admin: {\n ...baseImportCollection.admin,\n custom: {\n ...baseImportCollection.admin?.custom,\n 'plugin-import-export': {\n ...baseImportCollection.admin?.custom?.['plugin-import-export'],\n collectionSlugs: filteredImportSlugs,\n },\n },\n },\n }\n\n exportCollections.unshift(baseExportCollection)\n importCollections.unshift(baseImportCollection)\n\n return {\n customExportSlugMap,\n customImportSlugMap,\n exportCollections,\n importCollections,\n }\n}\n"],"names":["getExportCollection","getImportCollection","getPluginCollections","config","pluginConfig","baseExportSlugs","baseImportSlugs","collections","length","filter","c","export","map","slug","import","allSlugs","baseExportCollection","collectionSlugs","baseImportCollection","overrideExportCollection","collection","overrideImportCollection","exportCollections","importCollections","customExportSlugMap","Map","customImportSlugMap","collectionConfig","exportConfig","undefined","overrideCollection","overridden","push","set","admin","custom","importConf","importConfig","mergedExportSettings","mergedImportSettings","exportConf","format","disableSave","disableDownload","filteredExportSlugs","has","filteredImportSlugs","unshift"],"mappings":"AAIA,SAASA,mBAAmB,QAAQ,mCAAkC;AACtE,SAASC,mBAAmB,QAAQ,mCAAkC;AAuBtE;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,uBAAuB,OAAO,EACzCC,MAAM,EACNC,YAAY,EAIb;IACC,gEAAgE;IAChE,6EAA6E;IAC7E,wCAAwC;IACxC,IAAIC;IACJ,IAAIC;IAEJ,IAAIF,aAAaG,WAAW,IAAIH,aAAaG,WAAW,CAACC,MAAM,GAAG,GAAG;QACnEH,kBAAkBD,aAAaG,WAAW,CAACE,MAAM,CAAC,CAACC,IAAMA,EAAEC,MAAM,KAAK,OAAOC,GAAG,CAAC,CAACF,IAAMA,EAAEG,IAAI;QAC9FP,kBAAkBF,aAAaG,WAAW,CAACE,MAAM,CAAC,CAACC,IAAMA,EAAEI,MAAM,KAAK,OAAOF,GAAG,CAAC,CAACF,IAAMA,EAAEG,IAAI;IAChG,OAAO;QACL,+BAA+B;QAC/B,MAAME,WAAWZ,OAAOI,WAAW,EAAEK,IAAI,CAACF,IAAMA,EAAEG,IAAI,KAAK,EAAE;QAC7DR,kBAAkBU;QAClBT,kBAAkBS;IACpB;IAEA,IAAIC,uBAAuBhB,oBAAoB;QAC7CiB,iBAAiBZ;QACjBF;QACAC;IACF;IACA,IAAIc,uBAAuBjB,oBAAoB;QAC7CgB,iBAAiBX;QACjBF;IACF;IAEA,IACEA,aAAae,wBAAwB,IACrC,OAAOf,aAAae,wBAAwB,KAAK,YACjD;QACAH,uBAAuB,MAAMZ,aAAae,wBAAwB,CAAC;YACjEC,YAAYJ;QACd;IACF;IAEA,IACEZ,aAAai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AAG,CAAChC;IACtF,MAAMiC,sBAAsBxC,gBAAgBG,MAAM,CAAC,CAACI,OAAS,CAACa,oBAAoBmB,GAAG,CAAChC;IAEtF,8CAA8C;IAC9CG,uBAAuB;QACrB,GAAGA,oBAAoB;QACvBkB,OAAO;YACL,GAAGlB,qBAAqBkB,KAAK;YAC7BC,QAAQ;gBACN,GAAGnB,qBAAqBkB,KAAK,EAAEC,MAAM;gBACrC,wBAAwB;oBACtB,GAAGnB,qBAAqBkB,KAAK,EAAEC,QAAQ,CAAC,uBAAuB;oBAC/DlB,iBAAiB2B;gBACnB;YACF;QACF;IACF;IAEA1B,uBAAuB;QACrB,GAAGA,oBAAoB;QACvBgB,OAAO;YACL,GAAGhB,qBAAqBgB,KAAK;YAC7BC,QAAQ;gBACN,GAAGjB,qBAAqBgB,KAAK,EAAEC,MAAM;gBACrC,wBAAwB;oBACtB,GAAGjB,qBAAqBgB,KAAK,EAAEC,QAAQ,CAAC,uBAAuB;oBAC/DlB,iBAAiB6B;gBACnB;YACF;QACF;IACF;IAEAxB,kBAAkByB,OAAO,CAAC/B;IAC1BO,kBAAkBwB,OAAO,CAAC7B;IAE1B,OAAO;QACLM;QACAE;QACAJ;QACAC;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getPluginCollections.ts"],"sourcesContent":["import type { CollectionConfig, Config } from 'payload'\n\nimport type { ImportExportPluginConfig } from '../types.js'\n\nimport { getExportCollection } from '../export/getExportCollection.js'\nimport { getImportCollection } from '../import/getImportCollection.js'\n\nexport type PluginCollectionsResult = {\n /**\n * Map from target collection slug to the export collection slug to use for it.\n * Only contains entries for collections with custom export collection overrides.\n */\n customExportSlugMap: Map<string, string>\n /**\n * Map from target collection slug to the import collection slug to use for it.\n * Only contains entries for collections with custom import collection overrides.\n */\n customImportSlugMap: Map<string, string>\n /**\n * All export collections (base + any per-collection overrides)\n */\n exportCollections: CollectionConfig[]\n /**\n * All import collections (base + any per-collection overrides)\n */\n importCollections: CollectionConfig[]\n}\n\n/**\n * Processes the plugin config and returns export/import collections.\n *\n * - Creates the base export and import collections\n * - Applies top-level overrideExportCollection/overrideImportCollection if provided\n * - For each collection in `pluginConfig.collections` that has a function override\n * for `export` or `import`, applies the override to create customized collections\n *\n * Note: Per-collection settings (disableJobsQueue, batchSize, etc.) are stored on the\n * target collection's `custom['plugin-import-export']` and looked up dynamically at\n * runtime in the export/import hooks.\n *\n * @param config - The Payload config\n * @param pluginConfig - The import/export plugin config\n * @returns Object containing arrays of export and import collections\n */\nexport const getPluginCollections = async ({\n config,\n pluginConfig,\n}: {\n config: Config\n pluginConfig: ImportExportPluginConfig\n}): Promise<PluginCollectionsResult> => {\n // Calculate collection slugs for base export/import collections\n // If pluginConfig.collections is provided, filter by export/import !== false\n // Otherwise, use all config collections\n let baseExportSlugs: string[]\n let baseImportSlugs: string[]\n\n if (pluginConfig.collections && pluginConfig.collections.length > 0) {\n baseExportSlugs = pluginConfig.collections.filter((c) => c.export !== false).map((c) => c.slug)\n baseImportSlugs = pluginConfig.collections.filter((c) => c.import !== false).map((c) => c.slug)\n } else {\n // Fall back to all collections\n const allSlugs = config.collections?.map((c) => c.slug) || []\n baseExportSlugs = allSlugs\n baseImportSlugs = allSlugs\n }\n\n let baseExportCollection = getExportCollection({\n collectionSlugs: baseExportSlugs,\n config,\n pluginConfig,\n })\n let baseImportCollection = getImportCollection({\n collectionSlugs: baseImportSlugs,\n pluginConfig,\n })\n\n if (\n pluginConfig.overrideExportCollection &&\n typeof pluginConfig.overrideExportCollection === 'function'\n ) {\n baseExportCollection = await pluginConfig.overrideExportCollection({\n collection: baseExportCollection,\n })\n }\n\n if (\n pluginConfig.overrideImportCollection &&\n typeof pluginConfig.overrideImportCollection === 'function'\n ) {\n baseImportCollection = await pluginConfig.overrideImportCollection({\n collection: baseImportCollection,\n })\n }\n\n const exportCollections: CollectionConfig[] = []\n const importCollections: CollectionConfig[] = []\n\n const customExportSlugMap = new Map<string, string>()\n const customImportSlugMap = new Map<string, string>()\n\n // Process each collection config for custom collection overrides\n if (pluginConfig.collections && pluginConfig.collections.length > 0) {\n for (const collectionConfig of pluginConfig.collections) {\n const exportConfig =\n typeof collectionConfig.export === 'object' ? collectionConfig.export : undefined\n\n if (exportConfig?.overrideCollection) {\n // Create collection specific to this target collection\n const collection = getExportCollection({\n collectionSlugs: [collectionConfig.slug],\n config,\n exportConfig,\n pluginConfig,\n })\n\n // Call override once to determine user intent\n const overridden = await exportConfig.overrideCollection({ collection })\n\n // If the slug changed, this is a separate collection; otherwise it modifies the base\n if (overridden.slug !== baseExportCollection.slug) {\n exportCollections.push(overridden)\n customExportSlugMap.set(collectionConfig.slug, overridden.slug)\n } else {\n // Slug didn't change - merge settings into base collection while preserving all slugs\n baseExportCollection = {\n ...baseExportCollection,\n ...overridden,\n admin: {\n ...baseExportCollection.admin,\n ...overridden.admin,\n custom: {\n ...baseExportCollection.admin?.custom,\n ...overridden.admin?.custom,\n 'plugin-import-export': {\n ...overridden.admin?.custom?.['plugin-import-export'],\n ...baseExportCollection.admin?.custom?.['plugin-import-export'],\n // Ensure base collection's slug list is preserved\n collectionSlugs:\n baseExportCollection.admin?.custom?.['plugin-import-export']?.collectionSlugs,\n },\n },\n },\n }\n }\n }\n\n const importConf =\n typeof collectionConfig.import === 'object' ? collectionConfig.import : undefined\n\n if (importConf?.overrideCollection) {\n // Create collection specific to this target collection\n const collection = getImportCollection({\n collectionSlugs: [collectionConfig.slug],\n importConfig: importConf,\n pluginConfig,\n })\n\n // Call override once to determine user intent\n const overridden = await importConf.overrideCollection({ collection })\n\n // If the slug changed, this is a separate collection; otherwise it modifies the base\n if (overridden.slug !== baseImportCollection.slug) {\n importCollections.push(overridden)\n // Map this target collection to its custom import collection\n customImportSlugMap.set(collectionConfig.slug, overridden.slug)\n } else {\n // Slug didn't change - merge settings into base collection while preserving all slugs\n baseImportCollection = {\n ...baseImportCollection,\n ...overridden,\n admin: {\n ...baseImportCollection.admin,\n ...overridden.admin,\n custom: {\n ...baseImportCollection.admin?.custom,\n ...overridden.admin?.custom,\n 'plugin-import-export': {\n ...overridden.admin?.custom?.['plugin-import-export'],\n ...baseImportCollection.admin?.custom?.['plugin-import-export'],\n // Ensure base collection's slug list is preserved\n collectionSlugs:\n baseImportCollection.admin?.custom?.['plugin-import-export']?.collectionSlugs,\n },\n },\n },\n }\n }\n }\n }\n }\n\n // Filter out slugs that have custom export/import collections from the base collections\n // Collections with custom collections should ONLY be exportable/importable through those\n const filteredExportSlugs = baseExportSlugs.filter((slug) => !customExportSlugMap.has(slug))\n const filteredImportSlugs = baseImportSlugs.filter((slug) => !customImportSlugMap.has(slug))\n\n // Update base collections with filtered slugs\n baseExportCollection = {\n ...baseExportCollection,\n admin: {\n ...baseExportCollection.admin,\n custom: {\n ...baseExportCollection.admin?.custom,\n 'plugin-import-export': {\n ...baseExportCollection.admin?.custom?.['plugin-import-export'],\n collectionSlugs: filteredExportSlugs,\n },\n },\n },\n }\n\n baseImportCollection = {\n ...baseImportCollection,\n admin: {\n ...baseImportCollection.admin,\n custom: {\n ...baseImportCollection.admin?.custom,\n 'plugin-import-export': {\n ...baseImportCollection.admin?.custom?.['plugin-import-export'],\n collectionSlugs: filteredImportSlugs,\n },\n },\n },\n }\n\n exportCollections.unshift(baseExportCollection)\n importCollections.unshift(baseImportCollection)\n\n return {\n customExportSlugMap,\n customImportSlugMap,\n exportCollections,\n importCollections,\n }\n}\n"],"names":["getExportCollection","getImportCollection","getPluginCollections","config","pluginConfig","baseExportSlugs","baseImportSlugs","collections","length","filter","c","export","map","slug","import","allSlugs","baseExportCollection","collectionSlugs","baseImportCollection","overrideExportCollection","collection","overrideImportCollection","exportCollections","importCollections","customExportSlugMap","Map","customImportSlugMap","collectionConfig","exportConfig","undefined","overrideCollection","overridden","push","set","admin","custom","importConf","importConfig","filteredExportSlugs","has","filteredImportSlugs","unshift"],"mappings":"AAIA,SAASA,mBAAmB,QAAQ,mCAAkC;AACtE,SAASC,mBAAmB,QAAQ,mCAAkC;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BAAqBkB,KAAK,EAAEC,MAAM;gBACrC,wBAAwB;oBACtB,GAAGnB,qBAAqBkB,KAAK,EAAEC,QAAQ,CAAC,uBAAuB;oBAC/DlB,iBAAiBqB;gBACnB;YACF;QACF;IACF;IAEApB,uBAAuB;QACrB,GAAGA,oBAAoB;QACvBgB,OAAO;YACL,GAAGhB,qBAAqBgB,KAAK;YAC7BC,QAAQ;gBACN,GAAGjB,qBAAqBgB,KAAK,EAAEC,MAAM;gBACrC,wBAAwB;oBACtB,GAAGjB,qBAAqBgB,KAAK,EAAEC,QAAQ,CAAC,uBAAuB;oBAC/DlB,iBAAiBuB;gBACnB;YACF;QACF;IACF;IAEAlB,kBAAkBmB,OAAO,CAACzB;IAC1BO,kBAAkBkB,OAAO,CAACvB;IAE1B,OAAO;QACLM;QACAE;QACAJ;QACAC;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unflattenObject.d.ts","sourceRoot":"","sources":["../../src/utilities/unflattenObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAClD,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,6CAKzB,aAAa,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"unflattenObject.d.ts","sourceRoot":"","sources":["../../src/utilities/unflattenObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAClD,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,6CAKzB,aAAa,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CA0SxC,CAAA"}
|
|
@@ -36,6 +36,11 @@ import { processRichTextField } from './processRichTextField.js';
|
|
|
36
36
|
if (value === undefined) {
|
|
37
37
|
continue;
|
|
38
38
|
}
|
|
39
|
+
// Preserve system fields with underscore prefix (like _status) without splitting
|
|
40
|
+
if (flatKey === '_status') {
|
|
41
|
+
result[flatKey] = value;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
39
44
|
// Check if this is a _relationTo key for a polymorphic relationship
|
|
40
45
|
if (flatKey.endsWith('_relationTo')) {
|
|
41
46
|
const baseKey = flatKey.replace(/_relationTo$/, '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/unflattenObject.ts"],"sourcesContent":["import type { FlattenedField, PayloadRequest } from 'payload'\n\nimport type { FromCSVFunction } from '../types.js'\n\nimport { processRichTextField } from './processRichTextField.js'\n\ntype UnflattenArgs = {\n data: Record<string, unknown>\n fields: FlattenedField[]\n fromCSVFunctions?: Record<string, FromCSVFunction>\n req: PayloadRequest\n}\n\n/**\n * Converts flattened CSV data back into a nested document structure.\n *\n * The algorithm:\n * 1. Sorts keys to ensure array indices are processed in order\n * 2. For each flattened key (e.g., \"blocks_0_hero_title\"), splits by underscore into path segments\n * 3. Traverses/builds the nested structure, handling:\n * - Arrays (numeric segments like \"0\", \"1\")\n * - Blocks (blockType detection from slug patterns)\n * - Polymorphic relationships (_relationTo and _id suffix pairs)\n * - Regular nested objects\n * 4. Post-processes to handle localized fields, hasMany conversions, and relationship transforms\n */\nexport const unflattenObject = ({\n data,\n fields,\n fromCSVFunctions = {},\n req,\n}: UnflattenArgs): Record<string, unknown> => {\n if (!data || typeof data !== 'object') {\n return {}\n }\n\n const result: Record<string, unknown> = {}\n\n // Sort keys to ensure array indices are processed in order\n const sortedKeys = Object.keys(data).sort((a, b) => {\n // Extract array indices from flattened keys (e.g., \"field_0_subfield\" -> \"0\")\n const aMatch = a.match(/_(\\d+)(?:_|$)/)\n const bMatch = b.match(/_(\\d+)(?:_|$)/)\n\n if (aMatch && bMatch && aMatch.index !== undefined && bMatch.index !== undefined) {\n const aBase = a.substring(0, aMatch.index)\n const bBase = b.substring(0, bMatch.index)\n\n if (aBase === bBase) {\n return (parseInt(aMatch?.[1] ?? '0', 10) || 0) - (parseInt(bMatch?.[1] ?? '0', 10) || 0)\n }\n }\n\n return a.localeCompare(b)\n })\n\n for (const flatKey of sortedKeys) {\n let value = data[flatKey]\n\n // Skip undefined values but keep null for required field validation\n if (value === undefined) {\n continue\n }\n\n // Check if this is a _relationTo key for a polymorphic relationship\n if (flatKey.endsWith('_relationTo')) {\n const baseKey = flatKey.replace(/_relationTo$/, '')\n const idKey = `${baseKey}_id`\n\n // Check if this is a polymorphic relationship field\n const isPolymorphic = fields.some(\n (field) =>\n field.name === baseKey &&\n field.type === 'relationship' &&\n 'relationTo' in field &&\n Array.isArray(field.relationTo),\n )\n\n if (isPolymorphic) {\n if (baseKey in result) {\n continue\n }\n\n // If the corresponding _id key is undefined, skip processing entirely\n // This prevents creating empty objects when we should preserve existing data\n if (!(idKey in data) || data[idKey] === undefined) {\n continue\n }\n }\n }\n\n // Check if this is a _id key for a polymorphic relationship where _relationTo is undefined\n if (flatKey.endsWith('_id')) {\n const baseKey = flatKey.replace(/_id$/, '')\n const relationToKey = `${baseKey}_relationTo`\n\n // Check if this is a polymorphic relationship field\n const isPolymorphic = fields.some(\n (field) =>\n field.name === baseKey &&\n field.type === 'relationship' &&\n 'relationTo' in field &&\n Array.isArray(field.relationTo),\n )\n\n if (isPolymorphic) {\n // If the corresponding _relationTo key is undefined, skip processing entirely\n // This prevents creating empty objects when we should preserve existing data\n if (!(relationToKey in data) || data[relationToKey] === undefined) {\n continue\n }\n }\n }\n\n // Apply fromCSV function if available\n if (fromCSVFunctions[flatKey]) {\n value = fromCSVFunctions[flatKey]({\n columnName: flatKey,\n data,\n value,\n })\n }\n\n // Example: \"blocks_0_content_text\" -> [\"blocks\", \"0\", \"content\", \"text\"]\n const pathSegments = flatKey.split('_')\n let currentObject: Record<string, unknown> = result\n\n for (let i = 0; i < pathSegments.length; i++) {\n const segment = pathSegments[i]\n if (!segment) {\n continue\n } // Skip empty segments\n\n const nextSegment = pathSegments[i + 1]\n const isLast = i === pathSegments.length - 1\n\n // Check if next segment is a numeric array index (e.g., \"0\", \"1\", \"2\")\n const isArrayIndex = nextSegment !== undefined && /^\\d+$/.test(nextSegment)\n\n if (isLast) {\n // Special handling for blockType suffix in blocks\n if (segment === 'blockType' && i >= 3) {\n // Pattern: blocks_0_hero_blockType -> set blockType on the block\n const blockFieldName = pathSegments[0] // 'blocks'\n const isBlockField = fields.some(\n (field) => field.name === blockFieldName && field.type === 'blocks',\n )\n\n if (isBlockField && pathSegments[1]?.match(/^\\d+$/)) {\n const parent = getParentObject(result, pathSegments.slice(0, 2))\n if (parent && typeof parent === 'object') {\n parent.blockType = value\n }\n continue\n }\n }\n\n // Special handling for relationship fields with _id suffix\n if (segment === 'id' && i > 0) {\n const parentKey = pathSegments[i - 1]\n const isPreviousSegmentArrayIndex = parentKey ? /^\\d+$/.test(parentKey) : false\n\n if (!isPreviousSegmentArrayIndex) {\n // Check if this is a relationship field\n const isRelationship = fields.some(\n (field) => field.name === parentKey && field.type === 'relationship',\n )\n\n if (isRelationship) {\n // Check if this is a polymorphic relationship field\n const field = fields.find((f) => f.name === parentKey && f.type === 'relationship')\n const isPolymorphic =\n field && 'relationTo' in field && Array.isArray(field.relationTo)\n\n if (isPolymorphic) {\n const relationToKey = pathSegments.slice(0, i).concat('relationTo').join('_')\n const relationToValue = data[relationToKey]\n\n const parent = getParentObject(result, pathSegments.slice(0, i - 1))\n if (parent && parentKey && typeof parent === 'object') {\n // Both fields must be defined to create/update the relationship\n // If either is undefined, skip the field entirely (preserve existing data)\n if (value !== undefined && relationToValue !== undefined) {\n // Check if both are explicitly null\n if (relationToValue === null && value === null) {\n // Only set to null if explicitly null (user typed \"null\" in CSV)\n parent[parentKey] = null\n } else if (relationToValue || value) {\n // At least one has a value, create the relationship\n parent[parentKey] = {\n relationTo: relationToValue,\n value, // This will be transformed to proper format in postProcess\n }\n }\n // If both are empty strings, don't set the field (handled by not meeting the above conditions)\n }\n // If either is undefined, don't set the field at all (preserve existing data)\n }\n continue\n } else if (!isPolymorphic) {\n const parent = getParentObject(result, pathSegments.slice(0, i - 1))\n if (parent && parentKey && typeof parent === 'object') {\n parent[parentKey] = value\n }\n continue\n }\n }\n }\n }\n\n // _relationTo suffix is handled when processing the _id field above\n if (segment === 'relationTo' && i > 0) {\n const parentKey = pathSegments[i - 1]\n if (parentKey && !parentKey.match(/^\\d+$/)) {\n const field = fields.find((f) => f.name === parentKey && f.type === 'relationship')\n const isPolymorphic = field && 'relationTo' in field && Array.isArray(field.relationTo)\n\n if (isPolymorphic) {\n // For polymorphic relationships, this is handled when processing the _id field\n // Skip it entirely\n continue\n }\n }\n }\n\n currentObject[segment] = value\n } else if (isArrayIndex && nextSegment !== undefined) {\n if (!currentObject[segment] || !Array.isArray(currentObject[segment])) {\n currentObject[segment] = []\n }\n\n const arrayIndex = parseInt(nextSegment)\n const arr = currentObject[segment] as unknown[]\n\n // Ensure array has sufficient length\n while (arr.length <= arrayIndex) {\n arr.push(null)\n }\n\n // Handle array of objects\n if (arr[arrayIndex] === null || arr[arrayIndex] === undefined) {\n arr[arrayIndex] = {}\n }\n\n // Handle blocks field with block slug pattern (e.g., blocks_0_hero_title)\n const isBlocksField = fields.some((f) => f.name === segment && f.type === 'blocks')\n if (isBlocksField && i + 3 < pathSegments.length) {\n const blockSlug = pathSegments[i + 2]\n const blockFieldName = pathSegments[i + 3]\n\n if (blockSlug && blockFieldName) {\n const blockObject = arr[arrayIndex] as Record<string, unknown>\n blockObject.blockType = blockSlug\n\n if (i + 3 === pathSegments.length - 1) {\n blockObject[blockFieldName] = value\n } else {\n if (!blockObject[blockFieldName] || typeof blockObject[blockFieldName] !== 'object') {\n blockObject[blockFieldName] = {}\n }\n currentObject = blockObject[blockFieldName] as Record<string, unknown>\n i = i + 3\n continue\n }\n break\n }\n }\n\n if (i + 2 === pathSegments.length - 1) {\n const lastSegment = pathSegments[pathSegments.length - 1]\n if (lastSegment && arr[arrayIndex] && typeof arr[arrayIndex] === 'object') {\n ;(arr[arrayIndex] as Record<string, unknown>)[lastSegment] = value\n }\n break\n } else if (i + 1 === pathSegments.length - 1) {\n // Direct array value (e.g., tags_0 = \"value\")\n arr[arrayIndex] = value\n break\n } else {\n currentObject = arr[arrayIndex] as Record<string, unknown>\n i++\n }\n } else {\n // Skip if already set to null (polymorphic relationship already processed)\n if (currentObject[segment] === null && isLast && segment === 'relationTo') {\n continue\n }\n\n if (\n !currentObject[segment] ||\n typeof currentObject[segment] !== 'object' ||\n Array.isArray(currentObject[segment])\n ) {\n currentObject[segment] = {}\n }\n\n // Handle polymorphic relationship arrays\n if (segment === 'relationTo' && i > 0 && pathSegments[i - 1]?.match(/^\\d+$/)) {\n currentObject[segment] = value\n } else if (\n typeof currentObject[segment] === 'object' &&\n !Array.isArray(currentObject[segment]) &&\n currentObject[segment] !== null\n ) {\n currentObject = currentObject[segment] as Record<string, unknown>\n }\n }\n }\n }\n\n try {\n // Post-process to handle special structures\n postProcessDocument(result, fields)\n } catch (err) {\n // Log but don't throw - return partially processed result\n\n req.payload.logger.error({\n err,\n msg: '[plugin-import-export] Error in postProcessDocument',\n })\n }\n\n return result\n}\n\nconst getParentObject = (\n obj: Record<string, unknown>,\n segments: string[],\n): Record<string, unknown> | undefined => {\n let current: Record<string, unknown> = obj\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i]\n const nextSegment = segments[i + 1]\n\n if (!segment) {\n continue\n }\n\n if (nextSegment && /^\\d+$/.test(nextSegment)) {\n const arrayIndex = parseInt(nextSegment)\n const arr = current[segment] as unknown[]\n\n if (Array.isArray(arr) && arr[arrayIndex]) {\n current = arr[arrayIndex] as Record<string, unknown>\n i++ // Skip the index\n } else {\n return undefined\n }\n } else {\n const next = current[segment]\n if (typeof next === 'object' && next !== null && !Array.isArray(next)) {\n current = next as Record<string, unknown>\n } else {\n return undefined\n }\n }\n }\n\n return current\n}\n\n/**\n * Post-processes the unflattened document to handle special field types:\n * - Localized fields: transforms field_locale keys to nested { field: { locale: value } }\n * - Number hasMany: converts comma-separated strings or arrays to number arrays\n * - Relationship hasMany: converts comma-separated IDs to arrays\n * - Polymorphic relationships: transforms flat {relationTo, id} to {relationTo, value}\n * - Rich text fields: ensures proper data structure\n */\nconst postProcessDocument = (doc: Record<string, unknown>, fields: FlattenedField[]): void => {\n const localizedFields = fields.filter((field) => field.localized)\n const processedLocalizedFields = new Set<string>()\n\n for (const field of localizedFields) {\n if (processedLocalizedFields.has(field.name)) {\n continue\n }\n\n // Look for all locale-specific keys for this field\n const localePattern = new RegExp(`^${field.name}_([a-z]{2}(?:_[A-Z]{2})?)$`)\n const localeData: Record<string, unknown> = {}\n const keysToDelete: string[] = []\n\n for (const [key, value] of Object.entries(doc)) {\n const match = key.match(localePattern)\n if (match && match[1]) {\n const locale = match[1]\n localeData[locale] = value\n keysToDelete.push(key)\n }\n }\n\n // If we found locale-specific data, restructure it as Payload expects\n if (Object.keys(localeData).length > 0) {\n // Payload stores localized fields as nested objects: { field: { en: 'value', es: 'value' } }\n doc[field.name] = localeData\n keysToDelete.forEach((key) => delete doc[key])\n processedLocalizedFields.add(field.name)\n }\n }\n\n // Handle number fields with hasMany - convert string arrays to number arrays\n const numberFields = fields.filter((field) => field.type === 'number' && field.hasMany)\n for (const field of numberFields) {\n const value = doc[field.name]\n\n // Skip if field doesn't exist in document\n if (!(field.name in doc)) {\n continue\n }\n\n // Handle comma-separated string (e.g., \"1,2,3,4,5\")\n if (typeof value === 'string' && value.includes(',')) {\n doc[field.name] = value\n .split(',')\n .map((v) => v.trim())\n .filter((v) => v !== '')\n .map((v) => {\n const num = parseFloat(v)\n return isNaN(num) ? 0 : num\n })\n }\n // Handle array of values from indexed columns (e.g., field_0, field_1, etc.)\n else if (Array.isArray(value)) {\n // Filter out null, undefined, and empty string values, then convert to numbers\n doc[field.name] = value\n .filter((v) => v !== null && v !== undefined && v !== '')\n .map((v) => {\n if (typeof v === 'string') {\n const num = parseFloat(v)\n return isNaN(num) ? 0 : num\n }\n return v\n })\n }\n // Handle single value for hasMany (convert to array)\n else if (value !== null && value !== undefined && value !== '') {\n const num = typeof value === 'string' ? parseFloat(value) : value\n doc[field.name] = isNaN(num as number) ? [] : [num]\n }\n // Handle empty/null values - convert to empty array for hasMany\n else {\n doc[field.name] = []\n }\n }\n\n // Handle relationship fields with hasMany - convert comma-separated IDs to arrays\n const relationshipFields = fields.filter(\n (field) =>\n (field.type === 'relationship' || field.type === 'upload') &&\n field.hasMany === true &&\n !Array.isArray(field.relationTo), // Skip polymorphic for now, handled separately\n )\n for (const field of relationshipFields) {\n const value = doc[field.name]\n\n // Handle comma-separated string of IDs (e.g., \"id1,id2,id3\")\n if (typeof value === 'string' && value.includes(',')) {\n doc[field.name] = value\n .split(',')\n .map((v) => v.trim())\n .filter((v) => v !== '')\n }\n // Keep array as-is if already an array\n else if (Array.isArray(value)) {\n doc[field.name] = value.filter((v) => v !== null && v !== undefined && v !== '')\n }\n // Convert single value to array for hasMany\n else if (value !== null && value !== undefined && value !== '') {\n doc[field.name] = [value]\n }\n }\n\n // Handle polymorphic relationships - transform from flat structure to proper format\n for (const [key, value] of Object.entries(doc)) {\n // Handle arrays of polymorphic relationships\n if (Array.isArray(value)) {\n // Check if this array contains polymorphic relationship objects\n const hasPolymorphicItems = value.some(\n (item) => typeof item === 'object' && item !== null && 'relationTo' in item,\n )\n\n if (hasPolymorphicItems) {\n // Filter out null/invalid polymorphic items and transform valid ones\n const processedArray = []\n for (let i = 0; i < value.length; i++) {\n const item = value[i]\n if (typeof item === 'object' && item !== null && 'relationTo' in item) {\n const typedItem = item as Record<string, unknown>\n\n // Skip if both relationTo and value/id are null/empty\n if (!typedItem.relationTo || (!typedItem.id && !typedItem.value)) {\n continue\n }\n\n // Transform from {relationTo: 'collection', id: '123'} to {relationTo: 'collection', value: '123'}\n if ('id' in typedItem) {\n typedItem.value = typedItem.id\n delete typedItem.id\n }\n\n processedArray.push(typedItem)\n } else if (item !== null && item !== undefined) {\n processedArray.push(item)\n }\n }\n\n // Update the array with filtered results\n if (value.length !== processedArray.length) {\n doc[key] = processedArray.length > 0 ? processedArray : []\n }\n }\n // For non-polymorphic arrays, preserve null placeholders for sparse arrays\n }\n // Handle single polymorphic relationships\n else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Check if this is a single polymorphic relationship\n if ('relationTo' in value && ('id' in value || 'value' in value)) {\n const typedValue = value as Record<string, unknown>\n\n // If both relationTo and value are null/empty, set the whole field to null\n if (!typedValue.relationTo || (!typedValue.id && !typedValue.value)) {\n doc[key] = null\n } else {\n // If it has 'id', transform to 'value'\n if ('id' in typedValue && !('value' in typedValue)) {\n typedValue.value = typedValue.id\n delete typedValue.id\n }\n }\n } else {\n // Recursively process nested objects\n postProcessDocument(value as Record<string, unknown>, fields)\n }\n }\n }\n\n // Process rich text fields to ensure proper data types\n const richTextFields = fields.filter((field) => field.type === 'richText')\n for (const field of richTextFields) {\n if (field.name in doc && doc[field.name]) {\n doc[field.name] = processRichTextField(doc[field.name])\n }\n }\n\n // Also process rich text fields in blocks\n const blockFields = fields.filter((field) => field.type === 'blocks')\n for (const field of blockFields) {\n if (field.name in doc && Array.isArray(doc[field.name])) {\n const blocks = doc[field.name] as any[]\n for (const block of blocks) {\n if (!block || typeof block !== 'object') {\n continue\n }\n\n // Look for richText fields directly in the block\n for (const [key, value] of Object.entries(block)) {\n if (key === 'richText' || (typeof key === 'string' && key.includes('richText'))) {\n block[key] = processRichTextField(value)\n }\n }\n }\n }\n }\n}\n"],"names":["processRichTextField","unflattenObject","data","fields","fromCSVFunctions","req","result","sortedKeys","Object","keys","sort","a","b","aMatch","match","bMatch","index","undefined","aBase","substring","bBase","parseInt","localeCompare","flatKey","value","endsWith","baseKey","replace","idKey","isPolymorphic","some","field","name","type","Array","isArray","relationTo","relationToKey","columnName","pathSegments","split","currentObject","i","length","segment","nextSegment","isLast","isArrayIndex","test","blockFieldName","isBlockField","parent","getParentObject","slice","blockType","parentKey","isPreviousSegmentArrayIndex","isRelationship","find","f","concat","join","relationToValue","arrayIndex","arr","push","isBlocksField","blockSlug","blockObject","lastSegment","postProcessDocument","err","payload","logger","error","msg","obj","segments","current","next","doc","localizedFields","filter","localized","processedLocalizedFields","Set","has","localePattern","RegExp","localeData","keysToDelete","key","entries","locale","forEach","add","numberFields","hasMany","includes","map","v","trim","num","parseFloat","isNaN","relationshipFields","hasPolymorphicItems","item","processedArray","typedItem","id","typedValue","richTextFields","blockFields","blocks","block"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,4BAA2B;AAShE;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,IAAI,EACJC,MAAM,EACNC,mBAAmB,CAAC,CAAC,EACrBC,GAAG,EACW;IACd,IAAI,CAACH,QAAQ,OAAOA,SAAS,UAAU;QACrC,OAAO,CAAC;IACV;IAEA,MAAMI,SAAkC,CAAC;IAEzC,2DAA2D;IAC3D,MAAMC,aAAaC,OAAOC,IAAI,CAACP,MAAMQ,IAAI,CAAC,CAACC,GAAGC;QAC5C,8EAA8E;QAC9E,MAAMC,SAASF,EAAEG,KAAK,CAAC;QACvB,MA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B;gBACF;YACF,OAAO;gBACL,qCAAqC;gBACrCxC,oBAAoB9C,OAAkCrB;YACxD;QACF;IACF;IAEA,uDAAuD;IACvD,MAAM6G,iBAAiB7G,OAAO+E,MAAM,CAAC,CAACnD,QAAUA,MAAME,IAAI,KAAK;IAC/D,KAAK,MAAMF,SAASiF,eAAgB;QAClC,IAAIjF,MAAMC,IAAI,IAAIgD,OAAOA,GAAG,CAACjD,MAAMC,IAAI,CAAC,EAAE;YACxCgD,GAAG,CAACjD,MAAMC,IAAI,CAAC,GAAGhC,qBAAqBgF,GAAG,CAACjD,MAAMC,IAAI,CAAC;QACxD;IACF;IAEA,0CAA0C;IAC1C,MAAMiF,cAAc9G,OAAO+E,MAAM,CAAC,CAACnD,QAAUA,MAAME,IAAI,KAAK;IAC5D,KAAK,MAAMF,SAASkF,YAAa;QAC/B,IAAIlF,MAAMC,IAAI,IAAIgD,OAAO9C,MAAMC,OAAO,CAAC6C,GAAG,CAACjD,MAAMC,IAAI,CAAC,GAAG;YACvD,MAAMkF,SAASlC,GAAG,CAACjD,MAAMC,IAAI,CAAC;YAC9B,KAAK,MAAMmF,SAASD,OAAQ;gBAC1B,IAAI,CAACC,SAAS,OAAOA,UAAU,UAAU;oBACvC;gBACF;gBAEA,iDAAiD;gBACjD,KAAK,MAAM,CAACxB,KAAKnE,MAAM,IAAIhB,OAAOoF,OAAO,CAACuB,OAAQ;oBAChD,IAAIxB,QAAQ,cAAe,OAAOA,QAAQ,YAAYA,IAAIO,QAAQ,CAAC,aAAc;wBAC/EiB,KAAK,CAACxB,IAAI,GAAG3F,qBAAqBwB;oBACpC;gBACF;YACF;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/unflattenObject.ts"],"sourcesContent":["import type { FlattenedField, PayloadRequest } from 'payload'\n\nimport type { FromCSVFunction } from '../types.js'\n\nimport { processRichTextField } from './processRichTextField.js'\n\ntype UnflattenArgs = {\n data: Record<string, unknown>\n fields: FlattenedField[]\n fromCSVFunctions?: Record<string, FromCSVFunction>\n req: PayloadRequest\n}\n\n/**\n * Converts flattened CSV data back into a nested document structure.\n *\n * The algorithm:\n * 1. Sorts keys to ensure array indices are processed in order\n * 2. For each flattened key (e.g., \"blocks_0_hero_title\"), splits by underscore into path segments\n * 3. Traverses/builds the nested structure, handling:\n * - Arrays (numeric segments like \"0\", \"1\")\n * - Blocks (blockType detection from slug patterns)\n * - Polymorphic relationships (_relationTo and _id suffix pairs)\n * - Regular nested objects\n * 4. Post-processes to handle localized fields, hasMany conversions, and relationship transforms\n */\nexport const unflattenObject = ({\n data,\n fields,\n fromCSVFunctions = {},\n req,\n}: UnflattenArgs): Record<string, unknown> => {\n if (!data || typeof data !== 'object') {\n return {}\n }\n\n const result: Record<string, unknown> = {}\n\n // Sort keys to ensure array indices are processed in order\n const sortedKeys = Object.keys(data).sort((a, b) => {\n // Extract array indices from flattened keys (e.g., \"field_0_subfield\" -> \"0\")\n const aMatch = a.match(/_(\\d+)(?:_|$)/)\n const bMatch = b.match(/_(\\d+)(?:_|$)/)\n\n if (aMatch && bMatch && aMatch.index !== undefined && bMatch.index !== undefined) {\n const aBase = a.substring(0, aMatch.index)\n const bBase = b.substring(0, bMatch.index)\n\n if (aBase === bBase) {\n return (parseInt(aMatch?.[1] ?? '0', 10) || 0) - (parseInt(bMatch?.[1] ?? '0', 10) || 0)\n }\n }\n\n return a.localeCompare(b)\n })\n\n for (const flatKey of sortedKeys) {\n let value = data[flatKey]\n\n // Skip undefined values but keep null for required field validation\n if (value === undefined) {\n continue\n }\n\n // Preserve system fields with underscore prefix (like _status) without splitting\n if (flatKey === '_status') {\n result[flatKey] = value\n continue\n }\n\n // Check if this is a _relationTo key for a polymorphic relationship\n if (flatKey.endsWith('_relationTo')) {\n const baseKey = flatKey.replace(/_relationTo$/, '')\n const idKey = `${baseKey}_id`\n\n // Check if this is a polymorphic relationship field\n const isPolymorphic = fields.some(\n (field) =>\n field.name === baseKey &&\n field.type === 'relationship' &&\n 'relationTo' in field &&\n Array.isArray(field.relationTo),\n )\n\n if (isPolymorphic) {\n if (baseKey in result) {\n continue\n }\n\n // If the corresponding _id key is undefined, skip processing entirely\n // This prevents creating empty objects when we should preserve existing data\n if (!(idKey in data) || data[idKey] === undefined) {\n continue\n }\n }\n }\n\n // Check if this is a _id key for a polymorphic relationship where _relationTo is undefined\n if (flatKey.endsWith('_id')) {\n const baseKey = flatKey.replace(/_id$/, '')\n const relationToKey = `${baseKey}_relationTo`\n\n // Check if this is a polymorphic relationship field\n const isPolymorphic = fields.some(\n (field) =>\n field.name === baseKey &&\n field.type === 'relationship' &&\n 'relationTo' in field &&\n Array.isArray(field.relationTo),\n )\n\n if (isPolymorphic) {\n // If the corresponding _relationTo key is undefined, skip processing entirely\n // This prevents creating empty objects when we should preserve existing data\n if (!(relationToKey in data) || data[relationToKey] === undefined) {\n continue\n }\n }\n }\n\n // Apply fromCSV function if available\n if (fromCSVFunctions[flatKey]) {\n value = fromCSVFunctions[flatKey]({\n columnName: flatKey,\n data,\n value,\n })\n }\n\n // Example: \"blocks_0_content_text\" -> [\"blocks\", \"0\", \"content\", \"text\"]\n const pathSegments = flatKey.split('_')\n let currentObject: Record<string, unknown> = result\n\n for (let i = 0; i < pathSegments.length; i++) {\n const segment = pathSegments[i]\n if (!segment) {\n continue\n } // Skip empty segments\n\n const nextSegment = pathSegments[i + 1]\n const isLast = i === pathSegments.length - 1\n\n // Check if next segment is a numeric array index (e.g., \"0\", \"1\", \"2\")\n const isArrayIndex = nextSegment !== undefined && /^\\d+$/.test(nextSegment)\n\n if (isLast) {\n // Special handling for blockType suffix in blocks\n if (segment === 'blockType' && i >= 3) {\n // Pattern: blocks_0_hero_blockType -> set blockType on the block\n const blockFieldName = pathSegments[0] // 'blocks'\n const isBlockField = fields.some(\n (field) => field.name === blockFieldName && field.type === 'blocks',\n )\n\n if (isBlockField && pathSegments[1]?.match(/^\\d+$/)) {\n const parent = getParentObject(result, pathSegments.slice(0, 2))\n if (parent && typeof parent === 'object') {\n parent.blockType = value\n }\n continue\n }\n }\n\n // Special handling for relationship fields with _id suffix\n if (segment === 'id' && i > 0) {\n const parentKey = pathSegments[i - 1]\n const isPreviousSegmentArrayIndex = parentKey ? /^\\d+$/.test(parentKey) : false\n\n if (!isPreviousSegmentArrayIndex) {\n // Check if this is a relationship field\n const isRelationship = fields.some(\n (field) => field.name === parentKey && field.type === 'relationship',\n )\n\n if (isRelationship) {\n // Check if this is a polymorphic relationship field\n const field = fields.find((f) => f.name === parentKey && f.type === 'relationship')\n const isPolymorphic =\n field && 'relationTo' in field && Array.isArray(field.relationTo)\n\n if (isPolymorphic) {\n const relationToKey = pathSegments.slice(0, i).concat('relationTo').join('_')\n const relationToValue = data[relationToKey]\n\n const parent = getParentObject(result, pathSegments.slice(0, i - 1))\n if (parent && parentKey && typeof parent === 'object') {\n // Both fields must be defined to create/update the relationship\n // If either is undefined, skip the field entirely (preserve existing data)\n if (value !== undefined && relationToValue !== undefined) {\n // Check if both are explicitly null\n if (relationToValue === null && value === null) {\n // Only set to null if explicitly null (user typed \"null\" in CSV)\n parent[parentKey] = null\n } else if (relationToValue || value) {\n // At least one has a value, create the relationship\n parent[parentKey] = {\n relationTo: relationToValue,\n value, // This will be transformed to proper format in postProcess\n }\n }\n // If both are empty strings, don't set the field (handled by not meeting the above conditions)\n }\n // If either is undefined, don't set the field at all (preserve existing data)\n }\n continue\n } else if (!isPolymorphic) {\n const parent = getParentObject(result, pathSegments.slice(0, i - 1))\n if (parent && parentKey && typeof parent === 'object') {\n parent[parentKey] = value\n }\n continue\n }\n }\n }\n }\n\n // _relationTo suffix is handled when processing the _id field above\n if (segment === 'relationTo' && i > 0) {\n const parentKey = pathSegments[i - 1]\n if (parentKey && !parentKey.match(/^\\d+$/)) {\n const field = fields.find((f) => f.name === parentKey && f.type === 'relationship')\n const isPolymorphic = field && 'relationTo' in field && Array.isArray(field.relationTo)\n\n if (isPolymorphic) {\n // For polymorphic relationships, this is handled when processing the _id field\n // Skip it entirely\n continue\n }\n }\n }\n\n currentObject[segment] = value\n } else if (isArrayIndex && nextSegment !== undefined) {\n if (!currentObject[segment] || !Array.isArray(currentObject[segment])) {\n currentObject[segment] = []\n }\n\n const arrayIndex = parseInt(nextSegment)\n const arr = currentObject[segment] as unknown[]\n\n // Ensure array has sufficient length\n while (arr.length <= arrayIndex) {\n arr.push(null)\n }\n\n // Handle array of objects\n if (arr[arrayIndex] === null || arr[arrayIndex] === undefined) {\n arr[arrayIndex] = {}\n }\n\n // Handle blocks field with block slug pattern (e.g., blocks_0_hero_title)\n const isBlocksField = fields.some((f) => f.name === segment && f.type === 'blocks')\n if (isBlocksField && i + 3 < pathSegments.length) {\n const blockSlug = pathSegments[i + 2]\n const blockFieldName = pathSegments[i + 3]\n\n if (blockSlug && blockFieldName) {\n const blockObject = arr[arrayIndex] as Record<string, unknown>\n blockObject.blockType = blockSlug\n\n if (i + 3 === pathSegments.length - 1) {\n blockObject[blockFieldName] = value\n } else {\n if (!blockObject[blockFieldName] || typeof blockObject[blockFieldName] !== 'object') {\n blockObject[blockFieldName] = {}\n }\n currentObject = blockObject[blockFieldName] as Record<string, unknown>\n i = i + 3\n continue\n }\n break\n }\n }\n\n if (i + 2 === pathSegments.length - 1) {\n const lastSegment = pathSegments[pathSegments.length - 1]\n if (lastSegment && arr[arrayIndex] && typeof arr[arrayIndex] === 'object') {\n ;(arr[arrayIndex] as Record<string, unknown>)[lastSegment] = value\n }\n break\n } else if (i + 1 === pathSegments.length - 1) {\n // Direct array value (e.g., tags_0 = \"value\")\n arr[arrayIndex] = value\n break\n } else {\n currentObject = arr[arrayIndex] as Record<string, unknown>\n i++\n }\n } else {\n // Skip if already set to null (polymorphic relationship already processed)\n if (currentObject[segment] === null && isLast && segment === 'relationTo') {\n continue\n }\n\n if (\n !currentObject[segment] ||\n typeof currentObject[segment] !== 'object' ||\n Array.isArray(currentObject[segment])\n ) {\n currentObject[segment] = {}\n }\n\n // Handle polymorphic relationship arrays\n if (segment === 'relationTo' && i > 0 && pathSegments[i - 1]?.match(/^\\d+$/)) {\n currentObject[segment] = value\n } else if (\n typeof currentObject[segment] === 'object' &&\n !Array.isArray(currentObject[segment]) &&\n currentObject[segment] !== null\n ) {\n currentObject = currentObject[segment] as Record<string, unknown>\n }\n }\n }\n }\n\n try {\n // Post-process to handle special structures\n postProcessDocument(result, fields)\n } catch (err) {\n // Log but don't throw - return partially processed result\n\n req.payload.logger.error({\n err,\n msg: '[plugin-import-export] Error in postProcessDocument',\n })\n }\n\n return result\n}\n\nconst getParentObject = (\n obj: Record<string, unknown>,\n segments: string[],\n): Record<string, unknown> | undefined => {\n let current: Record<string, unknown> = obj\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i]\n const nextSegment = segments[i + 1]\n\n if (!segment) {\n continue\n }\n\n if (nextSegment && /^\\d+$/.test(nextSegment)) {\n const arrayIndex = parseInt(nextSegment)\n const arr = current[segment] as unknown[]\n\n if (Array.isArray(arr) && arr[arrayIndex]) {\n current = arr[arrayIndex] as Record<string, unknown>\n i++ // Skip the index\n } else {\n return undefined\n }\n } else {\n const next = current[segment]\n if (typeof next === 'object' && next !== null && !Array.isArray(next)) {\n current = next as Record<string, unknown>\n } else {\n return undefined\n }\n }\n }\n\n return current\n}\n\n/**\n * Post-processes the unflattened document to handle special field types:\n * - Localized fields: transforms field_locale keys to nested { field: { locale: value } }\n * - Number hasMany: converts comma-separated strings or arrays to number arrays\n * - Relationship hasMany: converts comma-separated IDs to arrays\n * - Polymorphic relationships: transforms flat {relationTo, id} to {relationTo, value}\n * - Rich text fields: ensures proper data structure\n */\nconst postProcessDocument = (doc: Record<string, unknown>, fields: FlattenedField[]): void => {\n const localizedFields = fields.filter((field) => field.localized)\n const processedLocalizedFields = new Set<string>()\n\n for (const field of localizedFields) {\n if (processedLocalizedFields.has(field.name)) {\n continue\n }\n\n // Look for all locale-specific keys for this field\n const localePattern = new RegExp(`^${field.name}_([a-z]{2}(?:_[A-Z]{2})?)$`)\n const localeData: Record<string, unknown> = {}\n const keysToDelete: string[] = []\n\n for (const [key, value] of Object.entries(doc)) {\n const match = key.match(localePattern)\n if (match && match[1]) {\n const locale = match[1]\n localeData[locale] = value\n keysToDelete.push(key)\n }\n }\n\n // If we found locale-specific data, restructure it as Payload expects\n if (Object.keys(localeData).length > 0) {\n // Payload stores localized fields as nested objects: { field: { en: 'value', es: 'value' } }\n doc[field.name] = localeData\n keysToDelete.forEach((key) => delete doc[key])\n processedLocalizedFields.add(field.name)\n }\n }\n\n // Handle number fields with hasMany - convert string arrays to number arrays\n const numberFields = fields.filter((field) => field.type === 'number' && field.hasMany)\n for (const field of numberFields) {\n const value = doc[field.name]\n\n // Skip if field doesn't exist in document\n if (!(field.name in doc)) {\n continue\n }\n\n // Handle comma-separated string (e.g., \"1,2,3,4,5\")\n if (typeof value === 'string' && value.includes(',')) {\n doc[field.name] = value\n .split(',')\n .map((v) => v.trim())\n .filter((v) => v !== '')\n .map((v) => {\n const num = parseFloat(v)\n return isNaN(num) ? 0 : num\n })\n }\n // Handle array of values from indexed columns (e.g., field_0, field_1, etc.)\n else if (Array.isArray(value)) {\n // Filter out null, undefined, and empty string values, then convert to numbers\n doc[field.name] = value\n .filter((v) => v !== null && v !== undefined && v !== '')\n .map((v) => {\n if (typeof v === 'string') {\n const num = parseFloat(v)\n return isNaN(num) ? 0 : num\n }\n return v\n })\n }\n // Handle single value for hasMany (convert to array)\n else if (value !== null && value !== undefined && value !== '') {\n const num = typeof value === 'string' ? parseFloat(value) : value\n doc[field.name] = isNaN(num as number) ? [] : [num]\n }\n // Handle empty/null values - convert to empty array for hasMany\n else {\n doc[field.name] = []\n }\n }\n\n // Handle relationship fields with hasMany - convert comma-separated IDs to arrays\n const relationshipFields = fields.filter(\n (field) =>\n (field.type === 'relationship' || field.type === 'upload') &&\n field.hasMany === true &&\n !Array.isArray(field.relationTo), // Skip polymorphic for now, handled separately\n )\n for (const field of relationshipFields) {\n const value = doc[field.name]\n\n // Handle comma-separated string of IDs (e.g., \"id1,id2,id3\")\n if (typeof value === 'string' && value.includes(',')) {\n doc[field.name] = value\n .split(',')\n .map((v) => v.trim())\n .filter((v) => v !== '')\n }\n // Keep array as-is if already an array\n else if (Array.isArray(value)) {\n doc[field.name] = value.filter((v) => v !== null && v !== undefined && v !== '')\n }\n // Convert single value to array for hasMany\n else if (value !== null && value !== undefined && value !== '') {\n doc[field.name] = [value]\n }\n }\n\n // Handle polymorphic relationships - transform from flat structure to proper format\n for (const [key, value] of Object.entries(doc)) {\n // Handle arrays of polymorphic relationships\n if (Array.isArray(value)) {\n // Check if this array contains polymorphic relationship objects\n const hasPolymorphicItems = value.some(\n (item) => typeof item === 'object' && item !== null && 'relationTo' in item,\n )\n\n if (hasPolymorphicItems) {\n // Filter out null/invalid polymorphic items and transform valid ones\n const processedArray = []\n for (let i = 0; i < value.length; i++) {\n const item = value[i]\n if (typeof item === 'object' && item !== null && 'relationTo' in item) {\n const typedItem = item as Record<string, unknown>\n\n // Skip if both relationTo and value/id are null/empty\n if (!typedItem.relationTo || (!typedItem.id && !typedItem.value)) {\n continue\n }\n\n // Transform from {relationTo: 'collection', id: '123'} to {relationTo: 'collection', value: '123'}\n if ('id' in typedItem) {\n typedItem.value = typedItem.id\n delete typedItem.id\n }\n\n processedArray.push(typedItem)\n } else if (item !== null && item !== undefined) {\n processedArray.push(item)\n }\n }\n\n // Update the array with filtered results\n if (value.length !== processedArray.length) {\n doc[key] = processedArray.length > 0 ? processedArray : []\n }\n }\n // For non-polymorphic arrays, preserve null placeholders for sparse arrays\n }\n // Handle single polymorphic relationships\n else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Check if this is a single polymorphic relationship\n if ('relationTo' in value && ('id' in value || 'value' in value)) {\n const typedValue = value as Record<string, unknown>\n\n // If both relationTo and value are null/empty, set the whole field to null\n if (!typedValue.relationTo || (!typedValue.id && !typedValue.value)) {\n doc[key] = null\n } else {\n // If it has 'id', transform to 'value'\n if ('id' in typedValue && !('value' in typedValue)) {\n typedValue.value = typedValue.id\n delete typedValue.id\n }\n }\n } else {\n // Recursively process nested objects\n postProcessDocument(value as Record<string, unknown>, fields)\n }\n }\n }\n\n // Process rich text fields to ensure proper data types\n const richTextFields = fields.filter((field) => field.type === 'richText')\n for (const field of richTextFields) {\n if (field.name in doc && doc[field.name]) {\n doc[field.name] = processRichTextField(doc[field.name])\n }\n }\n\n // Also process rich text fields in blocks\n const blockFields = fields.filter((field) => field.type === 'blocks')\n for (const field of blockFields) {\n if (field.name in doc && Array.isArray(doc[field.name])) {\n const blocks = doc[field.name] as any[]\n for (const block of blocks) {\n if (!block || typeof block !== 'object') {\n continue\n }\n\n // Look for richText fields directly in the block\n for (const [key, value] of Object.entries(block)) {\n if (key === 'richText' || (typeof key === 'string' && key.includes('richText'))) {\n block[key] = processRichTextField(value)\n }\n }\n }\n }\n }\n}\n"],"names":["processRichTextField","unflattenObject","data","fields","fromCSVFunctions","req","result","sortedKeys","Object","keys","sort","a","b","aMatch","match","bMatch","index","undefined","aBase","substring","bBase","parseInt","localeCompare","flatKey","value","endsWith","baseKey","replace","idKey","isPolymorphic","some","field","name","type","Array","isArray","relationTo","relationToKey","columnName","pathSegments","split","currentObject","i","length","segment","nextSegment","isLast","isArrayIndex","test","blockFieldName","isBlockField","parent","getParentObject","slice","blockType","parentKey","isPreviousSegmentArrayIndex","isRelationship","find","f","concat","join","relationToValue","arrayIndex","arr","push","isBlocksField","blockSlug","blockObject","lastSegment","postProcessDocument","err","payload","logger","error","msg","obj","segments","current","next","doc","localizedFields","filter","localized","processedLocalizedFields","Set","has","localePattern","RegExp","localeData","keysToDelete","key","entries","locale","forEach","add","numberFields","hasMany","includes","map","v","trim","num","parseFloat","isNaN","relationshipFields","hasPolymorphicItems","item","processedArray","typedItem","id","typedValue","richTextFields","blockFields","blocks","block"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,4BAA2B;AAShE;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,IAAI,EACJC,M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