@payloadcms/db-postgres 3.0.0-canary.6041f49 → 3.0.0-canary.690108d

Sign up to get free protection for your applications and to get access to all the features.
Files changed (369) hide show
  1. package/README.md +1 -1
  2. package/dist/connect.d.ts +1 -1
  3. package/dist/connect.d.ts.map +1 -1
  4. package/dist/connect.js +22 -13
  5. package/dist/connect.js.map +1 -1
  6. package/dist/exports/migration-utils.d.ts +2 -0
  7. package/dist/exports/migration-utils.d.ts.map +1 -0
  8. package/dist/exports/migration-utils.js +3 -0
  9. package/dist/exports/migration-utils.js.map +1 -0
  10. package/dist/index.d.ts +1 -2
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +40 -67
  13. package/dist/index.js.map +1 -1
  14. package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
  15. package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
  16. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
  17. package/dist/predefinedMigrations/relationships-v2-v3.mjs +11 -0
  18. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +20 -0
  19. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
  20. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +169 -0
  21. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
  22. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
  23. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
  24. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +191 -0
  25. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
  26. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
  27. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
  28. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js +56 -0
  29. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
  30. package/dist/predefinedMigrations/v2-v3/index.d.ts +23 -0
  31. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
  32. package/dist/predefinedMigrations/v2-v3/index.js +211 -0
  33. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -0
  34. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +20 -0
  35. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
  36. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +57 -0
  37. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
  38. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +23 -0
  39. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
  40. package/dist/predefinedMigrations/v2-v3/traverseFields.js +85 -0
  41. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
  42. package/dist/predefinedMigrations/v2-v3/types.d.ts +9 -0
  43. package/dist/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
  44. package/dist/predefinedMigrations/v2-v3/types.js +6 -0
  45. package/dist/predefinedMigrations/v2-v3/types.js.map +1 -0
  46. package/dist/types.d.ts +42 -77
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/types.js.map +1 -1
  49. package/package.json +24 -15
  50. package/dist/count.d.ts +0 -3
  51. package/dist/count.d.ts.map +0 -1
  52. package/dist/count.js +0 -50
  53. package/dist/count.js.map +0 -1
  54. package/dist/create.d.ts +0 -3
  55. package/dist/create.d.ts.map +0 -1
  56. package/dist/create.js +0 -19
  57. package/dist/create.js.map +0 -1
  58. package/dist/createGlobal.d.ts +0 -5
  59. package/dist/createGlobal.d.ts.map +0 -1
  60. package/dist/createGlobal.js +0 -19
  61. package/dist/createGlobal.js.map +0 -1
  62. package/dist/createGlobalVersion.d.ts +0 -6
  63. package/dist/createGlobalVersion.d.ts.map +0 -1
  64. package/dist/createGlobalVersion.js +0 -33
  65. package/dist/createGlobalVersion.js.map +0 -1
  66. package/dist/createMigration.d.ts +0 -3
  67. package/dist/createMigration.d.ts.map +0 -1
  68. package/dist/createMigration.js +0 -81
  69. package/dist/createMigration.js.map +0 -1
  70. package/dist/createVersion.d.ts +0 -5
  71. package/dist/createVersion.d.ts.map +0 -1
  72. package/dist/createVersion.js +0 -44
  73. package/dist/createVersion.js.map +0 -1
  74. package/dist/deleteMany.d.ts +0 -3
  75. package/dist/deleteMany.d.ts.map +0 -1
  76. package/dist/deleteMany.js +0 -28
  77. package/dist/deleteMany.js.map +0 -1
  78. package/dist/deleteOne.d.ts +0 -3
  79. package/dist/deleteOne.d.ts.map +0 -1
  80. package/dist/deleteOne.js +0 -59
  81. package/dist/deleteOne.js.map +0 -1
  82. package/dist/deleteVersions.d.ts +0 -3
  83. package/dist/deleteVersions.d.ts.map +0 -1
  84. package/dist/deleteVersions.js +0 -31
  85. package/dist/deleteVersions.js.map +0 -1
  86. package/dist/destroy.d.ts +0 -3
  87. package/dist/destroy.d.ts.map +0 -1
  88. package/dist/destroy.js +0 -11
  89. package/dist/destroy.js.map +0 -1
  90. package/dist/find/buildFindManyArgs.d.ts +0 -13
  91. package/dist/find/buildFindManyArgs.d.ts.map +0 -1
  92. package/dist/find/buildFindManyArgs.js +0 -64
  93. package/dist/find/buildFindManyArgs.js.map +0 -1
  94. package/dist/find/chainMethods.d.ts +0 -16
  95. package/dist/find/chainMethods.d.ts.map +0 -1
  96. package/dist/find/chainMethods.js +0 -12
  97. package/dist/find/chainMethods.js.map +0 -1
  98. package/dist/find/findMany.d.ts +0 -22
  99. package/dist/find/findMany.d.ts.map +0 -1
  100. package/dist/find/findMany.js +0 -163
  101. package/dist/find/findMany.js.map +0 -1
  102. package/dist/find/traverseFields.d.ts +0 -16
  103. package/dist/find/traverseFields.d.ts.map +0 -1
  104. package/dist/find/traverseFields.js +0 -138
  105. package/dist/find/traverseFields.js.map +0 -1
  106. package/dist/find.d.ts +0 -3
  107. package/dist/find.d.ts.map +0 -1
  108. package/dist/find.js +0 -21
  109. package/dist/find.js.map +0 -1
  110. package/dist/findGlobal.d.ts +0 -3
  111. package/dist/findGlobal.d.ts.map +0 -1
  112. package/dist/findGlobal.js +0 -23
  113. package/dist/findGlobal.js.map +0 -1
  114. package/dist/findGlobalVersions.d.ts +0 -3
  115. package/dist/findGlobalVersions.d.ts.map +0 -1
  116. package/dist/findGlobalVersions.js +0 -24
  117. package/dist/findGlobalVersions.js.map +0 -1
  118. package/dist/findOne.d.ts +0 -5
  119. package/dist/findOne.d.ts.map +0 -1
  120. package/dist/findOne.js +0 -21
  121. package/dist/findOne.js.map +0 -1
  122. package/dist/findVersions.d.ts +0 -3
  123. package/dist/findVersions.d.ts.map +0 -1
  124. package/dist/findVersions.js +0 -24
  125. package/dist/findVersions.js.map +0 -1
  126. package/dist/init.d.ts +0 -3
  127. package/dist/init.d.ts.map +0 -1
  128. package/dist/init.js +0 -96
  129. package/dist/init.js.map +0 -1
  130. package/dist/migrate.d.ts +0 -3
  131. package/dist/migrate.d.ts.map +0 -1
  132. package/dist/migrate.js +0 -99
  133. package/dist/migrate.js.map +0 -1
  134. package/dist/migrateDown.d.ts +0 -3
  135. package/dist/migrateDown.d.ts.map +0 -1
  136. package/dist/migrateDown.js +0 -63
  137. package/dist/migrateDown.js.map +0 -1
  138. package/dist/migrateFresh.d.ts +0 -8
  139. package/dist/migrateFresh.d.ts.map +0 -1
  140. package/dist/migrateFresh.js +0 -72
  141. package/dist/migrateFresh.js.map +0 -1
  142. package/dist/migrateRefresh.d.ts +0 -6
  143. package/dist/migrateRefresh.d.ts.map +0 -1
  144. package/dist/migrateRefresh.js +0 -102
  145. package/dist/migrateRefresh.js.map +0 -1
  146. package/dist/migrateReset.d.ts +0 -6
  147. package/dist/migrateReset.d.ts.map +0 -1
  148. package/dist/migrateReset.js +0 -82
  149. package/dist/migrateReset.js.map +0 -1
  150. package/dist/migrateStatus.d.ts +0 -3
  151. package/dist/migrateStatus.d.ts.map +0 -1
  152. package/dist/migrateStatus.js +0 -44
  153. package/dist/migrateStatus.js.map +0 -1
  154. package/dist/queries/buildAndOrConditions.d.ts +0 -17
  155. package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
  156. package/dist/queries/buildAndOrConditions.js +0 -29
  157. package/dist/queries/buildAndOrConditions.js.map +0 -1
  158. package/dist/queries/buildQuery.d.ts +0 -31
  159. package/dist/queries/buildQuery.d.ts.map +0 -1
  160. package/dist/queries/buildQuery.js +0 -76
  161. package/dist/queries/buildQuery.js.map +0 -1
  162. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts +0 -2
  163. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  164. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +0 -14
  165. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  166. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts +0 -2
  167. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  168. package/dist/queries/createJSONQuery/formatJSONPathSegment.js +0 -5
  169. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  170. package/dist/queries/createJSONQuery/index.d.ts +0 -10
  171. package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
  172. package/dist/queries/createJSONQuery/index.js +0 -54
  173. package/dist/queries/createJSONQuery/index.js.map +0 -1
  174. package/dist/queries/getTableColumnFromPath.d.ts +0 -51
  175. package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
  176. package/dist/queries/getTableColumnFromPath.js +0 -445
  177. package/dist/queries/getTableColumnFromPath.js.map +0 -1
  178. package/dist/queries/operatorMap.d.ts +0 -18
  179. package/dist/queries/operatorMap.d.ts.map +0 -1
  180. package/dist/queries/operatorMap.js +0 -24
  181. package/dist/queries/operatorMap.js.map +0 -1
  182. package/dist/queries/parseParams.d.ts +0 -17
  183. package/dist/queries/parseParams.d.ts.map +0 -1
  184. package/dist/queries/parseParams.js +0 -182
  185. package/dist/queries/parseParams.js.map +0 -1
  186. package/dist/queries/sanitizeQueryValue.d.ts +0 -15
  187. package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
  188. package/dist/queries/sanitizeQueryValue.js +0 -90
  189. package/dist/queries/sanitizeQueryValue.js.map +0 -1
  190. package/dist/queries/selectDistinct.d.ts +0 -23
  191. package/dist/queries/selectDistinct.d.ts.map +0 -1
  192. package/dist/queries/selectDistinct.js +0 -41
  193. package/dist/queries/selectDistinct.js.map +0 -1
  194. package/dist/queryDrafts.d.ts +0 -3
  195. package/dist/queryDrafts.d.ts.map +0 -1
  196. package/dist/queryDrafts.js +0 -41
  197. package/dist/queryDrafts.js.map +0 -1
  198. package/dist/schema/build.d.ts +0 -30
  199. package/dist/schema/build.d.ts.map +0 -1
  200. package/dist/schema/build.js +0 -320
  201. package/dist/schema/build.js.map +0 -1
  202. package/dist/schema/createIndex.d.ts +0 -12
  203. package/dist/schema/createIndex.d.ts.map +0 -1
  204. package/dist/schema/createIndex.js +0 -18
  205. package/dist/schema/createIndex.js.map +0 -1
  206. package/dist/schema/createTableName.d.ts +0 -30
  207. package/dist/schema/createTableName.d.ts.map +0 -1
  208. package/dist/schema/createTableName.js +0 -31
  209. package/dist/schema/createTableName.js.map +0 -1
  210. package/dist/schema/idToUUID.d.ts +0 -3
  211. package/dist/schema/idToUUID.d.ts.map +0 -1
  212. package/dist/schema/idToUUID.js +0 -11
  213. package/dist/schema/idToUUID.js.map +0 -1
  214. package/dist/schema/parentIDColumnMap.d.ts +0 -4
  215. package/dist/schema/parentIDColumnMap.d.ts.map +0 -1
  216. package/dist/schema/parentIDColumnMap.js +0 -9
  217. package/dist/schema/parentIDColumnMap.js.map +0 -1
  218. package/dist/schema/setColumnID.d.ts +0 -11
  219. package/dist/schema/setColumnID.d.ts.map +0 -1
  220. package/dist/schema/setColumnID.js +0 -24
  221. package/dist/schema/setColumnID.js.map +0 -1
  222. package/dist/schema/traverseFields.d.ts +0 -38
  223. package/dist/schema/traverseFields.d.ts.map +0 -1
  224. package/dist/schema/traverseFields.js +0 -551
  225. package/dist/schema/traverseFields.js.map +0 -1
  226. package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
  227. package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
  228. package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
  229. package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
  230. package/dist/transactions/beginTransaction.d.ts +0 -3
  231. package/dist/transactions/beginTransaction.d.ts.map +0 -1
  232. package/dist/transactions/beginTransaction.js +0 -47
  233. package/dist/transactions/beginTransaction.js.map +0 -1
  234. package/dist/transactions/commitTransaction.d.ts +0 -3
  235. package/dist/transactions/commitTransaction.d.ts.map +0 -1
  236. package/dist/transactions/commitTransaction.js +0 -14
  237. package/dist/transactions/commitTransaction.js.map +0 -1
  238. package/dist/transactions/rollbackTransaction.d.ts +0 -3
  239. package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
  240. package/dist/transactions/rollbackTransaction.js +0 -13
  241. package/dist/transactions/rollbackTransaction.js.map +0 -1
  242. package/dist/transform/read/hasManyNumber.d.ts +0 -10
  243. package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
  244. package/dist/transform/read/hasManyNumber.js +0 -10
  245. package/dist/transform/read/hasManyNumber.js.map +0 -1
  246. package/dist/transform/read/hasManyText.d.ts +0 -10
  247. package/dist/transform/read/hasManyText.d.ts.map +0 -1
  248. package/dist/transform/read/hasManyText.js +0 -10
  249. package/dist/transform/read/hasManyText.js.map +0 -1
  250. package/dist/transform/read/index.d.ts +0 -12
  251. package/dist/transform/read/index.d.ts.map +0 -1
  252. package/dist/transform/read/index.js +0 -43
  253. package/dist/transform/read/index.js.map +0 -1
  254. package/dist/transform/read/relationship.d.ts +0 -10
  255. package/dist/transform/read/relationship.d.ts.map +0 -1
  256. package/dist/transform/read/relationship.js +0 -64
  257. package/dist/transform/read/relationship.js.map +0 -1
  258. package/dist/transform/read/traverseFields.d.ts +0 -52
  259. package/dist/transform/read/traverseFields.d.ts.map +0 -1
  260. package/dist/transform/read/traverseFields.js +0 -421
  261. package/dist/transform/read/traverseFields.js.map +0 -1
  262. package/dist/transform/write/array.d.ts +0 -26
  263. package/dist/transform/write/array.d.ts.map +0 -1
  264. package/dist/transform/write/array.js +0 -58
  265. package/dist/transform/write/array.js.map +0 -1
  266. package/dist/transform/write/blocks.d.ts +0 -25
  267. package/dist/transform/write/blocks.d.ts.map +0 -1
  268. package/dist/transform/write/blocks.js +0 -54
  269. package/dist/transform/write/blocks.js.map +0 -1
  270. package/dist/transform/write/index.d.ts +0 -13
  271. package/dist/transform/write/index.d.ts.map +0 -1
  272. package/dist/transform/write/index.js +0 -41
  273. package/dist/transform/write/index.js.map +0 -1
  274. package/dist/transform/write/numbers.d.ts +0 -8
  275. package/dist/transform/write/numbers.d.ts.map +0 -1
  276. package/dist/transform/write/numbers.js +0 -11
  277. package/dist/transform/write/numbers.js.map +0 -1
  278. package/dist/transform/write/relationships.d.ts +0 -10
  279. package/dist/transform/write/relationships.d.ts.map +0 -1
  280. package/dist/transform/write/relationships.js +0 -23
  281. package/dist/transform/write/relationships.js.map +0 -1
  282. package/dist/transform/write/selects.d.ts +0 -8
  283. package/dist/transform/write/selects.d.ts.map +0 -1
  284. package/dist/transform/write/selects.js +0 -20
  285. package/dist/transform/write/selects.js.map +0 -1
  286. package/dist/transform/write/texts.d.ts +0 -8
  287. package/dist/transform/write/texts.d.ts.map +0 -1
  288. package/dist/transform/write/texts.js +0 -11
  289. package/dist/transform/write/texts.js.map +0 -1
  290. package/dist/transform/write/traverseFields.d.ts +0 -50
  291. package/dist/transform/write/traverseFields.d.ts.map +0 -1
  292. package/dist/transform/write/traverseFields.js +0 -428
  293. package/dist/transform/write/traverseFields.js.map +0 -1
  294. package/dist/transform/write/types.d.ts +0 -43
  295. package/dist/transform/write/types.d.ts.map +0 -1
  296. package/dist/transform/write/types.js +0 -3
  297. package/dist/transform/write/types.js.map +0 -1
  298. package/dist/update.d.ts +0 -3
  299. package/dist/update.d.ts.map +0 -1
  300. package/dist/update.js +0 -55
  301. package/dist/update.js.map +0 -1
  302. package/dist/updateGlobal.d.ts +0 -5
  303. package/dist/updateGlobal.d.ts.map +0 -1
  304. package/dist/updateGlobal.js +0 -25
  305. package/dist/updateGlobal.js.map +0 -1
  306. package/dist/updateGlobalVersion.d.ts +0 -5
  307. package/dist/updateGlobalVersion.d.ts.map +0 -1
  308. package/dist/updateGlobalVersion.js +0 -36
  309. package/dist/updateGlobalVersion.js.map +0 -1
  310. package/dist/updateVersion.d.ts +0 -5
  311. package/dist/updateVersion.d.ts.map +0 -1
  312. package/dist/updateVersion.js +0 -36
  313. package/dist/updateVersion.js.map +0 -1
  314. package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
  315. package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
  316. package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
  317. package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
  318. package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
  319. package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
  320. package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
  321. package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
  322. package/dist/upsertRow/index.d.ts +0 -4
  323. package/dist/upsertRow/index.d.ts.map +0 -1
  324. package/dist/upsertRow/index.js +0 -277
  325. package/dist/upsertRow/index.js.map +0 -1
  326. package/dist/upsertRow/insertArrays.d.ts +0 -13
  327. package/dist/upsertRow/insertArrays.d.ts.map +0 -1
  328. package/dist/upsertRow/insertArrays.js +0 -68
  329. package/dist/upsertRow/insertArrays.js.map +0 -1
  330. package/dist/upsertRow/types.d.ts +0 -27
  331. package/dist/upsertRow/types.d.ts.map +0 -1
  332. package/dist/upsertRow/types.js +0 -3
  333. package/dist/upsertRow/types.js.map +0 -1
  334. package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
  335. package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
  336. package/dist/utilities/appendPrefixToKeys.js +0 -6
  337. package/dist/utilities/appendPrefixToKeys.js.map +0 -1
  338. package/dist/utilities/createBlocksMap.d.ts +0 -5
  339. package/dist/utilities/createBlocksMap.d.ts.map +0 -1
  340. package/dist/utilities/createBlocksMap.js +0 -29
  341. package/dist/utilities/createBlocksMap.js.map +0 -1
  342. package/dist/utilities/createMigrationTable.d.ts +0 -3
  343. package/dist/utilities/createMigrationTable.d.ts.map +0 -1
  344. package/dist/utilities/createMigrationTable.js +0 -13
  345. package/dist/utilities/createMigrationTable.js.map +0 -1
  346. package/dist/utilities/createRelationshipMap.d.ts +0 -2
  347. package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
  348. package/dist/utilities/createRelationshipMap.js +0 -19
  349. package/dist/utilities/createRelationshipMap.js.map +0 -1
  350. package/dist/utilities/hasLocalesTable.d.ts +0 -3
  351. package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
  352. package/dist/utilities/hasLocalesTable.js +0 -11
  353. package/dist/utilities/hasLocalesTable.js.map +0 -1
  354. package/dist/utilities/isArrayOfRows.d.ts +0 -2
  355. package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
  356. package/dist/utilities/isArrayOfRows.js +0 -5
  357. package/dist/utilities/isArrayOfRows.js.map +0 -1
  358. package/dist/utilities/migrationTableExists.d.ts +0 -3
  359. package/dist/utilities/migrationTableExists.d.ts.map +0 -1
  360. package/dist/utilities/migrationTableExists.js +0 -9
  361. package/dist/utilities/migrationTableExists.js.map +0 -1
  362. package/dist/utilities/parseError.d.ts +0 -5
  363. package/dist/utilities/parseError.d.ts.map +0 -1
  364. package/dist/utilities/parseError.js +0 -17
  365. package/dist/utilities/parseError.js.map +0 -1
  366. package/dist/utilities/pushDevSchema.d.ts +0 -9
  367. package/dist/utilities/pushDevSchema.d.ts.map +0 -1
  368. package/dist/utilities/pushDevSchema.js +0 -58
  369. package/dist/utilities/pushDevSchema.js.map +0 -1
