@payloadcms/plugin-import-export 3.69.0-internal.2883df2 → 3.69.0-internal.35bf893

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 (322) hide show
  1. package/dist/components/CollectionField/index.d.ts.map +1 -1
  2. package/dist/components/CollectionField/index.js +8 -3
  3. package/dist/components/CollectionField/index.js.map +1 -1
  4. package/dist/components/ExportListMenuItem/index.d.ts +0 -1
  5. package/dist/components/ExportListMenuItem/index.d.ts.map +1 -1
  6. package/dist/components/ExportListMenuItem/index.js +0 -1
  7. package/dist/components/ExportListMenuItem/index.js.map +1 -1
  8. package/dist/components/ExportPreview/index.d.ts +4 -0
  9. package/dist/components/ExportPreview/index.d.ts.map +1 -0
  10. package/dist/components/ExportPreview/index.js +252 -0
  11. package/dist/components/ExportPreview/index.js.map +1 -0
  12. package/dist/components/ExportPreview/index.scss +36 -0
  13. package/dist/components/ImportCollectionField/index.d.ts +3 -0
  14. package/dist/components/ImportCollectionField/index.d.ts.map +1 -0
  15. package/dist/components/ImportCollectionField/index.js +17 -0
  16. package/dist/components/ImportCollectionField/index.js.map +1 -0
  17. package/dist/components/ImportListMenuItem/index.d.ts +6 -0
  18. package/dist/components/ImportListMenuItem/index.d.ts.map +1 -0
  19. package/dist/components/ImportListMenuItem/index.js +48 -0
  20. package/dist/components/ImportListMenuItem/index.js.map +1 -0
  21. package/dist/components/ImportPreview/index.d.ts +4 -0
  22. package/dist/components/ImportPreview/index.d.ts.map +1 -0
  23. package/dist/components/ImportPreview/index.js +624 -0
  24. package/dist/components/ImportPreview/index.js.map +1 -0
  25. package/dist/components/ImportPreview/index.scss +41 -0
  26. package/dist/components/ImportSaveButton/index.d.ts +2 -0
  27. package/dist/components/ImportSaveButton/index.d.ts.map +1 -0
  28. package/dist/components/ImportSaveButton/index.js +18 -0
  29. package/dist/components/ImportSaveButton/index.js.map +1 -0
  30. package/dist/components/Page/index.scss +4 -2
  31. package/dist/constants.d.ts +21 -0
  32. package/dist/constants.d.ts.map +1 -0
  33. package/dist/constants.js +21 -0
  34. package/dist/constants.js.map +1 -0
  35. package/dist/export/batchProcessor.d.ts +107 -0
  36. package/dist/export/batchProcessor.d.ts.map +1 -0
  37. package/dist/export/batchProcessor.js +187 -0
  38. package/dist/export/batchProcessor.js.map +1 -0
  39. package/dist/export/createExport.d.ts +9 -4
  40. package/dist/export/createExport.d.ts.map +1 -1
  41. package/dist/export/createExport.js +163 -111
  42. package/dist/export/createExport.js.map +1 -1
  43. package/dist/export/getCreateExportCollectionTask.d.ts +1 -2
  44. package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
  45. package/dist/export/getCreateExportCollectionTask.js +10 -18
  46. package/dist/export/getCreateExportCollectionTask.js.map +1 -1
  47. package/dist/export/getExportCollection.d.ts +8 -0
  48. package/dist/export/getExportCollection.d.ts.map +1 -0
  49. package/dist/export/getExportCollection.js +100 -0
  50. package/dist/export/getExportCollection.js.map +1 -0
  51. package/dist/export/getFields.d.ts +8 -2
  52. package/dist/export/getFields.d.ts.map +1 -1
  53. package/dist/export/getFields.js +7 -9
  54. package/dist/export/getFields.js.map +1 -1
  55. package/dist/export/handleDownload.d.ts +3 -0
  56. package/dist/export/handleDownload.d.ts.map +1 -0
  57. package/dist/export/{download.js → handleDownload.js} +7 -6
  58. package/dist/export/handleDownload.js.map +1 -0
  59. package/dist/export/handlePreview.d.ts +3 -0
  60. package/dist/export/handlePreview.d.ts.map +1 -0
  61. package/dist/export/handlePreview.js +163 -0
  62. package/dist/export/handlePreview.js.map +1 -0
  63. package/dist/exports/rsc.d.ts +5 -1
  64. package/dist/exports/rsc.d.ts.map +1 -1
  65. package/dist/exports/rsc.js +5 -1
  66. package/dist/exports/rsc.js.map +1 -1
  67. package/dist/import/batchProcessor.d.ts +46 -0
  68. package/dist/import/batchProcessor.d.ts.map +1 -0
  69. package/dist/import/batchProcessor.js +529 -0
  70. package/dist/import/batchProcessor.js.map +1 -0
  71. package/dist/import/createImport.d.ts +45 -0
  72. package/dist/import/createImport.d.ts.map +1 -0
  73. package/dist/import/createImport.js +175 -0
  74. package/dist/import/createImport.js.map +1 -0
  75. package/dist/import/getCreateImportCollectionTask.d.ts +13 -0
  76. package/dist/import/getCreateImportCollectionTask.d.ts.map +1 -0
  77. package/dist/import/getCreateImportCollectionTask.js +81 -0
  78. package/dist/import/getCreateImportCollectionTask.js.map +1 -0
  79. package/dist/import/getFields.d.ts +7 -0
  80. package/dist/import/getFields.d.ts.map +1 -0
  81. package/dist/import/getFields.js +150 -0
  82. package/dist/import/getFields.js.map +1 -0
  83. package/dist/import/getImportCollection.d.ts +8 -0
  84. package/dist/import/getImportCollection.d.ts.map +1 -0
  85. package/dist/import/getImportCollection.js +258 -0
  86. package/dist/import/getImportCollection.js.map +1 -0
  87. package/dist/import/handlePreview.d.ts +3 -0
  88. package/dist/import/handlePreview.d.ts.map +1 -0
  89. package/dist/import/handlePreview.js +94 -0
  90. package/dist/import/handlePreview.js.map +1 -0
  91. package/dist/index.d.ts +3 -2
  92. package/dist/index.d.ts.map +1 -1
  93. package/dist/index.js +68 -110
  94. package/dist/index.js.map +1 -1
  95. package/dist/translations/languages/ar.d.ts.map +1 -1
  96. package/dist/translations/languages/ar.js +21 -1
  97. package/dist/translations/languages/ar.js.map +1 -1
  98. package/dist/translations/languages/az.d.ts.map +1 -1
  99. package/dist/translations/languages/az.js +21 -1
  100. package/dist/translations/languages/az.js.map +1 -1
  101. package/dist/translations/languages/bg.d.ts.map +1 -1
  102. package/dist/translations/languages/bg.js +21 -1
  103. package/dist/translations/languages/bg.js.map +1 -1
  104. package/dist/translations/languages/bnBd.d.ts +4 -0
  105. package/dist/translations/languages/bnBd.d.ts.map +1 -0
  106. package/dist/translations/languages/bnBd.js +48 -0
  107. package/dist/translations/languages/bnBd.js.map +1 -0
  108. package/dist/translations/languages/bnIn.d.ts +4 -0
  109. package/dist/translations/languages/bnIn.d.ts.map +1 -0
  110. package/dist/translations/languages/bnIn.js +48 -0
  111. package/dist/translations/languages/bnIn.js.map +1 -0
  112. package/dist/translations/languages/ca.d.ts.map +1 -1
  113. package/dist/translations/languages/ca.js +21 -1
  114. package/dist/translations/languages/ca.js.map +1 -1
  115. package/dist/translations/languages/cs.d.ts.map +1 -1
  116. package/dist/translations/languages/cs.js +21 -1
  117. package/dist/translations/languages/cs.js.map +1 -1
  118. package/dist/translations/languages/da.d.ts.map +1 -1
  119. package/dist/translations/languages/da.js +21 -1
  120. package/dist/translations/languages/da.js.map +1 -1
  121. package/dist/translations/languages/de.d.ts.map +1 -1
  122. package/dist/translations/languages/de.js +21 -1
  123. package/dist/translations/languages/de.js.map +1 -1
  124. package/dist/translations/languages/en.d.ts +20 -0
  125. package/dist/translations/languages/en.d.ts.map +1 -1
  126. package/dist/translations/languages/en.js +21 -1
  127. package/dist/translations/languages/en.js.map +1 -1
  128. package/dist/translations/languages/es.d.ts.map +1 -1
  129. package/dist/translations/languages/es.js +21 -1
  130. package/dist/translations/languages/es.js.map +1 -1
  131. package/dist/translations/languages/et.d.ts.map +1 -1
  132. package/dist/translations/languages/et.js +21 -1
  133. package/dist/translations/languages/et.js.map +1 -1
  134. package/dist/translations/languages/fa.d.ts.map +1 -1
  135. package/dist/translations/languages/fa.js +21 -1
  136. package/dist/translations/languages/fa.js.map +1 -1
  137. package/dist/translations/languages/fr.d.ts.map +1 -1
  138. package/dist/translations/languages/fr.js +21 -1
  139. package/dist/translations/languages/fr.js.map +1 -1
  140. package/dist/translations/languages/he.d.ts.map +1 -1
  141. package/dist/translations/languages/he.js +21 -1
  142. package/dist/translations/languages/he.js.map +1 -1
  143. package/dist/translations/languages/hr.d.ts.map +1 -1
  144. package/dist/translations/languages/hr.js +21 -1
  145. package/dist/translations/languages/hr.js.map +1 -1
  146. package/dist/translations/languages/hu.d.ts.map +1 -1
  147. package/dist/translations/languages/hu.js +21 -1
  148. package/dist/translations/languages/hu.js.map +1 -1
  149. package/dist/translations/languages/hy.d.ts.map +1 -1
  150. package/dist/translations/languages/hy.js +21 -1
  151. package/dist/translations/languages/hy.js.map +1 -1
  152. package/dist/translations/languages/id.d.ts +4 -0
  153. package/dist/translations/languages/id.d.ts.map +1 -0
  154. package/dist/translations/languages/id.js +48 -0
  155. package/dist/translations/languages/id.js.map +1 -0
  156. package/dist/translations/languages/is.d.ts.map +1 -1
  157. package/dist/translations/languages/is.js +21 -1
  158. package/dist/translations/languages/is.js.map +1 -1
  159. package/dist/translations/languages/it.d.ts.map +1 -1
  160. package/dist/translations/languages/it.js +21 -1
  161. package/dist/translations/languages/it.js.map +1 -1
  162. package/dist/translations/languages/ja.d.ts.map +1 -1
  163. package/dist/translations/languages/ja.js +21 -1
  164. package/dist/translations/languages/ja.js.map +1 -1
  165. package/dist/translations/languages/ko.d.ts.map +1 -1
  166. package/dist/translations/languages/ko.js +21 -1
  167. package/dist/translations/languages/ko.js.map +1 -1
  168. package/dist/translations/languages/lt.d.ts.map +1 -1
  169. package/dist/translations/languages/lt.js +21 -1
  170. package/dist/translations/languages/lt.js.map +1 -1
  171. package/dist/translations/languages/lv.d.ts.map +1 -1
  172. package/dist/translations/languages/lv.js +26 -6
  173. package/dist/translations/languages/lv.js.map +1 -1
  174. package/dist/translations/languages/my.d.ts.map +1 -1
  175. package/dist/translations/languages/my.js +21 -1
  176. package/dist/translations/languages/my.js.map +1 -1
  177. package/dist/translations/languages/nb.d.ts.map +1 -1
  178. package/dist/translations/languages/nb.js +21 -1
  179. package/dist/translations/languages/nb.js.map +1 -1
  180. package/dist/translations/languages/nl.d.ts.map +1 -1
  181. package/dist/translations/languages/nl.js +21 -1
  182. package/dist/translations/languages/nl.js.map +1 -1
  183. package/dist/translations/languages/pl.d.ts.map +1 -1
  184. package/dist/translations/languages/pl.js +21 -1
  185. package/dist/translations/languages/pl.js.map +1 -1
  186. package/dist/translations/languages/pt.d.ts.map +1 -1
  187. package/dist/translations/languages/pt.js +21 -1
  188. package/dist/translations/languages/pt.js.map +1 -1
  189. package/dist/translations/languages/ro.d.ts.map +1 -1
  190. package/dist/translations/languages/ro.js +21 -1
  191. package/dist/translations/languages/ro.js.map +1 -1
  192. package/dist/translations/languages/rs.d.ts.map +1 -1
  193. package/dist/translations/languages/rs.js +21 -1
  194. package/dist/translations/languages/rs.js.map +1 -1
  195. package/dist/translations/languages/rsLatin.d.ts.map +1 -1
  196. package/dist/translations/languages/rsLatin.js +21 -1
  197. package/dist/translations/languages/rsLatin.js.map +1 -1
  198. package/dist/translations/languages/ru.d.ts.map +1 -1
  199. package/dist/translations/languages/ru.js +21 -1
  200. package/dist/translations/languages/ru.js.map +1 -1
  201. package/dist/translations/languages/sk.d.ts.map +1 -1
  202. package/dist/translations/languages/sk.js +21 -1
  203. package/dist/translations/languages/sk.js.map +1 -1
  204. package/dist/translations/languages/sl.d.ts.map +1 -1
  205. package/dist/translations/languages/sl.js +21 -1
  206. package/dist/translations/languages/sl.js.map +1 -1
  207. package/dist/translations/languages/sv.d.ts.map +1 -1
  208. package/dist/translations/languages/sv.js +21 -1
  209. package/dist/translations/languages/sv.js.map +1 -1
  210. package/dist/translations/languages/ta.d.ts.map +1 -1
  211. package/dist/translations/languages/ta.js +21 -1
  212. package/dist/translations/languages/ta.js.map +1 -1
  213. package/dist/translations/languages/th.d.ts.map +1 -1
  214. package/dist/translations/languages/th.js +21 -1
  215. package/dist/translations/languages/th.js.map +1 -1
  216. package/dist/translations/languages/tr.d.ts.map +1 -1
  217. package/dist/translations/languages/tr.js +21 -1
  218. package/dist/translations/languages/tr.js.map +1 -1
  219. package/dist/translations/languages/uk.d.ts.map +1 -1
  220. package/dist/translations/languages/uk.js +21 -1
  221. package/dist/translations/languages/uk.js.map +1 -1
  222. package/dist/translations/languages/vi.d.ts.map +1 -1
  223. package/dist/translations/languages/vi.js +29 -9
  224. package/dist/translations/languages/vi.js.map +1 -1
  225. package/dist/translations/languages/zh.d.ts.map +1 -1
  226. package/dist/translations/languages/zh.js +21 -1
  227. package/dist/translations/languages/zh.js.map +1 -1
  228. package/dist/translations/languages/zhTw.d.ts.map +1 -1
  229. package/dist/translations/languages/zhTw.js +21 -1
  230. package/dist/translations/languages/zhTw.js.map +1 -1
  231. package/dist/translations/types.d.ts +13 -0
  232. package/dist/translations/types.d.ts.map +1 -1
  233. package/dist/translations/types.js.map +1 -1
  234. package/dist/types.d.ts +166 -22
  235. package/dist/types.d.ts.map +1 -1
  236. package/dist/types.js +1 -1
  237. package/dist/types.js.map +1 -1
  238. package/dist/utilities/flattenObject.d.ts.map +1 -0
  239. package/dist/{export → utilities}/flattenObject.js +13 -6
  240. package/dist/utilities/flattenObject.js.map +1 -0
  241. package/dist/utilities/getExportFieldFunctions.d.ts +12 -0
  242. package/dist/utilities/getExportFieldFunctions.d.ts.map +1 -0
  243. package/dist/{export/getCustomFieldFunctions.js → utilities/getExportFieldFunctions.js} +18 -2
  244. package/dist/utilities/getExportFieldFunctions.js.map +1 -0
  245. package/dist/utilities/getFilename.d.ts +6 -0
  246. package/dist/utilities/getFilename.d.ts.map +1 -0
  247. package/dist/{export → utilities}/getFilename.js +4 -1
  248. package/dist/utilities/getFilename.js.map +1 -0
  249. package/dist/utilities/getFlattenedFieldKeys.d.ts +12 -1
  250. package/dist/utilities/getFlattenedFieldKeys.d.ts.map +1 -1
  251. package/dist/utilities/getFlattenedFieldKeys.js +35 -10
  252. package/dist/utilities/getFlattenedFieldKeys.js.map +1 -1
  253. package/dist/utilities/getImportFieldFunctions.d.ts +12 -0
  254. package/dist/utilities/getImportFieldFunctions.d.ts.map +1 -0
  255. package/dist/utilities/getImportFieldFunctions.js +130 -0
  256. package/dist/utilities/getImportFieldFunctions.js.map +1 -0
  257. package/dist/utilities/getPluginCollections.d.ts +39 -0
  258. package/dist/utilities/getPluginCollections.d.ts.map +1 -0
  259. package/dist/utilities/getPluginCollections.js +102 -0
  260. package/dist/utilities/getPluginCollections.js.map +1 -0
  261. package/dist/utilities/getSchemaColumns.d.ts +43 -0
  262. package/dist/utilities/getSchemaColumns.d.ts.map +1 -0
  263. package/dist/utilities/getSchemaColumns.js +163 -0
  264. package/dist/utilities/getSchemaColumns.js.map +1 -0
  265. package/dist/utilities/getSelect.d.ts +11 -0
  266. package/dist/utilities/getSelect.d.ts.map +1 -0
  267. package/dist/{export → utilities}/getSelect.js +6 -2
  268. package/dist/utilities/getSelect.js.map +1 -0
  269. package/dist/utilities/parseCSV.d.ts +11 -0
  270. package/dist/utilities/parseCSV.d.ts.map +1 -0
  271. package/dist/utilities/parseCSV.js +67 -0
  272. package/dist/utilities/parseCSV.js.map +1 -0
  273. package/dist/utilities/parseCSV.spec.js +168 -0
  274. package/dist/utilities/parseCSV.spec.js.map +1 -0
  275. package/dist/utilities/parseJSON.d.ts +11 -0
  276. package/dist/utilities/parseJSON.d.ts.map +1 -0
  277. package/dist/utilities/parseJSON.js +25 -0
  278. package/dist/utilities/parseJSON.js.map +1 -0
  279. package/dist/utilities/processRichTextField.d.ts +6 -0
  280. package/dist/utilities/processRichTextField.d.ts.map +1 -0
  281. package/dist/utilities/processRichTextField.js +45 -0
  282. package/dist/utilities/processRichTextField.js.map +1 -0
  283. package/dist/utilities/unflattenObject.d.ts +11 -0
  284. package/dist/utilities/unflattenObject.d.ts.map +1 -0
  285. package/dist/utilities/unflattenObject.js +431 -0
  286. package/dist/utilities/unflattenObject.js.map +1 -0
  287. package/dist/utilities/unflattenObject.spec.js +679 -0
  288. package/dist/utilities/unflattenObject.spec.js.map +1 -0
  289. package/dist/utilities/useBatchProcessor.d.ts +103 -0
  290. package/dist/utilities/useBatchProcessor.d.ts.map +1 -0
  291. package/dist/utilities/useBatchProcessor.js +88 -0
  292. package/dist/utilities/useBatchProcessor.js.map +1 -0
  293. package/dist/utilities/validateLimitValue.d.ts +1 -1
  294. package/dist/utilities/validateLimitValue.d.ts.map +1 -1
  295. package/dist/utilities/validateLimitValue.js +1 -4
  296. package/dist/utilities/validateLimitValue.js.map +1 -1
  297. package/package.json +9 -9
  298. package/dist/components/ExportListMenuItem/index.scss +0 -52
  299. package/dist/components/Preview/index.d.ts +0 -4
  300. package/dist/components/Preview/index.d.ts.map +0 -1
  301. package/dist/components/Preview/index.js +0 -180
  302. package/dist/components/Preview/index.js.map +0 -1
  303. package/dist/components/Preview/index.scss +0 -8
  304. package/dist/export/download.d.ts +0 -3
  305. package/dist/export/download.d.ts.map +0 -1
  306. package/dist/export/download.js.map +0 -1
  307. package/dist/export/flattenObject.d.ts.map +0 -1
  308. package/dist/export/flattenObject.js.map +0 -1
  309. package/dist/export/getCustomFieldFunctions.d.ts +0 -8
  310. package/dist/export/getCustomFieldFunctions.d.ts.map +0 -1
  311. package/dist/export/getCustomFieldFunctions.js.map +0 -1
  312. package/dist/export/getFilename.d.ts +0 -2
  313. package/dist/export/getFilename.d.ts.map +0 -1
  314. package/dist/export/getFilename.js.map +0 -1
  315. package/dist/export/getSelect.d.ts +0 -7
  316. package/dist/export/getSelect.d.ts.map +0 -1
  317. package/dist/export/getSelect.js.map +0 -1
  318. package/dist/getExportCollection.d.ts +0 -7
  319. package/dist/getExportCollection.d.ts.map +0 -1
  320. package/dist/getExportCollection.js +0 -86
  321. package/dist/getExportCollection.js.map +0 -1
  322. /package/dist/{export → utilities}/flattenObject.d.ts +0 -0
