@payloadcms/db-postgres 3.0.0-canary.ee0375f → 3.0.0-canary.ef0a8d0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (380) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +4 -6
  3. package/dist/connect.js.map +1 -1
  4. package/dist/countDistinct.d.ts +3 -0
  5. package/dist/countDistinct.d.ts.map +1 -0
  6. package/dist/countDistinct.js +26 -0
  7. package/dist/countDistinct.js.map +1 -0
  8. package/dist/createJSONQuery/convertPathToJSONTraversal.d.ts.map +1 -0
  9. package/dist/createJSONQuery/convertPathToJSONTraversal.js.map +1 -0
  10. package/dist/createJSONQuery/formatJSONPathSegment.d.ts.map +1 -0
  11. package/dist/createJSONQuery/formatJSONPathSegment.js.map +1 -0
  12. package/dist/createJSONQuery/index.d.ts.map +1 -0
  13. package/dist/createJSONQuery/index.js.map +1 -0
  14. package/dist/createMigration.d.ts.map +1 -1
  15. package/dist/createMigration.js +7 -29
  16. package/dist/createMigration.js.map +1 -1
  17. package/dist/defaultSnapshot.d.ts +3 -0
  18. package/dist/defaultSnapshot.d.ts.map +1 -0
  19. package/dist/defaultSnapshot.js +16 -0
  20. package/dist/defaultSnapshot.js.map +1 -0
  21. package/dist/deleteWhere.d.ts +3 -0
  22. package/dist/deleteWhere.d.ts.map +1 -0
  23. package/dist/deleteWhere.js +7 -0
  24. package/dist/deleteWhere.js.map +1 -0
  25. package/dist/dropDatabase.d.ts +3 -0
  26. package/dist/dropDatabase.d.ts.map +1 -0
  27. package/dist/dropDatabase.js +9 -0
  28. package/dist/dropDatabase.js.map +1 -0
  29. package/dist/execute.d.ts +3 -0
  30. package/dist/execute.d.ts.map +1 -0
  31. package/dist/execute.js +13 -0
  32. package/dist/execute.js.map +1 -0
  33. package/dist/exports/migration-utils.js.map +1 -1
  34. package/dist/generateDrizzleJSON.d.ts +3 -0
  35. package/dist/generateDrizzleJSON.d.ts.map +1 -0
  36. package/dist/generateDrizzleJSON.js +8 -0
  37. package/dist/generateDrizzleJSON.js.map +1 -0
  38. package/dist/generateMigration.d.ts +3 -0
  39. package/dist/generateMigration.d.ts.map +1 -0
  40. package/dist/generateMigration.js +8 -0
  41. package/dist/generateMigration.js.map +1 -0
  42. package/dist/getMigrationTemplate.d.ts +3 -0
  43. package/dist/getMigrationTemplate.d.ts.map +1 -0
  44. package/dist/getMigrationTemplate.js +12 -0
  45. package/dist/getMigrationTemplate.js.map +1 -0
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +27 -62
  48. package/dist/index.js.map +1 -1
  49. package/dist/init.d.ts.map +1 -1
  50. package/dist/init.js +1 -1
  51. package/dist/init.js.map +1 -1
  52. package/dist/insert.d.ts +3 -0
  53. package/dist/insert.d.ts.map +1 -0
  54. package/dist/insert.js +13 -0
  55. package/dist/insert.js.map +1 -0
  56. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -1
  57. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +5 -4
  58. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
  59. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +5 -1
  60. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -1
  61. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -1
  62. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -1
  63. package/dist/predefinedMigrations/v2-v3/index.d.ts +2 -2
  64. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
  65. package/dist/predefinedMigrations/v2-v3/index.js +7 -1
  66. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -1
  67. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +5 -4
  68. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
  69. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +1 -0
  70. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -1
  71. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +3 -2
  72. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
  73. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -1
  74. package/dist/predefinedMigrations/v2-v3/types.js.map +1 -1
  75. package/dist/requireDrizzleKit.d.ts +3 -0
  76. package/dist/requireDrizzleKit.d.ts.map +1 -0
  77. package/dist/requireDrizzleKit.js +5 -0
  78. package/dist/requireDrizzleKit.js.map +1 -0
  79. package/dist/schema/build.d.ts.map +1 -1
  80. package/dist/schema/build.js +2 -2
  81. package/dist/schema/build.js.map +1 -1
  82. package/dist/schema/createIndex.js.map +1 -1
  83. package/dist/schema/idToUUID.js.map +1 -1
  84. package/dist/schema/parentIDColumnMap.js.map +1 -1
  85. package/dist/schema/setColumnID.js.map +1 -1
  86. package/dist/schema/traverseFields.d.ts.map +1 -1
  87. package/dist/schema/traverseFields.js +2 -4
  88. package/dist/schema/traverseFields.js.map +1 -1
  89. package/dist/types.d.ts +72 -29
  90. package/dist/types.d.ts.map +1 -1
  91. package/dist/types.js.map +1 -1
  92. package/package.json +9 -9
  93. package/dist/count.d.ts +0 -3
  94. package/dist/count.d.ts.map +0 -1
  95. package/dist/count.js +0 -41
  96. package/dist/count.js.map +0 -1
  97. package/dist/create.d.ts +0 -3
  98. package/dist/create.d.ts.map +0 -1
  99. package/dist/create.js +0 -19
  100. package/dist/create.js.map +0 -1
  101. package/dist/createGlobal.d.ts +0 -4
  102. package/dist/createGlobal.d.ts.map +0 -1
  103. package/dist/createGlobal.js +0 -19
  104. package/dist/createGlobal.js.map +0 -1
  105. package/dist/createGlobalVersion.d.ts +0 -5
  106. package/dist/createGlobalVersion.d.ts.map +0 -1
  107. package/dist/createGlobalVersion.js +0 -33
  108. package/dist/createGlobalVersion.js.map +0 -1
  109. package/dist/createVersion.d.ts +0 -4
  110. package/dist/createVersion.d.ts.map +0 -1
  111. package/dist/createVersion.js +0 -40
  112. package/dist/createVersion.js.map +0 -1
  113. package/dist/deleteMany.d.ts +0 -3
  114. package/dist/deleteMany.d.ts.map +0 -1
  115. package/dist/deleteMany.js +0 -28
  116. package/dist/deleteMany.js.map +0 -1
  117. package/dist/deleteOne.d.ts +0 -3
  118. package/dist/deleteOne.d.ts.map +0 -1
  119. package/dist/deleteOne.js +0 -59
  120. package/dist/deleteOne.js.map +0 -1
  121. package/dist/deleteVersions.d.ts +0 -3
  122. package/dist/deleteVersions.d.ts.map +0 -1
  123. package/dist/deleteVersions.js +0 -31
  124. package/dist/deleteVersions.js.map +0 -1
  125. package/dist/destroy.d.ts +0 -3
  126. package/dist/destroy.d.ts.map +0 -1
  127. package/dist/destroy.js +0 -15
  128. package/dist/destroy.js.map +0 -1
  129. package/dist/find/buildFindManyArgs.d.ts +0 -17
  130. package/dist/find/buildFindManyArgs.d.ts.map +0 -1
  131. package/dist/find/buildFindManyArgs.js +0 -65
  132. package/dist/find/buildFindManyArgs.js.map +0 -1
  133. package/dist/find/chainMethods.d.ts +0 -16
  134. package/dist/find/chainMethods.d.ts.map +0 -1
  135. package/dist/find/chainMethods.js +0 -12
  136. package/dist/find/chainMethods.js.map +0 -1
  137. package/dist/find/findMany.d.ts +0 -21
  138. package/dist/find/findMany.d.ts.map +0 -1
  139. package/dist/find/findMany.js +0 -152
  140. package/dist/find/findMany.js.map +0 -1
  141. package/dist/find/traverseFields.d.ts +0 -17
  142. package/dist/find/traverseFields.d.ts.map +0 -1
  143. package/dist/find/traverseFields.js +0 -156
  144. package/dist/find/traverseFields.js.map +0 -1
  145. package/dist/find.d.ts +0 -3
  146. package/dist/find.d.ts.map +0 -1
  147. package/dist/find.js +0 -21
  148. package/dist/find.js.map +0 -1
  149. package/dist/findGlobal.d.ts +0 -3
  150. package/dist/findGlobal.d.ts.map +0 -1
  151. package/dist/findGlobal.js +0 -23
  152. package/dist/findGlobal.js.map +0 -1
  153. package/dist/findGlobalVersions.d.ts +0 -3
  154. package/dist/findGlobalVersions.d.ts.map +0 -1
  155. package/dist/findGlobalVersions.js +0 -24
  156. package/dist/findGlobalVersions.js.map +0 -1
  157. package/dist/findOne.d.ts +0 -4
  158. package/dist/findOne.d.ts.map +0 -1
  159. package/dist/findOne.js +0 -21
  160. package/dist/findOne.js.map +0 -1
  161. package/dist/findVersions.d.ts +0 -3
  162. package/dist/findVersions.d.ts.map +0 -1
  163. package/dist/findVersions.js +0 -24
  164. package/dist/findVersions.js.map +0 -1
  165. package/dist/migrate.d.ts +0 -3
  166. package/dist/migrate.d.ts.map +0 -1
  167. package/dist/migrate.js +0 -99
  168. package/dist/migrate.js.map +0 -1
  169. package/dist/migrateDown.d.ts +0 -3
  170. package/dist/migrateDown.d.ts.map +0 -1
  171. package/dist/migrateDown.js +0 -63
  172. package/dist/migrateDown.js.map +0 -1
  173. package/dist/migrateFresh.d.ts +0 -8
  174. package/dist/migrateFresh.d.ts.map +0 -1
  175. package/dist/migrateFresh.js +0 -72
  176. package/dist/migrateFresh.js.map +0 -1
  177. package/dist/migrateRefresh.d.ts +0 -6
  178. package/dist/migrateRefresh.d.ts.map +0 -1
  179. package/dist/migrateRefresh.js +0 -102
  180. package/dist/migrateRefresh.js.map +0 -1
  181. package/dist/migrateReset.d.ts +0 -6
  182. package/dist/migrateReset.d.ts.map +0 -1
  183. package/dist/migrateReset.js +0 -82
  184. package/dist/migrateReset.js.map +0 -1
  185. package/dist/migrateStatus.d.ts +0 -3
  186. package/dist/migrateStatus.d.ts.map +0 -1
  187. package/dist/migrateStatus.js +0 -44
  188. package/dist/migrateStatus.js.map +0 -1
  189. package/dist/queries/buildAndOrConditions.d.ts +0 -16
  190. package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
  191. package/dist/queries/buildAndOrConditions.js +0 -28
  192. package/dist/queries/buildAndOrConditions.js.map +0 -1
  193. package/dist/queries/buildQuery.d.ts +0 -30
  194. package/dist/queries/buildQuery.d.ts.map +0 -1
  195. package/dist/queries/buildQuery.js +0 -72
  196. package/dist/queries/buildQuery.js.map +0 -1
  197. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  198. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  199. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  200. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  201. package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
  202. package/dist/queries/createJSONQuery/index.js.map +0 -1
  203. package/dist/queries/getTableColumnFromPath.d.ts +0 -50
  204. package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
  205. package/dist/queries/getTableColumnFromPath.js +0 -516
  206. package/dist/queries/getTableColumnFromPath.js.map +0 -1
  207. package/dist/queries/operatorMap.d.ts +0 -18
  208. package/dist/queries/operatorMap.d.ts.map +0 -1
  209. package/dist/queries/operatorMap.js +0 -24
  210. package/dist/queries/operatorMap.js.map +0 -1
  211. package/dist/queries/parseParams.d.ts +0 -16
  212. package/dist/queries/parseParams.d.ts.map +0 -1
  213. package/dist/queries/parseParams.js +0 -183
  214. package/dist/queries/parseParams.js.map +0 -1
  215. package/dist/queries/sanitizeQueryValue.d.ts +0 -15
  216. package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
  217. package/dist/queries/sanitizeQueryValue.js +0 -89
  218. package/dist/queries/sanitizeQueryValue.js.map +0 -1
  219. package/dist/queries/selectDistinct.d.ts +0 -22
  220. package/dist/queries/selectDistinct.d.ts.map +0 -1
  221. package/dist/queries/selectDistinct.js +0 -30
  222. package/dist/queries/selectDistinct.js.map +0 -1
  223. package/dist/queryDrafts.d.ts +0 -3
  224. package/dist/queryDrafts.d.ts.map +0 -1
  225. package/dist/queryDrafts.js +0 -40
  226. package/dist/queryDrafts.js.map +0 -1
  227. package/dist/schema/createTableName.d.ts +0 -30
  228. package/dist/schema/createTableName.d.ts.map +0 -1
  229. package/dist/schema/createTableName.js +0 -31
  230. package/dist/schema/createTableName.js.map +0 -1
  231. package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
  232. package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
  233. package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
  234. package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
  235. package/dist/transactions/beginTransaction.d.ts +0 -3
  236. package/dist/transactions/beginTransaction.d.ts.map +0 -1
  237. package/dist/transactions/beginTransaction.js +0 -51
  238. package/dist/transactions/beginTransaction.js.map +0 -1
  239. package/dist/transactions/commitTransaction.d.ts +0 -3
  240. package/dist/transactions/commitTransaction.d.ts.map +0 -1
  241. package/dist/transactions/commitTransaction.js +0 -14
  242. package/dist/transactions/commitTransaction.js.map +0 -1
  243. package/dist/transactions/rollbackTransaction.d.ts +0 -3
  244. package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
  245. package/dist/transactions/rollbackTransaction.js +0 -13
  246. package/dist/transactions/rollbackTransaction.js.map +0 -1
  247. package/dist/transform/read/hasManyNumber.d.ts +0 -10
  248. package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
  249. package/dist/transform/read/hasManyNumber.js +0 -10
  250. package/dist/transform/read/hasManyNumber.js.map +0 -1
  251. package/dist/transform/read/hasManyText.d.ts +0 -10
  252. package/dist/transform/read/hasManyText.d.ts.map +0 -1
  253. package/dist/transform/read/hasManyText.js +0 -10
  254. package/dist/transform/read/hasManyText.js.map +0 -1
  255. package/dist/transform/read/index.d.ts +0 -13
  256. package/dist/transform/read/index.d.ts.map +0 -1
  257. package/dist/transform/read/index.js +0 -44
  258. package/dist/transform/read/index.js.map +0 -1
  259. package/dist/transform/read/relationship.d.ts +0 -10
  260. package/dist/transform/read/relationship.d.ts.map +0 -1
  261. package/dist/transform/read/relationship.js +0 -60
  262. package/dist/transform/read/relationship.js.map +0 -1
  263. package/dist/transform/read/traverseFields.d.ts +0 -57
  264. package/dist/transform/read/traverseFields.d.ts.map +0 -1
  265. package/dist/transform/read/traverseFields.js +0 -435
  266. package/dist/transform/read/traverseFields.js.map +0 -1
  267. package/dist/transform/write/array.d.ts +0 -26
  268. package/dist/transform/write/array.d.ts.map +0 -1
  269. package/dist/transform/write/array.js +0 -58
  270. package/dist/transform/write/array.js.map +0 -1
  271. package/dist/transform/write/blocks.d.ts +0 -25
  272. package/dist/transform/write/blocks.d.ts.map +0 -1
  273. package/dist/transform/write/blocks.js +0 -54
  274. package/dist/transform/write/blocks.js.map +0 -1
  275. package/dist/transform/write/index.d.ts +0 -13
  276. package/dist/transform/write/index.d.ts.map +0 -1
  277. package/dist/transform/write/index.js +0 -41
  278. package/dist/transform/write/index.js.map +0 -1
  279. package/dist/transform/write/numbers.d.ts +0 -8
  280. package/dist/transform/write/numbers.d.ts.map +0 -1
  281. package/dist/transform/write/numbers.js +0 -11
  282. package/dist/transform/write/numbers.js.map +0 -1
  283. package/dist/transform/write/relationships.d.ts +0 -10
  284. package/dist/transform/write/relationships.d.ts.map +0 -1
  285. package/dist/transform/write/relationships.js +0 -23
  286. package/dist/transform/write/relationships.js.map +0 -1
  287. package/dist/transform/write/selects.d.ts +0 -8
  288. package/dist/transform/write/selects.d.ts.map +0 -1
  289. package/dist/transform/write/selects.js +0 -20
  290. package/dist/transform/write/selects.js.map +0 -1
  291. package/dist/transform/write/texts.d.ts +0 -8
  292. package/dist/transform/write/texts.d.ts.map +0 -1
  293. package/dist/transform/write/texts.js +0 -11
  294. package/dist/transform/write/texts.js.map +0 -1
  295. package/dist/transform/write/traverseFields.d.ts +0 -50
  296. package/dist/transform/write/traverseFields.d.ts.map +0 -1
  297. package/dist/transform/write/traverseFields.js +0 -445
  298. package/dist/transform/write/traverseFields.js.map +0 -1
  299. package/dist/transform/write/types.d.ts +0 -43
  300. package/dist/transform/write/types.d.ts.map +0 -1
  301. package/dist/transform/write/types.js +0 -3
  302. package/dist/transform/write/types.js.map +0 -1
  303. package/dist/update.d.ts +0 -3
  304. package/dist/update.d.ts.map +0 -1
  305. package/dist/update.js +0 -54
  306. package/dist/update.js.map +0 -1
  307. package/dist/updateGlobal.d.ts +0 -4
  308. package/dist/updateGlobal.d.ts.map +0 -1
  309. package/dist/updateGlobal.js +0 -25
  310. package/dist/updateGlobal.js.map +0 -1
  311. package/dist/updateGlobalVersion.d.ts +0 -4
  312. package/dist/updateGlobalVersion.d.ts.map +0 -1
  313. package/dist/updateGlobalVersion.js +0 -36
  314. package/dist/updateGlobalVersion.js.map +0 -1
  315. package/dist/updateVersion.d.ts +0 -4
  316. package/dist/updateVersion.d.ts.map +0 -1
  317. package/dist/updateVersion.js +0 -36
  318. package/dist/updateVersion.js.map +0 -1
  319. package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
  320. package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
  321. package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
  322. package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
  323. package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
  324. package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
  325. package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
  326. package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
  327. package/dist/upsertRow/index.d.ts +0 -4
  328. package/dist/upsertRow/index.d.ts.map +0 -1
  329. package/dist/upsertRow/index.js +0 -279
  330. package/dist/upsertRow/index.js.map +0 -1
  331. package/dist/upsertRow/insertArrays.d.ts +0 -13
  332. package/dist/upsertRow/insertArrays.d.ts.map +0 -1
  333. package/dist/upsertRow/insertArrays.js +0 -68
  334. package/dist/upsertRow/insertArrays.js.map +0 -1
  335. package/dist/upsertRow/types.d.ts +0 -32
  336. package/dist/upsertRow/types.d.ts.map +0 -1
  337. package/dist/upsertRow/types.js +0 -3
  338. package/dist/upsertRow/types.js.map +0 -1
  339. package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
  340. package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
  341. package/dist/utilities/appendPrefixToKeys.js +0 -6
  342. package/dist/utilities/appendPrefixToKeys.js.map +0 -1
  343. package/dist/utilities/createBlocksMap.d.ts +0 -5
  344. package/dist/utilities/createBlocksMap.d.ts.map +0 -1
  345. package/dist/utilities/createBlocksMap.js +0 -29
  346. package/dist/utilities/createBlocksMap.js.map +0 -1
  347. package/dist/utilities/createMigrationTable.d.ts +0 -3
  348. package/dist/utilities/createMigrationTable.d.ts.map +0 -1
  349. package/dist/utilities/createMigrationTable.js +0 -13
  350. package/dist/utilities/createMigrationTable.js.map +0 -1
  351. package/dist/utilities/createRelationshipMap.d.ts +0 -2
  352. package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
  353. package/dist/utilities/createRelationshipMap.js +0 -19
  354. package/dist/utilities/createRelationshipMap.js.map +0 -1
  355. package/dist/utilities/hasLocalesTable.d.ts +0 -3
  356. package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
  357. package/dist/utilities/hasLocalesTable.js +0 -11
  358. package/dist/utilities/hasLocalesTable.js.map +0 -1
  359. package/dist/utilities/isArrayOfRows.d.ts +0 -2
  360. package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
  361. package/dist/utilities/isArrayOfRows.js +0 -5
  362. package/dist/utilities/isArrayOfRows.js.map +0 -1
  363. package/dist/utilities/migrationTableExists.d.ts +0 -3
  364. package/dist/utilities/migrationTableExists.d.ts.map +0 -1
  365. package/dist/utilities/migrationTableExists.js +0 -9
  366. package/dist/utilities/migrationTableExists.js.map +0 -1
  367. package/dist/utilities/parseError.d.ts +0 -5
  368. package/dist/utilities/parseError.d.ts.map +0 -1
  369. package/dist/utilities/parseError.js +0 -17
  370. package/dist/utilities/parseError.js.map +0 -1
  371. package/dist/utilities/pushDevSchema.d.ts +0 -9
  372. package/dist/utilities/pushDevSchema.d.ts.map +0 -1
  373. package/dist/utilities/pushDevSchema.js +0 -58
  374. package/dist/utilities/pushDevSchema.js.map +0 -1
  375. /package/dist/{queries/createJSONQuery → createJSONQuery}/convertPathToJSONTraversal.d.ts +0 -0
  376. /package/dist/{queries/createJSONQuery → createJSONQuery}/convertPathToJSONTraversal.js +0 -0
  377. /package/dist/{queries/createJSONQuery → createJSONQuery}/formatJSONPathSegment.d.ts +0 -0
  378. /package/dist/{queries/createJSONQuery → createJSONQuery}/formatJSONPathSegment.js +0 -0
  379. /package/dist/{queries/createJSONQuery → createJSONQuery}/index.d.ts +0 -0
  380. /package/dist/{queries/createJSONQuery → createJSONQuery}/index.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAW,MAAM,SAAS,CAAA;AA+C/C,eAAO,MAAM,OAAO,EAAE,OAmDrB,CAAA"}
