@payloadcms/plugin-import-export 4.0.0-internal.d28e9fb → 4.0.0-internal.d7d662c

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 (187) hide show
  1. package/dist/components/CollectionField/index.d.ts +3 -2
  2. package/dist/components/CollectionField/index.d.ts.map +1 -1
  3. package/dist/components/CollectionField/index.js.map +1 -1
  4. package/dist/components/ExportListMenuItem/index.d.ts.map +1 -1
  5. package/dist/components/ExportListMenuItem/index.js +14 -12
  6. package/dist/components/ExportListMenuItem/index.js.map +1 -1
  7. package/dist/components/ExportPreview/index.css +52 -0
  8. package/dist/components/ExportPreview/index.d.ts +1 -1
  9. package/dist/components/ExportPreview/index.d.ts.map +1 -1
  10. package/dist/components/ExportPreview/index.js +12 -2
  11. package/dist/components/ExportPreview/index.js.map +1 -1
  12. package/dist/components/FieldsToExport/index.d.ts +3 -2
  13. package/dist/components/FieldsToExport/index.d.ts.map +1 -1
  14. package/dist/components/FieldsToExport/index.js +18 -15
  15. package/dist/components/FieldsToExport/index.js.map +1 -1
  16. package/dist/components/FieldsToExport/reduceFields.d.ts +6 -0
  17. package/dist/components/FieldsToExport/reduceFields.d.ts.map +1 -1
  18. package/dist/components/FieldsToExport/reduceFields.js +4 -0
  19. package/dist/components/FieldsToExport/reduceFields.js.map +1 -1
  20. package/dist/components/FormatField/index.d.ts +3 -2
  21. package/dist/components/FormatField/index.d.ts.map +1 -1
  22. package/dist/components/FormatField/index.js +6 -3
  23. package/dist/components/FormatField/index.js.map +1 -1
  24. package/dist/components/ImportListMenuItem/index.d.ts.map +1 -1
  25. package/dist/components/ImportListMenuItem/index.js +14 -12
  26. package/dist/components/ImportListMenuItem/index.js.map +1 -1
  27. package/dist/components/ImportPreview/index.css +45 -0
  28. package/dist/components/ImportPreview/index.d.ts +1 -1
  29. package/dist/components/ImportPreview/index.d.ts.map +1 -1
  30. package/dist/components/ImportPreview/index.js +44 -11
  31. package/dist/components/ImportPreview/index.js.map +1 -1
  32. package/dist/components/LimitField/index.d.ts +3 -2
  33. package/dist/components/LimitField/index.d.ts.map +1 -1
  34. package/dist/components/LimitField/index.js.map +1 -1
  35. package/dist/components/LocaleField/index.d.ts +3 -2
  36. package/dist/components/LocaleField/index.d.ts.map +1 -1
  37. package/dist/components/LocaleField/index.js.map +1 -1
  38. package/dist/components/Page/index.d.ts +4 -3
  39. package/dist/components/Page/index.d.ts.map +1 -1
  40. package/dist/components/Page/index.js +1 -1
  41. package/dist/components/Page/index.js.map +1 -1
  42. package/dist/components/RelationshipCell/getRelationshipGroupKey.d.ts +7 -0
  43. package/dist/components/RelationshipCell/getRelationshipGroupKey.d.ts.map +1 -0
  44. package/dist/components/RelationshipCell/getRelationshipGroupKey.js +3 -0
  45. package/dist/components/RelationshipCell/getRelationshipGroupKey.js.map +1 -0
  46. package/dist/components/RelationshipCell/getRelationshipGroups.d.ts +43 -0
  47. package/dist/components/RelationshipCell/getRelationshipGroups.d.ts.map +1 -0
  48. package/dist/components/RelationshipCell/getRelationshipGroups.js +109 -0
  49. package/dist/components/RelationshipCell/getRelationshipGroups.js.map +1 -0
  50. package/dist/components/RelationshipCell/index.css +30 -0
  51. package/dist/components/RelationshipCell/index.d.ts +15 -0
  52. package/dist/components/RelationshipCell/index.d.ts.map +1 -0
  53. package/dist/components/RelationshipCell/index.js +57 -0
  54. package/dist/components/RelationshipCell/index.js.map +1 -0
  55. package/dist/components/SortBy/index.css +9 -0
  56. package/dist/components/SortBy/index.d.ts +4 -3
  57. package/dist/components/SortBy/index.d.ts.map +1 -1
  58. package/dist/components/SortBy/index.js +1 -2
  59. package/dist/components/SortBy/index.js.map +1 -1
  60. package/dist/components/SortOrder/index.css +9 -0
  61. package/dist/components/SortOrder/index.d.ts +4 -3
  62. package/dist/components/SortOrder/index.d.ts.map +1 -1
  63. package/dist/components/SortOrder/index.js +1 -2
  64. package/dist/components/SortOrder/index.js.map +1 -1
  65. package/dist/export/batchProcessor.d.ts +4 -3
  66. package/dist/export/batchProcessor.d.ts.map +1 -1
  67. package/dist/export/batchProcessor.js +6 -2
  68. package/dist/export/batchProcessor.js.map +1 -1
  69. package/dist/export/createExport.d.ts +4 -2
  70. package/dist/export/createExport.d.ts.map +1 -1
  71. package/dist/export/createExport.js +7 -2
  72. package/dist/export/createExport.js.map +1 -1
  73. package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
  74. package/dist/export/getCreateExportCollectionTask.js +11 -0
  75. package/dist/export/getCreateExportCollectionTask.js.map +1 -1
  76. package/dist/export/getExportCollection.d.ts.map +1 -1
  77. package/dist/export/getExportCollection.js +9 -4
  78. package/dist/export/getExportCollection.js.map +1 -1
  79. package/dist/export/getFields.js.map +1 -1
  80. package/dist/export/handleDownload.d.ts.map +1 -1
  81. package/dist/export/handleDownload.js +7 -3
  82. package/dist/export/handleDownload.js.map +1 -1
  83. package/dist/export/handlePreview.d.ts.map +1 -1
  84. package/dist/export/handlePreview.js +25 -6
  85. package/dist/export/handlePreview.js.map +1 -1
  86. package/dist/exports/types.d.ts +1 -1
  87. package/dist/exports/types.d.ts.map +1 -1
  88. package/dist/exports/types.js.map +1 -1
  89. package/dist/import/batchProcessor.d.ts +4 -3
  90. package/dist/import/batchProcessor.d.ts.map +1 -1
  91. package/dist/import/batchProcessor.js +15 -8
  92. package/dist/import/batchProcessor.js.map +1 -1
  93. package/dist/import/createImport.d.ts +3 -2
  94. package/dist/import/createImport.d.ts.map +1 -1
  95. package/dist/import/createImport.js +9 -2
  96. package/dist/import/createImport.js.map +1 -1
  97. package/dist/import/getCreateImportCollectionTask.d.ts.map +1 -1
  98. package/dist/import/getCreateImportCollectionTask.js +5 -2
  99. package/dist/import/getCreateImportCollectionTask.js.map +1 -1
  100. package/dist/import/getImportCollection.d.ts.map +1 -1
  101. package/dist/import/getImportCollection.js +6 -4
  102. package/dist/import/getImportCollection.js.map +1 -1
  103. package/dist/import/handlePreview.d.ts.map +1 -1
  104. package/dist/import/handlePreview.js +5 -1
  105. package/dist/import/handlePreview.js.map +1 -1
  106. package/dist/index.d.ts +2 -13
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +19 -8
  109. package/dist/index.js.map +1 -1
  110. package/dist/translations/languages/en.d.ts.map +1 -1
  111. package/dist/types.d.ts +17 -33
  112. package/dist/types.d.ts.map +1 -1
  113. package/dist/types.js.map +1 -1
  114. package/dist/utilities/applyFieldHooks.d.ts +1 -2
  115. package/dist/utilities/applyFieldHooks.d.ts.map +1 -1
  116. package/dist/utilities/applyFieldHooks.js +2 -3
  117. package/dist/utilities/applyFieldHooks.js.map +1 -1
  118. package/dist/utilities/flattenObject.d.ts.map +1 -1
  119. package/dist/utilities/flattenObject.js +3 -13
  120. package/dist/utilities/flattenObject.js.map +1 -1
  121. package/dist/utilities/flattenedFields.d.ts.map +1 -1
  122. package/dist/utilities/flattenedFields.js +3 -0
  123. package/dist/utilities/flattenedFields.js.map +1 -1
  124. package/dist/utilities/getExportFieldFunctions.js +64 -35
  125. package/dist/utilities/getExportFieldFunctions.js.map +1 -1
  126. package/dist/utilities/getFileFromDoc.js +3 -3
  127. package/dist/utilities/getFileFromDoc.js.map +1 -1
  128. package/dist/utilities/getImportFieldFunctions.js +0 -8
  129. package/dist/utilities/getImportFieldFunctions.js.map +1 -1
  130. package/dist/utilities/getSchemaColumns.d.ts +1 -1
  131. package/dist/utilities/getSchemaColumns.js +2 -2
  132. package/dist/utilities/getSchemaColumns.js.map +1 -1
  133. package/dist/utilities/getSelect.d.ts.map +1 -1
  134. package/dist/utilities/getSelect.js +11 -3
  135. package/dist/utilities/getSelect.js.map +1 -1
  136. package/dist/utilities/getSubmittedFormValues.d.ts +12 -0
  137. package/dist/utilities/getSubmittedFormValues.d.ts.map +1 -0
  138. package/dist/utilities/getSubmittedFormValues.js +24 -0
  139. package/dist/utilities/getSubmittedFormValues.js.map +1 -0
  140. package/dist/utilities/processRichTextField.d.ts.map +1 -1
  141. package/dist/utilities/processRichTextField.js +7 -0
  142. package/dist/utilities/processRichTextField.js.map +1 -1
  143. package/dist/utilities/setNestedValue.d.ts +2 -1
  144. package/dist/utilities/setNestedValue.d.ts.map +1 -1
  145. package/dist/utilities/setNestedValue.js +65 -34
  146. package/dist/utilities/setNestedValue.js.map +1 -1
  147. package/dist/utilities/sortHelpers.d.ts +1 -1
  148. package/dist/utilities/unflattenObject.d.ts.map +1 -1
  149. package/dist/utilities/unflattenObject.js +29 -18
  150. package/dist/utilities/unflattenObject.js.map +1 -1
  151. package/dist/utilities/unflattenPostProcess.d.ts.map +1 -1
  152. package/dist/utilities/unflattenPostProcess.js +39 -13
  153. package/dist/utilities/unflattenPostProcess.js.map +1 -1
  154. package/license.md +1 -1
  155. package/package.json +25 -28
  156. package/dist/components/ExportPreview/index.scss +0 -48
  157. package/dist/components/FieldsToExport/index.scss +0 -0
  158. package/dist/components/FieldsToExport/reduceFields.spec.js +0 -239
  159. package/dist/components/FieldsToExport/reduceFields.spec.js.map +0 -1
  160. package/dist/components/ImportPreview/index.scss +0 -41
  161. package/dist/components/SortBy/index.scss +0 -3
  162. package/dist/components/SortOrder/index.scss +0 -3
  163. package/dist/utilities/applyFieldHooks.spec.js +0 -205
  164. package/dist/utilities/applyFieldHooks.spec.js.map +0 -1
  165. package/dist/utilities/buildDisabledFieldRegex.spec.js +0 -64
  166. package/dist/utilities/buildDisabledFieldRegex.spec.js.map +0 -1
  167. package/dist/utilities/fieldToRegex.spec.js +0 -151
  168. package/dist/utilities/fieldToRegex.spec.js.map +0 -1
  169. package/dist/utilities/filterToSelectedFields.spec.js +0 -204
  170. package/dist/utilities/filterToSelectedFields.spec.js.map +0 -1
  171. package/dist/utilities/flattenObject.spec.js +0 -158
  172. package/dist/utilities/flattenObject.spec.js.map +0 -1
  173. package/dist/utilities/getExportFieldFunctions.spec.js +0 -50
  174. package/dist/utilities/getExportFieldFunctions.spec.js.map +0 -1
  175. package/dist/utilities/getImportFieldFunctions.spec.js +0 -167
  176. package/dist/utilities/getImportFieldFunctions.spec.js.map +0 -1
  177. package/dist/utilities/getSchemaColumns.spec.js +0 -157
  178. package/dist/utilities/getSchemaColumns.spec.js.map +0 -1
  179. package/dist/utilities/legacyHookDispatch.spec.js +0 -227
  180. package/dist/utilities/legacyHookDispatch.spec.js.map +0 -1
  181. package/dist/utilities/parseCSV.spec.js +0 -195
  182. package/dist/utilities/parseCSV.spec.js.map +0 -1
  183. package/dist/utilities/siblingDoc.spec.js +0 -278
  184. package/dist/utilities/siblingDoc.spec.js.map +0 -1
  185. package/dist/utilities/unflattenObject.spec.js +0 -713
  186. package/dist/utilities/unflattenObject.spec.js.map +0 -1
  187. /package/dist/components/Page/{index.scss → index.css} +0 -0
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CollectionConfig, CollectionSlug, DataFromCollectionSlug, PayloadRequest } from 'payload';
1
+ import type { CollectionConfig, CollectionSlug, DataFromCollectionSlug, JsonObject, PayloadRequest } from 'payload';
2
2
  /**
3
3
  * Function to dynamically determine the limit based on request context
4
4
  */
