@payloadcms/plugin-import-export 4.0.0-internal.688c4d0 → 4.0.0-internal.77191e5

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 (130) hide show
  1. package/dist/components/ExportPreview/index.css +55 -0
  2. package/dist/components/ExportPreview/index.d.ts +1 -1
  3. package/dist/components/ExportPreview/index.d.ts.map +1 -1
  4. package/dist/components/ExportPreview/index.js +1 -1
  5. package/dist/components/ExportPreview/index.js.map +1 -1
  6. package/dist/components/FieldsToExport/reduceFields.d.ts.map +1 -1
  7. package/dist/components/FormatField/index.d.ts.map +1 -1
  8. package/dist/components/FormatField/index.js +6 -3
  9. package/dist/components/FormatField/index.js.map +1 -1
  10. package/dist/components/ImportPreview/index.css +48 -0
  11. package/dist/components/ImportPreview/index.d.ts +1 -1
  12. package/dist/components/ImportPreview/index.d.ts.map +1 -1
  13. package/dist/components/ImportPreview/index.js +1 -1
  14. package/dist/components/ImportPreview/index.js.map +1 -1
  15. package/dist/components/Page/index.d.ts +1 -1
  16. package/dist/components/Page/index.d.ts.map +1 -1
  17. package/dist/components/Page/index.js +1 -1
  18. package/dist/components/Page/index.js.map +1 -1
  19. package/dist/components/SortBy/index.css +9 -0
  20. package/dist/components/SortBy/index.d.ts +1 -1
  21. package/dist/components/SortBy/index.d.ts.map +1 -1
  22. package/dist/components/SortBy/index.js +1 -2
  23. package/dist/components/SortBy/index.js.map +1 -1
  24. package/dist/components/SortOrder/index.css +9 -0
  25. package/dist/components/SortOrder/index.d.ts +1 -1
  26. package/dist/components/SortOrder/index.d.ts.map +1 -1
  27. package/dist/components/SortOrder/index.js +1 -2
  28. package/dist/components/SortOrder/index.js.map +1 -1
  29. package/dist/export/batchProcessor.d.ts +2 -2
  30. package/dist/export/batchProcessor.d.ts.map +1 -1
  31. package/dist/export/batchProcessor.js.map +1 -1
  32. package/dist/export/createExport.d.ts +2 -2
  33. package/dist/export/createExport.d.ts.map +1 -1
  34. package/dist/export/createExport.js +1 -1
  35. package/dist/export/createExport.js.map +1 -1
  36. package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
  37. package/dist/export/getExportCollection.d.ts.map +1 -1
  38. package/dist/export/getExportCollection.js +4 -4
  39. package/dist/export/getExportCollection.js.map +1 -1
  40. package/dist/export/getFields.d.ts.map +1 -1
  41. package/dist/export/handleDownload.d.ts.map +1 -1
  42. package/dist/export/handleDownload.js +2 -2
  43. package/dist/export/handleDownload.js.map +1 -1
  44. package/dist/export/handlePreview.d.ts.map +1 -1
  45. package/dist/export/handlePreview.js +1 -1
  46. package/dist/export/handlePreview.js.map +1 -1
  47. package/dist/import/batchProcessor.d.ts +2 -2
  48. package/dist/import/batchProcessor.d.ts.map +1 -1
  49. package/dist/import/batchProcessor.js.map +1 -1
  50. package/dist/import/createImport.d.ts.map +1 -1
  51. package/dist/import/createImport.js.map +1 -1
  52. package/dist/import/getCreateImportCollectionTask.d.ts.map +1 -1
  53. package/dist/import/getFields.d.ts.map +1 -1
  54. package/dist/import/getImportCollection.d.ts.map +1 -1
  55. package/dist/import/getImportCollection.js +4 -4
  56. package/dist/import/getImportCollection.js.map +1 -1
  57. package/dist/import/handlePreview.d.ts.map +1 -1
  58. package/dist/index.d.ts +1 -2
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +6 -3
  61. package/dist/index.js.map +1 -1
  62. package/dist/translations/languages/en.d.ts.map +1 -1
  63. package/dist/utilities/applyFieldHooks.d.ts.map +1 -1
  64. package/dist/utilities/buildDisabledFieldRegex.d.ts.map +1 -1
  65. package/dist/utilities/collectDisabledFieldPaths.d.ts.map +1 -1
  66. package/dist/utilities/fieldToRegex.d.ts.map +1 -1
  67. package/dist/utilities/flattenObject.d.ts.map +1 -1
  68. package/dist/utilities/flattenedFields.d.ts.map +1 -1
  69. package/dist/utilities/getExportFieldFunctions.d.ts.map +1 -1
  70. package/dist/utilities/getFileFromDoc.d.ts.map +1 -1
  71. package/dist/utilities/getFileFromDoc.js +3 -3
  72. package/dist/utilities/getFileFromDoc.js.map +1 -1
  73. package/dist/utilities/getFlattenedFieldKeys.d.ts.map +1 -1
  74. package/dist/utilities/getImportFieldFunctions.d.ts.map +1 -1
  75. package/dist/utilities/getPluginCollections.d.ts.map +1 -1
  76. package/dist/utilities/getSchemaColumns.d.ts.map +1 -1
  77. package/dist/utilities/getSelect.d.ts.map +1 -1
  78. package/dist/utilities/getSelect.js +11 -3
  79. package/dist/utilities/getSelect.js.map +1 -1
  80. package/dist/utilities/isPlainObject.d.ts.map +1 -1
  81. package/dist/utilities/parseCSV.d.ts.map +1 -1
  82. package/dist/utilities/parseJSON.d.ts.map +1 -1
  83. package/dist/utilities/polymorphicRel.d.ts.map +1 -1
  84. package/dist/utilities/processRichTextField.d.ts.map +1 -1
  85. package/dist/utilities/removeDisabledFields.d.ts.map +1 -1
  86. package/dist/utilities/setNestedValue.d.ts +2 -1
  87. package/dist/utilities/setNestedValue.d.ts.map +1 -1
  88. package/dist/utilities/setNestedValue.js +65 -34
  89. package/dist/utilities/setNestedValue.js.map +1 -1
  90. package/dist/utilities/sortHelpers.d.ts +1 -1
  91. package/dist/utilities/sortHelpers.d.ts.map +1 -1
  92. package/dist/utilities/unflattenObject.d.ts.map +1 -1
  93. package/dist/utilities/unflattenPostProcess.d.ts.map +1 -1
  94. package/dist/utilities/validateLimitValue.d.ts.map +1 -1
  95. package/license.md +1 -1
  96. package/package.json +9 -9
  97. package/dist/@types/assets.d.js +0 -2
  98. package/dist/@types/assets.d.js.map +0 -1
  99. package/dist/components/ExportPreview/index.scss +0 -48
  100. package/dist/components/FieldsToExport/index.scss +0 -0
  101. package/dist/components/FieldsToExport/reduceFields.spec.js +0 -239
  102. package/dist/components/FieldsToExport/reduceFields.spec.js.map +0 -1
  103. package/dist/components/ImportPreview/index.scss +0 -41
  104. package/dist/components/SortBy/index.scss +0 -3
  105. package/dist/components/SortOrder/index.scss +0 -3
  106. package/dist/utilities/applyFieldHooks.spec.js +0 -205
  107. package/dist/utilities/applyFieldHooks.spec.js.map +0 -1
  108. package/dist/utilities/buildDisabledFieldRegex.spec.js +0 -64
  109. package/dist/utilities/buildDisabledFieldRegex.spec.js.map +0 -1
  110. package/dist/utilities/fieldToRegex.spec.js +0 -151
  111. package/dist/utilities/fieldToRegex.spec.js.map +0 -1
  112. package/dist/utilities/filterToSelectedFields.spec.js +0 -204
  113. package/dist/utilities/filterToSelectedFields.spec.js.map +0 -1
  114. package/dist/utilities/flattenObject.spec.js +0 -158
  115. package/dist/utilities/flattenObject.spec.js.map +0 -1
  116. package/dist/utilities/getExportFieldFunctions.spec.js +0 -50
  117. package/dist/utilities/getExportFieldFunctions.spec.js.map +0 -1
  118. package/dist/utilities/getImportFieldFunctions.spec.js +0 -167
  119. package/dist/utilities/getImportFieldFunctions.spec.js.map +0 -1
  120. package/dist/utilities/getSchemaColumns.spec.js +0 -157
  121. package/dist/utilities/getSchemaColumns.spec.js.map +0 -1
  122. package/dist/utilities/parseCSV.spec.js +0 -195
  123. package/dist/utilities/parseCSV.spec.js.map +0 -1
  124. package/dist/utilities/processRichTextField.spec.js +0 -308
  125. package/dist/utilities/processRichTextField.spec.js.map +0 -1
  126. package/dist/utilities/siblingDoc.spec.js +0 -278
  127. package/dist/utilities/siblingDoc.spec.js.map +0 -1
  128. package/dist/utilities/unflattenObject.spec.js +0 -819
  129. package/dist/utilities/unflattenObject.spec.js.map +0 -1
  130. /package/dist/components/Page/{index.scss → index.css} +0 -0
