@payloadcms/plugin-import-export 3.77.0-internal.9837b1e → 3.77.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/components/CollectionField/index.d.ts +2 -2
  2. package/dist/components/CollectionField/index.d.ts.map +1 -1
  3. package/dist/components/CollectionField/index.js +5 -28
  4. package/dist/components/CollectionField/index.js.map +1 -1
  5. package/dist/components/CollectionSelectField/index.d.ts +13 -0
  6. package/dist/components/CollectionSelectField/index.d.ts.map +1 -0
  7. package/dist/components/CollectionSelectField/index.js +159 -0
  8. package/dist/components/CollectionSelectField/index.js.map +1 -0
  9. package/dist/components/ExportListMenuItem/index.d.ts.map +1 -1
  10. package/dist/components/ExportListMenuItem/index.js +5 -1
  11. package/dist/components/ExportListMenuItem/index.js.map +1 -1
  12. package/dist/components/ExportPreview/index.d.ts.map +1 -1
  13. package/dist/components/ExportPreview/index.js.map +1 -1
  14. package/dist/components/FieldsToExport/index.js +1 -1
  15. package/dist/components/FieldsToExport/index.js.map +1 -1
  16. package/dist/components/ImportPreview/index.d.ts.map +1 -1
  17. package/dist/components/ImportPreview/index.js +50 -30
  18. package/dist/components/ImportPreview/index.js.map +1 -1
  19. package/dist/export/createExport.d.ts +1 -2
  20. package/dist/export/createExport.d.ts.map +1 -1
  21. package/dist/export/createExport.js +2 -1
  22. package/dist/export/createExport.js.map +1 -1
  23. package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
  24. package/dist/export/getCreateExportCollectionTask.js +12 -1
  25. package/dist/export/getCreateExportCollectionTask.js.map +1 -1
  26. package/dist/export/getExportCollection.d.ts +5 -1
  27. package/dist/export/getExportCollection.d.ts.map +1 -1
  28. package/dist/export/getExportCollection.js +20 -5
  29. package/dist/export/getExportCollection.js.map +1 -1
  30. package/dist/export/getFields.d.ts +7 -1
  31. package/dist/export/getFields.d.ts.map +1 -1
  32. package/dist/export/getFields.js +15 -3
  33. package/dist/export/getFields.js.map +1 -1
  34. package/dist/exports/rsc.d.ts +0 -1
  35. package/dist/exports/rsc.d.ts.map +1 -1
  36. package/dist/exports/rsc.js +0 -1
  37. package/dist/exports/rsc.js.map +1 -1
  38. package/dist/import/batchProcessor.d.ts.map +1 -1
  39. package/dist/import/batchProcessor.js +9 -3
  40. package/dist/import/batchProcessor.js.map +1 -1
  41. package/dist/import/getFields.d.ts +7 -3
  42. package/dist/import/getFields.d.ts.map +1 -1
  43. package/dist/import/getFields.js +12 -7
  44. package/dist/import/getFields.js.map +1 -1
  45. package/dist/import/getImportCollection.d.ts +6 -3
  46. package/dist/import/getImportCollection.d.ts.map +1 -1
  47. package/dist/import/getImportCollection.js +7 -4
  48. package/dist/import/getImportCollection.js.map +1 -1
  49. package/dist/index.d.ts +5 -0
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +2 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/utilities/collectTimezoneCompanionFields.d.ts +24 -0
  54. package/dist/utilities/collectTimezoneCompanionFields.d.ts.map +1 -0
  55. package/dist/utilities/collectTimezoneCompanionFields.js +89 -0
  56. package/dist/utilities/collectTimezoneCompanionFields.js.map +1 -0
  57. package/dist/utilities/collectTimezoneCompanionFields.spec.js +319 -0
  58. package/dist/utilities/collectTimezoneCompanionFields.spec.js.map +1 -0
  59. package/dist/utilities/getFilename.d.ts +1 -1
  60. package/dist/utilities/getFilename.js +3 -3
  61. package/dist/utilities/getFilename.js.map +1 -1
  62. package/dist/utilities/getPluginCollections.d.ts.map +1 -1
  63. package/dist/utilities/getPluginCollections.js +106 -34
  64. package/dist/utilities/getPluginCollections.js.map +1 -1
  65. package/dist/utilities/getSchemaColumns.d.ts.map +1 -1
  66. package/dist/utilities/getSchemaColumns.js +9 -56
  67. package/dist/utilities/getSchemaColumns.js.map +1 -1
  68. package/dist/utilities/getSchemaColumns.spec.js +157 -0
  69. package/dist/utilities/getSchemaColumns.spec.js.map +1 -0
  70. package/dist/utilities/parseCSV.d.ts.map +1 -1
  71. package/dist/utilities/parseCSV.js +1 -0
  72. package/dist/utilities/parseCSV.js.map +1 -1
  73. package/dist/utilities/parseCSV.spec.js +26 -0
  74. package/dist/utilities/parseCSV.spec.js.map +1 -1
  75. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAKrC,OAAO,KAAK,EACV,eAAe,EACf,wBAAwB,EACxB,KAAK,EAEL,aAAa,EACd,MAAM,YAAY,CAAA;AAQnB,eAAO,MAAM,kBAAkB,iBACd,wBAAwB,cACxB,MAAM,KAAG,OAAO,CAAC,MAAM,CA2KrC,CAAA;AAEH,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAiB,WAAW;QAC1B,sBAAsB,CAAC,EAAE;YACvB;;;;;;eAMG;YACH,QAAQ,CAAC,EAAE,OAAO,CAAA;YAClB,OAAO,CAAC,EAAE,eAAe,CAAA;YACzB;;eAEG;YACH,KAAK,CAAC,EAAE,aAAa,CAAA;SACtB,CAAA;KACF;IAED,UAAiB,qBAAqB;QACpC,sBAAsB,CAAC,EAAE;YACvB;;;eAGG;YACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;YACzB;;;eAGG;YACH,YAAY,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;SAC9B,CAAA;KACF;IAED,UAAiB,gBAAgB;QAC/B,sBAAsB,CAAC,EAAE;YACvB;;;;eAIG;YACH,WAAW,CAAC,EAAE,KAAK,CAAA;YACnB;;;;eAIG;YACH,WAAW,CAAC,EAAE,KAAK,CAAA;SACpB,CAAA;KACF;CACF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAKrC,OAAO,KAAK,EACV,eAAe,EACf,wBAAwB,EACxB,KAAK,EAEL,aAAa,EACd,MAAM,YAAY,CAAA;AAQnB,eAAO,MAAM,kBAAkB,iBACd,wBAAwB,cACxB,MAAM,KAAG,OAAO,CAAC,MAAM,CA6KrC,CAAA;AAEH,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAiB,WAAW;QAC1B,sBAAsB,CAAC,EAAE;YACvB;;;;;;eAMG;YACH,QAAQ,CAAC,EAAE,OAAO,CAAA;YAClB,OAAO,CAAC,EAAE,eAAe,CAAA;YACzB;;eAEG;YACH,KAAK,CAAC,EAAE,aAAa,CAAA;SACtB,CAAA;KACF;IAED,UAAiB,qBAAqB;QACpC,sBAAsB,CAAC,EAAE;YACvB;;;eAGG;YACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;YAC1B;;;eAGG;YACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;YACzB;;;eAGG;YACH,YAAY,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;SAC9B,CAAA;KACF;IAED,UAAiB,gBAAgB;QAC/B,sBAAsB,CAAC,EAAE;YACvB;;;;eAIG;YACH,WAAW,CAAC,EAAE,KAAK,CAAA;YACnB;;;;eAIG;YACH,WAAW,CAAC,EAAE,KAAK,CAAA;SACpB,CAAA;KACF;CACF"}