@@ -0,0 +1,679 @@
1
+ import { unflattenObject } from './unflattenObject.js';
2
+ describe('unflattenObject', ()=>{
3
+ const mockReq = {
4
+ payload: {
5
+ logger: {
6
+ error: jest.fn()
7
+ }
8
+ }
9
+ };
10
+ describe('hasMany number fields', ()=>{
11
+ const fields = [
12
+ {
13
+ name: 'hasManyNumber',
14
+ type: 'number',
15
+ hasMany: true
16
+ }
17
+ ];
18
+ it('should handle comma-separated number strings', ()=>{
19
+ const data = {
20
+ hasManyNumber: '1,2,3,5,8'
21
+ };
22
+ const result = unflattenObject({
23
+ data,
24
+ fields,
25
+ req: mockReq
26
+ });
27
+ expect(result).toEqual({
28
+ hasManyNumber: [
29
+ 1,
30
+ 2,
31
+ 3,
32
+ 5,
33
+ 8
34
+ ]
35
+ });
36
+ });
37
+ it('should handle comma-separated numbers with spaces', ()=>{
38
+ const data = {
39
+ hasManyNumber: ' 10 , 20 , 30 '
40
+ };
41
+ const result = unflattenObject({
42
+ data,
43
+ fields,
44
+ req: mockReq
45
+ });
46
+ expect(result).toEqual({
47
+ hasManyNumber: [
48
+ 10,
49
+ 20,
50
+ 30
51
+ ]
52
+ });
53
+ });
54
+ it('should filter out empty values in comma-separated strings', ()=>{
55
+ const data = {
56
+ hasManyNumber: '1,,3,,5'
57
+ };
58
+ const result = unflattenObject({
59
+ data,
60
+ fields,
61
+ req: mockReq
62
+ });
63
+ expect(result).toEqual({
64
+ hasManyNumber: [
65
+ 1,
66
+ 3,
67
+ 5
68
+ ]
69
+ });
70
+ });
71
+ it('should handle single number values', ()=>{
72
+ const data = {
73
+ hasManyNumber: 42
74
+ };
75
+ const result = unflattenObject({
76
+ data,
77
+ fields,
78
+ req: mockReq
79
+ });
80
+ expect(result).toEqual({
81
+ hasManyNumber: [
82
+ 42
83
+ ]
84
+ });
85
+ });
86
+ it('should handle single string number values', ()=>{
87
+ const data = {
88
+ hasManyNumber: '42'
89
+ };
90
+ const result = unflattenObject({
91
+ data,
92
+ fields,
93
+ req: mockReq
94
+ });
95
+ expect(result).toEqual({
96
+ hasManyNumber: [
97
+ 42
98
+ ]
99
+ });
100
+ });
101
+ it('should handle indexed array format', ()=>{
102
+ const data = {
103
+ hasManyNumber_0: 1,
104
+ hasManyNumber_1: 2,
105
+ hasManyNumber_2: 3
106
+ };
107
+ const result = unflattenObject({
108
+ data,
109
+ fields,
110
+ req: mockReq
111
+ });
112
+ expect(result).toEqual({
113
+ hasManyNumber: [
114
+ 1,
115
+ 2,
116
+ 3
117
+ ]
118
+ });
119
+ });
120
+ it('should filter out null and empty values from indexed arrays', ()=>{
121
+ const data = {
122
+ hasManyNumber_0: 1,
123
+ hasManyNumber_1: null,
124
+ hasManyNumber_2: '',
125
+ hasManyNumber_3: 3
126
+ };
127
+ const result = unflattenObject({
128
+ data,
129
+ fields,
130
+ req: mockReq
131
+ });
132
+ expect(result).toEqual({
133
+ hasManyNumber: [
134
+ 1,
135
+ 3
136
+ ]
137
+ });
138
+ });
139
+ it('should handle empty, null, and undefined values', ()=>{
140
+ // explicit null gets converted to empty array in postProcess for hasMany
141
+ expect(unflattenObject({
142
+ data: {
143
+ hasManyNumber: null
144
+ },
145
+ fields,
146
+ req: mockReq
147
+ })).toEqual({
148
+ hasManyNumber: []
149
+ });
150
+ // undefined is skipped entirely (preserves existing data)
151
+ expect(unflattenObject({
152
+ data: {
153
+ hasManyNumber: undefined
154
+ },
155
+ fields,
156
+ req: mockReq
157
+ })).toEqual({});
158
+ });
159
+ });
160
+ describe('hasMany relationship fields', ()=>{
161
+ const fields = [
162
+ {
163
+ name: 'hasManyRelationship',
164
+ type: 'relationship',
165
+ hasMany: true,
166
+ relationTo: 'posts'
167
+ }
168
+ ];
169
+ it('should handle comma-separated ID strings', ()=>{
170
+ const data = {
171
+ hasManyRelationship: 'id1,id2,id3'
172
+ };
173
+ const result = unflattenObject({
174
+ data,
175
+ fields,
176
+ req: mockReq
177
+ });
178
+ expect(result).toEqual({
179
+ hasManyRelationship: [
180
+ 'id1',
181
+ 'id2',
182
+ 'id3'
183
+ ]
184
+ });
185
+ });
186
+ it('should handle comma-separated IDs with spaces', ()=>{
187
+ const data = {
188
+ hasManyRelationship: ' id1 , id2 , id3 '
189
+ };
190
+ const result = unflattenObject({
191
+ data,
192
+ fields,
193
+ req: mockReq
194
+ });
195
+ expect(result).toEqual({
196
+ hasManyRelationship: [
197
+ 'id1',
198
+ 'id2',
199
+ 'id3'
200
+ ]
201
+ });
202
+ });
203
+ it('should filter out empty values in comma-separated IDs', ()=>{
204
+ const data = {
205
+ hasManyRelationship: 'id1,,id3,,id5'
206
+ };
207
+ const result = unflattenObject({
208
+ data,
209
+ fields,
210
+ req: mockReq
211
+ });
212
+ expect(result).toEqual({
213
+ hasManyRelationship: [
214
+ 'id1',
215
+ 'id3',
216
+ 'id5'
217
+ ]
218
+ });
219
+ });
220
+ it('should handle single ID values', ()=>{
221
+ const data = {
222
+ hasManyRelationship: 'singleId'
223
+ };
224
+ const result = unflattenObject({
225
+ data,
226
+ fields,
227
+ req: mockReq
228
+ });
229
+ expect(result).toEqual({
230
+ hasManyRelationship: [
231
+ 'singleId'
232
+ ]
233
+ });
234
+ });
235
+ it('should handle indexed array format', ()=>{
236
+ const data = {
237
+ hasManyRelationship_0: 'id1',
238
+ hasManyRelationship_1: 'id2',
239
+ hasManyRelationship_2: 'id3'
240
+ };
241
+ const result = unflattenObject({
242
+ data,
243
+ fields,
244
+ req: mockReq
245
+ });
246
+ expect(result).toEqual({
247
+ hasManyRelationship: [
248
+ 'id1',
249
+ 'id2',
250
+ 'id3'
251
+ ]
252
+ });
253
+ });
254
+ it('should handle MongoDB ObjectIDs', ()=>{
255
+ const data = {
256
+ hasManyRelationship: '507f1f77bcf86cd799439011,507f191e810c19729de860ea'
257
+ };
258
+ const result = unflattenObject({
259
+ data,
260
+ fields,
261
+ req: mockReq
262
+ });
263
+ expect(result).toEqual({
264
+ hasManyRelationship: [
265
+ '507f1f77bcf86cd799439011',
266
+ '507f191e810c19729de860ea'
267
+ ]
268
+ });
269
+ });
270
+ });
271
+ describe('localized fields', ()=>{
272
+ const fields = [
273
+ {
274
+ name: 'title',
275
+ type: 'text',
276
+ localized: true
277
+ }
278
+ ];
279
+ it('should transform locale-specific keys to nested structure', ()=>{
280
+ const data = {
281
+ title_en: 'English Title',
282
+ title_es: 'Título en Español'
283
+ };
284
+ const result = unflattenObject({
285
+ data,
286
+ fields,
287
+ req: mockReq
288
+ });
289
+ expect(result).toEqual({
290
+ title: {
291
+ en: 'English Title',
292
+ es: 'Título en Español'
293
+ }
294
+ });
295
+ });
296
+ it('should handle missing locales', ()=>{
297
+ const data = {
298
+ title_en: 'English Title'
299
+ };
300
+ const result = unflattenObject({
301
+ data,
302
+ fields,
303
+ req: mockReq
304
+ });
305
+ expect(result).toEqual({
306
+ title: {
307
+ en: 'English Title'
308
+ }
309
+ });
310
+ });
311
+ });
312
+ describe('blocks fields', ()=>{
313
+ const fields = [
314
+ {
315
+ name: 'blocks',
316
+ type: 'blocks'
317
+ }
318
+ ];
319
+ it('should handle block fields with blockType', ()=>{
320
+ const data = {
321
+ blocks_0_hero_title: 'Hero Title',
322
+ blocks_0_hero_subtitle: 'Hero Subtitle',
323
+ blocks_0_hero_blockType: 'hero'
324
+ };
325
+ const result = unflattenObject({
326
+ data,
327
+ fields,
328
+ req: mockReq
329
+ });
330
+ expect(result).toEqual({
331
+ blocks: [
332
+ {
333
+ blockType: 'hero',
334
+ title: 'Hero Title',
335
+ subtitle: 'Hero Subtitle'
336
+ }
337
+ ]
338
+ });
339
+ });
340
+ it('should handle multiple blocks', ()=>{
341
+ const data = {
342
+ blocks_0_hero_title: 'Hero Title',
343
+ blocks_0_hero_blockType: 'hero',
344
+ blocks_1_text_content: 'Text Content',
345
+ blocks_1_text_blockType: 'text'
346
+ };
347
+ const result = unflattenObject({
348
+ data,
349
+ fields,
350
+ req: mockReq
351
+ });
352
+ expect(result).toEqual({
353
+ blocks: [
354
+ {
355
+ blockType: 'hero',
356
+ title: 'Hero Title'
357
+ },
358
+ {
359
+ blockType: 'text',
360
+ content: 'Text Content'
361
+ }
362
+ ]
363
+ });
364
+ });
365
+ });
366
+ describe('array fields', ()=>{
367
+ const fields = [
368
+ {
369
+ name: 'items',
370
+ type: 'array'
371
+ }
372
+ ];
373
+ it('should handle indexed array objects', ()=>{
374
+ const data = {
375
+ items_0_name: 'Item 1',
376
+ items_0_value: 10,
377
+ items_1_name: 'Item 2',
378
+ items_1_value: 20
379
+ };
380
+ const result = unflattenObject({
381
+ data,
382
+ fields,
383
+ req: mockReq
384
+ });
385
+ expect(result).toEqual({
386
+ items: [
387
+ {
388
+ name: 'Item 1',
389
+ value: 10
390
+ },
391
+ {
392
+ name: 'Item 2',
393
+ value: 20
394
+ }
395
+ ]
396
+ });
397
+ });
398
+ it('should handle sparse arrays', ()=>{
399
+ const data = {
400
+ items_0_name: 'Item 1',
401
+ items_2_name: 'Item 3'
402
+ };
403
+ const result = unflattenObject({
404
+ data,
405
+ fields,
406
+ req: mockReq
407
+ });
408
+ expect(result).toEqual({
409
+ items: [
410
+ {
411
+ name: 'Item 1'
412
+ },
413
+ null,
414
+ {
415
+ name: 'Item 3'
416
+ }
417
+ ]
418
+ });
419
+ });
420
+ });
421
+ describe('group fields', ()=>{
422
+ const fields = [
423
+ {
424
+ name: 'group',
425
+ type: 'group'
426
+ }
427
+ ];
428
+ it('should handle nested group fields', ()=>{
429
+ const data = {
430
+ group_field1: 'Value 1',
431
+ group_field2: 'Value 2'
432
+ };
433
+ const result = unflattenObject({
434
+ data,
435
+ fields,
436
+ req: mockReq
437
+ });
438
+ expect(result).toEqual({
439
+ group: {
440
+ field1: 'Value 1',
441
+ field2: 'Value 2'
442
+ }
443
+ });
444
+ });
445
+ });
446
+ describe('polymorphic relationships', ()=>{
447
+ const fields = [
448
+ {
449
+ name: 'polymorphic',
450
+ type: 'relationship',
451
+ relationTo: [
452
+ 'posts',
453
+ 'pages'
454
+ ]
455
+ }
456
+ ];
457
+ it('should handle polymorphic relationship with id and relationTo', ()=>{
458
+ const data = {
459
+ polymorphic_id: '123',
460
+ polymorphic_relationTo: 'posts'
461
+ };
462
+ const result = unflattenObject({
463
+ data,
464
+ fields,
465
+ req: mockReq
466
+ });
467
+ expect(result).toEqual({
468
+ polymorphic: {
469
+ relationTo: 'posts',
470
+ value: '123'
471
+ }
472
+ });
473
+ });
474
+ it('should handle explicitly null polymorphic relationships', ()=>{
475
+ const data = {
476
+ polymorphic_id: null,
477
+ polymorphic_relationTo: null
478
+ };
479
+ const result = unflattenObject({
480
+ data,
481
+ fields,
482
+ req: mockReq
483
+ });
484
+ expect(result).toEqual({
485
+ polymorphic: null
486
+ });
487
+ });
488
+ it('should skip polymorphic relationships with undefined values', ()=>{
489
+ const data = {
490
+ polymorphic_id: undefined,
491
+ polymorphic_relationTo: undefined
492
+ };
493
+ const result = unflattenObject({
494
+ data,
495
+ fields,
496
+ req: mockReq
497
+ });
498
+ // Both undefined means field is not set (preserves existing data)
499
+ expect(result).toEqual({});
500
+ });
501
+ it('should skip polymorphic relationship with undefined id', ()=>{
502
+ const data = {
503
+ polymorphic_id: undefined,
504
+ polymorphic_relationTo: 'posts'
505
+ };
506
+ const result = unflattenObject({
507
+ data,
508
+ fields,
509
+ req: mockReq
510
+ });
511
+ // Undefined ID means don't update this field
512
+ expect(result).toEqual({});
513
+ });
514
+ it('should skip polymorphic relationship with undefined relationTo', ()=>{
515
+ const data = {
516
+ polymorphic_id: '123',
517
+ polymorphic_relationTo: undefined
518
+ };
519
+ const result = unflattenObject({
520
+ data,
521
+ fields,
522
+ req: mockReq
523
+ });
524
+ // Undefined relationTo means don't update this field
525
+ expect(result).toEqual({});
526
+ });
527
+ it('should handle polymorphic hasMany relationships', ()=>{
528
+ const fields = [
529
+ {
530
+ name: 'polymorphicMany',
531
+ type: 'relationship',
532
+ hasMany: true,
533
+ relationTo: [
534
+ 'posts',
535
+ 'pages'
536
+ ]
537
+ }
538
+ ];
539
+ const data = {
540
+ polymorphicMany_0_id: '123',
541
+ polymorphicMany_0_relationTo: 'posts',
542
+ polymorphicMany_1_id: '456',
543
+ polymorphicMany_1_relationTo: 'pages'
544
+ };
545
+ const result = unflattenObject({
546
+ data,
547
+ fields,
548
+ req: mockReq
549
+ });
550
+ expect(result).toEqual({
551
+ polymorphicMany: [
552
+ {
553
+ relationTo: 'posts',
554
+ value: '123'
555
+ },
556
+ {
557
+ relationTo: 'pages',
558
+ value: '456'
559
+ }
560
+ ]
561
+ });
562
+ });
563
+ it('should filter out empty polymorphic hasMany items', ()=>{
564
+ const fields = [
565
+ {
566
+ name: 'polymorphicMany',
567
+ type: 'relationship',
568
+ hasMany: true,
569
+ relationTo: [
570
+ 'posts',
571
+ 'pages'
572
+ ]
573
+ }
574
+ ];
575
+ const data = {
576
+ polymorphicMany_0_id: '123',
577
+ polymorphicMany_0_relationTo: 'posts',
578
+ polymorphicMany_1_id: null,
579
+ polymorphicMany_1_relationTo: null,
580
+ polymorphicMany_2_id: '456',
581
+ polymorphicMany_2_relationTo: 'pages'
582
+ };
583
+ const result = unflattenObject({
584
+ data,
585
+ fields,
586
+ req: mockReq
587
+ });
588
+ expect(result).toEqual({
589
+ polymorphicMany: [
590
+ {
591
+ relationTo: 'posts',
592
+ value: '123'
593
+ },
594
+ {
595
+ relationTo: 'pages',
596
+ value: '456'
597
+ }
598
+ ]
599
+ });
600
+ });
601
+ it('should handle all empty polymorphic hasMany items', ()=>{
602
+ const fields = [
603
+ {
604
+ name: 'polymorphicMany',
605
+ type: 'relationship',
606
+ hasMany: true,
607
+ relationTo: [
608
+ 'posts',
609
+ 'pages'
610
+ ]
611
+ }
612
+ ];
613
+ const data = {
614
+ polymorphicMany_0_id: null,
615
+ polymorphicMany_0_relationTo: null,
616
+ polymorphicMany_1_id: '',
617
+ polymorphicMany_1_relationTo: ''
618
+ };
619
+ const result = unflattenObject({
620
+ data,
621
+ fields,
622
+ req: mockReq
623
+ });
624
+ expect(result).toEqual({
625
+ polymorphicMany: []
626
+ });
627
+ });
628
+ });
629
+ describe('edge cases', ()=>{
630
+ it('should handle empty data', ()=>{
631
+ const result = unflattenObject({
632
+ data: {},
633
+ fields: [],
634
+ req: mockReq
635
+ });
636
+ expect(result).toEqual({});
637
+ });
638
+ it('should handle null data', ()=>{
639
+ const result = unflattenObject({
640
+ data: null,
641
+ fields: [],
642
+ req: mockReq
643
+ });
644
+ expect(result).toEqual({});
645
+ });
646
+ it('should handle undefined values', ()=>{
647
+ const data = {
648
+ field1: undefined,
649
+ field2: 'value'
650
+ };
651
+ const result = unflattenObject({
652
+ data,
653
+ fields: [],
654
+ req: mockReq
655
+ });
656
+ expect(result).toEqual({
657
+ field2: 'value'
658
+ });
659
+ });
660
+ it('should preserve null values for validation', ()=>{
661
+ const data = {
662
+ field1: null,
663
+ field2: 'value'
664
+ };
665
+ const result = unflattenObject({
666
+ data,
667
+ fields: [],
668
+ req: mockReq
669
+ });
670
+ // null values are preserved for validation
671
+ expect(result).toEqual({
672
+ field1: null,
673
+ field2: 'value'
674
+ });
675
+ });
676
+ });
677
+ });
678
+
679
+ //# sourceMappingURL=unflattenObject.spec.js.map