@@ -29,6 +29,14 @@ export type ImportResult = {
29
29
  total: number;
30
30
  updated: number;
31
31
  };
32
+ /** Export document or unsaved form values. `id` indicates a saved document. Treat as read-only. */
33
+ export type ExportDoc = {
34
+ id?: number | string;
35
+ } & JsonObject;
36
+ /** Import document or unsaved preview form values. `id` indicates a saved document. Treat as read-only. */
37
+ export type ImportDoc = {
38
+ id?: number | string;
39
+ } & JsonObject;
32
40
  /**
33
41
  * Hook called before each export batch is written to file.
34
42
  * Receives the transformed batch data and the original DB documents.
@@ -39,6 +47,8 @@ export type ExportBeforeHook<TSlug extends CollectionSlug = CollectionSlug> = (a
39
47
  batchNumber: number;
40
48
  /** Transformed batch — flat rows for CSV, nested docs for JSON. Modify and return this. */
41
49
  data: Record<string, unknown>[];
50
+ /** See {@link ExportDoc}. */
51
+ exportDoc: ExportDoc;
42
52
  /** Export format. Open-ended to support custom formats in the future. */
43
53
  format: 'csv' | 'json' | ({} & string);
44
54
  /**
@@ -63,6 +73,8 @@ export type ExportAfterHook = (args: {
63
73
  batchNumber: number;
64
74
  /** The batch data that was written */
