@payloadcms/db-postgres 3.0.0-beta.68 → 3.0.0-beta.69

Sign up to get free protection for your applications and to get access to all the features.
Files changed (361) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +4 -6
  3. package/dist/connect.js.map +1 -1
  4. package/dist/countDistinct.d.ts +3 -0
  5. package/dist/countDistinct.d.ts.map +1 -0
  6. package/dist/countDistinct.js +24 -0
  7. package/dist/countDistinct.js.map +1 -0
  8. package/dist/createJSONQuery/convertPathToJSONTraversal.d.ts.map +1 -0
  9. package/dist/createJSONQuery/convertPathToJSONTraversal.js.map +1 -0
  10. package/dist/createJSONQuery/formatJSONPathSegment.d.ts.map +1 -0
  11. package/dist/createJSONQuery/formatJSONPathSegment.js.map +1 -0
  12. package/dist/createJSONQuery/index.d.ts.map +1 -0
  13. package/dist/createJSONQuery/index.js.map +1 -0
  14. package/dist/createMigration.d.ts.map +1 -1
  15. package/dist/createMigration.js +8 -30
  16. package/dist/createMigration.js.map +1 -1
  17. package/dist/defaultSnapshot.d.ts +3 -0
  18. package/dist/defaultSnapshot.d.ts.map +1 -0
  19. package/dist/defaultSnapshot.js +16 -0
  20. package/dist/defaultSnapshot.js.map +1 -0
  21. package/dist/deleteWhere.d.ts +3 -0
  22. package/dist/deleteWhere.d.ts.map +1 -0
  23. package/dist/deleteWhere.js +6 -0
  24. package/dist/deleteWhere.js.map +1 -0
  25. package/dist/dropDatabase.d.ts +3 -0
  26. package/dist/dropDatabase.d.ts.map +1 -0
  27. package/dist/dropDatabase.js +9 -0
  28. package/dist/dropDatabase.js.map +1 -0
  29. package/dist/execute.d.ts +3 -0
  30. package/dist/execute.d.ts.map +1 -0
  31. package/dist/execute.js +11 -0
  32. package/dist/execute.js.map +1 -0
  33. package/dist/getMigrationTemplate.d.ts +3 -0
  34. package/dist/getMigrationTemplate.d.ts.map +1 -0
  35. package/dist/getMigrationTemplate.js +12 -0
  36. package/dist/getMigrationTemplate.js.map +1 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +27 -63
  39. package/dist/index.js.map +1 -1
  40. package/dist/init.d.ts.map +1 -1
  41. package/dist/init.js +1 -1
  42. package/dist/init.js.map +1 -1
  43. package/dist/insert.d.ts +3 -0
  44. package/dist/insert.d.ts.map +1 -0
  45. package/dist/insert.js +12 -0
  46. package/dist/insert.js.map +1 -0
  47. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +3 -2
  48. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
  49. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +1 -1
  50. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -1
  51. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
  52. package/dist/predefinedMigrations/v2-v3/index.js +1 -1
  53. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -1
  54. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +3 -2
  55. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
  56. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -1
  57. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +3 -2
  58. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
  59. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -1
  60. package/dist/requireDrizzleKit.d.ts +3 -0
  61. package/dist/requireDrizzleKit.d.ts.map +1 -0
  62. package/dist/requireDrizzleKit.js +5 -0
  63. package/dist/requireDrizzleKit.js.map +1 -0
  64. package/dist/schema/build.d.ts.map +1 -1
  65. package/dist/schema/build.js +2 -2
  66. package/dist/schema/build.js.map +1 -1
  67. package/dist/schema/traverseFields.d.ts.map +1 -1
  68. package/dist/schema/traverseFields.js +2 -4
  69. package/dist/schema/traverseFields.js.map +1 -1
  70. package/dist/types.d.ts +72 -28
  71. package/dist/types.d.ts.map +1 -1
  72. package/dist/types.js.map +1 -1
  73. package/package.json +6 -6
  74. package/dist/count.d.ts +0 -3
  75. package/dist/count.d.ts.map +0 -1
  76. package/dist/count.js +0 -41
  77. package/dist/count.js.map +0 -1
  78. package/dist/create.d.ts +0 -3
  79. package/dist/create.d.ts.map +0 -1
  80. package/dist/create.js +0 -19
  81. package/dist/create.js.map +0 -1
  82. package/dist/createGlobal.d.ts +0 -4
  83. package/dist/createGlobal.d.ts.map +0 -1
  84. package/dist/createGlobal.js +0 -19
  85. package/dist/createGlobal.js.map +0 -1
  86. package/dist/createGlobalVersion.d.ts +0 -4
  87. package/dist/createGlobalVersion.d.ts.map +0 -1
  88. package/dist/createGlobalVersion.js +0 -33
  89. package/dist/createGlobalVersion.js.map +0 -1
  90. package/dist/createVersion.d.ts +0 -4
  91. package/dist/createVersion.d.ts.map +0 -1
  92. package/dist/createVersion.js +0 -40
  93. package/dist/createVersion.js.map +0 -1
  94. package/dist/deleteMany.d.ts +0 -3
  95. package/dist/deleteMany.d.ts.map +0 -1
  96. package/dist/deleteMany.js +0 -28
  97. package/dist/deleteMany.js.map +0 -1
  98. package/dist/deleteOne.d.ts +0 -3
  99. package/dist/deleteOne.d.ts.map +0 -1
  100. package/dist/deleteOne.js +0 -59
  101. package/dist/deleteOne.js.map +0 -1
  102. package/dist/deleteVersions.d.ts +0 -3
  103. package/dist/deleteVersions.d.ts.map +0 -1
  104. package/dist/deleteVersions.js +0 -31
  105. package/dist/deleteVersions.js.map +0 -1
  106. package/dist/destroy.d.ts +0 -3
  107. package/dist/destroy.d.ts.map +0 -1
  108. package/dist/destroy.js +0 -15
  109. package/dist/destroy.js.map +0 -1
  110. package/dist/find/buildFindManyArgs.d.ts +0 -17
  111. package/dist/find/buildFindManyArgs.d.ts.map +0 -1
  112. package/dist/find/buildFindManyArgs.js +0 -65
  113. package/dist/find/buildFindManyArgs.js.map +0 -1
  114. package/dist/find/chainMethods.d.ts +0 -16
  115. package/dist/find/chainMethods.d.ts.map +0 -1
  116. package/dist/find/chainMethods.js +0 -12
  117. package/dist/find/chainMethods.js.map +0 -1
  118. package/dist/find/findMany.d.ts +0 -21
  119. package/dist/find/findMany.d.ts.map +0 -1
  120. package/dist/find/findMany.js +0 -152
  121. package/dist/find/findMany.js.map +0 -1
  122. package/dist/find/traverseFields.d.ts +0 -17
  123. package/dist/find/traverseFields.d.ts.map +0 -1
  124. package/dist/find/traverseFields.js +0 -156
  125. package/dist/find/traverseFields.js.map +0 -1
  126. package/dist/find.d.ts +0 -3
  127. package/dist/find.d.ts.map +0 -1
  128. package/dist/find.js +0 -21
  129. package/dist/find.js.map +0 -1
  130. package/dist/findGlobal.d.ts +0 -3
  131. package/dist/findGlobal.d.ts.map +0 -1
  132. package/dist/findGlobal.js +0 -23
  133. package/dist/findGlobal.js.map +0 -1
  134. package/dist/findGlobalVersions.d.ts +0 -3
  135. package/dist/findGlobalVersions.d.ts.map +0 -1
  136. package/dist/findGlobalVersions.js +0 -24
  137. package/dist/findGlobalVersions.js.map +0 -1
  138. package/dist/findOne.d.ts +0 -4
  139. package/dist/findOne.d.ts.map +0 -1
  140. package/dist/findOne.js +0 -21
  141. package/dist/findOne.js.map +0 -1
  142. package/dist/findVersions.d.ts +0 -3
  143. package/dist/findVersions.d.ts.map +0 -1
  144. package/dist/findVersions.js +0 -24
  145. package/dist/findVersions.js.map +0 -1
  146. package/dist/migrate.d.ts +0 -3
  147. package/dist/migrate.d.ts.map +0 -1
  148. package/dist/migrate.js +0 -99
  149. package/dist/migrate.js.map +0 -1
  150. package/dist/migrateDown.d.ts +0 -3
  151. package/dist/migrateDown.d.ts.map +0 -1
  152. package/dist/migrateDown.js +0 -63
  153. package/dist/migrateDown.js.map +0 -1
  154. package/dist/migrateFresh.d.ts +0 -8
  155. package/dist/migrateFresh.d.ts.map +0 -1
  156. package/dist/migrateFresh.js +0 -72
  157. package/dist/migrateFresh.js.map +0 -1
  158. package/dist/migrateRefresh.d.ts +0 -6
  159. package/dist/migrateRefresh.d.ts.map +0 -1
  160. package/dist/migrateRefresh.js +0 -102
  161. package/dist/migrateRefresh.js.map +0 -1
  162. package/dist/migrateReset.d.ts +0 -6
  163. package/dist/migrateReset.d.ts.map +0 -1
  164. package/dist/migrateReset.js +0 -82
  165. package/dist/migrateReset.js.map +0 -1
  166. package/dist/migrateStatus.d.ts +0 -3
  167. package/dist/migrateStatus.d.ts.map +0 -1
  168. package/dist/migrateStatus.js +0 -44
  169. package/dist/migrateStatus.js.map +0 -1
  170. package/dist/queries/buildAndOrConditions.d.ts +0 -16
  171. package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
  172. package/dist/queries/buildAndOrConditions.js +0 -28
  173. package/dist/queries/buildAndOrConditions.js.map +0 -1
  174. package/dist/queries/buildQuery.d.ts +0 -30
  175. package/dist/queries/buildQuery.d.ts.map +0 -1
  176. package/dist/queries/buildQuery.js +0 -72
  177. package/dist/queries/buildQuery.js.map +0 -1
  178. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  179. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  180. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  181. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  182. package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
  183. package/dist/queries/createJSONQuery/index.js.map +0 -1
  184. package/dist/queries/getTableColumnFromPath.d.ts +0 -50
  185. package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
  186. package/dist/queries/getTableColumnFromPath.js +0 -516
  187. package/dist/queries/getTableColumnFromPath.js.map +0 -1
  188. package/dist/queries/operatorMap.d.ts +0 -18
  189. package/dist/queries/operatorMap.d.ts.map +0 -1
  190. package/dist/queries/operatorMap.js +0 -24
  191. package/dist/queries/operatorMap.js.map +0 -1
  192. package/dist/queries/parseParams.d.ts +0 -16
  193. package/dist/queries/parseParams.d.ts.map +0 -1
  194. package/dist/queries/parseParams.js +0 -183
  195. package/dist/queries/parseParams.js.map +0 -1
  196. package/dist/queries/sanitizeQueryValue.d.ts +0 -15
  197. package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
  198. package/dist/queries/sanitizeQueryValue.js +0 -89
  199. package/dist/queries/sanitizeQueryValue.js.map +0 -1
  200. package/dist/queries/selectDistinct.d.ts +0 -22
  201. package/dist/queries/selectDistinct.d.ts.map +0 -1
  202. package/dist/queries/selectDistinct.js +0 -30
  203. package/dist/queries/selectDistinct.js.map +0 -1
  204. package/dist/queryDrafts.d.ts +0 -3
  205. package/dist/queryDrafts.d.ts.map +0 -1
  206. package/dist/queryDrafts.js +0 -40
  207. package/dist/queryDrafts.js.map +0 -1
  208. package/dist/schema/createTableName.d.ts +0 -30
  209. package/dist/schema/createTableName.d.ts.map +0 -1
  210. package/dist/schema/createTableName.js +0 -31
  211. package/dist/schema/createTableName.js.map +0 -1
  212. package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
  213. package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
  214. package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
  215. package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
  216. package/dist/transactions/beginTransaction.d.ts +0 -3
  217. package/dist/transactions/beginTransaction.d.ts.map +0 -1
  218. package/dist/transactions/beginTransaction.js +0 -51
  219. package/dist/transactions/beginTransaction.js.map +0 -1
  220. package/dist/transactions/commitTransaction.d.ts +0 -3
  221. package/dist/transactions/commitTransaction.d.ts.map +0 -1
  222. package/dist/transactions/commitTransaction.js +0 -15
  223. package/dist/transactions/commitTransaction.js.map +0 -1
  224. package/dist/transactions/rollbackTransaction.d.ts +0 -3
  225. package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
  226. package/dist/transactions/rollbackTransaction.js +0 -14
  227. package/dist/transactions/rollbackTransaction.js.map +0 -1
  228. package/dist/transform/read/hasManyNumber.d.ts +0 -10
  229. package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
  230. package/dist/transform/read/hasManyNumber.js +0 -10
  231. package/dist/transform/read/hasManyNumber.js.map +0 -1
  232. package/dist/transform/read/hasManyText.d.ts +0 -10
  233. package/dist/transform/read/hasManyText.d.ts.map +0 -1
  234. package/dist/transform/read/hasManyText.js +0 -10
  235. package/dist/transform/read/hasManyText.js.map +0 -1
  236. package/dist/transform/read/index.d.ts +0 -13
  237. package/dist/transform/read/index.d.ts.map +0 -1
  238. package/dist/transform/read/index.js +0 -44
  239. package/dist/transform/read/index.js.map +0 -1
  240. package/dist/transform/read/relationship.d.ts +0 -10
  241. package/dist/transform/read/relationship.d.ts.map +0 -1
  242. package/dist/transform/read/relationship.js +0 -60
  243. package/dist/transform/read/relationship.js.map +0 -1
  244. package/dist/transform/read/traverseFields.d.ts +0 -57
  245. package/dist/transform/read/traverseFields.d.ts.map +0 -1
  246. package/dist/transform/read/traverseFields.js +0 -435
  247. package/dist/transform/read/traverseFields.js.map +0 -1
  248. package/dist/transform/write/array.d.ts +0 -26
  249. package/dist/transform/write/array.d.ts.map +0 -1
  250. package/dist/transform/write/array.js +0 -58
  251. package/dist/transform/write/array.js.map +0 -1
  252. package/dist/transform/write/blocks.d.ts +0 -25
  253. package/dist/transform/write/blocks.d.ts.map +0 -1
  254. package/dist/transform/write/blocks.js +0 -54
  255. package/dist/transform/write/blocks.js.map +0 -1
  256. package/dist/transform/write/index.d.ts +0 -13
  257. package/dist/transform/write/index.d.ts.map +0 -1
  258. package/dist/transform/write/index.js +0 -41
  259. package/dist/transform/write/index.js.map +0 -1
  260. package/dist/transform/write/numbers.d.ts +0 -8
  261. package/dist/transform/write/numbers.d.ts.map +0 -1
  262. package/dist/transform/write/numbers.js +0 -11
  263. package/dist/transform/write/numbers.js.map +0 -1
  264. package/dist/transform/write/relationships.d.ts +0 -10
  265. package/dist/transform/write/relationships.d.ts.map +0 -1
  266. package/dist/transform/write/relationships.js +0 -23
  267. package/dist/transform/write/relationships.js.map +0 -1
  268. package/dist/transform/write/selects.d.ts +0 -8
  269. package/dist/transform/write/selects.d.ts.map +0 -1
  270. package/dist/transform/write/selects.js +0 -20
  271. package/dist/transform/write/selects.js.map +0 -1
  272. package/dist/transform/write/texts.d.ts +0 -8
  273. package/dist/transform/write/texts.d.ts.map +0 -1
  274. package/dist/transform/write/texts.js +0 -11
  275. package/dist/transform/write/texts.js.map +0 -1
  276. package/dist/transform/write/traverseFields.d.ts +0 -50
  277. package/dist/transform/write/traverseFields.d.ts.map +0 -1
  278. package/dist/transform/write/traverseFields.js +0 -445
  279. package/dist/transform/write/traverseFields.js.map +0 -1
  280. package/dist/transform/write/types.d.ts +0 -43
  281. package/dist/transform/write/types.d.ts.map +0 -1
  282. package/dist/transform/write/types.js +0 -3
  283. package/dist/transform/write/types.js.map +0 -1
  284. package/dist/update.d.ts +0 -3
  285. package/dist/update.d.ts.map +0 -1
  286. package/dist/update.js +0 -54
  287. package/dist/update.js.map +0 -1
  288. package/dist/updateGlobal.d.ts +0 -4
  289. package/dist/updateGlobal.d.ts.map +0 -1
  290. package/dist/updateGlobal.js +0 -25
  291. package/dist/updateGlobal.js.map +0 -1
  292. package/dist/updateGlobalVersion.d.ts +0 -4
  293. package/dist/updateGlobalVersion.d.ts.map +0 -1
  294. package/dist/updateGlobalVersion.js +0 -36
  295. package/dist/updateGlobalVersion.js.map +0 -1
  296. package/dist/updateVersion.d.ts +0 -4
  297. package/dist/updateVersion.d.ts.map +0 -1
  298. package/dist/updateVersion.js +0 -36
  299. package/dist/updateVersion.js.map +0 -1
  300. package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
  301. package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
  302. package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
  303. package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
  304. package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
  305. package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
  306. package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
  307. package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
  308. package/dist/upsertRow/index.d.ts +0 -4
  309. package/dist/upsertRow/index.d.ts.map +0 -1
  310. package/dist/upsertRow/index.js +0 -281
  311. package/dist/upsertRow/index.js.map +0 -1
  312. package/dist/upsertRow/insertArrays.d.ts +0 -13
  313. package/dist/upsertRow/insertArrays.d.ts.map +0 -1
  314. package/dist/upsertRow/insertArrays.js +0 -68
  315. package/dist/upsertRow/insertArrays.js.map +0 -1
  316. package/dist/upsertRow/types.d.ts +0 -32
  317. package/dist/upsertRow/types.d.ts.map +0 -1
  318. package/dist/upsertRow/types.js +0 -3
  319. package/dist/upsertRow/types.js.map +0 -1
  320. package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
  321. package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
  322. package/dist/utilities/appendPrefixToKeys.js +0 -6
  323. package/dist/utilities/appendPrefixToKeys.js.map +0 -1
  324. package/dist/utilities/createBlocksMap.d.ts +0 -5
  325. package/dist/utilities/createBlocksMap.d.ts.map +0 -1
  326. package/dist/utilities/createBlocksMap.js +0 -29
  327. package/dist/utilities/createBlocksMap.js.map +0 -1
  328. package/dist/utilities/createMigrationTable.d.ts +0 -3
  329. package/dist/utilities/createMigrationTable.d.ts.map +0 -1
  330. package/dist/utilities/createMigrationTable.js +0 -13
  331. package/dist/utilities/createMigrationTable.js.map +0 -1
  332. package/dist/utilities/createRelationshipMap.d.ts +0 -2
  333. package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
  334. package/dist/utilities/createRelationshipMap.js +0 -19
  335. package/dist/utilities/createRelationshipMap.js.map +0 -1
  336. package/dist/utilities/hasLocalesTable.d.ts +0 -3
  337. package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
  338. package/dist/utilities/hasLocalesTable.js +0 -11
  339. package/dist/utilities/hasLocalesTable.js.map +0 -1
  340. package/dist/utilities/isArrayOfRows.d.ts +0 -2
  341. package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
  342. package/dist/utilities/isArrayOfRows.js +0 -5
  343. package/dist/utilities/isArrayOfRows.js.map +0 -1
  344. package/dist/utilities/migrationTableExists.d.ts +0 -3
  345. package/dist/utilities/migrationTableExists.d.ts.map +0 -1
  346. package/dist/utilities/migrationTableExists.js +0 -9
  347. package/dist/utilities/migrationTableExists.js.map +0 -1
  348. package/dist/utilities/parseError.d.ts +0 -5
  349. package/dist/utilities/parseError.d.ts.map +0 -1
  350. package/dist/utilities/parseError.js +0 -17
  351. package/dist/utilities/parseError.js.map +0 -1
  352. package/dist/utilities/pushDevSchema.d.ts +0 -9
  353. package/dist/utilities/pushDevSchema.d.ts.map +0 -1
  354. package/dist/utilities/pushDevSchema.js +0 -58
  355. package/dist/utilities/pushDevSchema.js.map +0 -1
  356. /package/dist/{queries/createJSONQuery → createJSONQuery}/convertPathToJSONTraversal.d.ts +0 -0
  357. /package/dist/{queries/createJSONQuery → createJSONQuery}/convertPathToJSONTraversal.js +0 -0
  358. /package/dist/{queries/createJSONQuery → createJSONQuery}/formatJSONPathSegment.d.ts +0 -0
  359. /package/dist/{queries/createJSONQuery → createJSONQuery}/formatJSONPathSegment.js +0 -0
  360. /package/dist/{queries/createJSONQuery → createJSONQuery}/index.d.ts +0 -0
  361. /package/dist/{queries/createJSONQuery → createJSONQuery}/index.js +0 -0
