@axiumine/koa-utils 8.0.0 → 8.1.0

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 (392) hide show
  1. package/README.md +2 -0
  2. package/dist/lib/PostgreSQL/clock/CLOCK_SQL.d.mts +7 -0
  3. package/dist/lib/PostgreSQL/clock/CLOCK_SQL.mjs +8 -0
  4. package/dist/lib/PostgreSQL/clock/DB_NOW_SQL.d.mts +5 -0
  5. package/dist/lib/PostgreSQL/clock/DB_NOW_SQL.mjs +6 -0
  6. package/dist/lib/PostgreSQL/clock/IClock.d.mts +4 -0
  7. package/dist/lib/PostgreSQL/clock/IClock.mjs +2 -0
  8. package/dist/lib/PostgreSQL/clock/IDbClock.d.mts +11 -0
  9. package/dist/lib/PostgreSQL/clock/IDbClock.mjs +2 -0
  10. package/dist/lib/PostgreSQL/clock/IDbClockOptions.d.mts +11 -0
  11. package/dist/lib/PostgreSQL/clock/IDbClockOptions.mjs +2 -0
  12. package/dist/lib/PostgreSQL/clock/IDbClockSeam.d.mts +10 -0
  13. package/dist/lib/PostgreSQL/clock/IDbClockSeam.mjs +2 -0
  14. package/dist/lib/PostgreSQL/clock/createDbClock.d.mts +23 -0
  15. package/dist/lib/PostgreSQL/clock/createDbClock.mjs +54 -0
  16. package/dist/lib/PostgreSQL/clock/lockTaken.d.mts +11 -0
  17. package/dist/lib/PostgreSQL/clock/lockTaken.mjs +17 -0
  18. package/dist/lib/PostgreSQL/counter/IDbCounter.d.mts +9 -0
  19. package/dist/lib/PostgreSQL/counter/IDbCounter.mjs +2 -0
  20. package/dist/lib/PostgreSQL/error/DB_CLOCK_REASONS.d.mts +12 -0
  21. package/dist/lib/PostgreSQL/error/DB_CLOCK_REASONS.mjs +20 -0
  22. package/dist/lib/PostgreSQL/error/DB_CONNECT_REASONS.d.mts +11 -0
  23. package/dist/lib/PostgreSQL/error/DB_CONNECT_REASONS.mjs +12 -0
  24. package/dist/lib/PostgreSQL/error/DB_INTERNAL_REASONS.d.mts +23 -0
  25. package/dist/lib/PostgreSQL/error/DB_INTERNAL_REASONS.mjs +35 -0
  26. package/dist/lib/PostgreSQL/error/DB_PARSE_REASONS.d.mts +13 -0
  27. package/dist/lib/PostgreSQL/error/DB_PARSE_REASONS.mjs +14 -0
  28. package/dist/lib/PostgreSQL/error/DB_STATE_REASONS.d.mts +7 -0
  29. package/dist/lib/PostgreSQL/error/DB_STATE_REASONS.mjs +8 -0
  30. package/dist/lib/PostgreSQL/error/DB_TX_REASONS.d.mts +9 -0
  31. package/dist/lib/PostgreSQL/error/DB_TX_REASONS.mjs +10 -0
  32. package/dist/lib/PostgreSQL/error/DbClockError.d.mts +6 -0
  33. package/dist/lib/PostgreSQL/error/DbClockError.mjs +27 -0
  34. package/dist/lib/PostgreSQL/error/DbConnectError.d.mts +11 -0
  35. package/dist/lib/PostgreSQL/error/DbConnectError.mjs +18 -0
  36. package/dist/lib/PostgreSQL/error/DbParseError.d.mts +11 -0
  37. package/dist/lib/PostgreSQL/error/DbParseError.mjs +16 -0
  38. package/dist/lib/PostgreSQL/error/DbStateError.d.mts +10 -0
  39. package/dist/lib/PostgreSQL/error/DbStateError.mjs +14 -0
  40. package/dist/lib/PostgreSQL/error/DbTxError.d.mts +6 -0
  41. package/dist/lib/PostgreSQL/error/DbTxError.mjs +10 -0
  42. package/dist/lib/PostgreSQL/error/IConstraintEntry.d.mts +17 -0
  43. package/dist/lib/PostgreSQL/error/IConstraintEntry.mjs +2 -0
  44. package/dist/lib/PostgreSQL/error/IConstraintEntryBuilder.d.mts +20 -0
  45. package/dist/lib/PostgreSQL/error/IConstraintEntryBuilder.mjs +2 -0
  46. package/dist/lib/PostgreSQL/error/IConstraintTable.d.mts +7 -0
  47. package/dist/lib/PostgreSQL/error/IConstraintTable.mjs +2 -0
  48. package/dist/lib/PostgreSQL/error/IDbClockReason.d.mts +3 -0
  49. package/dist/lib/PostgreSQL/error/IDbClockReason.mjs +2 -0
  50. package/dist/lib/PostgreSQL/error/IDbConnectReason.d.mts +3 -0
  51. package/dist/lib/PostgreSQL/error/IDbConnectReason.mjs +2 -0
  52. package/dist/lib/PostgreSQL/error/IDbErrorCounter.d.mts +4 -0
  53. package/dist/lib/PostgreSQL/error/IDbErrorCounter.mjs +2 -0
  54. package/dist/lib/PostgreSQL/error/IDbErrorCounterName.d.mts +7 -0
  55. package/dist/lib/PostgreSQL/error/IDbErrorCounterName.mjs +2 -0
  56. package/dist/lib/PostgreSQL/error/IDbErrorFactory.d.mts +16 -0
  57. package/dist/lib/PostgreSQL/error/IDbErrorFactory.mjs +2 -0
  58. package/dist/lib/PostgreSQL/error/IDbInternalReason.d.mts +3 -0
  59. package/dist/lib/PostgreSQL/error/IDbInternalReason.mjs +2 -0
  60. package/dist/lib/PostgreSQL/error/IDbParseReason.d.mts +3 -0
  61. package/dist/lib/PostgreSQL/error/IDbParseReason.mjs +2 -0
  62. package/dist/lib/PostgreSQL/error/IDbStateReason.d.mts +3 -0
  63. package/dist/lib/PostgreSQL/error/IDbStateReason.mjs +2 -0
  64. package/dist/lib/PostgreSQL/error/IDbTxReason.d.mts +3 -0
  65. package/dist/lib/PostgreSQL/error/IDbTxReason.mjs +2 -0
  66. package/dist/lib/PostgreSQL/error/ILockOrderReason.d.mts +3 -0
  67. package/dist/lib/PostgreSQL/error/ILockOrderReason.mjs +2 -0
  68. package/dist/lib/PostgreSQL/error/IMapDbErrorOptions.d.mts +22 -0
  69. package/dist/lib/PostgreSQL/error/IMapDbErrorOptions.mjs +2 -0
  70. package/dist/lib/PostgreSQL/error/IRoleAssertionReason.d.mts +3 -0
  71. package/dist/lib/PostgreSQL/error/IRoleAssertionReason.mjs +2 -0
  72. package/dist/lib/PostgreSQL/error/IRoleAssertionSubject.d.mts +12 -0
  73. package/dist/lib/PostgreSQL/error/IRoleAssertionSubject.mjs +2 -0
  74. package/dist/lib/PostgreSQL/error/LOCK_ORDER_REASONS.d.mts +11 -0
  75. package/dist/lib/PostgreSQL/error/LOCK_ORDER_REASONS.mjs +12 -0
  76. package/dist/lib/PostgreSQL/error/LockOrderError.d.mts +6 -0
  77. package/dist/lib/PostgreSQL/error/LockOrderError.mjs +10 -0
  78. package/dist/lib/PostgreSQL/error/ROLE_ASSERT_REASONS.d.mts +21 -0
  79. package/dist/lib/PostgreSQL/error/ROLE_ASSERT_REASONS.mjs +35 -0
  80. package/dist/lib/PostgreSQL/error/RoleAssertionError.d.mts +19 -0
  81. package/dist/lib/PostgreSQL/error/RoleAssertionError.mjs +58 -0
  82. package/dist/lib/PostgreSQL/error/buildConstraintEntry.d.mts +15 -0
  83. package/dist/lib/PostgreSQL/error/buildConstraintEntry.mjs +16 -0
  84. package/dist/lib/PostgreSQL/error/constraintNameOf.d.mts +6 -0
  85. package/dist/lib/PostgreSQL/error/constraintNameOf.mjs +17 -0
  86. package/dist/lib/PostgreSQL/error/errorNameOf.d.mts +5 -0
  87. package/dist/lib/PostgreSQL/error/errorNameOf.mjs +12 -0
  88. package/dist/lib/PostgreSQL/error/lookupConstraint.d.mts +7 -0
  89. package/dist/lib/PostgreSQL/error/lookupConstraint.mjs +8 -0
  90. package/dist/lib/PostgreSQL/error/mapDbError.d.mts +28 -0
  91. package/dist/lib/PostgreSQL/error/mapDbError.mjs +52 -0
  92. package/dist/lib/PostgreSQL/error/sqlstateField.d.mts +4 -0
  93. package/dist/lib/PostgreSQL/error/sqlstateField.mjs +5 -0
  94. package/dist/lib/PostgreSQL/error/sqlstateOf.d.mts +5 -0
  95. package/dist/lib/PostgreSQL/error/sqlstateOf.mjs +12 -0
  96. package/dist/lib/PostgreSQL/guard/IAffectedResult.d.mts +4 -0
  97. package/dist/lib/PostgreSQL/guard/IAffectedResult.mjs +2 -0
  98. package/dist/lib/PostgreSQL/guard/IGuardCounter.d.mts +3 -0
  99. package/dist/lib/PostgreSQL/guard/IGuardCounter.mjs +2 -0
  100. package/dist/lib/PostgreSQL/guard/IVersionGuardCode.d.mts +5 -0
  101. package/dist/lib/PostgreSQL/guard/IVersionGuardCode.mjs +2 -0
  102. package/dist/lib/PostgreSQL/guard/IVersionGuardField.d.mts +3 -0
  103. package/dist/lib/PostgreSQL/guard/IVersionGuardField.mjs +2 -0
  104. package/dist/lib/PostgreSQL/guard/IVersionGuardInput.d.mts +29 -0
  105. package/dist/lib/PostgreSQL/guard/IVersionGuardInput.mjs +2 -0
  106. package/dist/lib/PostgreSQL/guard/VERSION_GUARD_FIELDS.d.mts +2 -0
  107. package/dist/lib/PostgreSQL/guard/VERSION_GUARD_FIELDS.mjs +3 -0
  108. package/dist/lib/PostgreSQL/guard/assertAffected.d.mts +10 -0
  109. package/dist/lib/PostgreSQL/guard/assertAffected.mjs +17 -0
  110. package/dist/lib/PostgreSQL/guard/guardVersion.d.mts +21 -0
  111. package/dist/lib/PostgreSQL/guard/guardVersion.mjs +47 -0
  112. package/dist/lib/PostgreSQL/lock/CLAIM_LIMIT_MAX.d.mts +2 -0
  113. package/dist/lib/PostgreSQL/lock/CLAIM_LIMIT_MAX.mjs +3 -0
  114. package/dist/lib/PostgreSQL/lock/IClaimRegistry.d.mts +6 -0
  115. package/dist/lib/PostgreSQL/lock/IClaimRegistry.mjs +2 -0
  116. package/dist/lib/PostgreSQL/lock/IClaimRequest.d.mts +7 -0
  117. package/dist/lib/PostgreSQL/lock/IClaimRequest.mjs +2 -0
  118. package/dist/lib/PostgreSQL/lock/ILockAdmission.d.mts +4 -0
  119. package/dist/lib/PostgreSQL/lock/ILockAdmission.mjs +2 -0
  120. package/dist/lib/PostgreSQL/lock/ILockOrderSpec.d.mts +19 -0
  121. package/dist/lib/PostgreSQL/lock/ILockOrderSpec.mjs +2 -0
  122. package/dist/lib/PostgreSQL/lock/ILockOrderTracker.d.mts +41 -0
  123. package/dist/lib/PostgreSQL/lock/ILockOrderTracker.mjs +2 -0
  124. package/dist/lib/PostgreSQL/lock/ILockTrackerConfig.d.mts +5 -0
  125. package/dist/lib/PostgreSQL/lock/ILockTrackerConfig.mjs +2 -0
  126. package/dist/lib/PostgreSQL/lock/ILockTrackerOptions.d.mts +7 -0
  127. package/dist/lib/PostgreSQL/lock/ILockTrackerOptions.mjs +2 -0
  128. package/dist/lib/PostgreSQL/lock/IRowLockMode.d.mts +3 -0
  129. package/dist/lib/PostgreSQL/lock/IRowLockMode.mjs +2 -0
  130. package/dist/lib/PostgreSQL/lock/ROW_LOCK_MODES.d.mts +2 -0
  131. package/dist/lib/PostgreSQL/lock/ROW_LOCK_MODES.mjs +3 -0
  132. package/dist/lib/PostgreSQL/lock/claimRowsSkipLocked.d.mts +16 -0
  133. package/dist/lib/PostgreSQL/lock/claimRowsSkipLocked.mjs +32 -0
  134. package/dist/lib/PostgreSQL/lock/createLockOrderTracker.d.mts +14 -0
  135. package/dist/lib/PostgreSQL/lock/createLockOrderTracker.mjs +60 -0
  136. package/dist/lib/PostgreSQL/lock/lockedRow.d.mts +7 -0
  137. package/dist/lib/PostgreSQL/lock/lockedRow.mjs +12 -0
  138. package/dist/lib/PostgreSQL/lock/lockedRows.d.mts +3 -0
  139. package/dist/lib/PostgreSQL/lock/lockedRows.mjs +8 -0
  140. package/dist/lib/PostgreSQL/lock/rowLockModeOf.d.mts +3 -0
  141. package/dist/lib/PostgreSQL/lock/rowLockModeOf.mjs +9 -0
  142. package/dist/lib/PostgreSQL/lock/uuidOf.d.mts +2 -0
  143. package/dist/lib/PostgreSQL/lock/uuidOf.mjs +10 -0
  144. package/dist/lib/PostgreSQL/lock/uuidsOf.d.mts +5 -0
  145. package/dist/lib/PostgreSQL/lock/uuidsOf.mjs +13 -0
  146. package/dist/lib/PostgreSQL/parse/IArrayParser.d.mts +2 -0
  147. package/dist/lib/PostgreSQL/parse/IArrayParser.mjs +2 -0
  148. package/dist/lib/PostgreSQL/parse/IDriverTypes.d.mts +4 -0
  149. package/dist/lib/PostgreSQL/parse/IDriverTypes.mjs +2 -0
  150. package/dist/lib/PostgreSQL/parse/IStringParser.d.mts +2 -0
  151. package/dist/lib/PostgreSQL/parse/IStringParser.mjs +2 -0
  152. package/dist/lib/PostgreSQL/parse/ITypeParserEntry.d.mts +9 -0
  153. package/dist/lib/PostgreSQL/parse/ITypeParserEntry.mjs +2 -0
  154. package/dist/lib/PostgreSQL/parse/TYPE_PARSERS.d.mts +12 -0
  155. package/dist/lib/PostgreSQL/parse/TYPE_PARSERS.mjs +38 -0
  156. package/dist/lib/PostgreSQL/parse/arrayOf.d.mts +7 -0
  157. package/dist/lib/PostgreSQL/parse/arrayOf.mjs +50 -0
  158. package/dist/lib/PostgreSQL/parse/createTypeRegistry.d.mts +13 -0
  159. package/dist/lib/PostgreSQL/parse/createTypeRegistry.mjs +26 -0
  160. package/dist/lib/PostgreSQL/parse/parseDate.d.mts +7 -0
  161. package/dist/lib/PostgreSQL/parse/parseDate.mjs +19 -0
  162. package/dist/lib/PostgreSQL/parse/parseInt8.d.mts +6 -0
  163. package/dist/lib/PostgreSQL/parse/parseInt8.mjs +17 -0
  164. package/dist/lib/PostgreSQL/parse/parseTime.d.mts +7 -0
  165. package/dist/lib/PostgreSQL/parse/parseTime.mjs +24 -0
  166. package/dist/lib/PostgreSQL/parse/parseTimestamptz.d.mts +17 -0
  167. package/dist/lib/PostgreSQL/parse/parseTimestamptz.mjs +79 -0
  168. package/dist/lib/PostgreSQL/parse/parseUuid.d.mts +3 -0
  169. package/dist/lib/PostgreSQL/parse/parseUuid.mjs +9 -0
  170. package/dist/lib/PostgreSQL/pool/DEFAULT_CONNECT_TIMEOUT_MS.d.mts +2 -0
  171. package/dist/lib/PostgreSQL/pool/DEFAULT_CONNECT_TIMEOUT_MS.mjs +3 -0
  172. package/dist/lib/PostgreSQL/pool/DEFAULT_KEEPALIVE_INITIAL_DELAY_MS.d.mts +2 -0
  173. package/dist/lib/PostgreSQL/pool/DEFAULT_KEEPALIVE_INITIAL_DELAY_MS.mjs +3 -0
  174. package/dist/lib/PostgreSQL/pool/ICreatePoolOptions.d.mts +28 -0
  175. package/dist/lib/PostgreSQL/pool/ICreatePoolOptions.mjs +2 -0
  176. package/dist/lib/PostgreSQL/pool/IDbDriver.d.mts +12 -0
  177. package/dist/lib/PostgreSQL/pool/IDbDriver.mjs +2 -0
  178. package/dist/lib/PostgreSQL/pool/IPoolCounter.d.mts +4 -0
  179. package/dist/lib/PostgreSQL/pool/IPoolCounter.mjs +2 -0
  180. package/dist/lib/PostgreSQL/pool/IPoolCounterName.d.mts +7 -0
  181. package/dist/lib/PostgreSQL/pool/IPoolCounterName.mjs +2 -0
  182. package/dist/lib/PostgreSQL/pool/IPoolEvents.d.mts +4 -0
  183. package/dist/lib/PostgreSQL/pool/IPoolEvents.mjs +2 -0
  184. package/dist/lib/PostgreSQL/pool/IPoolLogger.d.mts +8 -0
  185. package/dist/lib/PostgreSQL/pool/IPoolLogger.mjs +2 -0
  186. package/dist/lib/PostgreSQL/pool/REQUIRED_SESSION_TIME_ZONE.d.mts +2 -0
  187. package/dist/lib/PostgreSQL/pool/REQUIRED_SESSION_TIME_ZONE.mjs +3 -0
  188. package/dist/lib/PostgreSQL/pool/createPool.d.mts +31 -0
  189. package/dist/lib/PostgreSQL/pool/createPool.mjs +67 -0
  190. package/dist/lib/PostgreSQL/role/IAssertRoleOptions.d.mts +10 -0
  191. package/dist/lib/PostgreSQL/role/IAssertRoleOptions.mjs +2 -0
  192. package/dist/lib/PostgreSQL/role/IRoleAssertion.d.mts +6 -0
  193. package/dist/lib/PostgreSQL/role/IRoleAssertion.mjs +2 -0
  194. package/dist/lib/PostgreSQL/role/IRoleGrant.d.mts +19 -0
  195. package/dist/lib/PostgreSQL/role/IRoleGrant.mjs +2 -0
  196. package/dist/lib/PostgreSQL/role/IRolePool.d.mts +6 -0
  197. package/dist/lib/PostgreSQL/role/IRolePool.mjs +2 -0
  198. package/dist/lib/PostgreSQL/role/assertRole.d.mts +36 -0
  199. package/dist/lib/PostgreSQL/role/assertRole.mjs +54 -0
  200. package/dist/lib/PostgreSQL/tx/DEFAULT_LOCK_TIMEOUT_MS.d.mts +2 -0
  201. package/dist/lib/PostgreSQL/tx/DEFAULT_LOCK_TIMEOUT_MS.mjs +3 -0
  202. package/dist/lib/PostgreSQL/tx/IRetryDelay.d.mts +2 -0
  203. package/dist/lib/PostgreSQL/tx/IRetryDelay.mjs +2 -0
  204. package/dist/lib/PostgreSQL/tx/ITx.d.mts +9 -0
  205. package/dist/lib/PostgreSQL/tx/ITx.mjs +2 -0
  206. package/dist/lib/PostgreSQL/tx/ITxClient.d.mts +12 -0
  207. package/dist/lib/PostgreSQL/tx/ITxClient.mjs +2 -0
  208. package/dist/lib/PostgreSQL/tx/ITxCounter.d.mts +4 -0
  209. package/dist/lib/PostgreSQL/tx/ITxCounter.mjs +2 -0
  210. package/dist/lib/PostgreSQL/tx/ITxCounterName.d.mts +10 -0
  211. package/dist/lib/PostgreSQL/tx/ITxCounterName.mjs +2 -0
  212. package/dist/lib/PostgreSQL/tx/ITxFailureReason.d.mts +3 -0
  213. package/dist/lib/PostgreSQL/tx/ITxFailureReason.mjs +2 -0
  214. package/dist/lib/PostgreSQL/tx/ITxIsolation.d.mts +3 -0
  215. package/dist/lib/PostgreSQL/tx/ITxIsolation.mjs +2 -0
  216. package/dist/lib/PostgreSQL/tx/ITxOptions.d.mts +27 -0
  217. package/dist/lib/PostgreSQL/tx/ITxOptions.mjs +2 -0
  218. package/dist/lib/PostgreSQL/tx/ITxPool.d.mts +5 -0
  219. package/dist/lib/PostgreSQL/tx/ITxPool.mjs +2 -0
  220. package/dist/lib/PostgreSQL/tx/ITxResult.d.mts +6 -0
  221. package/dist/lib/PostgreSQL/tx/ITxResult.mjs +2 -0
  222. package/dist/lib/PostgreSQL/tx/MAX_LOCK_TIMEOUT_MS.d.mts +2 -0
  223. package/dist/lib/PostgreSQL/tx/MAX_LOCK_TIMEOUT_MS.mjs +3 -0
  224. package/dist/lib/PostgreSQL/tx/TX_FAILURE_REASONS.d.mts +7 -0
  225. package/dist/lib/PostgreSQL/tx/TX_FAILURE_REASONS.mjs +8 -0
  226. package/dist/lib/PostgreSQL/tx/TX_ISOLATION_LEVELS.d.mts +2 -0
  227. package/dist/lib/PostgreSQL/tx/TX_ISOLATION_LEVELS.mjs +3 -0
  228. package/dist/lib/PostgreSQL/tx/TX_RETRY_BASE_DELAY_MS.d.mts +2 -0
  229. package/dist/lib/PostgreSQL/tx/TX_RETRY_BASE_DELAY_MS.mjs +3 -0
  230. package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX.d.mts +2 -0
  231. package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX.mjs +3 -0
  232. package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX_CEILING.d.mts +2 -0
  233. package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX_CEILING.mjs +3 -0
  234. package/dist/lib/PostgreSQL/tx/defaultRetryDelay.d.mts +3 -0
  235. package/dist/lib/PostgreSQL/tx/defaultRetryDelay.mjs +4 -0
  236. package/dist/lib/PostgreSQL/tx/jitteredDelay.d.mts +7 -0
  237. package/dist/lib/PostgreSQL/tx/jitteredDelay.mjs +16 -0
  238. package/dist/lib/PostgreSQL/tx/withTx.d.mts +39 -0
  239. package/dist/lib/PostgreSQL/tx/withTx.mjs +41 -0
  240. package/dist/lib/PostgreSQL/url/IDatabaseUrlOptions.d.mts +10 -0
  241. package/dist/lib/PostgreSQL/url/IDatabaseUrlOptions.mjs +2 -0
  242. package/dist/lib/PostgreSQL/url/IDatabaseUrlReason.d.mts +14 -0
  243. package/dist/lib/PostgreSQL/url/IDatabaseUrlReason.mjs +2 -0
  244. package/dist/lib/PostgreSQL/url/LOOPBACK_HOSTS.d.mts +2 -0
  245. package/dist/lib/PostgreSQL/url/LOOPBACK_HOSTS.mjs +3 -0
  246. package/dist/lib/PostgreSQL/url/databaseUrlReason.d.mts +20 -0
  247. package/dist/lib/PostgreSQL/url/databaseUrlReason.mjs +99 -0
  248. package/dist/lib/PostgreSQL/url/isAbsolutePath.d.mts +2 -0
  249. package/dist/lib/PostgreSQL/url/isAbsolutePath.mjs +14 -0
  250. package/dist/lib/PostgreSQL/url/isValidHost.d.mts +6 -0
  251. package/dist/lib/PostgreSQL/url/isValidHost.mjs +20 -0
  252. package/dist/private/lib/PostgreSQL/ICivilDate.d.mts +6 -0
  253. package/dist/private/lib/PostgreSQL/ICivilDate.mjs +2 -0
  254. package/dist/private/lib/PostgreSQL/IClientConstructor.d.mts +3 -0
  255. package/dist/private/lib/PostgreSQL/IClientConstructor.mjs +2 -0
  256. package/dist/private/lib/PostgreSQL/IClientShape.d.mts +10 -0
  257. package/dist/private/lib/PostgreSQL/IClientShape.mjs +2 -0
  258. package/dist/private/lib/PostgreSQL/IClockSlot.d.mts +11 -0
  259. package/dist/private/lib/PostgreSQL/IClockSlot.mjs +2 -0
  260. package/dist/private/lib/PostgreSQL/IConnectCallback.d.mts +2 -0
  261. package/dist/private/lib/PostgreSQL/IConnectCallback.mjs +2 -0
  262. package/dist/private/lib/PostgreSQL/IConnectSettings.d.mts +8 -0
  263. package/dist/private/lib/PostgreSQL/IConnectSettings.mjs +2 -0
  264. package/dist/private/lib/PostgreSQL/IHelperRank.d.mts +5 -0
  265. package/dist/private/lib/PostgreSQL/IHelperRank.mjs +2 -0
  266. package/dist/private/lib/PostgreSQL/IInternalSink.d.mts +9 -0
  267. package/dist/private/lib/PostgreSQL/IInternalSink.mjs +2 -0
  268. package/dist/private/lib/PostgreSQL/ILockOrderPlan.d.mts +8 -0
  269. package/dist/private/lib/PostgreSQL/ILockOrderPlan.mjs +2 -0
  270. package/dist/private/lib/PostgreSQL/IModeOrder.d.mts +7 -0
  271. package/dist/private/lib/PostgreSQL/IModeOrder.mjs +2 -0
  272. package/dist/private/lib/PostgreSQL/IPostgresState.d.mts +9 -0
  273. package/dist/private/lib/PostgreSQL/IPostgresState.mjs +2 -0
  274. package/dist/private/lib/PostgreSQL/IRoleCheck.d.mts +4 -0
  275. package/dist/private/lib/PostgreSQL/IRoleCheck.mjs +2 -0
  276. package/dist/private/lib/PostgreSQL/IRoleColumnCheck.d.mts +7 -0
  277. package/dist/private/lib/PostgreSQL/IRoleColumnCheck.mjs +2 -0
  278. package/dist/private/lib/PostgreSQL/IRoleObjectCheck.d.mts +6 -0
  279. package/dist/private/lib/PostgreSQL/IRoleObjectCheck.mjs +2 -0
  280. package/dist/private/lib/PostgreSQL/IRolePlan.d.mts +7 -0
  281. package/dist/private/lib/PostgreSQL/IRolePlan.mjs +2 -0
  282. package/dist/private/lib/PostgreSQL/IRoleRow.d.mts +2 -0
  283. package/dist/private/lib/PostgreSQL/IRoleRow.mjs +2 -0
  284. package/dist/private/lib/PostgreSQL/ITrackerState.d.mts +10 -0
  285. package/dist/private/lib/PostgreSQL/ITrackerState.mjs +2 -0
  286. package/dist/private/lib/PostgreSQL/ITxHandleState.d.mts +6 -0
  287. package/dist/private/lib/PostgreSQL/ITxHandleState.mjs +2 -0
  288. package/dist/private/lib/PostgreSQL/ITxSettings.d.mts +14 -0
  289. package/dist/private/lib/PostgreSQL/ITxSettings.mjs +2 -0
  290. package/dist/private/lib/PostgreSQL/POSTGRES_STATE_KEY.d.mts +5 -0
  291. package/dist/private/lib/PostgreSQL/POSTGRES_STATE_KEY.mjs +6 -0
  292. package/dist/private/lib/PostgreSQL/POSTGRES_STATE_LAYOUT.d.mts +6 -0
  293. package/dist/private/lib/PostgreSQL/POSTGRES_STATE_LAYOUT.mjs +7 -0
  294. package/dist/private/lib/PostgreSQL/ROLE_ATTRIBUTES.d.mts +2 -0
  295. package/dist/private/lib/PostgreSQL/ROLE_ATTRIBUTES.mjs +9 -0
  296. package/dist/private/lib/PostgreSQL/ROLE_CATALOG_SQL.d.mts +26 -0
  297. package/dist/private/lib/PostgreSQL/ROLE_CATALOG_SQL.mjs +84 -0
  298. package/dist/private/lib/PostgreSQL/ROLE_PRIVILEGES.d.mts +2 -0
  299. package/dist/private/lib/PostgreSQL/ROLE_PRIVILEGES.mjs +7 -0
  300. package/dist/private/lib/PostgreSQL/TX_BEGIN_STATEMENTS.d.mts +7 -0
  301. package/dist/private/lib/PostgreSQL/TX_BEGIN_STATEMENTS.mjs +11 -0
  302. package/dist/private/lib/PostgreSQL/admitLock.d.mts +10 -0
  303. package/dist/private/lib/PostgreSQL/admitLock.mjs +33 -0
  304. package/dist/private/lib/PostgreSQL/assertPoolOptions.d.mts +12 -0
  305. package/dist/private/lib/PostgreSQL/assertPoolOptions.mjs +19 -0
  306. package/dist/private/lib/PostgreSQL/assertVersionGuardInput.d.mts +6 -0
  307. package/dist/private/lib/PostgreSQL/assertVersionGuardInput.mjs +14 -0
  308. package/dist/private/lib/PostgreSQL/catalogFlag.d.mts +2 -0
  309. package/dist/private/lib/PostgreSQL/catalogFlag.mjs +7 -0
  310. package/dist/private/lib/PostgreSQL/catalogRow.d.mts +4 -0
  311. package/dist/private/lib/PostgreSQL/catalogRow.mjs +11 -0
  312. package/dist/private/lib/PostgreSQL/catalogRows.d.mts +8 -0
  313. package/dist/private/lib/PostgreSQL/catalogRows.mjs +12 -0
  314. package/dist/private/lib/PostgreSQL/catalogText.d.mts +2 -0
  315. package/dist/private/lib/PostgreSQL/catalogText.mjs +7 -0
  316. package/dist/private/lib/PostgreSQL/checkRoleOnClient.d.mts +10 -0
  317. package/dist/private/lib/PostgreSQL/checkRoleOnClient.mjs +31 -0
  318. package/dist/private/lib/PostgreSQL/checkedClient.d.mts +8 -0
  319. package/dist/private/lib/PostgreSQL/checkedClient.mjs +22 -0
  320. package/dist/private/lib/PostgreSQL/civilCalendar.d.mts +13 -0
  321. package/dist/private/lib/PostgreSQL/civilCalendar.mjs +48 -0
  322. package/dist/private/lib/PostgreSQL/clockInstant.d.mts +11 -0
  323. package/dist/private/lib/PostgreSQL/clockInstant.mjs +18 -0
  324. package/dist/private/lib/PostgreSQL/clockSlot.d.mts +3 -0
  325. package/dist/private/lib/PostgreSQL/clockSlot.mjs +11 -0
  326. package/dist/private/lib/PostgreSQL/clockStatement.d.mts +6 -0
  327. package/dist/private/lib/PostgreSQL/clockStatement.mjs +22 -0
  328. package/dist/private/lib/PostgreSQL/connectAndCheck.d.mts +8 -0
  329. package/dist/private/lib/PostgreSQL/connectAndCheck.mjs +47 -0
  330. package/dist/private/lib/PostgreSQL/constraintDetails.d.mts +7 -0
  331. package/dist/private/lib/PostgreSQL/constraintDetails.mjs +21 -0
  332. package/dist/private/lib/PostgreSQL/constraintField.d.mts +4 -0
  333. package/dist/private/lib/PostgreSQL/constraintField.mjs +5 -0
  334. package/dist/private/lib/PostgreSQL/errorCodeOf.d.mts +2 -0
  335. package/dist/private/lib/PostgreSQL/errorCodeOf.mjs +7 -0
  336. package/dist/private/lib/PostgreSQL/internalFailure.d.mts +9 -0
  337. package/dist/private/lib/PostgreSQL/internalFailure.mjs +10 -0
  338. package/dist/private/lib/PostgreSQL/isNameList.d.mts +2 -0
  339. package/dist/private/lib/PostgreSQL/isNameList.mjs +6 -0
  340. package/dist/private/lib/PostgreSQL/isOneOf.d.mts +2 -0
  341. package/dist/private/lib/PostgreSQL/isOneOf.mjs +5 -0
  342. package/dist/private/lib/PostgreSQL/isQualifiedName.d.mts +2 -0
  343. package/dist/private/lib/PostgreSQL/isQualifiedName.mjs +7 -0
  344. package/dist/private/lib/PostgreSQL/isRoleName.d.mts +2 -0
  345. package/dist/private/lib/PostgreSQL/isRoleName.mjs +7 -0
  346. package/dist/private/lib/PostgreSQL/lockOrderPlan.d.mts +8 -0
  347. package/dist/private/lib/PostgreSQL/lockOrderPlan.mjs +66 -0
  348. package/dist/private/lib/PostgreSQL/mapTypedError.d.mts +3 -0
  349. package/dist/private/lib/PostgreSQL/mapTypedError.mjs +28 -0
  350. package/dist/private/lib/PostgreSQL/mapViolation.d.mts +3 -0
  351. package/dist/private/lib/PostgreSQL/mapViolation.mjs +32 -0
  352. package/dist/private/lib/PostgreSQL/membershipOutsider.d.mts +7 -0
  353. package/dist/private/lib/PostgreSQL/membershipOutsider.mjs +17 -0
  354. package/dist/private/lib/PostgreSQL/missingColumn.d.mts +9 -0
  355. package/dist/private/lib/PostgreSQL/missingColumn.mjs +15 -0
  356. package/dist/private/lib/PostgreSQL/missingGrant.d.mts +5 -0
  357. package/dist/private/lib/PostgreSQL/missingGrant.mjs +7 -0
  358. package/dist/private/lib/PostgreSQL/missingObject.d.mts +10 -0
  359. package/dist/private/lib/PostgreSQL/missingObject.mjs +14 -0
  360. package/dist/private/lib/PostgreSQL/poolUrlSecrets.d.mts +8 -0
  361. package/dist/private/lib/PostgreSQL/poolUrlSecrets.mjs +41 -0
  362. package/dist/private/lib/PostgreSQL/postgresState.d.mts +7 -0
  363. package/dist/private/lib/PostgreSQL/postgresState.mjs +32 -0
  364. package/dist/private/lib/PostgreSQL/rankCheckOption.d.mts +2 -0
  365. package/dist/private/lib/PostgreSQL/rankCheckOption.mjs +7 -0
  366. package/dist/private/lib/PostgreSQL/readField.d.mts +5 -0
  367. package/dist/private/lib/PostgreSQL/readField.mjs +10 -0
  368. package/dist/private/lib/PostgreSQL/roleCheckOf.d.mts +7 -0
  369. package/dist/private/lib/PostgreSQL/roleCheckOf.mjs +39 -0
  370. package/dist/private/lib/PostgreSQL/roleFailureSubject.d.mts +7 -0
  371. package/dist/private/lib/PostgreSQL/roleFailureSubject.mjs +12 -0
  372. package/dist/private/lib/PostgreSQL/rolePlan.d.mts +7 -0
  373. package/dist/private/lib/PostgreSQL/rolePlan.mjs +26 -0
  374. package/dist/private/lib/PostgreSQL/runRoleChecks.d.mts +17 -0
  375. package/dist/private/lib/PostgreSQL/runRoleChecks.mjs +48 -0
  376. package/dist/private/lib/PostgreSQL/runTxAttempt.d.mts +12 -0
  377. package/dist/private/lib/PostgreSQL/runTxAttempt.mjs +50 -0
  378. package/dist/private/lib/PostgreSQL/runTxBody.d.mts +11 -0
  379. package/dist/private/lib/PostgreSQL/runTxBody.mjs +19 -0
  380. package/dist/private/lib/PostgreSQL/runTxWithRetries.d.mts +10 -0
  381. package/dist/private/lib/PostgreSQL/runTxWithRetries.mjs +31 -0
  382. package/dist/private/lib/PostgreSQL/scrubSecrets.d.mts +2 -0
  383. package/dist/private/lib/PostgreSQL/scrubSecrets.mjs +6 -0
  384. package/dist/private/lib/PostgreSQL/txFailure.d.mts +4 -0
  385. package/dist/private/lib/PostgreSQL/txFailure.mjs +7 -0
  386. package/dist/private/lib/PostgreSQL/txHandle.d.mts +9 -0
  387. package/dist/private/lib/PostgreSQL/txHandle.mjs +26 -0
  388. package/dist/private/lib/PostgreSQL/txSettings.d.mts +7 -0
  389. package/dist/private/lib/PostgreSQL/txSettings.mjs +48 -0
  390. package/dist/private/lib/PostgreSQL/versionText.d.mts +5 -0
  391. package/dist/private/lib/PostgreSQL/versionText.mjs +12 -0
  392. package/package.json +501 -1
