@axiumine/koa-utils 7.2.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 (454) hide show
  1. package/README.md +40 -13
  2. package/dist/dataSources/MariaDB.mjs +3 -3
  3. package/dist/dataSources/MongoDB.mjs +2 -2
  4. package/dist/dataSources/PostgreSQL.mjs +3 -3
  5. package/dist/dataSources/Redis.mjs +3 -3
  6. package/dist/email/ISocketLabsClient.d.mts +8 -0
  7. package/dist/email/ISocketLabsClient.mjs +2 -0
  8. package/dist/email/ISocketLabsMessage.d.mts +20 -0
  9. package/dist/email/ISocketLabsMessage.mjs +4 -0
  10. package/dist/email/ISocketLabsSendResult.d.mts +12 -0
  11. package/dist/email/ISocketLabsSendResult.mjs +2 -0
  12. package/dist/email/ISocketLabsSenderOptions.d.mts +30 -0
  13. package/dist/email/ISocketLabsSenderOptions.mjs +3 -0
  14. package/dist/email/SocketLabsLib.d.mts +1 -0
  15. package/dist/email/SocketLabsLib.mjs +30 -21
  16. package/dist/email/createSocketLabsSender.d.mts +20 -0
  17. package/dist/email/createSocketLabsSender.mjs +66 -0
  18. package/dist/files/scanVirus.mjs +1 -1
  19. package/dist/files/storeUploadAsTemp.mjs +2 -2
  20. package/dist/graphQL/schema/mutations/login4Ever.mjs +1 -1
  21. package/dist/graphQL/schema/mutations/loginAdmin.mjs +1 -1
  22. package/dist/graphQL/schema/mutations/loginRememberme.mjs +1 -1
  23. package/dist/graphQL/schema/mutations/logout.mjs +3 -3
  24. package/dist/graphQL/schema/mutations/refresh.mjs +3 -3
  25. package/dist/graphQL/schema/mutations/resetPwd.mjs +1 -1
  26. package/dist/graphQL/schema/mutations/updatePassword.mjs +1 -1
  27. package/dist/koa/IKoaErrorHandlerContext.d.mts +11 -0
  28. package/dist/koa/IKoaErrorHandlerContext.mjs +2 -0
  29. package/dist/koa/IKoaErrorHandlerOptions.d.mts +28 -0
  30. package/dist/koa/IKoaErrorHandlerOptions.mjs +3 -0
  31. package/dist/koa/createKoaErrorHandler.d.mts +11 -0
  32. package/dist/koa/createKoaErrorHandler.mjs +37 -0
  33. package/dist/koa/middleware/authenticatedAuthorizationHandler/index.mjs +2 -2
  34. package/dist/koa/middleware/authenticatedLogoutHandler/index.mjs +2 -2
  35. package/dist/koa/middleware/authenticatedResourceHandler/index.mjs +2 -2
  36. package/dist/koa/tdwKoaErrorHandler.mjs +15 -23
  37. package/dist/lib/Constants.d.mts +0 -2
  38. package/dist/lib/Constants.mjs +0 -2
  39. package/dist/lib/MongoDB/throwMongoErrors.mjs +1 -1
  40. package/dist/lib/OBJECTID_0_OBJ.d.mts +6 -0
  41. package/dist/lib/OBJECTID_0_OBJ.mjs +8 -0
  42. package/dist/lib/PostgreSQL/clock/CLOCK_SQL.d.mts +7 -0
  43. package/dist/lib/PostgreSQL/clock/CLOCK_SQL.mjs +8 -0
  44. package/dist/lib/PostgreSQL/clock/DB_NOW_SQL.d.mts +5 -0
  45. package/dist/lib/PostgreSQL/clock/DB_NOW_SQL.mjs +6 -0
  46. package/dist/lib/PostgreSQL/clock/IClock.d.mts +4 -0
  47. package/dist/lib/PostgreSQL/clock/IClock.mjs +2 -0
  48. package/dist/lib/PostgreSQL/clock/IDbClock.d.mts +11 -0
  49. package/dist/lib/PostgreSQL/clock/IDbClock.mjs +2 -0
  50. package/dist/lib/PostgreSQL/clock/IDbClockOptions.d.mts +11 -0
  51. package/dist/lib/PostgreSQL/clock/IDbClockOptions.mjs +2 -0
  52. package/dist/lib/PostgreSQL/clock/IDbClockSeam.d.mts +10 -0
  53. package/dist/lib/PostgreSQL/clock/IDbClockSeam.mjs +2 -0
  54. package/dist/lib/PostgreSQL/clock/createDbClock.d.mts +23 -0
  55. package/dist/lib/PostgreSQL/clock/createDbClock.mjs +54 -0
  56. package/dist/lib/PostgreSQL/clock/lockTaken.d.mts +11 -0
  57. package/dist/lib/PostgreSQL/clock/lockTaken.mjs +17 -0
  58. package/dist/lib/PostgreSQL/counter/IDbCounter.d.mts +9 -0
  59. package/dist/lib/PostgreSQL/counter/IDbCounter.mjs +2 -0
  60. package/dist/lib/PostgreSQL/error/DB_CLOCK_REASONS.d.mts +12 -0
  61. package/dist/lib/PostgreSQL/error/DB_CLOCK_REASONS.mjs +20 -0
  62. package/dist/lib/PostgreSQL/error/DB_CONNECT_REASONS.d.mts +11 -0
  63. package/dist/lib/PostgreSQL/error/DB_CONNECT_REASONS.mjs +12 -0
  64. package/dist/lib/PostgreSQL/error/DB_INTERNAL_REASONS.d.mts +23 -0
  65. package/dist/lib/PostgreSQL/error/DB_INTERNAL_REASONS.mjs +35 -0
  66. package/dist/lib/PostgreSQL/error/DB_PARSE_REASONS.d.mts +13 -0
  67. package/dist/lib/PostgreSQL/error/DB_PARSE_REASONS.mjs +14 -0
  68. package/dist/lib/PostgreSQL/error/DB_STATE_REASONS.d.mts +7 -0
  69. package/dist/lib/PostgreSQL/error/DB_STATE_REASONS.mjs +8 -0
  70. package/dist/lib/PostgreSQL/error/DB_TX_REASONS.d.mts +9 -0
  71. package/dist/lib/PostgreSQL/error/DB_TX_REASONS.mjs +10 -0
  72. package/dist/lib/PostgreSQL/error/DbClockError.d.mts +6 -0
  73. package/dist/lib/PostgreSQL/error/DbClockError.mjs +27 -0
  74. package/dist/lib/PostgreSQL/error/DbConnectError.d.mts +11 -0
  75. package/dist/lib/PostgreSQL/error/DbConnectError.mjs +18 -0
  76. package/dist/lib/PostgreSQL/error/DbParseError.d.mts +11 -0
  77. package/dist/lib/PostgreSQL/error/DbParseError.mjs +16 -0
  78. package/dist/lib/PostgreSQL/error/DbStateError.d.mts +10 -0
  79. package/dist/lib/PostgreSQL/error/DbStateError.mjs +14 -0
  80. package/dist/lib/PostgreSQL/error/DbTxError.d.mts +6 -0
  81. package/dist/lib/PostgreSQL/error/DbTxError.mjs +10 -0
  82. package/dist/lib/PostgreSQL/error/IConstraintEntry.d.mts +17 -0
  83. package/dist/lib/PostgreSQL/error/IConstraintEntry.mjs +2 -0
  84. package/dist/lib/PostgreSQL/error/IConstraintEntryBuilder.d.mts +20 -0
  85. package/dist/lib/PostgreSQL/error/IConstraintEntryBuilder.mjs +2 -0
  86. package/dist/lib/PostgreSQL/error/IConstraintTable.d.mts +7 -0
  87. package/dist/lib/PostgreSQL/error/IConstraintTable.mjs +2 -0
  88. package/dist/lib/PostgreSQL/error/IDbClockReason.d.mts +3 -0
  89. package/dist/lib/PostgreSQL/error/IDbClockReason.mjs +2 -0
  90. package/dist/lib/PostgreSQL/error/IDbConnectReason.d.mts +3 -0
  91. package/dist/lib/PostgreSQL/error/IDbConnectReason.mjs +2 -0
  92. package/dist/lib/PostgreSQL/error/IDbErrorCounter.d.mts +4 -0
  93. package/dist/lib/PostgreSQL/error/IDbErrorCounter.mjs +2 -0
  94. package/dist/lib/PostgreSQL/error/IDbErrorCounterName.d.mts +7 -0
  95. package/dist/lib/PostgreSQL/error/IDbErrorCounterName.mjs +2 -0
  96. package/dist/lib/PostgreSQL/error/IDbErrorFactory.d.mts +16 -0
  97. package/dist/lib/PostgreSQL/error/IDbErrorFactory.mjs +2 -0
  98. package/dist/lib/PostgreSQL/error/IDbInternalReason.d.mts +3 -0
  99. package/dist/lib/PostgreSQL/error/IDbInternalReason.mjs +2 -0
  100. package/dist/lib/PostgreSQL/error/IDbParseReason.d.mts +3 -0
  101. package/dist/lib/PostgreSQL/error/IDbParseReason.mjs +2 -0
  102. package/dist/lib/PostgreSQL/error/IDbStateReason.d.mts +3 -0
  103. package/dist/lib/PostgreSQL/error/IDbStateReason.mjs +2 -0
  104. package/dist/lib/PostgreSQL/error/IDbTxReason.d.mts +3 -0
  105. package/dist/lib/PostgreSQL/error/IDbTxReason.mjs +2 -0
  106. package/dist/lib/PostgreSQL/error/ILockOrderReason.d.mts +3 -0
  107. package/dist/lib/PostgreSQL/error/ILockOrderReason.mjs +2 -0
  108. package/dist/lib/PostgreSQL/error/IMapDbErrorOptions.d.mts +22 -0
  109. package/dist/lib/PostgreSQL/error/IMapDbErrorOptions.mjs +2 -0
  110. package/dist/lib/PostgreSQL/error/IRoleAssertionReason.d.mts +3 -0
  111. package/dist/lib/PostgreSQL/error/IRoleAssertionReason.mjs +2 -0
  112. package/dist/lib/PostgreSQL/error/IRoleAssertionSubject.d.mts +12 -0
  113. package/dist/lib/PostgreSQL/error/IRoleAssertionSubject.mjs +2 -0
  114. package/dist/lib/PostgreSQL/error/LOCK_ORDER_REASONS.d.mts +11 -0
  115. package/dist/lib/PostgreSQL/error/LOCK_ORDER_REASONS.mjs +12 -0
  116. package/dist/lib/PostgreSQL/error/LockOrderError.d.mts +6 -0
  117. package/dist/lib/PostgreSQL/error/LockOrderError.mjs +10 -0
  118. package/dist/lib/PostgreSQL/error/ROLE_ASSERT_REASONS.d.mts +21 -0
  119. package/dist/lib/PostgreSQL/error/ROLE_ASSERT_REASONS.mjs +35 -0
  120. package/dist/lib/PostgreSQL/error/RoleAssertionError.d.mts +19 -0
  121. package/dist/lib/PostgreSQL/error/RoleAssertionError.mjs +58 -0
  122. package/dist/lib/PostgreSQL/error/buildConstraintEntry.d.mts +15 -0
  123. package/dist/lib/PostgreSQL/error/buildConstraintEntry.mjs +16 -0
  124. package/dist/lib/PostgreSQL/error/constraintNameOf.d.mts +6 -0
  125. package/dist/lib/PostgreSQL/error/constraintNameOf.mjs +17 -0
  126. package/dist/lib/PostgreSQL/error/errorNameOf.d.mts +5 -0
  127. package/dist/lib/PostgreSQL/error/errorNameOf.mjs +12 -0
  128. package/dist/lib/PostgreSQL/error/lookupConstraint.d.mts +7 -0
  129. package/dist/lib/PostgreSQL/error/lookupConstraint.mjs +8 -0
  130. package/dist/lib/PostgreSQL/error/mapDbError.d.mts +28 -0
  131. package/dist/lib/PostgreSQL/error/mapDbError.mjs +52 -0
  132. package/dist/lib/PostgreSQL/error/sqlstateField.d.mts +4 -0
  133. package/dist/lib/PostgreSQL/error/sqlstateField.mjs +5 -0
  134. package/dist/lib/PostgreSQL/error/sqlstateOf.d.mts +5 -0
  135. package/dist/lib/PostgreSQL/error/sqlstateOf.mjs +12 -0
  136. package/dist/lib/PostgreSQL/guard/IAffectedResult.d.mts +4 -0
  137. package/dist/lib/PostgreSQL/guard/IAffectedResult.mjs +2 -0
  138. package/dist/lib/PostgreSQL/guard/IGuardCounter.d.mts +3 -0
  139. package/dist/lib/PostgreSQL/guard/IGuardCounter.mjs +2 -0
  140. package/dist/lib/PostgreSQL/guard/IVersionGuardCode.d.mts +5 -0
  141. package/dist/lib/PostgreSQL/guard/IVersionGuardCode.mjs +2 -0
  142. package/dist/lib/PostgreSQL/guard/IVersionGuardField.d.mts +3 -0
  143. package/dist/lib/PostgreSQL/guard/IVersionGuardField.mjs +2 -0
  144. package/dist/lib/PostgreSQL/guard/IVersionGuardInput.d.mts +29 -0
  145. package/dist/lib/PostgreSQL/guard/IVersionGuardInput.mjs +2 -0
  146. package/dist/lib/PostgreSQL/guard/VERSION_GUARD_FIELDS.d.mts +2 -0
  147. package/dist/lib/PostgreSQL/guard/VERSION_GUARD_FIELDS.mjs +3 -0
  148. package/dist/lib/PostgreSQL/guard/assertAffected.d.mts +10 -0
  149. package/dist/lib/PostgreSQL/guard/assertAffected.mjs +17 -0
  150. package/dist/lib/PostgreSQL/guard/guardVersion.d.mts +21 -0
  151. package/dist/lib/PostgreSQL/guard/guardVersion.mjs +47 -0
  152. package/dist/lib/PostgreSQL/lock/CLAIM_LIMIT_MAX.d.mts +2 -0
  153. package/dist/lib/PostgreSQL/lock/CLAIM_LIMIT_MAX.mjs +3 -0
  154. package/dist/lib/PostgreSQL/lock/IClaimRegistry.d.mts +6 -0
  155. package/dist/lib/PostgreSQL/lock/IClaimRegistry.mjs +2 -0
  156. package/dist/lib/PostgreSQL/lock/IClaimRequest.d.mts +7 -0
  157. package/dist/lib/PostgreSQL/lock/IClaimRequest.mjs +2 -0
  158. package/dist/lib/PostgreSQL/lock/ILockAdmission.d.mts +4 -0
  159. package/dist/lib/PostgreSQL/lock/ILockAdmission.mjs +2 -0
  160. package/dist/lib/PostgreSQL/lock/ILockOrderSpec.d.mts +19 -0
  161. package/dist/lib/PostgreSQL/lock/ILockOrderSpec.mjs +2 -0
  162. package/dist/lib/PostgreSQL/lock/ILockOrderTracker.d.mts +41 -0
  163. package/dist/lib/PostgreSQL/lock/ILockOrderTracker.mjs +2 -0
  164. package/dist/lib/PostgreSQL/lock/ILockTrackerConfig.d.mts +5 -0
  165. package/dist/lib/PostgreSQL/lock/ILockTrackerConfig.mjs +2 -0
  166. package/dist/lib/PostgreSQL/lock/ILockTrackerOptions.d.mts +7 -0
  167. package/dist/lib/PostgreSQL/lock/ILockTrackerOptions.mjs +2 -0
  168. package/dist/lib/PostgreSQL/lock/IRowLockMode.d.mts +3 -0
  169. package/dist/lib/PostgreSQL/lock/IRowLockMode.mjs +2 -0
  170. package/dist/lib/PostgreSQL/lock/ROW_LOCK_MODES.d.mts +2 -0
  171. package/dist/lib/PostgreSQL/lock/ROW_LOCK_MODES.mjs +3 -0
  172. package/dist/lib/PostgreSQL/lock/claimRowsSkipLocked.d.mts +16 -0
  173. package/dist/lib/PostgreSQL/lock/claimRowsSkipLocked.mjs +32 -0
  174. package/dist/lib/PostgreSQL/lock/createLockOrderTracker.d.mts +14 -0
  175. package/dist/lib/PostgreSQL/lock/createLockOrderTracker.mjs +60 -0
  176. package/dist/lib/PostgreSQL/lock/lockedRow.d.mts +7 -0
  177. package/dist/lib/PostgreSQL/lock/lockedRow.mjs +12 -0
  178. package/dist/lib/PostgreSQL/lock/lockedRows.d.mts +3 -0
  179. package/dist/lib/PostgreSQL/lock/lockedRows.mjs +8 -0
  180. package/dist/lib/PostgreSQL/lock/rowLockModeOf.d.mts +3 -0
  181. package/dist/lib/PostgreSQL/lock/rowLockModeOf.mjs +9 -0
  182. package/dist/lib/PostgreSQL/lock/uuidOf.d.mts +2 -0
  183. package/dist/lib/PostgreSQL/lock/uuidOf.mjs +10 -0
  184. package/dist/lib/PostgreSQL/lock/uuidsOf.d.mts +5 -0
  185. package/dist/lib/PostgreSQL/lock/uuidsOf.mjs +13 -0
  186. package/dist/lib/PostgreSQL/parse/IArrayParser.d.mts +2 -0
  187. package/dist/lib/PostgreSQL/parse/IArrayParser.mjs +2 -0
  188. package/dist/lib/PostgreSQL/parse/IDriverTypes.d.mts +4 -0
  189. package/dist/lib/PostgreSQL/parse/IDriverTypes.mjs +2 -0
  190. package/dist/lib/PostgreSQL/parse/IStringParser.d.mts +2 -0
  191. package/dist/lib/PostgreSQL/parse/IStringParser.mjs +2 -0
  192. package/dist/lib/PostgreSQL/parse/ITypeParserEntry.d.mts +9 -0
  193. package/dist/lib/PostgreSQL/parse/ITypeParserEntry.mjs +2 -0
  194. package/dist/lib/PostgreSQL/parse/TYPE_PARSERS.d.mts +12 -0
  195. package/dist/lib/PostgreSQL/parse/TYPE_PARSERS.mjs +38 -0
  196. package/dist/lib/PostgreSQL/parse/arrayOf.d.mts +7 -0
  197. package/dist/lib/PostgreSQL/parse/arrayOf.mjs +50 -0
  198. package/dist/lib/PostgreSQL/parse/createTypeRegistry.d.mts +13 -0
  199. package/dist/lib/PostgreSQL/parse/createTypeRegistry.mjs +26 -0
  200. package/dist/lib/PostgreSQL/parse/parseDate.d.mts +7 -0
  201. package/dist/lib/PostgreSQL/parse/parseDate.mjs +19 -0
  202. package/dist/lib/PostgreSQL/parse/parseInt8.d.mts +6 -0
  203. package/dist/lib/PostgreSQL/parse/parseInt8.mjs +17 -0
  204. package/dist/lib/PostgreSQL/parse/parseTime.d.mts +7 -0
  205. package/dist/lib/PostgreSQL/parse/parseTime.mjs +24 -0
  206. package/dist/lib/PostgreSQL/parse/parseTimestamptz.d.mts +17 -0
  207. package/dist/lib/PostgreSQL/parse/parseTimestamptz.mjs +79 -0
  208. package/dist/lib/PostgreSQL/parse/parseUuid.d.mts +3 -0
  209. package/dist/lib/PostgreSQL/parse/parseUuid.mjs +9 -0
  210. package/dist/lib/PostgreSQL/pool/DEFAULT_CONNECT_TIMEOUT_MS.d.mts +2 -0
  211. package/dist/lib/PostgreSQL/pool/DEFAULT_CONNECT_TIMEOUT_MS.mjs +3 -0
  212. package/dist/lib/PostgreSQL/pool/DEFAULT_KEEPALIVE_INITIAL_DELAY_MS.d.mts +2 -0
  213. package/dist/lib/PostgreSQL/pool/DEFAULT_KEEPALIVE_INITIAL_DELAY_MS.mjs +3 -0
  214. package/dist/lib/PostgreSQL/pool/ICreatePoolOptions.d.mts +28 -0
  215. package/dist/lib/PostgreSQL/pool/ICreatePoolOptions.mjs +2 -0
  216. package/dist/lib/PostgreSQL/pool/IDbDriver.d.mts +12 -0
  217. package/dist/lib/PostgreSQL/pool/IDbDriver.mjs +2 -0
  218. package/dist/lib/PostgreSQL/pool/IPoolCounter.d.mts +4 -0
  219. package/dist/lib/PostgreSQL/pool/IPoolCounter.mjs +2 -0
  220. package/dist/lib/PostgreSQL/pool/IPoolCounterName.d.mts +7 -0
  221. package/dist/lib/PostgreSQL/pool/IPoolCounterName.mjs +2 -0
  222. package/dist/lib/PostgreSQL/pool/IPoolEvents.d.mts +4 -0
  223. package/dist/lib/PostgreSQL/pool/IPoolEvents.mjs +2 -0
  224. package/dist/lib/PostgreSQL/pool/IPoolLogger.d.mts +8 -0
  225. package/dist/lib/PostgreSQL/pool/IPoolLogger.mjs +2 -0
  226. package/dist/lib/PostgreSQL/pool/REQUIRED_SESSION_TIME_ZONE.d.mts +2 -0
  227. package/dist/lib/PostgreSQL/pool/REQUIRED_SESSION_TIME_ZONE.mjs +3 -0
  228. package/dist/lib/PostgreSQL/pool/createPool.d.mts +31 -0
  229. package/dist/lib/PostgreSQL/pool/createPool.mjs +67 -0
  230. package/dist/lib/PostgreSQL/role/IAssertRoleOptions.d.mts +10 -0
  231. package/dist/lib/PostgreSQL/role/IAssertRoleOptions.mjs +2 -0
  232. package/dist/lib/PostgreSQL/role/IRoleAssertion.d.mts +6 -0
  233. package/dist/lib/PostgreSQL/role/IRoleAssertion.mjs +2 -0
  234. package/dist/lib/PostgreSQL/role/IRoleGrant.d.mts +19 -0
  235. package/dist/lib/PostgreSQL/role/IRoleGrant.mjs +2 -0
  236. package/dist/lib/PostgreSQL/role/IRolePool.d.mts +6 -0
  237. package/dist/lib/PostgreSQL/role/IRolePool.mjs +2 -0
  238. package/dist/lib/PostgreSQL/role/assertRole.d.mts +36 -0
  239. package/dist/lib/PostgreSQL/role/assertRole.mjs +54 -0
  240. package/dist/lib/PostgreSQL/tx/DEFAULT_LOCK_TIMEOUT_MS.d.mts +2 -0
  241. package/dist/lib/PostgreSQL/tx/DEFAULT_LOCK_TIMEOUT_MS.mjs +3 -0
  242. package/dist/lib/PostgreSQL/tx/IRetryDelay.d.mts +2 -0
  243. package/dist/lib/PostgreSQL/tx/IRetryDelay.mjs +2 -0
  244. package/dist/lib/PostgreSQL/tx/ITx.d.mts +9 -0
  245. package/dist/lib/PostgreSQL/tx/ITx.mjs +2 -0
  246. package/dist/lib/PostgreSQL/tx/ITxClient.d.mts +12 -0
  247. package/dist/lib/PostgreSQL/tx/ITxClient.mjs +2 -0
  248. package/dist/lib/PostgreSQL/tx/ITxCounter.d.mts +4 -0
  249. package/dist/lib/PostgreSQL/tx/ITxCounter.mjs +2 -0
  250. package/dist/lib/PostgreSQL/tx/ITxCounterName.d.mts +10 -0
  251. package/dist/lib/PostgreSQL/tx/ITxCounterName.mjs +2 -0
  252. package/dist/lib/PostgreSQL/tx/ITxFailureReason.d.mts +3 -0
  253. package/dist/lib/PostgreSQL/tx/ITxFailureReason.mjs +2 -0
  254. package/dist/lib/PostgreSQL/tx/ITxIsolation.d.mts +3 -0
  255. package/dist/lib/PostgreSQL/tx/ITxIsolation.mjs +2 -0
  256. package/dist/lib/PostgreSQL/tx/ITxOptions.d.mts +27 -0
  257. package/dist/lib/PostgreSQL/tx/ITxOptions.mjs +2 -0
  258. package/dist/lib/PostgreSQL/tx/ITxPool.d.mts +5 -0
  259. package/dist/lib/PostgreSQL/tx/ITxPool.mjs +2 -0
  260. package/dist/lib/PostgreSQL/tx/ITxResult.d.mts +6 -0
  261. package/dist/lib/PostgreSQL/tx/ITxResult.mjs +2 -0
  262. package/dist/lib/PostgreSQL/tx/MAX_LOCK_TIMEOUT_MS.d.mts +2 -0
  263. package/dist/lib/PostgreSQL/tx/MAX_LOCK_TIMEOUT_MS.mjs +3 -0
  264. package/dist/lib/PostgreSQL/tx/TX_FAILURE_REASONS.d.mts +7 -0
  265. package/dist/lib/PostgreSQL/tx/TX_FAILURE_REASONS.mjs +8 -0
  266. package/dist/lib/PostgreSQL/tx/TX_ISOLATION_LEVELS.d.mts +2 -0
  267. package/dist/lib/PostgreSQL/tx/TX_ISOLATION_LEVELS.mjs +3 -0
  268. package/dist/lib/PostgreSQL/tx/TX_RETRY_BASE_DELAY_MS.d.mts +2 -0
  269. package/dist/lib/PostgreSQL/tx/TX_RETRY_BASE_DELAY_MS.mjs +3 -0
  270. package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX.d.mts +2 -0
  271. package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX.mjs +3 -0
  272. package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX_CEILING.d.mts +2 -0
  273. package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX_CEILING.mjs +3 -0
  274. package/dist/lib/PostgreSQL/tx/defaultRetryDelay.d.mts +3 -0
  275. package/dist/lib/PostgreSQL/tx/defaultRetryDelay.mjs +4 -0
  276. package/dist/lib/PostgreSQL/tx/jitteredDelay.d.mts +7 -0
  277. package/dist/lib/PostgreSQL/tx/jitteredDelay.mjs +16 -0
  278. package/dist/lib/PostgreSQL/tx/withTx.d.mts +39 -0
  279. package/dist/lib/PostgreSQL/tx/withTx.mjs +41 -0
  280. package/dist/lib/PostgreSQL/url/IDatabaseUrlOptions.d.mts +10 -0
  281. package/dist/lib/PostgreSQL/url/IDatabaseUrlOptions.mjs +2 -0
  282. package/dist/lib/PostgreSQL/url/IDatabaseUrlReason.d.mts +14 -0
  283. package/dist/lib/PostgreSQL/url/IDatabaseUrlReason.mjs +2 -0
  284. package/dist/lib/PostgreSQL/url/LOOPBACK_HOSTS.d.mts +2 -0
  285. package/dist/lib/PostgreSQL/url/LOOPBACK_HOSTS.mjs +3 -0
  286. package/dist/lib/PostgreSQL/url/databaseUrlReason.d.mts +20 -0
  287. package/dist/lib/PostgreSQL/url/databaseUrlReason.mjs +99 -0
  288. package/dist/lib/PostgreSQL/url/isAbsolutePath.d.mts +2 -0
  289. package/dist/lib/PostgreSQL/url/isAbsolutePath.mjs +14 -0
  290. package/dist/lib/PostgreSQL/url/isValidHost.d.mts +6 -0
  291. package/dist/lib/PostgreSQL/url/isValidHost.mjs +20 -0
  292. package/dist/lib/tokenOptions.mjs +2 -2
  293. package/dist/lib/tokens.mjs +3 -2
  294. package/dist/lib/tryCatchRethrow.mjs +1 -1
  295. package/dist/private/email/orFalse.mjs +1 -1
  296. package/dist/private/files/reEncode.mjs +1 -1
  297. package/dist/private/graphQL/schema/mutations/setLastLoginSQL.mjs +1 -1
  298. package/dist/private/graphQL/schema/mutations/setRedisLoginSession.mjs +3 -3
  299. package/dist/private/lib/ISentryClient.d.mts +10 -0
  300. package/dist/private/lib/ISentryClient.mjs +2 -0
  301. package/dist/private/lib/PostgreSQL/ICivilDate.d.mts +6 -0
  302. package/dist/private/lib/PostgreSQL/ICivilDate.mjs +2 -0
  303. package/dist/private/lib/PostgreSQL/IClientConstructor.d.mts +3 -0
  304. package/dist/private/lib/PostgreSQL/IClientConstructor.mjs +2 -0
  305. package/dist/private/lib/PostgreSQL/IClientShape.d.mts +10 -0
  306. package/dist/private/lib/PostgreSQL/IClientShape.mjs +2 -0
  307. package/dist/private/lib/PostgreSQL/IClockSlot.d.mts +11 -0
  308. package/dist/private/lib/PostgreSQL/IClockSlot.mjs +2 -0
  309. package/dist/private/lib/PostgreSQL/IConnectCallback.d.mts +2 -0
  310. package/dist/private/lib/PostgreSQL/IConnectCallback.mjs +2 -0
  311. package/dist/private/lib/PostgreSQL/IConnectSettings.d.mts +8 -0
  312. package/dist/private/lib/PostgreSQL/IConnectSettings.mjs +2 -0
  313. package/dist/private/lib/PostgreSQL/IHelperRank.d.mts +5 -0
  314. package/dist/private/lib/PostgreSQL/IHelperRank.mjs +2 -0
  315. package/dist/private/lib/PostgreSQL/IInternalSink.d.mts +9 -0
  316. package/dist/private/lib/PostgreSQL/IInternalSink.mjs +2 -0
  317. package/dist/private/lib/PostgreSQL/ILockOrderPlan.d.mts +8 -0
  318. package/dist/private/lib/PostgreSQL/ILockOrderPlan.mjs +2 -0
  319. package/dist/private/lib/PostgreSQL/IModeOrder.d.mts +7 -0
  320. package/dist/private/lib/PostgreSQL/IModeOrder.mjs +2 -0
  321. package/dist/private/lib/PostgreSQL/IPostgresState.d.mts +9 -0
  322. package/dist/private/lib/PostgreSQL/IPostgresState.mjs +2 -0
  323. package/dist/private/lib/PostgreSQL/IRoleCheck.d.mts +4 -0
  324. package/dist/private/lib/PostgreSQL/IRoleCheck.mjs +2 -0
  325. package/dist/private/lib/PostgreSQL/IRoleColumnCheck.d.mts +7 -0
  326. package/dist/private/lib/PostgreSQL/IRoleColumnCheck.mjs +2 -0
  327. package/dist/private/lib/PostgreSQL/IRoleObjectCheck.d.mts +6 -0
  328. package/dist/private/lib/PostgreSQL/IRoleObjectCheck.mjs +2 -0
  329. package/dist/private/lib/PostgreSQL/IRolePlan.d.mts +7 -0
  330. package/dist/private/lib/PostgreSQL/IRolePlan.mjs +2 -0
  331. package/dist/private/lib/PostgreSQL/IRoleRow.d.mts +2 -0
  332. package/dist/private/lib/PostgreSQL/IRoleRow.mjs +2 -0
  333. package/dist/private/lib/PostgreSQL/ITrackerState.d.mts +10 -0
  334. package/dist/private/lib/PostgreSQL/ITrackerState.mjs +2 -0
  335. package/dist/private/lib/PostgreSQL/ITxHandleState.d.mts +6 -0
  336. package/dist/private/lib/PostgreSQL/ITxHandleState.mjs +2 -0
  337. package/dist/private/lib/PostgreSQL/ITxSettings.d.mts +14 -0
  338. package/dist/private/lib/PostgreSQL/ITxSettings.mjs +2 -0
  339. package/dist/private/lib/PostgreSQL/POSTGRES_STATE_KEY.d.mts +5 -0
  340. package/dist/private/lib/PostgreSQL/POSTGRES_STATE_KEY.mjs +6 -0
  341. package/dist/private/lib/PostgreSQL/POSTGRES_STATE_LAYOUT.d.mts +6 -0
  342. package/dist/private/lib/PostgreSQL/POSTGRES_STATE_LAYOUT.mjs +7 -0
  343. package/dist/private/lib/PostgreSQL/ROLE_ATTRIBUTES.d.mts +2 -0
  344. package/dist/private/lib/PostgreSQL/ROLE_ATTRIBUTES.mjs +9 -0
  345. package/dist/private/lib/PostgreSQL/ROLE_CATALOG_SQL.d.mts +26 -0
  346. package/dist/private/lib/PostgreSQL/ROLE_CATALOG_SQL.mjs +84 -0
  347. package/dist/private/lib/PostgreSQL/ROLE_PRIVILEGES.d.mts +2 -0
  348. package/dist/private/lib/PostgreSQL/ROLE_PRIVILEGES.mjs +7 -0
  349. package/dist/private/lib/PostgreSQL/TX_BEGIN_STATEMENTS.d.mts +7 -0
  350. package/dist/private/lib/PostgreSQL/TX_BEGIN_STATEMENTS.mjs +11 -0
  351. package/dist/private/lib/PostgreSQL/admitLock.d.mts +10 -0
  352. package/dist/private/lib/PostgreSQL/admitLock.mjs +33 -0
  353. package/dist/private/lib/PostgreSQL/assertPoolOptions.d.mts +12 -0
  354. package/dist/private/lib/PostgreSQL/assertPoolOptions.mjs +19 -0
  355. package/dist/private/lib/PostgreSQL/assertVersionGuardInput.d.mts +6 -0
  356. package/dist/private/lib/PostgreSQL/assertVersionGuardInput.mjs +14 -0
  357. package/dist/private/lib/PostgreSQL/catalogFlag.d.mts +2 -0
  358. package/dist/private/lib/PostgreSQL/catalogFlag.mjs +7 -0
  359. package/dist/private/lib/PostgreSQL/catalogRow.d.mts +4 -0
  360. package/dist/private/lib/PostgreSQL/catalogRow.mjs +11 -0
  361. package/dist/private/lib/PostgreSQL/catalogRows.d.mts +8 -0
  362. package/dist/private/lib/PostgreSQL/catalogRows.mjs +12 -0
  363. package/dist/private/lib/PostgreSQL/catalogText.d.mts +2 -0
  364. package/dist/private/lib/PostgreSQL/catalogText.mjs +7 -0
  365. package/dist/private/lib/PostgreSQL/checkRoleOnClient.d.mts +10 -0
  366. package/dist/private/lib/PostgreSQL/checkRoleOnClient.mjs +31 -0
  367. package/dist/private/lib/PostgreSQL/checkedClient.d.mts +8 -0
  368. package/dist/private/lib/PostgreSQL/checkedClient.mjs +22 -0
  369. package/dist/private/lib/PostgreSQL/civilCalendar.d.mts +13 -0
  370. package/dist/private/lib/PostgreSQL/civilCalendar.mjs +48 -0
  371. package/dist/private/lib/PostgreSQL/clockInstant.d.mts +11 -0
  372. package/dist/private/lib/PostgreSQL/clockInstant.mjs +18 -0
  373. package/dist/private/lib/PostgreSQL/clockSlot.d.mts +3 -0
  374. package/dist/private/lib/PostgreSQL/clockSlot.mjs +11 -0
  375. package/dist/private/lib/PostgreSQL/clockStatement.d.mts +6 -0
  376. package/dist/private/lib/PostgreSQL/clockStatement.mjs +22 -0
  377. package/dist/private/lib/PostgreSQL/connectAndCheck.d.mts +8 -0
  378. package/dist/private/lib/PostgreSQL/connectAndCheck.mjs +47 -0
  379. package/dist/private/lib/PostgreSQL/constraintDetails.d.mts +7 -0
  380. package/dist/private/lib/PostgreSQL/constraintDetails.mjs +21 -0
  381. package/dist/private/lib/PostgreSQL/constraintField.d.mts +4 -0
  382. package/dist/private/lib/PostgreSQL/constraintField.mjs +5 -0
  383. package/dist/private/lib/PostgreSQL/errorCodeOf.d.mts +2 -0
  384. package/dist/private/lib/PostgreSQL/errorCodeOf.mjs +7 -0
  385. package/dist/private/lib/PostgreSQL/internalFailure.d.mts +9 -0
  386. package/dist/private/lib/PostgreSQL/internalFailure.mjs +10 -0
  387. package/dist/private/lib/PostgreSQL/isNameList.d.mts +2 -0
  388. package/dist/private/lib/PostgreSQL/isNameList.mjs +6 -0
  389. package/dist/private/lib/PostgreSQL/isOneOf.d.mts +2 -0
  390. package/dist/private/lib/PostgreSQL/isOneOf.mjs +5 -0
  391. package/dist/private/lib/PostgreSQL/isQualifiedName.d.mts +2 -0
  392. package/dist/private/lib/PostgreSQL/isQualifiedName.mjs +7 -0
  393. package/dist/private/lib/PostgreSQL/isRoleName.d.mts +2 -0
  394. package/dist/private/lib/PostgreSQL/isRoleName.mjs +7 -0
  395. package/dist/private/lib/PostgreSQL/lockOrderPlan.d.mts +8 -0
  396. package/dist/private/lib/PostgreSQL/lockOrderPlan.mjs +66 -0
  397. package/dist/private/lib/PostgreSQL/mapTypedError.d.mts +3 -0
  398. package/dist/private/lib/PostgreSQL/mapTypedError.mjs +28 -0
  399. package/dist/private/lib/PostgreSQL/mapViolation.d.mts +3 -0
  400. package/dist/private/lib/PostgreSQL/mapViolation.mjs +32 -0
  401. package/dist/private/lib/PostgreSQL/membershipOutsider.d.mts +7 -0
  402. package/dist/private/lib/PostgreSQL/membershipOutsider.mjs +17 -0
  403. package/dist/private/lib/PostgreSQL/missingColumn.d.mts +9 -0
  404. package/dist/private/lib/PostgreSQL/missingColumn.mjs +15 -0
  405. package/dist/private/lib/PostgreSQL/missingGrant.d.mts +5 -0
  406. package/dist/private/lib/PostgreSQL/missingGrant.mjs +7 -0
  407. package/dist/private/lib/PostgreSQL/missingObject.d.mts +10 -0
  408. package/dist/private/lib/PostgreSQL/missingObject.mjs +14 -0
  409. package/dist/private/lib/PostgreSQL/poolUrlSecrets.d.mts +8 -0
  410. package/dist/private/lib/PostgreSQL/poolUrlSecrets.mjs +41 -0
  411. package/dist/private/lib/PostgreSQL/postgresState.d.mts +7 -0
  412. package/dist/private/lib/PostgreSQL/postgresState.mjs +32 -0
  413. package/dist/private/lib/PostgreSQL/rankCheckOption.d.mts +2 -0
  414. package/dist/private/lib/PostgreSQL/rankCheckOption.mjs +7 -0
  415. package/dist/private/lib/PostgreSQL/readField.d.mts +5 -0
  416. package/dist/private/lib/PostgreSQL/readField.mjs +10 -0
  417. package/dist/private/lib/PostgreSQL/roleCheckOf.d.mts +7 -0
  418. package/dist/private/lib/PostgreSQL/roleCheckOf.mjs +39 -0
  419. package/dist/private/lib/PostgreSQL/roleFailureSubject.d.mts +7 -0
  420. package/dist/private/lib/PostgreSQL/roleFailureSubject.mjs +12 -0
  421. package/dist/private/lib/PostgreSQL/rolePlan.d.mts +7 -0
  422. package/dist/private/lib/PostgreSQL/rolePlan.mjs +26 -0
  423. package/dist/private/lib/PostgreSQL/runRoleChecks.d.mts +17 -0
  424. package/dist/private/lib/PostgreSQL/runRoleChecks.mjs +48 -0
  425. package/dist/private/lib/PostgreSQL/runTxAttempt.d.mts +12 -0
  426. package/dist/private/lib/PostgreSQL/runTxAttempt.mjs +50 -0
  427. package/dist/private/lib/PostgreSQL/runTxBody.d.mts +11 -0
  428. package/dist/private/lib/PostgreSQL/runTxBody.mjs +19 -0
  429. package/dist/private/lib/PostgreSQL/runTxWithRetries.d.mts +10 -0
  430. package/dist/private/lib/PostgreSQL/runTxWithRetries.mjs +31 -0
  431. package/dist/private/lib/PostgreSQL/scrubSecrets.d.mts +2 -0
  432. package/dist/private/lib/PostgreSQL/scrubSecrets.mjs +6 -0
  433. package/dist/private/lib/PostgreSQL/txFailure.d.mts +4 -0
  434. package/dist/private/lib/PostgreSQL/txFailure.mjs +7 -0
  435. package/dist/private/lib/PostgreSQL/txHandle.d.mts +9 -0
  436. package/dist/private/lib/PostgreSQL/txHandle.mjs +26 -0
  437. package/dist/private/lib/PostgreSQL/txSettings.d.mts +7 -0
  438. package/dist/private/lib/PostgreSQL/txSettings.mjs +48 -0
  439. package/dist/private/lib/PostgreSQL/versionText.d.mts +5 -0
  440. package/dist/private/lib/PostgreSQL/versionText.mjs +12 -0
  441. package/dist/private/lib/access/assertResetAllowed.mjs +1 -1
  442. package/dist/private/lib/access/db/deleteUserByEmail.mjs +1 -1
  443. package/dist/private/lib/access/db/enableEmailAccess.mjs +1 -1
  444. package/dist/private/lib/access/db/userData4VerifyEmail.mjs +1 -1
  445. package/dist/private/lib/access/handleBadDB.mjs +1 -1
  446. package/dist/private/lib/createSentryClient.d.mts +7 -0
  447. package/dist/private/lib/createSentryClient.mjs +20 -0
  448. package/dist/private/lib/importOptional.d.mts +7 -0
  449. package/dist/private/lib/importOptional.mjs +27 -0
  450. package/dist/private/lib/loadEnv.d.mts +12 -0
  451. package/dist/private/lib/loadEnv.mjs +14 -0
  452. package/dist/private/lib/sentry.d.mts +3 -0
  453. package/dist/private/lib/sentry.mjs +12 -0
  454. package/package.json +563 -7