@@ -1,445 +0,0 @@
1
- /* eslint-disable no-param-reassign */ import { fieldAffectsData } from 'payload/shared';
2
- import toSnakeCase from 'to-snake-case';
3
- import { isArrayOfRows } from '../../utilities/isArrayOfRows.js';
4
- import { transformArray } from './array.js';
5
- import { transformBlocks } from './blocks.js';
6
- import { transformNumbers } from './numbers.js';
7
- import { transformRelationship } from './relationships.js';
8
- import { transformSelects } from './selects.js';
9
- import { transformTexts } from './texts.js';
10
- export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksToDelete, columnPrefix, data, existingLocales, fieldPrefix, fields, forcedLocale, locales, numbers, parentTableName, path, relationships, relationshipsToDelete, row, selects, texts })=>{
11
- fields.forEach((field)=>{
12
- let columnName = '';
13
- let fieldName = '';
14
- let fieldData;
15
- if (fieldAffectsData(field)) {
16
- columnName = `${columnPrefix || ''}${toSnakeCase(field.name)}`;
17
- fieldName = `${fieldPrefix || ''}${field.name}`;
18
- fieldData = data[field.name];
19
- }
20
- if (field.type === 'array') {
21
- const arrayTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`);
22
- if (!arrays[arrayTableName]) arrays[arrayTableName] = [];
23
- if (field.localized) {
24
- if (typeof data[field.name] === 'object' && data[field.name] !== null) {
25
- Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
26
- if (Array.isArray(localeData)) {
27
- const newRows = transformArray({
28
- adapter,
29
- arrayTableName,
30
- baseTableName,
31
- blocks,
32
- blocksToDelete,
33
- data: localeData,
34
- field,
35
- locale: localeKey,
36
- numbers,
37
- path,
38
- relationships,
39
- relationshipsToDelete,
40
- selects,
41
- texts
42
- });
43
- arrays[arrayTableName] = arrays[arrayTableName].concat(newRows);
44
- }
45
- });
46
- }
47
- } else {
48
- const newRows = transformArray({
49
- adapter,
50
- arrayTableName,
51
- baseTableName,
52
- blocks,
53
- blocksToDelete,
54
- data: data[field.name],
55
- field,
56
- numbers,
57
- path,
58
- relationships,
59
- relationshipsToDelete,
60
- selects,
61
- texts
62
- });
63
- arrays[arrayTableName] = arrays[arrayTableName].concat(newRows);
64
- }
65
- return;
66
- }
67
- if (field.type === 'blocks') {
68
- field.blocks.forEach(({ slug })=>{
69
- blocksToDelete.add(toSnakeCase(slug));
70
- });
71
- if (field.localized) {
72
- if (typeof data[field.name] === 'object' && data[field.name] !== null) {
73
- Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
74
- if (Array.isArray(localeData)) {
75
- transformBlocks({
76
- adapter,
77
- baseTableName,
78
- blocks,
79
- blocksToDelete,
80
- data: localeData,
81
- field,
82
- locale: localeKey,
83
- numbers,
84
- path,
85
- relationships,
86
- relationshipsToDelete,
87
- selects,
88
- texts
89
- });
90
- }
91
- });
92
- }
93
- } else if (isArrayOfRows(fieldData)) {
94
- transformBlocks({
95
- adapter,
96
- baseTableName,
97
- blocks,
98
- blocksToDelete,
99
- data: fieldData,
100
- field,
101
- numbers,
102
- path,
103
- relationships,
104
- relationshipsToDelete,
105
- selects,
106
- texts
107
- });
108
- }
109
- return;
110
- }
111
- if (field.type === 'group') {
112
- if (typeof data[field.name] === 'object' && data[field.name] !== null) {
113
- if (field.localized) {
114
- Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
115
- traverseFields({
116
- adapter,
117
- arrays,
118
- baseTableName,
119
- blocks,
120
- blocksToDelete,
121
- columnPrefix: `${columnName}_`,
122
- data: localeData,
123
- existingLocales,
124
- fieldPrefix: `${fieldName}_`,
125
- fields: field.fields,
126
- forcedLocale: localeKey,
127
- locales,
128
- numbers,
129
- parentTableName,
130
- path: `${path || ''}${field.name}.`,
131
- relationships,
132
- relationshipsToDelete,
133
- row,
134
- selects,
135
- texts
136
- });
137
- });
138
- } else {
139
- traverseFields({
140
- adapter,
141
- arrays,
142
- baseTableName,
143
- blocks,
144
- blocksToDelete,
145
- columnPrefix: `${columnName}_`,
146
- data: data[field.name],
147
- existingLocales,
148
- fieldPrefix: `${fieldName}_`,
149
- fields: field.fields,
150
- locales,
151
- numbers,
152
- parentTableName,
153
- path: `${path || ''}${field.name}.`,
154
- relationships,
155
- relationshipsToDelete,
156
- row,
157
- selects,
158
- texts
159
- });
160
- }
161
- }
162
- return;
163
- }
164
- if (field.type === 'tabs') {
165
- field.tabs.forEach((tab)=>{
166
- if ('name' in tab) {
167
- if (typeof data[tab.name] === 'object' && data[tab.name] !== null) {
168
- if (tab.localized) {
169
- Object.entries(data[tab.name]).forEach(([localeKey, localeData])=>{
170
- traverseFields({
171
- adapter,
172
- arrays,
173
- baseTableName,
174
- blocks,
175
- blocksToDelete,
176
- columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,
177
- data: localeData,
178
- existingLocales,
179
- fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,
180
- fields: tab.fields,
181
- forcedLocale: localeKey,
182
- locales,
183
- numbers,
184
- parentTableName,
185
- path: `${path || ''}${tab.name}.`,
186
- relationships,
187
- relationshipsToDelete,
188
- row,
189
- selects,
190
- texts
191
- });
192
- });
193
- } else {
194
- traverseFields({
195
- adapter,
196
- arrays,
197
- baseTableName,
198
- blocks,
199
- blocksToDelete,
200
- columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,
201
- data: data[tab.name],
202
- existingLocales,
203
- fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,
204
- fields: tab.fields,
205
- locales,
206
- numbers,
207
- parentTableName,
208
- path: `${path || ''}${tab.name}.`,
209
- relationships,
210
- relationshipsToDelete,
211
- row,
212
- selects,
213
- texts
214
- });
215
- }
216
- }
217
- } else {
218
- traverseFields({
219
- adapter,
220
- arrays,
221
- baseTableName,
222
- blocks,
223
- blocksToDelete,
224
- columnPrefix,
225
- data,
226
- existingLocales,
227
- fieldPrefix,
228
- fields: tab.fields,
229
- locales,
230
- numbers,
231
- parentTableName,
232
- path,
233
- relationships,
234
- relationshipsToDelete,
235
- row,
236
- selects,
237
- texts
238
- });
239
- }
240
- });
241
- }
242
- if (field.type === 'row' || field.type === 'collapsible') {
243
- traverseFields({
244
- adapter,
245
- arrays,
246
- baseTableName,
247
- blocks,
248
- blocksToDelete,
249
- columnPrefix,
250
- data,
251
- existingLocales,
252
- fieldPrefix,
253
- fields: field.fields,
254
- locales,
255
- numbers,
256
- parentTableName,
257
- path,
258
- relationships,
259
- relationshipsToDelete,
260
- row,
261
- selects,
262
- texts
263
- });
264
- }
265
- if (field.type === 'relationship' || field.type === 'upload') {
266
- const relationshipPath = `${path || ''}${field.name}`;
267
- if (field.localized && (Array.isArray(field.relationTo) || 'hasMany' in field && field.hasMany)) {
268
- if (typeof fieldData === 'object') {
269
- Object.entries(fieldData).forEach(([localeKey, localeData])=>{
270
- if (localeData === null) {
271
- relationshipsToDelete.push({
272
- locale: localeKey,
273
- path: relationshipPath
274
- });
275
- return;
276
- }
277
- transformRelationship({
278
- baseRow: {
279
- locale: localeKey,
280
- path: relationshipPath
281
- },
282
- data: localeData,
283
- field,
284
- relationships
285
- });
286
- });
287
- }
288
- return;
289
- } else if (Array.isArray(field.relationTo) || 'hasMany' in field && field.hasMany) {
290
- if (fieldData === null || Array.isArray(fieldData) && fieldData.length === 0) {
291
- relationshipsToDelete.push({
292
- path: relationshipPath
293
- });
294
- return;
295
- }
296
- transformRelationship({
297
- baseRow: {
298
- path: relationshipPath
299
- },
300
- data: fieldData,
301
- field,
302
- relationships
303
- });
304
- return;
305
- } else {
306
- if (!field.localized && fieldData && typeof fieldData === 'object' && 'id' in fieldData && fieldData?.id) {
307
- fieldData = fieldData.id;
308
- } else if (field.localized) {
309
- if (typeof fieldData === 'object') {
310
- Object.entries(fieldData).forEach(([localeKey, localeData])=>{
311
- if (typeof localeData === 'object') {
312
- if (localeData && 'id' in localeData && localeData?.id) {
313
- fieldData[localeKey] = localeData.id;
314
- }
315
- } else {
316
- fieldData[localeKey] = localeData;
317
- }
318
- });
319
- }
320
- }
321
- }
322
- }
323
- if (field.type === 'text' && field.hasMany) {
324
- const textPath = `${path || ''}${field.name}`;
325
- if (field.localized) {
326
- if (typeof fieldData === 'object') {
327
- Object.entries(fieldData).forEach(([localeKey, localeData])=>{
328
- if (Array.isArray(localeData)) {
329
- transformTexts({
330
- baseRow: {
331
- locale: localeKey,
332
- path: textPath
333
- },
334
- data: localeData,
335
- texts
336
- });
337
- }
338
- });
339
- }
340
- } else if (Array.isArray(fieldData)) {
341
- transformTexts({
342
- baseRow: {
343
- path: textPath
344
- },
345
- data: fieldData,
346
- texts
347
- });
348
- }
349
- return;
350
- }
351
- if (field.type === 'number' && field.hasMany) {
352
- const numberPath = `${path || ''}${field.name}`;
353
- if (field.localized) {
354
- if (typeof fieldData === 'object') {
355
- Object.entries(fieldData).forEach(([localeKey, localeData])=>{
356
- if (Array.isArray(localeData)) {
357
- transformNumbers({
358
- baseRow: {
359
- locale: localeKey,
360
- path: numberPath
361
- },
362
- data: localeData,
363
- numbers
364
- });
365
- }
366
- });
367
- }
368
- } else if (Array.isArray(fieldData)) {
369
- transformNumbers({
370
- baseRow: {
371
- path: numberPath
372
- },
373
- data: fieldData,
374
- numbers
375
- });
376
- }
377
- return;
378
- }
379
- if (field.type === 'select' && field.hasMany) {
380
- const selectTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`);
381
- if (!selects[selectTableName]) selects[selectTableName] = [];
382
- if (field.localized) {
383
- if (typeof data[field.name] === 'object' && data[field.name] !== null) {
384
- Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
385
- if (Array.isArray(localeData)) {
386
- const newRows = transformSelects({
387
- id: data._uuid || data.id,
388
- data: localeData,
389
- locale: localeKey
390
- });
391
- selects[selectTableName] = selects[selectTableName].concat(newRows);
392
- }
393
- });
394
- }
395
- } else if (Array.isArray(data[field.name])) {
396
- const newRows = transformSelects({
397
- id: data._uuid || data.id,
398
- data: data[field.name]
399
- });
400
- selects[selectTableName] = selects[selectTableName].concat(newRows);
401
- }
402
- return;
403
- }
404
- if (fieldAffectsData(field)) {
405
- const valuesToTransform = [];
406
- if (field.localized) {
407
- if (typeof fieldData === 'object' && fieldData !== null) {
408
- Object.entries(fieldData).forEach(([localeKey, localeData])=>{
409
- if (!locales[localeKey]) locales[localeKey] = {};
410
- valuesToTransform.push({
411
- localeKey,
412
- ref: locales,
413
- value: localeData
414
- });
415
- });
416
- }
417
- } else {
418
- let ref = row;
419
- if (forcedLocale) {
420
- if (!locales[forcedLocale]) locales[forcedLocale] = {};
421
- ref = locales[forcedLocale];
422
- }
423
- valuesToTransform.push({
424
- ref,
425
- value: fieldData
426
- });
427
- }
428
- valuesToTransform.forEach(({ localeKey, ref, value })=>{
429
- if (typeof value !== 'undefined') {
430
- let formattedValue = value;
431
- if (field.type === 'date' && field.name === 'updatedAt') {
432
- formattedValue = new Date().toISOString();
433
- }
434
- if (localeKey) {
435
- ref[localeKey][fieldName] = formattedValue;
436
- } else {
437
- ref[fieldName] = formattedValue;
438
- }
439
- }
440
- });
441
- }
442
- });
443
- };
444
-
445
- //# sourceMappingURL=traverseFields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/transform/write/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Field } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { ArrayRowToInsert, BlockRowToInsert, RelationshipToDelete } from './types.js'\n\nimport { isArrayOfRows } from '../../utilities/isArrayOfRows.js'\nimport { transformArray } from './array.js'\nimport { transformBlocks } from './blocks.js'\nimport { transformNumbers } from './numbers.js'\nimport { transformRelationship } from './relationships.js'\nimport { transformSelects } from './selects.js'\nimport { transformTexts } from './texts.js'\n\ntype Args = {\n adapter: PostgresAdapter\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n /**\n * This is the name of the base table\n */\n baseTableName: string\n blocks: {\n [blockType: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n /**\n * A snake-case field prefix, representing prior fields\n * Ex: my_group_my_named_tab_\n */\n columnPrefix: string\n data: Record<string, unknown>\n existingLocales?: Record<string, unknown>[]\n /**\n * A prefix that will retain camel-case formatting, representing prior fields\n * Ex: myGroup_myNamedTab_\n */\n fieldPrefix: string\n fields: Field[]\n forcedLocale?: string\n locales: {\n [locale: string]: Record<string, unknown>\n }\n numbers: Record<string, unknown>[]\n /**\n * This is the name of the parent table\n */\n parentTableName: string\n path: string\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\n row: Record<string, unknown>\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n texts: Record<string, unknown>[]\n}\n\nexport const traverseFields = ({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields,\n forcedLocale,\n locales,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n}: Args) => {\n fields.forEach((field) => {\n let columnName = ''\n let fieldName = ''\n let fieldData: unknown\n\n if (fieldAffectsData(field)) {\n columnName = `${columnPrefix || ''}${toSnakeCase(field.name)}`\n fieldName = `${fieldPrefix || ''}${field.name}`\n fieldData = data[field.name]\n }\n\n if (field.type === 'array') {\n const arrayTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`)\n\n if (!arrays[arrayTableName]) arrays[arrayTableName] = []\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n const newRows = transformArray({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data: localeData,\n field,\n locale: localeKey,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n\n arrays[arrayTableName] = arrays[arrayTableName].concat(newRows)\n }\n })\n }\n } else {\n const newRows = transformArray({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data: data[field.name],\n field,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n\n arrays[arrayTableName] = arrays[arrayTableName].concat(newRows)\n }\n\n return\n }\n\n if (field.type === 'blocks') {\n field.blocks.forEach(({ slug }) => {\n blocksToDelete.add(toSnakeCase(slug))\n })\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformBlocks({\n adapter,\n baseTableName,\n blocks,\n blocksToDelete,\n data: localeData,\n field,\n locale: localeKey,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n }\n })\n }\n } else if (isArrayOfRows(fieldData)) {\n transformBlocks({\n adapter,\n baseTableName,\n blocks,\n blocksToDelete,\n data: fieldData,\n field,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n }\n\n return\n }\n\n if (field.type === 'group') {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n if (field.localized) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnName}_`,\n data: localeData as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldName}_`,\n fields: field.fields,\n forcedLocale: localeKey,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${field.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n })\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnName}_`,\n data: data[field.name] as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldName}_`,\n fields: field.fields,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${field.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n }\n\n return\n }\n\n if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n if ('name' in tab) {\n if (typeof data[tab.name] === 'object' && data[tab.name] !== null) {\n if (tab.localized) {\n Object.entries(data[tab.name]).forEach(([localeKey, localeData]) => {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,\n data: localeData as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,\n fields: tab.fields,\n forcedLocale: localeKey,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${tab.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n })\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,\n data: data[tab.name] as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,\n fields: tab.fields,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${tab.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n }\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields: tab.fields,\n locales,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n })\n }\n\n if (field.type === 'row' || field.type === 'collapsible') {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields: field.fields,\n locales,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n const relationshipPath = `${path || ''}${field.name}`\n\n if (\n field.localized &&\n (Array.isArray(field.relationTo) || ('hasMany' in field && field.hasMany))\n ) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (localeData === null) {\n relationshipsToDelete.push({\n locale: localeKey,\n path: relationshipPath,\n })\n return\n }\n\n transformRelationship({\n baseRow: {\n locale: localeKey,\n path: relationshipPath,\n },\n data: localeData,\n field,\n relationships,\n })\n })\n }\n return\n } else if (Array.isArray(field.relationTo) || ('hasMany' in field && field.hasMany)) {\n if (fieldData === null || (Array.isArray(fieldData) && fieldData.length === 0)) {\n relationshipsToDelete.push({ path: relationshipPath })\n return\n }\n\n transformRelationship({\n baseRow: {\n path: relationshipPath,\n },\n data: fieldData,\n field,\n relationships,\n })\n return\n } else {\n if (\n !field.localized &&\n fieldData &&\n typeof fieldData === 'object' &&\n 'id' in fieldData &&\n fieldData?.id\n ) {\n fieldData = fieldData.id\n } else if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (typeof localeData === 'object') {\n if (localeData && 'id' in localeData && localeData?.id) {\n fieldData[localeKey] = localeData.id\n }\n } else {\n fieldData[localeKey] = localeData\n }\n })\n }\n }\n }\n }\n\n if (field.type === 'text' && field.hasMany) {\n const textPath = `${path || ''}${field.name}`\n\n if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformTexts({\n baseRow: {\n locale: localeKey,\n path: textPath,\n },\n data: localeData,\n texts,\n })\n }\n })\n }\n } else if (Array.isArray(fieldData)) {\n transformTexts({\n baseRow: {\n path: textPath,\n },\n data: fieldData,\n texts,\n })\n }\n\n return\n }\n\n if (field.type === 'number' && field.hasMany) {\n const numberPath = `${path || ''}${field.name}`\n\n if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformNumbers({\n baseRow: {\n locale: localeKey,\n path: numberPath,\n },\n data: localeData,\n numbers,\n })\n }\n })\n }\n } else if (Array.isArray(fieldData)) {\n transformNumbers({\n baseRow: {\n path: numberPath,\n },\n data: fieldData,\n numbers,\n })\n }\n\n return\n }\n\n if (field.type === 'select' && field.hasMany) {\n const selectTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`)\n if (!selects[selectTableName]) selects[selectTableName] = []\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n const newRows = transformSelects({\n id: data._uuid || data.id,\n data: localeData,\n locale: localeKey,\n })\n\n selects[selectTableName] = selects[selectTableName].concat(newRows)\n }\n })\n }\n } else if (Array.isArray(data[field.name])) {\n const newRows = transformSelects({\n id: data._uuid || data.id,\n data: data[field.name],\n })\n\n selects[selectTableName] = selects[selectTableName].concat(newRows)\n }\n\n return\n }\n\n if (fieldAffectsData(field)) {\n const valuesToTransform: { localeKey?: string; ref: unknown; value: unknown }[] = []\n\n if (field.localized) {\n if (typeof fieldData === 'object' && fieldData !== null) {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (!locales[localeKey]) locales[localeKey] = {}\n\n valuesToTransform.push({\n localeKey,\n ref: locales,\n value: localeData,\n })\n })\n }\n } else {\n let ref = row\n\n if (forcedLocale) {\n if (!locales[forcedLocale]) locales[forcedLocale] = {}\n ref = locales[forcedLocale]\n }\n\n valuesToTransform.push({ ref, value: fieldData })\n }\n\n valuesToTransform.forEach(({ localeKey, ref, value }) => {\n if (typeof value !== 'undefined') {\n let formattedValue = value\n\n if (field.type === 'date' && field.name === 'updatedAt') {\n formattedValue = new Date().toISOString()\n }\n\n if (localeKey) {\n ref[localeKey][fieldName] = formattedValue\n } else {\n ref[fieldName] = formattedValue\n }\n }\n })\n }\n })\n}\n"],"names":["fieldAffectsData","toSnakeCase","isArrayOfRows","transformArray","transformBlocks","transformNumbers","transformRelationship","transformSelects","transformTexts","traverseFields","adapter","arrays","baseTableName","blocks","blocksToDelete","columnPrefix","data","existingLocales","fieldPrefix","fields","forcedLocale","locales","numbers","parentTableName","path","relationships","relationshipsToDelete","row","selects","texts","forEach","field","columnName","fieldName","fieldData","name","type","arrayTableName","tableNameMap","get","localized","Object","entries","localeKey","localeData","Array","isArray","newRows","locale","concat","slug","add","tabs","tab","relationshipPath","relationTo","hasMany","push","baseRow","length","id","textPath","numberPath","selectTableName","_uuid","valuesToTransform","ref","value","formattedValue","Date","toISOString"],"mappings":"AAAA,oCAAoC,GAGpC,SAASA,gBAAgB,QAAQ,iBAAgB;AACjD,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,cAAc,QAAQ,aAAY;AAC3C,SAASC,eAAe,QAAQ,cAAa;AAC7C,SAASC,gBAAgB,QAAQ,eAAc;AAC/C,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,gBAAgB,QAAQ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ACvDiC,iBAAiB,IAAIC,OAAOC,WAAW;oBACzC;oBAEA,IAAI3B,WAAW;wBACbuB,GAAG,CAACvB,UAAU,CAACV,UAAU,GAAGmC;oBAC9B,OAAO;wBACLF,GAAG,CAACjC,UAAU,GAAGmC;oBACnB;gBACF;YACF;QACF;IACF;AACF,EAAC"}
@@ -1,43 +0,0 @@
1
- export type ArrayRowToInsert = {
2
- arrays: {
3
- [tableName: string]: ArrayRowToInsert[];
4
- };
5
- locales: {
6
- [locale: string]: Record<string, unknown>;
7
- };
8
- row: Record<string, unknown>;
9
- };
10
- export type BlockRowToInsert = {
11
- arrays: {
12
- [tableName: string]: ArrayRowToInsert[];
13
- };
14
- locales: {
15
- [locale: string]: Record<string, unknown>;
16
- };
17
- row: Record<string, unknown>;
18
- };
19
- export type RelationshipToDelete = {
20
- locale?: string;
21
- path: string;
22
- };
23
- export type RowToInsert = {
24
- arrays: {
25
- [tableName: string]: ArrayRowToInsert[];
26
- };
27
- blocks: {
28
- [blockType: string]: BlockRowToInsert[];
29
- };
30
- blocksToDelete: Set<string>;
31
- locales: {
32
- [locale: string]: Record<string, unknown>;
33
- };
34
- numbers: Record<string, unknown>[];
35
- relationships: Record<string, unknown>[];
36
- relationshipsToDelete: RelationshipToDelete[];
37
- row: Record<string, unknown>;
38
- selects: {
39
- [tableName: string]: Record<string, unknown>[];
40
- };
41
- texts: Record<string, unknown>[];
42
- };
43
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/transform/write/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE;QACN,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD,OAAO,EAAE;QACP,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAC1C,CAAA;IACD,GAAG,EAAE,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C,CAAA"}
@@ -1,3 +0,0 @@
1
- export { };
2
-
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/transform/write/types.ts"],"sourcesContent":["export type ArrayRowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n locales: {\n [locale: string]: Record<string, unknown>\n }\n row: Record<string, unknown>\n}\n\nexport type BlockRowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n locales: {\n [locale: string]: Record<string, unknown>\n }\n row: Record<string, unknown>\n}\n\nexport type RelationshipToDelete = {\n locale?: string\n path: string\n}\n\nexport type RowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n blocks: {\n [blockType: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n locales: {\n [locale: string]: Record<string, unknown>\n }\n numbers: Record<string, unknown>[]\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\n row: Record<string, unknown>\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n texts: Record<string, unknown>[]\n}\n"],"names":[],"mappings":"AAyBA,WAmBC"}
package/dist/update.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { UpdateOne } from 'payload';
2
- export declare const updateOne: UpdateOne;
3
- //# sourceMappingURL=update.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAUxC,eAAO,MAAM,SAAS,EAAE,SA4CvB,CAAA"}
package/dist/update.js DELETED
@@ -1,54 +0,0 @@
1
- import toSnakeCase from 'to-snake-case';
2
- import buildQuery from './queries/buildQuery.js';
3
- import { selectDistinct } from './queries/selectDistinct.js';
4
- import { upsertRow } from './upsertRow/index.js';
5
- export const updateOne = async function updateOne({ id, collection: collectionSlug, data, draft, locale, req, where: whereArg }) {
6
- const db = this.sessions[await req.transactionID]?.db || this.drizzle;
7
- const collection = this.payload.collections[collectionSlug].config;
8
- const tableName = this.tableNameMap.get(toSnakeCase(collection.slug));
9
- const whereToUse = whereArg || {
10
- id: {
11
- equals: id
12
- }
13
- };
14
- let idToUpdate = id;
15
- const { joins, selectFields, where } = await buildQuery({
16
- adapter: this,
17
- fields: collection.fields,
18
- locale,
19
- tableName,
20
- where: whereToUse
21
- });
22
- const selectDistinctResult = await selectDistinct({
23
- adapter: this,
24
- chainedMethods: [
25
- {
26
- args: [
27
- 1
28
- ],
29
- method: 'limit'
30
- }
31
- ],
32
- db,
33
- joins,
34
- selectFields,
35
- tableName,
36
- where
37
- });
38
- if (selectDistinctResult?.[0]?.id) {
39
- idToUpdate = selectDistinctResult?.[0]?.id;
40
- }
41
- const result = await upsertRow({
42
- id: idToUpdate,
43
- adapter: this,
44
- data,
45
- db,
46
- fields: collection.fields,
47
- operation: 'update',
48
- req,
49
- tableName
50
- });
51
- return result;
52
- };
53
-
54
- //# sourceMappingURL=update.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/update.ts"],"sourcesContent":["import type { UpdateOne } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport buildQuery from './queries/buildQuery.js'\nimport { selectDistinct } from './queries/selectDistinct.js'\nimport { upsertRow } from './upsertRow/index.js'\n\nexport const updateOne: UpdateOne = async function updateOne(\n this: PostgresAdapter,\n { id, collection: collectionSlug, data, draft, locale, req, where: whereArg },\n) {\n const db = this.sessions[await req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n const whereToUse = whereArg || { id: { equals: id } }\n let idToUpdate = id\n\n const { joins, selectFields, where } = await buildQuery({\n adapter: this,\n fields: collection.fields,\n locale,\n tableName,\n where: whereToUse,\n })\n\n const selectDistinctResult = await selectDistinct({\n adapter: this,\n chainedMethods: [{ args: [1], method: 'limit' }],\n db,\n joins,\n selectFields,\n tableName,\n where,\n })\n\n if (selectDistinctResult?.[0]?.id) {\n idToUpdate = selectDistinctResult?.[0]?.id\n }\n\n const result = await upsertRow({\n id: idToUpdate,\n adapter: this,\n data,\n db,\n fields: collection.fields,\n operation: 'update',\n req,\n tableName,\n })\n\n return result\n}\n"],"names":["toSnakeCase","buildQuery","selectDistinct","upsertRow","updateOne","id","collection","collectionSlug","data","draft","locale","req","where","whereArg","db","sessions","transactionID","drizzle","payload","collections","config","tableName","tableNameMap","get","slug","whereToUse","equals","idToUpdate","joins","selectFields","adapter","fields","selectDistinctResult","chainedMethods","args","method","result","operation"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,OAAOC,gBAAgB,0BAAyB;AAChD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EAAEC,EAAE,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,OAAOC,QAAQ,EAAE;IAE7E,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAAC,MAAMJ,IAAIK,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IACrE,MAAMX,aAAa,IAAI,CAACY,OAAO,CAACC,WAAW,CAACZ,eAAe,CAACa,MAAM;IAClE,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACvB,YAAYM,WAAWkB,IAAI;IACnE,MAAMC,aAAaZ,YAAY;QAAER,IAAI;YAAEqB,QAAQrB;QAAG;IAAE;IACpD,IAAIsB,aAAatB;IAEjB,MAAM,EAAEuB,KAAK,EAAEC,YAAY,EAAEjB,KAAK,EAAE,GAAG,MAAMX,WAAW;QACtD6B,SAAS,IAAI;QACbC,QAAQzB,WAAWyB,MAAM;QACzBrB;QACAW;QACAT,OAAOa;IACT;IAEA,MAAMO,uBAAuB,MAAM9B,eAAe;QAChD4B,SAAS,IAAI;QACbG,gBAAgB;YAAC;gBAAEC,MAAM;oBAAC;iBAAE;gBAAEC,QAAQ;YAAQ;SAAE;QAChDrB;QACAc;QACAC;QACAR;QACAT;IACF;IAEA,IAAIoB,sBAAsB,CAAC,EAAE,EAAE3B,IAAI;QACjCsB,aAAaK,sBAAsB,CAAC,EAAE,EAAE3B;IAC1C;IAEA,MAAM+B,SAAS,MAAMjC,UAAU;QAC7BE,IAAIsB;QACJG,SAAS,IAAI;QACbtB;QACAM;QACAiB,QAAQzB,WAAWyB,MAAM;QACzBM,WAAW;QACX1B;QACAU;IACF;IAEA,OAAOe;AACT,EAAC"}
@@ -1,4 +0,0 @@
1
- import type { UpdateGlobalArgs } from 'payload';
2
- import type { PostgresAdapter } from './types.js';
3
- export declare function updateGlobal<T extends Record<string, unknown>>(this: PostgresAdapter, { slug, data, req }: UpdateGlobalArgs): Promise<T>;
4
- //# sourceMappingURL=updateGlobal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"updateGlobal.d.ts","sourceRoot":"","sources":["../src/updateGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,IAAI,EAAE,eAAe,EACrB,EAAE,IAAI,EAAE,IAAI,EAAE,GAA0B,EAAE,EAAE,gBAAgB,GAC3D,OAAO,CAAC,CAAC,CAAC,CAkBZ"}