@contember/database 1.4.0-rc.8 → 2.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (620) hide show
  1. package/dist/development/index.cjs +102 -0
  2. package/dist/development/index.cjs.map +1 -0
  3. package/dist/development/index.js +90 -0
  4. package/dist/development/index.js.map +1 -0
  5. package/dist/development/src/Literal.cjs +37 -0
  6. package/dist/development/src/Literal.cjs.map +1 -0
  7. package/dist/development/src/Literal.js +37 -0
  8. package/dist/development/src/Literal.js.map +1 -0
  9. package/dist/development/src/builders/CaseStatement.cjs +46 -0
  10. package/dist/development/src/builders/CaseStatement.cjs.map +1 -0
  11. package/dist/development/src/builders/CaseStatement.js +46 -0
  12. package/dist/development/src/builders/CaseStatement.js.map +1 -0
  13. package/dist/development/src/builders/ColumnExpressionFactory.cjs +33 -0
  14. package/dist/development/src/builders/ColumnExpressionFactory.cjs.map +1 -0
  15. package/dist/development/src/builders/ColumnExpressionFactory.js +33 -0
  16. package/dist/development/src/builders/ColumnExpressionFactory.js.map +1 -0
  17. package/dist/development/src/builders/Compiler.cjs +217 -0
  18. package/dist/development/src/builders/Compiler.cjs.map +1 -0
  19. package/dist/development/src/builders/Compiler.js +217 -0
  20. package/dist/development/src/builders/Compiler.js.map +1 -0
  21. package/dist/development/src/builders/ConditionBuilder.cjs +156 -0
  22. package/dist/development/src/builders/ConditionBuilder.cjs.map +1 -0
  23. package/dist/development/src/builders/ConditionBuilder.js +156 -0
  24. package/dist/development/src/builders/ConditionBuilder.js.map +1 -0
  25. package/dist/development/src/builders/ConflictActionType.cjs +9 -0
  26. package/dist/development/src/builders/ConflictActionType.cjs.map +1 -0
  27. package/dist/development/src/builders/ConflictActionType.js +9 -0
  28. package/dist/development/src/builders/ConflictActionType.js.map +1 -0
  29. package/dist/development/src/builders/DeleteBuilder.cjs +54 -0
  30. package/dist/development/src/builders/DeleteBuilder.cjs.map +1 -0
  31. package/dist/development/src/builders/DeleteBuilder.js +54 -0
  32. package/dist/development/src/builders/DeleteBuilder.js.map +1 -0
  33. package/dist/development/src/builders/InsertBuilder.cjs +106 -0
  34. package/dist/development/src/builders/InsertBuilder.cjs.map +1 -0
  35. package/dist/development/src/builders/InsertBuilder.js +106 -0
  36. package/dist/development/src/builders/InsertBuilder.js.map +1 -0
  37. package/dist/development/src/builders/LimitByGroupWrapper.cjs +37 -0
  38. package/dist/development/src/builders/LimitByGroupWrapper.cjs.map +1 -0
  39. package/dist/development/src/builders/LimitByGroupWrapper.js +37 -0
  40. package/dist/development/src/builders/LimitByGroupWrapper.js.map +1 -0
  41. package/dist/development/src/builders/LockType.cjs +17 -0
  42. package/dist/development/src/builders/LockType.cjs.map +1 -0
  43. package/dist/development/src/builders/LockType.js +17 -0
  44. package/dist/development/src/builders/LockType.js.map +1 -0
  45. package/dist/development/src/builders/SelectBuilder.cjs +143 -0
  46. package/dist/development/src/builders/SelectBuilder.cjs.map +1 -0
  47. package/dist/development/src/builders/SelectBuilder.js +143 -0
  48. package/dist/development/src/builders/SelectBuilder.js.map +1 -0
  49. package/dist/development/src/builders/UpdateBuilder.cjs +82 -0
  50. package/dist/development/src/builders/UpdateBuilder.cjs.map +1 -0
  51. package/dist/development/src/builders/UpdateBuilder.js +82 -0
  52. package/dist/development/src/builders/UpdateBuilder.js.map +1 -0
  53. package/dist/development/src/builders/WindowFunction.cjs +50 -0
  54. package/dist/development/src/builders/WindowFunction.cjs.map +1 -0
  55. package/dist/development/src/builders/WindowFunction.js +50 -0
  56. package/dist/development/src/builders/WindowFunction.js.map +1 -0
  57. package/dist/development/src/builders/formatUtils.cjs +23 -0
  58. package/dist/development/src/builders/formatUtils.cjs.map +1 -0
  59. package/dist/development/src/builders/formatUtils.js +23 -0
  60. package/dist/development/src/builders/formatUtils.js.map +1 -0
  61. package/dist/development/src/builders/internal/Returning.cjs +26 -0
  62. package/dist/development/src/builders/internal/Returning.cjs.map +1 -0
  63. package/dist/development/src/builders/internal/Returning.js +26 -0
  64. package/dist/development/src/builders/internal/Returning.js.map +1 -0
  65. package/dist/development/src/builders/internal/Subqueries.cjs +15 -0
  66. package/dist/development/src/builders/internal/Subqueries.cjs.map +1 -0
  67. package/dist/development/src/builders/internal/Subqueries.js +15 -0
  68. package/dist/development/src/builders/internal/Subqueries.js.map +1 -0
  69. package/dist/development/src/builders/internal/Where.cjs +53 -0
  70. package/dist/development/src/builders/internal/Where.cjs.map +1 -0
  71. package/dist/development/src/builders/internal/Where.js +54 -0
  72. package/dist/development/src/builders/internal/Where.js.map +1 -0
  73. package/dist/development/src/builders/internal/With.cjs +52 -0
  74. package/dist/development/src/builders/internal/With.cjs.map +1 -0
  75. package/dist/development/src/builders/internal/With.js +53 -0
  76. package/dist/development/src/builders/internal/With.js.map +1 -0
  77. package/dist/development/src/builders/utils.cjs +26 -0
  78. package/dist/development/src/builders/utils.cjs.map +1 -0
  79. package/dist/development/src/builders/utils.js +26 -0
  80. package/dist/development/src/builders/utils.js.map +1 -0
  81. package/dist/development/src/client/AcquiredConnection.cjs +91 -0
  82. package/dist/development/src/client/AcquiredConnection.cjs.map +1 -0
  83. package/dist/development/src/client/AcquiredConnection.js +91 -0
  84. package/dist/development/src/client/AcquiredConnection.js.map +1 -0
  85. package/dist/development/src/client/Client.cjs +89 -0
  86. package/dist/development/src/client/Client.cjs.map +1 -0
  87. package/dist/development/src/client/Client.js +89 -0
  88. package/dist/development/src/client/Client.js.map +1 -0
  89. package/dist/development/src/client/Connection.cjs +62 -0
  90. package/dist/development/src/client/Connection.cjs.map +1 -0
  91. package/dist/development/src/client/Connection.js +62 -0
  92. package/dist/development/src/client/Connection.js.map +1 -0
  93. package/dist/development/src/client/EventManager.cjs +38 -0
  94. package/dist/development/src/client/EventManager.cjs.map +1 -0
  95. package/dist/development/src/client/EventManager.js +38 -0
  96. package/dist/development/src/client/EventManager.js.map +1 -0
  97. package/dist/development/src/client/Pool.cjs +380 -0
  98. package/dist/development/src/client/Pool.cjs.map +1 -0
  99. package/dist/development/src/client/Pool.js +380 -0
  100. package/dist/development/src/client/Pool.js.map +1 -0
  101. package/dist/development/src/client/Transaction.cjs +143 -0
  102. package/dist/development/src/client/Transaction.cjs.map +1 -0
  103. package/dist/development/src/client/Transaction.js +143 -0
  104. package/dist/development/src/client/Transaction.js.map +1 -0
  105. package/dist/development/src/client/errorCodes.cjs +266 -0
  106. package/dist/development/src/client/errorCodes.cjs.map +1 -0
  107. package/dist/development/src/client/errorCodes.js +266 -0
  108. package/dist/development/src/client/errorCodes.js.map +1 -0
  109. package/dist/development/src/client/errors.cjs +65 -0
  110. package/dist/development/src/client/errors.cjs.map +1 -0
  111. package/dist/development/src/client/errors.js +65 -0
  112. package/dist/development/src/client/errors.js.map +1 -0
  113. package/dist/development/src/exceptions.cjs +6 -0
  114. package/dist/development/src/exceptions.cjs.map +1 -0
  115. package/dist/development/src/exceptions.js +6 -0
  116. package/dist/development/src/exceptions.js.map +1 -0
  117. package/dist/development/src/metadata/DatabaseMetadata.cjs +18 -0
  118. package/dist/development/src/metadata/DatabaseMetadata.cjs.map +1 -0
  119. package/dist/development/src/metadata/DatabaseMetadata.js +18 -0
  120. package/dist/development/src/metadata/DatabaseMetadata.js.map +1 -0
  121. package/dist/{src/metadata/DatabaseMetadataResolver.js → development/src/metadata/DatabaseMetadataResolver.cjs} +49 -59
  122. package/dist/development/src/metadata/DatabaseMetadataResolver.cjs.map +1 -0
  123. package/dist/development/src/metadata/DatabaseMetadataResolver.js +96 -0
  124. package/dist/development/src/metadata/DatabaseMetadataResolver.js.map +1 -0
  125. package/dist/development/src/metadata/ForeignKeyConstraintMetadata.cjs +56 -0
  126. package/dist/development/src/metadata/ForeignKeyConstraintMetadata.cjs.map +1 -0
  127. package/dist/development/src/metadata/ForeignKeyConstraintMetadata.js +56 -0
  128. package/dist/development/src/metadata/ForeignKeyConstraintMetadata.js.map +1 -0
  129. package/dist/development/src/metadata/IndexMetadata.cjs +30 -0
  130. package/dist/development/src/metadata/IndexMetadata.cjs.map +1 -0
  131. package/dist/development/src/metadata/IndexMetadata.js +30 -0
  132. package/dist/development/src/metadata/IndexMetadata.js.map +1 -0
  133. package/dist/development/src/metadata/UniqueConstraintMetadata.cjs +39 -0
  134. package/dist/development/src/metadata/UniqueConstraintMetadata.cjs.map +1 -0
  135. package/dist/development/src/metadata/UniqueConstraintMetadata.js +39 -0
  136. package/dist/development/src/metadata/UniqueConstraintMetadata.js.map +1 -0
  137. package/dist/development/src/metadata/stringArrayEquals.cjs +12 -0
  138. package/dist/development/src/metadata/stringArrayEquals.cjs.map +1 -0
  139. package/dist/development/src/metadata/stringArrayEquals.js +12 -0
  140. package/dist/development/src/metadata/stringArrayEquals.js.map +1 -0
  141. package/dist/development/src/queryable/DatabaseQuery.cjs +16 -0
  142. package/dist/development/src/queryable/DatabaseQuery.cjs.map +1 -0
  143. package/dist/development/src/queryable/DatabaseQuery.js +16 -0
  144. package/dist/development/src/queryable/DatabaseQuery.js.map +1 -0
  145. package/dist/development/src/queryable/DatabaseQueryable.cjs +13 -0
  146. package/dist/development/src/queryable/DatabaseQueryable.cjs.map +1 -0
  147. package/dist/development/src/queryable/DatabaseQueryable.js +13 -0
  148. package/dist/development/src/queryable/DatabaseQueryable.js.map +1 -0
  149. package/dist/development/src/utils/ConstraintHelper.cjs +44 -0
  150. package/dist/development/src/utils/ConstraintHelper.cjs.map +1 -0
  151. package/dist/development/src/utils/ConstraintHelper.js +44 -0
  152. package/dist/development/src/utils/ConstraintHelper.js.map +1 -0
  153. package/dist/development/src/utils/Mutex.cjs +49 -0
  154. package/dist/development/src/utils/Mutex.cjs.map +1 -0
  155. package/dist/development/src/utils/Mutex.js +49 -0
  156. package/dist/development/src/utils/Mutex.js.map +1 -0
  157. package/dist/development/src/utils/assertNever.cjs +7 -0
  158. package/dist/development/src/utils/assertNever.cjs.map +1 -0
  159. package/dist/development/src/utils/assertNever.js +7 -0
  160. package/dist/development/src/utils/assertNever.js.map +1 -0
  161. package/dist/development/src/utils/asyncIterableTransaction.cjs +26 -0
  162. package/dist/development/src/utils/asyncIterableTransaction.cjs.map +1 -0
  163. package/dist/development/src/utils/asyncIterableTransaction.js +26 -0
  164. package/dist/development/src/utils/asyncIterableTransaction.js.map +1 -0
  165. package/dist/development/src/utils/createDatabaseIfNotExists.cjs +34 -0
  166. package/dist/development/src/utils/createDatabaseIfNotExists.cjs.map +1 -0
  167. package/dist/development/src/utils/createDatabaseIfNotExists.js +34 -0
  168. package/dist/development/src/utils/createDatabaseIfNotExists.js.map +1 -0
  169. package/dist/development/src/utils/listen.cjs +118 -0
  170. package/dist/development/src/utils/listen.cjs.map +1 -0
  171. package/dist/development/src/utils/listen.js +118 -0
  172. package/dist/development/src/utils/listen.js.map +1 -0
  173. package/dist/{src/utils/pgClientFactory.js → development/src/utils/pgClientFactory.cjs} +8 -7
  174. package/dist/development/src/utils/pgClientFactory.cjs.map +1 -0
  175. package/dist/development/src/utils/pgClientFactory.js +13 -0
  176. package/dist/development/src/utils/pgClientFactory.js.map +1 -0
  177. package/dist/development/src/utils/retryTransaction.cjs +49 -0
  178. package/dist/development/src/utils/retryTransaction.cjs.map +1 -0
  179. package/dist/development/src/utils/retryTransaction.js +49 -0
  180. package/dist/development/src/utils/retryTransaction.js.map +1 -0
  181. package/dist/development/src/utils/sql.cjs +22 -0
  182. package/dist/development/src/utils/sql.cjs.map +1 -0
  183. package/dist/development/src/utils/sql.js +22 -0
  184. package/dist/development/src/utils/sql.js.map +1 -0
  185. package/dist/development/src/utils/withDatabaseAdvisoryLock.cjs +15 -0
  186. package/dist/development/src/utils/withDatabaseAdvisoryLock.cjs.map +1 -0
  187. package/dist/development/src/utils/withDatabaseAdvisoryLock.js +15 -0
  188. package/dist/development/src/utils/withDatabaseAdvisoryLock.js.map +1 -0
  189. package/dist/production/index.cjs +102 -0
  190. package/dist/production/index.cjs.map +1 -0
  191. package/dist/production/index.js +90 -0
  192. package/dist/production/index.js.map +1 -0
  193. package/dist/production/src/Literal.cjs +37 -0
  194. package/dist/production/src/Literal.cjs.map +1 -0
  195. package/dist/production/src/Literal.js +37 -0
  196. package/dist/production/src/Literal.js.map +1 -0
  197. package/dist/production/src/builders/CaseStatement.cjs +46 -0
  198. package/dist/production/src/builders/CaseStatement.cjs.map +1 -0
  199. package/dist/production/src/builders/CaseStatement.js +46 -0
  200. package/dist/production/src/builders/CaseStatement.js.map +1 -0
  201. package/dist/production/src/builders/ColumnExpressionFactory.cjs +33 -0
  202. package/dist/production/src/builders/ColumnExpressionFactory.cjs.map +1 -0
  203. package/dist/production/src/builders/ColumnExpressionFactory.js +33 -0
  204. package/dist/production/src/builders/ColumnExpressionFactory.js.map +1 -0
  205. package/dist/production/src/builders/Compiler.cjs +217 -0
  206. package/dist/production/src/builders/Compiler.cjs.map +1 -0
  207. package/dist/production/src/builders/Compiler.js +217 -0
  208. package/dist/production/src/builders/Compiler.js.map +1 -0
  209. package/dist/production/src/builders/ConditionBuilder.cjs +156 -0
  210. package/dist/production/src/builders/ConditionBuilder.cjs.map +1 -0
  211. package/dist/production/src/builders/ConditionBuilder.js +156 -0
  212. package/dist/production/src/builders/ConditionBuilder.js.map +1 -0
  213. package/dist/production/src/builders/ConflictActionType.cjs +9 -0
  214. package/dist/production/src/builders/ConflictActionType.cjs.map +1 -0
  215. package/dist/production/src/builders/ConflictActionType.js +9 -0
  216. package/dist/production/src/builders/ConflictActionType.js.map +1 -0
  217. package/dist/production/src/builders/DeleteBuilder.cjs +54 -0
  218. package/dist/production/src/builders/DeleteBuilder.cjs.map +1 -0
  219. package/dist/production/src/builders/DeleteBuilder.js +54 -0
  220. package/dist/production/src/builders/DeleteBuilder.js.map +1 -0
  221. package/dist/production/src/builders/InsertBuilder.cjs +106 -0
  222. package/dist/production/src/builders/InsertBuilder.cjs.map +1 -0
  223. package/dist/production/src/builders/InsertBuilder.js +106 -0
  224. package/dist/production/src/builders/InsertBuilder.js.map +1 -0
  225. package/dist/production/src/builders/LimitByGroupWrapper.cjs +37 -0
  226. package/dist/production/src/builders/LimitByGroupWrapper.cjs.map +1 -0
  227. package/dist/production/src/builders/LimitByGroupWrapper.js +37 -0
  228. package/dist/production/src/builders/LimitByGroupWrapper.js.map +1 -0
  229. package/dist/production/src/builders/LockType.cjs +17 -0
  230. package/dist/production/src/builders/LockType.cjs.map +1 -0
  231. package/dist/production/src/builders/LockType.js +17 -0
  232. package/dist/production/src/builders/LockType.js.map +1 -0
  233. package/dist/production/src/builders/SelectBuilder.cjs +143 -0
  234. package/dist/production/src/builders/SelectBuilder.cjs.map +1 -0
  235. package/dist/production/src/builders/SelectBuilder.js +143 -0
  236. package/dist/production/src/builders/SelectBuilder.js.map +1 -0
  237. package/dist/production/src/builders/UpdateBuilder.cjs +82 -0
  238. package/dist/production/src/builders/UpdateBuilder.cjs.map +1 -0
  239. package/dist/production/src/builders/UpdateBuilder.js +82 -0
  240. package/dist/production/src/builders/UpdateBuilder.js.map +1 -0
  241. package/dist/production/src/builders/WindowFunction.cjs +50 -0
  242. package/dist/production/src/builders/WindowFunction.cjs.map +1 -0
  243. package/dist/production/src/builders/WindowFunction.js +50 -0
  244. package/dist/production/src/builders/WindowFunction.js.map +1 -0
  245. package/dist/production/src/builders/formatUtils.cjs +23 -0
  246. package/dist/production/src/builders/formatUtils.cjs.map +1 -0
  247. package/dist/production/src/builders/formatUtils.js +23 -0
  248. package/dist/production/src/builders/formatUtils.js.map +1 -0
  249. package/dist/production/src/builders/internal/Returning.cjs +26 -0
  250. package/dist/production/src/builders/internal/Returning.cjs.map +1 -0
  251. package/dist/production/src/builders/internal/Returning.js +26 -0
  252. package/dist/production/src/builders/internal/Returning.js.map +1 -0
  253. package/dist/production/src/builders/internal/Subqueries.cjs +15 -0
  254. package/dist/production/src/builders/internal/Subqueries.cjs.map +1 -0
  255. package/dist/production/src/builders/internal/Subqueries.js +15 -0
  256. package/dist/production/src/builders/internal/Subqueries.js.map +1 -0
  257. package/dist/production/src/builders/internal/Where.cjs +53 -0
  258. package/dist/production/src/builders/internal/Where.cjs.map +1 -0
  259. package/dist/production/src/builders/internal/Where.js +54 -0
  260. package/dist/production/src/builders/internal/Where.js.map +1 -0
  261. package/dist/production/src/builders/internal/With.cjs +52 -0
  262. package/dist/production/src/builders/internal/With.cjs.map +1 -0
  263. package/dist/production/src/builders/internal/With.js +53 -0
  264. package/dist/production/src/builders/internal/With.js.map +1 -0
  265. package/dist/production/src/builders/utils.cjs +26 -0
  266. package/dist/production/src/builders/utils.cjs.map +1 -0
  267. package/dist/production/src/builders/utils.js +26 -0
  268. package/dist/production/src/builders/utils.js.map +1 -0
  269. package/dist/production/src/client/AcquiredConnection.cjs +91 -0
  270. package/dist/production/src/client/AcquiredConnection.cjs.map +1 -0
  271. package/dist/production/src/client/AcquiredConnection.js +91 -0
  272. package/dist/production/src/client/AcquiredConnection.js.map +1 -0
  273. package/dist/production/src/client/Client.cjs +89 -0
  274. package/dist/production/src/client/Client.cjs.map +1 -0
  275. package/dist/production/src/client/Client.js +89 -0
  276. package/dist/production/src/client/Client.js.map +1 -0
  277. package/dist/production/src/client/Connection.cjs +62 -0
  278. package/dist/production/src/client/Connection.cjs.map +1 -0
  279. package/dist/production/src/client/Connection.js +62 -0
  280. package/dist/production/src/client/Connection.js.map +1 -0
  281. package/dist/production/src/client/EventManager.cjs +38 -0
  282. package/dist/production/src/client/EventManager.cjs.map +1 -0
  283. package/dist/production/src/client/EventManager.js +38 -0
  284. package/dist/production/src/client/EventManager.js.map +1 -0
  285. package/dist/production/src/client/Pool.cjs +380 -0
  286. package/dist/production/src/client/Pool.cjs.map +1 -0
  287. package/dist/production/src/client/Pool.js +380 -0
  288. package/dist/production/src/client/Pool.js.map +1 -0
  289. package/dist/production/src/client/Transaction.cjs +143 -0
  290. package/dist/production/src/client/Transaction.cjs.map +1 -0
  291. package/dist/production/src/client/Transaction.js +143 -0
  292. package/dist/production/src/client/Transaction.js.map +1 -0
  293. package/dist/production/src/client/errorCodes.cjs +266 -0
  294. package/dist/production/src/client/errorCodes.cjs.map +1 -0
  295. package/dist/production/src/client/errorCodes.js +266 -0
  296. package/dist/production/src/client/errorCodes.js.map +1 -0
  297. package/dist/production/src/client/errors.cjs +65 -0
  298. package/dist/production/src/client/errors.cjs.map +1 -0
  299. package/dist/production/src/client/errors.js +65 -0
  300. package/dist/production/src/client/errors.js.map +1 -0
  301. package/dist/production/src/exceptions.cjs +6 -0
  302. package/dist/production/src/exceptions.cjs.map +1 -0
  303. package/dist/production/src/exceptions.js +6 -0
  304. package/dist/production/src/exceptions.js.map +1 -0
  305. package/dist/production/src/metadata/DatabaseMetadata.cjs +18 -0
  306. package/dist/production/src/metadata/DatabaseMetadata.cjs.map +1 -0
  307. package/dist/production/src/metadata/DatabaseMetadata.js +18 -0
  308. package/dist/production/src/metadata/DatabaseMetadata.js.map +1 -0
  309. package/dist/production/src/metadata/DatabaseMetadataResolver.cjs +96 -0
  310. package/dist/production/src/metadata/DatabaseMetadataResolver.cjs.map +1 -0
  311. package/dist/production/src/metadata/DatabaseMetadataResolver.js +96 -0
  312. package/dist/production/src/metadata/DatabaseMetadataResolver.js.map +1 -0
  313. package/dist/production/src/metadata/ForeignKeyConstraintMetadata.cjs +56 -0
  314. package/dist/production/src/metadata/ForeignKeyConstraintMetadata.cjs.map +1 -0
  315. package/dist/production/src/metadata/ForeignKeyConstraintMetadata.js +56 -0
  316. package/dist/production/src/metadata/ForeignKeyConstraintMetadata.js.map +1 -0
  317. package/dist/production/src/metadata/IndexMetadata.cjs +30 -0
  318. package/dist/production/src/metadata/IndexMetadata.cjs.map +1 -0
  319. package/dist/production/src/metadata/IndexMetadata.js +30 -0
  320. package/dist/production/src/metadata/IndexMetadata.js.map +1 -0
  321. package/dist/production/src/metadata/UniqueConstraintMetadata.cjs +39 -0
  322. package/dist/production/src/metadata/UniqueConstraintMetadata.cjs.map +1 -0
  323. package/dist/production/src/metadata/UniqueConstraintMetadata.js +39 -0
  324. package/dist/production/src/metadata/UniqueConstraintMetadata.js.map +1 -0
  325. package/dist/production/src/metadata/stringArrayEquals.cjs +12 -0
  326. package/dist/production/src/metadata/stringArrayEquals.cjs.map +1 -0
  327. package/dist/production/src/metadata/stringArrayEquals.js +12 -0
  328. package/dist/production/src/metadata/stringArrayEquals.js.map +1 -0
  329. package/dist/production/src/queryable/DatabaseQuery.cjs +16 -0
  330. package/dist/production/src/queryable/DatabaseQuery.cjs.map +1 -0
  331. package/dist/production/src/queryable/DatabaseQuery.js +16 -0
  332. package/dist/production/src/queryable/DatabaseQuery.js.map +1 -0
  333. package/dist/production/src/queryable/DatabaseQueryable.cjs +13 -0
  334. package/dist/production/src/queryable/DatabaseQueryable.cjs.map +1 -0
  335. package/dist/production/src/queryable/DatabaseQueryable.js +13 -0
  336. package/dist/production/src/queryable/DatabaseQueryable.js.map +1 -0
  337. package/dist/production/src/utils/ConstraintHelper.cjs +44 -0
  338. package/dist/production/src/utils/ConstraintHelper.cjs.map +1 -0
  339. package/dist/production/src/utils/ConstraintHelper.js +44 -0
  340. package/dist/production/src/utils/ConstraintHelper.js.map +1 -0
  341. package/dist/production/src/utils/Mutex.cjs +49 -0
  342. package/dist/production/src/utils/Mutex.cjs.map +1 -0
  343. package/dist/production/src/utils/Mutex.js +49 -0
  344. package/dist/production/src/utils/Mutex.js.map +1 -0
  345. package/dist/production/src/utils/assertNever.cjs +7 -0
  346. package/dist/production/src/utils/assertNever.cjs.map +1 -0
  347. package/dist/production/src/utils/assertNever.js +7 -0
  348. package/dist/production/src/utils/assertNever.js.map +1 -0
  349. package/dist/production/src/utils/asyncIterableTransaction.cjs +26 -0
  350. package/dist/production/src/utils/asyncIterableTransaction.cjs.map +1 -0
  351. package/dist/production/src/utils/asyncIterableTransaction.js +26 -0
  352. package/dist/production/src/utils/asyncIterableTransaction.js.map +1 -0
  353. package/dist/production/src/utils/createDatabaseIfNotExists.cjs +34 -0
  354. package/dist/production/src/utils/createDatabaseIfNotExists.cjs.map +1 -0
  355. package/dist/production/src/utils/createDatabaseIfNotExists.js +34 -0
  356. package/dist/production/src/utils/createDatabaseIfNotExists.js.map +1 -0
  357. package/dist/production/src/utils/listen.cjs +118 -0
  358. package/dist/production/src/utils/listen.cjs.map +1 -0
  359. package/dist/production/src/utils/listen.js +118 -0
  360. package/dist/production/src/utils/listen.js.map +1 -0
  361. package/dist/production/src/utils/pgClientFactory.cjs +13 -0
  362. package/dist/production/src/utils/pgClientFactory.cjs.map +1 -0
  363. package/dist/production/src/utils/pgClientFactory.js +13 -0
  364. package/dist/production/src/utils/pgClientFactory.js.map +1 -0
  365. package/dist/production/src/utils/retryTransaction.cjs +49 -0
  366. package/dist/production/src/utils/retryTransaction.cjs.map +1 -0
  367. package/dist/production/src/utils/retryTransaction.js +49 -0
  368. package/dist/production/src/utils/retryTransaction.js.map +1 -0
  369. package/dist/production/src/utils/sql.cjs +22 -0
  370. package/dist/production/src/utils/sql.cjs.map +1 -0
  371. package/dist/production/src/utils/sql.js +22 -0
  372. package/dist/production/src/utils/sql.js.map +1 -0
  373. package/dist/production/src/utils/withDatabaseAdvisoryLock.cjs +15 -0
  374. package/dist/production/src/utils/withDatabaseAdvisoryLock.cjs.map +1 -0
  375. package/dist/production/src/utils/withDatabaseAdvisoryLock.js +15 -0
  376. package/dist/production/src/utils/withDatabaseAdvisoryLock.js.map +1 -0
  377. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  378. package/dist/{src → types}/builders/QueryBuilder.d.ts +1 -1
  379. package/dist/{src → types}/builders/QueryBuilder.d.ts.map +1 -1
  380. package/dist/{src → types}/client/Pool.d.ts +0 -1
  381. package/dist/types/client/Pool.d.ts.map +1 -0
  382. package/dist/{src → types}/client/Transaction.d.ts +1 -1
  383. package/dist/{src → types}/client/Transaction.d.ts.map +1 -1
  384. package/dist/{src → types}/client/errors.d.ts +0 -2
  385. package/dist/{src → types}/client/errors.d.ts.map +1 -1
  386. package/dist/types/tsconfig.tsbuildinfo +1 -0
  387. package/dist/{src → types}/types.d.ts +0 -1
  388. package/dist/types/types.d.ts.map +1 -0
  389. package/dist/{src → types}/utils/createDatabaseIfNotExists.d.ts.map +1 -1
  390. package/dist/{src → types}/utils/pgClientFactory.d.ts +2 -2
  391. package/dist/types/utils/pgClientFactory.d.ts.map +1 -0
  392. package/dist/types/utils/retryTransaction.d.ts +7 -0
  393. package/dist/{src → types}/utils/retryTransaction.d.ts.map +1 -1
  394. package/dist/{src → types}/utils/sql.d.ts.map +1 -1
  395. package/dist/{src → types}/utils/withDatabaseAdvisoryLock.d.ts.map +1 -1
  396. package/package.json +23 -11
  397. package/src/builders/QueryBuilder.ts +1 -1
  398. package/src/client/errors.ts +1 -3
  399. package/src/tsconfig.json +1 -1
  400. package/src/utils/pgClientFactory.ts +9 -7
  401. package/vitest.config.ts +3 -0
  402. package/dist/src/Literal.js +0 -34
  403. package/dist/src/Literal.js.map +0 -1
  404. package/dist/src/builders/CaseStatement.js +0 -47
  405. package/dist/src/builders/CaseStatement.js.map +0 -1
  406. package/dist/src/builders/ColumnExpressionFactory.js +0 -33
  407. package/dist/src/builders/ColumnExpressionFactory.js.map +0 -1
  408. package/dist/src/builders/Compiler.js +0 -215
  409. package/dist/src/builders/Compiler.js.map +0 -1
  410. package/dist/src/builders/ConditionBuilder.js +0 -156
  411. package/dist/src/builders/ConditionBuilder.js.map +0 -1
  412. package/dist/src/builders/ConflictActionType.js +0 -9
  413. package/dist/src/builders/ConflictActionType.js.map +0 -1
  414. package/dist/src/builders/DeleteBuilder.js +0 -55
  415. package/dist/src/builders/DeleteBuilder.js.map +0 -1
  416. package/dist/src/builders/InsertBuilder.js +0 -109
  417. package/dist/src/builders/InsertBuilder.js.map +0 -1
  418. package/dist/src/builders/LimitByGroupWrapper.js +0 -43
  419. package/dist/src/builders/LimitByGroupWrapper.js.map +0 -1
  420. package/dist/src/builders/LockType.js +0 -16
  421. package/dist/src/builders/LockType.js.map +0 -1
  422. package/dist/src/builders/QueryBuilder.js +0 -3
  423. package/dist/src/builders/QueryBuilder.js.map +0 -1
  424. package/dist/src/builders/SelectBuilder.js +0 -134
  425. package/dist/src/builders/SelectBuilder.js.map +0 -1
  426. package/dist/src/builders/UpdateBuilder.js +0 -84
  427. package/dist/src/builders/UpdateBuilder.js.map +0 -1
  428. package/dist/src/builders/WindowFunction.js +0 -50
  429. package/dist/src/builders/WindowFunction.js.map +0 -1
  430. package/dist/src/builders/formatUtils.js +0 -20
  431. package/dist/src/builders/formatUtils.js.map +0 -1
  432. package/dist/src/builders/index.js +0 -29
  433. package/dist/src/builders/index.js.map +0 -1
  434. package/dist/src/builders/internal/Returning.js +0 -25
  435. package/dist/src/builders/internal/Returning.js.map +0 -1
  436. package/dist/src/builders/internal/Subqueries.js +0 -18
  437. package/dist/src/builders/internal/Subqueries.js.map +0 -1
  438. package/dist/src/builders/internal/Where.js +0 -39
  439. package/dist/src/builders/internal/Where.js.map +0 -1
  440. package/dist/src/builders/internal/With.js +0 -41
  441. package/dist/src/builders/internal/With.js.map +0 -1
  442. package/dist/src/builders/utils.js +0 -30
  443. package/dist/src/builders/utils.js.map +0 -1
  444. package/dist/src/client/AcquiredConnection.js +0 -82
  445. package/dist/src/client/AcquiredConnection.js.map +0 -1
  446. package/dist/src/client/Client.js +0 -54
  447. package/dist/src/client/Client.js.map +0 -1
  448. package/dist/src/client/Connection.js +0 -62
  449. package/dist/src/client/Connection.js.map +0 -1
  450. package/dist/src/client/EventManager.js +0 -35
  451. package/dist/src/client/EventManager.js.map +0 -1
  452. package/dist/src/client/PgClient.js +0 -3
  453. package/dist/src/client/PgClient.js.map +0 -1
  454. package/dist/src/client/Pool.d.ts.map +0 -1
  455. package/dist/src/client/Pool.js +0 -404
  456. package/dist/src/client/Pool.js.map +0 -1
  457. package/dist/src/client/Transaction.js +0 -129
  458. package/dist/src/client/Transaction.js.map +0 -1
  459. package/dist/src/client/errorCodes.js +0 -266
  460. package/dist/src/client/errorCodes.js.map +0 -1
  461. package/dist/src/client/errors.js +0 -55
  462. package/dist/src/client/errors.js.map +0 -1
  463. package/dist/src/client/index.js +0 -24
  464. package/dist/src/client/index.js.map +0 -1
  465. package/dist/src/exceptions.js +0 -7
  466. package/dist/src/exceptions.js.map +0 -1
  467. package/dist/src/index.js +0 -34
  468. package/dist/src/index.js.map +0 -1
  469. package/dist/src/metadata/DatabaseMetadata.js +0 -18
  470. package/dist/src/metadata/DatabaseMetadata.js.map +0 -1
  471. package/dist/src/metadata/DatabaseMetadataResolver.js.map +0 -1
  472. package/dist/src/metadata/ForeignKeyConstraintMetadata.js +0 -56
  473. package/dist/src/metadata/ForeignKeyConstraintMetadata.js.map +0 -1
  474. package/dist/src/metadata/IndexMetadata.js +0 -31
  475. package/dist/src/metadata/IndexMetadata.js.map +0 -1
  476. package/dist/src/metadata/UniqueConstraintMetadata.js +0 -40
  477. package/dist/src/metadata/UniqueConstraintMetadata.js.map +0 -1
  478. package/dist/src/metadata/index.js +0 -22
  479. package/dist/src/metadata/index.js.map +0 -1
  480. package/dist/src/metadata/stringArrayEquals.js +0 -13
  481. package/dist/src/metadata/stringArrayEquals.js.map +0 -1
  482. package/dist/src/queryable/DatabaseQuery.js +0 -17
  483. package/dist/src/queryable/DatabaseQuery.js.map +0 -1
  484. package/dist/src/queryable/DatabaseQueryable.js +0 -14
  485. package/dist/src/queryable/DatabaseQueryable.js.map +0 -1
  486. package/dist/src/queryable/index.js +0 -19
  487. package/dist/src/queryable/index.js.map +0 -1
  488. package/dist/src/tsconfig.tsbuildinfo +0 -1
  489. package/dist/src/types.d.ts.map +0 -1
  490. package/dist/src/types.js +0 -3
  491. package/dist/src/types.js.map +0 -1
  492. package/dist/src/utils/ConstraintHelper.js +0 -42
  493. package/dist/src/utils/ConstraintHelper.js.map +0 -1
  494. package/dist/src/utils/Mutex.js +0 -49
  495. package/dist/src/utils/Mutex.js.map +0 -1
  496. package/dist/src/utils/assertNever.js +0 -8
  497. package/dist/src/utils/assertNever.js.map +0 -1
  498. package/dist/src/utils/asyncIterableTransaction.js +0 -32
  499. package/dist/src/utils/asyncIterableTransaction.js.map +0 -1
  500. package/dist/src/utils/createDatabaseIfNotExists.js +0 -24
  501. package/dist/src/utils/createDatabaseIfNotExists.js.map +0 -1
  502. package/dist/src/utils/index.js +0 -27
  503. package/dist/src/utils/index.js.map +0 -1
  504. package/dist/src/utils/listen.js +0 -126
  505. package/dist/src/utils/listen.js.map +0 -1
  506. package/dist/src/utils/pgClientFactory.d.ts.map +0 -1
  507. package/dist/src/utils/pgClientFactory.js.map +0 -1
  508. package/dist/src/utils/retryTransaction.d.ts +0 -7
  509. package/dist/src/utils/retryTransaction.js +0 -42
  510. package/dist/src/utils/retryTransaction.js.map +0 -1
  511. package/dist/src/utils/sql.js +0 -23
  512. package/dist/src/utils/sql.js.map +0 -1
  513. package/dist/src/utils/withDatabaseAdvisoryLock.js +0 -17
  514. package/dist/src/utils/withDatabaseAdvisoryLock.js.map +0 -1
  515. package/dist/tests/cases/unit/connection.test.js +0 -128
  516. package/dist/tests/cases/unit/connection.test.js.map +0 -1
  517. package/dist/tests/cases/unit/createConnectionMockAlt.js +0 -47
  518. package/dist/tests/cases/unit/createConnectionMockAlt.js.map +0 -1
  519. package/dist/tests/cases/unit/eventManager.test.js +0 -131
  520. package/dist/tests/cases/unit/eventManager.test.js.map +0 -1
  521. package/dist/tests/cases/unit/pool.test.js +0 -372
  522. package/dist/tests/cases/unit/pool.test.js.map +0 -1
  523. package/dist/tests/cases/unit/queryBuilder.test.js +0 -371
  524. package/dist/tests/cases/unit/queryBuilder.test.js.map +0 -1
  525. package/dist/tests/src/tags.js +0 -13
  526. package/dist/tests/src/tags.js.map +0 -1
  527. package/vite.config.js +0 -3
  528. /package/dist/{src → types}/Literal.d.ts +0 -0
  529. /package/dist/{src → types}/Literal.d.ts.map +0 -0
  530. /package/dist/{src → types}/builders/CaseStatement.d.ts +0 -0
  531. /package/dist/{src → types}/builders/CaseStatement.d.ts.map +0 -0
  532. /package/dist/{src → types}/builders/ColumnExpressionFactory.d.ts +0 -0
  533. /package/dist/{src → types}/builders/ColumnExpressionFactory.d.ts.map +0 -0
  534. /package/dist/{src → types}/builders/Compiler.d.ts +0 -0
  535. /package/dist/{src → types}/builders/Compiler.d.ts.map +0 -0
  536. /package/dist/{src → types}/builders/ConditionBuilder.d.ts +0 -0
  537. /package/dist/{src → types}/builders/ConditionBuilder.d.ts.map +0 -0
  538. /package/dist/{src → types}/builders/ConflictActionType.d.ts +0 -0
  539. /package/dist/{src → types}/builders/ConflictActionType.d.ts.map +0 -0
  540. /package/dist/{src → types}/builders/DeleteBuilder.d.ts +0 -0
  541. /package/dist/{src → types}/builders/DeleteBuilder.d.ts.map +0 -0
  542. /package/dist/{src → types}/builders/InsertBuilder.d.ts +0 -0
  543. /package/dist/{src → types}/builders/InsertBuilder.d.ts.map +0 -0
  544. /package/dist/{src → types}/builders/LimitByGroupWrapper.d.ts +0 -0
  545. /package/dist/{src → types}/builders/LimitByGroupWrapper.d.ts.map +0 -0
  546. /package/dist/{src → types}/builders/LockType.d.ts +0 -0
  547. /package/dist/{src → types}/builders/LockType.d.ts.map +0 -0
  548. /package/dist/{src → types}/builders/SelectBuilder.d.ts +0 -0
  549. /package/dist/{src → types}/builders/SelectBuilder.d.ts.map +0 -0
  550. /package/dist/{src → types}/builders/UpdateBuilder.d.ts +0 -0
  551. /package/dist/{src → types}/builders/UpdateBuilder.d.ts.map +0 -0
  552. /package/dist/{src → types}/builders/WindowFunction.d.ts +0 -0
  553. /package/dist/{src → types}/builders/WindowFunction.d.ts.map +0 -0
  554. /package/dist/{src → types}/builders/formatUtils.d.ts +0 -0
  555. /package/dist/{src → types}/builders/formatUtils.d.ts.map +0 -0
  556. /package/dist/{src → types}/builders/index.d.ts +0 -0
  557. /package/dist/{src → types}/builders/index.d.ts.map +0 -0
  558. /package/dist/{src → types}/builders/internal/Returning.d.ts +0 -0
  559. /package/dist/{src → types}/builders/internal/Returning.d.ts.map +0 -0
  560. /package/dist/{src → types}/builders/internal/Subqueries.d.ts +0 -0
  561. /package/dist/{src → types}/builders/internal/Subqueries.d.ts.map +0 -0
  562. /package/dist/{src → types}/builders/internal/Where.d.ts +0 -0
  563. /package/dist/{src → types}/builders/internal/Where.d.ts.map +0 -0
  564. /package/dist/{src → types}/builders/internal/With.d.ts +0 -0
  565. /package/dist/{src → types}/builders/internal/With.d.ts.map +0 -0
  566. /package/dist/{src → types}/builders/utils.d.ts +0 -0
  567. /package/dist/{src → types}/builders/utils.d.ts.map +0 -0
  568. /package/dist/{src → types}/client/AcquiredConnection.d.ts +0 -0
  569. /package/dist/{src → types}/client/AcquiredConnection.d.ts.map +0 -0
  570. /package/dist/{src → types}/client/Client.d.ts +0 -0
  571. /package/dist/{src → types}/client/Client.d.ts.map +0 -0
  572. /package/dist/{src → types}/client/Connection.d.ts +0 -0
  573. /package/dist/{src → types}/client/Connection.d.ts.map +0 -0
  574. /package/dist/{src → types}/client/EventManager.d.ts +0 -0
  575. /package/dist/{src → types}/client/EventManager.d.ts.map +0 -0
  576. /package/dist/{src → types}/client/PgClient.d.ts +0 -0
  577. /package/dist/{src → types}/client/PgClient.d.ts.map +0 -0
  578. /package/dist/{src → types}/client/errorCodes.d.ts +0 -0
  579. /package/dist/{src → types}/client/errorCodes.d.ts.map +0 -0
  580. /package/dist/{src → types}/client/index.d.ts +0 -0
  581. /package/dist/{src → types}/client/index.d.ts.map +0 -0
  582. /package/dist/{src → types}/exceptions.d.ts +0 -0
  583. /package/dist/{src → types}/exceptions.d.ts.map +0 -0
  584. /package/dist/{src → types}/index.d.ts +0 -0
  585. /package/dist/{src → types}/index.d.ts.map +0 -0
  586. /package/dist/{src → types}/metadata/DatabaseMetadata.d.ts +0 -0
  587. /package/dist/{src → types}/metadata/DatabaseMetadata.d.ts.map +0 -0
  588. /package/dist/{src → types}/metadata/DatabaseMetadataResolver.d.ts +0 -0
  589. /package/dist/{src → types}/metadata/DatabaseMetadataResolver.d.ts.map +0 -0
  590. /package/dist/{src → types}/metadata/ForeignKeyConstraintMetadata.d.ts +0 -0
  591. /package/dist/{src → types}/metadata/ForeignKeyConstraintMetadata.d.ts.map +0 -0
  592. /package/dist/{src → types}/metadata/IndexMetadata.d.ts +0 -0
  593. /package/dist/{src → types}/metadata/IndexMetadata.d.ts.map +0 -0
  594. /package/dist/{src → types}/metadata/UniqueConstraintMetadata.d.ts +0 -0
  595. /package/dist/{src → types}/metadata/UniqueConstraintMetadata.d.ts.map +0 -0
  596. /package/dist/{src → types}/metadata/index.d.ts +0 -0
  597. /package/dist/{src → types}/metadata/index.d.ts.map +0 -0
  598. /package/dist/{src → types}/metadata/stringArrayEquals.d.ts +0 -0
  599. /package/dist/{src → types}/metadata/stringArrayEquals.d.ts.map +0 -0
  600. /package/dist/{src → types}/queryable/DatabaseQuery.d.ts +0 -0
  601. /package/dist/{src → types}/queryable/DatabaseQuery.d.ts.map +0 -0
  602. /package/dist/{src → types}/queryable/DatabaseQueryable.d.ts +0 -0
  603. /package/dist/{src → types}/queryable/DatabaseQueryable.d.ts.map +0 -0
  604. /package/dist/{src → types}/queryable/index.d.ts +0 -0
  605. /package/dist/{src → types}/queryable/index.d.ts.map +0 -0
  606. /package/dist/{src → types}/utils/ConstraintHelper.d.ts +0 -0
  607. /package/dist/{src → types}/utils/ConstraintHelper.d.ts.map +0 -0
  608. /package/dist/{src → types}/utils/Mutex.d.ts +0 -0
  609. /package/dist/{src → types}/utils/Mutex.d.ts.map +0 -0
  610. /package/dist/{src → types}/utils/assertNever.d.ts +0 -0
  611. /package/dist/{src → types}/utils/assertNever.d.ts.map +0 -0
  612. /package/dist/{src → types}/utils/asyncIterableTransaction.d.ts +0 -0
  613. /package/dist/{src → types}/utils/asyncIterableTransaction.d.ts.map +0 -0
  614. /package/dist/{src → types}/utils/createDatabaseIfNotExists.d.ts +0 -0
  615. /package/dist/{src → types}/utils/index.d.ts +0 -0
  616. /package/dist/{src → types}/utils/index.d.ts.map +0 -0
  617. /package/dist/{src → types}/utils/listen.d.ts +0 -0
  618. /package/dist/{src → types}/utils/listen.d.ts.map +0 -0
  619. /package/dist/{src → types}/utils/sql.d.ts +0 -0
  620. /package/dist/{src → types}/utils/withDatabaseAdvisoryLock.d.ts +0 -0
