@payloadcms/plugin-import-export 4.0.0-internal.38b7f1d → 4.0.0-internal.c2b57ce

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 (67) hide show
  1. package/dist/components/FieldsToExport/reduceFields.d.ts.map +1 -1
  2. package/dist/export/createExport.d.ts.map +1 -1
  3. package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
  4. package/dist/export/getExportCollection.d.ts.map +1 -1
  5. package/dist/export/getFields.d.ts.map +1 -1
  6. package/dist/export/handleDownload.d.ts.map +1 -1
  7. package/dist/export/handlePreview.d.ts.map +1 -1
  8. package/dist/export/handlePreview.js +1 -1
  9. package/dist/export/handlePreview.js.map +1 -1
  10. package/dist/exports/types.d.ts +1 -1
  11. package/dist/exports/types.d.ts.map +1 -1
  12. package/dist/exports/types.js.map +1 -1
  13. package/dist/import/createImport.d.ts.map +1 -1
  14. package/dist/import/createImport.js +1 -1
  15. package/dist/import/createImport.js.map +1 -1
  16. package/dist/import/getCreateImportCollectionTask.d.ts.map +1 -1
  17. package/dist/import/getFields.d.ts.map +1 -1
  18. package/dist/import/getImportCollection.d.ts.map +1 -1
  19. package/dist/import/handlePreview.d.ts.map +1 -1
  20. package/dist/index.d.ts +1 -11
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +13 -5
  23. package/dist/index.js.map +1 -1
  24. package/dist/types.d.ts +0 -32
  25. package/dist/types.d.ts.map +1 -1
  26. package/dist/types.js.map +1 -1
  27. package/dist/utilities/applyFieldHooks.d.ts +1 -2
  28. package/dist/utilities/applyFieldHooks.d.ts.map +1 -1
  29. package/dist/utilities/applyFieldHooks.js +1 -2
  30. package/dist/utilities/applyFieldHooks.js.map +1 -1
  31. package/dist/utilities/buildDisabledFieldRegex.d.ts.map +1 -1
  32. package/dist/utilities/collectDisabledFieldPaths.d.ts.map +1 -1
  33. package/dist/utilities/fieldToRegex.d.ts.map +1 -1
  34. package/dist/utilities/flattenObject.d.ts.map +1 -1
  35. package/dist/utilities/flattenObject.js +3 -13
  36. package/dist/utilities/flattenObject.js.map +1 -1
  37. package/dist/utilities/flattenedFields.d.ts.map +1 -1
  38. package/dist/utilities/getExportFieldFunctions.d.ts.map +1 -1
  39. package/dist/utilities/getExportFieldFunctions.js +0 -8
  40. package/dist/utilities/getExportFieldFunctions.js.map +1 -1
  41. package/dist/utilities/getFileFromDoc.d.ts.map +1 -1
  42. package/dist/utilities/getFlattenedFieldKeys.d.ts.map +1 -1
  43. package/dist/utilities/getImportFieldFunctions.d.ts.map +1 -1
  44. package/dist/utilities/getImportFieldFunctions.js +0 -8
  45. package/dist/utilities/getImportFieldFunctions.js.map +1 -1
  46. package/dist/utilities/getPluginCollections.d.ts.map +1 -1
  47. package/dist/utilities/getSchemaColumns.d.ts +1 -1
  48. package/dist/utilities/getSchemaColumns.d.ts.map +1 -1
  49. package/dist/utilities/getSchemaColumns.js +2 -2
  50. package/dist/utilities/getSchemaColumns.js.map +1 -1
  51. package/dist/utilities/getSelect.d.ts.map +1 -1
  52. package/dist/utilities/isPlainObject.d.ts.map +1 -1
  53. package/dist/utilities/parseCSV.d.ts.map +1 -1
  54. package/dist/utilities/parseJSON.d.ts.map +1 -1
  55. package/dist/utilities/polymorphicRel.d.ts.map +1 -1
  56. package/dist/utilities/processRichTextField.d.ts.map +1 -1
  57. package/dist/utilities/removeDisabledFields.d.ts.map +1 -1
  58. package/dist/utilities/setNestedValue.d.ts.map +1 -1
  59. package/dist/utilities/sortHelpers.d.ts.map +1 -1
  60. package/dist/utilities/unflattenObject.d.ts.map +1 -1
  61. package/dist/utilities/unflattenObject.js +8 -16
  62. package/dist/utilities/unflattenObject.js.map +1 -1
  63. package/dist/utilities/unflattenPostProcess.d.ts.map +1 -1
  64. package/dist/utilities/validateLimitValue.d.ts.map +1 -1
  65. package/package.json +8 -8
  66. package/dist/utilities/legacyHookDispatch.spec.js +0 -227
  67. package/dist/utilities/legacyHookDispatch.spec.js.map +0 -1
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionConfig,\n CollectionSlug,\n DataFromCollectionSlug,\n PayloadRequest,\n} 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\n/**\n * Result of a completed import operation (or a single batch within one)\n */\nexport type ImportResult = {\n errors: Array<{\n doc: Record<string, unknown>\n error: string\n index: number\n }>\n imported: number\n total: number\n updated: number\n}\n\n/**\n * Hook called before each export batch is written to file.\n * Receives the transformed batch data and the original DB documents.\n * Return the modified data array — it replaces `data` for the write step.\n */\nexport type ExportBeforeHook<TSlug extends CollectionSlug = CollectionSlug> = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /** Transformed batch — flat rows for CSV, nested docs for JSON. Modify and return this. */\n data: Record<string, unknown>[]\n /** Export format. Open-ended to support custom formats in the future. */\n format: 'csv' | 'json' | ({} & string)\n /**\n * Raw DB documents before format-specific transformation. Read-only reference.\n *\n * Typed as a union so call sites that don't know the collection slug at\n * compile time (e.g. job tasks) don't need `as any` casts. To get the\n * narrower typed shape, declare your hook with a slug:\n * `const hook: ExportBeforeHook<'posts'> = (args) => { ... }`.\n */\n originalData: DataFromCollectionSlug<TSlug>[] | Record<string, unknown>[]\n req: PayloadRequest\n /** Total number of batches for this export operation */\n totalBatches: number\n}) => Promise<Record<string, unknown>[]> | Record<string, unknown>[]\n\n/**\n * Hook called after each export batch has been written to file.\n * For logging and observability only — return value is ignored.\n */\nexport type ExportAfterHook = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /** The batch data that was written */\n data: Record<string, unknown>[]\n /** Export format */\n format: 'csv' | 'json' | ({} & string)\n /** Raw DB documents before transformation */\n originalData: Record<string, unknown>[]\n req: PayloadRequest\n /** Total number of batches for this export operation */\n totalBatches: number\n}) => Promise<void> | void\n\n/**\n * Hook called before each import batch is written to the database.\n * Receives the processed (unflattened) documents and the raw file rows.\n * Return the modified documents array — it replaces `data` for the DB write step.\n */\nexport type ImportBeforeHook<TSlug extends CollectionSlug = CollectionSlug> = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /**\n * Unflattened documents ready to be written to the database. Modify and\n * return this. Typed as `Partial<...>` because rows from a CSV or JSON\n * import are not guaranteed to include every required field of the\n * collection — required fields are validated at write time.\n */\n data: Partial<DataFromCollectionSlug<TSlug>>[]\n /** Import format. Open-ended to support custom formats in the future. */\n format: 'csv' | 'json' | ({} & string)\n /** Raw parsed file rows before unflattening. Read-only reference. */\n originalData: Record<string, unknown>[]\n req: PayloadRequest\n /** Total number of batches for this import operation */\n totalBatches: number\n}) => Partial<DataFromCollectionSlug<TSlug>>[] | Promise<Partial<DataFromCollectionSlug<TSlug>>[]>\n\n/**\n * Hook called after each import batch has been written to the database.\n * For logging and observability only — return value is ignored.\n */\nexport type ImportAfterHook = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /** Import format */\n format: 'csv' | 'json' | ({} & string)\n /**\n * Raw parsed file rows for this batch before unflattening and before-hook\n * transformation. For CSV this is the flat key/value row; for JSON this is\n * the top-level parsed document. Read-only reference.\n */\n originalData: Record<string, unknown>[]\n req: PayloadRequest\n /** Result of this batch — counts and errors. Not the cumulative total. */\n result: ImportResult\n /** Total number of batches for this import operation */\n totalBatches: number\n}) => Promise<void> | void\n\n/**\n * Per-collection export configuration. Set on each entry of\n * ```\n * importExportPlugin({ collections: [{ slug, export: { ... } }] })\n * ```\n */\nexport type ExportConfig<TSlug extends CollectionSlug = CollectionSlug> = {\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 * Lifecycle hooks for export operations on this collection.\n * Hooks fire once per batch.\n */\n hooks?: {\n /**\n * Called after each batch is written to file. For logging/observability only.\n * Return value is ignored.\n */\n after?: ExportAfterHook\n /**\n * Called before each batch is written to file.\n * Return value replaces the batch data for the write step.\n */\n before?: ExportBeforeHook<TSlug>\n }\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\n/**\n * Per-collection import configuration. Set on each entry of\n * ```\n * importExportPlugin({ collections: [{ slug, import: { ... } }] })\n * ```\n */\nexport type ImportConfig<TSlug extends CollectionSlug = CollectionSlug> = {\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 * Lifecycle hooks for import operations on this collection.\n * Hooks fire once per batch.\n */\n hooks?: {\n /**\n * Called after each batch is written to the database. For logging/observability only.\n * Return value is ignored.\n */\n after?: ImportAfterHook\n /**\n * Called before each batch is written to the database.\n * Return value replaces the batch data for the DB write step.\n */\n before?: ImportBeforeHook<TSlug>\n }\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\n/**\n * Per-collection plugin entry. Identifies a target collection by `slug` and\n * configures its export/import behavior; either side can be disabled with `false`.\n */\nexport type PluginCollectionConfig<TSlug extends CollectionSlug = CollectionSlug> = {\n /**\n * Override the import collection for this collection or disable it entirely with `false`.\n *\n * @default true\n */\n export?: boolean | ExportConfig<TSlug>\n /**\n * Override the export collection for this collection or disable it entirely with `false`.\n *\n * @default true\n */\n import?: boolean | ImportConfig<TSlug>\n /**\n * Target collection's slug for import/export functionality\n */\n slug: TSlug\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<CollectionSlug>[]\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 * Field-level hook that runs before a field value is exported. Works for both\n * CSV and JSON. Return a value to replace the field, or `undefined` to fall\n * back to default behavior. Mutate `siblingData` to add or remove columns at\n * the same level.\n *\n * Return `null` (CSV only) when the hook has already written its replacement\n * columns to `siblingData` and default flattening should be skipped — used by\n * built-in handlers for polymorphic relationships to avoid duplicate columns.\n */\nexport type FieldBeforeExportHook = (args: {\n /** Runtime column path, underscore-separated (includes array indices, e.g. `items_0_note`). */\n columnName: string\n /** The top-level document being exported. */\n data: Record<string, unknown>\n format: 'csv' | 'json' | ({} & string)\n /** Writable output at the current level. CSV: the flat row accumulator. JSON: the sibling output object. */\n siblingData: Record<string, unknown>\n /** Read-only source at the current level, before any transformation. */\n siblingDoc: Record<string, unknown>\n value: unknown\n}) => unknown\n\n/**\n * Field-level hook that runs before a field value is imported. Works for both\n * CSV and JSON. Return the transformed value to use for this field.\n */\nexport type FieldBeforeImportHook = (args: {\n columnName: string\n /** Full flat row (CSV) or top-level parsed document (JSON). */\n data: Record<string, unknown>\n format: 'csv' | 'json' | ({} & string)\n /** Data at the current level. CSV: same reference as `data`. JSON: the parent-level object. */\n siblingData: Record<string, unknown>\n /** Read-only source at the current level, before any transformation. CSV: same as `data`. */\n siblingDoc: Record<string, unknown>\n value: unknown\n}) => unknown\n\n/**\n * @deprecated use `hooks.beforeExport`. Will be removed in a future major version.\n * Original arg shape preserved for backwards compatibility.\n */\nexport type ToCSVFunction = (args: {\n columnName: string\n /** Alias for `row`. */\n data: Record<string, unknown>\n /** The top-level document being exported. */\n doc: Record<string, unknown>\n /** Flat row accumulator at the current level. Mutate to add columns. */\n row: Record<string, unknown>\n /** Source document at the current level. */\n siblingDoc: Record<string, unknown>\n value: unknown\n}) => unknown\n\n/**\n * @deprecated use `hooks.beforeImport`. Will be removed in a future major version.\n * Original arg shape preserved for backwards compatibility.\n */\nexport type FromCSVFunction = (args: {\n columnName: string\n /** The full flat row being imported. */\n data: Record<string, unknown>\n value: unknown\n}) => unknown\n\n/** @internal */\nexport type ExportFieldHookEntry =\n | { fn: FieldBeforeExportHook; type: 'beforeExport' }\n | { fn: ToCSVFunction; type: 'toCSV' }\n\n/** @internal */\nexport type ImportFieldHookEntry =\n | { fn: FieldBeforeImportHook; type: 'beforeImport' }\n | { fn: FromCSVFunction; type: 'fromCSV' }\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":"AAmdA;;CAEC,GACD,WASyB"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionConfig,\n CollectionSlug,\n DataFromCollectionSlug,\n PayloadRequest,\n} 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\n/**\n * Result of a completed import operation (or a single batch within one)\n */\nexport type ImportResult = {\n errors: Array<{\n doc: Record<string, unknown>\n error: string\n index: number\n }>\n imported: number\n total: number\n updated: number\n}\n\n/**\n * Hook called before each export batch is written to file.\n * Receives the transformed batch data and the original DB documents.\n * Return the modified data array — it replaces `data` for the write step.\n */\nexport type ExportBeforeHook<TSlug extends CollectionSlug = CollectionSlug> = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /** Transformed batch — flat rows for CSV, nested docs for JSON. Modify and return this. */\n data: Record<string, unknown>[]\n /** Export format. Open-ended to support custom formats in the future. */\n format: 'csv' | 'json' | ({} & string)\n /**\n * Raw DB documents before format-specific transformation. Read-only reference.\n *\n * Typed as a union so call sites that don't know the collection slug at\n * compile time (e.g. job tasks) don't need `as any` casts. To get the\n * narrower typed shape, declare your hook with a slug:\n * `const hook: ExportBeforeHook<'posts'> = (args) => { ... }`.\n */\n originalData: DataFromCollectionSlug<TSlug>[] | Record<string, unknown>[]\n req: PayloadRequest\n /** Total number of batches for this export operation */\n totalBatches: number\n}) => Promise<Record<string, unknown>[]> | Record<string, unknown>[]\n\n/**\n * Hook called after each export batch has been written to file.\n * For logging and observability only — return value is ignored.\n */\nexport type ExportAfterHook = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /** The batch data that was written */\n data: Record<string, unknown>[]\n /** Export format */\n format: 'csv' | 'json' | ({} & string)\n /** Raw DB documents before transformation */\n originalData: Record<string, unknown>[]\n req: PayloadRequest\n /** Total number of batches for this export operation */\n totalBatches: number\n}) => Promise<void> | void\n\n/**\n * Hook called before each import batch is written to the database.\n * Receives the processed (unflattened) documents and the raw file rows.\n * Return the modified documents array — it replaces `data` for the DB write step.\n */\nexport type ImportBeforeHook<TSlug extends CollectionSlug = CollectionSlug> = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /**\n * Unflattened documents ready to be written to the database. Modify and\n * return this. Typed as `Partial<...>` because rows from a CSV or JSON\n * import are not guaranteed to include every required field of the\n * collection — required fields are validated at write time.\n */\n data: Partial<DataFromCollectionSlug<TSlug>>[]\n /** Import format. Open-ended to support custom formats in the future. */\n format: 'csv' | 'json' | ({} & string)\n /** Raw parsed file rows before unflattening. Read-only reference. */\n originalData: Record<string, unknown>[]\n req: PayloadRequest\n /** Total number of batches for this import operation */\n totalBatches: number\n}) => Partial<DataFromCollectionSlug<TSlug>>[] | Promise<Partial<DataFromCollectionSlug<TSlug>>[]>\n\n/**\n * Hook called after each import batch has been written to the database.\n * For logging and observability only — return value is ignored.\n */\nexport type ImportAfterHook = (args: {\n /** Current batch number, starting at 1 */\n batchNumber: number\n /** Import format */\n format: 'csv' | 'json' | ({} & string)\n /**\n * Raw parsed file rows for this batch before unflattening and before-hook\n * transformation. For CSV this is the flat key/value row; for JSON this is\n * the top-level parsed document. Read-only reference.\n */\n originalData: Record<string, unknown>[]\n req: PayloadRequest\n /** Result of this batch — counts and errors. Not the cumulative total. */\n result: ImportResult\n /** Total number of batches for this import operation */\n totalBatches: number\n}) => Promise<void> | void\n\n/**\n * Per-collection export configuration. Set on each entry of\n * ```\n * importExportPlugin({ collections: [{ slug, export: { ... } }] })\n * ```\n */\nexport type ExportConfig<TSlug extends CollectionSlug = CollectionSlug> = {\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 * Lifecycle hooks for export operations on this collection.\n * Hooks fire once per batch.\n */\n hooks?: {\n /**\n * Called after each batch is written to file. For logging/observability only.\n * Return value is ignored.\n */\n after?: ExportAfterHook\n /**\n * Called before each batch is written to file.\n * Return value replaces the batch data for the write step.\n */\n before?: ExportBeforeHook<TSlug>\n }\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\n/**\n * Per-collection import configuration. Set on each entry of\n * ```\n * importExportPlugin({ collections: [{ slug, import: { ... } }] })\n * ```\n */\nexport type ImportConfig<TSlug extends CollectionSlug = CollectionSlug> = {\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 * Lifecycle hooks for import operations on this collection.\n * Hooks fire once per batch.\n */\n hooks?: {\n /**\n * Called after each batch is written to the database. For logging/observability only.\n * Return value is ignored.\n */\n after?: ImportAfterHook\n /**\n * Called before each batch is written to the database.\n * Return value replaces the batch data for the DB write step.\n */\n before?: ImportBeforeHook<TSlug>\n }\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\n/**\n * Per-collection plugin entry. Identifies a target collection by `slug` and\n * configures its export/import behavior; either side can be disabled with `false`.\n */\nexport type PluginCollectionConfig<TSlug extends CollectionSlug = CollectionSlug> = {\n /**\n * Override the import collection for this collection or disable it entirely with `false`.\n *\n * @default true\n */\n export?: boolean | ExportConfig<TSlug>\n /**\n * Override the export collection for this collection or disable it entirely with `false`.\n *\n * @default true\n */\n import?: boolean | ImportConfig<TSlug>\n /**\n * Target collection's slug for import/export functionality\n */\n slug: TSlug\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<CollectionSlug>[]\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 * Field-level hook that runs before a field value is exported. Works for both\n * CSV and JSON. Return a value to replace the field, or `undefined` to fall\n * back to default behavior. Mutate `siblingData` to add or remove columns at\n * the same level.\n *\n * Return `null` (CSV only) when the hook has already written its replacement\n * columns to `siblingData` and default flattening should be skipped — used by\n * built-in handlers for polymorphic relationships to avoid duplicate columns.\n */\nexport type FieldBeforeExportHook = (args: {\n /** Runtime column path, underscore-separated (includes array indices, e.g. `items_0_note`). */\n columnName: string\n /** The top-level document being exported. */\n data: Record<string, unknown>\n format: 'csv' | 'json' | ({} & string)\n /** Writable output at the current level. CSV: the flat row accumulator. JSON: the sibling output object. */\n siblingData: Record<string, unknown>\n /** Read-only source at the current level, before any transformation. */\n siblingDoc: Record<string, unknown>\n value: unknown\n}) => unknown\n\n/**\n * Field-level hook that runs before a field value is imported. Works for both\n * CSV and JSON. Return the transformed value to use for this field.\n */\nexport type FieldBeforeImportHook = (args: {\n columnName: string\n /** Full flat row (CSV) or top-level parsed document (JSON). */\n data: Record<string, unknown>\n format: 'csv' | 'json' | ({} & string)\n /** Data at the current level. CSV: same reference as `data`. JSON: the parent-level object. */\n siblingData: Record<string, unknown>\n /** Read-only source at the current level, before any transformation. CSV: same as `data`. */\n siblingDoc: Record<string, unknown>\n value: unknown\n}) => unknown\n\n/** @internal */\nexport type ExportFieldHookEntry = { fn: FieldBeforeExportHook; type: 'beforeExport' }\n\n/** @internal */\nexport type ImportFieldHookEntry = { fn: FieldBeforeImportHook; type: 'beforeImport' }\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":"AAmbA;;CAEC,GACD,WASyB"}
@@ -13,8 +13,7 @@ export type Args = {
13
13
  };
14
14
  /**
15
15
  * Walks a nested document and applies each field's `beforeExport` or
16
- * `beforeImport` hook. Legacy `toCSV` / `fromCSV` hooks are handled by the
17
- * flat CSV pipelines and skipped here.
16
+ * `beforeImport` hook.
18
17
  *
19
18
  * Field-level hook errors are logged and the field falls back to its
20
19
  * original value so a single bad doc does not abort the batch.
@@ -1 +1 @@
1
- {"version":3,"file":"applyFieldHooks.d.ts","sourceRoot":"","sources":["../../src/utilities/applyFieldHooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7D,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,aAAa,CAAA;AAIpB,MAAM,MAAM,SAAS,GAAG,qBAAqB,GAAG,qBAAqB,CAAA;AAErE,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG,oBAAoB,CAAA;AAKxE,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAC1C,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,CAAA;IACtC,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,cAAc,GAAG,cAAc,CAAA;CACtC,CAAA;AAuHD;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,SAAU,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAYlE,CAAA"}
1
+ {"version":3,"file":"applyFieldHooks.d.ts","sourceRoot":"","sources":["../../src/utilities/applyFieldHooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7D,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,aAAa,CAAA;AAIpB,MAAM,MAAM,SAAS,GAAG,qBAAqB,GAAG,qBAAqB,CAAA;AAErE,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG,oBAAoB,CAAA;AAKxE,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAC1C,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,CAAA;IACtC,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,cAAc,GAAG,cAAc,CAAA;CACtC,CAAA;AAuHD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAYlE,CAAA"}
@@ -97,8 +97,7 @@ const traverseFields = ({ type, data, fieldHooks, fields, format, operation, pat
97
97
  };
98
98
  /**
99
99
  * Walks a nested document and applies each field's `beforeExport` or
100
- * `beforeImport` hook. Legacy `toCSV` / `fromCSV` hooks are handled by the
101
- * flat CSV pipelines and skipped here.
100
+ * `beforeImport` hook.
102
101
  *
103
102
  * Field-level hook errors are logged and the field falls back to its
104
103
  * original value so a single bad doc does not abort the batch.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/applyFieldHooks.ts"],"sourcesContent":["import type { FlattenedField, PayloadRequest } from 'payload'\n\nimport type {\n ExportFieldHookEntry,\n FieldBeforeExportHook,\n FieldBeforeImportHook,\n ImportFieldHookEntry,\n} from '../types.js'\n\nimport { isPlainObject } from './isPlainObject.js'\n\nexport type FieldHook = FieldBeforeExportHook | FieldBeforeImportHook\n\nexport type FieldHookEntry = ExportFieldHookEntry | ImportFieldHookEntry\n\nconst joinPath = (parent: string | undefined, segment: string): string =>\n parent ? `${parent}_${segment}` : segment\n\nexport type Args = {\n data: Record<string, unknown>\n fieldHooks: Record<string, FieldHookEntry>\n fields: FlattenedField[]\n format: 'csv' | 'json' | ({} & string)\n operation: 'export' | 'import'\n req: PayloadRequest\n type: 'beforeExport' | 'beforeImport'\n}\n\nconst operationLabel = { export: 'Export', import: 'Import' } as const\n\ntype TraverseArgs = {\n path: string | undefined\n schemaPath: string | undefined\n siblingData: Record<string, unknown>\n} & Args\n\nconst traverseFields = ({\n type,\n data,\n fieldHooks,\n fields,\n format,\n operation,\n path,\n req,\n schemaPath,\n siblingData,\n}: TraverseArgs): Record<string, unknown> => {\n const result: Record<string, unknown> = { ...siblingData }\n\n for (const field of fields) {\n if (!('name' in field) || !field.name) {\n continue\n }\n\n const fieldPath = joinPath(path, field.name)\n const fieldSchemaPath = joinPath(schemaPath, field.name)\n const entry = fieldHooks[fieldSchemaPath]\n const hook = entry?.type === type ? (entry.fn as FieldHook) : undefined\n\n if (typeof hook === 'function' && field.name in result) {\n try {\n const transformed = hook({\n columnName: fieldPath,\n data,\n format,\n siblingData: result,\n siblingDoc: siblingData,\n value: result[field.name],\n })\n\n if (typeof transformed !== 'undefined') {\n result[field.name] = transformed\n }\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `[plugin-import-export] Field-level before${operationLabel[operation]} hook for \"${fieldPath}\" threw — falling back to original value`,\n })\n }\n }\n\n if (!(field.name in result)) {\n continue\n }\n\n const value = result[field.name]\n\n if ((field.type === 'group' || field.type === 'tab') && isPlainObject(value)) {\n result[field.name] = traverseFields({\n type,\n data,\n fieldHooks,\n fields: field.flattenedFields,\n format,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: value,\n })\n } else if (field.type === 'array' && Array.isArray(value)) {\n result[field.name] = value.map((item, index) => {\n if (!isPlainObject(item)) {\n return item\n }\n return traverseFields({\n type,\n data,\n fieldHooks,\n fields: field.flattenedFields,\n format,\n operation,\n path: `${fieldPath}_${index}`,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: item,\n })\n })\n } else if (field.type === 'blocks' && Array.isArray(value)) {\n result[field.name] = value.map((item, index) => {\n if (!isPlainObject(item)) {\n return item\n }\n const blockType = typeof item.blockType === 'string' ? item.blockType : undefined\n const block = blockType ? field.blocks.find((b) => b.slug === blockType) : undefined\n return traverseFields({\n type,\n data,\n fieldHooks,\n fields: block?.flattenedFields ?? [],\n format,\n operation,\n path: blockType ? `${fieldPath}_${index}_${blockType}` : `${fieldPath}_${index}`,\n req,\n schemaPath: blockType ? `${fieldSchemaPath}_${blockType}` : fieldSchemaPath,\n siblingData: item,\n })\n })\n }\n }\n\n return result\n}\n\n/**\n * Walks a nested document and applies each field's `beforeExport` or\n * `beforeImport` hook. Legacy `toCSV` / `fromCSV` hooks are handled by the\n * flat CSV pipelines and skipped here.\n *\n * Field-level hook errors are logged and the field falls back to its\n * original value so a single bad doc does not abort the batch.\n */\nexport const applyFieldHooks = (args: Args): Record<string, unknown> => {\n const { data, fieldHooks } = args\n if (!data || typeof data !== 'object' || Object.keys(fieldHooks).length === 0) {\n return data\n }\n\n return traverseFields({\n ...args,\n path: undefined,\n schemaPath: undefined,\n siblingData: data,\n })\n}\n"],"names":["isPlainObject","joinPath","parent","segment","operationLabel","export","import","traverseFields","type","data","fieldHooks","fields","format","operation","path","req","schemaPath","siblingData","result","field","name","fieldPath","fieldSchemaPath","entry","hook","fn","undefined","transformed","columnName","siblingDoc","value","error","payload","logger","err","msg","flattenedFields","Array","isArray","map","item","index","blockType","block","blocks","find","b","slug","applyFieldHooks","args","Object","keys","length"],"mappings":"AASA,SAASA,aAAa,QAAQ,qBAAoB;AAMlD,MAAMC,WAAW,CAACC,QAA4BC,UAC5CD,SAAS,GAAGA,OAAO,CAAC,EAAEC,SAAS,GAAGA;AAYpC,MAAMC,iBAAiB;IAAEC,QAAQ;IAAUC,QAAQ;AAAS;AAQ5D,MAAMC,iBAAiB,CAAC,EACtBC,IAAI,EACJC,IAAI,EACJC,UAAU,EACVC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,IAAI,EACJC,GAAG,EACHC,UAAU,EACVC,WAAW,EACE;IACb,MAAMC,SAAkC;QAAE,GAAGD,WAAW;IAAC;IAEzD,KAAK,MAAME,SAASR,OAAQ;QAC1B,IAAI,CAAE,CAAA,UAAUQ,KAAI,KAAM,CAACA,MAAMC,IAAI,EAAE;YACrC;QACF;QAEA,MAAMC,YAAYpB,SAASa,MAAMK,MAAMC,IAAI;QAC3C,MAAME,kBAAkBrB,SAASe,YAAYG,MAAMC,IAAI;QACvD,MAAMG,QAAQb,UAAU,CAACY,gBAAgB;QACzC,MAAME,OAAOD,OAAOf,SAASA,OAAQe,MAAME,EAAE,GAAiBC;QAE9D,IAAI,OAAOF,SAAS,cAAcL,MAAMC,IAAI,IAAIF,QAAQ;YACtD,IAAI;gBACF,MAAMS,cAAcH,KAAK;oBACvBI,YAAYP;oBACZZ;oBACAG;oBACAK,aAAaC;oBACbW,YAAYZ;oBACZa,OAAOZ,MAAM,CAACC,MAAMC,IAAI,CAAC;gBAC3B;gBAEA,IAAI,OAAOO,gBAAgB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AI,CAACzC,cAAcwC,OAAO;oBACxB,OAAOA;gBACT;gBACA,MAAME,YAAY,OAAOF,KAAKE,SAAS,KAAK,WAAWF,KAAKE,SAAS,GAAGhB;gBACxE,MAAMiB,QAAQD,YAAYvB,MAAMyB,MAAM,CAACC,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKL,aAAahB;gBAC3E,OAAOnB,eAAe;oBACpBC;oBACAC;oBACAC;oBACAC,QAAQgC,OAAOP,mBAAmB,EAAE;oBACpCxB;oBACAC;oBACAC,MAAM4B,YAAY,GAAGrB,UAAU,CAAC,EAAEoB,MAAM,CAAC,EAAEC,WAAW,GAAG,GAAGrB,UAAU,CAAC,EAAEoB,OAAO;oBAChF1B;oBACAC,YAAY0B,YAAY,GAAGpB,gBAAgB,CAAC,EAAEoB,WAAW,GAAGpB;oBAC5DL,aAAauB;gBACf;YACF;QACF;IACF;IAEA,OAAOtB;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,MAAM8B,kBAAkB,CAACC;IAC9B,MAAM,EAAExC,IAAI,EAAEC,UAAU,EAAE,GAAGuC;IAC7B,IAAI,CAACxC,QAAQ,OAAOA,SAAS,YAAYyC,OAAOC,IAAI,CAACzC,YAAY0C,MAAM,KAAK,GAAG;QAC7E,OAAO3C;IACT;IAEA,OAAOF,eAAe;QACpB,GAAG0C,IAAI;QACPnC,MAAMY;QACNV,YAAYU;QACZT,aAAaR;IACf;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/applyFieldHooks.ts"],"sourcesContent":["import type { FlattenedField, PayloadRequest } from 'payload'\n\nimport type {\n ExportFieldHookEntry,\n FieldBeforeExportHook,\n FieldBeforeImportHook,\n ImportFieldHookEntry,\n} from '../types.js'\n\nimport { isPlainObject } from './isPlainObject.js'\n\nexport type FieldHook = FieldBeforeExportHook | FieldBeforeImportHook\n\nexport type FieldHookEntry = ExportFieldHookEntry | ImportFieldHookEntry\n\nconst joinPath = (parent: string | undefined, segment: string): string =>\n parent ? `${parent}_${segment}` : segment\n\nexport type Args = {\n data: Record<string, unknown>\n fieldHooks: Record<string, FieldHookEntry>\n fields: FlattenedField[]\n format: 'csv' | 'json' | ({} & string)\n operation: 'export' | 'import'\n req: PayloadRequest\n type: 'beforeExport' | 'beforeImport'\n}\n\nconst operationLabel = { export: 'Export', import: 'Import' } as const\n\ntype TraverseArgs = {\n path: string | undefined\n schemaPath: string | undefined\n siblingData: Record<string, unknown>\n} & Args\n\nconst traverseFields = ({\n type,\n data,\n fieldHooks,\n fields,\n format,\n operation,\n path,\n req,\n schemaPath,\n siblingData,\n}: TraverseArgs): Record<string, unknown> => {\n const result: Record<string, unknown> = { ...siblingData }\n\n for (const field of fields) {\n if (!('name' in field) || !field.name) {\n continue\n }\n\n const fieldPath = joinPath(path, field.name)\n const fieldSchemaPath = joinPath(schemaPath, field.name)\n const entry = fieldHooks[fieldSchemaPath]\n const hook = entry?.type === type ? (entry.fn as FieldHook) : undefined\n\n if (typeof hook === 'function' && field.name in result) {\n try {\n const transformed = hook({\n columnName: fieldPath,\n data,\n format,\n siblingData: result,\n siblingDoc: siblingData,\n value: result[field.name],\n })\n\n if (typeof transformed !== 'undefined') {\n result[field.name] = transformed\n }\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `[plugin-import-export] Field-level before${operationLabel[operation]} hook for \"${fieldPath}\" threw — falling back to original value`,\n })\n }\n }\n\n if (!(field.name in result)) {\n continue\n }\n\n const value = result[field.name]\n\n if ((field.type === 'group' || field.type === 'tab') && isPlainObject(value)) {\n result[field.name] = traverseFields({\n type,\n data,\n fieldHooks,\n fields: field.flattenedFields,\n format,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: value,\n })\n } else if (field.type === 'array' && Array.isArray(value)) {\n result[field.name] = value.map((item, index) => {\n if (!isPlainObject(item)) {\n return item\n }\n return traverseFields({\n type,\n data,\n fieldHooks,\n fields: field.flattenedFields,\n format,\n operation,\n path: `${fieldPath}_${index}`,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: item,\n })\n })\n } else if (field.type === 'blocks' && Array.isArray(value)) {\n result[field.name] = value.map((item, index) => {\n if (!isPlainObject(item)) {\n return item\n }\n const blockType = typeof item.blockType === 'string' ? item.blockType : undefined\n const block = blockType ? field.blocks.find((b) => b.slug === blockType) : undefined\n return traverseFields({\n type,\n data,\n fieldHooks,\n fields: block?.flattenedFields ?? [],\n format,\n operation,\n path: blockType ? `${fieldPath}_${index}_${blockType}` : `${fieldPath}_${index}`,\n req,\n schemaPath: blockType ? `${fieldSchemaPath}_${blockType}` : fieldSchemaPath,\n siblingData: item,\n })\n })\n }\n }\n\n return result\n}\n\n/**\n * Walks a nested document and applies each field's `beforeExport` or\n * `beforeImport` hook.\n *\n * Field-level hook errors are logged and the field falls back to its\n * original value so a single bad doc does not abort the batch.\n */\nexport const applyFieldHooks = (args: Args): Record<string, unknown> => {\n const { data, fieldHooks } = args\n if (!data || typeof data !== 'object' || Object.keys(fieldHooks).length === 0) {\n return data\n }\n\n return traverseFields({\n ...args,\n path: undefined,\n schemaPath: undefined,\n siblingData: data,\n })\n}\n"],"names":["isPlainObject","joinPath","parent","segment","operationLabel","export","import","traverseFields","type","data","fieldHooks","fields","format","operation","path","req","schemaPath","siblingData","result","field","name","fieldPath","fieldSchemaPath","entry","hook","fn","undefined","transformed","columnName","siblingDoc","value","error","payload","logger","err","msg","flattenedFields","Array","isArray","map","item","index","blockType","block","blocks","find","b","slug","applyFieldHooks","args","Object","keys","length"],"mappings":"AASA,SAASA,aAAa,QAAQ,qBAAoB;AAMlD,MAAMC,WAAW,CAACC,QAA4BC,UAC5CD,SAAS,GAAGA,OAAO,CAAC,EAAEC,SAAS,GAAGA;AAYpC,MAAMC,iBAAiB;IAAEC,QAAQ;IAAUC,QAAQ;AAAS;AAQ5D,MAAMC,iBAAiB,CAAC,EACtBC,IAAI,EACJC,IAAI,EACJC,UAAU,EACVC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,IAAI,EAC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,GACD,OAAO,MAAM8B,kBAAkB,CAACC;IAC9B,MAAM,EAAExC,IAAI,EAAEC,UAAU,EAAE,GAAGuC;IAC7B,IAAI,CAACxC,QAAQ,OAAOA,SAAS,YAAYyC,OAAOC,IAAI,CAACzC,YAAY0C,MAAM,KAAK,GAAG;QAC7E,OAAO3C;IACT;IAEA,OAAOF,eAAe;QACpB,GAAG0C,IAAI;QACPnC,MAAMY;QACNV,YAAYU;QACZT,aAAaR;IACf;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildDisabledFieldRegex.d.ts","sourceRoot":"","sources":["../../src/utilities/buildDisabledFieldRegex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,cAAe,MAAM,KAAG,MAyB3D,CAAA"}