package/dist/index.js CHANGED
@@ -75,6 +75,7 @@ export const importExportPlugin = (pluginConfig)=>async (config)=>{
75
75
  if (!exportDisabled) {
76
76
  components.listMenuItems.push({
77
77
  clientProps: {
78
+ collectionSlug: collection.slug,
78
79
  exportCollectionSlug: exportSlugForCollection
79
80
  },
80
81
  path: '@payloadcms/plugin-import-export/rsc#ExportListMenuItem'
@@ -84,6 +85,7 @@ export const importExportPlugin = (pluginConfig)=>async (config)=>{
84
85
  if (!importDisabled) {
85
86
  components.listMenuItems.push({
86
87
  clientProps: {
88
+ collectionSlug: collection.slug,
87
89
  importCollectionSlug: importSlugForCollection
88
90
  },
89
91
  path: '@payloadcms/plugin-import-export/rsc#ImportListMenuItem'
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 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 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 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","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,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KAAK,CAACC,KAAKC,MAAM;YAChBF,GAAG,CAACC,IAAI,GAAGC,MAAMpE,YAAY;YAC7B,OAAOkE;QACT,GACA,CAAC;QAGH7D,OAAOwD,IAAI,GAAG;YACZ,GAAGxD,OAAOwD,IAAI;YACd7D,cAAcH,gBAAgBiE,wBAAwBzD,OAAOwD,IAAI,EAAE7D,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\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,4CA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AM,IAAI,CAAC,CAAC;oBAC3B,wBAAwB;wBACtB,GAAIzC,WAAWyC,MAAM,EAAE,CAAC,uBAAuB,IAAI,CAAC,CAAC;wBACrD,GAAIH,gBAAgBJ,aAAa;4BAAEI;wBAAY,CAAC;wBAChD,GAAIE,gBAAgBN,aAAa;4BAAEM;wBAAY,CAAC;oBAClD;gBACF;YACF;YAEAxC,WAAWI,KAAK,CAACC,UAAU,GAAGA;QAChC;QAEA,IAAI,CAACnB,OAAOyD,IAAI,EAAE;YAChBzD,OAAOyD,IAAI,GAAG,CAAC;QACjB;QAEA;;KAEC,GACD,MAAMC,yBAAyBC,OAAOC,OAAO,CAACjE,cAAckE,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"}
@@ -0,0 +1,24 @@
1
+ import type { FlattenedField } from 'payload';
2
+ type FieldWithPresentational = {
3
+ fields?: FlattenedField[];
4
+ name?: string;
5
+ tabs?: {
6
+ fields: FlattenedField[];
7
+ name?: string;
8
+ }[];
9
+ type: 'collapsible' | 'row' | 'tabs';
10
+ } | FlattenedField;
11
+ /**
12
+ * Collects the names of auto-generated timezone companion fields from the schema.
13
+ *
14
+ * When a date field has `timezone: true`, Payload automatically generates a companion
15
+ * select field and inserts it immediately after the date field in the fields array.
16
+ * This function identifies those auto-generated fields by looking at the field sequence
17
+ * rather than assuming a specific naming convention (since the name can be overridden).
18
+ *
19
+ * This is used to filter out timezone companions unless explicitly selected,
20
+ * without incorrectly filtering user-defined fields that happen to end with `_tz`.
21
+ */
22
+ export declare const collectTimezoneCompanionFields: (fields: FieldWithPresentational[], prefix?: string) => Set<string>;
23
+ export {};
24
+ //# sourceMappingURL=collectTimezoneCompanionFields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectTimezoneCompanionFields.d.ts","sourceRoot":"","sources":["../../src/utilities/collectTimezoneCompanionFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,KAAK,uBAAuB,GACxB;IACE,MAAM,CAAC,EAAE,cAAc,EAAE,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,cAAc,EAAE,CAAA;QACxB,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;IACH,IAAI,EAAE,aAAa,GAAG,KAAK,GAAG,MAAM,CAAA;CACrC,GACD,cAAc,CAAA;AAElB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,8BAA8B,WACjC,uBAAuB,EAAE,sBAEhC,GAAG,CAAC,MAAM,CAmFZ,CAAA"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Collects the names of auto-generated timezone companion fields from the schema.
3
+ *
4
+ * When a date field has `timezone: true`, Payload automatically generates a companion
5
+ * select field and inserts it immediately after the date field in the fields array.
6
+ * This function identifies those auto-generated fields by looking at the field sequence
7
+ * rather than assuming a specific naming convention (since the name can be overridden).
8
+ *
9
+ * This is used to filter out timezone companions unless explicitly selected,
10
+ * without incorrectly filtering user-defined fields that happen to end with `_tz`.
11
+ */ export const collectTimezoneCompanionFields = (fields, prefix = '')=>{
12
+ const result = new Set();
13
+ for(let i = 0; i < fields.length; i++){
14
+ const field = fields[i];
15
+ if (!field) {
16
+ continue;
17
+ }
18
+ const name = 'name' in field && typeof field.name === 'string' ? field.name : undefined;
19
+ const fullKey = name && prefix ? `${prefix}_${name}` : name ?? prefix;
20
+ switch(field.type){
21
+ case 'array':
22
+ {
23
+ // Recurse into array fields - companion fields inside arrays get the array prefix
24
+ const subFields = collectTimezoneCompanionFields(field.fields, fullKey);
25
+ for (const subField of subFields){
26
+ result.add(subField);
27
+ }
28
+ break;
29
+ }
30
+ case 'blocks':
31
+ {
32
+ // Recurse into each block type
33
+ for (const block of field.blocks){
34
+ if (typeof block === 'string') {
35
+ continue; // Skip block references
36
+ }
37
+ const blockPrefix = `${fullKey}_${block.slug}`;
38
+ const blockFields = collectTimezoneCompanionFields(block.flattenedFields ?? block.fields, blockPrefix);
39
+ for (const blockField of blockFields){
40
+ result.add(blockField);
41
+ }
42
+ }
43
+ break;
44
+ }
45
+ case 'collapsible':
46
+ case 'group':
47
+ case 'row':
48
+ {
49
+ const subFields = collectTimezoneCompanionFields(field.fields, fullKey);
50
+ for (const subField of subFields){
51
+ result.add(subField);
52
+ }
53
+ break;
54
+ }
55
+ case 'date':
56
+ {
57
+ // If this date field has timezone enabled, the next field should be the companion
58
+ // (Payload splices it in right after the date field during sanitization)
59
+ if ('timezone' in field && field.timezone) {
60
+ const nextField = fields[i + 1];
61
+ if (nextField && 'name' in nextField && nextField.type === 'select') {
62
+ const companionName = prefix ? `${prefix}_${nextField.name}` : nextField.name;
63
+ result.add(companionName);
64
+ }
65
+ }
66
+ break;
67
+ }
68
+ case 'tabs':
69
+ {
70
+ for (const tab of field.tabs ?? []){
71
+ let tabPrefix;
72
+ if (tab.name) {
73
+ tabPrefix = fullKey ? `${fullKey}_${tab.name}` : tab.name;
74
+ } else {
75
+ tabPrefix = fullKey;
76
+ }
77
+ const tabFields = collectTimezoneCompanionFields(tab.fields || [], tabPrefix);
78
+ for (const tabField of tabFields){
79
+ result.add(tabField);
80
+ }
81
+ }
82
+ break;
83
+ }
84
+ }
85
+ }
86
+ return result;
87
+ };
88
+
89
+ //# sourceMappingURL=collectTimezoneCompanionFields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/collectTimezoneCompanionFields.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\ntype FieldWithPresentational =\n | {\n fields?: FlattenedField[]\n name?: string\n tabs?: {\n fields: FlattenedField[]\n name?: string\n }[]\n type: 'collapsible' | 'row' | 'tabs'\n }\n | FlattenedField\n\n/**\n * Collects the names of auto-generated timezone companion fields from the schema.\n *\n * When a date field has `timezone: true`, Payload automatically generates a companion\n * select field and inserts it immediately after the date field in the fields array.\n * This function identifies those auto-generated fields by looking at the field sequence\n * rather than assuming a specific naming convention (since the name can be overridden).\n *\n * This is used to filter out timezone companions unless explicitly selected,\n * without incorrectly filtering user-defined fields that happen to end with `_tz`.\n */\nexport const collectTimezoneCompanionFields = (\n fields: FieldWithPresentational[],\n prefix = '',\n): Set<string> => {\n const result = new Set<string>()\n\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i]\n\n if (!field) {\n continue\n }\n\n const name = 'name' in field && typeof field.name === 'string' ? field.name : undefined\n const fullKey = name && prefix ? `${prefix}_${name}` : (name ?? prefix)\n\n switch (field.type) {\n case 'array': {\n // Recurse into array fields - companion fields inside arrays get the array prefix\n const subFields = collectTimezoneCompanionFields(field.fields as FlattenedField[], fullKey)\n for (const subField of subFields) {\n result.add(subField)\n }\n break\n }\n\n case 'blocks': {\n // Recurse into each block type\n for (const block of field.blocks) {\n if (typeof block === 'string') {\n continue // Skip block references\n }\n const blockPrefix = `${fullKey}_${block.slug}`\n const blockFields = collectTimezoneCompanionFields(\n block.flattenedFields ?? block.fields,\n blockPrefix,\n )\n for (const blockField of blockFields) {\n result.add(blockField)\n }\n }\n break\n }\n\n case 'collapsible':\n case 'group':\n case 'row': {\n const subFields = collectTimezoneCompanionFields(field.fields as FlattenedField[], fullKey)\n for (const subField of subFields) {\n result.add(subField)\n }\n break\n }\n\n case 'date': {\n // If this date field has timezone enabled, the next field should be the companion\n // (Payload splices it in right after the date field during sanitization)\n if ('timezone' in field && field.timezone) {\n const nextField = fields[i + 1]\n if (nextField && 'name' in nextField && nextField.type === 'select') {\n const companionName = prefix ? `${prefix}_${nextField.name}` : nextField.name\n result.add(companionName)\n }\n }\n break\n }\n\n case 'tabs': {\n for (const tab of field.tabs ?? []) {\n let tabPrefix: string\n if (tab.name) {\n tabPrefix = fullKey ? `${fullKey}_${tab.name}` : tab.name\n } else {\n tabPrefix = fullKey\n }\n const tabFields = collectTimezoneCompanionFields(tab.fields || [], tabPrefix)\n for (const tabField of tabFields) {\n result.add(tabField)\n }\n }\n break\n }\n }\n }\n\n return result\n}\n"],"names":["collectTimezoneCompanionFields","fields","prefix","result","Set","i","length","field","name","undefined","fullKey","type","subFields","subField","add","block","blocks","blockPrefix","slug","blockFields","flattenedFields","blockField","timezone","nextField","companionName","tab","tabs","tabPrefix","tabFields","tabField"],"mappings":"AAcA;;;;;;;;;;CAUC,GACD,OAAO,MAAMA,iCAAiC,CAC5CC,QACAC,SAAS,EAAE;IAEX,MAAMC,SAAS,IAAIC;IAEnB,IAAK,IAAIC,IAAI,GAAGA,IAAIJ,OAAOK,MAAM,EAAED,IAAK;QACtC,MAAME,QAAQN,MAAM,CAACI,EAAE;QAEvB,IAAI,CAACE,OAAO;YACV;QACF;QAEA,MAAMC,OAAO,UAAUD,SAAS,OAAOA,MAAMC,IAAI,KAAK,WAAWD,MAAMC,IAAI,GAAGC;QAC9E,MAAMC,UAAUF,QAAQN,SAAS,GAAGA,OAAO,CAAC,EAAEM,MAAM,GAAIA,QAAQN;QAEhE,OAAQK,MAAMI,IAAI;YAChB,KAAK;gBAAS;oBACZ,kFAAkF;oBAClF,MAAMC,YAAYZ,+BAA+BO,MAAMN,MAAM,EAAsBS;oBACnF,KAAK,MAAMG,YAAYD,UAAW;wBAChCT,OAAOW,GAAG,CAACD;oBACb;oBACA;gBACF;YAEA,KAAK;gBAAU;oBACb,+BAA+B;oBAC/B,KAAK,MAAME,SAASR,MAAMS,MAAM,CAAE;wBAChC,IAAI,OAAOD,UAAU,UAAU;4BAC7B,UAAS,wBAAwB;wBACnC;wBACA,MAAME,cAAc,GAAGP,QAAQ,CAAC,EAAEK,MAAMG,IAAI,EAAE;wBAC9C,MAAMC,cAAcnB,+BAClBe,MAAMK,eAAe,IAAIL,MAAMd,MAAM,EACrCgB;wBAEF,KAAK,MAAMI,cAAcF,YAAa;4BACpChB,OAAOW,GAAG,CAACO;wBACb;oBACF;oBACA;gBACF;YAEA,KAAK;YACL,KAAK;YACL,KAAK;gBAAO;oBACV,MAAMT,YAAYZ,+BAA+BO,MAAMN,MAAM,EAAsBS;oBACnF,KAAK,MAAMG,YAAYD,UAAW;wBAChCT,OAAOW,GAAG,CAACD;oBACb;oBACA;gBACF;YAEA,KAAK;gBAAQ;oBACX,kFAAkF;oBAClF,yEAAyE;oBACzE,IAAI,cAAcN,SAASA,MAAMe,QAAQ,EAAE;wBACzC,MAAMC,YAAYtB,MAAM,CAACI,IAAI,EAAE;wBAC/B,IAAIkB,aAAa,UAAUA,aAAaA,UAAUZ,IAAI,KAAK,UAAU;4BACnE,MAAMa,gBAAgBtB,SAAS,GAAGA,OAAO,CAAC,EAAEqB,UAAUf,IAAI,EAAE,GAAGe,UAAUf,IAAI;4BAC7EL,OAAOW,GAAG,CAACU;wBACb;oBACF;oBACA;gBACF;YAEA,KAAK;gBAAQ;oBACX,KAAK,MAAMC,OAAOlB,MAAMmB,IAAI,IAAI,EAAE,CAAE;wBAClC,IAAIC;wBACJ,IAAIF,IAAIjB,IAAI,EAAE;4BACZmB,YAAYjB,UAAU,GAAGA,QAAQ,CAAC,EAAEe,IAAIjB,IAAI,EAAE,GAAGiB,IAAIjB,IAAI;wBAC3D,OAAO;4BACLmB,YAAYjB;wBACd;wBACA,MAAMkB,YAAY5B,+BAA+ByB,IAAIxB,MAAM,IAAI,EAAE,EAAE0B;wBACnE,KAAK,MAAME,YAAYD,UAAW;4BAChCzB,OAAOW,GAAG,CAACe;wBACb;oBACF;oBACA;gBACF;QACF;IACF;IAEA,OAAO1B;AACT,EAAC"}
@@ -0,0 +1,319 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { collectTimezoneCompanionFields } from './collectTimezoneCompanionFields.js';
3
+ describe('collectTimezoneCompanionFields', ()=>{
4
+ it('should return empty set for fields without date timezone', ()=>{
5
+ const fields = [
6
+ {
7
+ name: 'title',
8
+ type: 'text'
9
+ },
10
+ {
11
+ name: 'description',
12
+ type: 'textarea'
13
+ }
14
+ ];
15
+ const result = collectTimezoneCompanionFields(fields);
16
+ expect(result.size).toBe(0);
17
+ });
18
+ it('should return empty set for date fields without timezone enabled', ()=>{
19
+ const fields = [
20
+ {
21
+ name: 'publishedAt',
22
+ type: 'date'
23
+ },
24
+ {
25
+ name: 'createdAt',
26
+ type: 'date'
27
+ }
28
+ ];
29
+ const result = collectTimezoneCompanionFields(fields);
30
+ expect(result.size).toBe(0);
31
+ });
32
+ it('should collect timezone companion from the next select field after date with timezone', ()=>{
33
+ // Simulates sanitized fields where Payload inserts the companion right after the date
34
+ const fields = [
35
+ {
36
+ name: 'publishedAt',
37
+ type: 'date',
38
+ timezone: true
39
+ },
40
+ {
41
+ name: 'publishedAt_tz',
42
+ type: 'select',
43
+ options: []
44
+ }
45
+ ];
46
+ const result = collectTimezoneCompanionFields(fields);
47
+ expect(result.size).toBe(1);
48
+ expect(result.has('publishedAt_tz')).toBe(true);
49
+ });
50
+ it('should handle overridden timezone field names', ()=>{
51
+ // User overrode the timezone field name via timezone.override
52
+ const fields = [
53
+ {
54
+ name: 'publishedAt',
55
+ type: 'date',
56
+ timezone: true
57
+ },
58
+ {
59
+ name: 'pub_timezone',
60
+ type: 'select',
61
+ options: []
62
+ }
63
+ ];
64
+ const result = collectTimezoneCompanionFields(fields);
65
+ expect(result.size).toBe(1);
66
+ expect(result.has('pub_timezone')).toBe(true);
67
+ expect(result.has('publishedAt_tz')).toBe(false);
68
+ });
69
+ it('should collect multiple timezone companions', ()=>{
70
+ const fields = [
71
+ {
72
+ name: 'publishedAt',
73
+ type: 'date',
74
+ timezone: true
75
+ },
76
+ {
77
+ name: 'publishedAt_tz',
78
+ type: 'select',
79
+ options: []
80
+ },
81
+ {
82
+ name: 'title',
83
+ type: 'text'
84
+ },
85
+ {
86
+ name: 'scheduledAt',
87
+ type: 'date',
88
+ timezone: true
89
+ },
90
+ {
91
+ name: 'scheduledAt_tz',
92
+ type: 'select',
93
+ options: []
94
+ }
95
+ ];
96
+ const result = collectTimezoneCompanionFields(fields);
97
+ expect(result.size).toBe(2);
98
+ expect(result.has('publishedAt_tz')).toBe(true);
99
+ expect(result.has('scheduledAt_tz')).toBe(true);
100
+ });
101
+ it('should handle date fields in groups', ()=>{
102
+ const fields = [
103
+ {
104
+ name: 'meta',
105
+ type: 'group',
106
+ fields: [
107
+ {
108
+ name: 'publishedAt',
109
+ type: 'date',
110
+ timezone: true
111
+ },
112
+ {
113
+ name: 'publishedAt_tz',
114
+ type: 'select',
115
+ options: []
116
+ }
117
+ ]
118
+ }
119
+ ];
120
+ const result = collectTimezoneCompanionFields(fields);
121
+ expect(result.size).toBe(1);
122
+ expect(result.has('meta_publishedAt_tz')).toBe(true);
123
+ });
124
+ it('should handle date fields in arrays', ()=>{
125
+ const fields = [
126
+ {
127
+ name: 'events',
128
+ type: 'array',
129
+ fields: [
130
+ {
131
+ name: 'startTime',
132
+ type: 'date',
133
+ timezone: true
134
+ },
135
+ {
136
+ name: 'startTime_tz',
137
+ type: 'select',
138
+ options: []
139
+ }
140
+ ]
141
+ }
142
+ ];
143
+ const result = collectTimezoneCompanionFields(fields);
144
+ expect(result.size).toBe(1);
145
+ expect(result.has('events_startTime_tz')).toBe(true);
146
+ });
147
+ it('should handle date fields in blocks', ()=>{
148
+ const fields = [
149
+ {
150
+ name: 'layout',
151
+ type: 'blocks',
152
+ blocks: [
153
+ {
154
+ slug: 'event',
155
+ fields: [
156
+ {
157
+ name: 'eventDate',
158
+ type: 'date',
159
+ timezone: true
160
+ },
161
+ {
162
+ name: 'eventDate_tz',
163
+ type: 'select',
164
+ options: []
165
+ }
166
+ ]
167
+ }
168
+ ]
169
+ }
170
+ ];
171
+ const result = collectTimezoneCompanionFields(fields);
172
+ expect(result.size).toBe(1);
173
+ expect(result.has('layout_event_eventDate_tz')).toBe(true);
174
+ });
175
+ it('should handle deeply nested date fields', ()=>{
176
+ const fields = [
177
+ {
178
+ name: 'content',
179
+ type: 'group',
180
+ fields: [
181
+ {
182
+ name: 'schedule',
183
+ type: 'array',
184
+ fields: [
185
+ {
186
+ name: 'time',
187
+ type: 'date',
188
+ timezone: true
189
+ },
190
+ {
191
+ name: 'time_tz',
192
+ type: 'select',
193
+ options: []
194
+ }
195
+ ]
196
+ }
197
+ ]
198
+ }
199
+ ];
200
+ const result = collectTimezoneCompanionFields(fields);
201
+ expect(result.size).toBe(1);
202
+ expect(result.has('content_schedule_time_tz')).toBe(true);
203
+ });
204
+ it('should handle tabs', ()=>{
205
+ const fields = [
206
+ {
207
+ type: 'tabs',
208
+ tabs: [
209
+ {
210
+ name: 'scheduling',
211
+ fields: [
212
+ {
213
+ name: 'publishAt',
214
+ type: 'date',
215
+ timezone: true
216
+ },
217
+ {
218
+ name: 'publishAt_tz',
219
+ type: 'select',
220
+ options: []
221
+ }
222
+ ]
223
+ }
224
+ ]
225
+ }
226
+ ];
227
+ const result = collectTimezoneCompanionFields(fields);
228
+ expect(result.size).toBe(1);
229
+ expect(result.has('scheduling_publishAt_tz')).toBe(true);
230
+ });
231
+ it('should handle unnamed tabs (no prefix added)', ()=>{
232
+ const fields = [
233
+ {
234
+ type: 'tabs',
235
+ tabs: [
236
+ {
237
+ fields: [
238
+ {
239
+ name: 'publishAt',
240
+ type: 'date',
241
+ timezone: true
242
+ },
243
+ {
244
+ name: 'publishAt_tz',
245
+ type: 'select',
246
+ options: []
247
+ }
248
+ ]
249
+ }
250
+ ]
251
+ }
252
+ ];
253
+ const result = collectTimezoneCompanionFields(fields);
254
+ expect(result.size).toBe(1);
255
+ expect(result.has('publishAt_tz')).toBe(true);
256
+ });
257
+ it('should not include user-defined fields ending with _tz', ()=>{
258
+ const fields = [
259
+ {
260
+ name: 'my_tz',
261
+ type: 'text'
262
+ },
263
+ {
264
+ name: 'timezone_tz',
265
+ type: 'select',
266
+ options: []
267
+ },
268
+ {
269
+ name: 'publishedAt',
270
+ type: 'date',
271
+ timezone: true
272
+ },
273
+ {
274
+ name: 'publishedAt_tz',
275
+ type: 'select',
276
+ options: []
277
+ }
278
+ ];
279
+ const result = collectTimezoneCompanionFields(fields);
280
+ // Only the auto-generated timezone companion should be included
281
+ expect(result.size).toBe(1);
282
+ expect(result.has('publishedAt_tz')).toBe(true);
283
+ expect(result.has('my_tz')).toBe(false);
284
+ expect(result.has('timezone_tz')).toBe(false);
285
+ });
286
+ it('should not collect companion if next field is not a select', ()=>{
287
+ // Edge case: date with timezone but next field is not a select
288
+ const fields = [
289
+ {
290
+ name: 'publishedAt',
291
+ type: 'date',
292
+ timezone: true
293
+ },
294
+ {
295
+ name: 'title',
296
+ type: 'text'
297
+ }
298
+ ];
299
+ const result = collectTimezoneCompanionFields(fields);
300
+ expect(result.size).toBe(0);
301
+ });
302
+ it('should not collect companion if date is last field', ()=>{
303
+ const fields = [
304
+ {
305
+ name: 'title',
306
+ type: 'text'
307
+ },
308
+ {
309
+ name: 'publishedAt',
310
+ type: 'date',
311
+ timezone: true
312
+ }
313
+ ];
314
+ const result = collectTimezoneCompanionFields(fields);
315
+ expect(result.size).toBe(0);
316
+ });
317
+ });
318
+
319
+ //# sourceMappingURL=collectTimezoneCompanionFields.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/collectTimezoneCompanionFields.spec.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { collectTimezoneCompanionFields } from './collectTimezoneCompanionFields.js'\n\ndescribe('collectTimezoneCompanionFields', () => {\n it('should return empty set for fields without date timezone', () => {\n const fields: FlattenedField[] = [\n { name: 'title', type: 'text' },\n { name: 'description', type: 'textarea' },\n ]\n\n const result = collectTimezoneCompanionFields(fields)\n\n expect(result.size).toBe(0)\n })\n\n it('should return empty set for date fields without timezone enabled', () => {\n const fields: FlattenedField[] = [\n { name: 'publishedAt', type: 'date' },\n { name: 'createdAt', type: 'date' },\n ]\n\n const result = collectTimezoneCompanionFields(fields)\n\n expect(result.size).toBe(0)\n })\n\n it('should collect timezone companion from the next select field after date with timezone', () => {\n // Simulates sanitized fields where Payload inserts the companion right after the date\n const fields: FlattenedField[] = [\n { name: 'publishedAt', type: 'date', timezone: true },\n { name: 'publishedAt_tz', type: 'select', options: [] }, // auto-generated companion\n ]\n\n const result = collectTimezoneCompanionFields(fields)\n\n expect(result.size).toBe(1)\n expect(result.has('publishedAt_tz')).toBe(true)\n })\n\n it('should handle overridden timezone field names', () => {\n // User overrode the timezone field name via timezone.override\n const fields: FlattenedField[] = [\n { name: 'publishedAt', type: 'date', timezone: true },\n { name: 'pub_timezone', type: 'select', options: [] }, // overridden name\n ]\n\n const result = collectTimezoneCompanionFields(fields)\n\n expect(result.size).toBe(1)\n expect(result.has('pub_timezone')).toBe(true)\n expect(result.has('publishedAt_tz')).toBe(false)\n })\n\n it('should collect multiple timezone companions', () => {\n const fields: FlattenedField[] = [\n { name: 'publishedAt', type: 'date', timezone: true },\n { name: 'publishedAt_tz', type: 'select', options: [] },\n { name: 'title', type: 'text' },\n { name: 'scheduledAt', type: 'date', timezone: true },\n { name: 'scheduledAt_tz', type: 'select', options: [] },\n ]\n\n const result = collectTimezoneCompanionFields(fields)\n\n expect(result.size).toBe(2)\n expect(result.has('publishedAt_tz')).toBe(true)\n expect(result.has('scheduledAt_tz')).toBe(true)\n })\n\n it('should handle date fields in groups', () => {\n const fields: FlattenedField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n { name: 'publishedAt', type: 'date', timezone: true },\n { name: 'publishedAt_tz', type: 'select', options: [] },\n ],\n },\n ]\n\n const result = collectTimezoneCompanionFields(fields)\n\n expect(result.size).toBe(1)\n expect(result.has('meta_publishedAt_tz')).toBe(true)\n })\n\n it('should handle date fields in arrays', () => {\n const fields: FlattenedField[] = [\n {\n name: 'events',\n type: 'array',\n fields: [\n { name: 'startTime', type: 'date', timezone: true },\n { name: 'startTime_tz', type: 'select', options: [] },\n ],\n },\n ]\n\n const result = collectTimezoneCompanionFields(fields)\n\n expect(result.size).toBe(1)\n expect(result.has('events_startTime_tz')).toBe(true)\n })\n\n it('should handle date fields in blocks', () => {\n const fields: FlattenedField[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [\n {\n slug: 'event',\n fields: [\n { name: 'eventDate', type: 'date', timezone: true },\n { name: 'eventDate_tz', type: 'select', options: [] },\n ],\n },\n ],\n },\n ]\n\n const result = collectTimezoneCompanionFields(fields)\n\n expect(result.size).toBe(1)\n expect(result.has('layout_event_eventDate_tz')).toBe(true)\n })\n\n it('should handle deeply nested date fields', () => {\n const fields: FlattenedField[] = [\n {\n name: 'content',\n type: 'group',\n fields: [\n {\n name: 'schedule',\n type: 'array',\n fields: [\n { name: 'time', type: 'date', timezone: true },\n { name: 'time_tz', type: 'select', options: [] },\n ],\n },\n ],\n },\n ]\n\n const result = collectTimezoneCompanionFields(fields)\n\n expect(result.size).toBe(1)\n expect(result.has('content_schedule_time_tz')).toBe(true)\n })\n\n it('should handle tabs', () => {\n const fields: FlattenedField[] = [\n {\n type: 'tabs',\n tabs: [\n {\n name: 'scheduling',\n fields: [\n { name: 'publishAt', type: 'date', timezone: true },\n { name: 'publishAt_tz', type: 'select', options: [] },\n ],\n },\n ],\n },\n ]\n\n const result = collectTimezoneCompanionFields(fields)\n\n expect(result.size).toBe(1)\n expect(result.has('scheduling_publishAt_tz')).toBe(true)\n })\n\n it('should handle unnamed tabs (no prefix added)', () => {\n const fields: FlattenedField[] = [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n { name: 'publishAt', type: 'date', timezone: true },\n { name: 'publishAt_tz', type: 'select', options: [] },\n ],\n },\n ],\n },\n ]\n\n const result = collectTimezoneCompanionFields(fields)\n\n expect(result.size).toBe(1)\n expect(result.has('publishAt_tz')).toBe(true)\n })\n\n it('should not include user-defined fields ending with _tz', () => {\n const fields: FlattenedField[] = [\n { name: 'my_tz', type: 'text' },\n { name: 'timezone_tz', type: 'select', options: [] },\n { name: 'publishedAt', type: 'date', timezone: true },\n { name: 'publishedAt_tz', type: 'select', options: [] }, // actual companion\n ]\n\n const result = collectTimezoneCompanionFields(fields)\n\n // Only the auto-generated timezone companion should be included\n expect(result.size).toBe(1)\n expect(result.has('publishedAt_tz')).toBe(true)\n expect(result.has('my_tz')).toBe(false)\n expect(result.has('timezone_tz')).toBe(false)\n })\n\n it('should not collect companion if next field is not a select', () => {\n // Edge case: date with timezone but next field is not a select\n const fields: FlattenedField[] = [\n { name: 'publishedAt', type: 'date', timezone: true },\n { name: 'title', type: 'text' }, // not a select, so not a companion\n ]\n\n const result = collectTimezoneCompanionFields(fields)\n\n expect(result.size).toBe(0)\n })\n\n it('should not collect companion if date is last field', () => {\n const fields: FlattenedField[] = [\n { name: 'title', type: 'text' },\n { name: 'publishedAt', type: 'date', timezone: true },\n // no next field\n ]\n\n const result = collectTimezoneCompanionFields(fields)\n\n expect(result.size).toBe(0)\n })\n})\n"],"names":["describe","expect","it","collectTimezoneCompanionFields","fields","name","type","result","size","toBe","timezone","options","has","blocks","slug","tabs"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,8BAA8B,QAAQ,sCAAqC;AAEpFH,SAAS,kCAAkC;IACzCE,GAAG,4DAA4D;QAC7D,MAAME,SAA2B;YAC/B;gBAAEC,MAAM;gBAASC,MAAM;YAAO;YAC9B;gBAAED,MAAM;gBAAeC,MAAM;YAAW;SACzC;QAED,MAAMC,SAASJ,+BAA+BC;QAE9CH,OAAOM,OAAOC,IAAI,EAAEC,IAAI,CAAC;IAC3B;IAEAP,GAAG,oEAAoE;QACrE,MAAME,SAA2B;YAC/B;gBAAEC,MAAM;gBAAeC,MAAM;YAAO;YACpC;gBAAED,MAAM;gBAAaC,MAAM;YAAO;SACnC;QAED,MAAMC,SAASJ,+BAA+BC;QAE9CH,OAAOM,OAAOC,IAA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9B;gBAAED,MAAM;gBAAeC,MAAM;gBAAUK,SAAS,EAAE;YAAC;YACnD;gBAAEN,MAAM;gBAAeC,MAAM;gBAAQI,UAAU;YAAK;YACpD;gBAAEL,MAAM;gBAAkBC,MAAM;gBAAUK,SAAS,EAAE;YAAC;SACvD;QAED,MAAMJ,SAASJ,+BAA+BC;QAE9C,gEAAgE;QAChEH,OAAOM,OAAOC,IAAI,EAAEC,IAAI,CAAC;QACzBR,OAAOM,OAAOK,GAAG,CAAC,mBAAmBH,IAAI,CAAC;QAC1CR,OAAOM,OAAOK,GAAG,CAAC,UAAUH,IAAI,CAAC;QACjCR,OAAOM,OAAOK,GAAG,CAAC,gBAAgBH,IAAI,CAAC;IACzC;IAEAP,GAAG,8DAA8D;QAC/D,+DAA+D;QAC/D,MAAME,SAA2B;YAC/B;gBAAEC,MAAM;gBAAeC,MAAM;gBAAQI,UAAU;YAAK;YACpD;gBAAEL,MAAM;gBAASC,MAAM;YAAO;SAC/B;QAED,MAAMC,SAASJ,+BAA+BC;QAE9CH,OAAOM,OAAOC,IAAI,EAAEC,IAAI,CAAC;IAC3B;IAEAP,GAAG,sDAAsD;QACvD,MAAME,SAA2B;YAC/B;gBAAEC,MAAM;gBAASC,MAAM;YAAO;YAC9B;gBAAED,MAAM;gBAAeC,MAAM;gBAAQI,UAAU;YAAK;SAErD;QAED,MAAMH,SAASJ,+BAA+BC;QAE9CH,OAAOM,OAAOC,IAAI,EAAEC,IAAI,CAAC;IAC3B;AACF"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Generates a filename based on current date and time.
3
- * Format: "YYYY-MM-DD HH:MM:SS"
3
+ * Format: "YYYY-MM-DD_HH-MM-SS" (filesystem-safe characters)
4
4
  */
5
5
  export declare const getFilename: () => string;
6
6
  //# sourceMappingURL=getFilename.d.ts.map
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Generates a filename based on current date and time.
3
- * Format: "YYYY-MM-DD HH:MM:SS"
3
+ * Format: "YYYY-MM-DD_HH-MM-SS" (filesystem-safe characters)
4
4
  */ export const getFilename = ()=>{
5
5
  const now = new Date();
6
6
  const yyymmdd = now.toISOString().split('T')[0] // "YYYY-MM-DD"
7
7
  ;
8
- const hhmmss = now.toTimeString().split(' ')[0] // "HH:MM:SS"
8
+ const hhmmss = now.toTimeString().split(' ')[0]?.replace(/:/g, '-') || '' // "HH-MM-SS"
9
9
  ;
10
- return `${yyymmdd} ${hhmmss}`;
10
+ return `${yyymmdd}_${hhmmss}`;
11
11
  };
12
12
 
13
13
  //# sourceMappingURL=getFilename.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getFilename.ts"],"sourcesContent":["/**\n * Generates a filename based on current date and time.\n * Format: \"YYYY-MM-DD HH:MM:SS\"\n */\nexport const getFilename = () => {\n const now = new Date()\n const yyymmdd = now.toISOString().split('T')[0] // \"YYYY-MM-DD\"\n const hhmmss = now.toTimeString().split(' ')[0] // \"HH:MM:SS\"\n\n return `${yyymmdd} ${hhmmss}`\n}\n"],"names":["getFilename","now","Date","yyymmdd","toISOString","split","hhmmss","toTimeString"],"mappings":"AAAA;;;CAGC,GACD,OAAO,MAAMA,cAAc;IACzB,MAAMC,MAAM,IAAIC;IAChB,MAAMC,UAAUF,IAAIG,WAAW,GAAGC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,eAAe;;IAC/D,MAAMC,SAASL,IAAIM,YAAY,GAAGF,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa;;IAE7D,OAAO,GAAGF,QAAQ,CAAC,EAAEG,QAAQ;AAC/B,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/getFilename.ts"],"sourcesContent":["/**\n * Generates a filename based on current date and time.\n * Format: \"YYYY-MM-DD_HH-MM-SS\" (filesystem-safe characters)\n */\nexport const getFilename = () => {\n const now = new Date()\n const yyymmdd = now.toISOString().split('T')[0] // \"YYYY-MM-DD\"\n const hhmmss = now.toTimeString().split(' ')[0]?.replace(/:/g, '-') || '' // \"HH-MM-SS\"\n\n return `${yyymmdd}_${hhmmss}`\n}\n"],"names":["getFilename","now","Date","yyymmdd","toISOString","split","hhmmss","toTimeString","replace"],"mappings":"AAAA;;;CAGC,GACD,OAAO,MAAMA,cAAc;IACzB,MAAMC,MAAM,IAAIC;IAChB,MAAMC,UAAUF,IAAIG,WAAW,GAAGC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,eAAe;;IAC/D,MAAMC,SAASL,IAAIM,YAAY,GAAGF,KAAK,CAAC,IAAI,CAAC,EAAE,EAAEG,QAAQ,MAAM,QAAQ,GAAG,aAAa;;IAEvF,OAAO,GAAGL,QAAQ,CAAC,EAAEG,QAAQ;AAC/B,EAAC"}
@@ -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,EAA8B,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAKvF,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;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,8BAG9B;IACD,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,wBAAwB,CAAA;CACvC,KAAG,OAAO,CAAC,uBAAuB,CA8JlC,CAAA"}
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,EAA8B,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAKvF,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;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,8BAG9B;IACD,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,wBAAwB,CAAA;CACvC,KAAG,OAAO,CAAC,uBAAuB,CAuOlC,CAAA"}