65
75
  data: Record<string, unknown>[];
76
+ /** See {@link ExportDoc}. */
77
+ exportDoc: ExportDoc;
66
78
  /** Export format */
67
79
  format: 'csv' | 'json' | ({} & string);
68
80
  /** Raw DB documents before transformation */
@@ -88,6 +100,8 @@ export type ImportBeforeHook<TSlug extends CollectionSlug = CollectionSlug> = (a
88
100
  data: Partial<DataFromCollectionSlug<TSlug>>[];
89
101
  /** Import format. Open-ended to support custom formats in the future. */
90
102
  format: 'csv' | 'json' | ({} & string);
103
+ /** See {@link ImportDoc}. */
104
+ importDoc: ImportDoc;
91
105
  /** Raw parsed file rows before unflattening. Read-only reference. */
92
106
  originalData: Record<string, unknown>[];
93
107
  req: PayloadRequest;
@@ -103,6 +117,8 @@ export type ImportAfterHook = (args: {
103
117
  batchNumber: number;
104
118
  /** Import format */
105
119
  format: 'csv' | 'json' | ({} & string);
120
+ /** See {@link ImportDoc}. */
121
+ importDoc: ImportDoc;
106
122
  /**
107
123
  * Raw parsed file rows for this batch before unflattening and before-hook
108
124
  * transformation. For CSV this is the flat key/value row; for JSON this is
@@ -348,47 +364,15 @@ export type FieldBeforeImportHook = (args: {
348
364
  siblingDoc: Record<string, unknown>;
349
365
  value: unknown;
350
366
  }) => unknown;
351
- /**
352
- * @deprecated use `hooks.beforeExport`. Will be removed in a future major version.
353
- * Original arg shape preserved for backwards compatibility.
354
- */
355
- export type ToCSVFunction = (args: {
356
- columnName: string;
357
- /** Alias for `row`. */
358
- data: Record<string, unknown>;
359
- /** The top-level document being exported. */
360
- doc: Record<string, unknown>;
361
- /** Flat row accumulator at the current level. Mutate to add columns. */
362
- row: Record<string, unknown>;
363
- /** Source document at the current level. */
364
- siblingDoc: Record<string, unknown>;
365
- value: unknown;
366
- }) => unknown;
367
- /**
368
- * @deprecated use `hooks.beforeImport`. Will be removed in a future major version.
369
- * Original arg shape preserved for backwards compatibility.
370
- */
371
- export type FromCSVFunction = (args: {
372
- columnName: string;
373
- /** The full flat row being imported. */
374
- data: Record<string, unknown>;
375
- value: unknown;
376
- }) => unknown;
377
367
  /** @internal */
378
368
  export type ExportFieldHookEntry = {
379
369
  fn: FieldBeforeExportHook;
380
370
  type: 'beforeExport';
381
- } | {
382
- fn: ToCSVFunction;
383
- type: 'toCSV';
384
371
  };
385
372
  /** @internal */
386
373
  export type ImportFieldHookEntry = {
387
374
  fn: FieldBeforeImportHook;
388
375
  type: 'beforeImport';
389
- } | {
390
- fn: FromCSVFunction;
391
- type: 'fromCSV';
392
376
  };
393
377
  /**
394
378
  * Base pagination data returned from preview endpoints
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,cAAc,EACf,MAAM,SAAS,CAAA;AAEhB;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEvF;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG,aAAa,GAAG,MAAM,CAAA;AAE1C;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,EAChC,UAAU,GACX,EAAE;IACD,UAAU,EAAE,gBAAgB,CAAA;CAC7B,KAAK,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAElD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,KAAK,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC5B,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,MAAM,CAAA;KACd,CAAC,CAAA;IACF,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MA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AAChB,MAAM,MAAM,oBAAoB,GAAG;IAAE,EAAE,EAAE,qBAAqB,CAAC;IAAC,IAAI,EAAE,cAAc,CAAA;CAAE,CAAA;AAEtF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAC/B;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;CACxB,GAAG,qBAAqB,CAAA;AAEzB;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAC/B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,GAAG,qBAAqB,CAAA"}
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 JsonObject,\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/** Export document or unsaved form values. `id` indicates a saved document. Treat as read-only. */\nexport type ExportDoc = { id?: number | string } & JsonObject\n\n/** Import document or unsaved preview form values. `id` indicates a saved document. Treat as read-only. */\nexport type ImportDoc = { id?: number | string } & JsonObject\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 /** See {@link ExportDoc}. */\n exportDoc: ExportDoc\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 /** See {@link ExportDoc}. */\n exportDoc: ExportDoc\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 /** See {@link ImportDoc}. */\n importDoc: ImportDoc\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 /** See {@link ImportDoc}. */\n importDoc: ImportDoc\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":"AAkcA;;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,EAAkB,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7E,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;AA4HD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,SAAU,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAYlE,CAAA"}
@@ -77,7 +77,7 @@ const traverseFields = ({ type, data, fieldHooks, fields, format, operation, pat
77
77
  return item;
78
78
  }
79
79
  const blockType = typeof item.blockType === 'string' ? item.blockType : undefined;
80
- const block = blockType ? field.blocks.find((b)=>b.slug === blockType) : undefined;
80
+ const block = blockType ? req.payload.blocks[blockType] ?? field.blocks.find((b)=>typeof b !== 'string' && b.slug === blockType) : undefined;
81
81
  return traverseFields({
82
82
  type,
83
83
  data,
@@ -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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ACAC;oBACAC,MAAM,GAAGO,UAAU,CAAC,EAAEoB,OAAO;oBAC7B1B;oBACAC,YAAYM;oBACZL,aAAauB;gBACf;YACF;QACF,OAAO,IAAIrB,MAAMX,IAAI,KAAK,YAAY6B,MAAMC,OAAO,CAACR,QAAQ;YAC1DZ,MAAM,CAACC,MAAMC,IAAI,CAAC,GAAGU,MAAMS,GAAG,CAAC,CAACC,MAAMC;gBACpC,IAAI,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 { FlattenedBlock, 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 : 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\n ? (req.payload.blocks[blockType] ??\n field.blocks.find(\n (b): b is FlattenedBlock => typeof b !== 'string' && b.slug === blockType,\n ))\n : 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","appl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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,2DAOvB,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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AAA;gBAC3CA;gBACAC,OAAOpE,aAAamE;YACtB,CAAA;QAEA,MAAME,UAAUnC,OAAO0B,IAAI,CAACjD;QAE5B,KAAK,MAAM,EAAEyD,KAAK,EAAE,IAAIF,cAAe;YACrC,KAAK,MAAM7B,OAAOgC,QAAS;gBACzB,IAAIhC,OAAO4B,eAAe;oBACxB;gBACF;gBAEA,IAAIG,MAAME,IAAI,CAACjC,MAAM;oBACnB4B,aAAa,CAAC5B,IAAI,GAAG1B,GAAG,CAAC0B,IAAI;gBAC/B;YACF;QACF;QAEA,OAAO4B;IACT;IAEA,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"],"mapp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QACF;IACF;IAEAc,kBAAkBxB,MAAMI,MAAMA;IAE9B,IAAIY,MAAMC,OAAO,CAACf,WAAWA,OAAOgB,MAAM,GAAG,GAAG;QAC9C,MAAMwC,gBAAyC,CAAC;QAEhD,MAAMC,gBAAgBzD,OAAOkB,GAAG,CAAC,CAACwC,QAAW,CAAA;gBAC3CA;gBACAC,OAAOlE,aAAaiE;YACtB,CAAA;QAEA,MAAME,UAAUnC,OAAO0B,IAAI,CAAC/C;QAE5B,KAAK,MAAM,EAAEuD,KAAK,EAAE,IAAIF,cAAe;YACrC,KAAK,MAAM7B,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,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,IA6BF,CAAA"}
@@ -19,6 +19,9 @@
19
19
  if (field.type === 'blocks') {
20
20
  const base = parentPath ? `${parentPath}_${field.name}` : field.name;
21
21
  for (const block of field.blocks ?? []){
22
+ if (typeof block === 'string') {
23
+ continue;
24
+ }
22
25
  registerFieldHooks(getBlockFlattenedFields(block), `${base}_${block.slug}`, result, registerHandler);
23
26
  }
24
27
  continue;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/flattenedFields.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\n/**\n * Returns the `flattenedFields` of a group/tab/array field, or undefined for\n * field types that don't carry nested fields. Concentrates the cast for the\n * Payload core typing oversight (`FlattenedField` doesn't expose\n * `flattenedFields` on every variant).\n */\nexport const getNestedFlattenedFields = (field: FlattenedField): FlattenedField[] | undefined =>\n (field as { flattenedFields?: FlattenedField[] }).flattenedFields\n\n/**\n * Returns the `flattenedFields` of a `BlocksField` block (always an array).\n */\nexport const getBlockFlattenedFields = (block: {\n flattenedFields?: FlattenedField[]\n}): FlattenedField[] => block.flattenedFields ?? []\n\n/**\n * Traverses a flattened field schema and calls `registerHandler` for each\n * named field. Handles blocks (keyed by block slug), groups, tabs, and arrays.\n * Shared by `getExportFieldFunctions` and `getImportFieldFunctions`.\n */\nexport const registerFieldHooks = <TEntry>(\n fields: FlattenedField[],\n parentPath: string,\n result: Record<string, TEntry>,\n registerHandler: (field: FlattenedField, fullKey: string, result: Record<string, TEntry>) => void,\n): void => {\n for (const field of fields) {\n if (!('name' in field) || !field.name) {\n continue\n }\n\n if (field.type === 'blocks') {\n const base = parentPath ? `${parentPath}_${field.name}` : field.name\n for (const block of field.blocks ?? []) {\n registerFieldHooks(\n getBlockFlattenedFields(block),\n `${base}_${block.slug}`,\n result,\n registerHandler,\n )\n }\n continue\n }\n\n const fullKey = parentPath ? `${parentPath}_${field.name}` : field.name\n registerHandler(field, fullKey, result)\n\n if (field.type === 'group' || field.type === 'tab' || field.type === 'array') {\n registerFieldHooks(getNestedFlattenedFields(field) ?? [], fullKey, result, registerHandler)\n }\n }\n}\n"],"names":["getNestedFlattenedFields","field","flattenedFields","getBlockFlattenedFields","block","registerFieldHooks","fields","parentPath","result","registerHandler","name","type","base","blocks","slug","fullKey"],"mappings":"AAEA;;;;;CAKC,GACD,OAAO,MAAMA,2BAA2B,CAACC,QACvC,AAACA,MAAiDC,eAAe,CAAA;AAEnE;;CAEC,GACD,OAAO,MAAMC,0BAA0B,CAACC,QAEhBA,MAAMF,eAAe,IAAI,EAAE,CAAA;AAEnD;;;;CAIC,GACD,OAAO,MAAMG,qBAAqB,CAChCC,QACAC,YACAC,QACAC;IAEA,KAAK,MAAMR,SAASK,OAAQ;QAC1B,IAAI,CAAE,CAAA,UAAUL,KAAI,KAAM,CAACA,MAAMS,IAAI,EAAE;YACrC;QACF;QAEA,IAAIT,MAAMU,IAAI,KAAK,UAAU;YAC3B,MAAMC,OAAOL,aAAa,GAAGA,WAAW,CAAC,EAAEN,MAAMS,IAAI,EAAE,GAAGT,MAAMS,IAAI;YACpE,KAAK,MAAMN,SAASH,MAAMY,MAAM,IAAI,EAAE,CAAE;gBACtCR,mBACEF,wBAAwBC,QACxB,GAAGQ,KAAK,CAAC,EAAER,MAAMU,IAAI,EAAE,EACvBN,QACAC;YAEJ;YACA;QACF;QAEA,MAAMM,UAAUR,aAAa,GAAGA,WAAW,CAAC,EAAEN,MAAMS,IAAI,EAAE,GAAGT,MAAMS,IAAI;QACvED,gBAAgBR,OAAOc,SAASP;QAEhC,IAAIP,MAAMU,IAAI,KAAK,WAAWV,MAAMU,IAAI,KAAK,SAASV,MAAMU,IAAI,KAAK,SAAS;YAC5EN,mBAAmBL,yBAAyBC,UAAU,EAAE,EAAEc,SAASP,QAAQC;QAC7E;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/flattenedFields.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\n/**\n * Returns the `flattenedFields` of a group/tab/array field, or undefined for\n * field types that don't carry nested fields. Concentrates the cast for the\n * Payload core typing oversight (`FlattenedField` doesn't expose\n * `flattenedFields` on every variant).\n */\nexport const getNestedFlattenedFields = (field: FlattenedField): FlattenedField[] | undefined =>\n (field as { flattenedFields?: FlattenedField[] }).flattenedFields\n\n/**\n * Returns the `flattenedFields` of a `BlocksField` block (always an array).\n */\nexport const getBlockFlattenedFields = (block: {\n flattenedFields?: FlattenedField[]\n}): FlattenedField[] => block.flattenedFields ?? []\n\n/**\n * Traverses a flattened field schema and calls `registerHandler` for each\n * named field. Handles blocks (keyed by block slug), groups, tabs, and arrays.\n * Shared by `getExportFieldFunctions` and `getImportFieldFunctions`.\n */\nexport const registerFieldHooks = <TEntry>(\n fields: FlattenedField[],\n parentPath: string,\n result: Record<string, TEntry>,\n registerHandler: (field: FlattenedField, fullKey: string, result: Record<string, TEntry>) => void,\n): void => {\n for (const field of fields) {\n if (!('name' in field) || !field.name) {\n continue\n }\n\n if (field.type === 'blocks') {\n const base = parentPath ? `${parentPath}_${field.name}` : field.name\n for (const block of field.blocks ?? []) {\n if (typeof block === 'string') {\n continue\n }\n registerFieldHooks(\n getBlockFlattenedFields(block),\n `${base}_${block.slug}`,\n result,\n registerHandler,\n )\n }\n continue\n }\n\n const fullKey = parentPath ? `${parentPath}_${field.name}` : field.name\n registerHandler(field, fullKey, result)\n\n if (field.type === 'group' || field.type === 'tab' || field.type === 'array') {\n registerFieldHooks(getNestedFlattenedFields(field) ?? [], fullKey, result, registerHandler)\n }\n }\n}\n"],"names":["getNestedFlattenedFields","field","flattenedFields","getBlockFlattenedFields","block","registerFieldHooks","fields","parentPath","result","registerHandler","name","type","base","blocks","slug","fullKey"],"mappings":"AAEA;;;;;CAKC,GACD,OAAO,MAAMA,2BAA2B,CAACC,QACvC,AAACA,MAAiDC,eAAe,CAAA;AAEnE;;CAEC,GACD,OAAO,MAAMC,0BAA0B,CAACC,QAEhBA,MAAMF,eAAe,IAAI,EAAE,CAAA;AAEnD;;;;CAIC,GACD,OAAO,MAAMG,qBAAqB,CAChCC,QACAC,YACAC,QACAC;IAEA,KAAK,MAAMR,SAASK,OAAQ;QAC1B,IAAI,CAAE,CAAA,UAAUL,KAAI,KAAM,CAACA,MAAMS,IAAI,EAAE;YACrC;QACF;QAEA,IAAIT,MAAMU,IAAI,KAAK,UAAU;YAC3B,MAAMC,OAAOL,aAAa,GAAGA,WAAW,CAAC,EAAEN,MAAMS,IAAI,EAAE,GAAGT,MAAMS,IAAI;YACpE,KAAK,MAAMN,SAASH,MAAMY,MAAM,IAAI,EAAE,CAAE;gBACtC,IAAI,OAAOT,UAAU,UAAU;oBAC7B;gBACF;gBACAC,mBACEF,wBAAwBC,QACxB,GAAGQ,KAAK,CAAC,EAAER,MAAMU,IAAI,EAAE,EACvBN,QACAC;YAEJ;YACA;QACF;QAEA,MAAMM,UAAUR,aAAa,GAAGA,WAAW,CAAC,EAAEN,MAAMS,IAAI,EAAE,GAAGT,MAAMS,IAAI;QACvED,gBAAgBR,OAAOc,SAASP;QAEhC,IAAIP,MAAMU,IAAI,KAAK,WAAWV,MAAMU,IAAI,KAAK,SAASV,MAAMU,IAAI,KAAK,SAAS;YAC5EN,mBAAmBL,yBAAyBC,UAAU,EAAE,EAAEc,SAASP,QAAQC;QAC7E;IACF;AACF,EAAC"}
@@ -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',
@@ -58,45 +50,82 @@ const registerExportHandler = (field, fullKey, result)=>{
58
50
  registerHandler(({ value })=>typeof value === 'object' && value && 'id' in value ? value.id : value);
59
51
  return;
60
52
  }
61
- registerHandler(({ siblingData, value })=>{
62
- if (isPolymorphicRelValue(value)) {
63
- const id = getPolymorphicRelId(value);
64
- if (id !== undefined) {
65
- siblingData[`${fullKey}_id`] = id;
66
- siblingData[`${fullKey}_relationTo`] = value.relationTo;
67
- }
53
+ registerHandler(({ format, siblingData, value })=>{
54
+ // A shape this handler does not recognize is left untouched for JSON, which holds the
55
+ // source value verbatim. CSV still clears it, since its id/relationTo would otherwise
56
+ // land in sibling columns.
57
+ if (!isPolymorphicRelValue(value)) {
58
+ return format === 'json' ? undefined : null;
68
59
  }
60
+ // A recognized reference that resolves to no id is dangling, and a dangling reference
61
+ // cannot be imported back — clear it for both formats.
62
+ const id = getPolymorphicRelId(value);
63
+ if (id === undefined) {
64
+ return null;
65
+ }
66
+ if (format === 'json') {
67
+ return {
68
+ relationTo: value.relationTo,
69
+ value: id
70
+ };
71
+ }
72
+ siblingData[`${fullKey}_id`] = id;
73
+ siblingData[`${fullKey}_relationTo`] = value.relationTo;
69
74
  return null;
70
75
  });
71
76
  return;
72
77
  }
73
78
  if (!Array.isArray(field.relationTo)) {
74
- registerHandler(({ siblingData, value })=>{
75
- if (Array.isArray(value)) {
76
- value.forEach((val, i)=>{
77
- const id = typeof val === 'object' && val ? val.id : val;
78
- siblingData[`${fullKey}_${i}_id`] = id;
79
- });
80
- return null;
79
+ registerHandler(({ format, siblingData, value })=>{
80
+ if (!Array.isArray(value)) {
81
+ return undefined;
81
82
  }
82
- return undefined;
83
+ const ids = value.map((val)=>typeof val === 'object' && val ? val.id : val);
84
+ // Bare null entries fail relationship validation when the JSON is imported, so drop
85
+ // references that could not be resolved. CSV keeps source indexes in its column names;
86
+ // unflattening those columns collapses any gaps on import.
87
+ if (format === 'json') {
88
+ return ids.filter((id)=>id !== null && id !== undefined);
89
+ }
90
+ ids.forEach((id, i)=>{
91
+ siblingData[`${fullKey}_${i}_id`] = id;
92
+ });
93
+ return null;
83
94
  });
84
95
  return;
85
96
  }
86
- registerHandler(({ siblingData, value })=>{
87
- if (Array.isArray(value)) {
88
- value.forEach((val, i)=>{
89
- if (isPolymorphicRelValue(val)) {
90
- const id = getPolymorphicRelId(val);
91
- if (id !== undefined) {
92
- siblingData[`${fullKey}_${i}_id`] = id;
93
- siblingData[`${fullKey}_${i}_relationTo`] = val.relationTo;
94
- }
97
+ registerHandler(({ format, siblingData, value })=>{
98
+ if (!Array.isArray(value)) {
99
+ return undefined;
100
+ }
101
+ // `index` is carried so CSV columns stay pinned to the source position: an entry
102
+ // that cannot be resolved to an id leaves a gap rather than shifting its siblings.
103
+ const rels = value.flatMap((val, index)=>{
104
+ if (!isPolymorphicRelValue(val)) {
105
+ return [];
106
+ }
107
+ const id = getPolymorphicRelId(val);
108
+ return id === undefined ? [] : [
109
+ {
110
+ id,
111
+ index,
112
+ relationTo: val.relationTo
95
113
  }
96
- });
97
- return null;
114
+ ];
115
+ });
116
+ if (format === 'json') {
117
+ // Bare null entries fail relationship validation when the JSON is imported, so return
118
+ // only references that resolved to an id.
119
+ return rels.map(({ id, relationTo })=>({
120
+ relationTo,
121
+ value: id
122
+ }));
98
123
  }
99
- return undefined;
124
+ rels.forEach(({ id, index, relationTo })=>{
125
+ siblingData[`${fullKey}_${index}_id`] = id;
126
+ siblingData[`${fullKey}_${index}_relationTo`] = relationTo;
127
+ });
128
+ return null;
100
129
  });
101
130
  };
102
131
 
@@ -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,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
+ {"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 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(({ format, siblingData, value }) => {\n // A shape this handler does not recognize is left untouched for JSON, which holds the\n // source value verbatim. CSV still clears it, since its id/relationTo would otherwise\n // land in sibling columns.\n if (!isPolymorphicRelValue(value)) {\n return format === 'json' ? undefined : null\n }\n\n // A recognized reference that resolves to no id is dangling, and a dangling reference\n // cannot be imported back — clear it for both formats.\n const id = getPolymorphicRelId(value)\n if (id === undefined) {\n return null\n }\n\n if (format === 'json') {\n return { relationTo: value.relationTo, value: id }\n }\n siblingData[`${fullKey}_id`] = id\n siblingData[`${fullKey}_relationTo`] = value.relationTo\n return null\n })\n return\n }\n\n if (!Array.isArray(field.relationTo)) {\n registerHandler(({ format, siblingData, value }) => {\n if (!Array.isArray(value)) {\n return undefined\n }\n const ids = value.map((val) =>\n typeof val === 'object' && val ? (val as { id: unknown }).id : val,\n )\n // Bare null entries fail relationship validation when the JSON is imported, so drop\n // references that could not be resolved. CSV keeps source indexes in its column names;\n // unflattening those columns collapses any gaps on import.\n if (format === 'json') {\n return ids.filter((id) => id !== null && id !== undefined)\n }\n ids.forEach((id, i) => {\n siblingData[`${fullKey}_${i}_id`] = id\n })\n return null\n })\n return\n }\n\n registerHandler(({ format, siblingData, value }) => {\n if (!Array.isArray(value)) {\n return undefined\n }\n // `index` is carried so CSV columns stay pinned to the source position: an entry\n // that cannot be resolved to an id leaves a gap rather than shifting its siblings.\n const rels = value.flatMap((val, index) => {\n if (!isPolymorphicRelValue(val)) {\n return []\n }\n const id = getPolymorphicRelId(val)\n return id === undefined ? [] : [{ id, index, relationTo: val.relationTo }]\n })\n\n if (format === 'json') {\n // Bare null entries fail relationship validation when the JSON is imported, so return\n // only references that resolved to an id.\n return rels.map(({ id, relationTo }) => ({ relationTo, value: id }))\n }\n rels.forEach(({ id, index, relationTo }) => {\n siblingData[`${fullKey}_${index}_id`] = id\n siblingData[`${fullKey}_${index}_relationTo`] = relationTo\n })\n return null\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","ids","map","val","filter","forEach","i","rels","flatMap","index"],"mappings":"AAIA,SAASA,kBAAkB,QAAQ,uBAAs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