1
+ {"version":3,"file":"buildDisabledFieldRegex.d.ts","sourceRoot":"","sources":["../../src/utilities/buildDisabledFieldRegex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,GAAI,WAAW,MAAM,KAAG,MAyB3D,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"collectDisabledFieldPaths.d.ts","sourceRoot":"","sources":["../../src/utilities/collectDisabledFieldPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAKpC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,WAAY,KAAK,EAAE,KAAG,MAAM,EAmEjE,CAAA"}
1
+ {"version":3,"file":"collectDisabledFieldPaths.d.ts","sourceRoot":"","sources":["../../src/utilities/collectDisabledFieldPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAKpC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,KAAK,EAAE,KAAG,MAAM,EAmEjE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"fieldToRegex.d.ts","sourceRoot":"","sources":["../../src/utilities/fieldToRegex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,cAAe,MAAM,KAAG,MAoBhD,CAAA"}
1
+ {"version":3,"file":"fieldToRegex.d.ts","sourceRoot":"","sources":["../../src/utilities/fieldToRegex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAI,WAAW,MAAM,KAAG,MAoBhD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"flattenObject.d.ts","sourceRoot":"","sources":["../../src/utilities/flattenObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAMvD,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IACtD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,CAAA;IACtC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,aAAa,2DAOvB,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAqL/B,CAAA"}
1
+ {"version":3,"file":"flattenObject.d.ts","sourceRoot":"","sources":["../../src/utilities/flattenObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAMvD,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IACtD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,CAAA;IACtC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,wDAO3B,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CA2K/B,CAAA"}
@@ -4,21 +4,11 @@ import { getPolymorphicRelId, isPolymorphicRelValue } from './polymorphicRel.js'
4
4
  export const flattenObject = ({ data, exportFieldHooks, fields, format, path, req })=>{
5
5
  const row = {};
6
6
  const invokeHook = (entry, columnName, value, siblingSource)=>{
7
- if (entry.type === 'beforeExport') {
8
- return entry.fn({
9
- columnName,
10
- data,
11
- format,
12
- siblingData: row,
13
- siblingDoc: siblingSource,
14
- value
15
- });
16
- }
17
7
  return entry.fn({
18
8
  columnName,
19
- data: row,
20
- doc: data,
21
- row,
9
+ data,
10
+ format,
11
+ siblingData: row,
22
12
  siblingDoc: siblingSource,
23
13
  value
24
14
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/flattenObject.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport type { ExportFieldHookEntry } from '../types.js'\n\nimport { fieldToRegex } from './fieldToRegex.js'\nimport { isPlainObject } from './isPlainObject.js'\nimport { getPolymorphicRelId, isPolymorphicRelValue } from './polymorphicRel.js'\n\ntype Args = {\n data: Record<string, unknown>\n exportFieldHooks: Record<string, ExportFieldHookEntry>\n fields?: string[]\n format: 'csv' | 'json' | ({} & string)\n path?: string\n req: PayloadRequest\n}\n\nexport const flattenObject = ({\n data,\n exportFieldHooks,\n fields,\n format,\n path,\n req,\n}: Args): Record<string, unknown> => {\n const row: Record<string, unknown> = {}\n\n const invokeHook = (\n entry: ExportFieldHookEntry,\n columnName: string,\n value: unknown,\n siblingSource: Record<string, unknown>,\n ): unknown => {\n if (entry.type === 'beforeExport') {\n return entry.fn({\n columnName,\n data,\n format,\n siblingData: row,\n siblingDoc: siblingSource,\n value,\n })\n }\n return entry.fn({\n columnName,\n data: row,\n doc: data,\n row,\n siblingDoc: siblingSource,\n value,\n })\n }\n\n const selectedTopLevelKeys =\n Array.isArray(fields) && fields.length > 0\n ? new Set(fields.map((f) => f.split('.')[0]))\n : undefined\n\n const flattenWithFilter = (\n siblingSource: Record<string, unknown>,\n currentPath: string | undefined,\n currentSchemaPath: string | undefined,\n ) => {\n Object.entries(siblingSource).forEach(([key, value]) => {\n if (!currentPath && selectedTopLevelKeys && !selectedTopLevelKeys.has(key)) {\n return\n }\n\n const fieldPath = currentPath ? `${currentPath}_${key}` : key\n const fieldSchemaPath = currentSchemaPath ? `${currentSchemaPath}_${key}` : key\n const hookEntry = exportFieldHooks?.[fieldSchemaPath]\n\n const flattenArray = (items: unknown[], arrayPath: string, arraySchemaPath: string): void => {\n items.forEach((item, index) => {\n if (!isPlainObject(item)) {\n row[`${arrayPath}_${index}`] = item\n return\n }\n\n const blockType = typeof item.blockType === 'string' ? item.blockType : undefined\n const itemPath = blockType\n ? `${arrayPath}_${index}_${blockType}`\n : `${arrayPath}_${index}`\n const itemSchemaPath = blockType ? `${arraySchemaPath}_${blockType}` : arraySchemaPath\n\n if (isPolymorphicRelValue(item) && isPlainObject(item.value)) {\n const id = getPolymorphicRelId(item)\n if (id !== undefined) {\n row[`${itemPath}_relationTo`] = item.relationTo\n row[`${itemPath}_id`] = id\n return\n }\n }\n\n flattenWithFilter(item, itemPath, itemSchemaPath)\n })\n }\n\n if (Array.isArray(value)) {\n if (hookEntry) {\n try {\n const result = invokeHook(hookEntry, fieldPath, value, siblingSource)\n\n if (result === null) {\n return\n }\n\n if (Array.isArray(result)) {\n flattenArray(result, fieldPath, fieldSchemaPath)\n return\n }\n\n if (typeof result !== 'undefined') {\n row[fieldPath] = result\n return\n }\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `[plugin-import-export] Field-level beforeExport hook for \"${fieldPath}\" threw — falling back to default flattening`,\n })\n }\n }\n\n flattenArray(value, fieldPath, fieldSchemaPath)\n } else if (typeof value === 'object' && value !== null) {\n if (!hookEntry) {\n flattenWithFilter(value as Record<string, unknown>, fieldPath, fieldSchemaPath)\n } else {\n const keysBeforeHook = new Set(Object.keys(row))\n try {\n const result = invokeHook(hookEntry, fieldPath, value, siblingSource)\n if (result === null) {\n return\n }\n if (typeof result === 'undefined') {\n const hookWroteForField = Object.keys(row).some(\n (k) => !keysBeforeHook.has(k) && (k === fieldPath || k.startsWith(`${fieldPath}_`)),\n )\n if (hookWroteForField) {\n return\n }\n flattenWithFilter(value as Record<string, unknown>, fieldPath, fieldSchemaPath)\n } else if (typeof result === 'object' && !Array.isArray(result)) {\n flattenWithFilter(result as Record<string, unknown>, fieldPath, fieldSchemaPath)\n } else {\n row[fieldPath] = result\n }\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `[plugin-import-export] Field-level beforeExport hook for \"${fieldPath}\" threw — falling back to default flattening`,\n })\n flattenWithFilter(value as Record<string, unknown>, fieldPath, fieldSchemaPath)\n }\n }\n } else {\n if (hookEntry) {\n try {\n const result = invokeHook(hookEntry, fieldPath, value, siblingSource)\n if (typeof result !== 'undefined') {\n row[fieldPath] = result\n }\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `[plugin-import-export] Field-level beforeExport hook for \"${fieldPath}\" threw — falling back to original value`,\n })\n row[fieldPath] = value\n }\n } else {\n row[fieldPath] = value\n }\n }\n })\n }\n\n flattenWithFilter(data, path, path)\n\n if (Array.isArray(fields) && fields.length > 0) {\n const orderedResult: Record<string, unknown> = {}\n\n const fieldPatterns = fields.map((field) => ({\n field,\n regex: fieldToRegex(field),\n }))\n\n const rowKeys = Object.keys(row)\n\n for (const { regex } of fieldPatterns) {\n for (const key of rowKeys) {\n if (key in orderedResult) {\n continue\n }\n\n if (regex.test(key)) {\n orderedResult[key] = row[key]\n }\n }\n }\n\n return orderedResult\n }\n\n return row\n}\n"],"names":["fieldToRegex","isPlainObject","getPolymorphicRelId","isPolymorphicRelValue","flattenObject","data","exportFieldHooks","fields","format","path","req","row","invokeHook","entry","columnName","value","siblingSource","type","fn","siblingData","siblingDoc","doc","selectedTopLevelKeys","Array","isArray","length","Set","map","f","split","undefined","flattenWithFilter","currentPath","currentSchemaPath","Object","entries","forEach","key","has","fieldPath","fieldSchemaPath","hookEntry","flattenArray","items","arrayPath","arraySchemaPath","item","index","blockType","itemPath","itemSchemaPath","id","relationTo","result","error","payload","logger","err","msg","keysBeforeHook","keys","hookWroteForField","some","k","startsWith","orderedResult","fieldPatterns","field","regex","rowKeys","test"],"mappings":"AAIA,SAASA,YAAY,QAAQ,oBAAmB;AAChD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,mBAAmB,EAAEC,qBAAqB,QAAQ,sBAAqB;AAWhF,OAAO,MAAMC,gBAAgB,CAAC,EAC5BC,IAAI,EACJC,gBAAgB,EAChBC,MAAM,EACNC,MAAM,EACNC,IAAI,EACJC,GAAG,EACE;IACL,MAAMC,MAA+B,CAAC;IAEtC,MAAMC,aAAa,CACjBC,OACAC,YACAC,OACAC;QAEA,IAAIH,MAAMI,IAAI,KAAK,gBAAgB;YACjC,OAAOJ,MAAMK,EAAE,CAAC;gBACdJ;gBACAT;gBACAG;gBACAW,aAAaR;gBACbS,YAAYJ;gBACZD;YACF;QACF;QACA,OAAOF,MAAMK,EAAE,CAAC;YACdJ;YACAT,MAAMM;YACNU,KAAKhB;YACLM;YACAS,YAAYJ;YACZD;QACF;IACF;IAEA,MAAMO,uBACJC,MAAMC,OAAO,CAACjB,WAAWA,OAAOkB,MAAM,GAAG,IACrC,IAAIC,IAAInB,OAAOoB,GAAG,CAAC,CAACC,IAAMA,EAAEC,KAAK,CAAC,IAAI,CAAC,EAAE,KACzCC;IAE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,OAAOtD;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/flattenObject.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport type { ExportFieldHookEntry } from '../types.js'\n\nimport { fieldToRegex } from './fieldToRegex.js'\nimport { isPlainObject } from './isPlainObject.js'\nimport { getPolymorphicRelId, isPolymorphicRelValue } from './polymorphicRel.js'\n\ntype Args = {\n data: Record<string, unknown>\n exportFieldHooks: Record<string, ExportFieldHookEntry>\n fields?: string[]\n format: 'csv' | 'json' | ({} & string)\n path?: string\n req: PayloadRequest\n}\n\nexport const flattenObject = ({\n data,\n exportFieldHooks,\n fields,\n format,\n path,\n req,\n}: Args): Record<string, unknown> => {\n const row: Record<string, unknown> = {}\n\n const invokeHook = (\n entry: ExportFieldHookEntry,\n columnName: string,\n value: unknown,\n siblingSource: Record<string, unknown>,\n ): unknown => {\n return entry.fn({\n columnName,\n data,\n format,\n siblingData: row,\n siblingDoc: siblingSource,\n value,\n })\n }\n\n const selectedTopLevelKeys =\n Array.isArray(fields) && fields.length > 0\n ? new Set(fields.map((f) => f.split('.')[0]))\n : undefined\n\n const flattenWithFilter = (\n siblingSource: Record<string, unknown>,\n currentPath: string | undefined,\n currentSchemaPath: string | undefined,\n ) => {\n Object.entries(siblingSource).forEach(([key, value]) => {\n if (!currentPath && selectedTopLevelKeys && !selectedTopLevelKeys.has(key)) {\n return\n }\n\n const fieldPath = currentPath ? `${currentPath}_${key}` : key\n const fieldSchemaPath = currentSchemaPath ? `${currentSchemaPath}_${key}` : key\n const hookEntry = exportFieldHooks?.[fieldSchemaPath]\n\n const flattenArray = (items: unknown[], arrayPath: string, arraySchemaPath: string): void => {\n items.forEach((item, index) => {\n if (!isPlainObject(item)) {\n row[`${arrayPath}_${index}`] = item\n return\n }\n\n const blockType = typeof item.blockType === 'string' ? item.blockType : undefined\n const itemPath = blockType\n ? `${arrayPath}_${index}_${blockType}`\n : `${arrayPath}_${index}`\n const itemSchemaPath = blockType ? `${arraySchemaPath}_${blockType}` : arraySchemaPath\n\n if (isPolymorphicRelValue(item) && isPlainObject(item.value)) {\n const id = getPolymorphicRelId(item)\n if (id !== undefined) {\n row[`${itemPath}_relationTo`] = item.relationTo\n row[`${itemPath}_id`] = id\n return\n }\n }\n\n flattenWithFilter(item, itemPath, itemSchemaPath)\n })\n }\n\n if (Array.isArray(value)) {\n if (hookEntry) {\n try {\n const result = invokeHook(hookEntry, fieldPath, value, siblingSource)\n\n if (result === null) {\n return\n }\n\n if (Array.isArray(result)) {\n flattenArray(result, fieldPath, fieldSchemaPath)\n return\n }\n\n if (typeof result !== 'undefined') {\n row[fieldPath] = result\n return\n }\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `[plugin-import-export] Field-level beforeExport hook for \"${fieldPath}\" threw — falling back to default flattening`,\n })\n }\n }\n\n flattenArray(value, fieldPath, fieldSchemaPath)\n } else if (typeof value === 'object' && value !== null) {\n if (!hookEntry) {\n flattenWithFilter(value as Record<string, unknown>, fieldPath, fieldSchemaPath)\n } else {\n const keysBeforeHook = new Set(Object.keys(row))\n try {\n const result = invokeHook(hookEntry, fieldPath, value, siblingSource)\n if (result === null) {\n return\n }\n if (typeof result === 'undefined') {\n const hookWroteForField = Object.keys(row).some(\n (k) => !keysBeforeHook.has(k) && (k === fieldPath || k.startsWith(`${fieldPath}_`)),\n )\n if (hookWroteForField) {\n return\n }\n flattenWithFilter(value as Record<string, unknown>, fieldPath, fieldSchemaPath)\n } else if (typeof result === 'object' && !Array.isArray(result)) {\n flattenWithFilter(result as Record<string, unknown>, fieldPath, fieldSchemaPath)\n } else {\n row[fieldPath] = result\n }\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `[plugin-import-export] Field-level beforeExport hook for \"${fieldPath}\" threw — falling back to default flattening`,\n })\n flattenWithFilter(value as Record<string, unknown>, fieldPath, fieldSchemaPath)\n }\n }\n } else {\n if (hookEntry) {\n try {\n const result = invokeHook(hookEntry, fieldPath, value, siblingSource)\n if (typeof result !== 'undefined') {\n row[fieldPath] = result\n }\n } catch (error) {\n req.payload.logger.error({\n err: error,\n msg: `[plugin-import-export] Field-level beforeExport hook for \"${fieldPath}\" threw — falling back to original value`,\n })\n row[fieldPath] = value\n }\n } else {\n row[fieldPath] = value\n }\n }\n })\n }\n\n flattenWithFilter(data, path, path)\n\n if (Array.isArray(fields) && fields.length > 0) {\n const orderedResult: Record<string, unknown> = {}\n\n const fieldPatterns = fields.map((field) => ({\n field,\n regex: fieldToRegex(field),\n }))\n\n const rowKeys = Object.keys(row)\n\n for (const { regex } of fieldPatterns) {\n for (const key of rowKeys) {\n if (key in orderedResult) {\n continue\n }\n\n if (regex.test(key)) {\n orderedResult[key] = row[key]\n }\n }\n }\n\n return orderedResult\n }\n\n return row\n}\n"],"names":["fieldToRegex","isPlainObject","getPolymorphicRelId","isPolymorphicRelValue","flattenObject","data","exportFieldHooks","fields","format","path","req","row","invokeHook","entry","columnName","value","siblingSource","fn","siblingData","siblingDoc","selectedTopLevelKeys","Array","isArray","length","Set","map","f","split","undefined","flattenWithFilter","currentPath","currentSchemaPath","Object","entries","forEach","key","has","fieldPath","fieldSchemaPath","hookEntry","flattenArray","items","arrayPath","arraySchemaPath","item","index","blockType","itemPath","itemSchemaPath","id","relationTo","result","error","payload","logger","err","msg","keysBeforeHook","keys","hookWroteForField","some","k","startsWith","orderedResult","fieldPatterns","field","regex","rowKeys","test"],"mappings":"AAIA,SAASA,YAAY,QAAQ,oBAAmB;AAChD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,mBAAmB,EAAEC,qBAAqB,QAAQ,sBAAqB;AAWhF,OAAO,MAAMC,gBAAgB,CAAC,EAC5BC,IAAI,EACJC,gBAAgB,EAChBC,MAAM,EACNC,MAAM,EACNC,IAAI,EACJC,GAAG,EACE;IACL,MAAMC,MAA+B,CAAC;IAEtC,MAAMC,aAAa,CACjBC,OACAC,YACAC,OACAC;QAEA,OAAOH,MAAMI,EAAE,CAAC;YACdH;YACAT;YACAG;Y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7B,OAAOgC,QAAS;gBACzB,IAAIhC,OAAO4B,eAAe;oBACxB;gBACF;gBAEA,IAAIG,MAAME,IAAI,CAACjC,MAAM;oBACnB4B,aAAa,CAAC5B,IAAI,GAAGxB,GAAG,CAACwB,IAAI;gBAC/B;YACF;QACF;QAEA,OAAO4B;IACT;IAEA,OAAOpD;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"flattenedFields.d.ts","sourceRoot":"","sources":["../../src/utilities/flattenedFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,UAAW,cAAc,KAAG,cAAc,EAAE,GAAG,SACjB,CAAA;AAEnE;;GAEG;AACH,eAAO,MAAM,uBAAuB,UAAW;IAC7C,eAAe,CAAC,EAAE,cAAc,EAAE,CAAA;CACnC,KAAG,cAAc,EAAiC,CAAA;AAEnD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,UAC/B,cAAc,EAAE,cACZ,MAAM,UACV,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACb,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,KAChG,IA0BF,CAAA"}
1
+ {"version":3,"file":"flattenedFields.d.ts","sourceRoot":"","sources":["../../src/utilities/flattenedFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,cAAc,KAAG,cAAc,EAAE,GAAG,SACjB,CAAA;AAEnE;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,OAAO;IAC7C,eAAe,CAAC,EAAE,cAAc,EAAE,CAAA;CACnC,KAAG,cAAc,EAAiC,CAAA;AAEnD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,EACvC,QAAQ,cAAc,EAAE,EACxB,YAAY,MAAM,EAClB,QAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,iBAAiB,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,KAChG,IA0BF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getExportFieldFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/getExportFieldFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,oBAAoB,EAAyB,MAAM,aAAa,CAAA;AAK9E,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,cAAc,EAAE,CAAA;CACzB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,eAAgB,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAI7F,CAAA"}
1
+ {"version":3,"file":"getExportFieldFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/getExportFieldFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,oBAAoB,EAAyB,MAAM,aAAa,CAAA;AAK9E,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,cAAc,EAAE,CAAA;CACzB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAAI,YAAY,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAI7F,CAAA"}
@@ -10,7 +10,6 @@ import { getPolymorphicRelId, isPolymorphicRelValue } from './polymorphicRel.js'
10
10
  };
11
11
  const registerExportHandler = (field, fullKey, result)=>{
12
12
  const beforeExport = field.custom?.['plugin-import-export']?.hooks?.beforeExport;
13
- const toCSV = field.custom?.['plugin-import-export']?.toCSV;
14
13
  if (typeof beforeExport === 'function') {
15
14
  result[fullKey] = {
16
15
  type: 'beforeExport',
@@ -18,13 +17,6 @@ const registerExportHandler = (field, fullKey, result)=>{
18
17
  };
19
18
  return;
20
19
  }
21
- if (typeof toCSV === 'function') {
22
- result[fullKey] = {
23
- type: 'toCSV',
24
- fn: toCSV
25
- };
26
- return;
27
- }
28
20
  const registerHandler = (handler)=>{
29
21
  result[fullKey] = {
30
22
  type: 'beforeExport',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getExportFieldFunctions.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport type { ExportFieldHookEntry, FieldBeforeExportHook } from '../types.js'\n\nimport { registerFieldHooks } from './flattenedFields.js'\nimport { getPolymorphicRelId, isPolymorphicRelValue } from './polymorphicRel.js'\n\ntype Args = {\n fields: FlattenedField[]\n}\n\n/**\n * Builds a map from logical field path (e.g. `content_textBlock_body`) to\n * the export hook entry. Paths include block slugs but never array indices.\n */\nexport const getExportFieldFunctions = ({ fields }: Args): Record<string, ExportFieldHookEntry> => {\n const result: Record<string, ExportFieldHookEntry> = {}\n registerFieldHooks(fields, '', result, registerExportHandler)\n return result\n}\n\nconst registerExportHandler = (\n field: FlattenedField,\n fullKey: string,\n result: Record<string, ExportFieldHookEntry>,\n): void => {\n const beforeExport = field.custom?.['plugin-import-export']?.hooks?.beforeExport\n\n const toCSV = field.custom?.['plugin-import-export']?.toCSV\n\n if (typeof beforeExport === 'function') {\n result[fullKey] = { type: 'beforeExport', fn: beforeExport }\n return\n }\n\n if (typeof toCSV === 'function') {\n result[fullKey] = { type: 'toCSV', fn: toCSV }\n return\n }\n\n const registerHandler = (handler: FieldBeforeExportHook) => {\n result[fullKey] = { type: 'beforeExport', fn: handler }\n }\n\n if (field.type === 'json' || field.type === 'richText') {\n registerHandler(({ format, value }) => {\n if (format === 'json') {\n return value\n }\n if (value === null || value === undefined) {\n return value\n }\n if (typeof value === 'object') {\n return JSON.stringify(value)\n }\n return value\n })\n return\n }\n\n if (field.type === 'date') {\n registerHandler(({ value }) => value)\n return\n }\n\n if (field.type !== 'relationship' && field.type !== 'upload') {\n return\n }\n\n if (field.hasMany !== true) {\n if (!Array.isArray(field.relationTo)) {\n registerHandler(({ value }) =>\n typeof value === 'object' && value && 'id' in value ? value.id : value,\n )\n return\n }\n\n registerHandler(({ siblingData, value }) => {\n if (isPolymorphicRelValue(value)) {\n const id = getPolymorphicRelId(value)\n if (id !== undefined) {\n siblingData[`${fullKey}_id`] = id\n siblingData[`${fullKey}_relationTo`] = value.relationTo\n }\n }\n return null\n })\n return\n }\n\n if (!Array.isArray(field.relationTo)) {\n registerHandler(({ siblingData, value }) => {\n if (Array.isArray(value)) {\n value.forEach((val, i) => {\n const id = typeof val === 'object' && val ? (val as { id: unknown }).id : val\n siblingData[`${fullKey}_${i}_id`] = id\n })\n return null\n }\n return undefined\n })\n return\n }\n\n registerHandler(({ siblingData, value }) => {\n if (Array.isArray(value)) {\n value.forEach((val, i) => {\n if (isPolymorphicRelValue(val)) {\n const id = getPolymorphicRelId(val)\n if (id !== undefined) {\n siblingData[`${fullKey}_${i}_id`] = id\n siblingData[`${fullKey}_${i}_relationTo`] = val.relationTo\n }\n }\n })\n return null\n }\n return undefined\n })\n}\n"],"names":["registerFieldHooks","getPolymorphicRelId","isPolymorphicRelValue","getExportFieldFunctions","fields","result","registerExportHandler","field","fullKey","beforeExport","custom","hooks","toCSV","type","fn","registerHandler","handler","format","value","undefined","JSON","stringify","hasMany","Array","isArray","relationTo","id","siblingData","forEach","val","i"],"mappings":"AAIA,SAASA,kBAAkB,QAAQ,uBAAsB;AACzD,SAASC,mBAAmB,EAAEC,qBAAqB,QAAQ,sBAAqB;AAMhF;;;CAGC,GACD,OAAO,MAAMC,0BAA0B,CAAC,EAAEC,MAAM,EAAQ;IACtD,MAAMC,SAA+C,CAAC;IACtDL,mBAAmBI,QAAQ,IAAIC,QAAQC;IACvC,OAAOD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Functions.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport type { ExportFieldHookEntry, FieldBeforeExportHook } from '../types.js'\n\nimport { registerFieldHooks } from './flattenedFields.js'\nimport { getPolymorphicRelId, isPolymorphicRelValue } from './polymorphicRel.js'\n\ntype Args = {\n fields: FlattenedField[]\n}\n\n/**\n * Builds a map from logical field path (e.g. `content_textBlock_body`) to\n * the export hook entry. Paths include block slugs but never array indices.\n */\nexport const getExportFieldFunctions = ({ fields }: Args): Record<string, ExportFieldHookEntry> => {\n const result: Record<string, ExportFieldHookEntry> = {}\n registerFieldHooks(fields, '', result, registerExportHandler)\n return result\n}\n\nconst registerExportHandler = (\n field: FlattenedField,\n fullKey: string,\n result: Record<string, ExportFieldHookEntry>,\n): void => {\n const beforeExport = field.custom?.['plugin-import-export']?.hooks?.beforeExport\n\n if (typeof beforeExport === 'function') {\n result[fullKey] = { type: 'beforeExport', fn: beforeExport }\n return\n }\n\n const registerHandler = (handler: FieldBeforeExportHook) => {\n result[fullKey] = { type: 'beforeExport', fn: handler }\n }\n\n if (field.type === 'json' || field.type === 'richText') {\n registerHandler(({ format, value }) => {\n if (format === 'json') {\n return value\n }\n if (value === null || value === undefined) {\n return value\n }\n if (typeof value === 'object') {\n return JSON.stringify(value)\n }\n return value\n })\n return\n }\n\n if (field.type === 'date') {\n registerHandler(({ value }) => value)\n return\n }\n\n if (field.type !== 'relationship' && field.type !== 'upload') {\n return\n }\n\n if (field.hasMany !== true) {\n if (!Array.isArray(field.relationTo)) {\n registerHandler(({ value }) =>\n typeof value === 'object' && value && 'id' in value ? value.id : value,\n )\n return\n }\n\n registerHandler(({ siblingData, value }) => {\n if (isPolymorphicRelValue(value)) {\n const id = getPolymorphicRelId(value)\n if (id !== undefined) {\n siblingData[`${fullKey}_id`] = id\n siblingData[`${fullKey}_relationTo`] = value.relationTo\n }\n }\n return null\n })\n return\n }\n\n if (!Array.isArray(field.relationTo)) {\n registerHandler(({ siblingData, value }) => {\n if (Array.isArray(value)) {\n value.forEach((val, i) => {\n const id = typeof val === 'object' && val ? (val as { id: unknown }).id : val\n siblingData[`${fullKey}_${i}_id`] = id\n })\n return null\n }\n return undefined\n })\n return\n }\n\n registerHandler(({ siblingData, value }) => {\n if (Array.isArray(value)) {\n value.forEach((val, i) => {\n if (isPolymorphicRelValue(val)) {\n const id = getPolymorphicRelId(val)\n if (id !== undefined) {\n siblingData[`${fullKey}_${i}_id`] = id\n siblingData[`${fullKey}_${i}_relationTo`] = val.relationTo\n }\n }\n })\n return null\n }\n return undefined\n })\n}\n"],"names":["registerFieldHooks","getPolymorphicRelId","isPolymorphicRelValue","getExportFieldFunctions","fields","result","registerExportHandler","field","fullKey","beforeExport","custom","hooks","type","fn","registerHandler","handler","format","value","undefined","JSON","stringify","hasMany","Array","isArray","relationTo","id","siblingData","forEach","val","i"],"mappings":"AAIA,SAASA,kBAAkB,QAAQ,uBAAsB;AACzD,SAASC,mBAAmB,EAAEC,qBAAqB,QAAQ,sBAAqB;AAMhF;;;CAGC,GACD,OAAO,MAAMC,0BAA0B,CAAC,EAAEC,MAAM,EAAQ;IACtD,MAAMC,SAA+C,CAAC;IACtDL,mBAAmBI,QAAQ,IAAIC,QAAQC;IACvC,OAAOD;AACT,EAAC;AAED,MAAMC,wBAAwB,CAC5BC,OACAC,SACAH;IAEA,MAAMI,eAAeF,MAAMG,MAAM,EAAE,CAAC,uBAAuB,EAAEC,OAAOF;IAEpE,IAAI,OAAOA,iBAAiB,YAAY;QACtCJ,MAAM,CAACG,QAAQ,GAAG;YAAEI,MAAM;YAAgBC,IAAIJ;QAAa;QAC3D;IACF;IAEA,MAAMK,kBAAkB,CAACC;QACvBV,MAAM,CAACG,QAAQ,GAAG;YAAEI,MAAM;YAAgBC,IAAIE;QAAQ;IACxD;IAEA,IAAIR,MAAMK,IAAI,KAAK,UAAUL,MAAMK,IAAI,KAAK,YAAY;QACtDE,gBAAgB,CAAC,EAAEE,MAAM,EAAEC,KAAK,EAAE;YAChC,IAAID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B,EAAE,GAAG,CAAC,CAAC,GAAGJ;gBACtC;gBACA,OAAO;YACT;YACA,OAAOP;QACT;QACA;IACF;IAEAJ,gBAAgB,CAAC,EAAEY,WAAW,EAAET,KAAK,EAAE;QACrC,IAAIK,MAAMC,OAAO,CAACN,QAAQ;YACxBA,MAAMU,OAAO,CAAC,CAACC,KAAKC;gBAClB,IAAI3B,sBAAsB0B,MAAM;oBAC9B,MAAMH,KAAKxB,oBAAoB2B;oBAC/B,IAAIH,OAAOP,WAAW;wBACpBQ,WAAW,CAAC,GAAGlB,QAAQ,CAAC,EAAEqB,EAAE,GAAG,CAAC,CAAC,GAAGJ;wBACpCC,WAAW,CAAC,GAAGlB,QAAQ,CAAC,EAAEqB,EAAE,WAAW,CAAC,CAAC,GAAGD,IAAIJ,UAAU;oBAC5D;gBACF;YACF;YACA,OAAO;QACT;QACA,OAAON;IACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"getFileFromDoc.d.ts","sourceRoot":"","sources":["../../src/utilities/getFileFromDoc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAY,cAAc,EAAgB,MAAM,SAAS,CAAA;AAMvF,KAAK,IAAI,GAAG;IACV,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1D,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,KAAK,MAAM,GAAG;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,mCAA0C,IAAI,KAAG,OAAO,CAAC,MAAM,CAkEzF,CAAA"}
1
+ {"version":3,"file":"getFileFromDoc.d.ts","sourceRoot":"","sources":["../../src/utilities/getFileFromDoc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAY,cAAc,EAAgB,MAAM,SAAS,CAAA;AAMvF,KAAK,IAAI,GAAG;IACV,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1D,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,KAAK,MAAM,GAAG;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,gCAAgC,IAAI,KAAG,OAAO,CAAC,MAAM,CAkEzF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getFlattenedFieldKeys.d.ts","sourceRoot":"","sources":["../../src/utilities/getFlattenedFieldKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,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,MAAM,MAAM,4BAA4B,GAAG;IACzC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,WACxB,uBAAuB,EAAE,6BAExB,4BAA4B,KACpC,MAAM,EAuGR,CAAA"}
1
+ {"version":3,"file":"getFlattenedFieldKeys.d.ts","sourceRoot":"","sources":["../../src/utilities/getFlattenedFieldKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,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,MAAM,MAAM,4BAA4B,GAAG;IACzC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,uBAAuB,EAAE,EACjC,eAAW,EACX,UAAS,4BAAiC,KACzC,MAAM,EAuGR,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getImportFieldFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/getImportFieldFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAyB,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAI9E,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,cAAc,EAAE,CAAA;CACzB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,eAAgB,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAI7F,CAAA"}
1
+ {"version":3,"file":"getImportFieldFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/getImportFieldFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAyB,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAI9E,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,cAAc,EAAE,CAAA;CACzB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAAI,YAAY,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAI7F,CAAA"}
@@ -9,7 +9,6 @@ import { registerFieldHooks } from './flattenedFields.js';
9
9
  };
10
10
  const registerImportHandler = (field, fullKey, result)=>{
11
11
  const beforeImport = field.custom?.['plugin-import-export']?.hooks?.beforeImport;
12
- const fromCSV = field.custom?.['plugin-import-export']?.fromCSV;
13
12
  if (typeof beforeImport === 'function') {
14
13
  result[fullKey] = {
15
14
  type: 'beforeImport',
@@ -17,13 +16,6 @@ const registerImportHandler = (field, fullKey, result)=>{
17
16
  };
18
17
  return;
19
18
  }
20
- if (typeof fromCSV === 'function') {
21
- result[fullKey] = {
22
- type: 'fromCSV',
23
- fn: fromCSV
24
- };
25
- return;
26
- }
27
19
  const registerBeforeImport = (fn)=>{
28
20
  result[fullKey] = {
29
21
  type: 'beforeImport',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getImportFieldFunctions.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport type { FieldBeforeImportHook, ImportFieldHookEntry } from '../types.js'\n\nimport { registerFieldHooks } from './flattenedFields.js'\n\ntype Args = {\n fields: FlattenedField[]\n}\n\n/**\n * Builds a map from logical field path (e.g. `content_textBlock_body`) to\n * the import hook entry. Paths include block slugs but never array indices.\n */\nexport const getImportFieldFunctions = ({ fields }: Args): Record<string, ImportFieldHookEntry> => {\n const result: Record<string, ImportFieldHookEntry> = {}\n registerFieldHooks(fields, '', result, registerImportHandler)\n return result\n}\n\nconst registerImportHandler = (\n field: FlattenedField,\n fullKey: string,\n result: Record<string, ImportFieldHookEntry>,\n): void => {\n const beforeImport = field.custom?.['plugin-import-export']?.hooks?.beforeImport\n\n const fromCSV = field.custom?.['plugin-import-export']?.fromCSV\n\n if (typeof beforeImport === 'function') {\n result[fullKey] = { type: 'beforeImport', fn: beforeImport }\n return\n }\n\n if (typeof fromCSV === 'function') {\n result[fullKey] = { type: 'fromCSV', fn: fromCSV }\n return\n }\n\n const registerBeforeImport = (fn: FieldBeforeImportHook) => {\n result[fullKey] = { type: 'beforeImport', fn }\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n if (field.hasMany !== true) {\n if (!Array.isArray(field.relationTo)) {\n registerBeforeImport(({ value }) => value)\n }\n } else if (!Array.isArray(field.relationTo)) {\n registerBeforeImport(({ value }) => value)\n }\n return\n }\n\n if (field.type === 'number') {\n if (field.hasMany) {\n registerBeforeImport(({ value }) => value)\n return\n }\n registerBeforeImport(({ value }) => {\n if (isEmptyImportValue(value)) {\n return undefined\n }\n if (typeof value === 'number') {\n return value\n }\n if (typeof value === 'string') {\n const parsed = parseFloat(value)\n return isNaN(parsed) ? undefined : parsed\n }\n return value\n })\n return\n }\n\n if (field.type === 'checkbox') {\n registerBeforeImport(({ value }) => {\n if (isEmptyImportValue(value)) {\n return undefined\n }\n if (typeof value === 'boolean') {\n return value\n }\n if (typeof value === 'string') {\n return value.toLowerCase() === 'true' || value === '1'\n }\n return Boolean(value)\n })\n return\n }\n\n if (field.type === 'date') {\n registerBeforeImport(({ value }) => {\n if (isEmptyImportValue(value)) {\n return undefined\n }\n if (typeof value === 'string' && !isNaN(Date.parse(value))) {\n return value\n }\n try {\n const date = new Date(value as string)\n return isNaN(date.getTime()) ? value : date.toISOString()\n } catch {\n return value\n }\n })\n return\n }\n\n if (field.type === 'json' || field.type === 'richText') {\n registerBeforeImport(({ value }) => {\n if (isEmptyImportValue(value)) {\n return undefined\n }\n if (typeof value === 'object') {\n return value\n }\n if (typeof value === 'string') {\n try {\n return JSON.parse(value)\n } catch {\n return value\n }\n }\n return value\n })\n }\n}\n\nconst isEmptyImportValue = (value: unknown): boolean =>\n value === '' || value === null || value === undefined\n"],"names":["registerFieldHooks","getImportFieldFunctions","fields","result","registerImportHandler","field","fullKey","beforeImport","custom","hooks","fromCSV","type","fn","registerBeforeImport","hasMany","Array","isArray","relationTo","value","isEmptyImportValue","undefined","parsed","parseFloat","isNaN","toLowerCase","Boolean","Date","parse","date","getTime","toISOString","JSON"],"mappings":"AAIA,SAASA,kBAAkB,QAAQ,uBAAsB;AAMzD;;;CAGC,GACD,OAAO,MAAMC,0BAA0B,CAAC,EAAEC,MAAM,EAAQ;IACtD,MAAMC,SAA+C,CAAC;IACtDH,mBAAmBE,QAAQ,IAAIC,QAAQC;IACvC,OAAOD;AACT,EAAC;AAED,MAAMC,wBAAwB,CAC5BC,OACAC,SACAH;IAEA,MAAMI,eAAeF,MAAMG,MAAM,EAAE,CAAC,uBAAuB,EAAEC,OAAOF;IAEpE,MAAMG,UAAUL,MAAMG,MAAM,EAAE,CAAC,uBAAuB,EAAEE;IAExD,IAAI,OAAOH,iBAAiB,YAAY;QACtCJ,MAAM,CAACG,QAAQ,GAAG;YAAEK,MAAM;YAAgBC,IAAIL;QAAa;QAC3D;IACF;IAEA,IAAI,OAAOG,YAAY,YAAY;QACjCP,MAAM,CAACG,QAAQ,GAAG;YAAEK,MAAM;YAAWC,IAAIF;QAAQ;QACjD;IACF;IAEA,MAAMG,uBAAuB,CAACD;QAC5BT,MAAM,CAACG,QAAQ,GAAG;YAAEK,MAAM;YAAgBC;QAAG;IAC/C;IAEA,IAAIP,MAAMM,IAAI,KAAK,kBAAkBN,MAAMM,IAAI,KAAK,UAAU;QAC5D,IAAIN,MAAMS,OAAO,KAAK,MAAM;YAC1B,IAAI,CAACC,MAAMC,OAAO,CAACX,MAAMY,UAAU,GAAG;gBACpCJ,qBAAqB,CAAC,EAAEK,KAAK,EAAE,GAAKA;YACtC;QACF,OAAO,IAAI,CAACH,MAAMC,OAAO,CAACX,MAAMY,UAAU,GAAG;YAC3CJ,qBAAqB,CAAC,EAAEK,KAAK,EAAE,GAAKA;QACtC;QACA;IACF;IAEA,IAAIb,MAAMM,IAAI,KAAK,UAAU;QAC3B,IAAIN,MAAMS,OAAO,EAA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I,OAAOA,UAAU,UAAU;gBAC7B,IAAI;oBACF,OAAOa,KAAKJ,KAAK,CAACT;gBACpB,EAAE,OAAM;oBACN,OAAOA;gBACT;YACF;YACA,OAAOA;QACT;IACF;AACF;AAEA,MAAMC,qBAAqB,CAACD,QAC1BA,UAAU,MAAMA,UAAU,QAAQA,UAAUE"}
1
+ {"version":3,"sources":["../../src/utilities/getImportFieldFunctions.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport type { FieldBeforeImportHook, ImportFieldHookEntry } from '../types.js'\n\nimport { registerFieldHooks } from './flattenedFields.js'\n\ntype Args = {\n fields: FlattenedField[]\n}\n\n/**\n * Builds a map from logical field path (e.g. `content_textBlock_body`) to\n * the import hook entry. Paths include block slugs but never array indices.\n */\nexport const getImportFieldFunctions = ({ fields }: Args): Record<string, ImportFieldHookEntry> => {\n const result: Record<string, ImportFieldHookEntry> = {}\n registerFieldHooks(fields, '', result, registerImportHandler)\n return result\n}\n\nconst registerImportHandler = (\n field: FlattenedField,\n fullKey: string,\n result: Record<string, ImportFieldHookEntry>,\n): void => {\n const beforeImport = field.custom?.['plugin-import-export']?.hooks?.beforeImport\n\n if (typeof beforeImport === 'function') {\n result[fullKey] = { type: 'beforeImport', fn: beforeImport }\n return\n }\n\n const registerBeforeImport = (fn: FieldBeforeImportHook) => {\n result[fullKey] = { type: 'beforeImport', fn }\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n if (field.hasMany !== true) {\n if (!Array.isArray(field.relationTo)) {\n registerBeforeImport(({ value }) => value)\n }\n } else if (!Array.isArray(field.relationTo)) {\n registerBeforeImport(({ value }) => value)\n }\n return\n }\n\n if (field.type === 'number') {\n if (field.hasMany) {\n registerBeforeImport(({ value }) => value)\n return\n }\n registerBeforeImport(({ value }) => {\n if (isEmptyImportValue(value)) {\n return undefined\n }\n if (typeof value === 'number') {\n return value\n }\n if (typeof value === 'string') {\n const parsed = parseFloat(value)\n return isNaN(parsed) ? undefined : parsed\n }\n return value\n })\n return\n }\n\n if (field.type === 'checkbox') {\n registerBeforeImport(({ value }) => {\n if (isEmptyImportValue(value)) {\n return undefined\n }\n if (typeof value === 'boolean') {\n return value\n }\n if (typeof value === 'string') {\n return value.toLowerCase() === 'true' || value === '1'\n }\n return Boolean(value)\n })\n return\n }\n\n if (field.type === 'date') {\n registerBeforeImport(({ value }) => {\n if (isEmptyImportValue(value)) {\n return undefined\n }\n if (typeof value === 'string' && !isNaN(Date.parse(value))) {\n return value\n }\n try {\n const date = new Date(value as string)\n return isNaN(date.getTime()) ? value : date.toISOString()\n } catch {\n return value\n }\n })\n return\n }\n\n if (field.type === 'json' || field.type === 'richText') {\n registerBeforeImport(({ value }) => {\n if (isEmptyImportValue(value)) {\n return undefined\n }\n if (typeof value === 'object') {\n return value\n }\n if (typeof value === 'string') {\n try {\n return JSON.parse(value)\n } catch {\n return value\n }\n }\n return value\n })\n }\n}\n\nconst isEmptyImportValue = (value: unknown): boolean =>\n value === '' || value === null || value === undefined\n"],"names":["registerFieldHooks","getImportFieldFunctions","fields","result","registerImportHandler","field","fullKey","beforeImport","custom","hooks","type","fn","registerBeforeImport","hasMany","Array","isArray","relationTo","value","isEmptyImportValue","undefined","parsed","parseFloat","isNaN","toLowerCase","Boolean","Date","parse","date","getTime","toISOString","JSON"],"mappings":"AAIA,SAASA,kBAAkB,QAAQ,uBAAsB;AAMzD;;;CAGC,GACD,OAAO,MAAMC,0BAA0B,CAAC,EAAEC,MAAM,EAAQ;IACtD,MAAMC,SAA+C,CAAC;IACtDH,mBAAmBE,QAAQ,IAAIC,QAAQC;IACvC,OAAOD;AACT,EAAC;AAED,MAAMC,wBAAwB,CAC5BC,OACAC,SACAH;IAEA,MAAMI,eAAeF,MAAMG,MAAM,EAAE,CAAC,uBAAuB,EAAEC,OAAOF;IAEpE,IAAI,OAAOA,iBAAiB,YAAY;QACtCJ,MAAM,CAACG,QAAQ,GAAG;YAAEI,MAAM;YAAgBC,IAAIJ;QAAa;QAC3D;IACF;IAEA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YAC7B,IAAIC,mBAAmBD,QAAQ;gBAC7B,OAAOE;YACT;YACA,IAAI,OAAOF,UAAU,YAAY,CAACK,MAAMG,KAAKC,KAAK,CAACT,SAAS;gBAC1D,OAAOA;YACT;YACA,IAAI;gBACF,MAAMU,OAAO,IAAIF,KAAKR;gBACtB,OAAOK,MAAMK,KAAKC,OAAO,MAAMX,QAAQU,KAAKE,WAAW;YACzD,EAAE,OAAM;gBACN,OAAOZ;YACT;QACF;QACA;IACF;IAEA,IAAIZ,MAAMK,IAAI,KAAK,UAAUL,MAAMK,IAAI,KAAK,YAAY;QACtDE,qBAAqB,CAAC,EAAEK,KAAK,EAAE;YAC7B,IAAIC,mBAAmBD,QAAQ;gBAC7B,OAAOE;YACT;YACA,IAAI,OAAOF,UAAU,UAAU;gBAC7B,OAAOA;YACT;YACA,IAAI,OAAOA,UAAU,UAAU;gBAC7B,IAAI;oBACF,OAAOa,KAAKJ,KAAK,CAACT;gBACpB,EAAE,OAAM;oBACN,OAAOA;gBACT;YACF;YACA,OAAOA;QACT;IACF;AACF;AAEA,MAAMC,qBAAqB,CAACD,QAC1BA,UAAU,MAAMA,UAAU,QAAQA,UAAUE"}
@@ -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,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"}
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,GAAU,2BAGxC;IACD,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,wBAAwB,CAAA;CACvC,KAAG,OAAO,CAAC,uBAAuB,CAyLlC,CAAA"}
@@ -37,7 +37,7 @@ export declare const getSchemaColumns: ({ collectionConfig, disabledFields, fiel
37
37
  /**
38
38
  * Merges schema-derived columns with data-discovered columns.
39
39
  * Schema columns provide the base ordering, data columns add any additional
40
- * columns (e.g., array indices beyond 0, dynamic fields, derived columns from toCSV).
40
+ * columns (e.g., array indices beyond 0, dynamic fields, derived columns from beforeExport hooks).
41
41
  */
42
42
  export declare const mergeColumns: (schemaColumns: string[], dataColumns: string[]) => string[];
43
43
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"getSchemaColumns.d.ts","sourceRoot":"","sources":["../../src/utilities/getSchemaColumns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAIxD,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,uFAM1B,oBAAoB,KAAG,MAAM,EAmC/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,kBAAmB,MAAM,EAAE,eAAe,MAAM,EAAE,KAAG,MAAM,EAqEnF,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAmC5F"}
1
+ {"version":3,"file":"getSchemaColumns.d.ts","sourceRoot":"","sources":["../../src/utilities/getSchemaColumns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAIxD,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,GAAI,oFAM9B,oBAAoB,KAAG,MAAM,EAmC/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,eAAe,MAAM,EAAE,EAAE,aAAa,MAAM,EAAE,KAAG,MAAM,EAqEnF,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAmC5F"}
@@ -45,7 +45,7 @@ import { getFlattenedFieldKeys } from './getFlattenedFieldKeys.js';
45
45
  /**
46
46
  * Merges schema-derived columns with data-discovered columns.
47
47
  * Schema columns provide the base ordering, data columns add any additional
48
- * columns (e.g., array indices beyond 0, dynamic fields, derived columns from toCSV).
48
+ * columns (e.g., array indices beyond 0, dynamic fields, derived columns from beforeExport hooks).
49
49
  */ export const mergeColumns = (schemaColumns, dataColumns)=>{
50
50
  const result = [
51
51
  ...schemaColumns
@@ -101,7 +101,7 @@ import { getFlattenedFieldKeys } from './getFlattenedFieldKeys.js';
101
101
  }
102
102
  }
103
103
  }
104
- // Remove schema columns that were fully replaced by toCSV-derived columns (e.g. "user" → "user_id", "user_email")
104
+ // Remove schema columns that were fully replaced by beforeExport-derived columns (e.g. "user" → "user_id", "user_email")
105
105
  for (const [schemaCol, derivedCols] of insertedDerived){
106
106
  if (!dataColumns.includes(schemaCol) && derivedCols.length > 0) {
107
107
  const idx = result.indexOf(schemaCol);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getSchemaColumns.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from 'payload'\n\nimport { getFlattenedFieldKeys } from './getFlattenedFieldKeys.js'\n\nexport type GetSchemaColumnsArgs = {\n /**\n * The collection configuration to derive columns from\n */\n collectionConfig: SanitizedCollectionConfig\n /**\n * Array of disabled field paths from plugin config\n */\n disabledFields?: string[]\n /**\n * User-selected fields to export. If provided, only these fields (and their nested fields) will be included.\n */\n fields?: string[]\n /**\n * The locale to export. When 'all', localized fields are expanded to include all locale suffixes.\n */\n locale?: null | string\n /**\n * Available locale codes from config. Required when locale='all'.\n */\n localeCodes?: string[]\n}\n\n/**\n * Derives CSV column names from the collection schema.\n * This provides a base set of columns from field definitions.\n *\n * Note: For arrays/blocks with multiple items, the schema only generates index 0.\n * Additional indices from actual data should be merged with these columns.\n *\n * Benefits:\n * - Provides consistent base columns\n * - Works for empty exports\n * - Ensures proper column ordering\n */\nexport const getSchemaColumns = ({\n collectionConfig,\n disabledFields = [],\n fields: selectedFields,\n locale,\n localeCodes,\n}: GetSchemaColumnsArgs): string[] => {\n const expandLocales = locale === 'all' && localeCodes && localeCodes.length > 0\n\n let schemaColumns = getFlattenedFieldKeys(\n collectionConfig.flattenedFields,\n '',\n expandLocales ? { localeCodes } : {},\n )\n\n // Add id if not present in schema\n const hasIdField = schemaColumns.includes('id')\n if (!hasIdField) {\n schemaColumns = ['id', ...schemaColumns]\n }\n\n if (selectedFields && selectedFields.length > 0) {\n schemaColumns = filterToSelectedFields(schemaColumns, selectedFields)\n }\n\n if (disabledFields.length > 0) {\n const disabledSet = new Set<string>()\n for (const path of disabledFields) {\n disabledSet.add(path.replace(/\\./g, '_'))\n }\n schemaColumns = schemaColumns.filter((col) => {\n for (const disabled of disabledSet) {\n if (col === disabled || col.startsWith(`${disabled}_`)) {\n return false\n }\n }\n return true\n })\n }\n\n return schemaColumns\n}\n\n/**\n * Merges schema-derived columns with data-discovered columns.\n * Schema columns provide the base ordering, data columns add any additional\n * columns (e.g., array indices beyond 0, dynamic fields, derived columns from toCSV).\n */\nexport const mergeColumns = (schemaColumns: string[], dataColumns: string[]): string[] => {\n const result = [...schemaColumns]\n const schemaSet = new Set(schemaColumns)\n const insertedDerived = new Map<string, string[]>()\n\n for (const col of dataColumns) {\n if (!schemaSet.has(col)) {\n let inserted = false\n\n for (const schemaCol of schemaColumns) {\n if (col.startsWith(`${schemaCol}_`)) {\n const suffix = col.slice(schemaCol.length + 1)\n // Skip if suffix starts with a digit (array index pattern like field_0_*)\n if (!/^\\d/.test(suffix)) {\n const baseIdx = result.indexOf(schemaCol)\n if (baseIdx !== -1) {\n const derivedList = insertedDerived.get(schemaCol) || []\n const insertIdx = baseIdx + 1 + derivedList.length\n result.splice(insertIdx, 0, col)\n derivedList.push(col)\n insertedDerived.set(schemaCol, derivedList)\n schemaSet.add(col)\n inserted = true\n break\n }\n }\n }\n }\n\n if (!inserted) {\n // Check for array indices (e.g., field_1_*), insert after field_0_*\n const match = col.match(/^(.+?)_(\\d+)(_.*)?$/)\n if (match) {\n const [, basePath, index, suffix] = match\n if (basePath && index) {\n const prevIndex = parseInt(index, 10) - 1\n const prevCol = `${basePath}_${prevIndex}${suffix ?? ''}`\n const prevIdx = result.indexOf(prevCol)\n if (prevIdx !== -1) {\n // Insert after the previous index column\n result.splice(prevIdx + 1, 0, col)\n schemaSet.add(col)\n continue\n }\n }\n }\n\n const createdAtIdx = result.indexOf('createdAt')\n if (createdAtIdx !== -1) {\n result.splice(createdAtIdx, 0, col)\n } else {\n result.push(col)\n }\n schemaSet.add(col)\n }\n }\n }\n\n // Remove schema columns that were fully replaced by toCSV-derived columns (e.g. \"user\" → \"user_id\", \"user_email\")\n for (const [schemaCol, derivedCols] of insertedDerived) {\n if (!dataColumns.includes(schemaCol) && derivedCols.length > 0) {\n const idx = result.indexOf(schemaCol)\n if (idx !== -1) {\n result.splice(idx, 1)\n }\n }\n }\n\n return result\n}\n\n/**\n * Filters schema columns to only include those matching user-selected fields.\n * Preserves the order specified by the user in selectedFields.\n *\n * Container fields (groups, arrays, blocks) don't produce their own column, so we prefix-expand\n * to find their children (e.g., 'group' → 'group_name', 'group_age').\n * Leaf fields (date, text, select) produce an exact column, so we only match exactly to avoid\n * including siblings with similar prefixes (e.g., 'dateWithTimezone' won't pull 'dateWithTimezone_tz').\n */\nexport function filterToSelectedFields(columns: string[], selectedFields: string[]): string[] {\n const result: string[] = []\n const columnsSet = new Set(columns)\n\n // Convert selected fields to underscore notation patterns\n const patterns = selectedFields.map((field) => {\n const underscored = field.replace(/\\./g, '_')\n return {\n exact: underscored,\n original: field,\n prefix: `${underscored}_`,\n }\n })\n\n // Iterate through user-specified fields in order to preserve their ordering\n for (const pattern of patterns) {\n const hasExactColumn = columnsSet.has(pattern.exact)\n\n if (hasExactColumn && !result.includes(pattern.exact)) {\n result.push(pattern.exact)\n }\n\n // Only prefix-expand if no exact column match exists (containers need expansion, leaves don't)\n if (!hasExactColumn) {\n for (const column of columns) {\n if (column.startsWith(pattern.prefix)) {\n if (!result.includes(column)) {\n result.push(column)\n }\n }\n }\n }\n }\n\n return result\n}\n"],"names":["getFlattenedFieldKeys","getSchemaColumns","collectionConfig","disabledFields","fields","selectedFields","locale","localeCodes","expandLocales","length","schemaColumns","flattenedFields","hasIdField","includes","filterToSelectedFields","disabledSet","Set","path","add","replace","filter","col","disabled","startsWith","mergeColumns","dataColumns","result","schemaSet","insertedDerived","Map","has","inserted","schemaCol","suffix","slice","test","baseIdx","indexOf","derivedList","get","insertIdx","splice","push","set","match","basePath","index","prevIndex","parseInt","prevCol","prevIdx","createdAtIdx","derivedCols","idx","columns","columnsSet","patterns","map","field","underscored","exact","original","prefix","pattern","hasExactColumn","column"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,6BAA4B;AAyBlE;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,mBAAmB,CAAC,EAC/BC,gBAAgB,EAChBC,iBAAiB,EAAE,EACnBC,QAAQC,cAAc,EACtBC,MAAM,EACNC,WAAW,EACU;IACrB,MAAMC,gBAAgBF,WAAW,SAASC,eAAeA,YAAYE,MAAM,GAAG;IAE9E,IAAIC,gBAAgBV,sBAClBE,iBAAiBS,eAAe,EAChC,IACAH,gBAAgB;QAAED;IAAY,IAAI,CAAC;IAGrC,kCAAkC;IAClC,MAAMK,aAAaF,cAAcG,QAAQ,CAAC;IAC1C,IAAI,CAACD,YAAY;QACfF,gBAAgB;YAAC;eAASA;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D,MAAME,WAAWnD,eAAeoD,GAAG,CAAC,CAACC;QACnC,MAAMC,cAAcD,MAAMvC,OAAO,CAAC,OAAO;QACzC,OAAO;YACLyC,OAAOD;YACPE,UAAUH;YACVI,QAAQ,GAAGH,YAAY,CAAC,CAAC;QAC3B;IACF;IAEA,4EAA4E;IAC5E,KAAK,MAAMI,WAAWP,SAAU;QAC9B,MAAMQ,iBAAiBT,WAAWzB,GAAG,CAACiC,QAAQH,KAAK;QAEnD,IAAII,kBAAkB,CAACtC,OAAOb,QAAQ,CAACkD,QAAQH,KAAK,GAAG;YACrDlC,OAAOgB,IAAI,CAACqB,QAAQH,KAAK;QAC3B;QAEA,+FAA+F;QAC/F,IAAI,CAACI,gBAAgB;YACnB,KAAK,MAAMC,UAAUX,QAAS;gBAC5B,IAAIW,OAAO1C,UAAU,CAACwC,QAAQD,MAAM,GAAG;oBACrC,IAAI,CAACpC,OAAOb,QAAQ,CAACoD,SAAS;wBAC5BvC,OAAOgB,IAAI,CAACuB;oBACd;gBACF;YACF;QACF;IACF;IAEA,OAAOvC;AACT"}
1
+ {"version":3,"sources":["../../src/utilities/getSchemaColumns.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from 'payload'\n\nimport { getFlattenedFieldKeys } from './getFlattenedFieldKeys.js'\n\nexport type GetSchemaColumnsArgs = {\n /**\n * The collection configuration to derive columns from\n */\n collectionConfig: SanitizedCollectionConfig\n /**\n * Array of disabled field paths from plugin config\n */\n disabledFields?: string[]\n /**\n * User-selected fields to export. If provided, only these fields (and their nested fields) will be included.\n */\n fields?: string[]\n /**\n * The locale to export. When 'all', localized fields are expanded to include all locale suffixes.\n */\n locale?: null | string\n /**\n * Available locale codes from config. Required when locale='all'.\n */\n localeCodes?: string[]\n}\n\n/**\n * Derives CSV column names from the collection schema.\n * This provides a base set of columns from field definitions.\n *\n * Note: For arrays/blocks with multiple items, the schema only generates index 0.\n * Additional indices from actual data should be merged with these columns.\n *\n * Benefits:\n * - Provides consistent base columns\n * - Works for empty exports\n * - Ensures proper column ordering\n */\nexport const getSchemaColumns = ({\n collectionConfig,\n disabledFields = [],\n fields: selectedFields,\n locale,\n localeCodes,\n}: GetSchemaColumnsArgs): string[] => {\n const expandLocales = locale === 'all' && localeCodes && localeCodes.length > 0\n\n let schemaColumns = getFlattenedFieldKeys(\n collectionConfig.flattenedFields,\n '',\n expandLocales ? { localeCodes } : {},\n )\n\n // Add id if not present in schema\n const hasIdField = schemaColumns.includes('id')\n if (!hasIdField) {\n schemaColumns = ['id', ...schemaColumns]\n }\n\n if (selectedFields && selectedFields.length > 0) {\n schemaColumns = filterToSelectedFields(schemaColumns, selectedFields)\n }\n\n if (disabledFields.length > 0) {\n const disabledSet = new Set<string>()\n for (const path of disabledFields) {\n disabledSet.add(path.replace(/\\./g, '_'))\n }\n schemaColumns = schemaColumns.filter((col) => {\n for (const disabled of disabledSet) {\n if (col === disabled || col.startsWith(`${disabled}_`)) {\n return false\n }\n }\n return true\n })\n }\n\n return schemaColumns\n}\n\n/**\n * Merges schema-derived columns with data-discovered columns.\n * Schema columns provide the base ordering, data columns add any additional\n * columns (e.g., array indices beyond 0, dynamic fields, derived columns from beforeExport hooks).\n */\nexport const mergeColumns = (schemaColumns: string[], dataColumns: string[]): string[] => {\n const result = [...schemaColumns]\n const schemaSet = new Set(schemaColumns)\n const insertedDerived = new Map<string, string[]>()\n\n for (const col of dataColumns) {\n if (!schemaSet.has(col)) {\n let inserted = false\n\n for (const schemaCol of schemaColumns) {\n if (col.startsWith(`${schemaCol}_`)) {\n const suffix = col.slice(schemaCol.length + 1)\n // Skip if suffix starts with a digit (array index pattern like field_0_*)\n if (!/^\\d/.test(suffix)) {\n const baseIdx = result.indexOf(schemaCol)\n if (baseIdx !== -1) {\n const derivedList = insertedDerived.get(schemaCol) || []\n const insertIdx = baseIdx + 1 + derivedList.length\n result.splice(insertIdx, 0, col)\n derivedList.push(col)\n insertedDerived.set(schemaCol, derivedList)\n schemaSet.add(col)\n inserted = true\n break\n }\n }\n }\n }\n\n if (!inserted) {\n // Check for array indices (e.g., field_1_*), insert after field_0_*\n const match = col.match(/^(.+?)_(\\d+)(_.*)?$/)\n if (match) {\n const [, basePath, index, suffix] = match\n if (basePath && index) {\n const prevIndex = parseInt(index, 10) - 1\n const prevCol = `${basePath}_${prevIndex}${suffix ?? ''}`\n const prevIdx = result.indexOf(prevCol)\n if (prevIdx !== -1) {\n // Insert after the previous index column\n result.splice(prevIdx + 1, 0, col)\n schemaSet.add(col)\n continue\n }\n }\n }\n\n const createdAtIdx = result.indexOf('createdAt')\n if (createdAtIdx !== -1) {\n result.splice(createdAtIdx, 0, col)\n } else {\n result.push(col)\n }\n schemaSet.add(col)\n }\n }\n }\n\n // Remove schema columns that were fully replaced by beforeExport-derived columns (e.g. \"user\" → \"user_id\", \"user_email\")\n for (const [schemaCol, derivedCols] of insertedDerived) {\n if (!dataColumns.includes(schemaCol) && derivedCols.length > 0) {\n const idx = result.indexOf(schemaCol)\n if (idx !== -1) {\n result.splice(idx, 1)\n }\n }\n }\n\n return result\n}\n\n/**\n * Filters schema columns to only include those matching user-selected fields.\n * Preserves the order specified by the user in selectedFields.\n *\n * Container fields (groups, arrays, blocks) don't produce their own column, so we prefix-expand\n * to find their children (e.g., 'group' → 'group_name', 'group_age').\n * Leaf fields (date, text, select) produce an exact column, so we only match exactly to avoid\n * including siblings with similar prefixes (e.g., 'dateWithTimezone' won't pull 'dateWithTimezone_tz').\n */\nexport function filterToSelectedFields(columns: string[], selectedFields: string[]): string[] {\n const result: string[] = []\n const columnsSet = new Set(columns)\n\n // Convert selected fields to underscore notation patterns\n const patterns = selectedFields.map((field) => {\n const underscored = field.replace(/\\./g, '_')\n return {\n exact: underscored,\n original: field,\n prefix: `${underscored}_`,\n }\n })\n\n // Iterate through user-specified fields in order to preserve their ordering\n for (const pattern of patterns) {\n const hasExactColumn = columnsSet.has(pattern.exact)\n\n if (hasExactColumn && !result.includes(pattern.exact)) {\n result.push(pattern.exact)\n }\n\n // Only prefix-expand if no exact column match exists (containers need expansion, leaves don't)\n if (!hasExactColumn) {\n for (const column of columns) {\n if (column.startsWith(pattern.prefix)) {\n if (!result.includes(column)) {\n result.push(column)\n }\n }\n }\n }\n }\n\n return result\n}\n"],"names":["getFlattenedFieldKeys","getSchemaColumns","collectionConfig","disabledFields","fields","selectedFields","locale","localeCodes","expandLocales","length","schemaColumns","flattenedFields","hasIdField","includes","filterToSelectedFields","disabledSet","Set","path","add","replace","filter","col","disabled","startsWith","mergeColumns","dataColumns","result","schemaSet","insertedDerived","Map","has","inserted","schemaCol","suffix","slice","test","baseIdx","indexOf","derivedList","get","insertIdx","splice","push","set","match","basePath","index","prevIndex","parseInt","prevCol","prevIdx","createdAtIdx","derivedCols","idx","columns","columnsSet","patterns","map","field","underscored","exact","original","prefix","pattern","hasExactColumn","column"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,6BAA4B;AAyBlE;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,mBAAmB,CAAC,EAC/BC,gBAAgB,EAChBC,iBAAiB,EAAE,EACnBC,QAAQC,cAAc,EACtBC,MAAM,EACNC,WAAW,EACU;IACrB,MAAMC,gBAAgBF,WAAW,SAASC,eAAeA,YAAYE,MAAM,GAAG;IAE9E,IAAIC,gBAAgBV,sBAClBE,iBAAiBS,eAAe,EAChC,IACAH,gBAAgB;QAAED;IAAY,IAAI,CAAC;IAGrC,kCAAkC;IAClC,MAAMK,aAAaF,cAAcG,QAAQ,CAAC;IAC1C,IAAI,CAACD,YAAY;QACfF,gBAAgB;YAAC;eAASA;SAAc;IAC1C;IAEA,IAAIL,kBAAkBA,eAAeI,MAAM,GAAG,GAAG;QAC/CC,gBAAgBI,uBAAuBJ,eAAeL;IACxD;IAEA,IAAIF,eAAeM,MAAM,GAAG,GAAG;QAC7B,MAAMM,cAAc,IAAIC;QACxB,KAAK,MAAMC,QAAQd,eAAgB;YACjCY,YAAYG,GAAG,CAACD,KAAKE,OAAO,CAAC,OAAO;QACtC;QACAT,g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CAACiC,QAAQH,KAAK;QAEnD,IAAII,kBAAkB,CAACtC,OAAOb,QAAQ,CAACkD,QAAQH,KAAK,GAAG;YACrDlC,OAAOgB,IAAI,CAACqB,QAAQH,KAAK;QAC3B;QAEA,+FAA+F;QAC/F,IAAI,CAACI,gBAAgB;YACnB,KAAK,MAAMC,UAAUX,QAAS;gBAC5B,IAAIW,OAAO1C,UAAU,CAACwC,QAAQD,MAAM,GAAG;oBACrC,IAAI,CAACpC,OAAOb,QAAQ,CAACoD,SAAS;wBAC5BvC,OAAOgB,IAAI,CAACuB;oBACd;gBACF;YACF;QACF;IACF;IAEA,OAAOvC;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"getSelect.d.ts","sourceRoot":"","sources":["../../src/utilities/getSelect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,WAAY,MAAM,EAAE,KAAG,iBAoB5C,CAAA"}
1
+ {"version":3,"file":"getSelect.d.ts","sourceRoot":"","sources":["../../src/utilities/getSelect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,EAAE,KAAG,iBAoB5C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"isPlainObject.d.ts","sourceRoot":"","sources":["../../src/utilities/isPlainObject.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,UAAW,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CACR,CAAA"}
1
+ {"version":3,"file":"isPlainObject.d.ts","sourceRoot":"","sources":["../../src/utilities/isPlainObject.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CACR,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"parseCSV.d.ts","sourceRoot":"","sources":["../../src/utilities/parseCSV.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,kBAAyB,YAAY,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CA8D7F,CAAA"}
1
+ {"version":3,"file":"parseCSV.d.ts","sourceRoot":"","sources":["../../src/utilities/parseCSV.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAU,eAAe,YAAY,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CA8D7F,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"parseJSON.d.ts","sourceRoot":"","sources":["../../src/utilities/parseJSON.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,kBAAmB,aAAa,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAiB/E,CAAA"}
1
+ {"version":3,"file":"parseJSON.d.ts","sourceRoot":"","sources":["../../src/utilities/parseJSON.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,eAAe,aAAa,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAiB/E,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"polymorphicRel.d.ts","sourceRoot":"","sources":["../../src/utilities/polymorphicRel.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,MAAM,GAAG,MAAM,CAAA;CACjD,CAAA;AAED,eAAO,MAAM,qBAAqB,MAAO,OAAO,KAAG,CAAC,IAAI,mBACkB,CAAA;AAE1E;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,MAAO,mBAAmB,KAAG,MAAM,GAAG,MAAM,GAAG,SAS9E,CAAA"}
1
+ {"version":3,"file":"polymorphicRel.d.ts","sourceRoot":"","sources":["../../src/utilities/polymorphicRel.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,MAAM,GAAG,MAAM,CAAA;CACjD,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,mBACkB,CAAA;AAE1E;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,GAAG,mBAAmB,KAAG,MAAM,GAAG,MAAM,GAAG,SAS9E,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"processRichTextField.d.ts","sourceRoot":"","sources":["../../src/utilities/processRichTextField.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,UAAW,OAAO,KAAG,OA4CrD,CAAA"}
1
+ {"version":3,"file":"processRichTextField.d.ts","sourceRoot":"","sources":["../../src/utilities/processRichTextField.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,KAAG,OA4CrD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"removeDisabledFields.d.ts","sourceRoot":"","sources":["../../src/utilities/removeDisabledFields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,oBAAoB,QAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,aAClB,MAAM,EAAE,KACjB,MAAM,CAAC,MAAM,EAAE,OAAO,CA8DxB,CAAA"}
1
+ {"version":3,"file":"removeDisabledFields.d.ts","sourceRoot":"","sources":["../../src/utilities/removeDisabledFields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,oBAAoB,GAC/B,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,WAAU,MAAM,EAAO,KACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CA8DxB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"setNestedValue.d.ts","sourceRoot":"","sources":["../../src/utilities/setNestedValue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,eAAO,MAAM,cAAc,QACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QACtB,MAAM,SACL,OAAO,KACb,IA8CF,CAAA"}
1
+ {"version":3,"file":"setNestedValue.d.ts","sourceRoot":"","sources":["../../src/utilities/setNestedValue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,eAAO,MAAM,cAAc,GACzB,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,MAAM,MAAM,EACZ,OAAO,OAAO,KACb,IA8CF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"sortHelpers.d.ts","sourceRoot":"","sources":["../../src/utilities/sortHelpers.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,eAAO,MAAM,aAAa,OAAQ,IAAI,GAAG,MAAM,KAAG,MAAwC,CAAA;AAE1F,iEAAiE;AACjE,eAAO,MAAM,cAAc,UAAW,MAAM,SAAS,KAAK,GAAG,MAAM,KAAG,MAC9B,CAAA;AAGxC,eAAO,MAAM,mBAAmB,MAAO,OAAO,KAAG,MAAM,GAAG,SAQzD,CAAA"}
1
+ {"version":3,"file":"sortHelpers.d.ts","sourceRoot":"","sources":["../../src/utilities/sortHelpers.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,eAAO,MAAM,aAAa,GAAI,IAAI,IAAI,GAAG,MAAM,KAAG,MAAwC,CAAA;AAE1F,iEAAiE;AACjE,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,OAAO,KAAK,GAAG,MAAM,KAAG,MAC9B,CAAA;AAGxC,eAAO,MAAM,mBAAmB,GAAI,GAAG,OAAO,KAAG,MAAM,GAAG,SAQzD,CAAA"}
@@ -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,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAKvD,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,CAAA;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM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