@axiumine/koa-utils 8.0.0 → 9.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 (431) hide show
  1. package/LICENSE +658 -228
  2. package/README.md +8 -4
  3. package/dist/dataSources/PostgreSQL.mjs +5 -5
  4. package/dist/email/SocketLabsLib.d.mts +2 -1
  5. package/dist/email/SocketLabsLib.mjs +5 -3
  6. package/dist/files/storeUploadAsTemp.mjs +2 -0
  7. package/dist/graphQL/schema/mutations/emailChangeHashVerify.mjs +2 -1
  8. package/dist/graphQL/schema/mutations/logout.mjs +1 -1
  9. package/dist/graphQL/schema/mutations/resetPwd.mjs +3 -1
  10. package/dist/koa/middleware/authenticatedAuthorizationHandler/index.d.mts +1 -1
  11. package/dist/koa/middleware/authenticatedAuthorizationHandler/verifySignedRefreshToken.mjs +12 -9
  12. package/dist/koa/middleware/authenticatedLogoutHandler/index.d.mts +1 -1
  13. package/dist/koa/middleware/authenticatedResourceHandler/index.d.mts +1 -1
  14. package/dist/koa/middleware/debug/index.d.mts +1 -1
  15. package/dist/lib/ArrayLib.d.mts +0 -1
  16. package/dist/lib/ArrayLib.mjs +0 -1
  17. package/dist/lib/DateLib.mjs +1 -1
  18. package/dist/lib/MariaDB/throwSqlErrors.mjs +3 -1
  19. package/dist/lib/MongoDB/IMongoDBError.d.mts +2 -3
  20. package/dist/lib/MongoDB/throwIfMongoErr.mjs +4 -2
  21. package/dist/lib/NumLib.d.mts +0 -1
  22. package/dist/lib/NumLib.mjs +1 -1
  23. package/dist/lib/PostgreSQL/clock/CLOCK_SQL.d.mts +7 -0
  24. package/dist/lib/PostgreSQL/clock/CLOCK_SQL.mjs +8 -0
  25. package/dist/lib/PostgreSQL/clock/DB_NOW_SQL.d.mts +5 -0
  26. package/dist/lib/PostgreSQL/clock/DB_NOW_SQL.mjs +6 -0
  27. package/dist/lib/PostgreSQL/clock/IClock.d.mts +4 -0
  28. package/dist/lib/PostgreSQL/clock/IClock.mjs +2 -0
  29. package/dist/lib/PostgreSQL/clock/IDbClock.d.mts +11 -0
  30. package/dist/lib/PostgreSQL/clock/IDbClock.mjs +2 -0
  31. package/dist/lib/PostgreSQL/clock/IDbClockOptions.d.mts +11 -0
  32. package/dist/lib/PostgreSQL/clock/IDbClockOptions.mjs +2 -0
  33. package/dist/lib/PostgreSQL/clock/IDbClockSeam.d.mts +10 -0
  34. package/dist/lib/PostgreSQL/clock/IDbClockSeam.mjs +2 -0
  35. package/dist/lib/PostgreSQL/clock/createDbClock.d.mts +23 -0
  36. package/dist/lib/PostgreSQL/clock/createDbClock.mjs +54 -0
  37. package/dist/lib/PostgreSQL/clock/lockTaken.d.mts +11 -0
  38. package/dist/lib/PostgreSQL/clock/lockTaken.mjs +17 -0
  39. package/dist/lib/PostgreSQL/counter/IDbCounter.d.mts +9 -0
  40. package/dist/lib/PostgreSQL/counter/IDbCounter.mjs +2 -0
  41. package/dist/lib/PostgreSQL/error/DB_CLOCK_REASONS.d.mts +12 -0
  42. package/dist/lib/PostgreSQL/error/DB_CLOCK_REASONS.mjs +20 -0
  43. package/dist/lib/PostgreSQL/error/DB_CONNECT_REASONS.d.mts +11 -0
  44. package/dist/lib/PostgreSQL/error/DB_CONNECT_REASONS.mjs +12 -0
  45. package/dist/lib/PostgreSQL/error/DB_INTERNAL_REASONS.d.mts +23 -0
  46. package/dist/lib/PostgreSQL/error/DB_INTERNAL_REASONS.mjs +35 -0
  47. package/dist/lib/PostgreSQL/error/DB_PARSE_REASONS.d.mts +13 -0
  48. package/dist/lib/PostgreSQL/error/DB_PARSE_REASONS.mjs +14 -0
  49. package/dist/lib/PostgreSQL/error/DB_STATE_REASONS.d.mts +7 -0
  50. package/dist/lib/PostgreSQL/error/DB_STATE_REASONS.mjs +8 -0
  51. package/dist/lib/PostgreSQL/error/DB_TX_REASONS.d.mts +9 -0
  52. package/dist/lib/PostgreSQL/error/DB_TX_REASONS.mjs +10 -0
  53. package/dist/lib/PostgreSQL/error/DbClockError.d.mts +6 -0
  54. package/dist/lib/PostgreSQL/error/DbClockError.mjs +27 -0
  55. package/dist/lib/PostgreSQL/error/DbConnectError.d.mts +11 -0
  56. package/dist/lib/PostgreSQL/error/DbConnectError.mjs +18 -0
  57. package/dist/lib/PostgreSQL/error/DbParseError.d.mts +11 -0
  58. package/dist/lib/PostgreSQL/error/DbParseError.mjs +16 -0
  59. package/dist/lib/PostgreSQL/error/DbStateError.d.mts +10 -0
  60. package/dist/lib/PostgreSQL/error/DbStateError.mjs +14 -0
  61. package/dist/lib/PostgreSQL/error/DbTxError.d.mts +6 -0
  62. package/dist/lib/PostgreSQL/error/DbTxError.mjs +10 -0
  63. package/dist/lib/PostgreSQL/error/IConstraintEntry.d.mts +17 -0
  64. package/dist/lib/PostgreSQL/error/IConstraintEntry.mjs +2 -0
  65. package/dist/lib/PostgreSQL/error/IConstraintEntryBuilder.d.mts +20 -0
  66. package/dist/lib/PostgreSQL/error/IConstraintEntryBuilder.mjs +2 -0
  67. package/dist/lib/PostgreSQL/error/IConstraintTable.d.mts +7 -0
  68. package/dist/lib/PostgreSQL/error/IConstraintTable.mjs +2 -0
  69. package/dist/lib/PostgreSQL/error/IDbClockReason.d.mts +3 -0
  70. package/dist/lib/PostgreSQL/error/IDbClockReason.mjs +2 -0
  71. package/dist/lib/PostgreSQL/error/IDbConnectReason.d.mts +3 -0
  72. package/dist/lib/PostgreSQL/error/IDbConnectReason.mjs +2 -0
  73. package/dist/lib/PostgreSQL/error/IDbErrorCounter.d.mts +4 -0
  74. package/dist/lib/PostgreSQL/error/IDbErrorCounter.mjs +2 -0
  75. package/dist/lib/PostgreSQL/error/IDbErrorCounterName.d.mts +7 -0
  76. package/dist/lib/PostgreSQL/error/IDbErrorCounterName.mjs +2 -0
  77. package/dist/lib/PostgreSQL/error/IDbErrorFactory.d.mts +16 -0
  78. package/dist/lib/PostgreSQL/error/IDbErrorFactory.mjs +2 -0
  79. package/dist/lib/PostgreSQL/error/IDbInternalReason.d.mts +3 -0
  80. package/dist/lib/PostgreSQL/error/IDbInternalReason.mjs +2 -0
  81. package/dist/lib/PostgreSQL/error/IDbParseReason.d.mts +3 -0
  82. package/dist/lib/PostgreSQL/error/IDbParseReason.mjs +2 -0
  83. package/dist/lib/PostgreSQL/error/IDbStateReason.d.mts +3 -0
  84. package/dist/lib/PostgreSQL/error/IDbStateReason.mjs +2 -0
  85. package/dist/lib/PostgreSQL/error/IDbTxReason.d.mts +3 -0
  86. package/dist/lib/PostgreSQL/error/IDbTxReason.mjs +2 -0
  87. package/dist/lib/PostgreSQL/error/ILockOrderReason.d.mts +3 -0
  88. package/dist/lib/PostgreSQL/error/ILockOrderReason.mjs +2 -0
  89. package/dist/lib/PostgreSQL/error/IMapDbErrorOptions.d.mts +22 -0
  90. package/dist/lib/PostgreSQL/error/IMapDbErrorOptions.mjs +2 -0
  91. package/dist/lib/PostgreSQL/error/IRoleAssertionReason.d.mts +3 -0
  92. package/dist/lib/PostgreSQL/error/IRoleAssertionReason.mjs +2 -0
  93. package/dist/lib/PostgreSQL/error/IRoleAssertionSubject.d.mts +12 -0
  94. package/dist/lib/PostgreSQL/error/IRoleAssertionSubject.mjs +2 -0
  95. package/dist/lib/PostgreSQL/error/LOCK_ORDER_REASONS.d.mts +11 -0
  96. package/dist/lib/PostgreSQL/error/LOCK_ORDER_REASONS.mjs +12 -0
  97. package/dist/lib/PostgreSQL/error/LockOrderError.d.mts +6 -0
  98. package/dist/lib/PostgreSQL/error/LockOrderError.mjs +10 -0
  99. package/dist/lib/PostgreSQL/error/ROLE_ASSERT_REASONS.d.mts +21 -0
  100. package/dist/lib/PostgreSQL/error/ROLE_ASSERT_REASONS.mjs +35 -0
  101. package/dist/lib/PostgreSQL/error/RoleAssertionError.d.mts +19 -0
  102. package/dist/lib/PostgreSQL/error/RoleAssertionError.mjs +58 -0
  103. package/dist/lib/PostgreSQL/error/buildConstraintEntry.d.mts +15 -0
  104. package/dist/lib/PostgreSQL/error/buildConstraintEntry.mjs +16 -0
  105. package/dist/lib/PostgreSQL/error/constraintNameOf.d.mts +6 -0
  106. package/dist/lib/PostgreSQL/error/constraintNameOf.mjs +17 -0
  107. package/dist/lib/PostgreSQL/error/errorNameOf.d.mts +5 -0
  108. package/dist/lib/PostgreSQL/error/errorNameOf.mjs +12 -0
  109. package/dist/lib/PostgreSQL/error/lookupConstraint.d.mts +7 -0
  110. package/dist/lib/PostgreSQL/error/lookupConstraint.mjs +8 -0
  111. package/dist/lib/PostgreSQL/error/mapDbError.d.mts +28 -0
  112. package/dist/lib/PostgreSQL/error/mapDbError.mjs +52 -0
  113. package/dist/lib/PostgreSQL/error/sqlstateField.d.mts +4 -0
  114. package/dist/lib/PostgreSQL/error/sqlstateField.mjs +5 -0
  115. package/dist/lib/PostgreSQL/error/sqlstateOf.d.mts +5 -0
  116. package/dist/lib/PostgreSQL/error/sqlstateOf.mjs +12 -0
  117. package/dist/lib/PostgreSQL/guard/IAffectedResult.d.mts +4 -0
  118. package/dist/lib/PostgreSQL/guard/IAffectedResult.mjs +2 -0
  119. package/dist/lib/PostgreSQL/guard/IGuardCounter.d.mts +3 -0
  120. package/dist/lib/PostgreSQL/guard/IGuardCounter.mjs +2 -0
  121. package/dist/lib/PostgreSQL/guard/IVersionGuardCode.d.mts +5 -0
  122. package/dist/lib/PostgreSQL/guard/IVersionGuardCode.mjs +2 -0
  123. package/dist/lib/PostgreSQL/guard/IVersionGuardField.d.mts +3 -0
  124. package/dist/lib/PostgreSQL/guard/IVersionGuardField.mjs +2 -0
  125. package/dist/lib/PostgreSQL/guard/IVersionGuardInput.d.mts +29 -0
  126. package/dist/lib/PostgreSQL/guard/IVersionGuardInput.mjs +2 -0
  127. package/dist/lib/PostgreSQL/guard/VERSION_GUARD_FIELDS.d.mts +2 -0
  128. package/dist/lib/PostgreSQL/guard/VERSION_GUARD_FIELDS.mjs +3 -0
  129. package/dist/lib/PostgreSQL/guard/assertAffected.d.mts +10 -0
  130. package/dist/lib/PostgreSQL/guard/assertAffected.mjs +17 -0
  131. package/dist/lib/PostgreSQL/guard/guardVersion.d.mts +21 -0
  132. package/dist/lib/PostgreSQL/guard/guardVersion.mjs +47 -0
  133. package/dist/lib/PostgreSQL/lock/CLAIM_LIMIT_MAX.d.mts +2 -0
  134. package/dist/lib/PostgreSQL/lock/CLAIM_LIMIT_MAX.mjs +3 -0
  135. package/dist/lib/PostgreSQL/lock/IClaimRegistry.d.mts +6 -0
  136. package/dist/lib/PostgreSQL/lock/IClaimRegistry.mjs +2 -0
  137. package/dist/lib/PostgreSQL/lock/IClaimRequest.d.mts +7 -0
  138. package/dist/lib/PostgreSQL/lock/IClaimRequest.mjs +2 -0
  139. package/dist/lib/PostgreSQL/lock/ILockAdmission.d.mts +4 -0
  140. package/dist/lib/PostgreSQL/lock/ILockAdmission.mjs +2 -0
  141. package/dist/lib/PostgreSQL/lock/ILockOrderSpec.d.mts +19 -0
  142. package/dist/lib/PostgreSQL/lock/ILockOrderSpec.mjs +2 -0
  143. package/dist/lib/PostgreSQL/lock/ILockOrderTracker.d.mts +41 -0
  144. package/dist/lib/PostgreSQL/lock/ILockOrderTracker.mjs +2 -0
  145. package/dist/lib/PostgreSQL/lock/ILockTrackerConfig.d.mts +5 -0
  146. package/dist/lib/PostgreSQL/lock/ILockTrackerConfig.mjs +2 -0
  147. package/dist/lib/PostgreSQL/lock/ILockTrackerOptions.d.mts +7 -0
  148. package/dist/lib/PostgreSQL/lock/ILockTrackerOptions.mjs +2 -0
  149. package/dist/lib/PostgreSQL/lock/IRowLockMode.d.mts +3 -0
  150. package/dist/lib/PostgreSQL/lock/IRowLockMode.mjs +2 -0
  151. package/dist/lib/PostgreSQL/lock/ROW_LOCK_MODES.d.mts +2 -0
  152. package/dist/lib/PostgreSQL/lock/ROW_LOCK_MODES.mjs +3 -0
  153. package/dist/lib/PostgreSQL/lock/claimRowsSkipLocked.d.mts +16 -0
  154. package/dist/lib/PostgreSQL/lock/claimRowsSkipLocked.mjs +32 -0
  155. package/dist/lib/PostgreSQL/lock/createLockOrderTracker.d.mts +14 -0
  156. package/dist/lib/PostgreSQL/lock/createLockOrderTracker.mjs +60 -0
  157. package/dist/lib/PostgreSQL/lock/lockedRow.d.mts +7 -0
  158. package/dist/lib/PostgreSQL/lock/lockedRow.mjs +12 -0
  159. package/dist/lib/PostgreSQL/lock/lockedRows.d.mts +3 -0
  160. package/dist/lib/PostgreSQL/lock/lockedRows.mjs +8 -0
  161. package/dist/lib/PostgreSQL/lock/rowLockModeOf.d.mts +3 -0
  162. package/dist/lib/PostgreSQL/lock/rowLockModeOf.mjs +9 -0
  163. package/dist/lib/PostgreSQL/lock/uuidOf.d.mts +2 -0
  164. package/dist/lib/PostgreSQL/lock/uuidOf.mjs +10 -0
  165. package/dist/lib/PostgreSQL/lock/uuidsOf.d.mts +5 -0
  166. package/dist/lib/PostgreSQL/lock/uuidsOf.mjs +13 -0
  167. package/dist/lib/PostgreSQL/parse/IArrayParser.d.mts +2 -0
  168. package/dist/lib/PostgreSQL/parse/IArrayParser.mjs +2 -0
  169. package/dist/lib/PostgreSQL/parse/IDriverTypes.d.mts +4 -0
  170. package/dist/lib/PostgreSQL/parse/IDriverTypes.mjs +2 -0
  171. package/dist/lib/PostgreSQL/parse/IStringParser.d.mts +2 -0
  172. package/dist/lib/PostgreSQL/parse/IStringParser.mjs +2 -0
  173. package/dist/lib/PostgreSQL/parse/ITypeParserEntry.d.mts +9 -0
  174. package/dist/lib/PostgreSQL/parse/ITypeParserEntry.mjs +2 -0
  175. package/dist/lib/PostgreSQL/parse/TYPE_PARSERS.d.mts +12 -0
  176. package/dist/lib/PostgreSQL/parse/TYPE_PARSERS.mjs +38 -0
  177. package/dist/lib/PostgreSQL/parse/arrayOf.d.mts +7 -0
  178. package/dist/lib/PostgreSQL/parse/arrayOf.mjs +50 -0
  179. package/dist/lib/PostgreSQL/parse/createTypeRegistry.d.mts +13 -0
  180. package/dist/lib/PostgreSQL/parse/createTypeRegistry.mjs +26 -0
  181. package/dist/lib/PostgreSQL/parse/parseDate.d.mts +7 -0
  182. package/dist/lib/PostgreSQL/parse/parseDate.mjs +19 -0
  183. package/dist/lib/PostgreSQL/parse/parseInt8.d.mts +6 -0
  184. package/dist/lib/PostgreSQL/parse/parseInt8.mjs +17 -0
  185. package/dist/lib/PostgreSQL/parse/parseTime.d.mts +7 -0
  186. package/dist/lib/PostgreSQL/parse/parseTime.mjs +24 -0
  187. package/dist/lib/PostgreSQL/parse/parseTimestamptz.d.mts +17 -0
  188. package/dist/lib/PostgreSQL/parse/parseTimestamptz.mjs +79 -0
  189. package/dist/lib/PostgreSQL/parse/parseUuid.d.mts +3 -0
  190. package/dist/lib/PostgreSQL/parse/parseUuid.mjs +9 -0
  191. package/dist/lib/PostgreSQL/pool/DEFAULT_CONNECT_TIMEOUT_MS.d.mts +2 -0
  192. package/dist/lib/PostgreSQL/pool/DEFAULT_CONNECT_TIMEOUT_MS.mjs +3 -0
  193. package/dist/lib/PostgreSQL/pool/DEFAULT_KEEPALIVE_INITIAL_DELAY_MS.d.mts +2 -0
  194. package/dist/lib/PostgreSQL/pool/DEFAULT_KEEPALIVE_INITIAL_DELAY_MS.mjs +3 -0
  195. package/dist/lib/PostgreSQL/pool/ICreatePoolOptions.d.mts +28 -0
  196. package/dist/lib/PostgreSQL/pool/ICreatePoolOptions.mjs +2 -0
  197. package/dist/lib/PostgreSQL/pool/IDbDriver.d.mts +12 -0
  198. package/dist/lib/PostgreSQL/pool/IDbDriver.mjs +2 -0
  199. package/dist/lib/PostgreSQL/pool/IPoolCounter.d.mts +4 -0
  200. package/dist/lib/PostgreSQL/pool/IPoolCounter.mjs +2 -0
  201. package/dist/lib/PostgreSQL/pool/IPoolCounterName.d.mts +7 -0
  202. package/dist/lib/PostgreSQL/pool/IPoolCounterName.mjs +2 -0
  203. package/dist/lib/PostgreSQL/pool/IPoolEvents.d.mts +4 -0
  204. package/dist/lib/PostgreSQL/pool/IPoolEvents.mjs +2 -0
  205. package/dist/lib/PostgreSQL/pool/IPoolLogger.d.mts +8 -0
  206. package/dist/lib/PostgreSQL/pool/IPoolLogger.mjs +2 -0
  207. package/dist/lib/PostgreSQL/pool/REQUIRED_SESSION_TIME_ZONE.d.mts +2 -0
  208. package/dist/lib/PostgreSQL/pool/REQUIRED_SESSION_TIME_ZONE.mjs +3 -0
  209. package/dist/lib/PostgreSQL/pool/createPool.d.mts +31 -0
  210. package/dist/lib/PostgreSQL/pool/createPool.mjs +67 -0
  211. package/dist/lib/PostgreSQL/role/IAssertRoleOptions.d.mts +10 -0
  212. package/dist/lib/PostgreSQL/role/IAssertRoleOptions.mjs +2 -0
  213. package/dist/lib/PostgreSQL/role/IRoleAssertion.d.mts +6 -0
  214. package/dist/lib/PostgreSQL/role/IRoleAssertion.mjs +2 -0
  215. package/dist/lib/PostgreSQL/role/IRoleGrant.d.mts +19 -0
  216. package/dist/lib/PostgreSQL/role/IRoleGrant.mjs +2 -0
  217. package/dist/lib/PostgreSQL/role/IRolePool.d.mts +6 -0
  218. package/dist/lib/PostgreSQL/role/IRolePool.mjs +2 -0
  219. package/dist/lib/PostgreSQL/role/assertRole.d.mts +36 -0
  220. package/dist/lib/PostgreSQL/role/assertRole.mjs +54 -0
  221. package/dist/lib/PostgreSQL/tx/DEFAULT_LOCK_TIMEOUT_MS.d.mts +2 -0
  222. package/dist/lib/PostgreSQL/tx/DEFAULT_LOCK_TIMEOUT_MS.mjs +3 -0
  223. package/dist/lib/PostgreSQL/tx/IRetryDelay.d.mts +2 -0
  224. package/dist/lib/PostgreSQL/tx/IRetryDelay.mjs +2 -0
  225. package/dist/lib/PostgreSQL/tx/ITx.d.mts +9 -0
  226. package/dist/lib/PostgreSQL/tx/ITx.mjs +2 -0
  227. package/dist/lib/PostgreSQL/tx/ITxClient.d.mts +12 -0
  228. package/dist/lib/PostgreSQL/tx/ITxClient.mjs +2 -0
  229. package/dist/lib/PostgreSQL/tx/ITxCounter.d.mts +4 -0
  230. package/dist/lib/PostgreSQL/tx/ITxCounter.mjs +2 -0
  231. package/dist/lib/PostgreSQL/tx/ITxCounterName.d.mts +10 -0
  232. package/dist/lib/PostgreSQL/tx/ITxCounterName.mjs +2 -0
  233. package/dist/lib/PostgreSQL/tx/ITxFailureReason.d.mts +3 -0
  234. package/dist/lib/PostgreSQL/tx/ITxFailureReason.mjs +2 -0
  235. package/dist/lib/PostgreSQL/tx/ITxIsolation.d.mts +3 -0
  236. package/dist/lib/PostgreSQL/tx/ITxIsolation.mjs +2 -0
  237. package/dist/lib/PostgreSQL/tx/ITxOptions.d.mts +27 -0
  238. package/dist/lib/PostgreSQL/tx/ITxOptions.mjs +2 -0
  239. package/dist/lib/PostgreSQL/tx/ITxPool.d.mts +5 -0
  240. package/dist/lib/PostgreSQL/tx/ITxPool.mjs +2 -0
  241. package/dist/lib/PostgreSQL/tx/ITxResult.d.mts +6 -0
  242. package/dist/lib/PostgreSQL/tx/ITxResult.mjs +2 -0
  243. package/dist/lib/PostgreSQL/tx/MAX_LOCK_TIMEOUT_MS.d.mts +2 -0
  244. package/dist/lib/PostgreSQL/tx/MAX_LOCK_TIMEOUT_MS.mjs +3 -0
  245. package/dist/lib/PostgreSQL/tx/TX_FAILURE_REASONS.d.mts +7 -0
  246. package/dist/lib/PostgreSQL/tx/TX_FAILURE_REASONS.mjs +8 -0
  247. package/dist/lib/PostgreSQL/tx/TX_ISOLATION_LEVELS.d.mts +2 -0
  248. package/dist/lib/PostgreSQL/tx/TX_ISOLATION_LEVELS.mjs +3 -0
  249. package/dist/lib/PostgreSQL/tx/TX_RETRY_BASE_DELAY_MS.d.mts +2 -0
  250. package/dist/lib/PostgreSQL/tx/TX_RETRY_BASE_DELAY_MS.mjs +3 -0
  251. package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX.d.mts +2 -0
  252. package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX.mjs +3 -0
  253. package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX_CEILING.d.mts +2 -0
  254. package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX_CEILING.mjs +3 -0
  255. package/dist/lib/PostgreSQL/tx/defaultRetryDelay.d.mts +3 -0
  256. package/dist/lib/PostgreSQL/tx/defaultRetryDelay.mjs +4 -0
  257. package/dist/lib/PostgreSQL/tx/jitteredDelay.d.mts +7 -0
  258. package/dist/lib/PostgreSQL/tx/jitteredDelay.mjs +16 -0
  259. package/dist/lib/PostgreSQL/tx/withTx.d.mts +39 -0
  260. package/dist/lib/PostgreSQL/tx/withTx.mjs +41 -0
  261. package/dist/lib/PostgreSQL/url/IDatabaseUrlOptions.d.mts +10 -0
  262. package/dist/lib/PostgreSQL/url/IDatabaseUrlOptions.mjs +2 -0
  263. package/dist/lib/PostgreSQL/url/IDatabaseUrlReason.d.mts +14 -0
  264. package/dist/lib/PostgreSQL/url/IDatabaseUrlReason.mjs +2 -0
  265. package/dist/lib/PostgreSQL/url/LOOPBACK_HOSTS.d.mts +2 -0
  266. package/dist/lib/PostgreSQL/url/LOOPBACK_HOSTS.mjs +3 -0
  267. package/dist/lib/PostgreSQL/url/databaseUrlReason.d.mts +20 -0
  268. package/dist/lib/PostgreSQL/url/databaseUrlReason.mjs +99 -0
  269. package/dist/lib/PostgreSQL/url/isAbsolutePath.d.mts +2 -0
  270. package/dist/lib/PostgreSQL/url/isAbsolutePath.mjs +14 -0
  271. package/dist/lib/PostgreSQL/url/isValidHost.d.mts +6 -0
  272. package/dist/lib/PostgreSQL/url/isValidHost.mjs +20 -0
  273. package/dist/lib/StringLib.d.mts +0 -1
  274. package/dist/lib/StringLib.mjs +0 -1
  275. package/dist/lib/db/log/logGraphql.d.mts +8 -6
  276. package/dist/lib/db/log/logGraphql.mjs +9 -23
  277. package/dist/lib/db/log/logThrow.d.mts +9 -0
  278. package/dist/lib/db/log/logThrow.mjs +11 -11
  279. package/dist/lib/hash.mjs +1 -6
  280. package/dist/lib/isSessionBlocked.d.mts +1 -1
  281. package/dist/lib/throwIfNotValidEnumValue.mjs +1 -0
  282. package/dist/lib/tryCatchRethrow.mjs +5 -3
  283. package/dist/private/files/reEncode.mjs +2 -0
  284. package/dist/private/lib/PostgreSQL/ICivilDate.d.mts +6 -0
  285. package/dist/private/lib/PostgreSQL/ICivilDate.mjs +2 -0
  286. package/dist/private/lib/PostgreSQL/IClientConstructor.d.mts +3 -0
  287. package/dist/private/lib/PostgreSQL/IClientConstructor.mjs +2 -0
  288. package/dist/private/lib/PostgreSQL/IClientShape.d.mts +10 -0
  289. package/dist/private/lib/PostgreSQL/IClientShape.mjs +2 -0
  290. package/dist/private/lib/PostgreSQL/IClockSlot.d.mts +11 -0
  291. package/dist/private/lib/PostgreSQL/IClockSlot.mjs +2 -0
  292. package/dist/private/lib/PostgreSQL/IConnectCallback.d.mts +2 -0
  293. package/dist/private/lib/PostgreSQL/IConnectCallback.mjs +2 -0
  294. package/dist/private/lib/PostgreSQL/IConnectSettings.d.mts +8 -0
  295. package/dist/private/lib/PostgreSQL/IConnectSettings.mjs +2 -0
  296. package/dist/private/lib/PostgreSQL/IHelperRank.d.mts +5 -0
  297. package/dist/private/lib/PostgreSQL/IHelperRank.mjs +2 -0
  298. package/dist/private/lib/PostgreSQL/IInternalSink.d.mts +9 -0
  299. package/dist/private/lib/PostgreSQL/IInternalSink.mjs +2 -0
  300. package/dist/private/lib/PostgreSQL/ILockOrderPlan.d.mts +8 -0
  301. package/dist/private/lib/PostgreSQL/ILockOrderPlan.mjs +2 -0
  302. package/dist/private/lib/PostgreSQL/IModeOrder.d.mts +7 -0
  303. package/dist/private/lib/PostgreSQL/IModeOrder.mjs +2 -0
  304. package/dist/private/lib/PostgreSQL/IPostgresState.d.mts +9 -0
  305. package/dist/private/lib/PostgreSQL/IPostgresState.mjs +2 -0
  306. package/dist/private/lib/PostgreSQL/IRoleCheck.d.mts +4 -0
  307. package/dist/private/lib/PostgreSQL/IRoleCheck.mjs +2 -0
  308. package/dist/private/lib/PostgreSQL/IRoleColumnCheck.d.mts +7 -0
  309. package/dist/private/lib/PostgreSQL/IRoleColumnCheck.mjs +2 -0
  310. package/dist/private/lib/PostgreSQL/IRoleObjectCheck.d.mts +6 -0
  311. package/dist/private/lib/PostgreSQL/IRoleObjectCheck.mjs +2 -0
  312. package/dist/private/lib/PostgreSQL/IRolePlan.d.mts +7 -0
  313. package/dist/private/lib/PostgreSQL/IRolePlan.mjs +2 -0
  314. package/dist/private/lib/PostgreSQL/IRoleRow.d.mts +2 -0
  315. package/dist/private/lib/PostgreSQL/IRoleRow.mjs +2 -0
  316. package/dist/private/lib/PostgreSQL/ITrackerState.d.mts +10 -0
  317. package/dist/private/lib/PostgreSQL/ITrackerState.mjs +2 -0
  318. package/dist/private/lib/PostgreSQL/ITxHandleState.d.mts +6 -0
  319. package/dist/private/lib/PostgreSQL/ITxHandleState.mjs +2 -0
  320. package/dist/private/lib/PostgreSQL/ITxSettings.d.mts +14 -0
  321. package/dist/private/lib/PostgreSQL/ITxSettings.mjs +2 -0
  322. package/dist/private/lib/PostgreSQL/POSTGRES_STATE_KEY.d.mts +5 -0
  323. package/dist/private/lib/PostgreSQL/POSTGRES_STATE_KEY.mjs +6 -0
  324. package/dist/private/lib/PostgreSQL/POSTGRES_STATE_LAYOUT.d.mts +6 -0
  325. package/dist/private/lib/PostgreSQL/POSTGRES_STATE_LAYOUT.mjs +7 -0
  326. package/dist/private/lib/PostgreSQL/ROLE_ATTRIBUTES.d.mts +2 -0
  327. package/dist/private/lib/PostgreSQL/ROLE_ATTRIBUTES.mjs +9 -0
  328. package/dist/private/lib/PostgreSQL/ROLE_CATALOG_SQL.d.mts +26 -0
  329. package/dist/private/lib/PostgreSQL/ROLE_CATALOG_SQL.mjs +84 -0
  330. package/dist/private/lib/PostgreSQL/ROLE_PRIVILEGES.d.mts +2 -0
  331. package/dist/private/lib/PostgreSQL/ROLE_PRIVILEGES.mjs +7 -0
  332. package/dist/private/lib/PostgreSQL/TX_BEGIN_STATEMENTS.d.mts +7 -0
  333. package/dist/private/lib/PostgreSQL/TX_BEGIN_STATEMENTS.mjs +11 -0
  334. package/dist/private/lib/PostgreSQL/admitLock.d.mts +10 -0
  335. package/dist/private/lib/PostgreSQL/admitLock.mjs +33 -0
  336. package/dist/private/lib/PostgreSQL/assertPoolOptions.d.mts +12 -0
  337. package/dist/private/lib/PostgreSQL/assertPoolOptions.mjs +19 -0
  338. package/dist/private/lib/PostgreSQL/assertVersionGuardInput.d.mts +6 -0
  339. package/dist/private/lib/PostgreSQL/assertVersionGuardInput.mjs +14 -0
  340. package/dist/private/lib/PostgreSQL/catalogFlag.d.mts +2 -0
  341. package/dist/private/lib/PostgreSQL/catalogFlag.mjs +7 -0
  342. package/dist/private/lib/PostgreSQL/catalogRow.d.mts +4 -0
  343. package/dist/private/lib/PostgreSQL/catalogRow.mjs +11 -0
  344. package/dist/private/lib/PostgreSQL/catalogRows.d.mts +8 -0
  345. package/dist/private/lib/PostgreSQL/catalogRows.mjs +12 -0
  346. package/dist/private/lib/PostgreSQL/catalogText.d.mts +2 -0
  347. package/dist/private/lib/PostgreSQL/catalogText.mjs +7 -0
  348. package/dist/private/lib/PostgreSQL/checkRoleOnClient.d.mts +10 -0
  349. package/dist/private/lib/PostgreSQL/checkRoleOnClient.mjs +31 -0
  350. package/dist/private/lib/PostgreSQL/checkedClient.d.mts +8 -0
  351. package/dist/private/lib/PostgreSQL/checkedClient.mjs +22 -0
  352. package/dist/private/lib/PostgreSQL/civilCalendar.d.mts +13 -0
  353. package/dist/private/lib/PostgreSQL/civilCalendar.mjs +48 -0
  354. package/dist/private/lib/PostgreSQL/clockInstant.d.mts +11 -0
  355. package/dist/private/lib/PostgreSQL/clockInstant.mjs +18 -0
  356. package/dist/private/lib/PostgreSQL/clockSlot.d.mts +3 -0
  357. package/dist/private/lib/PostgreSQL/clockSlot.mjs +11 -0
  358. package/dist/private/lib/PostgreSQL/clockStatement.d.mts +6 -0
  359. package/dist/private/lib/PostgreSQL/clockStatement.mjs +22 -0
  360. package/dist/private/lib/PostgreSQL/connectAndCheck.d.mts +8 -0
  361. package/dist/private/lib/PostgreSQL/connectAndCheck.mjs +47 -0
  362. package/dist/private/lib/PostgreSQL/constraintDetails.d.mts +7 -0
  363. package/dist/private/lib/PostgreSQL/constraintDetails.mjs +21 -0
  364. package/dist/private/lib/PostgreSQL/constraintField.d.mts +4 -0
  365. package/dist/private/lib/PostgreSQL/constraintField.mjs +5 -0
  366. package/dist/private/lib/PostgreSQL/errorCodeOf.d.mts +2 -0
  367. package/dist/private/lib/PostgreSQL/errorCodeOf.mjs +7 -0
  368. package/dist/private/lib/PostgreSQL/internalFailure.d.mts +9 -0
  369. package/dist/private/lib/PostgreSQL/internalFailure.mjs +10 -0
  370. package/dist/private/lib/PostgreSQL/isNameList.d.mts +2 -0
  371. package/dist/private/lib/PostgreSQL/isNameList.mjs +6 -0
  372. package/dist/private/lib/PostgreSQL/isOneOf.d.mts +2 -0
  373. package/dist/private/lib/PostgreSQL/isOneOf.mjs +5 -0
  374. package/dist/private/lib/PostgreSQL/isQualifiedName.d.mts +2 -0
  375. package/dist/private/lib/PostgreSQL/isQualifiedName.mjs +7 -0
  376. package/dist/private/lib/PostgreSQL/isRoleName.d.mts +2 -0
  377. package/dist/private/lib/PostgreSQL/isRoleName.mjs +7 -0
  378. package/dist/private/lib/PostgreSQL/lockOrderPlan.d.mts +8 -0
  379. package/dist/private/lib/PostgreSQL/lockOrderPlan.mjs +66 -0
  380. package/dist/private/lib/PostgreSQL/mapTypedError.d.mts +3 -0
  381. package/dist/private/lib/PostgreSQL/mapTypedError.mjs +28 -0
  382. package/dist/private/lib/PostgreSQL/mapViolation.d.mts +3 -0
  383. package/dist/private/lib/PostgreSQL/mapViolation.mjs +32 -0
  384. package/dist/private/lib/PostgreSQL/membershipOutsider.d.mts +7 -0
  385. package/dist/private/lib/PostgreSQL/membershipOutsider.mjs +17 -0
  386. package/dist/private/lib/PostgreSQL/missingColumn.d.mts +9 -0
  387. package/dist/private/lib/PostgreSQL/missingColumn.mjs +15 -0
  388. package/dist/private/lib/PostgreSQL/missingGrant.d.mts +5 -0
  389. package/dist/private/lib/PostgreSQL/missingGrant.mjs +7 -0
  390. package/dist/private/lib/PostgreSQL/missingObject.d.mts +10 -0
  391. package/dist/private/lib/PostgreSQL/missingObject.mjs +14 -0
  392. package/dist/private/lib/PostgreSQL/poolUrlSecrets.d.mts +8 -0
  393. package/dist/private/lib/PostgreSQL/poolUrlSecrets.mjs +41 -0
  394. package/dist/private/lib/PostgreSQL/postgresState.d.mts +7 -0
  395. package/dist/private/lib/PostgreSQL/postgresState.mjs +32 -0
  396. package/dist/private/lib/PostgreSQL/rankCheckOption.d.mts +2 -0
  397. package/dist/private/lib/PostgreSQL/rankCheckOption.mjs +7 -0
  398. package/dist/private/lib/PostgreSQL/readField.d.mts +5 -0
  399. package/dist/private/lib/PostgreSQL/readField.mjs +10 -0
  400. package/dist/private/lib/PostgreSQL/roleCheckOf.d.mts +7 -0
  401. package/dist/private/lib/PostgreSQL/roleCheckOf.mjs +39 -0
  402. package/dist/private/lib/PostgreSQL/roleFailureSubject.d.mts +7 -0
  403. package/dist/private/lib/PostgreSQL/roleFailureSubject.mjs +12 -0
  404. package/dist/private/lib/PostgreSQL/rolePlan.d.mts +7 -0
  405. package/dist/private/lib/PostgreSQL/rolePlan.mjs +26 -0
  406. package/dist/private/lib/PostgreSQL/runRoleChecks.d.mts +17 -0
  407. package/dist/private/lib/PostgreSQL/runRoleChecks.mjs +48 -0
  408. package/dist/private/lib/PostgreSQL/runTxAttempt.d.mts +12 -0
  409. package/dist/private/lib/PostgreSQL/runTxAttempt.mjs +50 -0
  410. package/dist/private/lib/PostgreSQL/runTxBody.d.mts +11 -0
  411. package/dist/private/lib/PostgreSQL/runTxBody.mjs +19 -0
  412. package/dist/private/lib/PostgreSQL/runTxWithRetries.d.mts +10 -0
  413. package/dist/private/lib/PostgreSQL/runTxWithRetries.mjs +31 -0
  414. package/dist/private/lib/PostgreSQL/scrubSecrets.d.mts +2 -0
  415. package/dist/private/lib/PostgreSQL/scrubSecrets.mjs +6 -0
  416. package/dist/private/lib/PostgreSQL/txFailure.d.mts +4 -0
  417. package/dist/private/lib/PostgreSQL/txFailure.mjs +7 -0
  418. package/dist/private/lib/PostgreSQL/txHandle.d.mts +9 -0
  419. package/dist/private/lib/PostgreSQL/txHandle.mjs +26 -0
  420. package/dist/private/lib/PostgreSQL/txSettings.d.mts +7 -0
  421. package/dist/private/lib/PostgreSQL/txSettings.mjs +48 -0
  422. package/dist/private/lib/PostgreSQL/versionText.d.mts +5 -0
  423. package/dist/private/lib/PostgreSQL/versionText.mjs +12 -0
  424. package/dist/private/lib/access/db/abandonUser.mjs +2 -3
  425. package/dist/private/lib/access/db/getResetPwd.mjs +4 -2
  426. package/dist/private/lib/access/db/setEmailHash.mjs +3 -1
  427. package/dist/private/lib/access/db/userData4VerifyEmail.d.mts +1 -1
  428. package/dist/private/lib/access/db/userData4VerifyEmail.mjs +4 -2
  429. package/dist/private/lib/access/handleIfHashBad.mjs +1 -0
  430. package/dist/private/lib/access/pathTools.mjs +2 -5
  431. package/package.json +504 -4
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ITxPool.mjs.map
@@ -0,0 +1,6 @@
1
+ /** What a statement answers: the rows, the count the server reports and the command tag. */
2
+ export interface ITxResult<TRow = Record<string, unknown>> {
3
+ readonly rows: TRow[];
4
+ readonly rowCount: number | null;
5
+ readonly command: string;
6
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ITxResult.mjs.map
@@ -0,0 +1,2 @@
1
+ /** The most `lock_timeout` the server takes (a 32-bit count of milliseconds). */
2
+ export declare const MAX_LOCK_TIMEOUT_MS = 2147483647;
@@ -0,0 +1,3 @@
1
+ /** The most `lock_timeout` the server takes (a 32-bit count of milliseconds). */
2
+ export const MAX_LOCK_TIMEOUT_MS = 2_147_483_647;
3
+ //# sourceMappingURL=MAX_LOCK_TIMEOUT_MS.mjs.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The closed reasons of the error that `withTx` asks its error factory for (`internal(reason)`):
3
+ *
4
+ * - `TX_RETRY_EXHAUSTED`: the transaction failed with SQLSTATE 40001 or 40P01 on every attempt, the retries included.
5
+ * - `LOCK_TIMEOUT`: a statement waited longer than the lock timeout (SQLSTATE 55P03). It is not retried.
6
+ */
7
+ export declare const TX_FAILURE_REASONS: readonly ["TX_RETRY_EXHAUSTED", "LOCK_TIMEOUT"];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The closed reasons of the error that `withTx` asks its error factory for (`internal(reason)`):
3
+ *
4
+ * - `TX_RETRY_EXHAUSTED`: the transaction failed with SQLSTATE 40001 or 40P01 on every attempt, the retries included.
5
+ * - `LOCK_TIMEOUT`: a statement waited longer than the lock timeout (SQLSTATE 55P03). It is not retried.
6
+ */
7
+ export const TX_FAILURE_REASONS = ['TX_RETRY_EXHAUSTED', 'LOCK_TIMEOUT'];
8
+ //# sourceMappingURL=TX_FAILURE_REASONS.mjs.map
@@ -0,0 +1,2 @@
1
+ /** The isolation levels `withTx` opens. `READ UNCOMMITTED` is the server's alias of `READ COMMITTED` and is not offered. */
2
+ export declare const TX_ISOLATION_LEVELS: readonly ["READ COMMITTED", "REPEATABLE READ", "SERIALIZABLE"];
@@ -0,0 +1,3 @@
1
+ /** The isolation levels `withTx` opens. `READ UNCOMMITTED` is the server's alias of `READ COMMITTED` and is not offered. */
2
+ export const TX_ISOLATION_LEVELS = ['READ COMMITTED', 'REPEATABLE READ', 'SERIALIZABLE'];
3
+ //# sourceMappingURL=TX_ISOLATION_LEVELS.mjs.map
@@ -0,0 +1,2 @@
1
+ /** The base of the jittered wait before a retry, in milliseconds (see `jitteredDelay`). */
2
+ export declare const TX_RETRY_BASE_DELAY_MS = 25;
@@ -0,0 +1,3 @@
1
+ /** The base of the jittered wait before a retry, in milliseconds (see `jitteredDelay`). */
2
+ export const TX_RETRY_BASE_DELAY_MS = 25;
3
+ //# sourceMappingURL=TX_RETRY_BASE_DELAY_MS.mjs.map
@@ -0,0 +1,2 @@
1
+ /** How many times a transaction is run again after SQLSTATE 40001 or 40P01, when `retryMax` is not given. */
2
+ export declare const TX_RETRY_MAX = 2;
@@ -0,0 +1,3 @@
1
+ /** How many times a transaction is run again after SQLSTATE 40001 or 40P01, when `retryMax` is not given. */
2
+ export const TX_RETRY_MAX = 2;
3
+ //# sourceMappingURL=TX_RETRY_MAX.mjs.map
@@ -0,0 +1,2 @@
1
+ /** The most an option `retryMax` may ask for, so that a loop is always short. */
2
+ export declare const TX_RETRY_MAX_CEILING = 10;
@@ -0,0 +1,3 @@
1
+ /** The most an option `retryMax` may ask for, so that a loop is always short. */
2
+ export const TX_RETRY_MAX_CEILING = 10;
3
+ //# sourceMappingURL=TX_RETRY_MAX_CEILING.mjs.map
@@ -0,0 +1,3 @@
1
+ import type { IRetryDelay } from "./IRetryDelay.mjs";
2
+ /** The default wait before a retry: `jitteredDelay()`. */
3
+ export declare const defaultRetryDelay: IRetryDelay;
@@ -0,0 +1,4 @@
1
+ import { jitteredDelay } from "./jitteredDelay.mjs";
2
+ /** The default wait before a retry: `jitteredDelay()`. */
3
+ export const defaultRetryDelay = jitteredDelay();
4
+ //# sourceMappingURL=defaultRetryDelay.mjs.map
@@ -0,0 +1,7 @@
1
+ import type { IRetryDelay } from "./IRetryDelay.mjs";
2
+ /**
3
+ * A wait of a random length from 0 to `TX_RETRY_BASE_DELAY_MS` times two to the power of the retry number minus one,
4
+ * both ends included ("full jitter"), so that two transactions that collided do not collide again in step.
5
+ * `random(n)` answers a whole number from 0 up to n, n excluded; the default is `node:crypto` `randomInt`.
6
+ */
7
+ export declare function jitteredDelay(random?: (maxExclusive: number) => number): IRetryDelay;
@@ -0,0 +1,16 @@
1
+ import { randomInt } from 'node:crypto';
2
+ import { TX_RETRY_BASE_DELAY_MS } from "./TX_RETRY_BASE_DELAY_MS.mjs";
3
+ /**
4
+ * A wait of a random length from 0 to `TX_RETRY_BASE_DELAY_MS` times two to the power of the retry number minus one,
5
+ * both ends included ("full jitter"), so that two transactions that collided do not collide again in step.
6
+ * `random(n)` answers a whole number from 0 up to n, n excluded; the default is `node:crypto` `randomInt`.
7
+ */
8
+ export function jitteredDelay(random = (max) => randomInt(max)) {
9
+ return (retry) => {
10
+ const wait = random(TX_RETRY_BASE_DELAY_MS * 2 ** (retry - 1) + 1);
11
+ return new Promise((done) => {
12
+ setTimeout(done, wait);
13
+ });
14
+ };
15
+ }
16
+ //# sourceMappingURL=jitteredDelay.mjs.map
@@ -0,0 +1,39 @@
1
+ import type { ITx } from "./ITx.mjs";
2
+ import type { ITxOptions } from "./ITxOptions.mjs";
3
+ import type { ITxPool } from "./ITxPool.mjs";
4
+ /**
5
+ * Runs `fn` in a transaction and answers what it answers. It is the one transaction wrapper, so that no caller writes
6
+ * its own isolation, lock timeout or retry loop.
7
+ *
8
+ * What one attempt does, in order:
9
+ *
10
+ * 1. Checks a connection out of the pool and listens to its `error` event while it holds it.
11
+ * 2. `BEGIN ISOLATION LEVEL <level> [READ ONLY]`, the text taken from a closed table (never built), then
12
+ * `SET LOCAL lock_timeout = <ms>`. `SET LOCAL` is the only form of `SET` here: the value ends with the transaction,
13
+ * so the role-level value is back for the next user of the connection, and a transaction pooler stays usable.
14
+ * 3. Runs `fn` with a handle that has one member, `query`. The pool and the connection are not reachable from the
15
+ * handle, and the handle stops working when the transaction ends, so a statement cannot run outside the
16
+ * transaction, not even through a handle that `fn` kept.
17
+ * 4. `COMMIT` when `fn` resolved; `ROLLBACK` when anything threw. A rollback that fails does not hide the error that
18
+ * caused it: the original error is thrown, and the connection is destroyed instead of returned to the pool.
19
+ *
20
+ * What the loop does with a failure of an attempt, by SQLSTATE:
21
+ *
22
+ * - `40001` (serialisation failure) and `40P01` (deadlock detected): the whole attempt was rolled back; `fn` runs again
23
+ * in a fresh transaction on a fresh checkout, after the injected delay, up to `retryMax` times (default
24
+ * `TX_RETRY_MAX`). After the last one fails too the caller gets `options.errors.internal('TX_RETRY_EXHAUSTED')`.
25
+ * - `55P03` (lock not available, the lock timeout): no retry; `options.errors.internal('LOCK_TIMEOUT')`.
26
+ * - anything else: rethrown unchanged (the same object) after the rollback.
27
+ *
28
+ * The two errors of the factory are asked for a reason and nothing else: no `cause`, no driver message, no constraint
29
+ * name. The reason goes to the log and to a counter, with the SQLSTATE and the number of attempts and nothing the
30
+ * driver wrote.
31
+ *
32
+ * A swallowed failure is not a success: if `fn` catches the error of a statement and resolves, the server answers
33
+ * `COMMIT` with the tag `ROLLBACK` (the transaction is aborted). The wrapper reads the tag and throws the first failed
34
+ * statement, which then goes through the classification above.
35
+ *
36
+ * Rejects with `TypeError` for an option out of range (before a connection is taken). `fn` may run more than once, so it
37
+ * must hold no state that a failed run leaves behind.
38
+ */
39
+ export declare function withTx<T>(pool: ITxPool, options: ITxOptions, fn: (tx: ITx) => Promise<T>): Promise<T>;
@@ -0,0 +1,41 @@
1
+ import { runTxWithRetries } from "../../../private/lib/PostgreSQL/runTxWithRetries.mjs";
2
+ import { txSettings } from "../../../private/lib/PostgreSQL/txSettings.mjs";
3
+ /**
4
+ * Runs `fn` in a transaction and answers what it answers. It is the one transaction wrapper, so that no caller writes
5
+ * its own isolation, lock timeout or retry loop.
6
+ *
7
+ * What one attempt does, in order:
8
+ *
9
+ * 1. Checks a connection out of the pool and listens to its `error` event while it holds it.
10
+ * 2. `BEGIN ISOLATION LEVEL <level> [READ ONLY]`, the text taken from a closed table (never built), then
11
+ * `SET LOCAL lock_timeout = <ms>`. `SET LOCAL` is the only form of `SET` here: the value ends with the transaction,
12
+ * so the role-level value is back for the next user of the connection, and a transaction pooler stays usable.
13
+ * 3. Runs `fn` with a handle that has one member, `query`. The pool and the connection are not reachable from the
14
+ * handle, and the handle stops working when the transaction ends, so a statement cannot run outside the
15
+ * transaction, not even through a handle that `fn` kept.
16
+ * 4. `COMMIT` when `fn` resolved; `ROLLBACK` when anything threw. A rollback that fails does not hide the error that
17
+ * caused it: the original error is thrown, and the connection is destroyed instead of returned to the pool.
18
+ *
19
+ * What the loop does with a failure of an attempt, by SQLSTATE:
20
+ *
21
+ * - `40001` (serialisation failure) and `40P01` (deadlock detected): the whole attempt was rolled back; `fn` runs again
22
+ * in a fresh transaction on a fresh checkout, after the injected delay, up to `retryMax` times (default
23
+ * `TX_RETRY_MAX`). After the last one fails too the caller gets `options.errors.internal('TX_RETRY_EXHAUSTED')`.
24
+ * - `55P03` (lock not available, the lock timeout): no retry; `options.errors.internal('LOCK_TIMEOUT')`.
25
+ * - anything else: rethrown unchanged (the same object) after the rollback.
26
+ *
27
+ * The two errors of the factory are asked for a reason and nothing else: no `cause`, no driver message, no constraint
28
+ * name. The reason goes to the log and to a counter, with the SQLSTATE and the number of attempts and nothing the
29
+ * driver wrote.
30
+ *
31
+ * A swallowed failure is not a success: if `fn` catches the error of a statement and resolves, the server answers
32
+ * `COMMIT` with the tag `ROLLBACK` (the transaction is aborted). The wrapper reads the tag and throws the first failed
33
+ * statement, which then goes through the classification above.
34
+ *
35
+ * Rejects with `TypeError` for an option out of range (before a connection is taken). `fn` may run more than once, so it
36
+ * must hold no state that a failed run leaves behind.
37
+ */
38
+ export async function withTx(pool, options, fn) {
39
+ return runTxWithRetries(pool, txSettings(options), fn, 0);
40
+ }
41
+ //# sourceMappingURL=withTx.mjs.map
@@ -0,0 +1,10 @@
1
+ /** What {@link databaseUrlReason} needs besides the URL. */
2
+ export interface IDatabaseUrlOptions {
3
+ /** The role the service must connect as; the user of the URL must equal it exactly. */
4
+ readonly expectedRole: string;
5
+ /**
6
+ * True when a loopback host may be reached without TLS (a disposable local database, a CI service container). The
7
+ * caller decides, from whatever environment signal it has: this function reads no environment variable.
8
+ */
9
+ readonly allowPlainLoopback: boolean;
10
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IDatabaseUrlOptions.mjs.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The closed words {@link databaseUrlReason} answers with; none contains a part of the URL:
3
+ *
4
+ * - `url_syntax`: whitespace, a control character or a backslash; not parseable; a fragment.
5
+ * - `url_scheme`: not `postgres://` or `postgresql://`.
6
+ * - `url_user`: no user, or a user that is not a plain identifier.
7
+ * - `url_role`: the user is not the expected role.
8
+ * - `url_host`: not a host name or an IP address.
9
+ * - `url_port`: no explicit port, or a port outside 1 to 65535.
10
+ * - `url_database`: no database name, or one that is not a plain identifier.
11
+ * - `url_query`: a query parameter other than `sslmode` and an absolute `sslrootcert`, or one given twice.
12
+ * - `url_tls`: no `sslmode=verify-full`, and not a loopback host the caller exempted.
13
+ */
14
+ export type IDatabaseUrlReason = 'url_syntax' | 'url_scheme' | 'url_user' | 'url_role' | 'url_host' | 'url_port' | 'url_database' | 'url_query' | 'url_tls';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IDatabaseUrlReason.mjs.map
@@ -0,0 +1,2 @@
1
+ /** The host names and addresses that count as loopback. Exactly these three, in lower case. */
2
+ export declare const LOOPBACK_HOSTS: readonly string[];
@@ -0,0 +1,3 @@
1
+ /** The host names and addresses that count as loopback. Exactly these three, in lower case. */
2
+ export const LOOPBACK_HOSTS = ['127.0.0.1', '::1', 'localhost'];
3
+ //# sourceMappingURL=LOOPBACK_HOSTS.mjs.map
@@ -0,0 +1,20 @@
1
+ import type { IDatabaseUrlOptions } from "./IDatabaseUrlOptions.mjs";
2
+ import type { IDatabaseUrlReason } from "./IDatabaseUrlReason.mjs";
3
+ /**
4
+ * Checks a database URL. Answers `undefined` when it is acceptable, otherwise the first reason it is not, in this order:
5
+ * syntax, scheme, user, role, host, port, database name, query, TLS. The reason is a closed word; it never contains a
6
+ * part of the URL.
7
+ *
8
+ * A URL is accepted only when it has a user equal to `expectedRole`, a host, an explicit port and one database name, and
9
+ * only when it asks for TLS with certificate and name verification (`sslmode=verify-full`), except for a loopback
10
+ * host when `allowPlainLoopback` is true.
11
+ *
12
+ * Why the URL is read so strictly. node-postgres reads a connection string with the WHATWG `URL` parser, then copies
13
+ * every query parameter over the parsed parts: `?host=`, `?port=`, `?user=` and `?password=` replace the host, the
14
+ * port, the user and the password of the URL itself, `?ssl=0` and `?sslmode=` change TLS, and `?uselibpqcompat=true`
15
+ * changes what `sslmode` means. A check that looked only at the authority would pass a URL that connects somewhere
16
+ * else, under another login, without TLS. So the query is an allow-list (`sslmode`, `sslrootcert`, each at most once),
17
+ * the user and the database name are plain identifiers (no percent-escape whose decoding two parsers could disagree
18
+ * about), and this function uses the same `URL` parser as the driver.
19
+ */
20
+ export declare function databaseUrlReason(text: string, options: IDatabaseUrlOptions): IDatabaseUrlReason | undefined;
@@ -0,0 +1,99 @@
1
+ import { isAbsolutePath } from "./isAbsolutePath.mjs";
2
+ import { isValidHost } from "./isValidHost.mjs";
3
+ import { LOOPBACK_HOSTS } from "./LOOPBACK_HOSTS.mjs";
4
+ /** The only query parameters a URL may carry. */
5
+ const ALLOWED_QUERY = ['sslmode', 'sslrootcert'];
6
+ const IDENTIFIER = /^\w[\w-]*$/;
7
+ const SCHEME = /^postgres(?:ql)?:\/\//;
8
+ /** The host of a parsed URL without the brackets of an IPv6 literal. */
9
+ const hostOf = (url) => (url.hostname.startsWith('[') ? url.hostname.slice(1, -1) : url.hostname);
10
+ /** True when a character is whitespace, a control character or a backslash. */
11
+ function hasForbiddenChar(text) {
12
+ for (const char of text) {
13
+ const code = char.charCodeAt(0);
14
+ if (code <= 0x20 || code === 0x7f || code === 0x5c)
15
+ return true;
16
+ }
17
+ return false;
18
+ }
19
+ /** The reason the text cannot be a URL at all, before it is parsed, or `undefined`. */
20
+ function syntaxReason(text) {
21
+ if (hasForbiddenChar(text))
22
+ return 'url_syntax';
23
+ return SCHEME.test(text) ? undefined : 'url_scheme';
24
+ }
25
+ /** The URL, parsed with the same `URL` parser the driver uses; `undefined` when it cannot be parsed or has a fragment. */
26
+ function parseUrl(text) {
27
+ try {
28
+ const url = new URL(text);
29
+ return url.hash === '' ? url : undefined;
30
+ }
31
+ catch {
32
+ return undefined;
33
+ }
34
+ }
35
+ function roleReason(url, expectedRole) {
36
+ // nosemgrep: ajinabraham.njsscan.dos.regex_dos.regex_dos -- IDENTIFIER is anchored with one quantifier per class, so it matches in linear time
37
+ if (!IDENTIFIER.test(url.username))
38
+ return 'url_user';
39
+ return url.username === expectedRole ? undefined : 'url_role';
40
+ }
41
+ function locationReason(url) {
42
+ if (!isValidHost(hostOf(url)))
43
+ return 'url_host';
44
+ // An absent port reads as 0 here, which the lower bound refuses; the parser has already refused a port above 65535
45
+ // and has written the digits without leading zeros.
46
+ const port = Number(url.port);
47
+ if (port < 1)
48
+ return 'url_port';
49
+ // The identifier has no `/`, so `/a/b` and a missing name both fail here.
50
+ return IDENTIFIER.test(url.pathname.slice(1)) ? undefined : 'url_database';
51
+ }
52
+ function queryReason(url) {
53
+ const seen = new Set();
54
+ for (const [key, value] of url.searchParams) {
55
+ if (!ALLOWED_QUERY.includes(key) || seen.has(key))
56
+ return 'url_query';
57
+ seen.add(key);
58
+ if (key === 'sslrootcert' && !isAbsolutePath(value))
59
+ return 'url_query';
60
+ }
61
+ return undefined;
62
+ }
63
+ /** The TLS rule: `verify-full`, or a loopback host when the caller allows plain loopback. */
64
+ function tlsReason(url, allowPlainLoopback) {
65
+ if (url.searchParams.get('sslmode') === 'verify-full')
66
+ return undefined;
67
+ const loopback = LOOPBACK_HOSTS.includes(hostOf(url).toLowerCase());
68
+ return loopback && allowPlainLoopback ? undefined : 'url_tls';
69
+ }
70
+ /**
71
+ * Checks a database URL. Answers `undefined` when it is acceptable, otherwise the first reason it is not, in this order:
72
+ * syntax, scheme, user, role, host, port, database name, query, TLS. The reason is a closed word; it never contains a
73
+ * part of the URL.
74
+ *
75
+ * A URL is accepted only when it has a user equal to `expectedRole`, a host, an explicit port and one database name, and
76
+ * only when it asks for TLS with certificate and name verification (`sslmode=verify-full`), except for a loopback
77
+ * host when `allowPlainLoopback` is true.
78
+ *
79
+ * Why the URL is read so strictly. node-postgres reads a connection string with the WHATWG `URL` parser, then copies
80
+ * every query parameter over the parsed parts: `?host=`, `?port=`, `?user=` and `?password=` replace the host, the
81
+ * port, the user and the password of the URL itself, `?ssl=0` and `?sslmode=` change TLS, and `?uselibpqcompat=true`
82
+ * changes what `sslmode` means. A check that looked only at the authority would pass a URL that connects somewhere
83
+ * else, under another login, without TLS. So the query is an allow-list (`sslmode`, `sslrootcert`, each at most once),
84
+ * the user and the database name are plain identifiers (no percent-escape whose decoding two parsers could disagree
85
+ * about), and this function uses the same `URL` parser as the driver.
86
+ */
87
+ export function databaseUrlReason(text, options) {
88
+ const early = syntaxReason(text);
89
+ if (early !== undefined)
90
+ return early;
91
+ const url = parseUrl(text);
92
+ if (url === undefined)
93
+ return 'url_syntax';
94
+ return (roleReason(url, options.expectedRole) ??
95
+ locationReason(url) ??
96
+ queryReason(url) ??
97
+ tlsReason(url, options.allowPlainLoopback));
98
+ }
99
+ //# sourceMappingURL=databaseUrlReason.mjs.map
@@ -0,0 +1,2 @@
1
+ /** True for an absolute POSIX path: starts with `/`, no `..` segment, no control character. */
2
+ export declare function isAbsolutePath(text: string): boolean;
@@ -0,0 +1,14 @@
1
+ /** True when the text holds an ASCII control character (code below 0x20, or 0x7f). */
2
+ function hasControlChar(text) {
3
+ for (const char of text) {
4
+ const code = char.charCodeAt(0);
5
+ if (code < 0x20 || code === 0x7f)
6
+ return true;
7
+ }
8
+ return false;
9
+ }
10
+ /** True for an absolute POSIX path: starts with `/`, no `..` segment, no control character. */
11
+ export function isAbsolutePath(text) {
12
+ return text.startsWith('/') && !hasControlChar(text) && !text.split('/').includes('..');
13
+ }
14
+ //# sourceMappingURL=isAbsolutePath.mjs.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * True for a host name, an IPv4 address or an IPv6 address. A scheme, a port, a path, a user, a bracket, a zone id, an
3
+ * underscore and a trailing dot are all refused. A name whose last label is all digits is refused too: it is how
4
+ * `127.1` and `999.1.1.1` look, and a resolver may read them as addresses.
5
+ */
6
+ export declare function isValidHost(text: string): boolean;
@@ -0,0 +1,20 @@
1
+ import { isIP } from 'node:net';
2
+ // eslint-disable-next-line security/detect-unsafe-regex -- nested quantifier is the bounded {0,61} inside an optional group, no backtracking blow-up
3
+ const DNS_LABEL = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?$/;
4
+ /** The last label is all digits: `127.1`, `999.1.1.1`, `8080`. */
5
+ const NUMERIC_TAIL = /(?:^|\.)\d+$/;
6
+ /**
7
+ * True for a host name, an IPv4 address or an IPv6 address. A scheme, a port, a path, a user, a bracket, a zone id, an
8
+ * underscore and a trailing dot are all refused. A name whose last label is all digits is refused too: it is how
9
+ * `127.1` and `999.1.1.1` look, and a resolver may read them as addresses.
10
+ */
11
+ export function isValidHost(text) {
12
+ if (text.length > 253)
13
+ return false;
14
+ if (isIP(text) !== 0)
15
+ return !text.includes('%');
16
+ if (!text.split('.').every((label) => DNS_LABEL.test(label)))
17
+ return false;
18
+ return !NUMERIC_TAIL.test(text);
19
+ }
20
+ //# sourceMappingURL=isValidHost.mjs.map
@@ -1,5 +1,4 @@
1
1
  export declare class StringLib {
2
- constructor();
3
2
  cleanHtml(str: string): string;
4
3
  cleanHtmlUndefined(str: string | undefined): string | undefined;
5
4
  /**
@@ -55,7 +55,6 @@ function stripTags(input) {
55
55
  }
56
56
  export class StringLib {
57
57
  // implements IStringLib
58
- constructor() { }
59
58
  cleanHtml(str) {
60
59
  return stripTags(str);
61
60
  }
@@ -1,9 +1,11 @@
1
- import { Types } from 'mongoose';
1
+ import type { Types } from 'mongoose';
2
2
  /**
3
- * Logs operations performed by users
4
- * @param owner
5
- * @param nome
6
- * @param status
7
- * @param msTot
3
+ * Kept for backwards compatibility only: this function writes nothing.
4
+ *
5
+ * It used to build a `LogStatsGraphql` document and discard it. The `.save()` call was commented out, so
6
+ * nothing reached MongoDB. The arguments are still accepted, and ignored, so that existing call sites keep
7
+ * compiling.
8
+ *
9
+ * @deprecated No-op. Nothing is logged: remove the call, or write the document yourself through the `LogStatsGraphql` model.
8
10
  */
9
11
  export declare const logGraphql: (owner: Types.ObjectId, nome: string, status: number, msTot: number) => void;
@@ -1,27 +1,13 @@
1
- import { LogStatsGraphql } from "../../../graphQL/models/MongoDB/log/LogStatsGraphql.mjs";
2
1
  /**
3
- * Logs operations performed by users
4
- * @param owner
5
- * @param nome
6
- * @param status
7
- * @param msTot
2
+ * Kept for backwards compatibility only: this function writes nothing.
3
+ *
4
+ * It used to build a `LogStatsGraphql` document and discard it. The `.save()` call was commented out, so
5
+ * nothing reached MongoDB. The arguments are still accepted, and ignored, so that existing call sites keep
6
+ * compiling.
7
+ *
8
+ * @deprecated No-op. Nothing is logged: remove the call, or write the document yourself through the `LogStatsGraphql` model.
8
9
  */
9
- export const logGraphql = function (owner, nome, status, msTot) {
10
- new LogStatsGraphql({
11
- owner,
12
- nome,
13
- status,
14
- msTot
15
- });
16
- /*
17
- return new Promise((resolve, reject) => {
18
- newStatsGraphql.save((err: any, res: any) => {
19
- if (err) {
20
- reject('Log error.' + err)
21
- } else {
22
- resolve(res)
23
- }
24
- })
25
- }) */
10
+ export const logGraphql = function () {
11
+ // Deliberately empty, see the doc above.
26
12
  };
27
13
  //# sourceMappingURL=logGraphql.mjs.map
@@ -1 +1,10 @@
1
+ /**
2
+ * Kept for backwards compatibility only: this function writes nothing.
3
+ *
4
+ * It used to build a `LogThrow` document and discard it. The `.save()` call was commented out, so nothing
5
+ * reached MongoDB, and the mail-on-error idea noted in the body was never implemented. The arguments are
6
+ * still accepted, and ignored, so that existing call sites keep compiling.
7
+ *
8
+ * @deprecated No-op. Nothing is logged: remove the call, or write the document yourself through the `LogThrow` model.
9
+ */
1
10
  export declare const logThrow: (log: string, errLevel: number) => void;
@@ -1,15 +1,15 @@
1
- import { LogThrow } from "../../../graphQL/models/MongoDB/log/LogThrow.mjs";
2
- import { Types } from 'mongoose';
3
- // const lastSendEmail = new Date();
4
- export const logThrow = function (log, errLevel) {
5
- new LogThrow({
6
- _id: new Types.ObjectId(),
7
- message: log,
8
- errLevel,
9
- inserted: new Date()
10
- });
1
+ /**
2
+ * Kept for backwards compatibility only: this function writes nothing.
3
+ *
4
+ * It used to build a `LogThrow` document and discard it. The `.save()` call was commented out, so nothing
5
+ * reached MongoDB, and the mail-on-error idea noted in the body was never implemented. The arguments are
6
+ * still accepted, and ignored, so that existing call sites keep compiling.
7
+ *
8
+ * @deprecated No-op. Nothing is logged: remove the call, or write the document yourself through the `LogThrow` model.
9
+ */
10
+ export const logThrow = function () {
11
+ // Deliberately empty, see the doc above. The original intent, never implemented:
11
12
  // send email, check last send email to avoid flooding (check last send email in collection with TTL / create a variable that stays available on every call to this function (lastSendEmail ?))
12
13
  // check db with config, e.g.: admin sets block on sending email because they're fixing the problem
13
- // return newThrowError.save()
14
14
  };
15
15
  //# sourceMappingURL=logThrow.mjs.map
package/dist/lib/hash.mjs CHANGED
@@ -5,11 +5,6 @@ import bcrypt from '@node-rs/bcrypt';
5
5
  * @param hash password hash
6
6
  */
7
7
  export async function compareHashAsync(clear, hash) {
8
- try {
9
- return await bcrypt.compare(clear, hash);
10
- }
11
- catch (err) {
12
- throw err;
13
- }
8
+ return await bcrypt.compare(clear, hash);
14
9
  }
15
10
  //# sourceMappingURL=hash.mjs.map
@@ -4,4 +4,4 @@
4
4
  * 'true' and 'false' alike — any non-empty value blocks.
5
5
  * Use this instead of deleting the token to block user access; set the flag from the control panel.
6
6
  */
7
- export declare function isSessionBlocked(redData: Record<string, string>): boolean;
7
+ export declare function isSessionBlocked(redData: Record<string, string> | null | undefined): boolean;
@@ -1,4 +1,5 @@
1
1
  import { throwErrorWrongUserInput } from "../graphQL/throw/throwErrorWrongUserInput.mjs";
2
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- published signature: removing `T` would break a consumer that passes an explicit type argument, `throwIfNotValidEnumValue<typeof MyEnum>(...)`
2
3
  export function throwIfNotValidEnumValue(enumObj, value) {
3
4
  const ret = Object.values(enumObj).includes(value);
4
5
  if (!ret) {
@@ -7,9 +7,11 @@ export function tryCatchRethrow(e) {
7
7
  throwIfMongoErr(e);
8
8
  // else throw here
9
9
  if (e instanceof GraphQLError) {
10
- // @ts-expect-error status do not exist
11
- const status = e.extensions?.http?.status || 500;
12
- const desc = e.extensions?.['description'] || '';
10
+ // The installed graphql types declare `extensions` as always present. Older majors left it undefined and the
11
+ // peer range has no floor, so it is read as optional, through the shape this function relies on.
12
+ const extensions = e.extensions;
13
+ const status = extensions?.http?.status || 500;
14
+ const desc = extensions?.description || '';
13
15
  throw throwGraphQLError(status, e.message, desc);
14
16
  }
15
17
  else {
@@ -13,6 +13,7 @@ export async function reEncode(filePath, ext, quality = 100) {
13
13
  try {
14
14
  // Read the bytes up front: sharp refuses to use one file as both input and output, which is
15
15
  // exactly what happens when the source already carries the target extension.
16
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- the path is this helper's input by design: the caller names a file it stored itself, nothing here builds it from request data
16
17
  const input = await fs.readFile(filePath);
17
18
  if (ext === 'jpeg') {
18
19
  await sharp(input).jpeg({ quality, progressive: true }).withMetadata({}).withExif({}).toFile(finalFilepath);
@@ -35,6 +36,7 @@ export async function reEncode(filePath, ext, quality = 100) {
35
36
  // extensions instead would delete the file just written whenever the two paths coincide
36
37
  if (finalFilepath !== filePath) {
37
38
  try {
39
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- same caller-supplied path as the read above
38
40
  await fs.unlink(filePath);
39
41
  }
40
42
  catch (e) {
@@ -0,0 +1,6 @@
1
+ /** A civil date of the proleptic Gregorian calendar; `year` is astronomical (1 BC is 0), `month` is 1 to 12. */
2
+ export interface ICivilDate {
3
+ readonly year: number;
4
+ readonly month: number;
5
+ readonly day: number;
6
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ICivilDate.mjs.map
@@ -0,0 +1,3 @@
1
+ import type { IClientShape } from './IClientShape.mjs';
2
+ /** The driver's `Client` class as the checked subclass needs it. */
3
+ export type IClientConstructor = new (config: Record<string, unknown>) => IClientShape;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IClientConstructor.mjs.map