1
+ {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAW,MAAM,SAAS,CAAA;AA6C/C,eAAO,MAAM,OAAO,EAAE,OA8CrB,CAAA"}
package/dist/connect.js CHANGED
@@ -1,7 +1,6 @@
1
- import { sql } from 'drizzle-orm';
1
+ import { pushDevSchema } from '@payloadcms/drizzle';
2
2
  import { drizzle } from 'drizzle-orm/node-postgres';
3
3
  import pg from 'pg';
4
- import { pushDevSchema } from './utilities/pushDevSchema.js';
5
4
  const connectWithReconnect = async function({ adapter, payload, reconnect = false }) {
6
5
  let result;
7
6
  if (!reconnect) {
@@ -62,10 +61,9 @@ export const connect = async function connect(options = {
62
61
  if (!hotReload) {
63
62
  if (process.env.PAYLOAD_DROP_DATABASE === 'true') {
64
63
  this.payload.logger.info(`---- DROPPING TABLES SCHEMA(${this.schemaName || 'public'}) ----`);
65
- await this.drizzle.execute(sql.raw(`
66
- drop schema if exists ${this.schemaName || 'public'} cascade;
67
- create schema ${this.schemaName || 'public'};
68
- `));
64
+ await this.dropDatabase({
65
+ adapter: this
66
+ });
69
67
  this.payload.logger.info('---- DROPPED TABLES ----');
70
68
  }
71
69
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { Connect, Payload } from 'payload'\n\nimport { sql } from 'drizzle-orm'\nimport { drizzle } from 'drizzle-orm/node-postgres'\nimport pg from 'pg'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { pushDevSchema } from './utilities/pushDevSchema.js'\n\nconst connectWithReconnect = async function ({\n adapter,\n payload,\n reconnect = false,\n}: {\n adapter: PostgresAdapter\n payload: Payload\n reconnect?: boolean\n}) {\n let result\n\n if (!reconnect) {\n result = await adapter.pool.connect()\n } else {\n try {\n result = await adapter.pool.connect()\n } catch (err) {\n setTimeout(() => {\n payload.logger.info('Reconnecting to postgres')\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }, 1000)\n }\n }\n if (!result) {\n return\n }\n result.prependListener('error', (err) => {\n try {\n if (err.code === 'ECONNRESET') {\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }\n } catch (err) {\n // swallow error\n }\n })\n}\n\nexport const connect: Connect = async function connect(\n this: PostgresAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n this.schema = {\n ...this.tables,\n ...this.relations,\n ...this.enums,\n }\n\n try {\n if (!this.pool) {\n this.pool = new pg.Pool(this.poolOptions)\n await connectWithReconnect({ adapter: this, payload: this.payload })\n }\n\n const logger = this.logger || false\n this.drizzle = drizzle(this.pool, { logger, schema: this.schema })\n\n if (!hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info(`---- DROPPING TABLES SCHEMA(${this.schemaName || 'public'}) ----`)\n await this.drizzle.execute(\n sql.raw(`\n drop schema if exists ${this.schemaName || 'public'} cascade;\n create schema ${this.schemaName || 'public'};\n `),\n )\n this.payload.logger.info('---- DROPPED TABLES ----')\n }\n }\n } catch (err) {\n this.payload.logger.error(`Error: cannot connect to Postgres. Details: ${err.message}`, err)\n if (typeof this.rejectInitializing === 'function') this.rejectInitializing()\n process.exit(1)\n }\n\n // Only push schema if not in production\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_MIGRATING !== 'true' &&\n this.push !== false\n ) {\n await pushDevSchema(this)\n }\n\n if (typeof this.resolveInitializing === 'function') this.resolveInitializing()\n}\n"],"names":["sql","drizzle","pg","pushDevSchema","connectWithReconnect","adapter","payload","reconnect","result","pool","connect","err","setTimeout","logger","info","prependListener","code","options","hotReload","schema","tables","relations","enums","Pool","poolOptions","process","env","PAYLOAD_DROP_DATABASE","schemaName","execute","raw","error","message","rejectInitializing","exit","NODE_ENV","PAYLOAD_MIGRATING","push","resolveInitializing"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,OAAO,QAAQ,4BAA2B;AACnD,OAAOC,QAAQ,KAAI;AAInB,SAASC,aAAa,QAAQ,+BAA8B;AAE5D,MAAMC,uBAAuB,eAAgB,EAC3CC,OAAO,EACPC,OAAO,EACPC,YAAY,KAAK,EAKlB;IACC,IAAIC;IAEJ,IAAI,CAACD,WAAW;QACdC,SAAS,MAAMH,QAAQI,IAAI,CAACC,OAAO;IACrC,OAAO;QACL,IAAI;YACFF,SAAS,MAAMH,QAAQI,IAAI,CAACC,OAAO;QACrC,EAAE,OAAOC,KAAK;YACZC,WAAW;gBACTN,QAAQO,MAAM,CAACC,IAAI,CAAC;gBACpB,KAAKV,qBAAqB;oBAAEC;oBAASC;oBAASC,WAAW;gBAAK;YAChE,GAAG;QACL;IACF;IACA,IAAI,CAACC,QAAQ;QACX;IACF;IACAA,OAAOO,eAAe,CAAC,SAAS,CAACJ;QAC/B,IAAI;YACF,IAAIA,IAAIK,IAAI,KAAK,cAAc;gBAC7B,KAAKZ,qBAAqB;oBAAEC;oBAASC;oBAASC,WAAW;gBAAK;YAChE;QACF,EAAE,OAAOI,KAAK;QACZ,gBAAgB;QAClB;IACF;AACF;AAEA,OAAO,MAAMD,UAAmB,eAAeA,Q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,QAAQS,IAAI,CAAC;IACf;IAEA,wCAAwC;IACxC,IACET,QAAQC,GAAG,CAACS,QAAQ,KAAK,gBACzBV,QAAQC,GAAG,CAACU,iBAAiB,KAAK,UAClC,IAAI,CAACC,IAAI,KAAK,OACd;QACA,MAAMlC,cAAc,IAAI;IAC1B;IAEA,IAAI,OAAO,IAAI,CAACmC,mBAAmB,KAAK,YAAY,IAAI,CAACA,mBAAmB;AAC9E,EAAC"}
1
+ {"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { DrizzleAdapter } from '@payloadcms/drizzle/types'\nimport type { Connect, Payload } from 'payload'\n\nimport { pushDevSchema } from '@payloadcms/drizzle'\nimport { drizzle } from 'drizzle-orm/node-postgres'\nimport pg from 'pg'\n\nimport type { PostgresAdapter } from './types.js'\n\nconst connectWithReconnect = async function ({\n adapter,\n payload,\n reconnect = false,\n}: {\n adapter: PostgresAdapter\n payload: Payload\n reconnect?: boolean\n}) {\n let result\n\n if (!reconnect) {\n result = await adapter.pool.connect()\n } else {\n try {\n result = await adapter.pool.connect()\n } catch (err) {\n setTimeout(() => {\n payload.logger.info('Reconnecting to postgres')\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }, 1000)\n }\n }\n if (!result) {\n return\n }\n result.prependListener('error', (err) => {\n try {\n if (err.code === 'ECONNRESET') {\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }\n } catch (err) {\n // swallow error\n }\n })\n}\n\nexport const connect: Connect = async function connect(\n this: PostgresAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n this.schema = {\n ...this.tables,\n ...this.relations,\n ...this.enums,\n }\n\n try {\n if (!this.pool) {\n this.pool = new pg.Pool(this.poolOptions)\n await connectWithReconnect({ adapter: this, payload: this.payload })\n }\n\n const logger = this.logger || false\n this.drizzle = drizzle(this.pool, { logger, schema: this.schema })\n\n if (!hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info(`---- DROPPING TABLES SCHEMA(${this.schemaName || 'public'}) ----`)\n await this.dropDatabase({ adapter: this })\n this.payload.logger.info('---- DROPPED TABLES ----')\n }\n }\n } catch (err) {\n this.payload.logger.error(`Error: cannot connect to Postgres. Details: ${err.message}`, err)\n if (typeof this.rejectInitializing === 'function') this.rejectInitializing()\n process.exit(1)\n }\n\n // Only push schema if not in production\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_MIGRATING !== 'true' &&\n this.push !== false\n ) {\n await pushDevSchema(this as unknown as DrizzleAdapter)\n }\n\n if (typeof this.resolveInitializing === 'function') this.resolveInitializing()\n}\n"],"names":["pushDevSchema","drizzle","pg","connectWithReconnect","adapter","payload","reconnect","result","pool","connect","err","setTimeout","logger","info","prependListener","code","options","hotReload","schema","tables","relations","enums","Pool","poolOptions","process","env","PAYLOAD_DROP_DATABASE","schemaName","dropDatabase","error","message","rejectInitializing","exit","NODE_ENV","PAYLOAD_MIGRATING","push","resolveInitializing"],"mappings":"AAGA,SAASA,aAAa,QAAQ,sBAAqB;AACnD,SAASC,OAAO,QAAQ,4BAA2B;AACnD,OAAOC,QAAQ,KAAI;AAInB,MAAMC,uBAAuB,eAAgB,EAC3CC,OAAO,EACPC,OAAO,EACPC,YAAY,KAAK,EAKlB;IACC,IAAIC;IAEJ,IAAI,CAACD,WAAW;QACdC,SAAS,MAAMH,QAAQI,IAAI,CAACC,OAAO;IACrC,OAAO;QACL,IAAI;YACFF,SAAS,MAAMH,QAAQI,IAAI,CAACC,OAAO;QACrC,EAAE,OAAOC,KAAK;YACZC,WAAW;gBACTN,QAAQO,MAAM,CAACC,IAAI,CAAC;gBACpB,KAAKV,qBAAqB;oBAAEC;oBAASC;oBAASC,WAAW;gBAAK;YAChE,GAAG;QACL;IACF;IACA,IAAI,CAACC,QAAQ;QACX;IACF;IACAA,OAAOO,eAAe,CAAC,SAAS,CAACJ;QAC/B,IAAI;YACF,IAAIA,IAAIK,IAAI,KAAK,cAAc;gBAC7B,KAAKZ,qBAAqB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BAAkB;QAC1EP,QAAQQ,IAAI,CAAC;IACf;IAEA,wCAAwC;IACxC,IACER,QAAQC,GAAG,CAACQ,QAAQ,KAAK,gBACzBT,QAAQC,GAAG,CAACS,iBAAiB,KAAK,UAClC,IAAI,CAACC,IAAI,KAAK,OACd;QACA,MAAMnC,cAAc,IAAI;IAC1B;IAEA,IAAI,OAAO,IAAI,CAACoC,mBAAmB,KAAK,YAAY,IAAI,CAACA,mBAAmB;AAC9E,EAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CountDistinct } from './types.js';
2
+ export declare const countDistinct: CountDistinct;
3
+ //# sourceMappingURL=countDistinct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"countDistinct.d.ts","sourceRoot":"","sources":["../src/countDistinct.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAA;AAEhE,eAAO,MAAM,aAAa,EAAE,aA2B3B,CAAA"}
@@ -0,0 +1,26 @@
1
+ import { chainMethods } from '@payloadcms/drizzle';
2
+ import { sql } from 'drizzle-orm';
3
+ export const countDistinct = async function countDistinct({ db, joins, tableName, where }) {
4
+ const chainedMethods = [];
5
+ joins.forEach(({ condition, table })=>{
6
+ chainedMethods.push({
7
+ args: [
8
+ table,
9
+ condition
10
+ ],
11
+ method: 'leftJoin'
12
+ });
13
+ });
14
+ const countResult = await chainMethods({
15
+ methods: chainedMethods,
16
+ query: db.select({
17
+ // @ts-expect-error generic string is not matching union type from drizzle
18
+ count: sql`count
19
+ (DISTINCT ${this.tables[tableName].id})`
20
+ }).from(this.tables[tableName])// @ts-expect-error where is picking up libsql types
21
+ .where(where)
22
+ });
23
+ return Number(countResult[0].count);
24
+ };
25
+
26
+ //# sourceMappingURL=countDistinct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/countDistinct.ts"],"sourcesContent":["import type { ChainedMethods, TransactionPg } from '@payloadcms/drizzle/types'\n\nimport { chainMethods } from '@payloadcms/drizzle'\nimport { sql } from 'drizzle-orm'\n\nimport type { CountDistinct, PostgresAdapter } from './types.js'\n\nexport const countDistinct: CountDistinct = async function countDistinct(\n this: PostgresAdapter,\n { db, joins, tableName, where },\n) {\n const chainedMethods: ChainedMethods = []\n\n joins.forEach(({ condition, table }) => {\n chainedMethods.push({\n args: [table, condition],\n method: 'leftJoin',\n })\n })\n\n const countResult = await chainMethods({\n methods: chainedMethods,\n query: (db as TransactionPg)\n .select({\n // @ts-expect-error generic string is not matching union type from drizzle\n count: sql<string>`count\n (DISTINCT ${this.tables[tableName].id})`,\n })\n .from(this.tables[tableName])\n // @ts-expect-error where is picking up libsql types\n .where(where),\n })\n\n return Number(countResult[0].count)\n}\n"],"names":["chainMethods","sql","countDistinct","db","joins","tableName","where","chainedMethods","forEach","condition","table","push","args","method","countResult","methods","query","select","count","tables","id","from","Number"],"mappings":"AAEA,SAASA,YAAY,QAAQ,sBAAqB;AAClD,SAASC,GAAG,QAAQ,cAAa;AAIjC,OAAO,MAAMC,gBAA+B,eAAeA,cAEzD,EAAEC,EAAE,EAAEC,KAAK,EAAEC,SAAS,EAAEC,KAAK,EAAE;IAE/B,MAAMC,iBAAiC,EAAE;IAEzCH,MAAMI,OAAO,CAAC,CAAC,EAAEC,SAAS,EAAEC,KAAK,EAAE;QACjCH,eAAeI,IAAI,CAAC;YAClBC,MAAM;gBAACF;gBAAOD;aAAU;YACxBI,QAAQ;QACV;IACF;IAEA,MAAMC,cAAc,MAAMd,aAAa;QACrCe,SAASR;QACTS,OAAO,AAACb,GACLc,MAAM,CAAC;YACN,0EAA0E;YAC1EC,OAAOjB,GAAW,CAAC;sBACL,EAAE,IAAI,CAACkB,MAAM,CAACd,UAAU,CAACe,EAAE,CAAC,CAAC,CAAC;QAC9C,GACCC,IAAI,CAAC,IAAI,CAACF,MAAM,CAACd,UAAU,CAC5B,oDAAoD;SACnDC,KAAK,CAACA;IACX;IAEA,OAAOgB,OAAOR,WAAW,CAAC,EAAE,CAACI,KAAK;AACpC,EAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertPathToJSONTraversal.d.ts","sourceRoot":"","sources":["../../src/createJSONQuery/convertPathToJSONTraversal.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,qBAAsB,MAAM,EAAE,WAUpE,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/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"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatJSONPathSegment.d.ts","sourceRoot":"","sources":["../../src/createJSONQuery/formatJSONPathSegment.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,YAAa,MAAM,WAEpD,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/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"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/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"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/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,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 +1 @@
1
- {"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../src/createMigration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,SAAS,CAAA;AA2CrE,eAAO,MAAM,eAAe,EAAE,eA6F7B,CAAA"}
1
+ {"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../src/createMigration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAgB9C,eAAO,MAAM,eAAe,EAAE,eA6F7B,CAAA"}
@@ -4,31 +4,9 @@ import path from 'path';
4
4
  import { getPredefinedMigration } from 'payload';
5
5
  import prompts from 'prompts';
6
6
  import { fileURLToPath } from 'url';
7
+ import { defaultDrizzleSnapshot } from './defaultSnapshot.js';
8
+ import { getMigrationTemplate } from './getMigrationTemplate.js';
7
9
  const require = createRequire(import.meta.url);
8
- const migrationTemplate = ({ downSQL, imports, upSQL })=>`import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
9
- ${imports ? `${imports}\n` : ''}
10
- export async function up({ payload, req }: MigrateUpArgs): Promise<void> {
11
- ${upSQL}
12
- };
13
-
14
- export async function down({ payload, req }: MigrateDownArgs): Promise<void> {
15
- ${downSQL}
16
- };
17
- `;
18
- const getDefaultDrizzleSnapshot = ()=>({
19
- id: '00000000-0000-0000-0000-000000000000',
20
- _meta: {
21
- columns: {},
22
- schemas: {},
23
- tables: {}
24
- },
25
- dialect: 'pg',
26
- enums: {},
27
- prevId: '00000000-0000-0000-0000-00000000000',
28
- schemas: {},
29
- tables: {},
30
- version: '5'
31
- });
32
10
  export const createMigration = async function createMigration({ file, forceAcceptWarning, migrationName, payload }) {
33
11
  const filename = fileURLToPath(import.meta.url);
34
12
  const dirname = path.dirname(filename);
@@ -54,7 +32,7 @@ export const createMigration = async function createMigration({ file, forceAccep
54
32
  const name = migrationName || file?.split('/').slice(2).join('/');
55
33
  const fileName = `${timestamp}${name ? `_${name.replace(/\W/g, '_')}` : ''}`;
56
34
  const filePath = `${dir}/${fileName}`;
57
- let drizzleJsonBefore = getDefaultDrizzleSnapshot();
35
+ let drizzleJsonBefore = defaultDrizzleSnapshot;
58
36
  if (!upSQL) {
59
37
  // Get latest migration snapshot
60
38
  const latestSnapshot = fs.readdirSync(dir).filter((file)=>file.endsWith('.json')).sort().reverse()?.[0];
@@ -63,7 +41,7 @@ export const createMigration = async function createMigration({ file, forceAccep
63
41
  }
64
42
  const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter);
65
43
  const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore);
66
- const sqlExecute = 'await payload.db.drizzle.execute(sql`';
44
+ const sqlExecute = 'await db.execute(sql`';
67
45
  if (sqlStatementsUp?.length) {
68
46
  upSQL = `${sqlExecute}\n ${sqlStatementsUp?.join('\n')}\`)`;
69
47
  }
@@ -85,11 +63,11 @@ export const createMigration = async function createMigration({ file, forceAccep
85
63
  process.exit(0);
86
64
  }
87
65
  }
66
+ // write schema
67
+ fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2));
88
68
  }
89
- // write schema
90
- fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2));
91
69
  // write migration
92
- fs.writeFileSync(`${filePath}.ts`, migrationTemplate({
70
+ fs.writeFileSync(`${filePath}.ts`, getMigrationTemplate({
93
71
  downSQL: downSQL || ` // Migration code`,
94
72
  imports,
95
73
  upSQL: upSQL || ` // Migration code`
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax, no-await-in-loop */\nimport type { DrizzleSnapshotJSON } from 'drizzle-kit/payload'\nimport type { CreateMigration, MigrationTemplateArgs } from 'payload'\n\nimport fs from 'fs'\nimport { createRequire } from 'module'\nimport path from 'path'\nimport { getPredefinedMigration } from 'payload'\nimport prompts from 'prompts'\nimport { fileURLToPath } from 'url'\n\nimport type { PostgresAdapter } from './types.js'\n\nconst require = createRequire(import.meta.url)\n\nconst migrationTemplate = ({\n downSQL,\n imports,\n upSQL,\n}: MigrationTemplateArgs): string => `import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'\n${imports ? `${imports}\\n` : ''}\nexport async function up({ payload, req }: MigrateUpArgs): Promise<void> {\n${upSQL}\n};\n\nexport async function down({ payload, req }: MigrateDownArgs): Promise<void> {\n${downSQL}\n};\n`\n\nconst getDefaultDrizzleSnapshot = (): DrizzleSnapshotJSON => ({\n id: '00000000-0000-0000-0000-000000000000',\n _meta: {\n columns: {},\n schemas: {},\n tables: {},\n },\n dialect: 'pg',\n enums: {},\n prevId: '00000000-0000-0000-0000-00000000000',\n schemas: {},\n tables: {},\n version: '5',\n})\n\nexport const createMigration: CreateMigration = async function createMigration(\n this: PostgresAdapter,\n { file, forceAcceptWarning, migrationName, payload },\n) {\n const filename = fileURLToPath(import.meta.url)\n const dirname = path.dirname(filename)\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n const { generateDrizzleJson, generateMigration } = require('drizzle-kit/payload')\n const drizzleJsonAfter = generateDrizzleJson(this.schema)\n const [yyymmdd, hhmmss] = new Date().toISOString().split('T')\n const formattedDate = yyymmdd.replace(/\\D/g, '')\n const formattedTime = hhmmss.split('.')[0].replace(/\\D/g, '')\n let imports: string = ''\n let downSQL: string\n let upSQL: string\n ;({ downSQL, imports, upSQL } = await getPredefinedMigration({\n dirname,\n file,\n migrationName,\n payload,\n }))\n\n const timestamp = `${formattedDate}_${formattedTime}`\n\n const name = migrationName || file?.split('/').slice(2).join('/')\n const fileName = `${timestamp}${name ? `_${name.replace(/\\W/g, '_')}` : ''}`\n\n const filePath = `${dir}/${fileName}`\n\n let drizzleJsonBefore = getDefaultDrizzleSnapshot()\n\n if (!upSQL) {\n // Get latest migration snapshot\n const latestSnapshot = fs\n .readdirSync(dir)\n .filter((file) => file.endsWith('.json'))\n .sort()\n .reverse()?.[0]\n\n if (latestSnapshot) {\n drizzleJsonBefore = JSON.parse(\n fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'),\n ) as DrizzleSnapshotJSON\n }\n\n const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter)\n const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore)\n const sqlExecute = 'await payload.db.drizzle.execute(sql`'\n\n if (sqlStatementsUp?.length) {\n upSQL = `${sqlExecute}\\n ${sqlStatementsUp?.join('\\n')}\\`)`\n }\n if (sqlStatementsDown?.length) {\n downSQL = `${sqlExecute}\\n ${sqlStatementsDown?.join('\\n')}\\`)`\n }\n\n if (!upSQL?.length && !downSQL?.length && !forceAcceptWarning) {\n const { confirm: shouldCreateBlankMigration } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message: 'No schema changes detected. Would you like to create a blank migration file?',\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!shouldCreateBlankMigration) {\n process.exit(0)\n }\n }\n }\n\n // write schema\n fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2))\n\n // write migration\n fs.writeFileSync(\n `${filePath}.ts`,\n migrationTemplate({\n downSQL: downSQL || ` // Migration code`,\n imports,\n upSQL: upSQL || ` // Migration code`,\n }),\n )\n payload.logger.info({ msg: `Migration created at ${filePath}.ts` })\n}\n"],"names":["fs","createRequire","path","getPredefinedMigration","prompts","fileURLToPath","require","url","migrationTemplate","downSQL","imports","upSQL","getDefaultDrizzleSnapshot","id","_meta","columns","schemas","tables","dialect","enums","prevId","version","createMigration","file","forceAcceptWarning","migrationName","payload","filename","dirname","dir","db","migrationDir","existsSync","mkdirSync","generateDrizzleJson","generateMigration","drizzleJsonAfter","schema","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","timestamp","name","slice","join","fileName","filePath","drizzleJsonBefore","latestSnapshot","readdirSync","filter","endsWith","sort","reverse","JSON","parse","readFileSync","sqlStatementsUp","sqlStatementsDown","sqlExecute","length","confirm","shouldCreateBlankMigration","type","initial","message","onCancel","process","exit","writeFileSync","stringify","logger","info","msg"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,yDAAyD,GAIzD,OAAOA,QAAQ,KAAI;AACnB,SAASC,aAAa,QAAQ,SAAQ;AACtC,OAAOC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ACxD,SAASwD,UAAU,CAACzC,oBAAoB;YAC7D,MAAM,EAAE0C,SAASC,0BAA0B,EAAE,GAAG,MAAM/D,QACpD;gBACE2C,MAAM;gBACNqB,MAAM;gBACNC,SAAS;gBACTC,SAAS;YACX,GACA;gBACEC,UAAU;oBACRC,QAAQC,IAAI,CAAC;gBACf;YACF;YAGF,IAAI,CAACN,4BAA4B;gBAC/BK,QAAQC,IAAI,CAAC;YACf;QACF;IACF;IAEA,eAAe;IACfzE,GAAG0E,aAAa,CAAC,CAAC,EAAEvB,SAAS,KAAK,CAAC,EAAEQ,KAAKgB,SAAS,CAACvC,kBAAkB,MAAM;IAE5E,kBAAkB;IAClBpC,GAAG0E,aAAa,CACd,CAAC,EAAEvB,SAAS,GAAG,CAAC,EAChB3C,kBAAkB;QAChBC,SAASA,WAAW,CAAC,mBAAmB,CAAC;QACzCC;QACAC,OAAOA,SAAS,CAAC,mBAAmB,CAAC;IACvC;IAEFe,QAAQkD,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK,CAAC,qBAAqB,EAAE3B,SAAS,GAAG,CAAC;IAAC;AACnE,EAAC"}
1
+ {"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax, no-await-in-loop */\nimport type { DrizzleSnapshotJSON } from 'drizzle-kit/payload'\nimport type { CreateMigration } from 'payload'\n\nimport fs from 'fs'\nimport { createRequire } from 'module'\nimport path from 'path'\nimport { getPredefinedMigration } from 'payload'\nimport prompts from 'prompts'\nimport { fileURLToPath } from 'url'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { defaultDrizzleSnapshot } from './defaultSnapshot.js'\nimport { getMigrationTemplate } from './getMigrationTemplate.js'\n\nconst require = createRequire(import.meta.url)\n\nexport const createMigration: CreateMigration = async function createMigration(\n this: PostgresAdapter,\n { file, forceAcceptWarning, migrationName, payload },\n) {\n const filename = fileURLToPath(import.meta.url)\n const dirname = path.dirname(filename)\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n const { generateDrizzleJson, generateMigration } = require('drizzle-kit/payload')\n const drizzleJsonAfter = generateDrizzleJson(this.schema)\n const [yyymmdd, hhmmss] = new Date().toISOString().split('T')\n const formattedDate = yyymmdd.replace(/\\D/g, '')\n const formattedTime = hhmmss.split('.')[0].replace(/\\D/g, '')\n let imports: string = ''\n let downSQL: string\n let upSQL: string\n ;({ downSQL, imports, upSQL } = await getPredefinedMigration({\n dirname,\n file,\n migrationName,\n payload,\n }))\n\n const timestamp = `${formattedDate}_${formattedTime}`\n\n const name = migrationName || file?.split('/').slice(2).join('/')\n const fileName = `${timestamp}${name ? `_${name.replace(/\\W/g, '_')}` : ''}`\n\n const filePath = `${dir}/${fileName}`\n\n let drizzleJsonBefore = defaultDrizzleSnapshot\n\n if (!upSQL) {\n // Get latest migration snapshot\n const latestSnapshot = fs\n .readdirSync(dir)\n .filter((file) => file.endsWith('.json'))\n .sort()\n .reverse()?.[0]\n\n if (latestSnapshot) {\n drizzleJsonBefore = JSON.parse(\n fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'),\n ) as DrizzleSnapshotJSON\n }\n\n const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter)\n const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore)\n const sqlExecute = 'await db.execute(sql`'\n\n if (sqlStatementsUp?.length) {\n upSQL = `${sqlExecute}\\n ${sqlStatementsUp?.join('\\n')}\\`)`\n }\n if (sqlStatementsDown?.length) {\n downSQL = `${sqlExecute}\\n ${sqlStatementsDown?.join('\\n')}\\`)`\n }\n\n if (!upSQL?.length && !downSQL?.length && !forceAcceptWarning) {\n const { confirm: shouldCreateBlankMigration } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message: 'No schema changes detected. Would you like to create a blank migration file?',\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!shouldCreateBlankMigration) {\n process.exit(0)\n }\n }\n\n // write schema\n fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2))\n }\n\n // write migration\n fs.writeFileSync(\n `${filePath}.ts`,\n getMigrationTemplate({\n downSQL: downSQL || ` // Migration code`,\n imports,\n upSQL: upSQL || ` // Migration code`,\n }),\n )\n payload.logger.info({ msg: `Migration created at ${filePath}.ts` })\n}\n"],"names":["fs","createRequire","path","getPredefinedMigration","prompts","fileURLToPath","defaultDrizzleSnapshot","getMigrationTemplate","require","url","createMigration","file","forceAcceptWarning","migrationName","payload","filename","dirname","dir","db","migrationDir","existsSync","mkdirSync","generateDrizzleJson","generateMigration","drizzleJsonAfter","schema","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","imports","downSQL","upSQL","timestamp","name","slice","join","fileName","filePath","drizzleJsonBefore","latestSnapshot","readdirSync","filter","endsWith","sort","reverse","JSON","parse","readFileSync","sqlStatementsUp","sqlStatementsDown","sqlExecute","length","confirm","shouldCreateBlankMigration","type","initial","message","onCancel","process","exit","writeFileSync","stringify","logger","info","msg"],"mappings":"AAAA,yDAAyD,GAIzD,OAAOA,QAAQ,KAAI;AACnB,SAASC,aAAa,QAAQ,SAAQ;AACtC,OAAOC,UAAU,OAAM;AACvB,SAASC,sBAAsB,QAAQ,UAAS;AAChD,OAAOC,aAAa,UAAS;AAC7B,SAASC,aAAa,QAAQ,MAAK;AAInC,SAASC,sBAAsB,QAAQ,uBAAsB;AAC7D,SAASC,oBAAoB,QAAQ,4BAA2B;AAEhE,MAAMC,UAAUP,cAAc,YAAYQ,GAAG;AAE7C,OAAO,MAAMC,kBAAmC,eAAeA,gBAE7D,EAAEC,IAAI,EAAEC,kBAAkB,EAAEC,aAAa,EAAEC,OAAO,EAAE;IAEpD,MAAMC,WAAWV,cAAc,YAAYI,GAAG;IAC9C,MAAMO,UAAUd,KAAKc,OAAO,CAACD;IAC7B,MAAME,MAAMH,QAAQI,EAAE,CAACC,YAAY;IACnC,IAAI,CAACnB,GA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QAEA,MAAMS,kBAAkB,MAAM9B,kBAAkBoB,mBAAmBnB;QACnE,MAAM8B,oBAAoB,MAAM/B,kBAAkBC,kBAAkBmB;QACpE,MAAMY,aAAa;QAEnB,IAAIF,iBAAiBG,QAAQ;YAC3BpB,QAAQ,CAAC,EAAEmB,WAAW,GAAG,EAAEF,iBAAiBb,KAAK,MAAM,GAAG,CAAC;QAC7D;QACA,IAAIc,mBAAmBE,QAAQ;YAC7BrB,UAAU,CAAC,EAAEoB,WAAW,GAAG,EAAED,mBAAmBd,KAAK,MAAM,GAAG,CAAC;QACjE;QAEA,IAAI,CAACJ,OAAOoB,UAAU,CAACrB,SAASqB,UAAU,CAAC5C,oBAAoB;YAC7D,MAAM,EAAE6C,SAASC,0BAA0B,EAAE,GAAG,MAAMtD,QACpD;gBACEkC,MAAM;gBACNqB,MAAM;gBACNC,SAAS;gBACTC,SAAS;YACX,GACA;gBACEC,UAAU;oBACRC,QAAQC,IAAI,CAAC;gBACf;YACF;YAGF,IAAI,CAACN,4BAA4B;gBAC/BK,QAAQC,IAAI,CAAC;YACf;QACF;QAEA,eAAe;QACfhE,GAAGiE,aAAa,CAAC,CAAC,EAAEvB,SAAS,KAAK,CAAC,EAAEQ,KAAKgB,SAAS,CAAC1C,kBAAkB,MAAM;IAC9E;IAEA,kBAAkB;IAClBxB,GAAGiE,aAAa,CACd,CAAC,EAAEvB,SAAS,GAAG,CAAC,EAChBnC,qBAAqB;QACnB4B,SAASA,WAAW,CAAC,mBAAmB,CAAC;QACzCD;QACAE,OAAOA,SAAS,CAAC,mBAAmB,CAAC;IACvC;IAEFtB,QAAQqD,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK,CAAC,qBAAqB,EAAE3B,SAAS,GAAG,CAAC;IAAC;AACnE,EAAC"}
@@ -0,0 +1,3 @@
1
+ import type { DrizzleSnapshotJSON } from 'drizzle-kit/payload';
2
+ export declare const defaultDrizzleSnapshot: DrizzleSnapshotJSON;
3
+ //# sourceMappingURL=defaultSnapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultSnapshot.d.ts","sourceRoot":"","sources":["../src/defaultSnapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAE9D,eAAO,MAAM,sBAAsB,EAAE,mBAapC,CAAA"}
@@ -0,0 +1,16 @@
1
+ export const defaultDrizzleSnapshot = {
2
+ id: '00000000-0000-0000-0000-000000000000',
3
+ _meta: {
4
+ columns: {},
5
+ schemas: {},
6
+ tables: {}
7
+ },
8
+ dialect: 'postgresql',
9
+ enums: {},
10
+ prevId: '00000000-0000-0000-0000-00000000000',
11
+ schemas: {},
12
+ tables: {},
13
+ version: '7'
14
+ };
15
+
16
+ //# sourceMappingURL=defaultSnapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/defaultSnapshot.ts"],"sourcesContent":["import type { DrizzleSnapshotJSON } from 'drizzle-kit/payload'\n\nexport const defaultDrizzleSnapshot: DrizzleSnapshotJSON = {\n id: '00000000-0000-0000-0000-000000000000',\n _meta: {\n columns: {},\n schemas: {},\n tables: {},\n },\n dialect: 'postgresql',\n enums: {},\n prevId: '00000000-0000-0000-0000-00000000000',\n schemas: {},\n tables: {},\n version: '7',\n}\n"],"names":["defaultDrizzleSnapshot","id","_meta","columns","schemas","tables","dialect","enums","prevId","version"],"mappings":"AAEA,OAAO,MAAMA,yBAA8C;IACzDC,IAAI;IACJC,OAAO;QACLC,SAAS,CAAC;QACVC,SAAS,CAAC;QACVC,QAAQ,CAAC;IACX;IACAC,SAAS;IACTC,OAAO,CAAC;IACRC,QAAQ;IACRJ,SAAS,CAAC;IACVC,QAAQ,CAAC;IACTI,SAAS;AACX,EAAC"}
@@ -0,0 +1,3 @@
1
+ import type { DeleteWhere } from './types.js';
2
+ export declare const deleteWhere: DeleteWhere;
3
+ //# sourceMappingURL=deleteWhere.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteWhere.d.ts","sourceRoot":"","sources":["../src/deleteWhere.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,eAAO,MAAM,WAAW,EAAE,WAMzB,CAAA"}
@@ -0,0 +1,7 @@
1
+ export const deleteWhere = async function deleteWhere({ db, tableName, where }) {
2
+ const table = this.tables[tableName];
3
+ await db.delete(table)// @ts-expect-error where is picking up libsql types
4
+ .where(where);
5
+ };
6
+
7
+ //# sourceMappingURL=deleteWhere.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/deleteWhere.ts"],"sourcesContent":["import type { TransactionPg } from '@payloadcms/drizzle/types'\n\nimport type { DeleteWhere } from './types.js'\n\nexport const deleteWhere: DeleteWhere = async function deleteWhere({ db, tableName, where }) {\n const table = this.tables[tableName]\n await (db as TransactionPg)\n .delete(table)\n // @ts-expect-error where is picking up libsql types\n .where(where)\n}\n"],"names":["deleteWhere","db","tableName","where","table","tables","delete"],"mappings":"AAIA,OAAO,MAAMA,cAA2B,eAAeA,YAAY,EAAEC,EAAE,EAAEC,SAAS,EAAEC,KAAK,EAAE;IACzF,MAAMC,QAAQ,IAAI,CAACC,MAAM,CAACH,UAAU;IACpC,MAAM,AAACD,GACJK,MAAM,CAACF,MACR,oDAAoD;KACnDD,KAAK,CAACA;AACX,EAAC"}
@@ -0,0 +1,3 @@
1
+ import type { DropDatabase } from './types.js';
2
+ export declare const dropDatabase: DropDatabase;
3
+ //# sourceMappingURL=dropDatabase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropDatabase.d.ts","sourceRoot":"","sources":["../src/dropDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,eAAO,MAAM,YAAY,EAAE,YAM1B,CAAA"}
@@ -0,0 +1,9 @@
1
+ export const dropDatabase = async function dropDatabase({ adapter }) {
2
+ await adapter.execute({
3
+ drizzle: adapter.drizzle,
4
+ raw: `drop schema if exists ${this.schemaName || 'public'} cascade;
5
+ create schema ${this.schemaName || 'public'};`
6
+ });
7
+ };
8
+
9
+ //# sourceMappingURL=dropDatabase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/dropDatabase.ts"],"sourcesContent":["import type { DropDatabase } from './types.js'\n\nexport const dropDatabase: DropDatabase = async function dropDatabase({ adapter }) {\n await adapter.execute({\n drizzle: adapter.drizzle,\n raw: `drop schema if exists ${this.schemaName || 'public'} cascade;\n create schema ${this.schemaName || 'public'};`,\n })\n}\n"],"names":["dropDatabase","adapter","execute","drizzle","raw","schemaName"],"mappings":"AAEA,OAAO,MAAMA,eAA6B,eAAeA,aAAa,EAAEC,OAAO,EAAE;IAC/E,MAAMA,QAAQC,OAAO,CAAC;QACpBC,SAASF,QAAQE,OAAO;QACxBC,KAAK,CAAC,sBAAsB,EAAE,IAAI,CAACC,UAAU,IAAI,SAAS;kBAC5C,EAAE,IAAI,CAACA,UAAU,IAAI,SAAS,CAAC,CAAC;IAChD;AACF,EAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Execute } from './types.js';
2
+ export declare const execute: Execute<any>;
3
+ //# sourceMappingURL=execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,eAAO,MAAM,OAAO,EAAE,OAAO,CAAC,GAAG,CAUhC,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { sql } from 'drizzle-orm';
2
+ export const execute = function execute({ db, drizzle, raw, sql: statement }) {
3
+ const executeFrom = db ?? drizzle;
4
+ if (raw) {
5
+ // @ts-expect-error drizzle-orm confusing libsql and pgsql types
6
+ return executeFrom.execute(sql.raw(raw));
7
+ } else {
8
+ // @ts-expect-error drizzle-orm confusing libsql and pgsql types
9
+ return executeFrom.execute(sql`${statement}`);
10
+ }
11
+ };
12
+
13
+ //# sourceMappingURL=execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/execute.ts"],"sourcesContent":["import { sql } from 'drizzle-orm'\n\nimport type { Execute } from './types.js'\n\nexport const execute: Execute<any> = function execute({ db, drizzle, raw, sql: statement }) {\n const executeFrom = db ?? drizzle\n\n if (raw) {\n // @ts-expect-error drizzle-orm confusing libsql and pgsql types\n return executeFrom.execute(sql.raw(raw))\n } else {\n // @ts-expect-error drizzle-orm confusing libsql and pgsql types\n return executeFrom.execute(sql`${statement}`)\n }\n}\n"],"names":["sql","execute","db","drizzle","raw","statement","executeFrom"],"mappings":"AAAA,SAASA,GAAG,QAAQ,cAAa;AAIjC,OAAO,MAAMC,UAAwB,SAASA,QAAQ,EAAEC,EAAE,EAAEC,OAAO,EAAEC,GAAG,EAAEJ,KAAKK,SAAS,EAAE;IACxF,MAAMC,cAAcJ,MAAMC;IAE1B,IAAIC,KAAK;QACP,gEAAgE;QAChE,OAAOE,YAAYL,OAAO,CAACD,IAAII,GAAG,CAACA;IACrC,OAAO;QACL,gEAAgE;QAChE,OAAOE,YAAYL,OAAO,CAACD,GAAG,CAAC,EAAEK,UAAU,CAAC;IAC9C;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/migration-utils.ts"],"sourcesContent":["export { migratePostgresV2toV3 } from '../predefinedMigrations/v2-v3/index.js'\n"],"names":["migratePostgresV2toV3"],"rangeMappings":"","mappings":"AAAA,SAASA,qBAAqB,QAAQ,yCAAwC"}
1
+ {"version":3,"sources":["../../src/exports/migration-utils.ts"],"sourcesContent":["export { migratePostgresV2toV3 } from '../predefinedMigrations/v2-v3/index.js'\n"],"names":["migratePostgresV2toV3"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,yCAAwC"}
@@ -0,0 +1,3 @@
1
+ import type { GenerateDrizzleJSON } from './types.js';
2
+ export declare const generateDrizzleJSON: GenerateDrizzleJSON;
3
+ //# sourceMappingURL=generateDrizzleJSON.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateDrizzleJSON.d.ts","sourceRoot":"","sources":["../src/generateDrizzleJSON.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErD,eAAO,MAAM,mBAAmB,EAAE,mBAIjC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { createRequire } from 'module';
2
+ const require = createRequire(import.meta.url);
3
+ export const generateDrizzleJSON = function generateDrizzleJSON({ schema }) {
4
+ const { generateDrizzleJson } = require('drizzle-kit/payload');
5
+ return generateDrizzleJson(schema);
6
+ };
7
+
8
+ //# sourceMappingURL=generateDrizzleJSON.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generateDrizzleJSON.ts"],"sourcesContent":["import { createRequire } from 'module'\nconst require = createRequire(import.meta.url)\n\nimport type { GenerateDrizzleJSON } from './types.js'\n\nexport const generateDrizzleJSON: GenerateDrizzleJSON = function generateDrizzleJSON({ schema }) {\n const { generateDrizzleJson } = require('drizzle-kit/payload')\n\n return generateDrizzleJson(schema)\n}\n"],"names":["createRequire","require","url","generateDrizzleJSON","schema","generateDrizzleJson"],"mappings":"AAAA,SAASA,aAAa,QAAQ,SAAQ;AACtC,MAAMC,UAAUD,cAAc,YAAYE,GAAG;AAI7C,OAAO,MAAMC,sBAA2C,SAASA,oBAAoB,EAAEC,MAAM,EAAE;IAC7F,MAAM,EAAEC,mBAAmB,EAAE,GAAGJ,QAAQ;IAExC,OAAOI,oBAAoBD;AAC7B,EAAC"}
@@ -0,0 +1,3 @@
1
+ import type { GenerateDrizzleJSON } from './types.js';
2
+ export declare const generateDrizzleJSON: GenerateDrizzleJSON;
3
+ //# sourceMappingURL=generateMigration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateMigration.d.ts","sourceRoot":"","sources":["../src/generateMigration.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErD,eAAO,MAAM,mBAAmB,EAAE,mBAIjC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { createRequire } from 'module';
2
+ const require = createRequire(import.meta.url);
3
+ export const generateDrizzleJSON = function generateDrizzleJSON({ schema }) {
4
+ const { generateDrizzleJson } = require('drizzle-kit/payload');
5
+ return generateDrizzleJson(schema);
6
+ };
7
+
8
+ //# sourceMappingURL=generateMigration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generateMigration.ts"],"sourcesContent":["import { createRequire } from 'module'\nconst require = createRequire(import.meta.url)\n\nimport type { GenerateDrizzleJSON } from './types.js'\n\nexport const generateDrizzleJSON: GenerateDrizzleJSON = function generateDrizzleJSON({ schema }) {\n const { generateDrizzleJson } = require('drizzle-kit/payload')\n\n return generateDrizzleJson(schema)\n}\n"],"names":["createRequire","require","url","generateDrizzleJSON","schema","generateDrizzleJson"],"mappings":"AAAA,SAASA,aAAa,QAAQ,SAAQ;AACtC,MAAMC,UAAUD,cAAc,YAAYE,GAAG;AAI7C,OAAO,MAAMC,sBAA2C,SAASA,oBAAoB,EAAEC,MAAM,EAAE;IAC7F,MAAM,EAAEC,mBAAmB,EAAE,GAAGJ,QAAQ;IAExC,OAAOI,oBAAoBD;AAC7B,EAAC"}
@@ -0,0 +1,3 @@
1
+ import type { MigrationTemplateArgs } from 'payload';
2
+ export declare const getMigrationTemplate: ({ downSQL, imports, upSQL, }: MigrationTemplateArgs) => string;
3
+ //# sourceMappingURL=getMigrationTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMigrationTemplate.d.ts","sourceRoot":"","sources":["../src/getMigrationTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,eAAO,MAAM,oBAAoB,iCAI9B,qBAAqB,KAAG,MAS1B,CAAA"}
@@ -0,0 +1,12 @@
1
+ export const getMigrationTemplate = ({ downSQL, imports, upSQL })=>`import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
2
+ ${imports ? `${imports}\n` : ''}
3
+ export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
4
+ ${upSQL}
5
+ }
6
+
7
+ export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
8
+ ${downSQL}
9
+ }
10
+ `;
11
+
12
+ //# sourceMappingURL=getMigrationTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/getMigrationTemplate.ts"],"sourcesContent":["import type { MigrationTemplateArgs } from 'payload'\n\nexport const getMigrationTemplate = ({\n downSQL,\n imports,\n upSQL,\n}: MigrationTemplateArgs): string => `import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'\n${imports ? `${imports}\\n` : ''}\nexport async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {\n${upSQL}\n}\n\nexport async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {\n${downSQL}\n}\n`\n"],"names":["getMigrationTemplate","downSQL","imports","upSQL"],"mappings":"AAEA,OAAO,MAAMA,uBAAuB,CAAC,EACnCC,OAAO,EACPC,OAAO,EACPC,KAAK,EACiB,GAAa,CAAC;AACtC,EAAED,UAAU,CAAC,EAAEA,QAAQ,EAAE,CAAC,GAAG,GAAG;;AAEhC,EAAEC,MAAM;;;;AAIR,EAAEF,QAAQ;;AAEV,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAW,MAAM,SAAS,CAAA;AAM1D,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAkCvD,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEhE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEjC,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAgF/E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAW,MAAM,SAAS,CAAA;AAoC1D,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAiBvD,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEhE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEjC,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAAC,eAAe,CAAC,CA+F/E"}
package/dist/index.js CHANGED
@@ -1,37 +1,19 @@
1
- import fs from 'fs';
2
- import path from 'path';
1
+ import { beginTransaction, commitTransaction, count, create, createGlobal, createGlobalVersion, createVersion, deleteMany, deleteOne, deleteVersions, destroy, find, findGlobal, findGlobalVersions, findMigrationDir, findOne, findVersions, migrate, migrateDown, migrateFresh, migrateRefresh, migrateReset, migrateStatus, operatorMap, queryDrafts, rollbackTransaction, updateGlobal, updateGlobalVersion, updateOne, updateVersion } from '@payloadcms/drizzle';
3
2
  import { createDatabaseAdapter } from 'payload';
4
3
  import { connect } from './connect.js';
5
- import { count } from './count.js';
6
- import { create } from './create.js';
7
- import { createGlobal } from './createGlobal.js';
8
- import { createGlobalVersion } from './createGlobalVersion.js';
4
+ import { countDistinct } from './countDistinct.js';
5
+ import { convertPathToJSONTraversal } from './createJSONQuery/convertPathToJSONTraversal.js';
6
+ import { createJSONQuery } from './createJSONQuery/index.js';
9
7
  import { createMigration } from './createMigration.js';
10
- import { createVersion } from './createVersion.js';
11
- import { deleteMany } from './deleteMany.js';
12
- import { deleteOne } from './deleteOne.js';
13
- import { deleteVersions } from './deleteVersions.js';
14
- import { destroy } from './destroy.js';
15
- import { find } from './find.js';
16
- import { findGlobal } from './findGlobal.js';
17
- import { findGlobalVersions } from './findGlobalVersions.js';
18
- import { findOne } from './findOne.js';
19
- import { findVersions } from './findVersions.js';
8
+ import { defaultDrizzleSnapshot } from './defaultSnapshot.js';
9
+ import { deleteWhere } from './deleteWhere.js';
10
+ import { dropDatabase } from './dropDatabase.js';
11
+ import { execute } from './execute.js';
12
+ import { generateDrizzleJSON } from './generateDrizzleJSON.js';
13
+ import { getMigrationTemplate } from './getMigrationTemplate.js';
20
14
  import { init } from './init.js';
21
- import { migrate } from './migrate.js';
22
- import { migrateDown } from './migrateDown.js';
23
- import { migrateFresh } from './migrateFresh.js';
24
- import { migrateRefresh } from './migrateRefresh.js';
25
- import { migrateReset } from './migrateReset.js';
26
- import { migrateStatus } from './migrateStatus.js';
27
- import { queryDrafts } from './queryDrafts.js';
28
- import { beginTransaction } from './transactions/beginTransaction.js';
29
- import { commitTransaction } from './transactions/commitTransaction.js';
30
- import { rollbackTransaction } from './transactions/rollbackTransaction.js';
31
- import { updateOne } from './update.js';
32
- import { updateGlobal } from './updateGlobal.js';
33
- import { updateGlobalVersion } from './updateGlobalVersion.js';
34
- import { updateVersion } from './updateVersion.js';
15
+ import { insert } from './insert.js';
16
+ import { requireDrizzleKit } from './requireDrizzleKit.js';
35
17
  export { sql } from 'drizzle-orm';
36
18
  export function postgresAdapter(args) {
37
19
  const postgresIDType = args.idType || 'serial';
@@ -46,13 +28,19 @@ export function postgresAdapter(args) {
46
28
  });
47
29
  return createDatabaseAdapter({
48
30
  name: 'postgres',
31
+ defaultDrizzleSnapshot,
49
32
  drizzle: undefined,
50
33
  enums: {},
34
+ features: {
35
+ json: true
36
+ },
51
37
  fieldConstraints: {},
38
+ getMigrationTemplate,
52
39
  idType: postgresIDType,
53
40
  initializing,
54
41
  localesSuffix: args.localesSuffix || '_locales',
55
42
  logger: args.logger,
43
+ operators: operatorMap,
56
44
  pgSchema: undefined,
57
45
  pool: undefined,
58
46
  poolOptions: args.pool,
@@ -69,23 +57,31 @@ export function postgresAdapter(args) {
69
57
  beginTransaction,
70
58
  commitTransaction,
71
59
  connect,
60
+ convertPathToJSONTraversal,
72
61
  count,
62
+ countDistinct,
73
63
  create,
74
64
  createGlobal,
75
65
  createGlobalVersion,
66
+ createJSONQuery,
76
67
  createMigration,
77
68
  createVersion,
78
69
  defaultIDType: payloadIDType,
79
70
  deleteMany,
80
71
  deleteOne,
81
72
  deleteVersions,
73
+ deleteWhere,
82
74
  destroy,
75
+ dropDatabase,
76
+ execute,
83
77
  find,
84
78
  findGlobal,
85
79
  findGlobalVersions,
86
80
  findOne,
87
81
  findVersions,
82
+ generateDrizzleJSON,
88
83
  init,
84
+ insert,
89
85
  migrate,
90
86
  migrateDown,
91
87
  migrateFresh,
@@ -96,6 +92,7 @@ export function postgresAdapter(args) {
96
92
  payload,
97
93
  queryDrafts,
98
94
  rejectInitializing,
95
+ requireDrizzleKit,
99
96
  resolveInitializing,
100
97
  rollbackTransaction,
101
98
  updateGlobal,
@@ -109,37 +106,5 @@ export function postgresAdapter(args) {
109
106
  init: adapter
110
107
  };
111
108
  }
112
- /**
113
- * Attempt to find migrations directory.
114
- *
115
- * Checks for the following directories in order:
116
- * - `migrationDir` argument from Payload config
117
- * - `src/migrations`
118
- * - `dist/migrations`
119
- * - `migrations`
120
- *
121
- * Defaults to `src/migrations`
122
- *
123
- * @param migrationDir
124
- * @returns
125
- */ function findMigrationDir(migrationDir) {
126
- const cwd = process.cwd();
127
- const srcDir = path.resolve(cwd, 'src/migrations');
128
- const distDir = path.resolve(cwd, 'dist/migrations');
129
- const relativeMigrations = path.resolve(cwd, 'migrations');
130
- // Use arg if provided
131
- if (migrationDir) return migrationDir;
132
- // Check other common locations
133
- if (fs.existsSync(srcDir)) {
134
- return srcDir;
135
- }
136
- if (fs.existsSync(distDir)) {
137
- return distDir;
138
- }
139
- if (fs.existsSync(relativeMigrations)) {
140
- return relativeMigrations;
141
- }
142
- return srcDir;
143
- }
144
109
 
145
110
  //# sourceMappingURL=index.js.map