@@ -0,0 +1,3 @@
1
+ import type { VERSION_GUARD_FIELDS } from './VERSION_GUARD_FIELDS.mjs';
2
+ /** One of {@link VERSION_GUARD_FIELDS}. */
3
+ export type IVersionGuardField = (typeof VERSION_GUARD_FIELDS)[number];
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IVersionGuardField.mjs.map
@@ -0,0 +1,29 @@
1
+ import type { IDbErrorFactory } from "../error/IDbErrorFactory.mjs";
2
+ import type { IPoolLogger } from "../pool/IPoolLogger.mjs";
3
+ import type { IGuardCounter } from './IGuardCounter.mjs';
4
+ import type { IVersionGuardField } from './IVersionGuardField.mjs';
5
+ /** The input of `guardVersion`. */
6
+ export interface IVersionGuardInput<TError extends Error = Error> {
7
+ /**
8
+ * The statement that reads the row again, in the transaction of the failed update. It carries the visibility predicate
9
+ * of the actor (for a row of a group: the actor is an active member of it) and the id, and answers no row when the row
10
+ * is absent or the actor may not see it, and one row with the column named by `field` otherwise. The text is a
11
+ * literal; the values are parameters.
12
+ */
13
+ readonly reread: {
14
+ readonly text: string;
15
+ readonly values?: readonly unknown[];
16
+ };
17
+ /** The version (or rev) that the failed update was guarded with: the one the client sent. */
18
+ readonly expected: number;
19
+ /** The guarded column: `version` (`STALE_VERSION`) or `rev` (`STALE_REV`). */
20
+ readonly field: IVersionGuardField;
21
+ /** The kind of row, for `NOT_FOUND` (`order`, `membership`, ...): the details are `{ entity }`. */
22
+ readonly entity: string;
23
+ /** Builds every error `guardVersion` answers: `make` for `NOT_FOUND`, `STALE_VERSION` and `STALE_REV`, `internal` for the rest. */
24
+ readonly errors: Pick<IDbErrorFactory<TError>, 'make' | 'internal'>;
25
+ /** Where the internal cases are logged; only `error` is called. */
26
+ readonly logger: Pick<IPoolLogger, 'error'>;
27
+ /** Where `guardVersion` counts. Default: nowhere. */
28
+ readonly counter?: IGuardCounter;
29
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IVersionGuardInput.mjs.map
@@ -0,0 +1,2 @@
1
+ /** The stale vocabulary of a guarded column: `version` gives the code `STALE_VERSION`, `rev` gives `STALE_REV`. */
2
+ export declare const VERSION_GUARD_FIELDS: readonly ["version", "rev"];
@@ -0,0 +1,3 @@
1
+ /** The stale vocabulary of a guarded column: `version` gives the code `STALE_VERSION`, `rev` gives `STALE_REV`. */
2
+ export const VERSION_GUARD_FIELDS = ['version', 'rev'];
3
+ //# sourceMappingURL=VERSION_GUARD_FIELDS.mjs.map
@@ -0,0 +1,10 @@
1
+ import type { IAffectedResult } from './IAffectedResult.mjs';
2
+ /**
3
+ * Throws `onMismatch` unless the statement affected exactly `expected` rows. `onMismatch` is the error to throw, or a
4
+ * function that builds it (so that a call that succeeds builds no error); it comes from the caller, built with the
5
+ * caller's own error family, so nothing here imports one. A count the server did not report (`null`, the answer of a
6
+ * statement that is not a `SELECT`, `INSERT`, `UPDATE` or `DELETE`) is not `expected`: nothing was proved, so nothing is
7
+ * reported as a success. `expected` is a whole number from 0; anything else is a `TypeError`, thrown before the count is
8
+ * read.
9
+ */
10
+ export declare function assertAffected(result: IAffectedResult, expected: number, onMismatch: Error | (() => Error)): void;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Throws `onMismatch` unless the statement affected exactly `expected` rows. `onMismatch` is the error to throw, or a
3
+ * function that builds it (so that a call that succeeds builds no error); it comes from the caller, built with the
4
+ * caller's own error family, so nothing here imports one. A count the server did not report (`null`, the answer of a
5
+ * statement that is not a `SELECT`, `INSERT`, `UPDATE` or `DELETE`) is not `expected`: nothing was proved, so nothing is
6
+ * reported as a success. `expected` is a whole number from 0; anything else is a `TypeError`, thrown before the count is
7
+ * read.
8
+ */
9
+ export function assertAffected(result, expected, onMismatch) {
10
+ if (!Number.isSafeInteger(expected) || expected < 0) {
11
+ throw new TypeError('expected must be a whole number of rows from 0');
12
+ }
13
+ if (result.rowCount === expected)
14
+ return;
15
+ throw typeof onMismatch === 'function' ? onMismatch() : onMismatch;
16
+ }
17
+ //# sourceMappingURL=assertAffected.mjs.map
@@ -0,0 +1,21 @@
1
+ import type { ITx } from "../tx/ITx.mjs";
2
+ import type { IVersionGuardInput } from './IVersionGuardInput.mjs';
3
+ /**
4
+ * Says why an update guarded by `WHERE id = $1 AND version = $2` (or `rev`) affected no row, and answers the error for the
5
+ * caller to throw (it does not throw it, so `throw await guardVersion(...)` ends the flow for the compiler too):
6
+ *
7
+ * - `errors.make('NOT_FOUND', { entity })` when the re-read finds no row: the row is absent, or the actor may not see it.
8
+ * The two cases are one answer on purpose, so a call by id never confirms that a row exists to someone who may not see
9
+ * it, and a stale version of such a row is `NOT_FOUND`, never `STALE_VERSION`;
10
+ * - `errors.make('STALE_VERSION')` (`field` `version`) or `errors.make('STALE_REV')` (`field` `rev`) when the actor sees
11
+ * the row and it has another version than `expected`;
12
+ * - `errors.internal('VERSION_UNCHANGED')` when the actor sees the row and it still has `expected`: the update missed for
13
+ * a reason this guard cannot name, which a version-only guard should not have;
14
+ * - `errors.internal('REREAD_UNREADABLE')` when the statement answered more than one row or no readable column.
15
+ *
16
+ * A failure of the re-read itself is thrown unchanged, for `mapDbError` or `withTx` to classify. Call it in the
17
+ * transaction of the update, so that the re-read sees what the update saw. It builds no SQL and logs no bound value: the
18
+ * statement runs as given, a literal with parameters written by the caller, who owns the table and the visibility rule.
19
+ * `TypeError` for a `field`, an `expected` or an `entity` out of shape, before any statement.
20
+ */
21
+ export declare function guardVersion<TError extends Error>(tx: Pick<ITx, 'query'>, input: IVersionGuardInput<TError>): Promise<TError>;
@@ -0,0 +1,47 @@
1
+ import { assertVersionGuardInput } from "../../../private/lib/PostgreSQL/assertVersionGuardInput.mjs";
2
+ import { internalFailure } from "../../../private/lib/PostgreSQL/internalFailure.mjs";
3
+ import { readField } from "../../../private/lib/PostgreSQL/readField.mjs";
4
+ import { versionText } from "../../../private/lib/PostgreSQL/versionText.mjs";
5
+ /** Logs, counts and builds the internal error for a re-read that cannot decide. */
6
+ function undecided(input, reason) {
7
+ return internalFailure(input, 'db_error_internal_total', 'version guard cannot decide', {
8
+ reason,
9
+ field: input.field,
10
+ entity: input.entity
11
+ });
12
+ }
13
+ /**
14
+ * Says why an update guarded by `WHERE id = $1 AND version = $2` (or `rev`) affected no row, and answers the error for the
15
+ * caller to throw (it does not throw it, so `throw await guardVersion(...)` ends the flow for the compiler too):
16
+ *
17
+ * - `errors.make('NOT_FOUND', { entity })` when the re-read finds no row: the row is absent, or the actor may not see it.
18
+ * The two cases are one answer on purpose, so a call by id never confirms that a row exists to someone who may not see
19
+ * it, and a stale version of such a row is `NOT_FOUND`, never `STALE_VERSION`;
20
+ * - `errors.make('STALE_VERSION')` (`field` `version`) or `errors.make('STALE_REV')` (`field` `rev`) when the actor sees
21
+ * the row and it has another version than `expected`;
22
+ * - `errors.internal('VERSION_UNCHANGED')` when the actor sees the row and it still has `expected`: the update missed for
23
+ * a reason this guard cannot name, which a version-only guard should not have;
24
+ * - `errors.internal('REREAD_UNREADABLE')` when the statement answered more than one row or no readable column.
25
+ *
26
+ * A failure of the re-read itself is thrown unchanged, for `mapDbError` or `withTx` to classify. Call it in the
27
+ * transaction of the update, so that the re-read sees what the update saw. It builds no SQL and logs no bound value: the
28
+ * statement runs as given, a literal with parameters written by the caller, who owns the table and the visibility rule.
29
+ * `TypeError` for a `field`, an `expected` or an `entity` out of shape, before any statement.
30
+ */
31
+ export async function guardVersion(tx, input) {
32
+ assertVersionGuardInput(input);
33
+ const answer = await tx.query(input.reread.text, input.reread.values);
34
+ const [row, ...more] = answer.rows;
35
+ if (row === undefined)
36
+ return input.errors.make('NOT_FOUND', { entity: input.entity });
37
+ if (more.length > 0)
38
+ return undecided(input, 'REREAD_UNREADABLE');
39
+ const current = versionText(readField(row, input.field));
40
+ if (current === undefined)
41
+ return undecided(input, 'REREAD_UNREADABLE');
42
+ if (current === String(input.expected))
43
+ return undecided(input, 'VERSION_UNCHANGED');
44
+ const stale = input.field === 'version' ? 'STALE_VERSION' : 'STALE_REV';
45
+ return input.errors.make(stale);
46
+ }
47
+ //# sourceMappingURL=guardVersion.mjs.map
@@ -0,0 +1,2 @@
1
+ /** The most rows one claim takes. */
2
+ export declare const CLAIM_LIMIT_MAX = 1000;
@@ -0,0 +1,3 @@
1
+ /** The most rows one claim takes. */
2
+ export const CLAIM_LIMIT_MAX = 1000;
3
+ //# sourceMappingURL=CLAIM_LIMIT_MAX.mjs.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The closed lists of `claimRowsSkipLocked`: a table name, then a predicate name, then the whole statement. The statements
3
+ * are yours and are written in your code, never built from input; the kit only picks one by two names that must be own
4
+ * keys here. Each statement takes the number of rows as `$1`.
5
+ */
6
+ export type IClaimRegistry = Readonly<Record<string, Readonly<Record<string, string>>>>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IClaimRegistry.mjs.map
@@ -0,0 +1,7 @@
1
+ /** What `claimRowsSkipLocked` takes: two names from the closed lists and a bound on the rows. */
2
+ export interface IClaimRequest {
3
+ readonly table: string;
4
+ readonly predicate: string;
5
+ /** A whole number from 1 to `CLAIM_LIMIT_MAX`. */
6
+ readonly limit: number;
7
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IClaimRequest.mjs.map
@@ -0,0 +1,4 @@
1
+ /** A rank that passed the check and is waiting for its statement: hand it to `record` when the lock was taken. */
2
+ export interface ILockAdmission {
3
+ readonly rank: number;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ILockAdmission.mjs.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * What `createLockOrderTracker` takes: the order of the locks of each mode, the rank each helper takes, and the mode a
3
+ * transaction is in until it says otherwise. The names are yours (`'standard'`, `'group'`, `'lockGroupShare'`); the kit
4
+ * ships no order. The spec is checked once, when the tracker is made, and copied: changing the object afterwards changes
5
+ * nothing.
6
+ */
7
+ export interface ILockOrderSpec<TMode extends string = string, THelper extends string = string> {
8
+ /** The ranks of each mode, lowest first, as distinct names. The rank of a name is its position, counted from 1. */
9
+ readonly orders: Readonly<Record<TMode, readonly string[]>>;
10
+ /**
11
+ * The rank each helper takes, by mode. A mode left out, or `undefined`, means the helper does not belong to that
12
+ * order. A helper must take a rank in at least one mode, and the name must be in the order of that mode.
13
+ */
14
+ readonly helpers: Readonly<Record<THelper, {
15
+ readonly [TKey in NoInfer<TMode>]?: string | undefined;
16
+ }>>;
17
+ /** The mode of a transaction that was not given one. */
18
+ readonly defaultMode: NoInfer<TMode>;
19
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ILockOrderSpec.mjs.map
@@ -0,0 +1,41 @@
1
+ import type { ILockAdmission } from './ILockAdmission.mjs';
2
+ import type { ILockTrackerConfig } from './ILockTrackerConfig.mjs';
3
+ import type { ILockTrackerOptions } from './ILockTrackerOptions.mjs';
4
+ /**
5
+ * The tracker of the order of the locks in a transaction, made by `createLockOrderTracker`. It keeps one number per
6
+ * transaction handle, in a `WeakMap` that belongs to this tracker, so a retry (which gets a fresh handle) starts again and
7
+ * nothing is kept past the transaction. Two trackers are two separate sets of state. A helper of yours calls `admit` before
8
+ * its statement, `record` when the statement took the lock, and `hold` for a lock that a later check wants to read.
9
+ */
10
+ export interface ILockOrderTracker<TMode extends string = string, THelper extends string = string> {
11
+ /**
12
+ * Sets the default of the rank check. Call it once at start, with a value you computed (the tracker reads no
13
+ * environment variable). With nothing, it restores `true`. It does not touch a transaction that is already tracked.
14
+ * A `TypeError` for a `rankCheck` that is not a boolean.
15
+ */
16
+ configure(config?: ILockTrackerConfig): void;
17
+ /**
18
+ * Puts the transaction in a mode and/or forces its rank check. Call it right after `withTx` opened the transaction and
19
+ * before the first lock; after a recorded lock it throws `LockOrderError` `TRACKER_STARTED`. A `TypeError` for a mode
20
+ * that is not in the spec or a `rankCheck` that is not a boolean.
21
+ */
22
+ track(tx: object, options?: ILockTrackerOptions<TMode>): void;
23
+ /**
24
+ * Checks the request against the order of the mode of the transaction, before the statement, and answers the rank to
25
+ * record, or `undefined` when the helper has no rank in this mode and the check is off. Nothing is recorded yet. A
26
+ * `LockOrderError` for a rank lower than one already recorded (`RANK_INVERSION`) and for a helper that does not belong
27
+ * to the mode (`MODE_REQUIRED`, `NOT_IN_MODE_ORDER`), when the check is on. A `TypeError` for a helper the spec does not
28
+ * name.
29
+ */
30
+ admit(tx: object, helper: THelper): ILockAdmission | undefined;
31
+ /** Records an admitted rank once its lock was taken; `undefined` records nothing. The same rank again passes. */
32
+ record(tx: object, admission: ILockAdmission | undefined): void;
33
+ /**
34
+ * Records the strength of a lock of the transaction under a key you chose (`1` weakest). A stronger lock replaces a
35
+ * weaker one and a weaker one never replaces a stronger one. Recorded also when the rank check is off. A `TypeError`
36
+ * for a strength that is not a whole number of at least 1.
37
+ */
38
+ hold(tx: object, key: string, strength: number): void;
39
+ /** The strength recorded under the key, `0` when none. A read: it creates no state. */
40
+ held(tx: object, key: string): number;
41
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ILockOrderTracker.mjs.map
@@ -0,0 +1,5 @@
1
+ /** What `configure` of a lock-order tracker takes. */
2
+ export interface ILockTrackerConfig {
3
+ /** The rank check for every transaction that does not say otherwise. Default `true`. */
4
+ readonly rankCheck?: boolean | undefined;
5
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ILockTrackerConfig.mjs.map
@@ -0,0 +1,7 @@
1
+ /** What `track` of a lock-order tracker takes. */
2
+ export interface ILockTrackerOptions<TMode extends string = string> {
3
+ /** The mode of the transaction. Default: the `defaultMode` of the spec. */
4
+ readonly mode?: TMode | undefined;
5
+ /** Forces the rank check on or off for this transaction. Default: the default of the tracker. */
6
+ readonly rankCheck?: boolean | undefined;
7
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ILockTrackerOptions.mjs.map
@@ -0,0 +1,3 @@
1
+ import type { ROW_LOCK_MODES } from './ROW_LOCK_MODES.mjs';
2
+ /** One of {@link ROW_LOCK_MODES}. */
3
+ export type IRowLockMode = (typeof ROW_LOCK_MODES)[number];
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IRowLockMode.mjs.map
@@ -0,0 +1,2 @@
1
+ /** The lock modes of a row: `update` is `FOR UPDATE`, `share` is `FOR SHARE`. A list to validate a mode against; the kit issues no lock clause. */
2
+ export declare const ROW_LOCK_MODES: readonly ["update", "share"];
@@ -0,0 +1,3 @@
1
+ /** The lock modes of a row: `update` is `FOR UPDATE`, `share` is `FOR SHARE`. A list to validate a mode against; the kit issues no lock clause. */
2
+ export const ROW_LOCK_MODES = ['update', 'share'];
3
+ //# sourceMappingURL=ROW_LOCK_MODES.mjs.map
@@ -0,0 +1,16 @@
1
+ import type { ITx } from "../tx/ITx.mjs";
2
+ import type { IClaimRegistry } from './IClaimRegistry.mjs';
3
+ import type { IClaimRequest } from './IClaimRequest.mjs';
4
+ /**
5
+ * The one row-claim primitive: runs the statement that the registry holds for a table and a predicate name, with the
6
+ * number of rows as `$1`, and tells the clock when it claimed any. The statement is written by the caller and is expected
7
+ * to take its rows with `FOR UPDATE SKIP LOCKED`, oldest first, so that rows another transaction holds are skipped, never
8
+ * waited for, and several workers claim apart by construction. The kit holds no statement and no lock clause: a name that
9
+ * is not an own key of the registry is a `TypeError`, and the only value from the request that reaches the database is
10
+ * the limit, bound as a parameter. A claim takes no rank in the order of a tracker (it is a queue operation). The caller
11
+ * commits the claim before it does anything slow with the rows.
12
+ *
13
+ * The checks, in order: the table, the predicate, the limit (a whole number from 1 to `CLAIM_LIMIT_MAX`). Each failure is a
14
+ * `TypeError`, before any statement.
15
+ */
16
+ export declare function claimRowsSkipLocked<TRow>(tx: ITx, claims: IClaimRegistry, request: IClaimRequest): Promise<TRow[]>;
@@ -0,0 +1,32 @@
1
+ import { CLAIM_LIMIT_MAX } from './CLAIM_LIMIT_MAX.mjs';
2
+ import { lockedRows } from './lockedRows.mjs';
3
+ /**
4
+ * The one row-claim primitive: runs the statement that the registry holds for a table and a predicate name, with the
5
+ * number of rows as `$1`, and tells the clock when it claimed any. The statement is written by the caller and is expected
6
+ * to take its rows with `FOR UPDATE SKIP LOCKED`, oldest first, so that rows another transaction holds are skipped, never
7
+ * waited for, and several workers claim apart by construction. The kit holds no statement and no lock clause: a name that
8
+ * is not an own key of the registry is a `TypeError`, and the only value from the request that reaches the database is
9
+ * the limit, bound as a parameter. A claim takes no rank in the order of a tracker (it is a queue operation). The caller
10
+ * commits the claim before it does anything slow with the rows.
11
+ *
12
+ * The checks, in order: the table, the predicate, the limit (a whole number from 1 to `CLAIM_LIMIT_MAX`). Each failure is a
13
+ * `TypeError`, before any statement.
14
+ */
15
+ export async function claimRowsSkipLocked(tx, claims, request) {
16
+ const { table, predicate, limit } = request;
17
+ const tableStatements = Object.hasOwn(claims, table)
18
+ ? Reflect.get(claims, table)
19
+ : undefined;
20
+ if (tableStatements === undefined) {
21
+ throw new TypeError('table is not in the closed list of claim tables');
22
+ }
23
+ if (!Object.hasOwn(tableStatements, predicate)) {
24
+ throw new TypeError(`predicate is not in the closed list of ${table}`);
25
+ }
26
+ if (!Number.isInteger(limit) || limit < 1 || limit > CLAIM_LIMIT_MAX) {
27
+ throw new TypeError(`limit must be a whole number from 1 to ${String(CLAIM_LIMIT_MAX)}`);
28
+ }
29
+ const { rows } = await tx.query(Reflect.get(tableStatements, predicate), [limit]);
30
+ return lockedRows(tx, rows);
31
+ }
32
+ //# sourceMappingURL=claimRowsSkipLocked.mjs.map
@@ -0,0 +1,14 @@
1
+ import type { ILockOrderSpec } from './ILockOrderSpec.mjs';
2
+ import type { ILockOrderTracker } from './ILockOrderTracker.mjs';
3
+ /**
4
+ * Makes the tracker of the order of the locks, from a spec: the ranks of each mode, the rank each helper takes, and the
5
+ * default mode. So that two requests can never wait for each other, a transaction takes its locks in the order of its
6
+ * mode; the tracker throws `LockOrderError` when a lower rank is requested after a higher one. The kit ships no order.
7
+ *
8
+ * The state of a transaction is kept in a `WeakMap` that belongs to this tracker (no module-level state), keyed by the
9
+ * handle that `withTx` hands out, so a retry starts again and nothing outlives the transaction. Make one tracker per spec,
10
+ * once, where your lock helpers live, and call it from every helper: two trackers do not see each other's transactions.
11
+ * The check is on unless `configure` or `track` turned it off. The spec is checked here (`TypeError` for a spec that
12
+ * would leave the order silently off) and copied.
13
+ */
14
+ export declare function createLockOrderTracker<TMode extends string, THelper extends string>(spec: ILockOrderSpec<TMode, THelper>): ILockOrderTracker<TMode, THelper>;
@@ -0,0 +1,60 @@
1
+ import { LockOrderError } from "../error/LockOrderError.mjs";
2
+ import { admitLock } from "../../../private/lib/PostgreSQL/admitLock.mjs";
3
+ import { lockOrderPlan } from "../../../private/lib/PostgreSQL/lockOrderPlan.mjs";
4
+ import { rankCheckOption } from "../../../private/lib/PostgreSQL/rankCheckOption.mjs";
5
+ /**
6
+ * Makes the tracker of the order of the locks, from a spec: the ranks of each mode, the rank each helper takes, and the
7
+ * default mode. So that two requests can never wait for each other, a transaction takes its locks in the order of its
8
+ * mode; the tracker throws `LockOrderError` when a lower rank is requested after a higher one. The kit ships no order.
9
+ *
10
+ * The state of a transaction is kept in a `WeakMap` that belongs to this tracker (no module-level state), keyed by the
11
+ * handle that `withTx` hands out, so a retry starts again and nothing outlives the transaction. Make one tracker per spec,
12
+ * once, where your lock helpers live, and call it from every helper: two trackers do not see each other's transactions.
13
+ * The check is on unless `configure` or `track` turned it off. The spec is checked here (`TypeError` for a spec that
14
+ * would leave the order silently off) and copied.
15
+ */
16
+ export function createLockOrderTracker(spec) {
17
+ const plan = lockOrderPlan(spec);
18
+ const states = new WeakMap();
19
+ let rankCheckDefault = true;
20
+ const stateOf = (tx) => {
21
+ let state = states.get(tx);
22
+ if (state === undefined) {
23
+ state = { order: plan.defaultOrder, rankCheck: rankCheckDefault, rank: 0, held: new Map() };
24
+ states.set(tx, state);
25
+ }
26
+ return state;
27
+ };
28
+ return {
29
+ configure(config = {}) {
30
+ rankCheckDefault = rankCheckOption(config.rankCheck) ?? true;
31
+ },
32
+ track(tx, options = {}) {
33
+ const order = options.mode === undefined ? plan.defaultOrder : plan.orders.get(options.mode);
34
+ if (order === undefined)
35
+ throw new TypeError(`mode must be one of ${[...plan.orders.keys()].join(', ')}`);
36
+ const rankCheck = rankCheckOption(options.rankCheck);
37
+ const state = stateOf(tx);
38
+ if (state.rank > 0) {
39
+ throw new LockOrderError('TRACKER_STARTED', 'the lock order mode of a transaction is set before its first lock');
40
+ }
41
+ state.order = order;
42
+ state.rankCheck = rankCheck ?? rankCheckDefault;
43
+ },
44
+ admit: (tx, helper) => admitLock(plan, stateOf(tx), helper),
45
+ record(tx, admission) {
46
+ if (admission === undefined)
47
+ return;
48
+ const state = stateOf(tx);
49
+ state.rank = Math.max(state.rank, admission.rank);
50
+ },
51
+ hold(tx, key, strength) {
52
+ if (!Number.isInteger(strength) || strength < 1)
53
+ throw new TypeError('strength must be a whole number of at least 1');
54
+ const { held } = stateOf(tx);
55
+ held.set(key, Math.max(held.get(key) ?? 0, strength));
56
+ },
57
+ held: (tx, key) => states.get(tx)?.held.get(key) ?? 0
58
+ };
59
+ }
60
+ //# sourceMappingURL=createLockOrderTracker.mjs.map
@@ -0,0 +1,7 @@
1
+ import type { ITx } from "../tx/ITx.mjs";
2
+ /**
3
+ * Tells the database clock that a lock was taken, when the statement locked a row: a clock bound to the transaction
4
+ * reads the instant right here, after the lock, and a write transaction may read the time from now on. A statement that
5
+ * locked nothing (no such row) is not a lock taken. Answers the row it was given.
6
+ */
7
+ export declare function lockedRow<TRow>(tx: ITx, row: TRow | undefined): Promise<TRow | undefined>;
@@ -0,0 +1,12 @@
1
+ import { lockTaken } from "../clock/lockTaken.mjs";
2
+ /**
3
+ * Tells the database clock that a lock was taken, when the statement locked a row: a clock bound to the transaction
4
+ * reads the instant right here, after the lock, and a write transaction may read the time from now on. A statement that
5
+ * locked nothing (no such row) is not a lock taken. Answers the row it was given.
6
+ */
7
+ export async function lockedRow(tx, row) {
8
+ if (row !== undefined)
9
+ await lockTaken(tx);
10
+ return row;
11
+ }
12
+ //# sourceMappingURL=lockedRow.mjs.map
@@ -0,0 +1,3 @@
1
+ import type { ITx } from "../tx/ITx.mjs";
2
+ /** The same as `lockedRow` for a list of locked rows: a lock was taken when the list is not empty. Answers the list it was given. */
3
+ export declare function lockedRows<TRow>(tx: ITx, rows: TRow[]): Promise<TRow[]>;
@@ -0,0 +1,8 @@
1
+ import { lockTaken } from "../clock/lockTaken.mjs";
2
+ /** The same as `lockedRow` for a list of locked rows: a lock was taken when the list is not empty. Answers the list it was given. */
3
+ export async function lockedRows(tx, rows) {
4
+ if (rows.length > 0)
5
+ await lockTaken(tx);
6
+ return rows;
7
+ }
8
+ //# sourceMappingURL=lockedRows.mjs.map
@@ -0,0 +1,3 @@
1
+ import type { IRowLockMode } from './IRowLockMode.mjs';
2
+ /** The mode itself when it is one of `ROW_LOCK_MODES`, otherwise a `TypeError` that names the list and never quotes the value. */
3
+ export declare function rowLockModeOf(value: unknown): IRowLockMode;
@@ -0,0 +1,9 @@
1
+ import { ROW_LOCK_MODES } from './ROW_LOCK_MODES.mjs';
2
+ /** The mode itself when it is one of `ROW_LOCK_MODES`, otherwise a `TypeError` that names the list and never quotes the value. */
3
+ export function rowLockModeOf(value) {
4
+ if (!ROW_LOCK_MODES.includes(value)) {
5
+ throw new TypeError(`mode must be one of ${ROW_LOCK_MODES.join(', ')}`);
6
+ }
7
+ return value;
8
+ }
9
+ //# sourceMappingURL=rowLockModeOf.mjs.map
@@ -0,0 +1,2 @@
1
+ /** The id in lower case, or a `TypeError` that names the argument by `label` and never quotes the value. */
2
+ export declare function uuidOf(value: unknown, label: string): string;
@@ -0,0 +1,10 @@
1
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
2
+ /** The id in lower case, or a `TypeError` that names the argument by `label` and never quotes the value. */
3
+ export function uuidOf(value, label) {
4
+ // nosemgrep: ajinabraham.njsscan.dos.regex_dos.regex_dos -- UUID has only fixed-length groups and no unbounded quantifier, so it matches in linear time
5
+ if (typeof value !== 'string' || !UUID.test(value)) {
6
+ throw new TypeError(`${label} must be a UUID`);
7
+ }
8
+ return value.toLowerCase();
9
+ }
10
+ //# sourceMappingURL=uuidOf.mjs.map
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The ids in lower case, without duplicates, ascending (the order of the `uuid` type), or a `TypeError` that names the
3
+ * argument by `label` and never quotes a value.
4
+ */
5
+ export declare function uuidsOf(value: unknown, label: string): string[];
@@ -0,0 +1,13 @@
1
+ import { uuidOf } from './uuidOf.mjs';
2
+ /**
3
+ * The ids in lower case, without duplicates, ascending (the order of the `uuid` type), or a `TypeError` that names the
4
+ * argument by `label` and never quotes a value.
5
+ */
6
+ export function uuidsOf(value, label) {
7
+ if (!Array.isArray(value))
8
+ throw new TypeError(`${label} must be an array of UUIDs`);
9
+ const ids = value.map((entry) => uuidOf(entry, `each entry of ${label}`));
10
+ // eslint-disable-next-line sonarjs/no-alphabetical-sort -- ids are lower-case hex and dashes, so the default order by UTF-16 code unit is the order of the `uuid` type; localeCompare would depend on the host locale
11
+ return [...new Set(ids)].sort();
12
+ }
13
+ //# sourceMappingURL=uuidsOf.mjs.map
@@ -0,0 +1,2 @@
1
+ /** A parser of an array: `null` stays `null` for an element that the server sent as `NULL`. */
2
+ export type IArrayParser = (text: string) => (string | null)[];
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IArrayParser.mjs.map
@@ -0,0 +1,4 @@
1
+ /** The part of the driver's `types` module that the registry needs. */
2
+ export interface IDriverTypes {
3
+ getTypeParser(oid: number, format?: 'text' | 'binary'): (value: string) => unknown;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IDriverTypes.mjs.map
@@ -0,0 +1,2 @@
1
+ /** A parser: the text the server sent in, the string the caller wants out. */
2
+ export type IStringParser = (text: string) => string;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IStringParser.mjs.map
@@ -0,0 +1,9 @@
1
+ /** One parser of this library and the type it is for. */
2
+ export interface ITypeParserEntry {
3
+ /** The OID of the type in `pg_type`; the OIDs of the built-in types are fixed. */
4
+ readonly oid: number;
5
+ /** The name `format_type` prints. */
6
+ readonly typeName: string;
7
+ /** `parse` returns what the column becomes, or throws a `DbParseError`. */
8
+ readonly parse: (text: string) => unknown;
9
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ITypeParserEntry.mjs.map
@@ -0,0 +1,12 @@
1
+ import type { ITypeParserEntry } from "./ITypeParserEntry.mjs";
2
+ /**
3
+ * The parsers of this library, by the OID of the type they read. The OIDs are those of the built-in types (`SELECT oid,
4
+ * typname FROM pg_type`; the same numbers are in the text parsers of `pg-types` and in the PostgreSQL catalog source
5
+ * `pg_type.dat`).
6
+ *
7
+ * Arrays are separate types: the driver's scalar parsers do not apply to an array of the same element (the OID of
8
+ * `date[]` is not the OID of `date`), so each array type has its own entry. The driver's own `date[]` parser returns
9
+ * `Date` values, its `time[]` parser returns the text with seconds, and a type it has no parser for comes back as the
10
+ * raw text `{...}`.
11
+ */
12
+ export declare const TYPE_PARSERS: readonly ITypeParserEntry[];