@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/buildQuery.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { PgTableWithColumns } from 'drizzle-orm/pg-core'\nimport type { Field, Where } from 'payload/types'\n\nimport { asc, desc } from 'drizzle-orm'\n\nimport type { GenericColumn, GenericTable, PostgresAdapter } from '../types.js'\n\nimport { getTableColumnFromPath } from './getTableColumnFromPath.js'\nimport { parseParams } from './parseParams.js'\n\nexport type BuildQueryJoins = Record<string, SQL>\n\nexport type BuildQueryJoinAliases = {\n condition: SQL\n table: GenericTable | PgTableWithColumns<any>\n}[]\n\ntype BuildQueryArgs = {\n adapter: PostgresAdapter\n fields: Field[]\n locale?: string\n sort?: string\n tableName: string\n where: Where\n}\n\ntype Result = {\n joinAliases: BuildQueryJoinAliases\n joins: BuildQueryJoins\n orderBy: {\n column: GenericColumn\n order: typeof asc | typeof desc\n }\n selectFields: Record<string, GenericColumn>\n where: SQL\n}\nconst buildQuery = async function buildQuery({\n adapter,\n fields,\n locale,\n sort,\n tableName,\n where: incomingWhere,\n}: BuildQueryArgs): Promise<Result> {\n const selectFields: Record<string, GenericColumn> = {\n id: adapter.tables[tableName].id,\n }\n const joins: BuildQueryJoins = {}\n const joinAliases: BuildQueryJoinAliases = []\n\n const orderBy: Result['orderBy'] = {\n column: null,\n order: null,\n }\n\n if (sort) {\n let sortPath\n\n if (sort[0] === '-') {\n sortPath = sort.substring(1)\n orderBy.order = desc\n } else {\n sortPath = sort\n orderBy.order = asc\n }\n\n try {\n const { columnName: sortTableColumnName, table: sortTable } = getTableColumnFromPath({\n adapter,\n collectionPath: sortPath,\n fields,\n joinAliases,\n joins,\n locale,\n pathSegments: sortPath.replace(/__/g, '.').split('.'),\n selectFields,\n tableName,\n value: sortPath,\n })\n orderBy.column = sortTable?.[sortTableColumnName]\n } catch (err) {\n // continue\n }\n }\n\n if (!orderBy?.column) {\n orderBy.order = desc\n const createdAt = adapter.tables[tableName]?.createdAt\n\n if (createdAt) {\n orderBy.column = createdAt\n } else {\n orderBy.column = adapter.tables[tableName].id\n }\n }\n\n if (orderBy.column) {\n selectFields.sort = orderBy.column\n }\n\n let where: SQL\n\n if (incomingWhere && Object.keys(incomingWhere).length > 0) {\n where = await parseParams({\n adapter,\n fields,\n joinAliases,\n joins,\n locale,\n selectFields,\n tableName,\n where: incomingWhere,\n })\n }\n\n return {\n joinAliases,\n joins,\n orderBy,\n selectFields,\n where,\n }\n}\n\nexport default buildQuery\n"],"names":["asc","desc","getTableColumnFromPath","parseParams","buildQuery","adapter","fields","locale","sort","tableName","where","incomingWhere","selectFields","id","tables","joins","joinAliases","orderBy","column","order","sortPath","substring","columnName","sortTableColumnName","table","sortTable","collectionPath","pathSegments","replace","split","value","err","createdAt","Object","keys","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,GAAG,EAAEC,IAAI,QAAQ,cAAa;AAIvC,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,WAAW,QAAQ,mBAAkB;AA4B9C,MAAMC,aAAa,eAAeA,WAAW,EAC3CC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,IAAI,EACJC,SAAS,EACTC,OAAOC,aAAa,EACL;IACf,MAAMC,eAA8C;QAClDC,IAAIR,QAAQS,MAAM,CAACL,UAAU,CAACI,EAAE;IAClC;IACA,MAAME,QAAyB,CAAC;IAChC,MAAMC,cAAqC,EAAE;IAE7C,MAAMC,UAA6B;QACjCC,QAAQ;QACRC,OAAO;IACT;IAEA,IAAIX,MAAM;QACR,IAAIY;QAEJ,IAAIZ,IAAI,CAAC,EAAE,KAAK,KAAK;YACnBY,WAAWZ,KAAKa,SAAS,CAAC;YAC1BJ,QAAQE,KAAK,GAAGlB;QAClB,OAAO;YACLmB,WAAWZ;YACXS,QAAQE,KAAK,GAAGnB;QAClB;QAEA,IAAI;YACF,MAAM,EAAEsB,YAAYC,mBAAmB,EAAEC,OAAOC,SAAS,EAAE,GAAGvB,uBAAuB;gBACnFG;gBACAqB,gBAAgBN;gBAChBd;gBACAU;gBACAD;gBACAR;gBACAoB,cAAcP,SAASQ,OAAO,CAAC,OAAO,KAAKC,KAAK,CAAC;gBACjDjB;gBACAH;gBACAqB,OAAOV;YACT;YACAH,QAAQC,MAAM,GAAGO,WAAW,CAACF,oBAAoB;QACnD,EAAE,OAAOQ,KAAK;QACZ,WAAW;QACb;IACF;IAEA,IAAI,CAACd,SAASC,QAAQ;QACpBD,QAAQE,KAAK,GAAGlB;QAChB,MAAM+B,YAAY3B,QAAQS,MAAM,CAACL,UAAU,EAAEuB;QAE7C,IAAIA,WAAW;YACbf,QAAQC,MAAM,GAAGc;QACnB,OAAO;YACLf,QAAQC,MAAM,GAAGb,QAAQS,MAAM,CAACL,UAAU,CAACI,EAAE;QAC/C;IACF;IAEA,IAAII,QAAQC,MAAM,EAAE;QAClBN,aAAaJ,IAAI,GAAGS,QAAQC,MAAM;IACpC;IAEA,IAAIR;IAEJ,IAAIC,iBAAiBsB,OAAOC,IAAI,CAACvB,eAAewB,MAAM,GAAG,GAAG;QAC1DzB,QAAQ,MAAMP,YAAY;YACxBE;YACAC;YACAU;YACAD;YACAR;YACAK;YACAH;YACAC,OAAOC;QACT;IACF;IAEA,OAAO;QACLK;QACAD;QACAE;QACAL;QACAF;IACF;AACF;AAEA,eAAeN,WAAU"}
@@ -1,2 +0,0 @@
1
- export declare const convertPathToJSONTraversal: (incomingSegments: string[]) => string;
2
- //# sourceMappingURL=convertPathToJSONTraversal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertPathToJSONTraversal.d.ts","sourceRoot":"","sources":["../../../src/queries/createJSONQuery/convertPathToJSONTraversal.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,qBAAsB,MAAM,EAAE,WAUpE,CAAA"}
@@ -1,14 +0,0 @@
1
- import { formatJSONPathSegment } from './formatJSONPathSegment.js';
2
- export const convertPathToJSONTraversal = (incomingSegments)=>{
3
- const segments = [
4
- ...incomingSegments
5
- ];
6
- segments.shift();
7
- return segments.reduce((res, segment, i)=>{
8
- const formattedSegment = formatJSONPathSegment(segment);
9
- if (i + 1 === segments.length) return `${res}->>${formattedSegment}`;
10
- return `${res}->${formattedSegment}`;
11
- }, '');
12
- };
13
-
14
- //# sourceMappingURL=convertPathToJSONTraversal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/queries/createJSONQuery/convertPathToJSONTraversal.ts"],"sourcesContent":["import { formatJSONPathSegment } from './formatJSONPathSegment.js'\n\nexport const convertPathToJSONTraversal = (incomingSegments: string[]) => {\n const segments = [...incomingSegments]\n segments.shift()\n\n return segments.reduce((res, segment, i) => {\n const formattedSegment = formatJSONPathSegment(segment)\n\n if (i + 1 === segments.length) return `${res}->>${formattedSegment}`\n return `${res}->${formattedSegment}`\n }, '')\n}\n"],"names":["formatJSONPathSegment","convertPathToJSONTraversal","incomingSegments","segments","shift","reduce","res","segment","i","formattedSegment","length"],"rangeMappings":";;;;;;;;;;;","mappings":"AAAA,SAASA,qBAAqB,QAAQ,6BAA4B;AAElE,OAAO,MAAMC,6BAA6B,CAACC;IACzC,MAAMC,WAAW;WAAID;KAAiB;IACtCC,SAASC,KAAK;IAEd,OAAOD,SAASE,MAAM,CAAC,CAACC,KAAKC,SAASC;QACpC,MAAMC,mBAAmBT,sBAAsBO;QAE/C,IAAIC,IAAI,MAAML,SAASO,MAAM,EAAE,OAAO,CAAC,EAAEJ,IAAI,GAAG,EAAEG,iBAAiB,CAAC;QACpE,OAAO,CAAC,EAAEH,IAAI,EAAE,EAAEG,iBAAiB,CAAC;IACtC,GAAG;AACL,EAAC"}
@@ -1,2 +0,0 @@
1
- export declare const formatJSONPathSegment: (segment: string) => string;
2
- //# sourceMappingURL=formatJSONPathSegment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatJSONPathSegment.d.ts","sourceRoot":"","sources":["../../../src/queries/createJSONQuery/formatJSONPathSegment.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,YAAa,MAAM,WAEpD,CAAA"}
@@ -1,5 +0,0 @@
1
- export const formatJSONPathSegment = (segment)=>{
2
- return Number.isNaN(parseInt(segment)) ? `'${segment}'` : segment;
3
- };
4
-
5
- //# sourceMappingURL=formatJSONPathSegment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/queries/createJSONQuery/formatJSONPathSegment.ts"],"sourcesContent":["export const formatJSONPathSegment = (segment: string) => {\n return Number.isNaN(parseInt(segment)) ? `'${segment}'` : segment\n}\n"],"names":["formatJSONPathSegment","segment","Number","isNaN","parseInt"],"rangeMappings":";;","mappings":"AAAA,OAAO,MAAMA,wBAAwB,CAACC;IACpC,OAAOC,OAAOC,KAAK,CAACC,SAASH,YAAY,CAAC,CAAC,EAAEA,QAAQ,CAAC,CAAC,GAAGA;AAC5D,EAAC"}
@@ -1,10 +0,0 @@
1
- type Args = {
2
- operator: string;
3
- pathSegments: string[];
4
- treatAsArray?: string[];
5
- treatRootAsArray?: boolean;
6
- value: unknown;
7
- };
8
- export declare const createJSONQuery: ({ operator, pathSegments, treatAsArray, treatRootAsArray, value, }: Args) => string;
9
- export {};
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/queries/createJSONQuery/index.ts"],"names":[],"mappings":"AAmDA,KAAK,IAAI,GAAG;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED,eAAO,MAAM,eAAe,uEAMzB,IAAI,KAAG,MAqBT,CAAA"}
@@ -1,54 +0,0 @@
1
- import { convertPathToJSONTraversal } from './convertPathToJSONTraversal.js';
2
- import { formatJSONPathSegment } from './formatJSONPathSegment.js';
3
- const operatorMap = {
4
- contains: '~*',
5
- equals: '=',
6
- like: '~*'
7
- };
8
- const fromArray = ({ isRoot, operator, pathSegments, treatAsArray, value })=>{
9
- const newPathSegments = pathSegments.slice(isRoot ? 1 : 2);
10
- const alias = `${pathSegments[isRoot ? 0 : 1]}_alias_${newPathSegments.length}`;
11
- newPathSegments.unshift(alias);
12
- const arrayElements = isRoot ? pathSegments[0] : `${pathSegments[0]} -> ${formatJSONPathSegment(pathSegments[1])}`;
13
- return `EXISTS (
14
- SELECT 1
15
- FROM jsonb_array_elements(${arrayElements}) AS ${alias}
16
- WHERE ${createJSONQuery({
17
- operator,
18
- pathSegments: newPathSegments,
19
- treatAsArray,
20
- value
21
- })}
22
- )`;
23
- };
24
- const createConstraint = ({ operator, pathSegments, value })=>{
25
- const jsonQuery = convertPathToJSONTraversal(pathSegments);
26
- return `${pathSegments[0]}${jsonQuery} ${operatorMap[operator]} '${value}'`;
27
- };
28
- export const createJSONQuery = ({ operator, pathSegments, treatAsArray, treatRootAsArray, value })=>{
29
- if (treatRootAsArray) {
30
- return fromArray({
31
- isRoot: true,
32
- operator,
33
- pathSegments,
34
- treatAsArray,
35
- value
36
- });
37
- }
38
- if (treatAsArray.includes(pathSegments[1])) {
39
- return fromArray({
40
- operator,
41
- pathSegments,
42
- treatAsArray,
43
- value
44
- });
45
- }
46
- return createConstraint({
47
- operator,
48
- pathSegments,
49
- treatAsArray,
50
- value
51
- });
52
- };
53
-
54
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/queries/createJSONQuery/index.ts"],"sourcesContent":["import { convertPathToJSONTraversal } from './convertPathToJSONTraversal.js'\nimport { formatJSONPathSegment } from './formatJSONPathSegment.js'\n\nconst operatorMap = {\n contains: '~*',\n equals: '=',\n like: '~*',\n}\n\ntype FromArrayArgs = {\n isRoot?: true\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n value: unknown\n}\n\nconst fromArray = ({ isRoot, operator, pathSegments, treatAsArray, value }: FromArrayArgs) => {\n const newPathSegments = pathSegments.slice(isRoot ? 1 : 2)\n const alias = `${pathSegments[isRoot ? 0 : 1]}_alias_${newPathSegments.length}`\n\n newPathSegments.unshift(alias)\n\n const arrayElements = isRoot\n ? pathSegments[0]\n : `${pathSegments[0]} -> ${formatJSONPathSegment(pathSegments[1])}`\n\n return `EXISTS (\n SELECT 1\n FROM jsonb_array_elements(${arrayElements}) AS ${alias}\n WHERE ${createJSONQuery({\n operator,\n pathSegments: newPathSegments,\n treatAsArray,\n value,\n })}\n )`\n}\n\ntype CreateConstraintArgs = {\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n value: unknown\n}\n\nconst createConstraint = ({ operator, pathSegments, value }: CreateConstraintArgs): string => {\n const jsonQuery = convertPathToJSONTraversal(pathSegments)\n return `${pathSegments[0]}${jsonQuery} ${operatorMap[operator]} '${value}'`\n}\n\ntype Args = {\n operator: string\n pathSegments: string[]\n treatAsArray?: string[]\n treatRootAsArray?: boolean\n value: unknown\n}\n\nexport const createJSONQuery = ({\n operator,\n pathSegments,\n treatAsArray,\n treatRootAsArray,\n value,\n}: Args): string => {\n if (treatRootAsArray) {\n return fromArray({\n isRoot: true,\n operator,\n pathSegments,\n treatAsArray,\n value,\n })\n }\n\n if (treatAsArray.includes(pathSegments[1])) {\n return fromArray({\n operator,\n pathSegments,\n treatAsArray,\n value,\n })\n }\n\n return createConstraint({ operator, pathSegments, treatAsArray, value })\n}\n"],"names":["convertPathToJSONTraversal","formatJSONPathSegment","operatorMap","contains","equals","like","fromArray","isRoot","operator","pathSegments","treatAsArray","value","newPathSegments","slice","alias","length","unshift","arrayElements","createJSONQuery","createConstraint","jsonQuery","treatRootAsArray","includes"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,0BAA0B,QAAQ,kCAAiC;AAC5E,SAASC,qBAAqB,QAAQ,6BAA4B;AAElE,MAAMC,cAAc;IAClBC,UAAU;IACVC,QAAQ;IACRC,MAAM;AACR;AAUA,MAAMC,YAAY,CAAC,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,YAAY,EAAEC,KAAK,EAAiB;IACvF,MAAMC,kBAAkBH,aAAaI,KAAK,CAACN,SAAS,IAAI;IACxD,MAAMO,QAAQ,CAAC,EAAEL,YAAY,CAACF,SAAS,IAAI,EAAE,CAAC,OAAO,EAAEK,gBAAgBG,MAAM,CAAC,CAAC;IAE/EH,gBAAgBI,OAAO,CAACF;IAExB,MAAMG,gBAAgBV,SAClBE,YAAY,CAAC,EAAE,GACf,CAAC,EAAEA,YAAY,CAAC,EAAE,CAAC,IAAI,EAAER,sBAAsBQ,YAAY,CAAC,EAAE,EAAE,CAAC;IAErE,OAAO,CAAC;;8BAEoB,EAAEQ,cAAc,KAAK,EAAEH,MAAM;UACjD,EAAEI,gBAAgB;QACtBV;QACAC,cAAcG;QACdF;QACAC;IACF,GAAG;GACJ,CAAC;AACJ;AASA,MAAMQ,mBAAmB,CAAC,EAAEX,QAAQ,EAAEC,YAAY,EAAEE,KAAK,EAAwB;IAC/E,MAAMS,YAAYpB,2BAA2BS;IAC7C,OAAO,CAAC,EAAEA,YAAY,CAAC,EAAE,CAAC,EAAEW,UAAU,CAAC,EAAElB,WAAW,CAACM,SAAS,CAAC,EAAE,EAAEG,MAAM,CAAC,CAAC;AAC7E;AAUA,OAAO,MAAMO,kBAAkB,CAAC,EAC9BV,QAAQ,EACRC,YAAY,EACZC,YAAY,EACZW,gBAAgB,EAChBV,KAAK,EACA;IACL,IAAIU,kBAAkB;QACpB,OAAOf,UAAU;YACfC,QAAQ;YACRC;YACAC;YACAC;YACAC;QACF;IACF;IAEA,IAAID,aAAaY,QAAQ,CAACb,YAAY,CAAC,EAAE,GAAG;QAC1C,OAAOH,UAAU;YACfE;YACAC;YACAC;YACAC;QACF;IACF;IAEA,OAAOQ,iBAAiB;QAAEX;QAAUC;QAAcC;QAAcC;IAAM;AACxE,EAAC"}
@@ -1,51 +0,0 @@
1
- import type { SQL } from 'drizzle-orm';
2
- import type { PgTableWithColumns } from 'drizzle-orm/pg-core';
3
- import type { Field, FieldAffectingData, TabAsField } from 'payload/types';
4
- import type { GenericColumn, GenericTable, PostgresAdapter } from '../types.js';
5
- import type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.js';
6
- type Constraint = {
7
- columnName: string;
8
- table: GenericTable | PgTableWithColumns<any>;
9
- value: unknown;
10
- };
11
- type TableColumn = {
12
- columnName?: string;
13
- constraints: Constraint[];
14
- field: FieldAffectingData;
15
- getNotNullColumnByValue?: (val: unknown) => string;
16
- pathSegments?: string[];
17
- rawColumn?: SQL;
18
- table: GenericTable | PgTableWithColumns<any>;
19
- };
20
- type Args = {
21
- adapter: PostgresAdapter;
22
- aliasTable?: GenericTable | PgTableWithColumns<any>;
23
- collectionPath: string;
24
- columnPrefix?: string;
25
- constraintPath?: string;
26
- constraints?: Constraint[];
27
- fields: (Field | TabAsField)[];
28
- joinAliases: BuildQueryJoinAliases;
29
- joins: BuildQueryJoins;
30
- locale?: string;
31
- pathSegments: string[];
32
- rootTableName?: string;
33
- selectFields: Record<string, GenericColumn>;
34
- tableName: string;
35
- /**
36
- * If creating a new table name for arrays and blocks, this suffix should be appended to the table name
37
- */
38
- tableNameSuffix?: string;
39
- /**
40
- * The raw value of the query before sanitization
41
- */
42
- value: unknown;
43
- };
44
- /**
45
- * Transforms path to table and column name
46
- * Adds tables to `join`
47
- * @returns TableColumn
48
- */
49
- export declare const getTableColumnFromPath: ({ adapter, aliasTable, collectionPath, columnPrefix, constraintPath: incomingConstraintPath, constraints, fields, joinAliases, joins, locale: incomingLocale, pathSegments: incomingSegments, rootTableName: incomingRootTableName, selectFields, tableName, tableNameSuffix, value, }: Args) => TableColumn;
50
- export {};
51
- //# sourceMappingURL=getTableColumnFromPath.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getTableColumnFromPath.d.ts","sourceRoot":"","sources":["../../src/queries/getTableColumnFromPath.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAe,UAAU,EAAa,MAAM,eAAe,CAAA;AAUlG,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAE7E,KAAK,UAAU,GAAG;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,YAAY,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAA;IAC7C,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED,KAAK,WAAW,GAAG;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,KAAK,EAAE,kBAAkB,CAAA;IACzB,uBAAuB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,CAAA;IAClD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,SAAS,CAAC,EAAE,GAAG,CAAA;IACf,KAAK,EAAE,YAAY,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAA;CAC9C,CAAA;AAED,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,UAAU,CAAC,EAAE,YAAY,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAA;IACnD,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAA;IAC1B,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,WAAW,EAAE,qBAAqB,CAAA;IAClC,KAAK,EAAE,eAAe,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AACD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,2RAiBhC,IAAI,KAAG,WA4fT,CAAA"}
@@ -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