@@ -0,0 +1,118 @@
1
+ import { wrapIdentifier } from "./sql.js";
2
+ import { clearInterval } from "node:timers";
3
+ class Listener {
4
+ constructor(client, channel, onMessage, options = {}) {
5
+ this.client = client;
6
+ this.channel = channel;
7
+ this.onMessage = onMessage;
8
+ this.options = options;
9
+ }
10
+ async run({ onClose, onError }) {
11
+ let aborted = false;
12
+ let onAbortInner = async () => {
13
+ };
14
+ const onAbort = async () => {
15
+ aborted = true;
16
+ await onAbortInner();
17
+ };
18
+ let cleanups = [];
19
+ const cleanup = () => {
20
+ let localCleanup = cleanups;
21
+ cleanups = [];
22
+ localCleanup.forEach((it) => it());
23
+ };
24
+ try {
25
+ cleanups.push(this.client.connection.on("notification", ({ channel, payload }) => {
26
+ if (channel !== this.channel || aborted) {
27
+ return;
28
+ }
29
+ this.onMessage(payload);
30
+ }));
31
+ await this.client.query(`LISTEN ${wrapIdentifier(this.channel)}`);
32
+ (async () => {
33
+ const stopListening = async () => {
34
+ try {
35
+ await this.client.query(`UNLISTEN ${wrapIdentifier(this.channel)}`);
36
+ } catch {
37
+ }
38
+ };
39
+ try {
40
+ if (aborted) {
41
+ await stopListening();
42
+ return;
43
+ }
44
+ await new Promise((resolve, reject) => {
45
+ onAbortInner = async () => {
46
+ await stopListening();
47
+ resolve();
48
+ };
49
+ cleanups.push(this.client.connection.on("end", reject));
50
+ cleanups.push(this.client.connection.on("error", reject));
51
+ const healthCheckHandle = setInterval(async () => {
52
+ try {
53
+ await this.client.query("SELECT 1");
54
+ } catch (e) {
55
+ reject(e);
56
+ }
57
+ }, this.options.healthCheckMs ?? 3e4);
58
+ cleanups.push(() => clearInterval(healthCheckHandle));
59
+ });
60
+ onClose?.();
61
+ } catch (e) {
62
+ onError(e);
63
+ } finally {
64
+ cleanup();
65
+ }
66
+ })();
67
+ return {
68
+ end: async () => {
69
+ await onAbort();
70
+ }
71
+ };
72
+ } catch (e) {
73
+ cleanup();
74
+ throw e;
75
+ }
76
+ }
77
+ }
78
+ class AcquiringListener {
79
+ constructor(client, channel, onMessage, options = {}) {
80
+ this.client = client;
81
+ this.channel = channel;
82
+ this.onMessage = onMessage;
83
+ this.options = options;
84
+ }
85
+ async run({ onClose, onError }) {
86
+ return new Promise(async (resolveRunning, rejectRunning) => {
87
+ try {
88
+ await this.client.scope(async (db) => {
89
+ const listener = new Listener(db, this.channel, this.onMessage, this.options);
90
+ await new Promise(async (resolveScope, rejectScope) => {
91
+ try {
92
+ const running = await listener.run({
93
+ onClose: resolveScope,
94
+ onError: rejectScope
95
+ });
96
+ resolveRunning({
97
+ end: async () => {
98
+ await running.end();
99
+ }
100
+ });
101
+ } catch (e) {
102
+ rejectScope(e);
103
+ }
104
+ });
105
+ });
106
+ onClose?.();
107
+ } catch (e) {
108
+ rejectRunning(e);
109
+ onError(e);
110
+ }
111
+ });
112
+ }
113
+ }
114
+ export {
115
+ AcquiringListener,
116
+ Listener
117
+ };
118
+ //# sourceMappingURL=listen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listen.js","sources":["../../../../../packages/database/src/utils/listen.ts"],"sourcesContent":["import { Client, Connection } from '../client'\nimport { wrapIdentifier } from './sql'\nimport { clearInterval } from 'node:timers'\n\ntype ListenArgs<P> = {\n\tclient: Client<Connection.AcquiredConnectionLike>\n\tchannel: string\n\tabortSignal?: AbortSignal\n\thealthCheckMs?: number\n\tonMessage: (payload: P) => void\n\tonError: (err: any) => void\n\tonClose?: () => void\n}\n\n\nexport class Listener<P> {\n\tconstructor(\n\t\tprivate readonly client: Client<Connection.AcquiredConnectionLike>,\n\t\tprivate readonly channel: string,\n\t\tprivate readonly onMessage: (message: P) => void,\n\t\tprivate readonly options: { healthCheckMs?: number } = {},\n\t) {\n\t}\n\n\tasync run({ onClose, onError }: {\n\t\t\t\t onError: (e: any) => void\n\t\t\t\t onClose?: () => void\n\t\t\t },\n\t): Promise<{ end: () => Promise<void> }> {\n\t\tlet aborted = false\n\t\tlet onAbortInner = async () => {}\n\t\tconst onAbort = async () => {\n\t\t\taborted = true\n\t\t\tawait onAbortInner()\n\t\t}\n\t\tlet cleanups: (() => void)[] = []\n\t\tconst cleanup = () => {\n\t\t\tlet localCleanup = cleanups\n\t\t\tcleanups = []\n\t\t\tlocalCleanup.forEach(it => it())\n\t\t}\n\t\ttry {\n\t\t\tcleanups.push(this.client.connection.on('notification', ({ channel, payload }) => {\n\t\t\t\tif (channel !== this.channel || aborted) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.onMessage(payload as P)\n\t\t\t}))\n\t\t\tawait this.client.query(`LISTEN ${wrapIdentifier(this.channel)}`)\n\n\t\t\t;(async () => {\n\t\t\t\tconst stopListening = async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.client.query(`UNLISTEN ${wrapIdentifier(this.channel)}`)\n\t\t\t\t\t} catch {\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\tawait stopListening()\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t\t\tonAbortInner = async () => {\n\t\t\t\t\t\t\tawait stopListening()\n\t\t\t\t\t\t\tresolve()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcleanups.push(this.client.connection.on('end', reject))\n\t\t\t\t\t\tcleanups.push(this.client.connection.on('error', reject))\n\n\t\t\t\t\t\tconst healthCheckHandle = setInterval(async () => {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait this.client.query('SELECT 1')\n\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\treject(e)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}, this.options.healthCheckMs ?? 30_000)\n\t\t\t\t\t\tcleanups.push(() => clearInterval(healthCheckHandle))\n\t\t\t\t\t})\n\t\t\t\t\tonClose?.()\n\t\t\t\t} catch (e) {\n\t\t\t\t\tonError(e)\n\t\t\t\t} finally {\n\t\t\t\t\tcleanup()\n\t\t\t\t}\n\t\t\t})()\n\n\t\t\treturn {\n\t\t\t\tend: async () => {\n\t\t\t\t\tawait onAbort()\n\t\t\t\t},\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tcleanup()\n\t\t\tthrow e\n\t\t}\n\t}\n}\n\n\nexport class AcquiringListener<P> {\n\tconstructor(\n\t\tprivate readonly client: Client,\n\t\tprivate readonly channel: string,\n\t\tprivate readonly onMessage: (message: P) => void,\n\t\tprivate readonly options: { healthCheckMs?: number } = {},\n\t) {\n\t}\n\n\tasync run({ onClose, onError }: { onError: (e: any) => void;onClose?: () => void },\n\t): Promise<{ end: () => Promise<void> }> {\n\t\treturn new Promise(async (resolveRunning, rejectRunning) => {\n\t\t\ttry {\n\t\t\t\tawait this.client.scope(async db => {\n\t\t\t\t\tconst listener = new Listener<P>(db, this.channel, this.onMessage, this.options)\n\t\t\t\t\tawait new Promise<void>(async (resolveScope, rejectScope) => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst running = await listener.run({\n\t\t\t\t\t\t\t\tonClose: resolveScope,\n\t\t\t\t\t\t\t\tonError: rejectScope,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\tresolveRunning({\n\t\t\t\t\t\t\t\tend: async () => {\n\t\t\t\t\t\t\t\t\tawait running.end()\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\trejectScope(e)\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t\tonClose?.()\n\t\t\t} catch (e) {\n\t\t\t\trejectRunning(e)\n\t\t\t\tonError(e)\n\t\t\t}\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";;AAeO,MAAM,SAAY;AAAA,EACxB,YACkB,QACA,SACA,WACA,UAAsC,CAAA,GACtD;AAJgB,SAAA,SAAA;AACA,SAAA,UAAA;AACA,SAAA,YAAA;AACA,SAAA,UAAA;AAAA,EAElB;AAAA,EAEA,MAAM,IAAI,EAAE,SAAS,WAIoB;AACxC,QAAI,UAAU;AACd,QAAI,eAAe,YAAY;AAAA,IAAA;AAC/B,UAAM,UAAU,YAAY;AACjB,gBAAA;AACV,YAAM,aAAa;AAAA,IAAA;AAEpB,QAAI,WAA2B,CAAA;AAC/B,UAAM,UAAU,MAAM;AACrB,UAAI,eAAe;AACnB,iBAAW,CAAA;AACE,mBAAA,QAAQ,CAAM,OAAA,GAAI,CAAA;AAAA,IAAA;AAE5B,QAAA;AACM,eAAA,KAAK,KAAK,OAAO,WAAW,GAAG,gBAAgB,CAAC,EAAE,SAAS,cAAc;AAC7E,YAAA,YAAY,KAAK,WAAW,SAAS;AACxC;AAAA,QACD;AACA,aAAK,UAAU,OAAY;AAAA,MAC3B,CAAA,CAAC;AACI,YAAA,KAAK,OAAO,MAAM,UAAU,eAAe,KAAK,OAAO,CAAC,EAAE;AAE/D,OAAC,YAAY;AACb,cAAM,gBAAgB,YAAY;AAC7B,cAAA;AACG,kBAAA,KAAK,OAAO,MAAM,YAAY,eAAe,KAAK,OAAO,CAAC,EAAE;AAAA,UAAA,QAC3D;AAAA,UACR;AAAA,QAAA;AAGG,YAAA;AACH,cAAI,SAAS;AACZ,kBAAM,cAAc;AACpB;AAAA,UACD;AACA,gBAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AAC5C,2BAAe,YAAY;AAC1B,oBAAM,cAAc;AACZ;YAAA;AAET,qBAAS,KAAK,KAAK,OAAO,WAAW,GAAG,OAAO,MAAM,CAAC;AACtD,qBAAS,KAAK,KAAK,OAAO,WAAW,GAAG,SAAS,MAAM,CAAC;AAElD,kBAAA,oBAAoB,YAAY,YAAY;AAC7C,kBAAA;AACG,sBAAA,KAAK,OAAO,MAAM,UAAU;AAAA,uBAC1B,GAAG;AACX,uBAAO,CAAC;AAAA,cACT;AAAA,YACE,GAAA,KAAK,QAAQ,iBAAiB,GAAM;AACvC,qBAAS,KAAK,MAAM,cAAc,iBAAiB,CAAC;AAAA,UAAA,CACpD;AACS;iBACF,GAAG;AACX,kBAAQ,CAAC;AAAA,QAAA,UACR;AACO;QACT;AAAA,MAAA;AAGM,aAAA;AAAA,QACN,KAAK,YAAY;AAChB,gBAAM,QAAQ;AAAA,QACf;AAAA,MAAA;AAAA,aAEO,GAAG;AACH;AACF,YAAA;AAAA,IACP;AAAA,EACD;AACD;AAGO,MAAM,kBAAqB;AAAA,EACjC,YACkB,QACA,SACA,WACA,UAAsC,CAAA,GACtD;AAJgB,SAAA,SAAA;AACA,SAAA,UAAA;AACA,SAAA,YAAA;AACA,SAAA,UAAA;AAAA,EAElB;AAAA,EAEA,MAAM,IAAI,EAAE,SAAS,WACoB;AACxC,WAAO,IAAI,QAAQ,OAAO,gBAAgB,kBAAkB;AACvD,UAAA;AACH,cAAM,KAAK,OAAO,MAAM,OAAM,OAAM;AAC7B,gBAAA,WAAW,IAAI,SAAY,IAAI,KAAK,SAAS,KAAK,WAAW,KAAK,OAAO;AAC/E,gBAAM,IAAI,QAAc,OAAO,cAAc,gBAAgB;AACxD,gBAAA;AACG,oBAAA,UAAU,MAAM,SAAS,IAAI;AAAA,gBAClC,SAAS;AAAA,gBACT,SAAS;AAAA,cAAA,CACT;AACc,6BAAA;AAAA,gBACd,KAAK,YAAY;AAChB,wBAAM,QAAQ;gBACf;AAAA,cAAA,CACA;AAAA,qBACO,GAAG;AACX,0BAAY,CAAC;AAAA,YACd;AAAA,UAAA,CACA;AAAA,QAAA,CACD;AACS;eACF,GAAG;AACX,sBAAc,CAAC;AACf,gBAAQ,CAAC;AAAA,MACV;AAAA,IAAA,CACA;AAAA,EACF;AACD;"}
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPgClientFactory = void 0;
4
- const pg_1 = require("pg");
5
- const createPgClientFactory = ({ queryTimeoutMs, statementTimeoutMs, connectionTimeoutMs, ...config }) => () => new pg_1.Client({
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const pg = require("pg");
4
+ const createPgClientFactory = ({ queryTimeoutMs, statementTimeoutMs, connectionTimeoutMs, ...config }) => () => {
5
+ return new pg.Client({
6
6
  query_timeout: queryTimeoutMs,
7
7
  statement_timeout: statementTimeoutMs,
8
8
  connectionTimeoutMillis: connectionTimeoutMs,
9
- ...config,
10
- });
9
+ ...config
10
+ });
11
+ };
11
12
  exports.createPgClientFactory = createPgClientFactory;