@@ -1,445 +0,0 @@
1
- /* eslint-disable no-param-reassign */ import { and, eq, like, sql } from 'drizzle-orm';
2
- import { alias } from 'drizzle-orm/pg-core';
3
- import { APIError } from 'payload/errors';
4
- import { fieldAffectsData, tabHasName } from 'payload/types';
5
- import { flattenTopLevelFields } from 'payload/utilities';
6
- import toSnakeCase from 'to-snake-case';
7
- import { v4 as uuid } from 'uuid';
8
- /**
9
- * Transforms path to table and column name
10
- * Adds tables to `join`
11
- * @returns TableColumn
12
- */ export const getTableColumnFromPath = ({ adapter, aliasTable, collectionPath, columnPrefix = '', constraintPath: incomingConstraintPath, constraints = [], fields, joinAliases, joins, locale: incomingLocale, pathSegments: incomingSegments, rootTableName: incomingRootTableName, selectFields, tableName, tableNameSuffix = '', value })=>{
13
- const fieldPath = incomingSegments[0];
14
- let locale = incomingLocale;
15
- const rootTableName = incomingRootTableName || tableName;
16
- let constraintPath = incomingConstraintPath || '';
17
- const field = flattenTopLevelFields(fields).find((fieldToFind)=>fieldAffectsData(fieldToFind) && fieldToFind.name === fieldPath);
18
- let newTableName = tableName;
19
- if (!field && fieldPath === 'id') {
20
- selectFields.id = adapter.tables[newTableName].id;
21
- return {
22
- columnName: 'id',
23
- constraints,
24
- field: {
25
- name: 'id',
26
- type: adapter.idType === 'uuid' ? 'text' : 'number'
27
- },
28
- table: adapter.tables[newTableName]
29
- };
30
- }
31
- if (field) {
32
- const pathSegments = [
33
- ...incomingSegments
34
- ];
35
- // If next segment is a locale,
36
- // we need to take it out and use it as the locale from this point on
37
- if ('localized' in field && field.localized && adapter.payload.config.localization) {
38
- const matchedLocale = adapter.payload.config.localization.localeCodes.find((locale)=>locale === pathSegments[1]);
39
- if (matchedLocale) {
40
- locale = matchedLocale;
41
- pathSegments.splice(1, 1);
42
- }
43
- }
44
- switch(field.type){
45
- case 'tabs':
46
- {
47
- return getTableColumnFromPath({
48
- adapter,
49
- aliasTable,
50
- collectionPath,
51
- columnPrefix,
52
- constraintPath,
53
- constraints,
54
- fields: field.tabs.map((tab)=>({
55
- ...tab,
56
- type: 'tab'
57
- })),
58
- joinAliases,
59
- joins,
60
- locale,
61
- pathSegments: pathSegments.slice(1),
62
- rootTableName,
63
- selectFields,
64
- tableName: newTableName,
65
- tableNameSuffix,
66
- value
67
- });
68
- }
69
- case 'tab':
70
- {
71
- if (tabHasName(field)) {
72
- return getTableColumnFromPath({
73
- adapter,
74
- aliasTable,
75
- collectionPath,
76
- columnPrefix: `${columnPrefix}${field.name}_`,
77
- constraintPath: `${constraintPath}${field.name}.`,
78
- constraints,
79
- fields: field.fields,
80
- joinAliases,
81
- joins,
82
- locale,
83
- pathSegments: pathSegments.slice(1),
84
- rootTableName,
85
- selectFields,
86
- tableName: newTableName,
87
- tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,
88
- value
89
- });
90
- }
91
- return getTableColumnFromPath({
92
- adapter,
93
- aliasTable,
94
- collectionPath,
95
- columnPrefix,
96
- constraintPath,
97
- constraints,
98
- fields: field.fields,
99
- joinAliases,
100
- joins,
101
- locale,
102
- pathSegments: pathSegments.slice(1),
103
- rootTableName,
104
- selectFields,
105
- tableName: newTableName,
106
- tableNameSuffix,
107
- value
108
- });
109
- }
110
- case 'group':
111
- {
112
- if (locale && field.localized && adapter.payload.config.localization) {
113
- newTableName = `${tableName}${adapter.localesSuffix}`;
114
- joins[tableName] = eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID);
115
- if (locale !== 'all') {
116
- constraints.push({
117
- columnName: '_locale',
118
- table: adapter.tables[newTableName],
119
- value: locale
120
- });
121
- }
122
- }
123
- return getTableColumnFromPath({
124
- adapter,
125
- aliasTable,
126
- collectionPath,
127
- columnPrefix: `${columnPrefix}${field.name}_`,
128
- constraintPath: `${constraintPath}${field.name}.`,
129
- constraints,
130
- fields: field.fields,
131
- joinAliases,
132
- joins,
133
- locale,
134
- pathSegments: pathSegments.slice(1),
135
- rootTableName,
136
- selectFields,
137
- tableName: newTableName,
138
- tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,
139
- value
140
- });
141
- }
142
- case 'select':
143
- {
144
- if (field.hasMany) {
145
- const newTableName = adapter.tableNameMap.get(`${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`);
146
- if (locale && field.localized && adapter.payload.config.localization) {
147
- joins[newTableName] = and(eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent), eq(adapter.tables[newTableName]._locale, locale));
148
- if (locale !== 'all') {
149
- constraints.push({
150
- columnName: '_locale',
151
- table: adapter.tables[newTableName],
152
- value: locale
153
- });
154
- }
155
- } else {
156
- joins[newTableName] = eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent);
157
- }
158
- return {
159
- columnName: 'value',
160
- constraints,
161
- field,
162
- table: adapter.tables[newTableName]
163
- };
164
- }
165
- break;
166
- }
167
- case 'text':
168
- case 'number':
169
- {
170
- if (field.hasMany) {
171
- let tableType = 'texts';
172
- let columnName = 'text';
173
- if (field.type === 'number') {
174
- tableType = 'numbers';
175
- columnName = 'number';
176
- }
177
- newTableName = `${tableName}_${tableType}`;
178
- const joinConstraints = [
179
- eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),
180
- eq(adapter.tables[newTableName].path, `${constraintPath}${field.name}`)
181
- ];
182
- if (locale && field.localized && adapter.payload.config.localization) {
183
- joins[newTableName] = and(...joinConstraints, eq(adapter.tables[newTableName]._locale, locale));
184
- if (locale !== 'all') {
185
- constraints.push({
186
- columnName: 'locale',
187
- table: adapter.tables[newTableName],
188
- value: locale
189
- });
190
- }
191
- } else {
192
- joins[newTableName] = and(...joinConstraints);
193
- }
194
- return {
195
- columnName,
196
- constraints,
197
- field,
198
- table: adapter.tables[newTableName]
199
- };
200
- }
201
- break;
202
- }
203
- case 'array':
204
- {
205
- newTableName = adapter.tableNameMap.get(`${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`);
206
- constraintPath = `${constraintPath}${field.name}.%.`;
207
- if (locale && field.localized && adapter.payload.config.localization) {
208
- joins[newTableName] = and(eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID), eq(adapter.tables[newTableName]._locale, locale));
209
- if (locale !== 'all') {
210
- constraints.push({
211
- columnName: '_locale',
212
- table: adapter.tables[newTableName],
213
- value: locale
214
- });
215
- }
216
- } else {
217
- joins[newTableName] = eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID);
218
- }
219
- return getTableColumnFromPath({
220
- adapter,
221
- collectionPath,
222
- constraintPath,
223
- constraints,
224
- fields: field.fields,
225
- joinAliases,
226
- joins,
227
- locale,
228
- pathSegments: pathSegments.slice(1),
229
- rootTableName,
230
- selectFields,
231
- tableName: newTableName,
232
- value
233
- });
234
- }
235
- case 'blocks':
236
- {
237
- let blockTableColumn;
238
- let newTableName;
239
- // handle blockType queries
240
- if (pathSegments[1] === 'blockType') {
241
- // find the block config using the value
242
- const blockTypes = Array.isArray(value) ? value : [
243
- value
244
- ];
245
- blockTypes.forEach((blockType)=>{
246
- const block = field.blocks.find((block)=>block.slug === blockType);
247
- newTableName = adapter.tableNameMap.get(`${tableName}_blocks_${toSnakeCase(block.slug)}`);
248
- joins[newTableName] = eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID);
249
- constraints.push({
250
- columnName: '_path',
251
- table: adapter.tables[newTableName],
252
- value: pathSegments[0]
253
- });
254
- });
255
- return {
256
- constraints,
257
- field,
258
- getNotNullColumnByValue: ()=>'id',
259
- table: adapter.tables[tableName]
260
- };
261
- }
262
- const hasBlockField = field.blocks.some((block)=>{
263
- newTableName = adapter.tableNameMap.get(`${tableName}_blocks_${toSnakeCase(block.slug)}`);
264
- constraintPath = `${constraintPath}${field.name}.%.`;
265
- let result;
266
- const blockConstraints = [];
267
- const blockSelectFields = {};
268
- try {
269
- result = getTableColumnFromPath({
270
- adapter,
271
- collectionPath,
272
- constraintPath,
273
- constraints: blockConstraints,
274
- fields: block.fields,
275
- joinAliases,
276
- joins,
277
- locale,
278
- pathSegments: pathSegments.slice(1),
279
- rootTableName,
280
- selectFields: blockSelectFields,
281
- tableName: newTableName,
282
- value
283
- });
284
- } catch (error) {
285
- // this is fine, not every block will have the field
286
- }
287
- if (!result) {
288
- return;
289
- }
290
- blockTableColumn = result;
291
- constraints = constraints.concat(blockConstraints);
292
- selectFields = {
293
- ...selectFields,
294
- ...blockSelectFields
295
- };
296
- if (field.localized && adapter.payload.config.localization) {
297
- joins[newTableName] = and(eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID), eq(adapter.tables[newTableName]._locale, locale));
298
- if (locale) {
299
- constraints.push({
300
- columnName: '_locale',
301
- table: adapter.tables[newTableName],
302
- value: locale
303
- });
304
- }
305
- } else {
306
- joins[newTableName] = eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID);
307
- }
308
- return true;
309
- });
310
- if (hasBlockField) {
311
- return {
312
- columnName: blockTableColumn.columnName,
313
- constraints,
314
- field: blockTableColumn.field,
315
- pathSegments: pathSegments.slice(1),
316
- rawColumn: blockTableColumn.rawColumn,
317
- table: blockTableColumn.table
318
- };
319
- }
320
- break;
321
- }
322
- case 'relationship':
323
- case 'upload':
324
- {
325
- let relationshipFields;
326
- const relationTableName = `${rootTableName}${adapter.relationshipsSuffix}`;
327
- const newCollectionPath = pathSegments.slice(1).join('.');
328
- const aliasRelationshipTableName = uuid();
329
- const aliasRelationshipTable = alias(adapter.tables[relationTableName], aliasRelationshipTableName);
330
- // Join in the relationships table
331
- if (locale && field.localized && adapter.payload.config.localization) {
332
- joinAliases.push({
333
- condition: and(eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent), eq(aliasRelationshipTable.locale, locale), like(aliasRelationshipTable.path, `${constraintPath}${field.name}`)),
334
- table: aliasRelationshipTable
335
- });
336
- if (locale !== 'all') {
337
- constraints.push({
338
- columnName: 'locale',
339
- table: aliasRelationshipTable,
340
- value: locale
341
- });
342
- }
343
- } else {
344
- // Join in the relationships table
345
- joinAliases.push({
346
- condition: and(eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent), like(aliasRelationshipTable.path, `${constraintPath}${field.name}`)),
347
- table: aliasRelationshipTable
348
- });
349
- }
350
- selectFields[`${relationTableName}.path`] = aliasRelationshipTable.path;
351
- let newAliasTable;
352
- if (typeof field.relationTo === 'string') {
353
- const relationshipConfig = adapter.payload.collections[field.relationTo].config;
354
- newTableName = adapter.tableNameMap.get(toSnakeCase(relationshipConfig.slug));
355
- // parent to relationship join table
356
- relationshipFields = relationshipConfig.fields;
357
- newAliasTable = alias(adapter.tables[newTableName], toSnakeCase(uuid()));
358
- joinAliases.push({
359
- condition: eq(newAliasTable.id, aliasRelationshipTable[`${field.relationTo}ID`]),
360
- table: newAliasTable
361
- });
362
- if (newCollectionPath === '' || newCollectionPath === 'id') {
363
- return {
364
- columnName: `${field.relationTo}ID`,
365
- constraints,
366
- field,
367
- table: aliasRelationshipTable
368
- };
369
- }
370
- } else if (newCollectionPath === 'value') {
371
- const tableColumnsNames = field.relationTo.map((relationTo)=>{
372
- const relationTableName = adapter.tableNameMap.get(toSnakeCase(adapter.payload.collections[relationTo].config.slug));
373
- return `"${aliasRelationshipTableName}"."${relationTableName}_id"`;
374
- });
375
- return {
376
- constraints,
377
- field,
378
- rawColumn: sql.raw(`COALESCE(${tableColumnsNames.join(', ')})`),
379
- table: aliasRelationshipTable
380
- };
381
- } else if (newCollectionPath === 'relationTo') {
382
- const relationTo = Array.isArray(field.relationTo) ? field.relationTo : [
383
- field.relationTo
384
- ];
385
- return {
386
- constraints,
387
- field,
388
- getNotNullColumnByValue: (val)=>{
389
- const matchedRelation = relationTo.find((relation)=>relation === val);
390
- if (matchedRelation) return `${matchedRelation}ID`;
391
- return undefined;
392
- },
393
- table: aliasRelationshipTable
394
- };
395
- } else {
396
- throw new APIError('Not supported');
397
- }
398
- return getTableColumnFromPath({
399
- adapter,
400
- aliasTable: newAliasTable,
401
- collectionPath: newCollectionPath,
402
- constraints,
403
- fields: relationshipFields,
404
- joinAliases,
405
- joins,
406
- locale,
407
- pathSegments: pathSegments.slice(1),
408
- rootTableName: newTableName,
409
- selectFields,
410
- tableName: newTableName,
411
- value
412
- });
413
- }
414
- }
415
- if (fieldAffectsData(field)) {
416
- if (field.localized && adapter.payload.config.localization) {
417
- // If localized, we go to localized table and set aliasTable to undefined
418
- // so it is not picked up below to be used as targetTable
419
- newTableName = `${tableName}${adapter.localesSuffix}`;
420
- const parentTable = aliasTable || adapter.tables[tableName];
421
- joins[newTableName] = eq(parentTable.id, adapter.tables[newTableName]._parentID);
422
- aliasTable = undefined;
423
- if (locale !== 'all') {
424
- constraints.push({
425
- columnName: '_locale',
426
- table: adapter.tables[newTableName],
427
- value: locale
428
- });
429
- }
430
- }
431
- const targetTable = aliasTable || adapter.tables[newTableName];
432
- selectFields[`${newTableName}.${columnPrefix}${field.name}`] = targetTable[`${columnPrefix}${field.name}`];
433
- return {
434
- columnName: `${columnPrefix}${field.name}`,
435
- constraints,
436
- field,
437
- pathSegments,
438
- table: targetTable
439
- };
440
- }
441
- }
442
- throw new APIError(`Cannot find field for path at ${fieldPath}`);
443
- };
444
-
445
- //# sourceMappingURL=getTableColumnFromPath.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/queries/getTableColumnFromPath.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { SQL } from 'drizzle-orm'\nimport type { PgTableWithColumns } from 'drizzle-orm/pg-core'\nimport type { Field, FieldAffectingData, NumberField, TabAsField, TextField } from 'payload/types'\n\nimport { and, eq, like, sql } from 'drizzle-orm'\nimport { alias } from 'drizzle-orm/pg-core'\nimport { APIError } from 'payload/errors'\nimport { fieldAffectsData, tabHasName } from 'payload/types'\nimport { flattenTopLevelFields } from 'payload/utilities'\nimport toSnakeCase from 'to-snake-case'\nimport { v4 as uuid } from 'uuid'\n\nimport type { GenericColumn, GenericTable, PostgresAdapter } from '../types.js'\nimport type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.js'\n\ntype Constraint = {\n columnName: string\n table: GenericTable | PgTableWithColumns<any>\n value: unknown\n}\n\ntype TableColumn = {\n columnName?: string\n constraints: Constraint[]\n field: FieldAffectingData\n getNotNullColumnByValue?: (val: unknown) => string\n pathSegments?: string[]\n rawColumn?: SQL\n table: GenericTable | PgTableWithColumns<any>\n}\n\ntype Args = {\n adapter: PostgresAdapter\n aliasTable?: GenericTable | PgTableWithColumns<any>\n collectionPath: string\n columnPrefix?: string\n constraintPath?: string\n constraints?: Constraint[]\n fields: (Field | TabAsField)[]\n joinAliases: BuildQueryJoinAliases\n joins: BuildQueryJoins\n locale?: string\n pathSegments: string[]\n rootTableName?: string\n selectFields: Record<string, GenericColumn>\n tableName: string\n /**\n * If creating a new table name for arrays and blocks, this suffix should be appended to the table name\n */\n tableNameSuffix?: string\n /**\n * The raw value of the query before sanitization\n */\n value: unknown\n}\n/**\n * Transforms path to table and column name\n * Adds tables to `join`\n * @returns TableColumn\n */\nexport const getTableColumnFromPath = ({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix = '',\n constraintPath: incomingConstraintPath,\n constraints = [],\n fields,\n joinAliases,\n joins,\n locale: incomingLocale,\n pathSegments: incomingSegments,\n rootTableName: incomingRootTableName,\n selectFields,\n tableName,\n tableNameSuffix = '',\n value,\n}: Args): TableColumn => {\n const fieldPath = incomingSegments[0]\n let locale = incomingLocale\n const rootTableName = incomingRootTableName || tableName\n let constraintPath = incomingConstraintPath || ''\n\n const field = flattenTopLevelFields(fields as Field[]).find(\n (fieldToFind) => fieldAffectsData(fieldToFind) && fieldToFind.name === fieldPath,\n ) as Field | TabAsField\n let newTableName = tableName\n\n if (!field && fieldPath === 'id') {\n selectFields.id = adapter.tables[newTableName].id\n return {\n columnName: 'id',\n constraints,\n field: {\n name: 'id',\n type: adapter.idType === 'uuid' ? 'text' : 'number',\n } as NumberField | TextField,\n table: adapter.tables[newTableName],\n }\n }\n\n if (field) {\n const pathSegments = [...incomingSegments]\n\n // If next segment is a locale,\n // we need to take it out and use it as the locale from this point on\n if ('localized' in field && field.localized && adapter.payload.config.localization) {\n const matchedLocale = adapter.payload.config.localization.localeCodes.find(\n (locale) => locale === pathSegments[1],\n )\n\n if (matchedLocale) {\n locale = matchedLocale\n pathSegments.splice(1, 1)\n }\n }\n\n switch (field.type) {\n case 'tabs': {\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix,\n constraintPath,\n constraints,\n fields: field.tabs.map((tab) => ({\n ...tab,\n type: 'tab',\n })),\n joinAliases,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix,\n value,\n })\n }\n case 'tab': {\n if (tabHasName(field)) {\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix: `${columnPrefix}${field.name}_`,\n constraintPath: `${constraintPath}${field.name}.`,\n constraints,\n fields: field.fields,\n joinAliases,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,\n value,\n })\n }\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix,\n constraintPath,\n constraints,\n fields: field.fields,\n joinAliases,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix,\n value,\n })\n }\n\n case 'group': {\n if (locale && field.localized && adapter.payload.config.localization) {\n newTableName = `${tableName}${adapter.localesSuffix}`\n\n joins[tableName] = eq(\n adapter.tables[tableName].id,\n adapter.tables[newTableName]._parentID,\n )\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n }\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix: `${columnPrefix}${field.name}_`,\n constraintPath: `${constraintPath}${field.name}.`,\n constraints,\n fields: field.fields,\n joinAliases,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,\n value,\n })\n }\n\n case 'select': {\n if (field.hasMany) {\n const newTableName = adapter.tableNameMap.get(\n `${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`,\n )\n\n if (locale && field.localized && adapter.payload.config.localization) {\n joins[newTableName] = and(\n eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),\n eq(adapter.tables[newTableName]._locale, locale),\n )\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins[newTableName] = eq(\n adapter.tables[tableName].id,\n adapter.tables[newTableName].parent,\n )\n }\n\n return {\n columnName: 'value',\n constraints,\n field,\n table: adapter.tables[newTableName],\n }\n }\n break\n }\n\n case 'text':\n case 'number': {\n if (field.hasMany) {\n let tableType = 'texts'\n let columnName = 'text'\n if (field.type === 'number') {\n tableType = 'numbers'\n columnName = 'number'\n }\n newTableName = `${tableName}_${tableType}`\n const joinConstraints = [\n eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),\n eq(adapter.tables[newTableName].path, `${constraintPath}${field.name}`),\n ]\n\n if (locale && field.localized && adapter.payload.config.localization) {\n joins[newTableName] = and(\n ...joinConstraints,\n eq(adapter.tables[newTableName]._locale, locale),\n )\n if (locale !== 'all') {\n constraints.push({\n columnName: 'locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins[newTableName] = and(...joinConstraints)\n }\n\n return {\n columnName,\n constraints,\n field,\n table: adapter.tables[newTableName],\n }\n }\n break\n }\n\n case 'array': {\n newTableName = adapter.tableNameMap.get(\n `${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`,\n )\n\n constraintPath = `${constraintPath}${field.name}.%.`\n if (locale && field.localized && adapter.payload.config.localization) {\n joins[newTableName] = and(\n eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),\n eq(adapter.tables[newTableName]._locale, locale),\n )\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins[newTableName] = eq(\n adapter.tables[tableName].id,\n adapter.tables[newTableName]._parentID,\n )\n }\n return getTableColumnFromPath({\n adapter,\n collectionPath,\n constraintPath,\n constraints,\n fields: field.fields,\n joinAliases,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n value,\n })\n }\n\n case 'blocks': {\n let blockTableColumn: TableColumn\n let newTableName: string\n\n // handle blockType queries\n if (pathSegments[1] === 'blockType') {\n // find the block config using the value\n const blockTypes = Array.isArray(value) ? value : [value]\n blockTypes.forEach((blockType) => {\n const block = field.blocks.find((block) => block.slug === blockType)\n\n newTableName = adapter.tableNameMap.get(\n `${tableName}_blocks_${toSnakeCase(block.slug)}`,\n )\n\n joins[newTableName] = eq(\n adapter.tables[tableName].id,\n adapter.tables[newTableName]._parentID,\n )\n constraints.push({\n columnName: '_path',\n table: adapter.tables[newTableName],\n value: pathSegments[0],\n })\n })\n return {\n constraints,\n field,\n getNotNullColumnByValue: () => 'id',\n table: adapter.tables[tableName],\n }\n }\n\n const hasBlockField = field.blocks.some((block) => {\n newTableName = adapter.tableNameMap.get(`${tableName}_blocks_${toSnakeCase(block.slug)}`)\n constraintPath = `${constraintPath}${field.name}.%.`\n\n let result\n const blockConstraints = []\n const blockSelectFields = {}\n try {\n result = getTableColumnFromPath({\n adapter,\n collectionPath,\n constraintPath,\n constraints: blockConstraints,\n fields: block.fields,\n joinAliases,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields: blockSelectFields,\n tableName: newTableName,\n value,\n })\n } catch (error) {\n // this is fine, not every block will have the field\n }\n if (!result) {\n return\n }\n blockTableColumn = result\n constraints = constraints.concat(blockConstraints)\n selectFields = { ...selectFields, ...blockSelectFields }\n if (field.localized && adapter.payload.config.localization) {\n joins[newTableName] = and(\n eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),\n eq(adapter.tables[newTableName]._locale, locale),\n )\n if (locale) {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins[newTableName] = eq(\n adapter.tables[tableName].id,\n adapter.tables[newTableName]._parentID,\n )\n }\n return true\n })\n if (hasBlockField) {\n return {\n columnName: blockTableColumn.columnName,\n constraints,\n field: blockTableColumn.field,\n pathSegments: pathSegments.slice(1),\n rawColumn: blockTableColumn.rawColumn,\n table: blockTableColumn.table,\n }\n }\n break\n }\n\n case 'relationship':\n case 'upload': {\n let relationshipFields\n const relationTableName = `${rootTableName}${adapter.relationshipsSuffix}`\n const newCollectionPath = pathSegments.slice(1).join('.')\n const aliasRelationshipTableName = uuid()\n const aliasRelationshipTable = alias(\n adapter.tables[relationTableName],\n aliasRelationshipTableName,\n )\n\n // Join in the relationships table\n if (locale && field.localized && adapter.payload.config.localization) {\n joinAliases.push({\n condition: and(\n eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent),\n eq(aliasRelationshipTable.locale, locale),\n like(aliasRelationshipTable.path, `${constraintPath}${field.name}`),\n ),\n table: aliasRelationshipTable,\n })\n if (locale !== 'all') {\n constraints.push({\n columnName: 'locale',\n table: aliasRelationshipTable,\n value: locale,\n })\n }\n } else {\n // Join in the relationships table\n joinAliases.push({\n condition: and(\n eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent),\n like(aliasRelationshipTable.path, `${constraintPath}${field.name}`),\n ),\n table: aliasRelationshipTable,\n })\n }\n\n selectFields[`${relationTableName}.path`] = aliasRelationshipTable.path\n\n let newAliasTable\n\n if (typeof field.relationTo === 'string') {\n const relationshipConfig = adapter.payload.collections[field.relationTo].config\n\n newTableName = adapter.tableNameMap.get(toSnakeCase(relationshipConfig.slug))\n\n // parent to relationship join table\n relationshipFields = relationshipConfig.fields\n\n newAliasTable = alias(adapter.tables[newTableName], toSnakeCase(uuid()))\n\n joinAliases.push({\n condition: eq(newAliasTable.id, aliasRelationshipTable[`${field.relationTo}ID`]),\n table: newAliasTable,\n })\n\n if (newCollectionPath === '' || newCollectionPath === 'id') {\n return {\n columnName: `${field.relationTo}ID`,\n constraints,\n field,\n table: aliasRelationshipTable,\n }\n }\n } else if (newCollectionPath === 'value') {\n const tableColumnsNames = field.relationTo.map((relationTo) => {\n const relationTableName = adapter.tableNameMap.get(\n toSnakeCase(adapter.payload.collections[relationTo].config.slug),\n )\n\n return `\"${aliasRelationshipTableName}\".\"${relationTableName}_id\"`\n })\n return {\n constraints,\n field,\n rawColumn: sql.raw(`COALESCE(${tableColumnsNames.join(', ')})`),\n table: aliasRelationshipTable,\n }\n } else if (newCollectionPath === 'relationTo') {\n const relationTo = Array.isArray(field.relationTo) ? field.relationTo : [field.relationTo]\n\n return {\n constraints,\n field,\n getNotNullColumnByValue: (val) => {\n const matchedRelation = relationTo.find((relation) => relation === val)\n if (matchedRelation) return `${matchedRelation}ID`\n return undefined\n },\n table: aliasRelationshipTable,\n }\n } else {\n throw new APIError('Not supported')\n }\n\n return getTableColumnFromPath({\n adapter,\n aliasTable: newAliasTable,\n collectionPath: newCollectionPath,\n constraints,\n fields: relationshipFields,\n joinAliases,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName: newTableName,\n selectFields,\n tableName: newTableName,\n value,\n })\n }\n }\n\n if (fieldAffectsData(field)) {\n if (field.localized && adapter.payload.config.localization) {\n // If localized, we go to localized table and set aliasTable to undefined\n // so it is not picked up below to be used as targetTable\n newTableName = `${tableName}${adapter.localesSuffix}`\n\n const parentTable = aliasTable || adapter.tables[tableName]\n\n joins[newTableName] = eq(parentTable.id, adapter.tables[newTableName]._parentID)\n\n aliasTable = undefined\n\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n }\n\n const targetTable = aliasTable || adapter.tables[newTableName]\n\n selectFields[`${newTableName}.${columnPrefix}${field.name}`] =\n targetTable[`${columnPrefix}${field.name}`]\n\n return {\n columnName: `${columnPrefix}${field.name}`,\n constraints,\n field,\n pathSegments,\n table: targetTable,\n }\n }\n }\n\n throw new APIError(`Cannot find field for path at ${fieldPath}`)\n}\n"],"names":["and","eq","like","sql","alias","APIError","fieldAffectsData","tabHasName","flattenTopLevelFields","toSnakeCase","v4","uuid","getTableColumnFromPath","adapter","aliasTable","collectionPath","columnPrefix","constraintPath","incomingConstraintPath","constraints","fields","joinAliases","joins","locale","incomingLocale","pathSegments","incomingSegments","rootTableName","incomingRootTableName","selectFields","tableName","tableNameSuffix","value","fieldPath","field","find","fieldToFind","name","newTableName","id","tables","columnName","type","idType","table","localized","payload","config","localization","matchedLocale","localeCodes","splice","tabs","map","tab","slice","localesSuffix","_parentID","push","hasMany","tableNameMap","get","parent","_locale","tableType","joinConstraints","path","blockTableColumn","blockTypes","Array","isArray","forEach","blockType","block","blocks","slug","getNotNullColumnByValue","hasBlockField","some","result","blockConstraints","blockSelectFields","error","concat","rawColumn","relationshipFields","relationTableName","relationshipsSuffix","newCollectionPath","join","aliasRelationshipTableName","aliasRelationshipTable","condition","newAliasTable","relationTo","relationshipConfig","collections","tableColumnsNames","raw","val","matchedRelation","relation","undefined","parentTable","targetTable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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F;gBAEb,IAAI/E,WAAW,OAAO;oBACpBJ,YAAYuC,IAAI,CAAC;wBACfjB,YAAY;wBACZG,OAAO/B,QAAQ2B,MAAM,CAACF,aAAa;wBACnCN,OAAOT;oBACT;gBACF;YACF;YAEA,MAAMiF,cAAc1F,cAAcD,QAAQ2B,MAAM,CAACF,aAAa;YAE9DT,YAAY,CAAC,CAAC,EAAES,aAAa,CAAC,EAAEtB,aAAa,EAAEkB,MAAMG,IAAI,CAAC,CAAC,CAAC,GAC1DmE,WAAW,CAAC,CAAC,EAAExF,aAAa,EAAEkB,MAAMG,IAAI,CAAC,CAAC,CAAC;YAE7C,OAAO;gBACLI,YAAY,CAAC,EAAEzB,aAAa,EAAEkB,MAAMG,IAAI,CAAC,CAAC;gBAC1ClB;gBACAe;gBACAT;gBACAmB,OAAO4D;YACT;QACF;IACF;IAEA,MAAM,IAAInG,SAAS,CAAC,8BAA8B,EAAE4B,UAAU,CAAC;AACjE,EAAC"}
@@ -1,18 +0,0 @@
1
- import { and, ilike, inArray, isNotNull, isNull, notInArray, or } from 'drizzle-orm';
2
- export declare const operatorMap: {
3
- and: typeof and;
4
- contains: typeof ilike;
5
- equals: import("drizzle-orm").BinaryOperator;
6
- exists: typeof isNotNull;
7
- greater_than: import("drizzle-orm").BinaryOperator;
8
- greater_than_equal: import("drizzle-orm").BinaryOperator;
9
- in: typeof inArray;
10
- isNull: typeof isNull;
11
- less_than: import("drizzle-orm").BinaryOperator;
12
- less_than_equal: import("drizzle-orm").BinaryOperator;
13
- like: typeof ilike;
14
- not_equals: import("drizzle-orm").BinaryOperator;
15
- not_in: typeof notInArray;
16
- or: typeof or;
17
- };
18
- //# sourceMappingURL=operatorMap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"operatorMap.d.ts","sourceRoot":"","sources":["../../src/queries/operatorMap.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EAIH,KAAK,EACL,OAAO,EACP,SAAS,EACT,MAAM,EAIN,UAAU,EACV,EAAE,EACH,MAAM,aAAa,CAAA;AAEpB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;CAoBvB,CAAA"}
@@ -1,24 +0,0 @@
1
- import { and, eq, gt, gte, ilike, inArray, isNotNull, isNull, lt, lte, ne, notInArray, or } from 'drizzle-orm';
2
- export const operatorMap = {
3
- // intersects: intersects,
4
- and,
5
- contains: ilike,
6
- equals: eq,
7
- exists: isNotNull,
8
- greater_than: gt,
9
- greater_than_equal: gte,
10
- in: inArray,
11
- isNull,
12
- less_than: lt,
13
- less_than_equal: lte,
14
- like: ilike,
15
- not_equals: ne,
16
- // TODO: geojson queries
17
- // near: near,
18
- // within: within,
19
- // all: all,
20
- not_in: notInArray,
21
- or
22
- };
23
-
24
- //# sourceMappingURL=operatorMap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/queries/operatorMap.ts"],"sourcesContent":["import {\n and,\n eq,\n gt,\n gte,\n ilike,\n inArray,\n isNotNull,\n isNull,\n lt,\n lte,\n ne,\n notInArray,\n or,\n} from 'drizzle-orm'\n\nexport const operatorMap = {\n // intersects: intersects,\n and,\n contains: ilike,\n equals: eq,\n exists: isNotNull,\n greater_than: gt,\n greater_than_equal: gte,\n in: inArray,\n isNull, // handles exists: false\n less_than: lt,\n less_than_equal: lte,\n like: ilike,\n not_equals: ne,\n // TODO: geojson queries\n // near: near,\n // within: within,\n // all: all,\n not_in: notInArray,\n or,\n}\n"],"names":["and","eq","gt","gte","ilike","inArray","isNotNull","isNull","lt","lte","ne","notInArray","or","operatorMap","contains","equals","exists","greater_than","greater_than_equal","in","less_than","less_than_equal","like","not_equals","not_in"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SACEA,GAAG,EACHC,EAAE,EACFC,EAAE,EACFC,GAAG,EACHC,KAAK,EACLC,OAAO,EACPC,SAAS,EACTC,MAAM,EACNC,EAAE,EACFC,GAAG,EACHC,EAAE,EACFC,UAAU,EACVC,EAAE,QACG,cAAa;AAEpB,OAAO,MAAMC,cAAc;IACzB,0BAA0B;IAC1Bb;IACAc,UAAUV;IACVW,QAAQd;IACRe,QAAQV;IACRW,cAAcf;IACdgB,oBAAoBf;IACpBgB,IAAId;IACJE;IACAa,WAAWZ;IACXa,iBAAiBZ;IACjBa,MAAMlB;IACNmB,YAAYb;IACZ,wBAAwB;IACxB,cAAc;IACd,kBAAkB;IAClB,YAAY;IACZc,QAAQb;IACRC;AACF,EAAC"}
@@ -1,17 +0,0 @@
1
- import type { SQL } from 'drizzle-orm';
2
- import type { Field, Where } from 'payload/types';
3
- import type { GenericColumn, PostgresAdapter } from '../types.js';
4
- import type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.js';
5
- type Args = {
6
- adapter: PostgresAdapter;
7
- fields: Field[];
8
- joinAliases: BuildQueryJoinAliases;
9
- joins: BuildQueryJoins;
10
- locale: string;
11
- selectFields: Record<string, GenericColumn>;
12
- tableName: string;
13
- where: Where;
14
- };
15
- export declare function parseParams({ adapter, fields, joinAliases, joins, locale, selectFields, tableName, where, }: Args): Promise<SQL>;
16
- export {};
17
- //# sourceMappingURL=parseParams.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseParams.d.ts","sourceRoot":"","sources":["../../src/queries/parseParams.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,KAAK,EAAY,KAAK,EAAE,MAAM,eAAe,CAAA;AAM3D,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAS7E,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,WAAW,EAAE,qBAAqB,CAAA;IAClC,KAAK,EAAE,eAAe,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,wBAAsB,WAAW,CAAC,EAChC,OAAO,EACP,MAAM,EACN,WAAW,EACX,KAAK,EACL,MAAM,EACN,YAAY,EACZ,SAAS,EACT,KAAK,GACN,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAwMrB"}