@payloadcms/db-postgres 3.0.0-canary.f83d96a → 3.0.0-canary.ff8c8fd

Sign up to get free protection for your applications and to get access to all the features.
Files changed (345) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +10 -6
  3. package/dist/connect.js.map +1 -1
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +32 -67
  7. package/dist/index.js.map +1 -1
  8. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +5 -4
  9. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
  10. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +1 -1
  11. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -1
  12. package/dist/predefinedMigrations/v2-v3/index.d.ts +2 -2
  13. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
  14. package/dist/predefinedMigrations/v2-v3/index.js +2 -2
  15. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -1
  16. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +5 -4
  17. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
  18. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -1
  19. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +3 -2
  20. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
  21. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -1
  22. package/dist/types.d.ts +42 -78
  23. package/dist/types.d.ts.map +1 -1
  24. package/dist/types.js.map +1 -1
  25. package/package.json +10 -10
  26. package/dist/count.d.ts +0 -3
  27. package/dist/count.d.ts.map +0 -1
  28. package/dist/count.js +0 -41
  29. package/dist/count.js.map +0 -1
  30. package/dist/create.d.ts +0 -3
  31. package/dist/create.d.ts.map +0 -1
  32. package/dist/create.js +0 -19
  33. package/dist/create.js.map +0 -1
  34. package/dist/createGlobal.d.ts +0 -4
  35. package/dist/createGlobal.d.ts.map +0 -1
  36. package/dist/createGlobal.js +0 -19
  37. package/dist/createGlobal.js.map +0 -1
  38. package/dist/createGlobalVersion.d.ts +0 -5
  39. package/dist/createGlobalVersion.d.ts.map +0 -1
  40. package/dist/createGlobalVersion.js +0 -33
  41. package/dist/createGlobalVersion.js.map +0 -1
  42. package/dist/createMigration.d.ts +0 -3
  43. package/dist/createMigration.d.ts.map +0 -1
  44. package/dist/createMigration.js +0 -102
  45. package/dist/createMigration.js.map +0 -1
  46. package/dist/createVersion.d.ts +0 -4
  47. package/dist/createVersion.d.ts.map +0 -1
  48. package/dist/createVersion.js +0 -40
  49. package/dist/createVersion.js.map +0 -1
  50. package/dist/deleteMany.d.ts +0 -3
  51. package/dist/deleteMany.d.ts.map +0 -1
  52. package/dist/deleteMany.js +0 -28
  53. package/dist/deleteMany.js.map +0 -1
  54. package/dist/deleteOne.d.ts +0 -3
  55. package/dist/deleteOne.d.ts.map +0 -1
  56. package/dist/deleteOne.js +0 -59
  57. package/dist/deleteOne.js.map +0 -1
  58. package/dist/deleteVersions.d.ts +0 -3
  59. package/dist/deleteVersions.d.ts.map +0 -1
  60. package/dist/deleteVersions.js +0 -31
  61. package/dist/deleteVersions.js.map +0 -1
  62. package/dist/destroy.d.ts +0 -3
  63. package/dist/destroy.d.ts.map +0 -1
  64. package/dist/destroy.js +0 -15
  65. package/dist/destroy.js.map +0 -1
  66. package/dist/find/buildFindManyArgs.d.ts +0 -17
  67. package/dist/find/buildFindManyArgs.d.ts.map +0 -1
  68. package/dist/find/buildFindManyArgs.js +0 -65
  69. package/dist/find/buildFindManyArgs.js.map +0 -1
  70. package/dist/find/chainMethods.d.ts +0 -16
  71. package/dist/find/chainMethods.d.ts.map +0 -1
  72. package/dist/find/chainMethods.js +0 -12
  73. package/dist/find/chainMethods.js.map +0 -1
  74. package/dist/find/findMany.d.ts +0 -21
  75. package/dist/find/findMany.d.ts.map +0 -1
  76. package/dist/find/findMany.js +0 -152
  77. package/dist/find/findMany.js.map +0 -1
  78. package/dist/find/traverseFields.d.ts +0 -17
  79. package/dist/find/traverseFields.d.ts.map +0 -1
  80. package/dist/find/traverseFields.js +0 -156
  81. package/dist/find/traverseFields.js.map +0 -1
  82. package/dist/find.d.ts +0 -3
  83. package/dist/find.d.ts.map +0 -1
  84. package/dist/find.js +0 -21
  85. package/dist/find.js.map +0 -1
  86. package/dist/findGlobal.d.ts +0 -3
  87. package/dist/findGlobal.d.ts.map +0 -1
  88. package/dist/findGlobal.js +0 -23
  89. package/dist/findGlobal.js.map +0 -1
  90. package/dist/findGlobalVersions.d.ts +0 -3
  91. package/dist/findGlobalVersions.d.ts.map +0 -1
  92. package/dist/findGlobalVersions.js +0 -24
  93. package/dist/findGlobalVersions.js.map +0 -1
  94. package/dist/findOne.d.ts +0 -4
  95. package/dist/findOne.d.ts.map +0 -1
  96. package/dist/findOne.js +0 -21
  97. package/dist/findOne.js.map +0 -1
  98. package/dist/findVersions.d.ts +0 -3
  99. package/dist/findVersions.d.ts.map +0 -1
  100. package/dist/findVersions.js +0 -24
  101. package/dist/findVersions.js.map +0 -1
  102. package/dist/init.d.ts +0 -3
  103. package/dist/init.d.ts.map +0 -1
  104. package/dist/init.js +0 -91
  105. package/dist/init.js.map +0 -1
  106. package/dist/migrate.d.ts +0 -3
  107. package/dist/migrate.d.ts.map +0 -1
  108. package/dist/migrate.js +0 -99
  109. package/dist/migrate.js.map +0 -1
  110. package/dist/migrateDown.d.ts +0 -3
  111. package/dist/migrateDown.d.ts.map +0 -1
  112. package/dist/migrateDown.js +0 -63
  113. package/dist/migrateDown.js.map +0 -1
  114. package/dist/migrateFresh.d.ts +0 -8
  115. package/dist/migrateFresh.d.ts.map +0 -1
  116. package/dist/migrateFresh.js +0 -72
  117. package/dist/migrateFresh.js.map +0 -1
  118. package/dist/migrateRefresh.d.ts +0 -6
  119. package/dist/migrateRefresh.d.ts.map +0 -1
  120. package/dist/migrateRefresh.js +0 -102
  121. package/dist/migrateRefresh.js.map +0 -1
  122. package/dist/migrateReset.d.ts +0 -6
  123. package/dist/migrateReset.d.ts.map +0 -1
  124. package/dist/migrateReset.js +0 -82
  125. package/dist/migrateReset.js.map +0 -1
  126. package/dist/migrateStatus.d.ts +0 -3
  127. package/dist/migrateStatus.d.ts.map +0 -1
  128. package/dist/migrateStatus.js +0 -44
  129. package/dist/migrateStatus.js.map +0 -1
  130. package/dist/queries/buildAndOrConditions.d.ts +0 -16
  131. package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
  132. package/dist/queries/buildAndOrConditions.js +0 -28
  133. package/dist/queries/buildAndOrConditions.js.map +0 -1
  134. package/dist/queries/buildQuery.d.ts +0 -30
  135. package/dist/queries/buildQuery.d.ts.map +0 -1
  136. package/dist/queries/buildQuery.js +0 -72
  137. package/dist/queries/buildQuery.js.map +0 -1
  138. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts +0 -2
  139. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  140. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +0 -14
  141. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  142. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts +0 -2
  143. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  144. package/dist/queries/createJSONQuery/formatJSONPathSegment.js +0 -5
  145. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  146. package/dist/queries/createJSONQuery/index.d.ts +0 -10
  147. package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
  148. package/dist/queries/createJSONQuery/index.js +0 -54
  149. package/dist/queries/createJSONQuery/index.js.map +0 -1
  150. package/dist/queries/getTableColumnFromPath.d.ts +0 -50
  151. package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
  152. package/dist/queries/getTableColumnFromPath.js +0 -516
  153. package/dist/queries/getTableColumnFromPath.js.map +0 -1
  154. package/dist/queries/operatorMap.d.ts +0 -18
  155. package/dist/queries/operatorMap.d.ts.map +0 -1
  156. package/dist/queries/operatorMap.js +0 -24
  157. package/dist/queries/operatorMap.js.map +0 -1
  158. package/dist/queries/parseParams.d.ts +0 -16
  159. package/dist/queries/parseParams.d.ts.map +0 -1
  160. package/dist/queries/parseParams.js +0 -183
  161. package/dist/queries/parseParams.js.map +0 -1
  162. package/dist/queries/sanitizeQueryValue.d.ts +0 -15
  163. package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
  164. package/dist/queries/sanitizeQueryValue.js +0 -89
  165. package/dist/queries/sanitizeQueryValue.js.map +0 -1
  166. package/dist/queries/selectDistinct.d.ts +0 -22
  167. package/dist/queries/selectDistinct.d.ts.map +0 -1
  168. package/dist/queries/selectDistinct.js +0 -30
  169. package/dist/queries/selectDistinct.js.map +0 -1
  170. package/dist/queryDrafts.d.ts +0 -3
  171. package/dist/queryDrafts.d.ts.map +0 -1
  172. package/dist/queryDrafts.js +0 -40
  173. package/dist/queryDrafts.js.map +0 -1
  174. package/dist/schema/build.d.ts +0 -34
  175. package/dist/schema/build.d.ts.map +0 -1
  176. package/dist/schema/build.js +0 -369
  177. package/dist/schema/build.js.map +0 -1
  178. package/dist/schema/createIndex.d.ts +0 -12
  179. package/dist/schema/createIndex.d.ts.map +0 -1
  180. package/dist/schema/createIndex.js +0 -18
  181. package/dist/schema/createIndex.js.map +0 -1
  182. package/dist/schema/createTableName.d.ts +0 -30
  183. package/dist/schema/createTableName.d.ts.map +0 -1
  184. package/dist/schema/createTableName.js +0 -31
  185. package/dist/schema/createTableName.js.map +0 -1
  186. package/dist/schema/idToUUID.d.ts +0 -3
  187. package/dist/schema/idToUUID.d.ts.map +0 -1
  188. package/dist/schema/idToUUID.js +0 -11
  189. package/dist/schema/idToUUID.js.map +0 -1
  190. package/dist/schema/parentIDColumnMap.d.ts +0 -4
  191. package/dist/schema/parentIDColumnMap.d.ts.map +0 -1
  192. package/dist/schema/parentIDColumnMap.js +0 -9
  193. package/dist/schema/parentIDColumnMap.js.map +0 -1
  194. package/dist/schema/setColumnID.d.ts +0 -11
  195. package/dist/schema/setColumnID.d.ts.map +0 -1
  196. package/dist/schema/setColumnID.js +0 -24
  197. package/dist/schema/setColumnID.js.map +0 -1
  198. package/dist/schema/traverseFields.d.ts +0 -36
  199. package/dist/schema/traverseFields.d.ts.map +0 -1
  200. package/dist/schema/traverseFields.js +0 -614
  201. package/dist/schema/traverseFields.js.map +0 -1
  202. package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
  203. package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
  204. package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
  205. package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
  206. package/dist/transactions/beginTransaction.d.ts +0 -3
  207. package/dist/transactions/beginTransaction.d.ts.map +0 -1
  208. package/dist/transactions/beginTransaction.js +0 -51
  209. package/dist/transactions/beginTransaction.js.map +0 -1
  210. package/dist/transactions/commitTransaction.d.ts +0 -3
  211. package/dist/transactions/commitTransaction.d.ts.map +0 -1
  212. package/dist/transactions/commitTransaction.js +0 -14
  213. package/dist/transactions/commitTransaction.js.map +0 -1
  214. package/dist/transactions/rollbackTransaction.d.ts +0 -3
  215. package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
  216. package/dist/transactions/rollbackTransaction.js +0 -13
  217. package/dist/transactions/rollbackTransaction.js.map +0 -1
  218. package/dist/transform/read/hasManyNumber.d.ts +0 -10
  219. package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
  220. package/dist/transform/read/hasManyNumber.js +0 -10
  221. package/dist/transform/read/hasManyNumber.js.map +0 -1
  222. package/dist/transform/read/hasManyText.d.ts +0 -10
  223. package/dist/transform/read/hasManyText.d.ts.map +0 -1
  224. package/dist/transform/read/hasManyText.js +0 -10
  225. package/dist/transform/read/hasManyText.js.map +0 -1
  226. package/dist/transform/read/index.d.ts +0 -13
  227. package/dist/transform/read/index.d.ts.map +0 -1
  228. package/dist/transform/read/index.js +0 -44
  229. package/dist/transform/read/index.js.map +0 -1
  230. package/dist/transform/read/relationship.d.ts +0 -10
  231. package/dist/transform/read/relationship.d.ts.map +0 -1
  232. package/dist/transform/read/relationship.js +0 -60
  233. package/dist/transform/read/relationship.js.map +0 -1
  234. package/dist/transform/read/traverseFields.d.ts +0 -57
  235. package/dist/transform/read/traverseFields.d.ts.map +0 -1
  236. package/dist/transform/read/traverseFields.js +0 -435
  237. package/dist/transform/read/traverseFields.js.map +0 -1
  238. package/dist/transform/write/array.d.ts +0 -26
  239. package/dist/transform/write/array.d.ts.map +0 -1
  240. package/dist/transform/write/array.js +0 -58
  241. package/dist/transform/write/array.js.map +0 -1
  242. package/dist/transform/write/blocks.d.ts +0 -25
  243. package/dist/transform/write/blocks.d.ts.map +0 -1
  244. package/dist/transform/write/blocks.js +0 -54
  245. package/dist/transform/write/blocks.js.map +0 -1
  246. package/dist/transform/write/index.d.ts +0 -13
  247. package/dist/transform/write/index.d.ts.map +0 -1
  248. package/dist/transform/write/index.js +0 -41
  249. package/dist/transform/write/index.js.map +0 -1
  250. package/dist/transform/write/numbers.d.ts +0 -8
  251. package/dist/transform/write/numbers.d.ts.map +0 -1
  252. package/dist/transform/write/numbers.js +0 -11
  253. package/dist/transform/write/numbers.js.map +0 -1
  254. package/dist/transform/write/relationships.d.ts +0 -10
  255. package/dist/transform/write/relationships.d.ts.map +0 -1
  256. package/dist/transform/write/relationships.js +0 -23
  257. package/dist/transform/write/relationships.js.map +0 -1
  258. package/dist/transform/write/selects.d.ts +0 -8
  259. package/dist/transform/write/selects.d.ts.map +0 -1
  260. package/dist/transform/write/selects.js +0 -20
  261. package/dist/transform/write/selects.js.map +0 -1
  262. package/dist/transform/write/texts.d.ts +0 -8
  263. package/dist/transform/write/texts.d.ts.map +0 -1
  264. package/dist/transform/write/texts.js +0 -11
  265. package/dist/transform/write/texts.js.map +0 -1
  266. package/dist/transform/write/traverseFields.d.ts +0 -50
  267. package/dist/transform/write/traverseFields.d.ts.map +0 -1
  268. package/dist/transform/write/traverseFields.js +0 -445
  269. package/dist/transform/write/traverseFields.js.map +0 -1
  270. package/dist/transform/write/types.d.ts +0 -43
  271. package/dist/transform/write/types.d.ts.map +0 -1
  272. package/dist/transform/write/types.js +0 -3
  273. package/dist/transform/write/types.js.map +0 -1
  274. package/dist/update.d.ts +0 -3
  275. package/dist/update.d.ts.map +0 -1
  276. package/dist/update.js +0 -54
  277. package/dist/update.js.map +0 -1
  278. package/dist/updateGlobal.d.ts +0 -4
  279. package/dist/updateGlobal.d.ts.map +0 -1
  280. package/dist/updateGlobal.js +0 -25
  281. package/dist/updateGlobal.js.map +0 -1
  282. package/dist/updateGlobalVersion.d.ts +0 -4
  283. package/dist/updateGlobalVersion.d.ts.map +0 -1
  284. package/dist/updateGlobalVersion.js +0 -36
  285. package/dist/updateGlobalVersion.js.map +0 -1
  286. package/dist/updateVersion.d.ts +0 -4
  287. package/dist/updateVersion.d.ts.map +0 -1
  288. package/dist/updateVersion.js +0 -36
  289. package/dist/updateVersion.js.map +0 -1
  290. package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
  291. package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
  292. package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
  293. package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
  294. package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
  295. package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
  296. package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
  297. package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
  298. package/dist/upsertRow/index.d.ts +0 -4
  299. package/dist/upsertRow/index.d.ts.map +0 -1
  300. package/dist/upsertRow/index.js +0 -281
  301. package/dist/upsertRow/index.js.map +0 -1
  302. package/dist/upsertRow/insertArrays.d.ts +0 -13
  303. package/dist/upsertRow/insertArrays.d.ts.map +0 -1
  304. package/dist/upsertRow/insertArrays.js +0 -68
  305. package/dist/upsertRow/insertArrays.js.map +0 -1
  306. package/dist/upsertRow/types.d.ts +0 -32
  307. package/dist/upsertRow/types.d.ts.map +0 -1
  308. package/dist/upsertRow/types.js +0 -3
  309. package/dist/upsertRow/types.js.map +0 -1
  310. package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
  311. package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
  312. package/dist/utilities/appendPrefixToKeys.js +0 -6
  313. package/dist/utilities/appendPrefixToKeys.js.map +0 -1
  314. package/dist/utilities/createBlocksMap.d.ts +0 -5
  315. package/dist/utilities/createBlocksMap.d.ts.map +0 -1
  316. package/dist/utilities/createBlocksMap.js +0 -29
  317. package/dist/utilities/createBlocksMap.js.map +0 -1
  318. package/dist/utilities/createMigrationTable.d.ts +0 -3
  319. package/dist/utilities/createMigrationTable.d.ts.map +0 -1
  320. package/dist/utilities/createMigrationTable.js +0 -13
  321. package/dist/utilities/createMigrationTable.js.map +0 -1
  322. package/dist/utilities/createRelationshipMap.d.ts +0 -2
  323. package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
  324. package/dist/utilities/createRelationshipMap.js +0 -19
  325. package/dist/utilities/createRelationshipMap.js.map +0 -1
  326. package/dist/utilities/hasLocalesTable.d.ts +0 -3
  327. package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
  328. package/dist/utilities/hasLocalesTable.js +0 -11
  329. package/dist/utilities/hasLocalesTable.js.map +0 -1
  330. package/dist/utilities/isArrayOfRows.d.ts +0 -2
  331. package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
  332. package/dist/utilities/isArrayOfRows.js +0 -5
  333. package/dist/utilities/isArrayOfRows.js.map +0 -1
  334. package/dist/utilities/migrationTableExists.d.ts +0 -3
  335. package/dist/utilities/migrationTableExists.d.ts.map +0 -1
  336. package/dist/utilities/migrationTableExists.js +0 -9
  337. package/dist/utilities/migrationTableExists.js.map +0 -1
  338. package/dist/utilities/parseError.d.ts +0 -5
  339. package/dist/utilities/parseError.d.ts.map +0 -1
  340. package/dist/utilities/parseError.js +0 -17
  341. package/dist/utilities/parseError.js.map +0 -1
  342. package/dist/utilities/pushDevSchema.d.ts +0 -9
  343. package/dist/utilities/pushDevSchema.d.ts.map +0 -1
  344. package/dist/utilities/pushDevSchema.js +0 -58
  345. 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'\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 joins: BuildQueryJoinAliases\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: 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 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 joins,\n locale,\n selectFields,\n tableName,\n where: incomingWhere,\n })\n }\n\n return {\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","orderBy","column","order","sortPath","substring","columnName","sortTableColumnName","table","sortTable","collectionPath","pathSegments","replace","split","value","err","createdAt","Object","keys","length"],"mappings":"AAIA,SAASA,GAAG,EAAEC,IAAI,QAAQ,cAAa;AAIvC,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,WAAW,QAAQ,mBAAkB;AA2B9C,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,QAA+B,EAAE;IAEvC,MAAMC,UAA6B;QACjCC,QAAQ;QACRC,OAAO;IACT;IAEA,IAAIV,MAAM;QACR,IAAIW;QAEJ,IAAIX,IAAI,CAAC,EAAE,KAAK,KAAK;YACnBW,WAAWX,KAAKY,SAAS,CAAC;YAC1BJ,QAAQE,KAAK,GAAGjB;QAClB,OAAO;YACLkB,WAAWX;YACXQ,QAAQE,KAAK,GAAGlB;QAClB;QAEA,IAAI;YACF,MAAM,EAAEqB,YAAYC,mBAAmB,EAAEC,OAAOC,SAAS,EAAE,GAAGtB,uBAAuB;gBACnFG;gBACAoB,gBAAgBN;gBAChBb;gBACAS;gBACAR;gBACAmB,cAAcP,SAASQ,OAAO,CAAC,OAAO,KAAKC,KAAK,CAAC;gBACjDhB;gBACAH;gBACAoB,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,GAAGjB;QAChB,MAAM8B,YAAY1B,QAAQS,MAAM,CAACL,UAAU,EAAEsB;QAE7C,IAAIA,WAAW;YACbf,QAAQC,MAAM,GAAGc;QACnB,OAAO;YACLf,QAAQC,MAAM,GAAGZ,QAAQS,MAAM,CAACL,UAAU,CAACI,EAAE;QAC/C;IACF;IAEA,IAAIG,QAAQC,MAAM,EAAE;QAClBL,aAAaJ,IAAI,GAAGQ,QAAQC,MAAM;IACpC;IAEA,IAAIP;IAEJ,IAAIC,iBAAiBqB,OAAOC,IAAI,CAACtB,eAAeuB,MAAM,GAAG,GAAG;QAC1DxB,QAAQ,MAAMP,YAAY;YACxBE;YACAC;YACAS;YACAR;YACAK;YACAH;YACAC,OAAOC;QACT;IACF;IAEA,OAAO;QACLI;QACAC;QACAJ;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"],"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"],"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"],"mappings":"AAAA,SAASA,0BAA0B,QAAQ,kCAAiC;AAC5E,SAASC,qBAAqB,QAAQ,6BAA4B;AAElE,MAAMC,cAAc;IAClBC,UAAU;IACVC,QAAQ;IACRC,MAAM;AACR;AAUA,MAAMC,YAAY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