@@ -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[];
@@ -0,0 +1,38 @@
1
+ import { DbParseError } from "../error/DbParseError.mjs";
2
+ import { arrayOf } from "./arrayOf.mjs";
3
+ import { parseDate } from "./parseDate.mjs";
4
+ import { parseInt8 } from "./parseInt8.mjs";
5
+ import { parseTime } from "./parseTime.mjs";
6
+ import { parseTimestamptz } from "./parseTimestamptz.mjs";
7
+ import { parseUuid } from "./parseUuid.mjs";
8
+ /** A parser that refuses: the driver's own would hand over a `Date`, and these parsers never build one. */
9
+ function refuse(typeName) {
10
+ return () => {
11
+ throw new DbParseError('UNSUPPORTED_TYPE', typeName);
12
+ };
13
+ }
14
+ /**
15
+ * The parsers of this library, by the OID of the type they read. The OIDs are those of the built-in types (`SELECT oid,
16
+ * typname FROM pg_type`; the same numbers are in the text parsers of `pg-types` and in the PostgreSQL catalog source
17
+ * `pg_type.dat`).
18
+ *
19
+ * Arrays are separate types: the driver's scalar parsers do not apply to an array of the same element (the OID of
20
+ * `date[]` is not the OID of `date`), so each array type has its own entry. The driver's own `date[]` parser returns
21
+ * `Date` values, its `time[]` parser returns the text with seconds, and a type it has no parser for comes back as the
22
+ * raw text `{...}`.
23
+ */
24
+ export const TYPE_PARSERS = [
25
+ { oid: 20, typeName: 'bigint', parse: parseInt8 },
26
+ { oid: 1082, typeName: 'date', parse: parseDate },
27
+ { oid: 1083, typeName: 'time without time zone', parse: parseTime },
28
+ { oid: 1184, typeName: 'timestamp with time zone', parse: parseTimestamptz },
29
+ { oid: 1016, typeName: 'bigint[]', parse: arrayOf(parseInt8, 'bigint[]') },
30
+ { oid: 1182, typeName: 'date[]', parse: arrayOf(parseDate, 'date[]') },
31
+ { oid: 1183, typeName: 'time without time zone[]', parse: arrayOf(parseTime, 'time without time zone[]') },
32
+ { oid: 1185, typeName: 'timestamp with time zone[]', parse: arrayOf(parseTimestamptz, 'timestamp with time zone[]') },
33
+ { oid: 2951, typeName: 'uuid[]', parse: arrayOf(parseUuid, 'uuid[]') },
34
+ // No parser exists for these: the driver's would return a Date.
35
+ { oid: 1114, typeName: 'timestamp without time zone', parse: refuse('timestamp without time zone') },
36
+ { oid: 1115, typeName: 'timestamp without time zone[]', parse: refuse('timestamp without time zone[]') }
37
+ ];
38
+ //# sourceMappingURL=TYPE_PARSERS.mjs.map
@@ -0,0 +1,7 @@
1
+ import type { IArrayParser } from "./IArrayParser.mjs";
2
+ import type { IStringParser } from "./IStringParser.mjs";
3
+ /**
4
+ * The parser of an array type: each element goes through `element`, a `NULL` stays `null`. `typeName` (`date[]`, ...)
5
+ * is the name the error carries. Only one-dimensional arrays are read; anything else is `MALFORMED`.
6
+ */
7
+ export declare function arrayOf(element: IStringParser, typeName: string): IArrayParser;
@@ -0,0 +1,50 @@
1
+ import { DbParseError } from "../error/DbParseError.mjs";
2
+ // One element: a double-quoted string with `\"` and `\\` escapes (group 1 holds its text between the quotes), or a run of
3
+ // characters without a comma, brace, quote, backslash or white space (group 1 absent). Sticky, so it matches exactly at
4
+ // `lastIndex`.
5
+ const ELEMENT = /"((?:[^"\\]|\\[\s\S])*)"|[^,{}"\\\s]+/y;
6
+ const ESCAPE = /\\([\s\S])/g;
7
+ // The element that starts at `from`, or undefined when none does. An unquoted `NULL`, in any case, is the null value.
8
+ function scanElement(inner, from) {
9
+ ELEMENT.lastIndex = from;
10
+ const match = ELEMENT.exec(inner);
11
+ if (match === null)
12
+ return undefined;
13
+ const quoted = match[1];
14
+ if (quoted !== undefined)
15
+ return { value: quoted.replace(ESCAPE, '$1'), next: ELEMENT.lastIndex };
16
+ return { value: match[0].toUpperCase() === 'NULL' ? null : match[0], next: ELEMENT.lastIndex };
17
+ }
18
+ // Splits the text of a one-dimensional array into its elements. The grammar is the one the server prints: `{}` or
19
+ // `{e1,e2,...}`. A second dimension (`{{1,2},{3,4}}`), a dimension prefix (`[0:1]={...}`) and anything after the closing
20
+ // brace are `MALFORMED`: a parser that guessed would hand the caller a wrong shape.
21
+ function splitArray(text, typeName) {
22
+ if (!text.startsWith('{') || !text.endsWith('}'))
23
+ throw new DbParseError('MALFORMED', typeName);
24
+ const inner = text.slice(1, -1);
25
+ const elements = [];
26
+ if (inner === '')
27
+ return elements;
28
+ let at = 0;
29
+ for (;;) {
30
+ const element = scanElement(inner, at);
31
+ if (element === undefined)
32
+ throw new DbParseError('MALFORMED', typeName);
33
+ elements.push(element.value);
34
+ if (element.next === inner.length)
35
+ return elements;
36
+ // Anything but a comma after an element (a space, a brace, a quote) is not the grammar.
37
+ if (inner.charAt(element.next) !== ',')
38
+ throw new DbParseError('MALFORMED', typeName);
39
+ // Past the comma.
40
+ at = element.next + 1;
41
+ }
42
+ }
43
+ /**
44
+ * The parser of an array type: each element goes through `element`, a `NULL` stays `null`. `typeName` (`date[]`, ...)
45
+ * is the name the error carries. Only one-dimensional arrays are read; anything else is `MALFORMED`.
46
+ */
47
+ export function arrayOf(element, typeName) {
48
+ return (text) => splitArray(text, typeName).map((item) => (item === null ? null : element(item)));
49
+ }
50
+ //# sourceMappingURL=arrayOf.mjs.map
@@ -0,0 +1,13 @@
1
+ import type { IDriverTypes } from "./IDriverTypes.mjs";
2
+ /**
3
+ * A type registry for one pool: the parsers of {@link TYPE_PARSERS} for their OIDs in text format, the driver's for
4
+ * everything else. Results are read in text format; a binary request goes to the driver unchanged.
5
+ *
6
+ * node-postgres reads a `types` option of the pool (passed on to every client of it): any object with a
7
+ * `getTypeParser(oid, format)` method. The object built here answers its own parsers first and the driver's for every
8
+ * other type. It is a new object per call and it never calls `types.setTypeParser`, which writes the process-wide
9
+ * registry of the driver; so the parsers of one pool are not seen by another pool, by a plain `new Pool()`, or by
10
+ * `pg.types.getTypeParser`. The driver is asked on every call, so a parser registered on it later is seen for the types
11
+ * this library does not parse.
12
+ */
13
+ export declare function createTypeRegistry(driverTypes: IDriverTypes): IDriverTypes;
@@ -0,0 +1,26 @@
1
+ import { TYPE_PARSERS } from "./TYPE_PARSERS.mjs";
2
+ /**
3
+ * A type registry for one pool: the parsers of {@link TYPE_PARSERS} for their OIDs in text format, the driver's for
4
+ * everything else. Results are read in text format; a binary request goes to the driver unchanged.
5
+ *
6
+ * node-postgres reads a `types` option of the pool (passed on to every client of it): any object with a
7
+ * `getTypeParser(oid, format)` method. The object built here answers its own parsers first and the driver's for every
8
+ * other type. It is a new object per call and it never calls `types.setTypeParser`, which writes the process-wide
9
+ * registry of the driver; so the parsers of one pool are not seen by another pool, by a plain `new Pool()`, or by
10
+ * `pg.types.getTypeParser`. The driver is asked on every call, so a parser registered on it later is seen for the types
11
+ * this library does not parse.
12
+ */
13
+ export function createTypeRegistry(driverTypes) {
14
+ const own = new Map(TYPE_PARSERS.map((entry) => [entry.oid, entry.parse]));
15
+ return {
16
+ getTypeParser(oid, format) {
17
+ if (format !== 'binary') {
18
+ const parse = own.get(oid);
19
+ if (parse !== undefined)
20
+ return parse;
21
+ }
22
+ return driverTypes.getTypeParser(oid, format);
23
+ }
24
+ };
25
+ }
26
+ //# sourceMappingURL=createTypeRegistry.mjs.map
@@ -0,0 +1,7 @@
1
+ import type { IStringParser } from "./IStringParser.mjs";
2
+ /**
3
+ * `date`: `YYYY-MM-DD`, years 0001 to 9999, checked against the calendar, returned unchanged. Under `DateStyle` ISO (the
4
+ * default) this is what the server prints. `infinity`, a BC date, a year of five digits and any other style are
5
+ * `MALFORMED`; a day that does not exist and year 0000 are `OUT_OF_RANGE`. No `Date` is built.
6
+ */
7
+ export declare const parseDate: IStringParser;
@@ -0,0 +1,19 @@
1
+ import { DbParseError } from "../error/DbParseError.mjs";
2
+ import { isCivilDate, MIN_YEAR } from "../../../private/lib/PostgreSQL/civilCalendar.mjs";
3
+ const DATE_TEXT = /^(\d{4})-(\d{2})-(\d{2})$/;
4
+ /**
5
+ * `date`: `YYYY-MM-DD`, years 0001 to 9999, checked against the calendar, returned unchanged. Under `DateStyle` ISO (the
6
+ * default) this is what the server prints. `infinity`, a BC date, a year of five digits and any other style are
7
+ * `MALFORMED`; a day that does not exist and year 0000 are `OUT_OF_RANGE`. No `Date` is built.
8
+ */
9
+ export const parseDate = (text) => {
10
+ const match = DATE_TEXT.exec(text);
11
+ if (match === null)
12
+ throw new DbParseError('MALFORMED', 'date');
13
+ const year = Number(match[1]);
14
+ if (year < MIN_YEAR || !isCivilDate(year, Number(match[2]), Number(match[3]))) {
15
+ throw new DbParseError('OUT_OF_RANGE', 'date');
16
+ }
17
+ return text;
18
+ };
19
+ //# sourceMappingURL=parseDate.mjs.map
@@ -0,0 +1,6 @@
1
+ import type { IStringParser } from "./IStringParser.mjs";
2
+ /**
3
+ * `int8`: the decimal string, unchanged, after a check of the shape and of the 64-bit range. It stays a string because
4
+ * a JavaScript number holds integers exactly only up to 2^53 - 1.
5
+ */
6
+ export declare const parseInt8: IStringParser;
@@ -0,0 +1,17 @@
1
+ import { DbParseError } from "../error/DbParseError.mjs";
2
+ const INT8_TEXT = /^(?:0|-?[1-9]\d*)$/;
3
+ const INT8_MIN = -(2n ** 63n);
4
+ const INT8_MAX = 2n ** 63n - 1n;
5
+ /**
6
+ * `int8`: the decimal string, unchanged, after a check of the shape and of the 64-bit range. It stays a string because
7
+ * a JavaScript number holds integers exactly only up to 2^53 - 1.
8
+ */
9
+ export const parseInt8 = (text) => {
10
+ if (!INT8_TEXT.test(text))
11
+ throw new DbParseError('MALFORMED', 'bigint');
12
+ const value = BigInt(text);
13
+ if (value < INT8_MIN || value > INT8_MAX)
14
+ throw new DbParseError('OUT_OF_RANGE', 'bigint');
15
+ return text;
16
+ };
17
+ //# sourceMappingURL=parseInt8.mjs.map
@@ -0,0 +1,7 @@
1
+ import type { IStringParser } from "./IStringParser.mjs";
2
+ /**
3
+ * `time`: `HH:mm`. The text must have zero seconds and no fraction of a second; a value with any of them is refused
4
+ * with `TIME_HAS_SECONDS`, not rounded or cut, because a silent cut would turn two different stored values into one.
5
+ * `24:00:00`, which PostgreSQL accepts, is `OUT_OF_RANGE`.
6
+ */
7
+ export declare const parseTime: IStringParser;
@@ -0,0 +1,24 @@
1
+ import { DbParseError } from "../error/DbParseError.mjs";
2
+ // eslint-disable-next-line security/detect-unsafe-regex -- the only nested quantifier is the bounded {1,6} fraction inside an optional group, input is one short text
3
+ const TIME_TEXT = /^(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,6}))?$/;
4
+ const TYPE_NAME = 'time without time zone';
5
+ /**
6
+ * `time`: `HH:mm`. The text must have zero seconds and no fraction of a second; a value with any of them is refused
7
+ * with `TIME_HAS_SECONDS`, not rounded or cut, because a silent cut would turn two different stored values into one.
8
+ * `24:00:00`, which PostgreSQL accepts, is `OUT_OF_RANGE`.
9
+ */
10
+ export const parseTime = (text) => {
11
+ const match = TIME_TEXT.exec(text);
12
+ if (match === null)
13
+ throw new DbParseError('MALFORMED', TYPE_NAME);
14
+ const hour = Number(match[1]);
15
+ if (hour > 24 || Number(match[2]) > 59 || Number(match[3]) > 59)
16
+ throw new DbParseError('MALFORMED', TYPE_NAME);
17
+ if (Number(match[3]) !== 0 || (match[4] !== undefined && /[1-9]/.test(match[4]))) {
18
+ throw new DbParseError('TIME_HAS_SECONDS', TYPE_NAME);
19
+ }
20
+ if (hour === 24)
21
+ throw new DbParseError('OUT_OF_RANGE', TYPE_NAME);
22
+ return text.slice(0, 5);
23
+ };
24
+ //# sourceMappingURL=parseTime.mjs.map
@@ -0,0 +1,17 @@
1
+ import type { IStringParser } from "./IStringParser.mjs";
2
+ /**
3
+ * `timestamptz`: `YYYY-MM-DDTHH:mm:ss.SSSZ`, the instant in UTC.
4
+ *
5
+ * The server prints the instant in the offset of the SESSION zone (`+00`, `-08`, `+05:30`, and for old dates with
6
+ * seconds, `-07:52:58`). The parser reads the offset and converts, so a session in another zone gives the same string.
7
+ *
8
+ * The part of a millisecond that the text carries (microseconds) is cut off toward zero on the line of epoch
9
+ * milliseconds, which is what a JavaScript time value does with a fraction (`TimeClip`). Not rounded: `.999999` of a
10
+ * second is `.999`. For an instant from 1970 on, that is the same as cutting the digits. For an instant before 1970 the
11
+ * epoch value is negative, and toward zero is later in time: the instant `1969-12-31 23:59:59.999999` (epoch minus one
12
+ * microsecond) becomes `1970-01-01T00:00:00.000Z`, and `23:59:59.9985` (epoch minus 1.5 ms) becomes `23:59:59.999`.
13
+ *
14
+ * A text in another shape (another `DateStyle`, `infinity`, a field out of range) is `MALFORMED`. A valid text whose
15
+ * UTC year is outside 1 to 9999 is `OUT_OF_RANGE`. No `Date` is built.
16
+ */
17
+ export declare const parseTimestamptz: IStringParser;
@@ -0,0 +1,79 @@
1
+ import { DbParseError } from "../error/DbParseError.mjs";
2
+ import { civilFromDays, daysFromCivil, isCivilDate, MAX_YEAR, MIN_YEAR, pad } from "../../../private/lib/PostgreSQL/civilCalendar.mjs";
3
+ // year (four to six digits: a session zone ahead of UTC prints 10000-01-01 for the last hours of 9999), date, time,
4
+ // fraction, offset (hours, optional minutes, optional seconds), optional ` BC`.
5
+ const TIMESTAMPTZ_TEXT =
6
+ // eslint-disable-next-line security/detect-unsafe-regex -- nested quantifiers are all bounded ({1,6}, {4,6}) inside optional groups, input is one short text
7
+ /^(\d{4,6})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,6}))?([+-])(\d{2})(?::(\d{2})(?::(\d{2}))?)?( BC)?$/;
8
+ const TYPE_NAME = 'timestamp with time zone';
9
+ const SECONDS_PER_DAY = 86400;
10
+ const MS_PER_DAY = 86_400_000;
11
+ const malformed = () => new DbParseError('MALFORMED', TYPE_NAME);
12
+ function readParts(match) {
13
+ return {
14
+ // A BC year prints as its count of years before 1 AD; the astronomical year is one less than minus it.
15
+ year: match[12] === undefined ? Number(match[1]) : 1 - Number(match[1]),
16
+ month: Number(match[2]),
17
+ day: Number(match[3]),
18
+ hour: Number(match[4]),
19
+ minute: Number(match[5]),
20
+ second: Number(match[6]),
21
+ microseconds: Number((match[7] ?? '').padEnd(6, '0')),
22
+ offsetSign: match[8] === '-' ? -1 : 1,
23
+ offsetHours: Number(match[9]),
24
+ offsetMinutes: Number(match[10] ?? 0),
25
+ offsetSeconds: Number(match[11] ?? 0)
26
+ };
27
+ }
28
+ // Every field against its range; the offset hours are not bounded here, the offset is whatever the server printed.
29
+ const isReadable = (p) => isCivilDate(p.year, p.month, p.day) &&
30
+ p.hour <= 23 &&
31
+ p.minute <= 59 &&
32
+ p.second <= 59 &&
33
+ p.offsetMinutes <= 59 &&
34
+ p.offsetSeconds <= 59;
35
+ // Epoch milliseconds, the part below a millisecond cut off toward zero (see parseTimestamptz).
36
+ function epochMsOf(p) {
37
+ const offset = p.offsetSign * (p.offsetHours * 3600 + p.offsetMinutes * 60 + p.offsetSeconds);
38
+ const localSeconds = daysFromCivil(p.year, p.month, p.day) * SECONDS_PER_DAY + p.hour * 3600 + p.minute * 60 + p.second;
39
+ const wholeMs = (localSeconds - offset) * 1000 + Math.floor(p.microseconds / 1000);
40
+ // The part below a millisecond is positive, so the exact value is wholeMs plus a fraction: toward zero is wholeMs when
41
+ // that is not negative, and one later when it is.
42
+ return wholeMs < 0 && p.microseconds % 1000 > 0 ? wholeMs + 1 : wholeMs;
43
+ }
44
+ function isoOf(epochMs) {
45
+ const days = Math.floor(epochMs / MS_PER_DAY);
46
+ const civil = civilFromDays(days);
47
+ if (civil.year < MIN_YEAR || civil.year > MAX_YEAR)
48
+ throw new DbParseError('OUT_OF_RANGE', TYPE_NAME);
49
+ const msOfDay = epochMs - days * MS_PER_DAY;
50
+ const secondOfDay = Math.floor(msOfDay / 1000);
51
+ return (`${pad(civil.year, 4)}-${pad(civil.month, 2)}-${pad(civil.day, 2)}` +
52
+ `T${pad(Math.floor(secondOfDay / 3600), 2)}:${pad(Math.floor((secondOfDay % 3600) / 60), 2)}` +
53
+ `:${pad(secondOfDay % 60, 2)}.${pad(msOfDay % 1000, 3)}Z`);
54
+ }
55
+ /**
56
+ * `timestamptz`: `YYYY-MM-DDTHH:mm:ss.SSSZ`, the instant in UTC.
57
+ *
58
+ * The server prints the instant in the offset of the SESSION zone (`+00`, `-08`, `+05:30`, and for old dates with
59
+ * seconds, `-07:52:58`). The parser reads the offset and converts, so a session in another zone gives the same string.
60
+ *
61
+ * The part of a millisecond that the text carries (microseconds) is cut off toward zero on the line of epoch
62
+ * milliseconds, which is what a JavaScript time value does with a fraction (`TimeClip`). Not rounded: `.999999` of a
63
+ * second is `.999`. For an instant from 1970 on, that is the same as cutting the digits. For an instant before 1970 the
64
+ * epoch value is negative, and toward zero is later in time: the instant `1969-12-31 23:59:59.999999` (epoch minus one
65
+ * microsecond) becomes `1970-01-01T00:00:00.000Z`, and `23:59:59.9985` (epoch minus 1.5 ms) becomes `23:59:59.999`.
66
+ *
67
+ * A text in another shape (another `DateStyle`, `infinity`, a field out of range) is `MALFORMED`. A valid text whose
68
+ * UTC year is outside 1 to 9999 is `OUT_OF_RANGE`. No `Date` is built.
69
+ */
70
+ export const parseTimestamptz = (text) => {
71
+ const match = TIMESTAMPTZ_TEXT.exec(text);
72
+ if (match === null)
73
+ throw malformed();
74
+ const parts = readParts(match);
75
+ if (!isReadable(parts))
76
+ throw malformed();
77
+ return isoOf(epochMsOf(parts));
78
+ };
79
+ //# sourceMappingURL=parseTimestamptz.mjs.map
@@ -0,0 +1,3 @@
1
+ import type { IStringParser } from "./IStringParser.mjs";
2
+ /** `uuid`: the lower case text the server prints, checked and returned unchanged. Used for the elements of `uuid[]`. */
3
+ export declare const parseUuid: IStringParser;
@@ -0,0 +1,9 @@
1
+ import { DbParseError } from "../error/DbParseError.mjs";
2
+ const UUID_TEXT = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
3
+ /** `uuid`: the lower case text the server prints, checked and returned unchanged. Used for the elements of `uuid[]`. */
4
+ export const parseUuid = (text) => {
5
+ if (!UUID_TEXT.test(text))
6
+ throw new DbParseError('MALFORMED', 'uuid');
7
+ return text;
8
+ };
9
+ //# sourceMappingURL=parseUuid.mjs.map
@@ -0,0 +1,2 @@
1
+ /** How long a connection, its login and its session check may take, in milliseconds. */
2
+ export declare const DEFAULT_CONNECT_TIMEOUT_MS = 5000;
@@ -0,0 +1,3 @@
1
+ /** How long a connection, its login and its session check may take, in milliseconds. */
2
+ export const DEFAULT_CONNECT_TIMEOUT_MS = 5_000;
3
+ //# sourceMappingURL=DEFAULT_CONNECT_TIMEOUT_MS.mjs.map
@@ -0,0 +1,2 @@
1
+ /** Idle time before the first TCP keepalive probe on a pooled connection, in milliseconds. */
2
+ export declare const DEFAULT_KEEPALIVE_INITIAL_DELAY_MS = 10000;
@@ -0,0 +1,3 @@
1
+ /** Idle time before the first TCP keepalive probe on a pooled connection, in milliseconds. */
2
+ export const DEFAULT_KEEPALIVE_INITIAL_DELAY_MS = 10_000;
3
+ //# sourceMappingURL=DEFAULT_KEEPALIVE_INITIAL_DELAY_MS.mjs.map
@@ -0,0 +1,28 @@
1
+ import type { IDbDriver } from "./IDbDriver.mjs";
2
+ import type { IPoolCounter } from "./IPoolCounter.mjs";
3
+ import type { IPoolEvents } from "./IPoolEvents.mjs";
4
+ import type { IPoolLogger } from "./IPoolLogger.mjs";
5
+ /** The options of `createPool`. */
6
+ export interface ICreatePoolOptions<TPool extends IPoolEvents = IPoolEvents> {
7
+ /** The node-postgres module. */
8
+ readonly driver: IDbDriver<TPool>;
9
+ /**
10
+ * The connection string, `postgres://role@host:port/database`, with a password after the role and a colon and an
11
+ * optional query of `sslmode` and `sslrootcert`. The password may be left out when the server trusts the connection.
12
+ */
13
+ readonly url: string;
14
+ /** The most connections the pool opens; a whole number from 1. */
15
+ readonly max: number;
16
+ /** The `application_name` of every session, at most 63 characters of `A-Z a-z 0-9 _ . : -`. */
17
+ readonly applicationName: string;
18
+ /** The logger of the service; the factory writes the idle-client errors and the connect failures to it. */
19
+ readonly logger: IPoolLogger;
20
+ /** Where the factory counts. Default: nowhere. */
21
+ readonly counter?: IPoolCounter;
22
+ /** Deadline of the connect, login and session check, in milliseconds. Default `DEFAULT_CONNECT_TIMEOUT_MS`. */
23
+ readonly connectTimeoutMs?: number;
24
+ /** TCP keepalive on pooled connections. Default `true`. */
25
+ readonly keepAlive?: boolean;
26
+ /** Idle time before the first keepalive probe, in milliseconds. Default `DEFAULT_KEEPALIVE_INITIAL_DELAY_MS`. */
27
+ readonly keepAliveInitialDelayMs?: number;
28
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ICreatePoolOptions.mjs.map
@@ -0,0 +1,12 @@
1
+ import type { IDriverTypes } from "../parse/IDriverTypes.mjs";
2
+ import type { IPoolEvents } from "./IPoolEvents.mjs";
3
+ /**
4
+ * The driver module, `import pg from 'pg'`: the node-postgres module is a parameter of `createPool`, never an import.
5
+ * The members are typed loosely on purpose: the factory calls them through narrow shapes of its own, and a test against
6
+ * the real module is the check that the shapes are right.
7
+ */
8
+ export interface IDbDriver<TPool extends IPoolEvents = IPoolEvents> {
9
+ readonly Client: new (config: never) => unknown;
10
+ readonly Pool: new (config: never) => TPool;
11
+ readonly types: IDriverTypes;
12
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IDbDriver.mjs.map