@payloadcms/db-postgres 3.0.0-canary.f6e77b8 → 3.0.0-canary.fb04843

Sign up to get free protection for your applications and to get access to all the features.
Files changed (370) 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 +45 -17
  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 +3 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +66 -69
  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 +196 -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 +63 -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 +65 -77
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/types.js.map +1 -1
  49. package/license.md +22 -0
  50. package/package.json +35 -17
  51. package/dist/count.d.ts +0 -3
  52. package/dist/count.d.ts.map +0 -1
  53. package/dist/count.js +0 -50
  54. package/dist/count.js.map +0 -1
  55. package/dist/create.d.ts +0 -3
  56. package/dist/create.d.ts.map +0 -1
  57. package/dist/create.js +0 -19
  58. package/dist/create.js.map +0 -1
  59. package/dist/createGlobal.d.ts +0 -5
  60. package/dist/createGlobal.d.ts.map +0 -1
  61. package/dist/createGlobal.js +0 -19
  62. package/dist/createGlobal.js.map +0 -1
  63. package/dist/createGlobalVersion.d.ts +0 -6
  64. package/dist/createGlobalVersion.d.ts.map +0 -1
  65. package/dist/createGlobalVersion.js +0 -33
  66. package/dist/createGlobalVersion.js.map +0 -1
  67. package/dist/createMigration.d.ts +0 -3
  68. package/dist/createMigration.d.ts.map +0 -1
  69. package/dist/createMigration.js +0 -81
  70. package/dist/createMigration.js.map +0 -1
  71. package/dist/createVersion.d.ts +0 -5
  72. package/dist/createVersion.d.ts.map +0 -1
  73. package/dist/createVersion.js +0 -44
  74. package/dist/createVersion.js.map +0 -1
  75. package/dist/deleteMany.d.ts +0 -3
  76. package/dist/deleteMany.d.ts.map +0 -1
  77. package/dist/deleteMany.js +0 -28
  78. package/dist/deleteMany.js.map +0 -1
  79. package/dist/deleteOne.d.ts +0 -3
  80. package/dist/deleteOne.d.ts.map +0 -1
  81. package/dist/deleteOne.js +0 -59
  82. package/dist/deleteOne.js.map +0 -1
  83. package/dist/deleteVersions.d.ts +0 -3
  84. package/dist/deleteVersions.d.ts.map +0 -1
  85. package/dist/deleteVersions.js +0 -31
  86. package/dist/deleteVersions.js.map +0 -1
  87. package/dist/destroy.d.ts +0 -3
  88. package/dist/destroy.d.ts.map +0 -1
  89. package/dist/destroy.js +0 -11
  90. package/dist/destroy.js.map +0 -1
  91. package/dist/find/buildFindManyArgs.d.ts +0 -13
  92. package/dist/find/buildFindManyArgs.d.ts.map +0 -1
  93. package/dist/find/buildFindManyArgs.js +0 -64
  94. package/dist/find/buildFindManyArgs.js.map +0 -1
  95. package/dist/find/chainMethods.d.ts +0 -16
  96. package/dist/find/chainMethods.d.ts.map +0 -1
  97. package/dist/find/chainMethods.js +0 -12
  98. package/dist/find/chainMethods.js.map +0 -1
  99. package/dist/find/findMany.d.ts +0 -22
  100. package/dist/find/findMany.d.ts.map +0 -1
  101. package/dist/find/findMany.js +0 -163
  102. package/dist/find/findMany.js.map +0 -1
  103. package/dist/find/traverseFields.d.ts +0 -16
  104. package/dist/find/traverseFields.d.ts.map +0 -1
  105. package/dist/find/traverseFields.js +0 -138
  106. package/dist/find/traverseFields.js.map +0 -1
  107. package/dist/find.d.ts +0 -3
  108. package/dist/find.d.ts.map +0 -1
  109. package/dist/find.js +0 -21
  110. package/dist/find.js.map +0 -1
  111. package/dist/findGlobal.d.ts +0 -3
  112. package/dist/findGlobal.d.ts.map +0 -1
  113. package/dist/findGlobal.js +0 -23
  114. package/dist/findGlobal.js.map +0 -1
  115. package/dist/findGlobalVersions.d.ts +0 -3
  116. package/dist/findGlobalVersions.d.ts.map +0 -1
  117. package/dist/findGlobalVersions.js +0 -24
  118. package/dist/findGlobalVersions.js.map +0 -1
  119. package/dist/findOne.d.ts +0 -5
  120. package/dist/findOne.d.ts.map +0 -1
  121. package/dist/findOne.js +0 -21
  122. package/dist/findOne.js.map +0 -1
  123. package/dist/findVersions.d.ts +0 -3
  124. package/dist/findVersions.d.ts.map +0 -1
  125. package/dist/findVersions.js +0 -24
  126. package/dist/findVersions.js.map +0 -1
  127. package/dist/init.d.ts +0 -3
  128. package/dist/init.d.ts.map +0 -1
  129. package/dist/init.js +0 -96
  130. package/dist/init.js.map +0 -1
  131. package/dist/migrate.d.ts +0 -3
  132. package/dist/migrate.d.ts.map +0 -1
  133. package/dist/migrate.js +0 -99
  134. package/dist/migrate.js.map +0 -1
  135. package/dist/migrateDown.d.ts +0 -3
  136. package/dist/migrateDown.d.ts.map +0 -1
  137. package/dist/migrateDown.js +0 -63
  138. package/dist/migrateDown.js.map +0 -1
  139. package/dist/migrateFresh.d.ts +0 -8
  140. package/dist/migrateFresh.d.ts.map +0 -1
  141. package/dist/migrateFresh.js +0 -72
  142. package/dist/migrateFresh.js.map +0 -1
  143. package/dist/migrateRefresh.d.ts +0 -6
  144. package/dist/migrateRefresh.d.ts.map +0 -1
  145. package/dist/migrateRefresh.js +0 -102
  146. package/dist/migrateRefresh.js.map +0 -1
  147. package/dist/migrateReset.d.ts +0 -6
  148. package/dist/migrateReset.d.ts.map +0 -1
  149. package/dist/migrateReset.js +0 -82
  150. package/dist/migrateReset.js.map +0 -1
  151. package/dist/migrateStatus.d.ts +0 -3
  152. package/dist/migrateStatus.d.ts.map +0 -1
  153. package/dist/migrateStatus.js +0 -44
  154. package/dist/migrateStatus.js.map +0 -1
  155. package/dist/queries/buildAndOrConditions.d.ts +0 -17
  156. package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
  157. package/dist/queries/buildAndOrConditions.js +0 -29
  158. package/dist/queries/buildAndOrConditions.js.map +0 -1
  159. package/dist/queries/buildQuery.d.ts +0 -31
  160. package/dist/queries/buildQuery.d.ts.map +0 -1
  161. package/dist/queries/buildQuery.js +0 -76
  162. package/dist/queries/buildQuery.js.map +0 -1
  163. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts +0 -2
  164. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  165. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +0 -14
  166. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  167. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts +0 -2
  168. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  169. package/dist/queries/createJSONQuery/formatJSONPathSegment.js +0 -5
  170. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  171. package/dist/queries/createJSONQuery/index.d.ts +0 -10
  172. package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
  173. package/dist/queries/createJSONQuery/index.js +0 -54
  174. package/dist/queries/createJSONQuery/index.js.map +0 -1
  175. package/dist/queries/getTableColumnFromPath.d.ts +0 -51
  176. package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
  177. package/dist/queries/getTableColumnFromPath.js +0 -445
  178. package/dist/queries/getTableColumnFromPath.js.map +0 -1
  179. package/dist/queries/operatorMap.d.ts +0 -18
  180. package/dist/queries/operatorMap.d.ts.map +0 -1
  181. package/dist/queries/operatorMap.js +0 -24
  182. package/dist/queries/operatorMap.js.map +0 -1
  183. package/dist/queries/parseParams.d.ts +0 -17
  184. package/dist/queries/parseParams.d.ts.map +0 -1
  185. package/dist/queries/parseParams.js +0 -182
  186. package/dist/queries/parseParams.js.map +0 -1
  187. package/dist/queries/sanitizeQueryValue.d.ts +0 -15
  188. package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
  189. package/dist/queries/sanitizeQueryValue.js +0 -90
  190. package/dist/queries/sanitizeQueryValue.js.map +0 -1
  191. package/dist/queries/selectDistinct.d.ts +0 -23
  192. package/dist/queries/selectDistinct.d.ts.map +0 -1
  193. package/dist/queries/selectDistinct.js +0 -41
  194. package/dist/queries/selectDistinct.js.map +0 -1
  195. package/dist/queryDrafts.d.ts +0 -3
  196. package/dist/queryDrafts.d.ts.map +0 -1
  197. package/dist/queryDrafts.js +0 -41
  198. package/dist/queryDrafts.js.map +0 -1
  199. package/dist/schema/build.d.ts +0 -30
  200. package/dist/schema/build.d.ts.map +0 -1
  201. package/dist/schema/build.js +0 -320
  202. package/dist/schema/build.js.map +0 -1
  203. package/dist/schema/createIndex.d.ts +0 -12
  204. package/dist/schema/createIndex.d.ts.map +0 -1
  205. package/dist/schema/createIndex.js +0 -18
  206. package/dist/schema/createIndex.js.map +0 -1
  207. package/dist/schema/createTableName.d.ts +0 -30
  208. package/dist/schema/createTableName.d.ts.map +0 -1
  209. package/dist/schema/createTableName.js +0 -31
  210. package/dist/schema/createTableName.js.map +0 -1
  211. package/dist/schema/idToUUID.d.ts +0 -3
  212. package/dist/schema/idToUUID.d.ts.map +0 -1
  213. package/dist/schema/idToUUID.js +0 -11
  214. package/dist/schema/idToUUID.js.map +0 -1
  215. package/dist/schema/parentIDColumnMap.d.ts +0 -4
  216. package/dist/schema/parentIDColumnMap.d.ts.map +0 -1
  217. package/dist/schema/parentIDColumnMap.js +0 -9
  218. package/dist/schema/parentIDColumnMap.js.map +0 -1
  219. package/dist/schema/setColumnID.d.ts +0 -11
  220. package/dist/schema/setColumnID.d.ts.map +0 -1
  221. package/dist/schema/setColumnID.js +0 -24
  222. package/dist/schema/setColumnID.js.map +0 -1
  223. package/dist/schema/traverseFields.d.ts +0 -38
  224. package/dist/schema/traverseFields.d.ts.map +0 -1
  225. package/dist/schema/traverseFields.js +0 -551
  226. package/dist/schema/traverseFields.js.map +0 -1
  227. package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
  228. package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
  229. package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
  230. package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
  231. package/dist/transactions/beginTransaction.d.ts +0 -3
  232. package/dist/transactions/beginTransaction.d.ts.map +0 -1
  233. package/dist/transactions/beginTransaction.js +0 -47
  234. package/dist/transactions/beginTransaction.js.map +0 -1
  235. package/dist/transactions/commitTransaction.d.ts +0 -3
  236. package/dist/transactions/commitTransaction.d.ts.map +0 -1
  237. package/dist/transactions/commitTransaction.js +0 -14
  238. package/dist/transactions/commitTransaction.js.map +0 -1
  239. package/dist/transactions/rollbackTransaction.d.ts +0 -3
  240. package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
  241. package/dist/transactions/rollbackTransaction.js +0 -13
  242. package/dist/transactions/rollbackTransaction.js.map +0 -1
  243. package/dist/transform/read/hasManyNumber.d.ts +0 -10
  244. package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
  245. package/dist/transform/read/hasManyNumber.js +0 -10
  246. package/dist/transform/read/hasManyNumber.js.map +0 -1
  247. package/dist/transform/read/hasManyText.d.ts +0 -10
  248. package/dist/transform/read/hasManyText.d.ts.map +0 -1
  249. package/dist/transform/read/hasManyText.js +0 -10
  250. package/dist/transform/read/hasManyText.js.map +0 -1
  251. package/dist/transform/read/index.d.ts +0 -12
  252. package/dist/transform/read/index.d.ts.map +0 -1
  253. package/dist/transform/read/index.js +0 -43
  254. package/dist/transform/read/index.js.map +0 -1
  255. package/dist/transform/read/relationship.d.ts +0 -10
  256. package/dist/transform/read/relationship.d.ts.map +0 -1
  257. package/dist/transform/read/relationship.js +0 -64
  258. package/dist/transform/read/relationship.js.map +0 -1
  259. package/dist/transform/read/traverseFields.d.ts +0 -52
  260. package/dist/transform/read/traverseFields.d.ts.map +0 -1
  261. package/dist/transform/read/traverseFields.js +0 -421
  262. package/dist/transform/read/traverseFields.js.map +0 -1
  263. package/dist/transform/write/array.d.ts +0 -26
  264. package/dist/transform/write/array.d.ts.map +0 -1
  265. package/dist/transform/write/array.js +0 -58
  266. package/dist/transform/write/array.js.map +0 -1
  267. package/dist/transform/write/blocks.d.ts +0 -25
  268. package/dist/transform/write/blocks.d.ts.map +0 -1
  269. package/dist/transform/write/blocks.js +0 -54
  270. package/dist/transform/write/blocks.js.map +0 -1
  271. package/dist/transform/write/index.d.ts +0 -13
  272. package/dist/transform/write/index.d.ts.map +0 -1
  273. package/dist/transform/write/index.js +0 -41
  274. package/dist/transform/write/index.js.map +0 -1
  275. package/dist/transform/write/numbers.d.ts +0 -8
  276. package/dist/transform/write/numbers.d.ts.map +0 -1
  277. package/dist/transform/write/numbers.js +0 -11
  278. package/dist/transform/write/numbers.js.map +0 -1
  279. package/dist/transform/write/relationships.d.ts +0 -10
  280. package/dist/transform/write/relationships.d.ts.map +0 -1
  281. package/dist/transform/write/relationships.js +0 -23
  282. package/dist/transform/write/relationships.js.map +0 -1
  283. package/dist/transform/write/selects.d.ts +0 -8
  284. package/dist/transform/write/selects.d.ts.map +0 -1
  285. package/dist/transform/write/selects.js +0 -20
  286. package/dist/transform/write/selects.js.map +0 -1
  287. package/dist/transform/write/texts.d.ts +0 -8
  288. package/dist/transform/write/texts.d.ts.map +0 -1
  289. package/dist/transform/write/texts.js +0 -11
  290. package/dist/transform/write/texts.js.map +0 -1
  291. package/dist/transform/write/traverseFields.d.ts +0 -50
  292. package/dist/transform/write/traverseFields.d.ts.map +0 -1
  293. package/dist/transform/write/traverseFields.js +0 -428
  294. package/dist/transform/write/traverseFields.js.map +0 -1
  295. package/dist/transform/write/types.d.ts +0 -43
  296. package/dist/transform/write/types.d.ts.map +0 -1
  297. package/dist/transform/write/types.js +0 -3
  298. package/dist/transform/write/types.js.map +0 -1
  299. package/dist/update.d.ts +0 -3
  300. package/dist/update.d.ts.map +0 -1
  301. package/dist/update.js +0 -55
  302. package/dist/update.js.map +0 -1
  303. package/dist/updateGlobal.d.ts +0 -5
  304. package/dist/updateGlobal.d.ts.map +0 -1
  305. package/dist/updateGlobal.js +0 -25
  306. package/dist/updateGlobal.js.map +0 -1
  307. package/dist/updateGlobalVersion.d.ts +0 -5
  308. package/dist/updateGlobalVersion.d.ts.map +0 -1
  309. package/dist/updateGlobalVersion.js +0 -36
  310. package/dist/updateGlobalVersion.js.map +0 -1
  311. package/dist/updateVersion.d.ts +0 -5
  312. package/dist/updateVersion.d.ts.map +0 -1
  313. package/dist/updateVersion.js +0 -36
  314. package/dist/updateVersion.js.map +0 -1
  315. package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
  316. package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
  317. package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
  318. package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
  319. package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
  320. package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
  321. package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
  322. package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
  323. package/dist/upsertRow/index.d.ts +0 -4
  324. package/dist/upsertRow/index.d.ts.map +0 -1
  325. package/dist/upsertRow/index.js +0 -277
  326. package/dist/upsertRow/index.js.map +0 -1
  327. package/dist/upsertRow/insertArrays.d.ts +0 -13
  328. package/dist/upsertRow/insertArrays.d.ts.map +0 -1
  329. package/dist/upsertRow/insertArrays.js +0 -68
  330. package/dist/upsertRow/insertArrays.js.map +0 -1
  331. package/dist/upsertRow/types.d.ts +0 -27
  332. package/dist/upsertRow/types.d.ts.map +0 -1
  333. package/dist/upsertRow/types.js +0 -3
  334. package/dist/upsertRow/types.js.map +0 -1
  335. package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
  336. package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
  337. package/dist/utilities/appendPrefixToKeys.js +0 -6
  338. package/dist/utilities/appendPrefixToKeys.js.map +0 -1
  339. package/dist/utilities/createBlocksMap.d.ts +0 -5
  340. package/dist/utilities/createBlocksMap.d.ts.map +0 -1
  341. package/dist/utilities/createBlocksMap.js +0 -29
  342. package/dist/utilities/createBlocksMap.js.map +0 -1
  343. package/dist/utilities/createMigrationTable.d.ts +0 -3
  344. package/dist/utilities/createMigrationTable.d.ts.map +0 -1
  345. package/dist/utilities/createMigrationTable.js +0 -13
  346. package/dist/utilities/createMigrationTable.js.map +0 -1
  347. package/dist/utilities/createRelationshipMap.d.ts +0 -2
  348. package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
  349. package/dist/utilities/createRelationshipMap.js +0 -19
  350. package/dist/utilities/createRelationshipMap.js.map +0 -1
  351. package/dist/utilities/hasLocalesTable.d.ts +0 -3
  352. package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
  353. package/dist/utilities/hasLocalesTable.js +0 -11
  354. package/dist/utilities/hasLocalesTable.js.map +0 -1
  355. package/dist/utilities/isArrayOfRows.d.ts +0 -2
  356. package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
  357. package/dist/utilities/isArrayOfRows.js +0 -5
  358. package/dist/utilities/isArrayOfRows.js.map +0 -1
  359. package/dist/utilities/migrationTableExists.d.ts +0 -3
  360. package/dist/utilities/migrationTableExists.d.ts.map +0 -1
  361. package/dist/utilities/migrationTableExists.js +0 -9
  362. package/dist/utilities/migrationTableExists.js.map +0 -1
  363. package/dist/utilities/parseError.d.ts +0 -5
  364. package/dist/utilities/parseError.d.ts.map +0 -1
  365. package/dist/utilities/parseError.js +0 -17
  366. package/dist/utilities/parseError.js.map +0 -1
  367. package/dist/utilities/pushDevSchema.d.ts +0 -9
  368. package/dist/utilities/pushDevSchema.d.ts.map +0 -1
  369. package/dist/utilities/pushDevSchema.js +0 -58
  370. package/dist/utilities/pushDevSchema.js.map +0 -1
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAKpC,SAASA,GAAG,EAAEC,EAAE,EAAEC,IAAI,EAAEC,GAAG,QAAQ,cAAa;AAChD,SAASC,KAAK,QAAQ,sBAAqB;AAC3C,SAASC,QAAQ,QAAQ,iBAAgB;AACzC,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,gBAAe;AAC5D,SAASC,qBAAqB,QAAQ,oBAAmB;AACzD,OAAOC,iBAAiB,gBAAe;AACvC,SAASC,MAAMC,IAAI,QAAQ,OAAM;AA6CjC;;;;CAIC,GACD,OAAO,MAAMC,yBAAyB,CAAC,EACrCC,OAAO,EACPC,UAAU,EACVC,cAAc,EACdC,eAAe,EAAE,EACjBC,gBAAgBC,sBAAsB,EACtCC,cAAc,EAAE,EAChBC,MAAM,EACNC,WAAW,EACXC,KAAK,EACLC,QAAQC,cAAc,EACtBC,cAAcC,gBAAgB,EAC9BC,eAAeC,qBAAqB,EACpCC,YAAY,EAC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are 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"}
@@ -1,182 +0,0 @@
1
- /* eslint-disable no-await-in-loop */ import { and, ilike, isNotNull, isNull, ne, notInArray, or, sql } from 'drizzle-orm';
2
- import { QueryError } from 'payload/errors';
3
- import { validOperators } from 'payload/types';
4
- import { buildAndOrConditions } from './buildAndOrConditions.js';
5
- import { convertPathToJSONTraversal } from './createJSONQuery/convertPathToJSONTraversal.js';
6
- import { createJSONQuery } from './createJSONQuery/index.js';
7
- import { getTableColumnFromPath } from './getTableColumnFromPath.js';
8
- import { operatorMap } from './operatorMap.js';
9
- import { sanitizeQueryValue } from './sanitizeQueryValue.js';
10
- export async function parseParams({ adapter, fields, joinAliases, joins, locale, selectFields, tableName, where }) {
11
- let result;
12
- const constraints = [];
13
- if (typeof where === 'object' && Object.keys(where).length > 0) {
14
- // We need to determine if the whereKey is an AND, OR, or a schema path
15
- for (const relationOrPath of Object.keys(where)){
16
- if (relationOrPath) {
17
- const condition = where[relationOrPath];
18
- let conditionOperator;
19
- if (relationOrPath.toLowerCase() === 'and') {
20
- conditionOperator = 'and';
21
- } else if (relationOrPath.toLowerCase() === 'or') {
22
- conditionOperator = 'or';
23
- }
24
- if (Array.isArray(condition)) {
25
- const builtConditions = await buildAndOrConditions({
26
- adapter,
27
- fields,
28
- joinAliases,
29
- joins,
30
- locale,
31
- selectFields,
32
- tableName,
33
- where: condition
34
- });
35
- if (builtConditions.length > 0) {
36
- result = operatorMap[conditionOperator](...builtConditions);
37
- }
38
- } else {
39
- // It's a path - and there can be multiple comparisons on a single path.
40
- // For example - title like 'test' and title not equal to 'tester'
41
- // So we need to loop on keys again here to handle each operator independently
42
- const pathOperators = where[relationOrPath];
43
- if (typeof pathOperators === 'object') {
44
- for (const operator of Object.keys(pathOperators)){
45
- if (validOperators.includes(operator)) {
46
- const val = where[relationOrPath][operator];
47
- const { columnName, constraints: queryConstraints, field, getNotNullColumnByValue, pathSegments, rawColumn, table } = getTableColumnFromPath({
48
- adapter,
49
- collectionPath: relationOrPath,
50
- fields,
51
- joinAliases,
52
- joins,
53
- locale,
54
- pathSegments: relationOrPath.replace(/__/g, '.').split('.'),
55
- selectFields,
56
- tableName,
57
- value: val
58
- });
59
- queryConstraints.forEach(({ columnName: col, table: constraintTable, value })=>{
60
- if (typeof value === 'string' && value.indexOf('%') > -1) {
61
- constraints.push(operatorMap.like(constraintTable[col], value));
62
- } else {
63
- constraints.push(operatorMap.equals(constraintTable[col], value));
64
- }
65
- });
66
- if ([
67
- 'json',
68
- 'richText'
69
- ].includes(field.type) && Array.isArray(pathSegments) && pathSegments.length > 1) {
70
- const segments = pathSegments.slice(1);
71
- segments.unshift(table[columnName].name);
72
- if (field.type === 'richText') {
73
- const jsonQuery = createJSONQuery({
74
- operator,
75
- pathSegments: segments,
76
- treatAsArray: [
77
- 'children'
78
- ],
79
- treatRootAsArray: true,
80
- value: val
81
- });
82
- constraints.push(sql.raw(jsonQuery));
83
- break;
84
- }
85
- const jsonQuery = convertPathToJSONTraversal(pathSegments);
86
- const operatorKeys = {
87
- contains: {
88
- operator: 'ilike',
89
- wildcard: '%'
90
- },
91
- equals: {
92
- operator: '=',
93
- wildcard: ''
94
- },
95
- exists: {
96
- operator: val === true ? 'is not null' : 'is null'
97
- },
98
- like: {
99
- operator: 'like',
100
- wildcard: '%'
101
- },
102
- not_equals: {
103
- operator: '<>',
104
- wildcard: ''
105
- }
106
- };
107
- let formattedValue = `'${operatorKeys[operator].wildcard}${val}${operatorKeys[operator].wildcard}'`;
108
- if (operator === 'exists') {
109
- formattedValue = '';
110
- }
111
- constraints.push(sql.raw(`${table[columnName].name}${jsonQuery} ${operatorKeys[operator].operator} ${formattedValue}`));
112
- break;
113
- }
114
- if (getNotNullColumnByValue) {
115
- const columnName = getNotNullColumnByValue(val);
116
- if (columnName) {
117
- constraints.push(isNotNull(table[columnName]));
118
- } else {
119
- throw new QueryError([
120
- {
121
- path: relationOrPath
122
- }
123
- ]);
124
- }
125
- break;
126
- }
127
- if (operator === 'like') {
128
- constraints.push(and(...val.split(' ').map((word)=>ilike(table[columnName], `%${word}%`))));
129
- break;
130
- }
131
- const sanitizedQueryValue = sanitizeQueryValue({
132
- adapter,
133
- field,
134
- operator,
135
- relationOrPath,
136
- val
137
- });
138
- if (sanitizedQueryValue === null) {
139
- break;
140
- }
141
- const { operator: queryOperator, value: queryValue } = sanitizedQueryValue;
142
- if (queryOperator === 'not_equals' && queryValue !== null) {
143
- constraints.push(or(isNull(rawColumn || table[columnName]), /* eslint-disable @typescript-eslint/no-explicit-any */ ne(rawColumn || table[columnName], queryValue)));
144
- break;
145
- }
146
- if ((field.type === 'relationship' || field.type === 'upload') && Array.isArray(queryValue) && operator === 'not_in') {
147
- constraints.push(sql`${notInArray(table[columnName], queryValue)} OR
148
- ${table[columnName]}
149
- IS
150
- NULL`);
151
- break;
152
- }
153
- if (operator === 'equals' && queryValue === null) {
154
- constraints.push(isNull(rawColumn || table[columnName]));
155
- break;
156
- }
157
- if (operator === 'not_equals' && queryValue === null) {
158
- constraints.push(isNotNull(rawColumn || table[columnName]));
159
- break;
160
- }
161
- constraints.push(operatorMap[queryOperator](rawColumn || table[columnName], queryValue));
162
- }
163
- }
164
- }
165
- }
166
- }
167
- }
168
- }
169
- if (constraints.length > 0) {
170
- if (result) {
171
- result = and(result, ...constraints);
172
- } else {
173
- result = and(...constraints);
174
- }
175
- }
176
- if (constraints.length === 1 && !result) {
177
- [result] = constraints;
178
- }
179
- return result;
180
- }
181
-
182
- //# sourceMappingURL=parseParams.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/queries/parseParams.ts"],"sourcesContent":["/* eslint-disable no-await-in-loop */\nimport type { SQL } from 'drizzle-orm'\nimport type { Field, Operator, Where } from 'payload/types'\n\nimport { and, ilike, isNotNull, isNull, ne, notInArray, or, sql } from 'drizzle-orm'\nimport { QueryError } from 'payload/errors'\nimport { validOperators } from 'payload/types'\n\nimport type { GenericColumn, PostgresAdapter } from '../types.js'\nimport type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.js'\n\nimport { buildAndOrConditions } from './buildAndOrConditions.js'\nimport { convertPathToJSONTraversal } from './createJSONQuery/convertPathToJSONTraversal.js'\nimport { createJSONQuery } from './createJSONQuery/index.js'\nimport { getTableColumnFromPath } from './getTableColumnFromPath.js'\nimport { operatorMap } from './operatorMap.js'\nimport { sanitizeQueryValue } from './sanitizeQueryValue.js'\n\ntype Args = {\n adapter: PostgresAdapter\n fields: Field[]\n joinAliases: BuildQueryJoinAliases\n joins: BuildQueryJoins\n locale: string\n selectFields: Record<string, GenericColumn>\n tableName: string\n where: Where\n}\n\nexport async function parseParams({\n adapter,\n fields,\n joinAliases,\n joins,\n locale,\n selectFields,\n tableName,\n where,\n}: Args): Promise<SQL> {\n let result: SQL\n const constraints: SQL[] = []\n\n if (typeof where === 'object' && Object.keys(where).length > 0) {\n // We need to determine if the whereKey is an AND, OR, or a schema path\n for (const relationOrPath of Object.keys(where)) {\n if (relationOrPath) {\n const condition = where[relationOrPath]\n let conditionOperator: 'and' | 'or'\n if (relationOrPath.toLowerCase() === 'and') {\n conditionOperator = 'and'\n } else if (relationOrPath.toLowerCase() === 'or') {\n conditionOperator = 'or'\n }\n if (Array.isArray(condition)) {\n const builtConditions = await buildAndOrConditions({\n adapter,\n fields,\n joinAliases,\n joins,\n locale,\n selectFields,\n tableName,\n where: condition,\n })\n if (builtConditions.length > 0) {\n result = operatorMap[conditionOperator](...builtConditions)\n }\n } else {\n // It's a path - and there can be multiple comparisons on a single path.\n // For example - title like 'test' and title not equal to 'tester'\n // So we need to loop on keys again here to handle each operator independently\n const pathOperators = where[relationOrPath]\n if (typeof pathOperators === 'object') {\n for (const operator of Object.keys(pathOperators)) {\n if (validOperators.includes(operator as Operator)) {\n const val = where[relationOrPath][operator]\n const {\n columnName,\n constraints: queryConstraints,\n field,\n getNotNullColumnByValue,\n pathSegments,\n rawColumn,\n table,\n } = getTableColumnFromPath({\n adapter,\n collectionPath: relationOrPath,\n fields,\n joinAliases,\n joins,\n locale,\n pathSegments: relationOrPath.replace(/__/g, '.').split('.'),\n selectFields,\n tableName,\n value: val,\n })\n\n queryConstraints.forEach(({ columnName: col, table: constraintTable, value }) => {\n if (typeof value === 'string' && value.indexOf('%') > -1) {\n constraints.push(operatorMap.like(constraintTable[col], value))\n } else {\n constraints.push(operatorMap.equals(constraintTable[col], value))\n }\n })\n\n if (\n ['json', 'richText'].includes(field.type) &&\n Array.isArray(pathSegments) &&\n pathSegments.length > 1\n ) {\n const segments = pathSegments.slice(1)\n segments.unshift(table[columnName].name)\n\n if (field.type === 'richText') {\n const jsonQuery = createJSONQuery({\n operator,\n pathSegments: segments,\n treatAsArray: ['children'],\n treatRootAsArray: true,\n value: val,\n })\n\n constraints.push(sql.raw(jsonQuery))\n break\n }\n\n const jsonQuery = convertPathToJSONTraversal(pathSegments)\n const operatorKeys = {\n contains: { operator: 'ilike', wildcard: '%' },\n equals: { operator: '=', wildcard: '' },\n exists: { operator: val === true ? 'is not null' : 'is null' },\n like: { operator: 'like', wildcard: '%' },\n not_equals: { operator: '<>', wildcard: '' },\n }\n let formattedValue = `'${operatorKeys[operator].wildcard}${val}${operatorKeys[operator].wildcard}'`\n\n if (operator === 'exists') {\n formattedValue = ''\n }\n\n constraints.push(\n sql.raw(\n `${table[columnName].name}${jsonQuery} ${operatorKeys[operator].operator} ${formattedValue}`,\n ),\n )\n\n break\n }\n\n if (getNotNullColumnByValue) {\n const columnName = getNotNullColumnByValue(val)\n if (columnName) {\n constraints.push(isNotNull(table[columnName]))\n } else {\n throw new QueryError([{ path: relationOrPath }])\n }\n break\n }\n\n if (operator === 'like') {\n constraints.push(\n and(...val.split(' ').map((word) => ilike(table[columnName], `%${word}%`))),\n )\n break\n }\n\n const sanitizedQueryValue = sanitizeQueryValue({\n adapter,\n field,\n operator,\n relationOrPath,\n val,\n })\n\n if (sanitizedQueryValue === null) {\n break\n }\n\n const { operator: queryOperator, value: queryValue } = sanitizedQueryValue\n\n if (queryOperator === 'not_equals' && queryValue !== null) {\n constraints.push(\n or(\n isNull(rawColumn || table[columnName]),\n /* eslint-disable @typescript-eslint/no-explicit-any */\n ne<any>(rawColumn || table[columnName], queryValue),\n ),\n )\n break\n }\n\n if (\n (field.type === 'relationship' || field.type === 'upload') &&\n Array.isArray(queryValue) &&\n operator === 'not_in'\n ) {\n constraints.push(\n sql`${notInArray(table[columnName], queryValue)} OR\n ${table[columnName]}\n IS\n NULL`,\n )\n\n break\n }\n\n if (operator === 'equals' && queryValue === null) {\n constraints.push(isNull(rawColumn || table[columnName]))\n break\n }\n\n if (operator === 'not_equals' && queryValue === null) {\n constraints.push(isNotNull(rawColumn || table[columnName]))\n break\n }\n\n constraints.push(\n operatorMap[queryOperator](rawColumn || table[columnName], queryValue),\n )\n }\n }\n }\n }\n }\n }\n }\n if (constraints.length > 0) {\n if (result) {\n result = and(result, ...constraints)\n } else {\n result = and(...constraints)\n }\n }\n if (constraints.length === 1 && !result) {\n ;[result] = constraints\n }\n\n return result\n}\n"],"names":["and","ilike","isNotNull","isNull","ne","notInArray","or","sql","QueryError","validOperators","buildAndOrConditions","convertPathToJSONTraversal","createJSONQuery","getTableColumnFromPath","operatorMap","sanitizeQueryValue","parseParams","adapter","fields","joinAliases","joins","locale","selectFields","tableName","where","result","constraints","Object","keys","length","relationOrPath","condition","conditionOperator","toLowerCase","Array","isArray","builtConditions","pathOperators","operator","includes","val","columnName","queryConstraints","field","getNotNullColumnByValue","pathSegments","rawColumn","table","collectionPath","replace","split","value","forEach","col","constraintTable","indexOf","push","like","equals","type","segments","slice","unshift","name","jsonQuery","treatAsArray","treatRootAsArray","raw","operatorKeys","contains","wildcard","exists","not_equals","formattedValue","path","map","word","sanitizedQueryValue","queryOperator","queryValue"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,mCAAmC,GAInC,SAASA,GAAG,EAAEC,KAAK,EAAEC,SAAS,EAAEC,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAEC,EAAE,EAAEC,GAAG,QAAQ,cAAa;AACpF,SAASC,UAAU,QAAQ,iBAAgB;AAC3C,SAASC,cAAc,QAAQ,gBAAe;AAK9C,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,0BAA0B,QAAQ,kDAAiD;AAC5F,SAASC,eAAe,QAAQ,6BAA4B;AAC5D,S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C,eAAe,MAAM;oCACzDrD,YAAY8B,IAAI,CACdlD,GACEH,OAAO2C,aAAaC,KAAK,CAACN,WAAW,GACrC,qDAAqD,GACrDrC,GAAQ0C,aAAaC,KAAK,CAACN,WAAW,EAAEsC;oCAG5C;gCACF;gCAEA,IACE,AAACpC,CAAAA,MAAMgB,IAAI,KAAK,kBAAkBhB,MAAMgB,IAAI,KAAK,QAAO,KACxDzB,MAAMC,OAAO,CAAC4C,eACdzC,aAAa,UACb;oCACAZ,YAAY8B,IAAI,CACdjD,GAAG,CAAC,EAAEF,WAAW0C,KAAK,CAACN,WAAW,EAAEsC,YAAY;oBAChD,EAAEhC,KAAK,CAACN,WAAW,CAAC;;wBAEhB,CAAC;oCAGP;gCACF;gCAEA,IAAIH,aAAa,YAAYyC,eAAe,MAAM;oCAChDrD,YAAY8B,IAAI,CAACrD,OAAO2C,aAAaC,KAAK,CAACN,WAAW;oCACtD;gCACF;gCAEA,IAAIH,aAAa,gBAAgByC,eAAe,MAAM;oCACpDrD,YAAY8B,IAAI,CAACtD,UAAU4C,aAAaC,KAAK,CAACN,WAAW;oCACzD;gCACF;gCAEAf,YAAY8B,IAAI,CACd1C,WAAW,CAACgE,cAAc,CAAChC,aAAaC,KAAK,CAACN,WAAW,EAAEsC;4BAE/D;wBACF;oBACF;gBACF;YACF;QACF;IACF;IACA,IAAIrD,YAAYG,MAAM,GAAG,GAAG;QAC1B,IAAIJ,QAAQ;YACVA,SAASzB,IAAIyB,WAAWC;QAC1B,OAAO;YACLD,SAASzB,OAAO0B;QAClB;IACF;IACA,IAAIA,YAAYG,MAAM,KAAK,KAAK,CAACJ,QAAQ;QACtC,CAACA,OAAO,GAAGC;IACd;IAEA,OAAOD;AACT"}
@@ -1,15 +0,0 @@
1
- import { type Field, type TabAsField } from 'payload/types';
2
- import type { PostgresAdapter } from '../types.js';
3
- type SanitizeQueryValueArgs = {
4
- adapter: PostgresAdapter;
5
- field: Field | TabAsField;
6
- operator: string;
7
- relationOrPath: string;
8
- val: any;
9
- };
10
- export declare const sanitizeQueryValue: ({ adapter, field, operator: operatorArg, relationOrPath, val, }: SanitizeQueryValueArgs) => {
11
- operator: string;
12
- value: unknown;
13
- };
14
- export {};
15
- //# sourceMappingURL=sanitizeQueryValue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sanitizeQueryValue.d.ts","sourceRoot":"","sources":["../../src/queries/sanitizeQueryValue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAoB,MAAM,eAAe,CAAA;AAG7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,eAAe,CAAA;IACxB,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,GAAG,EAAE,GAAG,CAAA;CACT,CAAA;AAED,eAAO,MAAM,kBAAkB,oEAM5B,sBAAsB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAyF7D,CAAA"}
@@ -1,90 +0,0 @@
1
- import { APIError } from 'payload/errors';
2
- import { fieldAffectsData } from 'payload/types';
3
- import { createArrayFromCommaDelineated } from 'payload/utilities';
4
- export const sanitizeQueryValue = ({ adapter, field, operator: operatorArg, relationOrPath, val })=>{
5
- let operator = operatorArg;
6
- let formattedValue = val;
7
- if (!fieldAffectsData(field)) return {
8
- operator,
9
- value: formattedValue
10
- };
11
- if ((field.type === 'relationship' || field.type === 'upload') && !relationOrPath.endsWith('relationTo') && Array.isArray(formattedValue)) {
12
- const allPossibleIDTypes = [];
13
- formattedValue.forEach((val)=>{
14
- if (adapter.idType !== 'uuid' && typeof val === 'string') {
15
- allPossibleIDTypes.push(val, parseInt(val));
16
- } else if (typeof val === 'string') {
17
- allPossibleIDTypes.push(val);
18
- } else {
19
- allPossibleIDTypes.push(val, String(val));
20
- }
21
- });
22
- formattedValue = allPossibleIDTypes;
23
- }
24
- // Cast incoming values as proper searchable types
25
- if (field.type === 'checkbox' && typeof val === 'string') {
26
- if (val.toLowerCase() === 'true') formattedValue = true;
27
- if (val.toLowerCase() === 'false') formattedValue = false;
28
- }
29
- if ([
30
- 'all',
31
- 'in',
32
- 'not_in'
33
- ].includes(operator)) {
34
- if (typeof formattedValue === 'string') {
35
- formattedValue = createArrayFromCommaDelineated(formattedValue);
36
- if (field.type === 'number') {
37
- formattedValue = formattedValue.map((arrayVal)=>parseFloat(arrayVal));
38
- }
39
- }
40
- if (!Array.isArray(formattedValue) || formattedValue.length === 0) {
41
- return null;
42
- }
43
- }
44
- if (field.type === 'number' && typeof formattedValue === 'string') {
45
- formattedValue = Number(val);
46
- }
47
- if (field.type === 'date' && operator !== 'exists') {
48
- if (typeof val === 'string') {
49
- formattedValue = new Date(val);
50
- if (Number.isNaN(Date.parse(formattedValue))) {
51
- return {
52
- operator,
53
- value: undefined
54
- };
55
- }
56
- }
57
- if (typeof val === 'number') {
58
- formattedValue = new Date(val);
59
- }
60
- }
61
- if ([
62
- 'relationship',
63
- 'upload'
64
- ].includes(field.type)) {
65
- if (val === 'null') {
66
- formattedValue = null;
67
- }
68
- }
69
- if ('hasMany' in field && field.hasMany && operator === 'contains') {
70
- operator = 'equals';
71
- }
72
- if (operator === 'near' || operator === 'within' || operator === 'intersects') {
73
- throw new APIError(`Querying with '${operator}' is not supported with the postgres database adapter.`);
74
- }
75
- if (operator === 'contains') {
76
- formattedValue = `%${formattedValue}%`;
77
- }
78
- if (operator === 'exists') {
79
- formattedValue = formattedValue === 'true' || formattedValue === true;
80
- if (formattedValue === false) {
81
- operator = 'isNull';
82
- }
83
- }
84
- return {
85
- operator,
86
- value: formattedValue
87
- };
88
- };
89
-
90
- //# sourceMappingURL=sanitizeQueryValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/queries/sanitizeQueryValue.ts"],"sourcesContent":["import { APIError } from 'payload/errors'\nimport { type Field, type TabAsField, fieldAffectsData } from 'payload/types'\nimport { createArrayFromCommaDelineated } from 'payload/utilities'\n\nimport type { PostgresAdapter } from '../types.js'\n\ntype SanitizeQueryValueArgs = {\n adapter: PostgresAdapter\n field: Field | TabAsField\n operator: string\n relationOrPath: string\n val: any\n}\n\nexport const sanitizeQueryValue = ({\n adapter,\n field,\n operator: operatorArg,\n relationOrPath,\n val,\n}: SanitizeQueryValueArgs): { operator: string; value: unknown } => {\n let operator = operatorArg\n let formattedValue = val\n\n if (!fieldAffectsData(field)) return { operator, value: formattedValue }\n\n if (\n (field.type === 'relationship' || field.type === 'upload') &&\n !relationOrPath.endsWith('relationTo') &&\n Array.isArray(formattedValue)\n ) {\n const allPossibleIDTypes: (number | string)[] = []\n formattedValue.forEach((val) => {\n if (adapter.idType !== 'uuid' && typeof val === 'string') {\n allPossibleIDTypes.push(val, parseInt(val))\n } else if (typeof val === 'string') {\n allPossibleIDTypes.push(val)\n } else {\n allPossibleIDTypes.push(val, String(val))\n }\n })\n formattedValue = allPossibleIDTypes\n }\n\n // Cast incoming values as proper searchable types\n if (field.type === 'checkbox' && typeof val === 'string') {\n if (val.toLowerCase() === 'true') formattedValue = true\n if (val.toLowerCase() === 'false') formattedValue = false\n }\n\n if (['all', 'in', 'not_in'].includes(operator)) {\n if (typeof formattedValue === 'string') {\n formattedValue = createArrayFromCommaDelineated(formattedValue)\n\n if (field.type === 'number') {\n formattedValue = formattedValue.map((arrayVal) => parseFloat(arrayVal))\n }\n }\n\n if (!Array.isArray(formattedValue) || formattedValue.length === 0) {\n return null\n }\n }\n\n if (field.type === 'number' && typeof formattedValue === 'string') {\n formattedValue = Number(val)\n }\n\n if (field.type === 'date' && operator !== 'exists') {\n if (typeof val === 'string') {\n formattedValue = new Date(val)\n if (Number.isNaN(Date.parse(formattedValue))) {\n return { operator, value: undefined }\n }\n }\n\n if (typeof val === 'number') {\n formattedValue = new Date(val)\n }\n }\n\n if (['relationship', 'upload'].includes(field.type)) {\n if (val === 'null') {\n formattedValue = null\n }\n }\n\n if ('hasMany' in field && field.hasMany && operator === 'contains') {\n operator = 'equals'\n }\n\n if (operator === 'near' || operator === 'within' || operator === 'intersects') {\n throw new APIError(\n `Querying with '${operator}' is not supported with the postgres database adapter.`,\n )\n }\n\n if (operator === 'contains') {\n formattedValue = `%${formattedValue}%`\n }\n\n if (operator === 'exists') {\n formattedValue = formattedValue === 'true' || formattedValue === true\n if (formattedValue === false) {\n operator = 'isNull'\n }\n }\n\n return { operator, value: formattedValue }\n}\n"],"names":["APIError","fieldAffectsData","createArrayFromCommaDelineated","sanitizeQueryValue","adapter","field","operator","operatorArg","relationOrPath","val","formattedValue","value","type","endsWith","Array","isArray","allPossibleIDTypes","forEach","idType","push","parseInt","String","toLowerCase","includes","map","arrayVal","parseFloat","length","Number","Date","isNaN","parse","undefined","hasMany"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,QAAQ,QAAQ,iBAAgB;AACzC,SAAsCC,gBAAgB,QAAQ,gBAAe;AAC7E,SAASC,8BAA8B,QAAQ,oBAAmB;AAYlE,OAAO,MAAMC,qBAAqB,CAAC,EACjCC,OAAO,EACPC,KAAK,EACLC,UAAUC,WAAW,EACrBC,cAAc,EACdC,GAAG,EACoB;IACvB,IAAIH,WAAWC;IACf,IAAIG,iBAAiBD;IAErB,IAAI,CAACR,iBAAiBI,QAAQ,OAAO;QAAEC;QAAUK,OAAOD;IAAe;IAEvE,IACE,AAACL,CAAAA,MAAMO,IAAI,KAAK,kBAAkBP,MAAMO,IAAI,KAAK,QAAO,KACxD,CAACJ,eAAeK,QAAQ,CAAC,iBACzBC,MAAMC,OAAO,CAACL,iBACd;QACA,MAAMM,qBAA0C,EAAE;QAClDN,eAAeO,OAAO,CAAC,CAACR;YACtB,IAAIL,QAAQ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ACnD,IAAIH,QAAQ,QAAQ;YAClBC,iBAAiB;QACnB;IACF;IAEA,IAAI,aAAaL,SAASA,MAAM4B,OAAO,IAAI3B,aAAa,YAAY;QAClEA,WAAW;IACb;IAEA,IAAIA,aAAa,UAAUA,aAAa,YAAYA,aAAa,cAAc;QAC7E,MAAM,IAAIN,SACR,CAAC,eAAe,EAAEM,SAAS,sDAAsD,CAAC;IAEtF;IAEA,IAAIA,aAAa,YAAY;QAC3BI,iBAAiB,CAAC,CAAC,EAAEA,eAAe,CAAC,CAAC;IACxC;IAEA,IAAIJ,aAAa,UAAU;QACzBI,iBAAiBA,mBAAmB,UAAUA,mBAAmB;QACjE,IAAIA,mBAAmB,OAAO;YAC5BJ,WAAW;QACb;IACF;IAEA,OAAO;QAAEA;QAAUK,OAAOD;IAAe;AAC3C,EAAC"}
@@ -1,23 +0,0 @@
1
- import type { QueryPromise, SQL } from 'drizzle-orm';
2
- import type { ChainedMethods } from '../find/chainMethods.js';
3
- import type { DrizzleDB, PostgresAdapter } from '../types.js';
4
- import type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.js';
5
- import { type GenericColumn } from '../types.js';
6
- type Args = {
7
- adapter: PostgresAdapter;
8
- chainedMethods?: ChainedMethods;
9
- db: DrizzleDB;
10
- joinAliases: BuildQueryJoinAliases;
11
- joins: BuildQueryJoins;
12
- selectFields: Record<string, GenericColumn>;
13
- tableName: string;
14
- where: SQL;
15
- };
16
- /**
17
- * Selects distinct records from a table only if there are joins that need to be used, otherwise return null
18
- */
19
- export declare const selectDistinct: ({ adapter, chainedMethods, db, joinAliases, joins, selectFields, tableName, where, }: Args) => QueryPromise<Record<string, GenericColumn> & {
20
- id: number | string;
21
- }[]>;
22
- export {};
23
- //# sourceMappingURL=selectDistinct.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"selectDistinct.d.ts","sourceRoot":"","sources":["../../src/queries/selectDistinct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAG7E,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,EAAE,EAAE,SAAS,CAAA;IACb,WAAW,EAAE,qBAAqB,CAAA;IAClC,KAAK,EAAE,eAAe,CAAA;IACtB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,GAAG,CAAA;CACX,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,yFASxB,IAAI,KAAG,aAAa,OAAO,MAAM,EAAE,aAAa,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EAAE,CA2B/E,CAAA"}
@@ -1,41 +0,0 @@
1
- import { chainMethods } from '../find/chainMethods.js';
2
- /**
3
- * Selects distinct records from a table only if there are joins that need to be used, otherwise return null
4
- */ export const selectDistinct = ({ adapter, chainedMethods = [], db, joinAliases, joins, selectFields, tableName, where })=>{
5
- if (Object.keys(joins).length > 0 || joinAliases.length > 0) {
6
- if (where) {
7
- chainedMethods.push({
8
- args: [
9
- where
10
- ],
11
- method: 'where'
12
- });
13
- }
14
- joinAliases.forEach(({ condition, table })=>{
15
- chainedMethods.push({
16
- args: [
17
- table,
18
- condition
19
- ],
20
- method: 'leftJoin'
21
- });
22
- });
23
- Object.entries(joins).forEach(([joinTable, condition])=>{
24
- if (joinTable) {
25
- chainedMethods.push({
26
- args: [
27
- adapter.tables[joinTable],
28
- condition
29
- ],
30
- method: 'leftJoin'
31
- });
32
- }
33
- });
34
- return chainMethods({
35
- methods: chainedMethods,
36
- query: db.selectDistinct(selectFields).from(adapter.tables[tableName])
37
- });
38
- }
39
- };
40
-
41
- //# sourceMappingURL=selectDistinct.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/queries/selectDistinct.ts"],"sourcesContent":["import type { QueryPromise, SQL } from 'drizzle-orm'\n\nimport type { ChainedMethods } from '../find/chainMethods.js'\nimport type { DrizzleDB, PostgresAdapter } from '../types.js'\nimport type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.js'\n\nimport { chainMethods } from '../find/chainMethods.js'\nimport { type GenericColumn } from '../types.js'\n\ntype Args = {\n adapter: PostgresAdapter\n chainedMethods?: ChainedMethods\n db: DrizzleDB\n joinAliases: BuildQueryJoinAliases\n joins: BuildQueryJoins\n selectFields: Record<string, GenericColumn>\n tableName: string\n where: SQL\n}\n\n/**\n * Selects distinct records from a table only if there are joins that need to be used, otherwise return null\n */\nexport const selectDistinct = ({\n adapter,\n chainedMethods = [],\n db,\n joinAliases,\n joins,\n selectFields,\n tableName,\n where,\n}: Args): QueryPromise<Record<string, GenericColumn> & { id: number | string }[]> => {\n if (Object.keys(joins).length > 0 || joinAliases.length > 0) {\n if (where) {\n chainedMethods.push({ args: [where], method: 'where' })\n }\n\n joinAliases.forEach(({ condition, table }) => {\n chainedMethods.push({\n args: [table, condition],\n method: 'leftJoin',\n })\n })\n\n Object.entries(joins).forEach(([joinTable, condition]) => {\n if (joinTable) {\n chainedMethods.push({\n args: [adapter.tables[joinTable], condition],\n method: 'leftJoin',\n })\n }\n })\n\n return chainMethods({\n methods: chainedMethods,\n query: db.selectDistinct(selectFields).from(adapter.tables[tableName]),\n })\n }\n}\n"],"names":["chainMethods","selectDistinct","adapter","chainedMethods","db","joinAliases","joins","selectFields","tableName","where","Object","keys","length","push","args","method","forEach","condition","table","entries","joinTable","tables","methods","query","from"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAMA,SAASA,YAAY,QAAQ,0BAAyB;AActD;;CAEC,GACD,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,OAAO,EACPC,iBAAiB,EAAE,EACnBC,EAAE,EACFC,WAAW,EACXC,KAAK,EACLC,YAAY,EACZC,SAAS,EACTC,KAAK,EACA;IACL,IAAIC,OAAOC,IAAI,CAACL,OAAOM,MAAM,GAAG,KAAKP,YAAYO,MAAM,GAAG,GAAG;QAC3D,IAAIH,OAAO;YACTN,eAAeU,IAAI,CAAC;gBAAEC,MAAM;oBAACL;iBAAM;gBAAEM,QAAQ;YAAQ;QACvD;QAEAV,YAAYW,OAAO,CAAC,CAAC,EAAEC,SAAS,EAAEC,KAAK,EAAE;YACvCf,eAAeU,IAAI,CAAC;gBAClBC,MAAM;oBAACI;oBAAOD;iBAAU;gBACxBF,QAAQ;YACV;QACF;QAEAL,OAAOS,OAAO,CAACb,OAAOU,OAAO,CAAC,CAAC,CAACI,WAAWH,UAAU;YACnD,IAAIG,WAAW;gBACbjB,eAAeU,IAAI,CAAC;oBAClBC,MAAM;wBAACZ,QAAQmB,MAAM,CAACD,UAAU;wBAAEH;qBAAU;oBAC5CF,QAAQ;gBACV;YACF;QACF;QAEA,OAAOf,aAAa;YAClBsB,SAASnB;YACToB,OAAOnB,GAAGH,cAAc,CAACM,cAAciB,IAAI,CAACtB,QAAQmB,MAAM,CAACb,UAAU;QACvE;IACF;AACF,EAAC"}
@@ -1,3 +0,0 @@
1
- import { type QueryDrafts } from 'payload/database';
2
- export declare const queryDrafts: QueryDrafts;
3
- //# sourceMappingURL=queryDrafts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queryDrafts.d.ts","sourceRoot":"","sources":["../src/queryDrafts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAkB,MAAM,kBAAkB,CAAA;AAQnE,eAAO,MAAM,WAAW,EAAE,WAgDzB,CAAA"}
@@ -1,41 +0,0 @@
1
- import { combineQueries } from 'payload/database';
2
- import { buildVersionCollectionFields } from 'payload/versions';
3
- import toSnakeCase from 'to-snake-case';
4
- import { findMany } from './find/findMany.js';
5
- export const queryDrafts = async function queryDrafts({ collection, limit, locale, page = 1, pagination, req = {}, sort, where }) {
6
- const collectionConfig = this.payload.collections[collection].config;
7
- const tableName = this.tableNameMap.get(`_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`);
8
- const fields = buildVersionCollectionFields(collectionConfig);
9
- const combinedWhere = combineQueries({
10
- latest: {
11
- equals: true
12
- }
13
- }, where);
14
- const result = await findMany({
15
- adapter: this,
16
- fields,
17
- limit,
18
- locale,
19
- page,
20
- pagination,
21
- req,
22
- sort,
23
- tableName,
24
- where: combinedWhere
25
- });
26
- return {
27
- ...result,
28
- docs: result.docs.map((doc)=>{
29
- // eslint-disable-next-line no-param-reassign
30
- doc = {
31
- id: doc.parent,
32
- ...doc.version,
33
- createdAt: doc.createdAt,
34
- updatedAt: doc.updatedAt
35
- };
36
- return doc;
37
- })
38
- };
39
- };
40
-
41
- //# sourceMappingURL=queryDrafts.js.map