@@ -1,151 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { fieldToRegex } from './fieldToRegex.js';
3
- describe('fieldToRegex', ()=>{
4
- describe('simple field paths', ()=>{
5
- it('should match exact field name', ()=>{
6
- const regex = fieldToRegex('title');
7
- expect(regex.test('title')).toBe(true);
8
- });
9
- it('should match field with array index', ()=>{
10
- const regex = fieldToRegex('items');
11
- expect(regex.test('items_0')).toBe(true);
12
- expect(regex.test('items_1')).toBe(true);
13
- expect(regex.test('items_99')).toBe(true);
14
- });
15
- it('should match nested fields under array items', ()=>{
16
- const regex = fieldToRegex('items');
17
- expect(regex.test('items_0_title')).toBe(true);
18
- expect(regex.test('items_1_description')).toBe(true);
19
- });
20
- it('should not match unrelated fields', ()=>{
21
- const regex = fieldToRegex('title');
22
- expect(regex.test('otherField')).toBe(false);
23
- expect(regex.test('titleExtra')).toBe(false);
24
- });
25
- });
26
- describe('dotted field paths', ()=>{
27
- it('should match nested field path without indices', ()=>{
28
- const regex = fieldToRegex('blocks.content');
29
- expect(regex.test('blocks_content')).toBe(true);
30
- });
31
- it('should match nested field path with array index in middle', ()=>{
32
- const regex = fieldToRegex('blocks.content');
33
- expect(regex.test('blocks_0_content')).toBe(true);
34
- expect(regex.test('blocks_1_content')).toBe(true);
35
- expect(regex.test('blocks_42_content')).toBe(true);
36
- });
37
- it('should match deeply nested paths with multiple indices', ()=>{
38
- const regex = fieldToRegex('blocks.content.items');
39
- expect(regex.test('blocks_0_content_items')).toBe(true);
40
- expect(regex.test('blocks_0_content_0_items')).toBe(true);
41
- expect(regex.test('blocks_1_content_2_items')).toBe(true);
42
- });
43
- it('should match nested fields under the matched path', ()=>{
44
- const regex = fieldToRegex('blocks.content');
45
- expect(regex.test('blocks_0_content_title')).toBe(true);
46
- expect(regex.test('blocks_0_content_richText')).toBe(true);
47
- expect(regex.test('blocks_1_content_0_value')).toBe(true);
48
- });
49
- });
50
- describe('complex nested structures', ()=>{
51
- it('should handle three-level nesting', ()=>{
52
- const regex = fieldToRegex('layout.sections.items');
53
- expect(regex.test('layout_sections_items')).toBe(true);
54
- expect(regex.test('layout_0_sections_items')).toBe(true);
55
- expect(regex.test('layout_0_sections_1_items')).toBe(true);
56
- expect(regex.test('layout_0_sections_1_items_2')).toBe(true);
57
- expect(regex.test('layout_0_sections_1_items_2_title')).toBe(true);
58
- });
59
- it('should not match partial field name matches', ()=>{
60
- const regex = fieldToRegex('block');
61
- expect(regex.test('blocks')).toBe(false);
62
- expect(regex.test('blocks_0_content')).toBe(false);
63
- expect(regex.test('blockType')).toBe(false);
64
- });
65
- it('should handle field names that look like array indices', ()=>{
66
- const regex = fieldToRegex('data.row');
67
- expect(regex.test('data_row')).toBe(true);
68
- expect(regex.test('data_0_row')).toBe(true);
69
- expect(regex.test('data_0_row_1')).toBe(true);
70
- });
71
- });
72
- describe('edge cases', ()=>{
73
- it('should handle single character field names', ()=>{
74
- const regex = fieldToRegex('a.b.c');
75
- expect(regex.test('a_b_c')).toBe(true);
76
- expect(regex.test('a_0_b_c')).toBe(true);
77
- expect(regex.test('a_0_b_1_c')).toBe(true);
78
- });
79
- it('should handle field names with numbers', ()=>{
80
- const regex = fieldToRegex('field1.field2');
81
- expect(regex.test('field1_field2')).toBe(true);
82
- expect(regex.test('field1_0_field2')).toBe(true);
83
- });
84
- it('should match field at end of key exactly', ()=>{
85
- const regex = fieldToRegex('meta.title');
86
- expect(regex.test('meta_title')).toBe(true);
87
- expect(regex.test('meta_0_title')).toBe(true);
88
- // Should not match if title is a prefix of another word
89
- expect(regex.test('meta_titleExtra')).toBe(false);
90
- });
91
- it('should handle field names starting with underscore', ()=>{
92
- const regex = fieldToRegex('_status');
93
- expect(regex.test('_status')).toBe(true);
94
- expect(regex.test('_status_0')).toBe(true);
95
- expect(regex.test('_statusExtra')).toBe(false);
96
- });
97
- it('should handle field names containing underscores', ()=>{
98
- const regex = fieldToRegex('my_field');
99
- expect(regex.test('my_field')).toBe(true);
100
- expect(regex.test('my_field_0')).toBe(true);
101
- expect(regex.test('my_fieldExtra')).toBe(false);
102
- });
103
- it('should handle nested paths with underscore fields', ()=>{
104
- const regex = fieldToRegex('group._status');
105
- expect(regex.test('group__status')).toBe(true);
106
- expect(regex.test('group_0__status')).toBe(true);
107
- });
108
- });
109
- describe('date fields with timezone companions', ()=>{
110
- it('should match date field and its _tz companion', ()=>{
111
- const regex = fieldToRegex('publishedDate');
112
- expect(regex.test('publishedDate')).toBe(true);
113
- expect(regex.test('publishedDate_tz')).toBe(true);
114
- });
115
- it('should match nested date field and its _tz companion', ()=>{
116
- const regex = fieldToRegex('meta.publishedDate');
117
- expect(regex.test('meta_publishedDate')).toBe(true);
118
- expect(regex.test('meta_publishedDate_tz')).toBe(true);
119
- expect(regex.test('meta_0_publishedDate')).toBe(true);
120
- expect(regex.test('meta_0_publishedDate_tz')).toBe(true);
121
- });
122
- it('should match date fields in arrays with _tz companions', ()=>{
123
- const regex = fieldToRegex('events.startDate');
124
- expect(regex.test('events_0_startDate')).toBe(true);
125
- expect(regex.test('events_0_startDate_tz')).toBe(true);
126
- expect(regex.test('events_1_startDate')).toBe(true);
127
- expect(regex.test('events_1_startDate_tz')).toBe(true);
128
- });
129
- it('should match deeply nested date fields with _tz companions', ()=>{
130
- const regex = fieldToRegex('blocks.content.scheduledAt');
131
- expect(regex.test('blocks_0_content_scheduledAt')).toBe(true);
132
- expect(regex.test('blocks_0_content_scheduledAt_tz')).toBe(true);
133
- expect(regex.test('blocks_0_content_0_scheduledAt')).toBe(true);
134
- expect(regex.test('blocks_0_content_0_scheduledAt_tz')).toBe(true);
135
- });
136
- it('should not match _tz suffix on unrelated fields', ()=>{
137
- const regex = fieldToRegex('title');
138
- expect(regex.test('title')).toBe(true);
139
- expect(regex.test('title_tz')).toBe(true); // _tz is treated as a nested field suffix
140
- expect(regex.test('publishedDate_tz')).toBe(false);
141
- });
142
- it('should handle date fields with underscores in name', ()=>{
143
- const regex = fieldToRegex('start_date');
144
- expect(regex.test('start_date')).toBe(true);
145
- expect(regex.test('start_date_tz')).toBe(true);
146
- expect(regex.test('start_date_0')).toBe(true);
147
- });
148
- });
149
- });
150
-
151
- //# sourceMappingURL=fieldToRegex.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utilities/fieldToRegex.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { fieldToRegex } from './fieldToRegex.js'\n\ndescribe('fieldToRegex', () => {\n describe('simple field paths', () => {\n it('should match exact field name', () => {\n const regex = fieldToRegex('title')\n\n expect(regex.test('title')).toBe(true)\n })\n\n it('should match field with array index', () => {\n const regex = fieldToRegex('items')\n\n expect(regex.test('items_0')).toBe(true)\n expect(regex.test('items_1')).toBe(true)\n expect(regex.test('items_99')).toBe(true)\n })\n\n it('should match nested fields under array items', () => {\n const regex = fieldToRegex('items')\n\n expect(regex.test('items_0_title')).toBe(true)\n expect(regex.test('items_1_description')).toBe(true)\n })\n\n it('should not match unrelated fields', () => {\n const regex = fieldToRegex('title')\n\n expect(regex.test('otherField')).toBe(false)\n expect(regex.test('titleExtra')).toBe(false)\n })\n })\n\n describe('dotted field paths', () => {\n it('should match nested field path without indices', () => {\n const regex = fieldToRegex('blocks.content')\n\n expect(regex.test('blocks_content')).toBe(true)\n })\n\n it('should match nested field path with array index in middle', () => {\n const regex = fieldToRegex('blocks.content')\n\n expect(regex.test('blocks_0_content')).toBe(true)\n expect(regex.test('blocks_1_content')).toBe(true)\n expect(regex.test('blocks_42_content')).toBe(true)\n })\n\n it('should match deeply nested paths with multiple indices', () => {\n const regex = fieldToRegex('blocks.content.items')\n\n expect(regex.test('blocks_0_content_items')).toBe(true)\n expect(regex.test('blocks_0_content_0_items')).toBe(true)\n expect(regex.test('blocks_1_content_2_items')).toBe(true)\n })\n\n it('should match nested fields under the matched path', () => {\n const regex = fieldToRegex('blocks.content')\n\n expect(regex.test('blocks_0_content_title')).toBe(true)\n expect(regex.test('blocks_0_content_richText')).toBe(true)\n expect(regex.test('blocks_1_content_0_value')).toBe(true)\n })\n })\n\n describe('complex nested structures', () => {\n it('should handle three-level nesting', () => {\n const regex = fieldToRegex('layout.sections.items')\n\n expect(regex.test('layout_sections_items')).toBe(true)\n expect(regex.test('layout_0_sections_items')).toBe(true)\n expect(regex.test('layout_0_sections_1_items')).toBe(true)\n expect(regex.test('layout_0_sections_1_items_2')).toBe(true)\n expect(regex.test('layout_0_sections_1_items_2_title')).toBe(true)\n })\n\n it('should not match partial field name matches', () => {\n const regex = fieldToRegex('block')\n\n expect(regex.test('blocks')).toBe(false)\n expect(regex.test('blocks_0_content')).toBe(false)\n expect(regex.test('blockType')).toBe(false)\n })\n\n it('should handle field names that look like array indices', () => {\n const regex = fieldToRegex('data.row')\n\n expect(regex.test('data_row')).toBe(true)\n expect(regex.test('data_0_row')).toBe(true)\n expect(regex.test('data_0_row_1')).toBe(true)\n })\n })\n\n describe('edge cases', () => {\n it('should handle single character field names', () => {\n const regex = fieldToRegex('a.b.c')\n\n expect(regex.test('a_b_c')).toBe(true)\n expect(regex.test('a_0_b_c')).toBe(true)\n expect(regex.test('a_0_b_1_c')).toBe(true)\n })\n\n it('should handle field names with numbers', () => {\n const regex = fieldToRegex('field1.field2')\n\n expect(regex.test('field1_field2')).toBe(true)\n expect(regex.test('field1_0_field2')).toBe(true)\n })\n\n it('should match field at end of key exactly', () => {\n const regex = fieldToRegex('meta.title')\n\n expect(regex.test('meta_title')).toBe(true)\n expect(regex.test('meta_0_title')).toBe(true)\n // Should not match if title is a prefix of another word\n expect(regex.test('meta_titleExtra')).toBe(false)\n })\n\n it('should handle field names starting with underscore', () => {\n const regex = fieldToRegex('_status')\n\n expect(regex.test('_status')).toBe(true)\n expect(regex.test('_status_0')).toBe(true)\n expect(regex.test('_statusExtra')).toBe(false)\n })\n\n it('should handle field names containing underscores', () => {\n const regex = fieldToRegex('my_field')\n\n expect(regex.test('my_field')).toBe(true)\n expect(regex.test('my_field_0')).toBe(true)\n expect(regex.test('my_fieldExtra')).toBe(false)\n })\n\n it('should handle nested paths with underscore fields', () => {\n const regex = fieldToRegex('group._status')\n\n expect(regex.test('group__status')).toBe(true)\n expect(regex.test('group_0__status')).toBe(true)\n })\n })\n\n describe('date fields with timezone companions', () => {\n it('should match date field and its _tz companion', () => {\n const regex = fieldToRegex('publishedDate')\n\n expect(regex.test('publishedDate')).toBe(true)\n expect(regex.test('publishedDate_tz')).toBe(true)\n })\n\n it('should match nested date field and its _tz companion', () => {\n const regex = fieldToRegex('meta.publishedDate')\n\n expect(regex.test('meta_publishedDate')).toBe(true)\n expect(regex.test('meta_publishedDate_tz')).toBe(true)\n expect(regex.test('meta_0_publishedDate')).toBe(true)\n expect(regex.test('meta_0_publishedDate_tz')).toBe(true)\n })\n\n it('should match date fields in arrays with _tz companions', () => {\n const regex = fieldToRegex('events.startDate')\n\n expect(regex.test('events_0_startDate')).toBe(true)\n expect(regex.test('events_0_startDate_tz')).toBe(true)\n expect(regex.test('events_1_startDate')).toBe(true)\n expect(regex.test('events_1_startDate_tz')).toBe(true)\n })\n\n it('should match deeply nested date fields with _tz companions', () => {\n const regex = fieldToRegex('blocks.content.scheduledAt')\n\n expect(regex.test('blocks_0_content_scheduledAt')).toBe(true)\n expect(regex.test('blocks_0_content_scheduledAt_tz')).toBe(true)\n expect(regex.test('blocks_0_content_0_scheduledAt')).toBe(true)\n expect(regex.test('blocks_0_content_0_scheduledAt_tz')).toBe(true)\n })\n\n it('should not match _tz suffix on unrelated fields', () => {\n const regex = fieldToRegex('title')\n\n expect(regex.test('title')).toBe(true)\n expect(regex.test('title_tz')).toBe(true) // _tz is treated as a nested field suffix\n expect(regex.test('publishedDate_tz')).toBe(false)\n })\n\n it('should handle date fields with underscores in name', () => {\n const regex = fieldToRegex('start_date')\n\n expect(regex.test('start_date')).toBe(true)\n expect(regex.test('start_date_tz')).toBe(true)\n expect(regex.test('start_date_0')).toBe(true)\n })\n })\n})\n"],"names":["describe","expect","it","fieldToRegex","regex","test","toBe"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,YAAY,QAAQ,oBAAmB;AAEhDH,SAAS,gBAAgB;IACvBA,SAAS,sBAAsB;QAC7BE,GAAG,iCAAiC;YAClC,MAAME,QAAQD,aAAa;YAE3BF,OAAOG,MAAMC,IAAI,CAAC,UAAUC,IAAI,CAAC;QACnC;QAEAJ,GAAG,uCAAuC;YACxC,MAAME,QAAQD,aAAa;YAE3BF,OAAOG,MAAMC,IAAI,CAAC,YAAYC,IAAI,CAAC;Y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;YAChDL,OAAOG,MAAMC,IAAI,CAAC,4BAA4BC,IAAI,CAAC;QACrD;QAEAJ,GAAG,0DAA0D;YAC3D,MAAME,QAAQD,aAAa;YAE3BF,OAAOG,MAAMC,IAAI,CAAC,uBAAuBC,IAAI,CAAC;YAC9CL,OAAOG,MAAMC,IAAI,CAAC,0BAA0BC,IAAI,CAAC;YACjDL,OAAOG,MAAMC,IAAI,CAAC,uBAAuBC,IAAI,CAAC;YAC9CL,OAAOG,MAAMC,IAAI,CAAC,0BAA0BC,IAAI,CAAC;QACnD;QAEAJ,GAAG,8DAA8D;YAC/D,MAAME,QAAQD,aAAa;YAE3BF,OAAOG,MAAMC,IAAI,CAAC,iCAAiCC,IAAI,CAAC;YACxDL,OAAOG,MAAMC,IAAI,CAAC,oCAAoCC,IAAI,CAAC;YAC3DL,OAAOG,MAAMC,IAAI,CAAC,mCAAmCC,IAAI,CAAC;YAC1DL,OAAOG,MAAMC,IAAI,CAAC,sCAAsCC,IAAI,CAAC;QAC/D;QAEAJ,GAAG,mDAAmD;YACpD,MAAME,QAAQD,aAAa;YAE3BF,OAAOG,MAAMC,IAAI,CAAC,UAAUC,IAAI,CAAC;YACjCL,OAAOG,MAAMC,IAAI,CAAC,aAAaC,IAAI,CAAC,OAAM,0CAA0C;YACpFL,OAAOG,MAAMC,IAAI,CAAC,qBAAqBC,IAAI,CAAC;QAC9C;QAEAJ,GAAG,sDAAsD;YACvD,MAAME,QAAQD,aAAa;YAE3BF,OAAOG,MAAMC,IAAI,CAAC,eAAeC,IAAI,CAAC;YACtCL,OAAOG,MAAMC,IAAI,CAAC,kBAAkBC,IAAI,CAAC;YACzCL,OAAOG,MAAMC,IAAI,CAAC,iBAAiBC,IAAI,CAAC;QAC1C;IACF;AACF"}
@@ -1,204 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { filterToSelectedFields } from './getSchemaColumns.js';
3
- describe('filterToSelectedFields', ()=>{
4
- describe('fields with their own column', ()=>{
5
- it('should include only the exact column for a date with timezones field', ()=>{
6
- const columns = [
7
- 'id',
8
- 'title',
9
- 'dateWithTimezone',
10
- 'dateWithTimezone_tz',
11
- 'createdAt'
12
- ];
13
- const result = filterToSelectedFields(columns, [
14
- 'title'
15
- ]);
16
- expect(result).toEqual([
17
- 'title'
18
- ]);
19
- });
20
- it('should not include timezone companion when only date field is selected', ()=>{
21
- const columns = [
22
- 'id',
23
- 'dateWithTimezone',
24
- 'dateWithTimezone_tz',
25
- 'createdAt'
26
- ];
27
- const result = filterToSelectedFields(columns, [
28
- 'dateWithTimezone'
29
- ]);
30
- expect(result).toEqual([
31
- 'dateWithTimezone'
32
- ]);
33
- expect(result).not.toContain('dateWithTimezone_tz');
34
- });
35
- it('should include both date and timezone companion when both are explicitly selected', ()=>{
36
- const columns = [
37
- 'id',
38
- 'dateWithTimezone',
39
- 'dateWithTimezone_tz',
40
- 'createdAt'
41
- ];
42
- const result = filterToSelectedFields(columns, [
43
- 'dateWithTimezone',
44
- 'dateWithTimezone_tz'
45
- ]);
46
- expect(result).toEqual([
47
- 'dateWithTimezone',
48
- 'dateWithTimezone_tz'
49
- ]);
50
- });
51
- it('should preserve user-specified ordering', ()=>{
52
- const columns = [
53
- 'id',
54
- 'title',
55
- 'email',
56
- 'createdAt'
57
- ];
58
- const result = filterToSelectedFields(columns, [
59
- 'email',
60
- 'title',
61
- 'id'
62
- ]);
63
- expect(result).toEqual([
64
- 'email',
65
- 'title',
66
- 'id'
67
- ]);
68
- });
69
- });
70
- describe('fields without their own column (groups, arrays, blocks)', ()=>{
71
- it('should expand a group to include its nested fields', ()=>{
72
- const columns = [
73
- 'id',
74
- 'group_name',
75
- 'group_age',
76
- 'createdAt'
77
- ];
78
- const result = filterToSelectedFields(columns, [
79
- 'group'
80
- ]);
81
- expect(result).toEqual([
82
- 'group_name',
83
- 'group_age'
84
- ]);
85
- });
86
- it('should expand an array to include its nested fields', ()=>{
87
- const columns = [
88
- 'id',
89
- 'items_0_title',
90
- 'items_0_value',
91
- 'createdAt'
92
- ];
93
- const result = filterToSelectedFields(columns, [
94
- 'items'
95
- ]);
96
- expect(result).toEqual([
97
- 'items_0_title',
98
- 'items_0_value'
99
- ]);
100
- });
101
- it('should expand blocks to include their nested fields', ()=>{
102
- const columns = [
103
- 'id',
104
- 'blocks_0_hero_blockType',
105
- 'blocks_0_hero_title',
106
- 'createdAt'
107
- ];
108
- const result = filterToSelectedFields(columns, [
109
- 'blocks'
110
- ]);
111
- expect(result).toEqual([
112
- 'blocks_0_hero_blockType',
113
- 'blocks_0_hero_title'
114
- ]);
115
- });
116
- it('should expand a hasMany select to include indexed columns', ()=>{
117
- const columns = [
118
- 'id',
119
- 'colors_0',
120
- 'createdAt'
121
- ];
122
- const result = filterToSelectedFields(columns, [
123
- 'colors'
124
- ]);
125
- expect(result).toEqual([
126
- 'colors_0'
127
- ]);
128
- });
129
- it('should expand a polymorphic relationship to include relationTo and id columns', ()=>{
130
- const columns = [
131
- 'id',
132
- 'relField_relationTo',
133
- 'relField_id',
134
- 'createdAt'
135
- ];
136
- const result = filterToSelectedFields(columns, [
137
- 'relField'
138
- ]);
139
- expect(result).toEqual([
140
- 'relField_relationTo',
141
- 'relField_id'
142
- ]);
143
- });
144
- });
145
- describe('nested field selections with dot notation', ()=>{
146
- it('should resolve a specific nested field within a group', ()=>{
147
- const columns = [
148
- 'id',
149
- 'group_name',
150
- 'group_age',
151
- 'createdAt'
152
- ];
153
- const result = filterToSelectedFields(columns, [
154
- 'group.name'
155
- ]);
156
- expect(result).toEqual([
157
- 'group_name'
158
- ]);
159
- expect(result).not.toContain('group_age');
160
- });
161
- });
162
- describe('mixed selections', ()=>{
163
- it('should handle groups and date fields together without sibling leakage', ()=>{
164
- const columns = [
165
- 'id',
166
- 'title',
167
- 'group_name',
168
- 'group_age',
169
- 'dateWithTimezone',
170
- 'dateWithTimezone_tz',
171
- 'createdAt'
172
- ];
173
- const result = filterToSelectedFields(columns, [
174
- 'id',
175
- 'group',
176
- 'dateWithTimezone'
177
- ]);
178
- expect(result).toEqual([
179
- 'id',
180
- 'group_name',
181
- 'group_age',
182
- 'dateWithTimezone'
183
- ]);
184
- expect(result).not.toContain('dateWithTimezone_tz');
185
- });
186
- it('should not produce duplicates when a group and its nested field are both selected', ()=>{
187
- const columns = [
188
- 'id',
189
- 'group_name',
190
- 'group_age'
191
- ];
192
- const result = filterToSelectedFields(columns, [
193
- 'group',
194
- 'group.name'
195
- ]);
196
- const uniqueResult = [
197
- ...new Set(result)
198
- ];
199
- expect(result).toEqual(uniqueResult);
200
- });
201
- });
202
- });
203
-
204
- //# sourceMappingURL=filterToSelectedFields.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utilities/filterToSelectedFields.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { filterToSelectedFields } from './getSchemaColumns.js'\n\ndescribe('filterToSelectedFields', () => {\n describe('fields with their own column', () => {\n it('should include only the exact column for a date with timezones field', () => {\n const columns = ['id', 'title', 'dateWithTimezone', 'dateWithTimezone_tz', 'createdAt']\n\n const result = filterToSelectedFields(columns, ['title'])\n\n expect(result).toEqual(['title'])\n })\n\n it('should not include timezone companion when only date field is selected', () => {\n const columns = ['id', 'dateWithTimezone', 'dateWithTimezone_tz', 'createdAt']\n\n const result = filterToSelectedFields(columns, ['dateWithTimezone'])\n\n expect(result).toEqual(['dateWithTimezone'])\n expect(result).not.toContain('dateWithTimezone_tz')\n })\n\n it('should include both date and timezone companion when both are explicitly selected', () => {\n const columns = ['id', 'dateWithTimezone', 'dateWithTimezone_tz', 'createdAt']\n\n const result = filterToSelectedFields(columns, ['dateWithTimezone', 'dateWithTimezone_tz'])\n\n expect(result).toEqual(['dateWithTimezone', 'dateWithTimezone_tz'])\n })\n\n it('should preserve user-specified ordering', () => {\n const columns = ['id', 'title', 'email', 'createdAt']\n\n const result = filterToSelectedFields(columns, ['email', 'title', 'id'])\n\n expect(result).toEqual(['email', 'title', 'id'])\n })\n })\n\n describe('fields without their own column (groups, arrays, blocks)', () => {\n it('should expand a group to include its nested fields', () => {\n const columns = ['id', 'group_name', 'group_age', 'createdAt']\n\n const result = filterToSelectedFields(columns, ['group'])\n\n expect(result).toEqual(['group_name', 'group_age'])\n })\n\n it('should expand an array to include its nested fields', () => {\n const columns = ['id', 'items_0_title', 'items_0_value', 'createdAt']\n\n const result = filterToSelectedFields(columns, ['items'])\n\n expect(result).toEqual(['items_0_title', 'items_0_value'])\n })\n\n it('should expand blocks to include their nested fields', () => {\n const columns = ['id', 'blocks_0_hero_blockType', 'blocks_0_hero_title', 'createdAt']\n\n const result = filterToSelectedFields(columns, ['blocks'])\n\n expect(result).toEqual(['blocks_0_hero_blockType', 'blocks_0_hero_title'])\n })\n\n it('should expand a hasMany select to include indexed columns', () => {\n const columns = ['id', 'colors_0', 'createdAt']\n\n const result = filterToSelectedFields(columns, ['colors'])\n\n expect(result).toEqual(['colors_0'])\n })\n\n it('should expand a polymorphic relationship to include relationTo and id columns', () => {\n const columns = ['id', 'relField_relationTo', 'relField_id', 'createdAt']\n\n const result = filterToSelectedFields(columns, ['relField'])\n\n expect(result).toEqual(['relField_relationTo', 'relField_id'])\n })\n })\n\n describe('nested field selections with dot notation', () => {\n it('should resolve a specific nested field within a group', () => {\n const columns = ['id', 'group_name', 'group_age', 'createdAt']\n\n const result = filterToSelectedFields(columns, ['group.name'])\n\n expect(result).toEqual(['group_name'])\n expect(result).not.toContain('group_age')\n })\n })\n\n describe('mixed selections', () => {\n it('should handle groups and date fields together without sibling leakage', () => {\n const columns = [\n 'id',\n 'title',\n 'group_name',\n 'group_age',\n 'dateWithTimezone',\n 'dateWithTimezone_tz',\n 'createdAt',\n ]\n\n const result = filterToSelectedFields(columns, ['id', 'group', 'dateWithTimezone'])\n\n expect(result).toEqual(['id', 'group_name', 'group_age', 'dateWithTimezone'])\n expect(result).not.toContain('dateWithTimezone_tz')\n })\n\n it('should not produce duplicates when a group and its nested field are both selected', () => {\n const columns = ['id', 'group_name', 'group_age']\n\n const result = filterToSelectedFields(columns, ['group', 'group.name'])\n\n const uniqueResult = [...new Set(result)]\n\n expect(result).toEqual(uniqueResult)\n })\n })\n})\n"],"names":["describe","expect","it","filterToSelectedFields","columns","result","toEqual","not","toContain","uniqueResult","Set"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,sBAAsB,QAAQ,wBAAuB;AAE9DH,SAAS,0BAA0B;IACjCA,SAAS,gCAAgC;QACvCE,GAAG,wEAAwE;YACzE,MAAME,UAAU;gBAAC;gBAAM;gBAAS;gBAAoB;gBAAuB;aAAY;YAEvF,MAAMC,SAASF,uBAAuBC,SAAS;gBAAC;aAAQ;YAExDH,OAAOI,QAAQC,OAAO,CAAC;gBAAC;aAAQ;QAClC;QAEAJ,GAAG,0EAA0E;YAC3E,MAAME,UAAU;gBAAC;gBAAM;gBAAoB;gBAAuB;aAAY;YAE9E,MAAMC,SAASF,uBAAuBC,SAAS;gBAAC;aAAmB;YAEnEH,OAAOI,QAAQC,OAAO,CAAC;gBAAC;aAAmB;YAC3CL,OAAOI,QAAQE,GAAG,CAACC,SAAS,CAAC;QAC/B;QAEAN,GAAG,qFAAqF;YACtF,MAAME,UAAU;gBAAC;gBAAM;gBAAoB;gBAAuB;aAAY;YAE9E,MAAMC,SAASF,uBAAuBC,SAAS;gBAAC;gBAAoB;aAAsB;YAE1FH,OAAOI,QAAQC,OAAO,CAAC;gBAAC;gBAAoB;aAAsB;QACpE;QAEAJ,GAAG,2CAA2C;YAC5C,MAAME,UAAU;gBAAC;gBAAM;gBAAS;gBAAS;aAAY;YAErD,MAAMC,SAASF,uBAAuBC,SAAS;gBAAC;gBAAS;gBAAS;aAAK;YAEvEH,OAAOI,QAAQC,OAAO,CAAC;gBAAC;gBAAS;gBAAS;aAAK;QACjD;IACF;IAEAN,SAAS,4DAA4D;QACnEE,GAAG,sDAAsD;YACvD,MAAME,UAAU;gBAAC;gBAAM;gBAAc;gBAAa;aAAY;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AMC,SAASF,uBAAuBC,SAAS;gBAAC;gBAAM;gBAAS;aAAmB;YAElFH,OAAOI,QAAQC,OAAO,CAAC;gBAAC;gBAAM;gBAAc;gBAAa;aAAmB;YAC5EL,OAAOI,QAAQE,GAAG,CAACC,SAAS,CAAC;QAC/B;QAEAN,GAAG,qFAAqF;YACtF,MAAME,UAAU;gBAAC;gBAAM;gBAAc;aAAY;YAEjD,MAAMC,SAASF,uBAAuBC,SAAS;gBAAC;gBAAS;aAAa;YAEtE,MAAMK,eAAe;mBAAI,IAAIC,IAAIL;aAAQ;YAEzCJ,OAAOI,QAAQC,OAAO,CAACG;QACzB;IACF;AACF"}
@@ -1,158 +0,0 @@
1
- import { describe, expect, it, vi } from 'vitest';
2
- import { flattenObject } from './flattenObject.js';
3
- const mockReq = {
4
- payload: {
5
- logger: {
6
- error: vi.fn()
7
- }
8
- }
9
- };
10
- describe('flattenObject parent + child traversal', ()=>{
11
- it('should run a parent group hook and still apply child field hooks against the transformed value', ()=>{
12
- const exportFieldHooks = {
13
- meta: {
14
- type: 'beforeExport',
15
- fn: ({ value })=>{
16
- const obj = value ?? {};
17
- return {
18
- ...obj,
19
- slug: `${obj.slug ?? ''}-from-parent`
20
- };
21
- }
22
- },
23
- meta_slug: {
24
- type: 'beforeExport',
25
- fn: ({ value })=>`${value}-from-child`
26
- }
27
- };
28
- const row = flattenObject({
29
- data: {
30
- meta: {
31
- slug: 'raw'
32
- }
33
- },
34
- exportFieldHooks,
35
- format: 'csv',
36
- req: mockReq
37
- });
38
- expect(row.meta_slug).toBe('raw-from-parent-from-child');
39
- });
40
- it('should still recurse into children when the parent group hook returns undefined', ()=>{
41
- const childCalls = [];
42
- const exportFieldHooks = {
43
- meta: {
44
- type: 'beforeExport',
45
- fn: ()=>undefined
46
- },
47
- meta_slug: {
48
- type: 'beforeExport',
49
- fn: ({ value })=>{
50
- childCalls.push(value);
51
- return `${value}-from-child`;
52
- }
53
- }
54
- };
55
- const row = flattenObject({
56
- data: {
57
- meta: {
58
- slug: 'raw'
59
- }
60
- },
61
- exportFieldHooks,
62
- format: 'csv',
63
- req: mockReq
64
- });
65
- expect(childCalls).toEqual([
66
- 'raw'
67
- ]);
68
- expect(row.meta_slug).toBe('raw-from-child');
69
- });
70
- it('should not recurse into children when the parent hook returns a primitive', ()=>{
71
- const childFn = vi.fn(({ value })=>`${value}-from-child`);
72
- const exportFieldHooks = {
73
- meta: {
74
- type: 'beforeExport',
75
- fn: ()=>'serialized'
76
- },
77
- meta_slug: {
78
- type: 'beforeExport',
79
- fn: childFn
80
- }
81
- };
82
- const row = flattenObject({
83
- data: {
84
- meta: {
85
- slug: 'raw'
86
- }
87
- },
88
- exportFieldHooks,
89
- format: 'csv',
90
- req: mockReq
91
- });
92
- expect(row.meta).toBe('serialized');
93
- expect(row.meta_slug).toBeUndefined();
94
- expect(childFn).not.toHaveBeenCalled();
95
- });
96
- it('should fall back to default array flattening when an undefined-returning hook did not write any keys, even if a sibling key with a matching prefix exists', ()=>{
97
- const exportFieldHooks = {
98
- tag: {
99
- type: 'beforeExport',
100
- fn: ()=>undefined
101
- }
102
- };
103
- const row = flattenObject({
104
- data: {
105
- tag_meta: 'sibling-set-first',
106
- tag: [
107
- 'a',
108
- 'b'
109
- ]
110
- },
111
- exportFieldHooks,
112
- format: 'csv',
113
- req: mockReq
114
- });
115
- expect(row.tag_meta).toBe('sibling-set-first');
116
- expect(row.tag_0).toBe('a');
117
- expect(row.tag_1).toBe('b');
118
- });
119
- it('should run a parent array hook then child hooks for each item', ()=>{
120
- const exportFieldHooks = {
121
- items: {
122
- type: 'beforeExport',
123
- fn: ({ value })=>{
124
- if (!Array.isArray(value)) {
125
- return value;
126
- }
127
- return value.map((item)=>({
128
- ...item,
129
- note: `${item.note ?? ''}-parent`
130
- }));
131
- }
132
- },
133
- items_note: {
134
- type: 'beforeExport',
135
- fn: ({ value })=>`${value}-child`
136
- }
137
- };
138
- const row = flattenObject({
139
- data: {
140
- items: [
141
- {
142
- note: 'a'
143
- },
144
- {
145
- note: 'b'
146
- }
147
- ]
148
- },
149
- exportFieldHooks,
150
- format: 'csv',
151
- req: mockReq
152
- });
153
- expect(row.items_0_note).toBe('a-parent-child');
154
- expect(row.items_1_note).toBe('b-parent-child');
155
- });
156
- });
157
-
158
- //# sourceMappingURL=flattenObject.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utilities/flattenObject.spec.ts"],"sourcesContent":["import { PayloadRequest } from 'payload'\n\nimport type { ExportFieldHookEntry } from '../types.js'\n\nimport { describe, expect, it, vi } from 'vitest'\n\nimport { flattenObject } from './flattenObject.js'\n\nconst mockReq = {\n payload: {\n logger: {\n error: vi.fn(),\n },\n },\n} as unknown as PayloadRequest\n\ndescribe('flattenObject parent + child traversal', () => {\n it('should run a parent group hook and still apply child field hooks against the transformed value', () => {\n const exportFieldHooks: Record<string, ExportFieldHookEntry> = {\n meta: {\n type: 'beforeExport',\n fn: ({ value }) => {\n const obj = (value ?? {}) as Record<string, unknown>\n return { ...obj, slug: `${obj.slug ?? ''}-from-parent` }\n },\n },\n meta_slug: {\n type: 'beforeExport',\n fn: ({ value }) => `${value}-from-child`,\n },\n }\n\n const row = flattenObject({\n data: { meta: { slug: 'raw' } },\n exportFieldHooks,\n format: 'csv',\n req: mockReq,\n })\n\n expect(row.meta_slug).toBe('raw-from-parent-from-child')\n })\n\n it('should still recurse into children when the parent group hook returns undefined', () => {\n const childCalls: unknown[] = []\n const exportFieldHooks: Record<string, ExportFieldHookEntry> = {\n meta: {\n type: 'beforeExport',\n fn: () => undefined,\n },\n meta_slug: {\n type: 'beforeExport',\n fn: ({ value }) => {\n childCalls.push(value)\n return `${value}-from-child`\n },\n },\n }\n\n const row = flattenObject({\n data: { meta: { slug: 'raw' } },\n exportFieldHooks,\n format: 'csv',\n req: mockReq,\n })\n\n expect(childCalls).toEqual(['raw'])\n expect(row.meta_slug).toBe('raw-from-child')\n })\n\n it('should not recurse into children when the parent hook returns a primitive', () => {\n const childFn = vi.fn(({ value }: { value: unknown }) => `${value}-from-child`)\n const exportFieldHooks: Record<string, ExportFieldHookEntry> = {\n meta: {\n type: 'beforeExport',\n fn: () => 'serialized',\n },\n meta_slug: {\n type: 'beforeExport',\n fn: childFn,\n },\n }\n\n const row = flattenObject({\n data: { meta: { slug: 'raw' } },\n exportFieldHooks,\n format: 'csv',\n req: mockReq,\n })\n\n expect(row.meta).toBe('serialized')\n expect(row.meta_slug).toBeUndefined()\n expect(childFn).not.toHaveBeenCalled()\n })\n\n it('should fall back to default array flattening when an undefined-returning hook did not write any keys, even if a sibling key with a matching prefix exists', () => {\n const exportFieldHooks: Record<string, ExportFieldHookEntry> = {\n tag: {\n type: 'beforeExport',\n fn: () => undefined,\n },\n }\n\n const row = flattenObject({\n data: { tag_meta: 'sibling-set-first', tag: ['a', 'b'] },\n exportFieldHooks,\n format: 'csv',\n req: mockReq,\n })\n\n expect(row.tag_meta).toBe('sibling-set-first')\n expect(row.tag_0).toBe('a')\n expect(row.tag_1).toBe('b')\n })\n\n it('should run a parent array hook then child hooks for each item', () => {\n const exportFieldHooks: Record<string, ExportFieldHookEntry> = {\n items: {\n type: 'beforeExport',\n fn: ({ value }) => {\n if (!Array.isArray(value)) {\n return value\n }\n return value.map((item) => ({\n ...(item as Record<string, unknown>),\n note: `${(item as Record<string, unknown>).note ?? ''}-parent`,\n }))\n },\n },\n items_note: {\n type: 'beforeExport',\n fn: ({ value }) => `${value}-child`,\n },\n }\n\n const row = flattenObject({\n data: { items: [{ note: 'a' }, { note: 'b' }] },\n exportFieldHooks,\n format: 'csv',\n req: mockReq,\n })\n\n expect(row.items_0_note).toBe('a-parent-child')\n expect(row.items_1_note).toBe('b-parent-child')\n })\n})\n"],"names":["describe","expect","it","vi","flattenObject","mockReq","payload","logger","error","fn","exportFieldHooks","meta","type","value","obj","slug","meta_slug","row","data","format","req","toBe","childCalls","undefined","push","toEqual","childFn","toBeUndefined","not","toHaveBeenCalled","tag","tag_meta","tag_0","tag_1","items","Array","isArray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AI;4BACRC,MAAM,GAAG,AAACD,KAAiCC,IAAI,IAAI,GAAG,OAAO,CAAC;wBAChE,CAAA;gBACF;YACF;YACAC,YAAY;gBACV5B,MAAM;gBACNH,IAAI,CAAC,EAAEI,KAAK,EAAE,GAAK,GAAGA,MAAM,MAAM,CAAC;YACrC;QACF;QAEA,MAAMI,MAAMb,cAAc;YACxBc,MAAM;gBAAEgB,OAAO;oBAAC;wBAAEK,MAAM;oBAAI;oBAAG;wBAAEA,MAAM;oBAAI;iBAAE;YAAC;YAC9C7B;YACAS,QAAQ;YACRC,KAAKf;QACP;QAEAJ,OAAOgB,IAAIwB,YAAY,EAAEpB,IAAI,CAAC;QAC9BpB,OAAOgB,IAAIyB,YAAY,EAAErB,IAAI,CAAC;IAChC;AACF"}
@@ -1,50 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { getExportFieldFunctions } from './getExportFieldFunctions.js';
3
- describe('getExportFieldFunctions registration', ()=>{
4
- it('should not collide bare-key entries when two same-named fields with built-in handlers exist in different positions', ()=>{
5
- const fields = [
6
- {
7
- name: 'groupA',
8
- type: 'group',
9
- flattenedFields: [
10
- {
11
- name: 'data',
12
- type: 'json'
13
- }
14
- ]
15
- },
16
- {
17
- name: 'groupB',
18
- type: 'group',
19
- flattenedFields: [
20
- {
21
- name: 'data',
22
- type: 'json'
23
- }
24
- ]
25
- }
26
- ];
27
- const result = getExportFieldFunctions({
28
- fields
29
- });
30
- // Both nested paths must be registered (not overwritten by collision)
31
- expect(result['groupA_data']).toBeDefined();
32
- expect(result['groupB_data']).toBeDefined();
33
- // No bare-key fallback should exist for nested fields — that's the bug
34
- expect(result['data']).toBeUndefined();
35
- });
36
- it('should still register a top-level field at its name', ()=>{
37
- const fields = [
38
- {
39
- name: 'topLevelData',
40
- type: 'json'
41
- }
42
- ];
43
- const result = getExportFieldFunctions({
44
- fields
45
- });
46
- expect(result['topLevelData']).toBeDefined();
47
- });
48
- });
49
-
50
- //# sourceMappingURL=getExportFieldFunctions.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utilities/getExportFieldFunctions.spec.ts"],"sourcesContent":["import { FlattenedField } from 'payload'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { getExportFieldFunctions } from './getExportFieldFunctions.js'\n\ndescribe('getExportFieldFunctions registration', () => {\n it('should not collide bare-key entries when two same-named fields with built-in handlers exist in different positions', () => {\n const fields: FlattenedField[] = [\n {\n name: 'groupA',\n type: 'group',\n flattenedFields: [{ name: 'data', type: 'json' } as FlattenedField],\n } as unknown as FlattenedField,\n {\n name: 'groupB',\n type: 'group',\n flattenedFields: [{ name: 'data', type: 'json' } as FlattenedField],\n } as unknown as FlattenedField,\n ]\n\n const result = getExportFieldFunctions({ fields })\n\n // Both nested paths must be registered (not overwritten by collision)\n expect(result['groupA_data']).toBeDefined()\n expect(result['groupB_data']).toBeDefined()\n\n // No bare-key fallback should exist for nested fields — that's the bug\n expect(result['data']).toBeUndefined()\n })\n\n it('should still register a top-level field at its name', () => {\n const fields: FlattenedField[] = [{ name: 'topLevelData', type: 'json' } as FlattenedField]\n\n const result = getExportFieldFunctions({ fields })\n\n expect(result['topLevelData']).toBeDefined()\n })\n})\n"],"names":["describe","expect","it","getExportFieldFunctions","fields","name","type","flattenedFields","result","toBeDefined","toBeUndefined"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,uBAAuB,QAAQ,+BAA8B;AAEtEH,SAAS,wCAAwC;IAC/CE,GAAG,sHAAsH;QACvH,MAAME,SAA2B;YAC/B;gBACEC,MAAM;gBACNC,MAAM;gBACNC,iBAAiB;oBAAC;wBAAEF,MAAM;wBAAQC,MAAM;oBAAO;iBAAoB;YACrE;YACA;gBACED,MAAM;gBACNC,MAAM;gBACNC,iBAAiB;oBAAC;wBAAEF,MAAM;wBAAQC,MAAM;oBAAO;iBAAoB;YACrE;SACD;QAED,MAAME,SAASL,wBAAwB;YAAEC;QAAO;QAEhD,sEAAsE;QACtEH,OAAOO,MAAM,CAAC,cAAc,EAAEC,WAAW;QACzCR,OAAOO,MAAM,CAAC,cAAc,EAAEC,WAAW;QAEzC,uEAAuE;QACvER,OAAOO,MAAM,CAAC,OAAO,EAAEE,aAAa;IACtC;IAEAR,GAAG,uDAAuD;QACxD,MAAME,SAA2B;YAAC;gBAAEC,MAAM;gBAAgBC,MAAM;YAAO;SAAoB;QAE3F,MAAME,SAASL,wBAAwB;YAAEC;QAAO;QAEhDH,OAAOO,MAAM,CAAC,eAAe,EAAEC,WAAW;IAC5C;AACF"}