2
- import type { PgTableWithColumns } from 'drizzle-orm/pg-core';
3
- import type { Field, FieldAffectingData, TabAsField } from 'payload';
4
- import type { GenericColumn, GenericTable, PostgresAdapter } from '../types.js';
5
- import type { BuildQueryJoinAliases } 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
- joins: BuildQueryJoinAliases;
29
- locale?: string;
30
- pathSegments: string[];
31
- rootTableName?: string;
32
- selectFields: Record<string, GenericColumn>;
33
- tableName: string;
34
- /**
35
- * If creating a new table name for arrays and blocks, this suffix should be appended to the table name
36
- */
37
- tableNameSuffix?: string;
38
- /**
39
- * The raw value of the query before sanitization
40
- */
41
- value: unknown;
42
- };
43
- /**
44
- * Transforms path to table and column name
45
- * Adds tables to `join`
46
- * @returns TableColumn
47
- */
48
- export declare const getTableColumnFromPath: ({ adapter, aliasTable, collectionPath, columnPrefix, constraintPath: incomingConstraintPath, constraints, fields, joins, locale: incomingLocale, pathSegments: incomingSegments, rootTableName: incomingRootTableName, selectFields, tableName, tableNameSuffix, value, }: Args) => TableColumn;
49
- export {};
50
- //# 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,OAA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