12
- //# sourceMappingURL=pgClientFactory.js.map
13
+ //# sourceMappingURL=pgClientFactory.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pgClientFactory.cjs","sources":["../../../../../packages/database/src/utils/pgClientFactory.ts"],"sourcesContent":["import pg from 'pg'\nimport { DatabaseConfig } from '../types'\nimport { PgClient } from '../client/PgClient'\n\nexport type PgClientFactory = () => PgClient\nexport const createPgClientFactory = ({ queryTimeoutMs, statementTimeoutMs, connectionTimeoutMs, ...config }: DatabaseConfig) => () => {\n\treturn new pg.Client({\n\t\tquery_timeout: queryTimeoutMs,\n\t\tstatement_timeout: statementTimeoutMs,\n\t\tconnectionTimeoutMillis: connectionTimeoutMs,\n\t\t...config,\n\t})\n}\n"],"names":[],"mappings":";;;AAKa,MAAA,wBAAwB,CAAC,EAAE,gBAAgB,oBAAoB,qBAAqB,GAAG,OAAO,MAAsB,MAAM;AAC/H,SAAA,IAAI,GAAG,OAAO;AAAA,IACpB,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,yBAAyB;AAAA,IACzB,GAAG;AAAA,EAAA,CACH;AACF;;"}
@@ -0,0 +1,13 @@
1
+ import pg from "pg";
2
+ const createPgClientFactory = ({ queryTimeoutMs, statementTimeoutMs, connectionTimeoutMs, ...config }) => () => {
3
+ return new pg.Client({
4
+ query_timeout: queryTimeoutMs,
5
+ statement_timeout: statementTimeoutMs,
6
+ connectionTimeoutMillis: connectionTimeoutMs,
7
+ ...config
8
+ });
9
+ };
10
+ export {
11
+ createPgClientFactory
12
+ };
13
+ //# sourceMappingURL=pgClientFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pgClientFactory.js","sources":["../../../../../packages/database/src/utils/pgClientFactory.ts"],"sourcesContent":["import pg from 'pg'\nimport { DatabaseConfig } from '../types'\nimport { PgClient } from '../client/PgClient'\n\nexport type PgClientFactory = () => PgClient\nexport const createPgClientFactory = ({ queryTimeoutMs, statementTimeoutMs, connectionTimeoutMs, ...config }: DatabaseConfig) => () => {\n\treturn new pg.Client({\n\t\tquery_timeout: queryTimeoutMs,\n\t\tstatement_timeout: statementTimeoutMs,\n\t\tconnectionTimeoutMillis: connectionTimeoutMs,\n\t\t...config,\n\t})\n}\n"],"names":[],"mappings":";AAKa,MAAA,wBAAwB,CAAC,EAAE,gBAAgB,oBAAoB,qBAAqB,GAAG,OAAO,MAAsB,MAAM;AAC/H,SAAA,IAAI,GAAG,OAAO;AAAA,IACpB,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,yBAAyB;AAAA,IACzB,GAAG;AAAA,EAAA,CACH;AACF;"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ require("../builders/Compiler.cjs");
4
+ require("../Literal.cjs");
5
+ require("node:timers");
6
+ require("./Mutex.cjs");
7
+ require("pg");
8
+ require("../builders/SelectBuilder.cjs");
9
+ require("../builders/internal/With.cjs");
10
+ require("../builders/internal/Where.cjs");
11
+ require("../client/EventManager.cjs");
12
+ require("@contember/queryable");
13
+ const errors = require("../client/errors.cjs");
14
+ require("../client/Connection.cjs");
15
+ const defaultOptions = {
16
+ maxAttempts: 5,
17
+ minTimeout: 20,
18
+ maxTimeout: 100
19
+ };
20
+ const retryTransaction = async (cb, logger, options = {}) => {
21
+ let attempt = 0;
22
+ const minTimeout = options.minTimeout ?? defaultOptions.minTimeout;
23
+ const maxAttempts = options.maxAttempts ?? defaultOptions.maxAttempts;
24
+ const additionalTimeout = ((options.maxTimeout ?? defaultOptions.maxTimeout) - minTimeout) / maxAttempts;
25
+ const timeout = async (attempt2) => {
26
+ const timeout2 = Math.round(minTimeout + Math.random() * additionalTimeout * attempt2);
27
+ await new Promise((resolve) => setTimeout(resolve, timeout2));
28
+ return timeout2;
29
+ };
30
+ do {
31
+ attempt++;
32
+ try {
33
+ return await cb();
34
+ } catch (e) {
35
+ if (!(e instanceof errors.SerializationFailureError)) {
36
+ throw e;
37
+ }
38
+ if (attempt < maxAttempts) {
39
+ const timeoutMs = await timeout(attempt);
40
+ logger(`RETRY: Serialization failure (attempt #${attempt}, retrying after ${timeoutMs}ms)`);
41
+ } else {
42
+ logger(`ABORT: Serialization failure (attempt #${attempt})`);
43
+ throw e;
44
+ }
45
+ }
46
+ } while (true);
47
+ };
48
+ exports.retryTransaction = retryTransaction;
49
+ //# sourceMappingURL=retryTransaction.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retryTransaction.cjs","sources":["../../../../../packages/database/src/utils/retryTransaction.ts"],"sourcesContent":["import { SerializationFailureError } from '../client'\n\nexport interface RetryOptions {\n\tmaxAttempts: number\n\tminTimeout: number\n\tmaxTimeout: number\n}\n\nconst defaultOptions: RetryOptions = {\n\tmaxAttempts: 5,\n\tminTimeout: 20,\n\tmaxTimeout: 100,\n}\n\nexport const retryTransaction = async <R>(\n\tcb: () => Promise<R> | R,\n\tlogger: (message: string) => void,\n\toptions: Partial<RetryOptions> = {},\n): Promise<R> => {\n\tlet attempt = 0\n\tconst minTimeout = options.minTimeout ?? defaultOptions.minTimeout\n\tconst maxAttempts = options.maxAttempts ?? defaultOptions.maxAttempts\n\tconst additionalTimeout = ((options.maxTimeout ?? defaultOptions.maxTimeout) - minTimeout) / maxAttempts\n\tconst timeout = async (attempt: number) => {\n\t\tconst timeout = Math.round(minTimeout + Math.random() * additionalTimeout * attempt)\n\t\tawait new Promise(resolve => setTimeout(resolve, timeout))\n\t\treturn timeout\n\t}\n\n\tdo {\n\t\tattempt++\n\t\ttry {\n\t\t\treturn await cb()\n\t\t} catch (e) {\n\t\t\tif (!(e instanceof SerializationFailureError)) {\n\t\t\t\tthrow e\n\t\t\t}\n\t\t\tif (attempt < maxAttempts) {\n\t\t\t\tconst timeoutMs = await timeout(attempt)\n\t\t\t\tlogger(`RETRY: Serialization failure (attempt #${attempt}, retrying after ${timeoutMs}ms)`)\n\t\t\t} else {\n\t\t\t\tlogger(`ABORT: Serialization failure (attempt #${attempt})`)\n\t\t\t\tthrow e\n\t\t\t}\n\t\t}\n\t} while (true)\n}\n"],"names":["attempt","timeout","SerializationFailureError"],"mappings":";;;;;;;;;;;;;;AAQA,MAAM,iBAA+B;AAAA,EACpC,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AACb;AAEO,MAAM,mBAAmB,OAC/B,IACA,QACA,UAAiC,CAAA,MACjB;AAChB,MAAI,UAAU;AACR,QAAA,aAAa,QAAQ,cAAc,eAAe;AAClD,QAAA,cAAc,QAAQ,eAAe,eAAe;AAC1D,QAAM,sBAAsB,QAAQ,cAAc,eAAe,cAAc,cAAc;AACvF,QAAA,UAAU,OAAOA,aAAoB;AACpCC,UAAAA,WAAU,KAAK,MAAM,aAAa,KAAK,OAAO,IAAI,oBAAoBD,QAAO;AACnF,UAAM,IAAI,QAAQ,CAAA,YAAW,WAAW,SAASC,QAAO,CAAC;AAClDA,WAAAA;AAAAA,EAAA;AAGL,KAAA;AACF;AACI,QAAA;AACH,aAAO,MAAM,GAAG;AAAA,aACR,GAAG;AACP,UAAA,EAAE,aAAaC,OAAAA,4BAA4B;AACxC,cAAA;AAAA,MACP;AACA,UAAI,UAAU,aAAa;AACpB,cAAA,YAAY,MAAM,QAAQ,OAAO;AACvC,eAAO,0CAA0C,OAAO,oBAAoB,SAAS,KAAK;AAAA,MAAA,OACpF;AACC,eAAA,0CAA0C,OAAO,GAAG;AACrD,cAAA;AAAA,MACP;AAAA,IACD;AAAA,EACQ,SAAA;AACV;;"}
@@ -0,0 +1,49 @@
1
+ import "../builders/Compiler.js";
2
+ import "../Literal.js";
3
+ import "node:timers";
4
+ import "./Mutex.js";
5
+ import "pg";
6
+ import "../builders/SelectBuilder.js";
7
+ import "../builders/internal/With.js";
8
+ import "../builders/internal/Where.js";
9
+ import "../client/EventManager.js";
10
+ import "@contember/queryable";
11
+ import { SerializationFailureError } from "../client/errors.js";
12
+ import "../client/Connection.js";
13
+ const defaultOptions = {
14
+ maxAttempts: 5,
15
+ minTimeout: 20,
16
+ maxTimeout: 100
17
+ };
18
+ const retryTransaction = async (cb, logger, options = {}) => {
19
+ let attempt = 0;
20
+ const minTimeout = options.minTimeout ?? defaultOptions.minTimeout;
21
+ const maxAttempts = options.maxAttempts ?? defaultOptions.maxAttempts;
22
+ const additionalTimeout = ((options.maxTimeout ?? defaultOptions.maxTimeout) - minTimeout) / maxAttempts;
23
+ const timeout = async (attempt2) => {
24
+ const timeout2 = Math.round(minTimeout + Math.random() * additionalTimeout * attempt2);
25
+ await new Promise((resolve) => setTimeout(resolve, timeout2));
26
+ return timeout2;
27
+ };
28
+ do {
29
+ attempt++;
30
+ try {
31
+ return await cb();
32
+ } catch (e) {
33
+ if (!(e instanceof SerializationFailureError)) {
34
+ throw e;
35
+ }
36
+ if (attempt < maxAttempts) {
37
+ const timeoutMs = await timeout(attempt);
38
+ logger(`RETRY: Serialization failure (attempt #${attempt}, retrying after ${timeoutMs}ms)`);
39
+ } else {
40
+ logger(`ABORT: Serialization failure (attempt #${attempt})`);
41
+ throw e;
42
+ }
43
+ }
44
+ } while (true);
45
+ };
46
+ export {
47
+ retryTransaction
48
+ };
49
+ //# sourceMappingURL=retryTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retryTransaction.js","sources":["../../../../../packages/database/src/utils/retryTransaction.ts"],"sourcesContent":["import { SerializationFailureError } from '../client'\n\nexport interface RetryOptions {\n\tmaxAttempts: number\n\tminTimeout: number\n\tmaxTimeout: number\n}\n\nconst defaultOptions: RetryOptions = {\n\tmaxAttempts: 5,\n\tminTimeout: 20,\n\tmaxTimeout: 100,\n}\n\nexport const retryTransaction = async <R>(\n\tcb: () => Promise<R> | R,\n\tlogger: (message: string) => void,\n\toptions: Partial<RetryOptions> = {},\n): Promise<R> => {\n\tlet attempt = 0\n\tconst minTimeout = options.minTimeout ?? defaultOptions.minTimeout\n\tconst maxAttempts = options.maxAttempts ?? defaultOptions.maxAttempts\n\tconst additionalTimeout = ((options.maxTimeout ?? defaultOptions.maxTimeout) - minTimeout) / maxAttempts\n\tconst timeout = async (attempt: number) => {\n\t\tconst timeout = Math.round(minTimeout + Math.random() * additionalTimeout * attempt)\n\t\tawait new Promise(resolve => setTimeout(resolve, timeout))\n\t\treturn timeout\n\t}\n\n\tdo {\n\t\tattempt++\n\t\ttry {\n\t\t\treturn await cb()\n\t\t} catch (e) {\n\t\t\tif (!(e instanceof SerializationFailureError)) {\n\t\t\t\tthrow e\n\t\t\t}\n\t\t\tif (attempt < maxAttempts) {\n\t\t\t\tconst timeoutMs = await timeout(attempt)\n\t\t\t\tlogger(`RETRY: Serialization failure (attempt #${attempt}, retrying after ${timeoutMs}ms)`)\n\t\t\t} else {\n\t\t\t\tlogger(`ABORT: Serialization failure (attempt #${attempt})`)\n\t\t\t\tthrow e\n\t\t\t}\n\t\t}\n\t} while (true)\n}\n"],"names":["attempt","timeout"],"mappings":";;;;;;;;;;;;AAQA,MAAM,iBAA+B;AAAA,EACpC,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AACb;AAEO,MAAM,mBAAmB,OAC/B,IACA,QACA,UAAiC,CAAA,MACjB;AAChB,MAAI,UAAU;AACR,QAAA,aAAa,QAAQ,cAAc,eAAe;AAClD,QAAA,cAAc,QAAQ,eAAe,eAAe;AAC1D,QAAM,sBAAsB,QAAQ,cAAc,eAAe,cAAc,cAAc;AACvF,QAAA,UAAU,OAAOA,aAAoB;AACpCC,UAAAA,WAAU,KAAK,MAAM,aAAa,KAAK,OAAO,IAAI,oBAAoBD,QAAO;AACnF,UAAM,IAAI,QAAQ,CAAA,YAAW,WAAW,SAASC,QAAO,CAAC;AAClDA,WAAAA;AAAAA,EAAA;AAGL,KAAA;AACF;AACI,QAAA;AACH,aAAO,MAAM,GAAG;AAAA,aACR,GAAG;AACP,UAAA,EAAE,aAAa,4BAA4B;AACxC,cAAA;AAAA,MACP;AACA,UAAI,UAAU,aAAa;AACpB,cAAA,YAAY,MAAM,QAAQ,OAAO;AACvC,eAAO,0CAA0C,OAAO,oBAAoB,SAAS,KAAK;AAAA,MAAA,OACpF;AACC,eAAA,0CAA0C,OAAO,GAAG;AACrD,cAAA;AAAA,MACP;AAAA,IACD;AAAA,EACQ,SAAA;AACV;"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const Literal = require("../Literal.cjs");
4
+ const wrapIdentifier = (value) => '"' + value.replace(/"/g, '""') + '"';
5
+ const aliasLiteral = (raw, alias) => {
6
+ if (!alias) {
7
+ return raw;
8
+ }
9
+ return new Literal.Literal(raw.sql + " as " + wrapIdentifier(alias), raw.parameters);
10
+ };
11
+ const prependSchema = (tableExpression, schema, cteAliases) => {
12
+ if (typeof tableExpression !== "string") {
13
+ return tableExpression;
14
+ }
15
+ return new Literal.Literal(
16
+ cteAliases.has(tableExpression) ? wrapIdentifier(tableExpression) : `${wrapIdentifier(schema)}.${wrapIdentifier(tableExpression)}`
17
+ );
18
+ };
19
+ exports.aliasLiteral = aliasLiteral;
20
+ exports.prependSchema = prependSchema;
21
+ exports.wrapIdentifier = wrapIdentifier;
22
+ //# sourceMappingURL=sql.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql.cjs","sources":["../../../../../packages/database/src/utils/sql.ts"],"sourcesContent":["import { Literal } from '../Literal'\n\nexport const wrapIdentifier = (value: string) => '\"' + value.replace(/\"/g, '\"\"') + '\"'\n\nexport const aliasLiteral = (raw: Literal, alias?: string): Literal => {\n\tif (!alias) {\n\t\treturn raw\n\t}\n\treturn new Literal(raw.sql + ' as ' + wrapIdentifier(alias), raw.parameters)\n}\n\nexport const prependSchema = (tableExpression: string | Literal, schema: string, cteAliases: Set<string>) => {\n\tif (typeof tableExpression !== 'string') {\n\t\treturn tableExpression\n\t}\n\treturn new Literal(\n\t\tcteAliases.has(tableExpression)\n\t\t\t? wrapIdentifier(tableExpression)\n\t\t\t: `${wrapIdentifier(schema)}.${wrapIdentifier(tableExpression)}`,\n\t)\n}\n"],"names":["Literal"],"mappings":";;;AAEa,MAAA,iBAAiB,CAAC,UAAkB,MAAM,MAAM,QAAQ,MAAM,IAAI,IAAI;AAEtE,MAAA,eAAe,CAAC,KAAc,UAA4B;AACtE,MAAI,CAAC,OAAO;AACJ,WAAA;AAAA,EACR;AACO,SAAA,IAAIA,QAAAA,QAAQ,IAAI,MAAM,SAAS,eAAe,KAAK,GAAG,IAAI,UAAU;AAC5E;AAEO,MAAM,gBAAgB,CAAC,iBAAmC,QAAgB,eAA4B;AACxG,MAAA,OAAO,oBAAoB,UAAU;AACjC,WAAA;AAAA,EACR;AACA,SAAO,IAAIA,QAAA;AAAA,IACV,WAAW,IAAI,eAAe,IAC3B,eAAe,eAAe,IAC9B,GAAG,eAAe,MAAM,CAAC,IAAI,eAAe,eAAe,CAAC;AAAA,EAAA;AAEjE;;;;"}
@@ -0,0 +1,22 @@
1
+ import { Literal } from "../Literal.js";
2
+ const wrapIdentifier = (value) => '"' + value.replace(/"/g, '""') + '"';
3
+ const aliasLiteral = (raw, alias) => {
4
+ if (!alias) {
5
+ return raw;
6
+ }
7
+ return new Literal(raw.sql + " as " + wrapIdentifier(alias), raw.parameters);
8
+ };
9
+ const prependSchema = (tableExpression, schema, cteAliases) => {
10
+ if (typeof tableExpression !== "string") {
11
+ return tableExpression;
12
+ }
13
+ return new Literal(
14
+ cteAliases.has(tableExpression) ? wrapIdentifier(tableExpression) : `${wrapIdentifier(schema)}.${wrapIdentifier(tableExpression)}`
15
+ );
16
+ };
17
+ export {
18
+ aliasLiteral,
19
+ prependSchema,
20
+ wrapIdentifier
21
+ };
22
+ //# sourceMappingURL=sql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql.js","sources":["../../../../../packages/database/src/utils/sql.ts"],"sourcesContent":["import { Literal } from '../Literal'\n\nexport const wrapIdentifier = (value: string) => '\"' + value.replace(/\"/g, '\"\"') + '\"'\n\nexport const aliasLiteral = (raw: Literal, alias?: string): Literal => {\n\tif (!alias) {\n\t\treturn raw\n\t}\n\treturn new Literal(raw.sql + ' as ' + wrapIdentifier(alias), raw.parameters)\n}\n\nexport const prependSchema = (tableExpression: string | Literal, schema: string, cteAliases: Set<string>) => {\n\tif (typeof tableExpression !== 'string') {\n\t\treturn tableExpression\n\t}\n\treturn new Literal(\n\t\tcteAliases.has(tableExpression)\n\t\t\t? wrapIdentifier(tableExpression)\n\t\t\t: `${wrapIdentifier(schema)}.${wrapIdentifier(tableExpression)}`,\n\t)\n}\n"],"names":[],"mappings":";AAEa,MAAA,iBAAiB,CAAC,UAAkB,MAAM,MAAM,QAAQ,MAAM,IAAI,IAAI;AAEtE,MAAA,eAAe,CAAC,KAAc,UAA4B;AACtE,MAAI,CAAC,OAAO;AACJ,WAAA;AAAA,EACR;AACO,SAAA,IAAI,QAAQ,IAAI,MAAM,SAAS,eAAe,KAAK,GAAG,IAAI,UAAU;AAC5E;AAEO,MAAM,gBAAgB,CAAC,iBAAmC,QAAgB,eAA4B;AACxG,MAAA,OAAO,oBAAoB,UAAU;AACjC,WAAA;AAAA,EACR;AACA,SAAO,IAAI;AAAA,IACV,WAAW,IAAI,eAAe,IAC3B,eAAe,eAAe,IAC9B,GAAG,eAAe,MAAM,CAAC,IAAI,eAAe,eAAe,CAAC;AAAA,EAAA;AAEjE;"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const withDatabaseAdvisoryLock = async (connection, lock, callback) => {
4
+ await connection.query(`select pg_advisory_lock(?)`, [lock]);
5
+ try {
6
+ return await callback();
7
+ } finally {
8
+ const result = await connection.query('select pg_advisory_unlock(?) as "lockReleased"', [lock]);
9
+ if (!result.rows[0].lockReleased) {
10
+ throw new Error("Failed to release migration lock");
11
+ }
12
+ }
13
+ };
14
+ exports.withDatabaseAdvisoryLock = withDatabaseAdvisoryLock;
15
+ //# sourceMappingURL=withDatabaseAdvisoryLock.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withDatabaseAdvisoryLock.cjs","sources":["../../../../../packages/database/src/utils/withDatabaseAdvisoryLock.ts"],"sourcesContent":["import { Connection } from '../client'\n\nexport const withDatabaseAdvisoryLock = async <Result>(\n\tconnection: Connection.ConnectionLike,\n\tlock: number,\n\tcallback: () => Result | Promise<Result>,\n): Promise<Result> => {\n\tawait connection.query(`select pg_advisory_lock(?)`, [lock])\n\ttry {\n\t\treturn await callback()\n\t} finally {\n\t\tconst result = await connection.query<{lockReleased: boolean}>('select pg_advisory_unlock(?) as \"lockReleased\"', [lock])\n\t\tif (!result.rows[0].lockReleased) {\n\t\t\tthrow new Error('Failed to release migration lock')\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAEO,MAAM,2BAA2B,OACvC,YACA,MACA,aACqB;AACrB,QAAM,WAAW,MAAM,8BAA8B,CAAC,IAAI,CAAC;AACvD,MAAA;AACH,WAAO,MAAM,SAAS;AAAA,EAAA,UACrB;AACD,UAAM,SAAS,MAAM,WAAW,MAA+B,kDAAkD,CAAC,IAAI,CAAC;AACvH,QAAI,CAAC,OAAO,KAAK,CAAC,EAAE,cAAc;AAC3B,YAAA,IAAI,MAAM,kCAAkC;AAAA,IACnD;AAAA,EACD;AACD;;"}
@@ -0,0 +1,15 @@
1
+ const withDatabaseAdvisoryLock = async (connection, lock, callback) => {
2
+ await connection.query(`select pg_advisory_lock(?)`, [lock]);
3
+ try {
4
+ return await callback();
5
+ } finally {
6
+ const result = await connection.query('select pg_advisory_unlock(?) as "lockReleased"', [lock]);
7
+ if (!result.rows[0].lockReleased) {
8
+ throw new Error("Failed to release migration lock");
9
+ }
10
+ }
11
+ };
12
+ export {
13
+ withDatabaseAdvisoryLock
14
+ };
15
+ //# sourceMappingURL=withDatabaseAdvisoryLock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withDatabaseAdvisoryLock.js","sources":["../../../../../packages/database/src/utils/withDatabaseAdvisoryLock.ts"],"sourcesContent":["import { Connection } from '../client'\n\nexport const withDatabaseAdvisoryLock = async <Result>(\n\tconnection: Connection.ConnectionLike,\n\tlock: number,\n\tcallback: () => Result | Promise<Result>,\n): Promise<Result> => {\n\tawait connection.query(`select pg_advisory_lock(?)`, [lock])\n\ttry {\n\t\treturn await callback()\n\t} finally {\n\t\tconst result = await connection.query<{lockReleased: boolean}>('select pg_advisory_unlock(?) as \"lockReleased\"', [lock])\n\t\tif (!result.rows[0].lockReleased) {\n\t\t\tthrow new Error('Failed to release migration lock')\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAEO,MAAM,2BAA2B,OACvC,YACA,MACA,aACqB;AACrB,QAAM,WAAW,MAAM,8BAA8B,CAAC,IAAI,CAAC;AACvD,MAAA;AACH,WAAO,MAAM,SAAS;AAAA,EAAA,UACrB;AACD,UAAM,SAAS,MAAM,WAAW,MAA+B,kDAAkD,CAAC,IAAI,CAAC;AACvH,QAAI,CAAC,OAAO,KAAK,CAAC,EAAE,cAAc;AAC3B,YAAA,IAAI,MAAM,kCAAkC;AAAA,IACnD;AAAA,EACD;AACD;"}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const Client = require("./src/client/Client.cjs");
4
+ const errorCodes = require("./src/client/errorCodes.cjs");
5
+ const errors = require("./src/client/errors.cjs");
6
+ const Connection = require("./src/client/Connection.cjs");
7
+ const EventManager = require("./src/client/EventManager.cjs");
8
+ const Pool = require("./src/client/Pool.cjs");
9
+ const Transaction = require("./src/client/Transaction.cjs");
10
+ const Compiler = require("./src/builders/Compiler.cjs");
11
+ const CaseStatement = require("./src/builders/CaseStatement.cjs");
12
+ const ConditionBuilder = require("./src/builders/ConditionBuilder.cjs");
13
+ const DeleteBuilder = require("./src/builders/DeleteBuilder.cjs");
14
+ const InsertBuilder = require("./src/builders/InsertBuilder.cjs");
15
+ const LimitByGroupWrapper = require("./src/builders/LimitByGroupWrapper.cjs");
16
+ const SelectBuilder = require("./src/builders/SelectBuilder.cjs");
17
+ const UpdateBuilder = require("./src/builders/UpdateBuilder.cjs");
18
+ const WindowFunction = require("./src/builders/WindowFunction.cjs");
19
+ const LockType = require("./src/builders/LockType.cjs");
20
+ const ConflictActionType = require("./src/builders/ConflictActionType.cjs");
21
+ const DatabaseMetadata = require("./src/metadata/DatabaseMetadata.cjs");
22
+ const DatabaseMetadataResolver = require("./src/metadata/DatabaseMetadataResolver.cjs");
23
+ const ForeignKeyConstraintMetadata = require("./src/metadata/ForeignKeyConstraintMetadata.cjs");
24
+ const IndexMetadata = require("./src/metadata/IndexMetadata.cjs");
25
+ const UniqueConstraintMetadata = require("./src/metadata/UniqueConstraintMetadata.cjs");
26
+ const DatabaseQuery = require("./src/queryable/DatabaseQuery.cjs");
27
+ const DatabaseQueryable = require("./src/queryable/DatabaseQueryable.cjs");
28
+ const Literal = require("./src/Literal.cjs");
29
+ const asyncIterableTransaction = require("./src/utils/asyncIterableTransaction.cjs");
30
+ const ConstraintHelper = require("./src/utils/ConstraintHelper.cjs");
31
+ const createDatabaseIfNotExists = require("./src/utils/createDatabaseIfNotExists.cjs");
32
+ const listen = require("./src/utils/listen.cjs");
33
+ require("./src/utils/Mutex.cjs");
34
+ const sql = require("./src/utils/sql.cjs");
35
+ const retryTransaction = require("./src/utils/retryTransaction.cjs");
36
+ const withDatabaseAdvisoryLock = require("./src/utils/withDatabaseAdvisoryLock.cjs");
37
+ const pgClientFactory = require("./src/utils/pgClientFactory.cjs");
38
+ exports.Client = Client.Client;
39
+ exports.ClientErrorCodes = errorCodes.ClientErrorCodes;
40
+ exports.ClientError = errors.ClientError;
41
+ exports.DatabaseError = errors.DatabaseError;
42
+ exports.ForeignKeyViolationError = errors.ForeignKeyViolationError;
43
+ exports.InvalidDataError = errors.InvalidDataError;
44
+ exports.NotNullViolationError = errors.NotNullViolationError;
45
+ exports.QueryError = errors.QueryError;
46
+ exports.SerializationFailureError = errors.SerializationFailureError;
47
+ exports.TransactionAbortedError = errors.TransactionAbortedError;
48
+ exports.UniqueViolationError = errors.UniqueViolationError;
49
+ Object.defineProperty(exports, "Connection", {
50
+ enumerable: true,
51
+ get: () => Connection.Connection
52
+ });
53
+ Object.defineProperty(exports, "EventManager", {
54
+ enumerable: true,
55
+ get: () => EventManager.EventManager
56
+ });
57
+ exports.AcquireTimeoutError = Pool.AcquireTimeoutError;
58
+ exports.Pool = Pool.Pool;
59
+ exports.PoolClosedError = Pool.PoolClosedError;
60
+ exports.PoolError = Pool.PoolError;
61
+ exports.poolStatsDescription = Pool.poolStatsDescription;
62
+ exports.Transaction = Transaction.Transaction;
63
+ exports.executeTransaction = Transaction.executeTransaction;
64
+ Object.defineProperty(exports, "Compiler", {
65
+ enumerable: true,
66
+ get: () => Compiler.Compiler
67
+ });
68
+ exports.CaseStatement = CaseStatement.CaseStatement;
69
+ exports.ConditionBuilder = ConditionBuilder.ConditionBuilder;
70
+ exports.Operator = ConditionBuilder.Operator;
71
+ exports.DeleteBuilder = DeleteBuilder.DeleteBuilder;
72
+ exports.InsertBuilder = InsertBuilder.InsertBuilder;
73
+ exports.LimitByGroupWrapper = LimitByGroupWrapper.LimitByGroupWrapper;
74
+ Object.defineProperty(exports, "SelectBuilder", {
75
+ enumerable: true,
76
+ get: () => SelectBuilder.SelectBuilder
77
+ });
78
+ exports.UpdateBuilder = UpdateBuilder.UpdateBuilder;
79
+ exports.WindowFunction = WindowFunction.WindowFunction;
80
+ exports.LockModifier = LockType.LockModifier;
81
+ exports.LockType = LockType.LockType;
82
+ exports.ConflictActionType = ConflictActionType.ConflictActionType;
83
+ exports.createDatabaseMetadata = DatabaseMetadata.createDatabaseMetadata;
84
+ exports.emptyDatabaseMetadata = DatabaseMetadata.emptyDatabaseMetadata;
85
+ exports.DatabaseMetadataResolver = DatabaseMetadataResolver.DatabaseMetadataResolver;
86
+ exports.ForeignKeyConstraintMetadataSet = ForeignKeyConstraintMetadata.ForeignKeyConstraintMetadataSet;
87
+ exports.ForeignKeyDeleteAction = ForeignKeyConstraintMetadata.ForeignKeyDeleteAction;
88
+ exports.IndexMetadataSet = IndexMetadata.IndexMetadataSet;
89
+ exports.UniqueConstraintMetadataSet = UniqueConstraintMetadata.UniqueConstraintMetadataSet;
90
+ exports.DatabaseQuery = DatabaseQuery.DatabaseQuery;
91
+ exports.DatabaseQueryable = DatabaseQueryable.DatabaseQueryable;
92
+ exports.Literal = Literal.Literal;
93
+ exports.asyncIterableTransaction = asyncIterableTransaction.asyncIterableTransaction;
94
+ exports.ConstraintHelper = ConstraintHelper.ConstraintHelper;
95
+ exports.createDatabaseIfNotExists = createDatabaseIfNotExists.createDatabaseIfNotExists;
96
+ exports.AcquiringListener = listen.AcquiringListener;
97
+ exports.Listener = listen.Listener;
98
+ exports.wrapIdentifier = sql.wrapIdentifier;
99
+ exports.retryTransaction = retryTransaction.retryTransaction;
100
+ exports.withDatabaseAdvisoryLock = withDatabaseAdvisoryLock.withDatabaseAdvisoryLock;
101
+ exports.createPgClientFactory = pgClientFactory.createPgClientFactory;
102
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,90 @@
1
+ import { Client } from "./src/client/Client.js";
2
+ import { ClientErrorCodes } from "./src/client/errorCodes.js";
3
+ import { ClientError, DatabaseError, ForeignKeyViolationError, InvalidDataError, NotNullViolationError, QueryError, SerializationFailureError, TransactionAbortedError, UniqueViolationError } from "./src/client/errors.js";
4
+ import { Connection } from "./src/client/Connection.js";
5
+ import { EventManager } from "./src/client/EventManager.js";
6
+ import { AcquireTimeoutError, Pool, PoolClosedError, PoolError, poolStatsDescription } from "./src/client/Pool.js";
7
+ import { Transaction, executeTransaction } from "./src/client/Transaction.js";
8
+ import { Compiler } from "./src/builders/Compiler.js";
9
+ import { CaseStatement } from "./src/builders/CaseStatement.js";
10
+ import { ConditionBuilder, Operator } from "./src/builders/ConditionBuilder.js";
11
+ import { DeleteBuilder } from "./src/builders/DeleteBuilder.js";
12
+ import { InsertBuilder } from "./src/builders/InsertBuilder.js";
13
+ import { LimitByGroupWrapper } from "./src/builders/LimitByGroupWrapper.js";
14
+ import { SelectBuilder } from "./src/builders/SelectBuilder.js";
15
+ import { UpdateBuilder } from "./src/builders/UpdateBuilder.js";
16
+ import { WindowFunction } from "./src/builders/WindowFunction.js";
17
+ import { LockModifier, LockType } from "./src/builders/LockType.js";
18
+ import { ConflictActionType } from "./src/builders/ConflictActionType.js";
19
+ import { createDatabaseMetadata, emptyDatabaseMetadata } from "./src/metadata/DatabaseMetadata.js";
20
+ import { DatabaseMetadataResolver } from "./src/metadata/DatabaseMetadataResolver.js";
21
+ import { ForeignKeyConstraintMetadataSet, ForeignKeyDeleteAction } from "./src/metadata/ForeignKeyConstraintMetadata.js";
22
+ import { IndexMetadataSet } from "./src/metadata/IndexMetadata.js";
23
+ import { UniqueConstraintMetadataSet } from "./src/metadata/UniqueConstraintMetadata.js";
24
+ import { DatabaseQuery } from "./src/queryable/DatabaseQuery.js";
25
+ import { DatabaseQueryable } from "./src/queryable/DatabaseQueryable.js";
26
+ import { Literal } from "./src/Literal.js";
27
+ import { asyncIterableTransaction } from "./src/utils/asyncIterableTransaction.js";
28
+ import { ConstraintHelper } from "./src/utils/ConstraintHelper.js";
29
+ import { createDatabaseIfNotExists } from "./src/utils/createDatabaseIfNotExists.js";
30
+ import { AcquiringListener, Listener } from "./src/utils/listen.js";
31
+ import "./src/utils/Mutex.js";
32
+ import { wrapIdentifier } from "./src/utils/sql.js";
33
+ import { retryTransaction } from "./src/utils/retryTransaction.js";
34
+ import { withDatabaseAdvisoryLock } from "./src/utils/withDatabaseAdvisoryLock.js";
35
+ import { createPgClientFactory } from "./src/utils/pgClientFactory.js";
36
+ export {
37
+ AcquireTimeoutError,
38
+ AcquiringListener,
39
+ CaseStatement,
40
+ Client,
41
+ ClientError,
42
+ ClientErrorCodes,
43
+ Compiler,
44
+ ConditionBuilder,
45
+ ConflictActionType,
46
+ Connection,
47
+ ConstraintHelper,
48
+ DatabaseError,
49
+ DatabaseMetadataResolver,
50
+ DatabaseQuery,
51
+ DatabaseQueryable,
52
+ DeleteBuilder,
53
+ EventManager,
54
+ ForeignKeyConstraintMetadataSet,
55
+ ForeignKeyDeleteAction,
56
+ ForeignKeyViolationError,
57
+ IndexMetadataSet,
58
+ InsertBuilder,
59
+ InvalidDataError,
60
+ LimitByGroupWrapper,
61
+ Listener,
62
+ Literal,
63
+ LockModifier,
64
+ LockType,
65
+ NotNullViolationError,
66
+ Operator,
67
+ Pool,
68
+ PoolClosedError,
69
+ PoolError,
70
+ QueryError,
71
+ SelectBuilder,
72
+ SerializationFailureError,
73
+ Transaction,
74
+ TransactionAbortedError,
75
+ UniqueConstraintMetadataSet,
76
+ UniqueViolationError,
77
+ UpdateBuilder,
78
+ WindowFunction,
79
+ asyncIterableTransaction,
80
+ createDatabaseIfNotExists,
81
+ createDatabaseMetadata,
82
+ createPgClientFactory,
83
+ emptyDatabaseMetadata,
84
+ executeTransaction,
85
+ poolStatsDescription,
86
+ retryTransaction,
87
+ withDatabaseAdvisoryLock,
88
+ wrapIdentifier
89
+ };
90
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ var __defProp = Object.defineProperty;
4
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
6
+ const _Literal = class _Literal2 {
7
+ constructor(sql, parameters = [], meta = {}) {
8
+ this.sql = sql;
9
+ this.parameters = parameters;
10
+ this.meta = meta;
11
+ }
12
+ append(literal) {
13
+ if (literal === _Literal2.empty) {
14
+ return this;
15
+ }
16
+ return new _Literal2(this.sql.trimLeft() + " " + literal.sql, [...this.parameters, ...literal.parameters]);
17
+ }
18
+ appendAll(literal, separator, prefixSuffix) {
19
+ const hasPrefixAndSuffix = prefixSuffix && literal.length > 0;
20
+ const prefix = hasPrefixAndSuffix ? prefixSuffix?.[0] : "";
21
+ const suffix = hasPrefixAndSuffix ? prefixSuffix?.[1] : "";
22
+ return new _Literal2(this.sql + prefix + literal.map((it) => it.sql).join(separator) + suffix, [
23
+ ...this.parameters,
24
+ ...literal.map((it) => it.parameters).reduce((acc, params) => [...acc, ...params], [])
25
+ ]);
26
+ }
27
+ appendString(sql) {
28
+ return new _Literal2((this.sql + sql).trimLeft(), this.parameters);
29
+ }
30
+ trim() {
31
+ return new _Literal2(this.sql.trim(), this.parameters);
32
+ }
33
+ };
34
+ __publicField(_Literal, "empty", new _Literal(""));
35
+ let Literal = _Literal;
36
+ exports.Literal = Literal;
37
+ //# sourceMappingURL=Literal.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Literal.cjs","sources":["../../../../packages/database/src/Literal.ts"],"sourcesContent":["export class Literal {\n\tstatic empty = new Literal('')\n\n\tconstructor(\n\t\tpublic readonly sql: string,\n\t\tpublic readonly parameters: readonly any[] = [],\n\t\tpublic readonly meta: Record<string, any> = {},\n\t) {}\n\n\tpublic append(literal: Literal) {\n\t\tif (literal === Literal.empty) {\n\t\t\treturn this\n\t\t}\n\t\treturn new Literal(this.sql.trimLeft() + ' ' + literal.sql, [...this.parameters, ...literal.parameters])\n\t}\n\n\tpublic appendAll(literal: Literal[], separator: string, prefixSuffix?: [string, string]) {\n\t\tconst hasPrefixAndSuffix = prefixSuffix && literal.length > 0\n\t\tconst prefix = hasPrefixAndSuffix ? prefixSuffix?.[0] : ''\n\t\tconst suffix = hasPrefixAndSuffix ? prefixSuffix?.[1] : ''\n\t\treturn new Literal(this.sql + prefix + literal.map(it => it.sql).join(separator) + suffix, [\n\t\t\t...this.parameters,\n\t\t\t...literal.map(it => it.parameters).reduce((acc, params) => [...acc, ...params], []),\n\t\t])\n\t}\n\n\tpublic appendString(sql: string) {\n\t\treturn new Literal((this.sql + sql).trimLeft(), this.parameters)\n\t}\n\n\tpublic trim(): Literal {\n\t\treturn new Literal(this.sql.trim(), this.parameters)\n\t}\n}\n"],"names":["_Literal"],"mappings":";;;;;AAAO,MAAM,WAAN,MAAMA,UAAQ;AAAA,EAGpB,YACiB,KACA,aAA6B,CAAA,GAC7B,OAA4B,CAAA,GAC3C;AAHe,SAAA,MAAA;AACA,SAAA,aAAA;AACA,SAAA,OAAA;AAAA,EACd;AAAA,EAEI,OAAO,SAAkB;AAC3B,QAAA,YAAYA,UAAQ,OAAO;AACvB,aAAA;AAAA,IACR;AACA,WAAO,IAAIA,UAAQ,KAAK,IAAI,SAAA,IAAa,MAAM,QAAQ,KAAK,CAAC,GAAG,KAAK,YAAY,GAAG,QAAQ,UAAU,CAAC;AAAA,EACxG;AAAA,EAEO,UAAU,SAAoB,WAAmB,cAAiC;AAClF,UAAA,qBAAqB,gBAAgB,QAAQ,SAAS;AAC5D,UAAM,SAAS,qBAAqB,eAAe,CAAC,IAAI;AACxD,UAAM,SAAS,qBAAqB,eAAe,CAAC,IAAI;AACxD,WAAO,IAAIA,UAAQ,KAAK,MAAM,SAAS,QAAQ,IAAI,CAAM,OAAA,GAAG,GAAG,EAAE,KAAK,SAAS,IAAI,QAAQ;AAAA,MAC1F,GAAG,KAAK;AAAA,MACR,GAAG,QAAQ,IAAI,QAAM,GAAG,UAAU,EAAE,OAAO,CAAC,KAAK,WAAW,CAAC,GAAG,KAAK,GAAG,MAAM,GAAG,EAAE;AAAA,IAAA,CACnF;AAAA,EACF;AAAA,EAEO,aAAa,KAAa;AACzB,WAAA,IAAIA,WAAS,KAAK,MAAM,KAAK,SAAS,GAAG,KAAK,UAAU;AAAA,EAChE;AAAA,EAEO,OAAgB;AACtB,WAAO,IAAIA,UAAQ,KAAK,IAAI,QAAQ,KAAK,UAAU;AAAA,EACpD;AACD;AAhCC,cADY,UACL,SAAQ,IAAI,SAAQ,EAAE,CAAA;AADvB,IAAM,UAAN;;"}