@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.
- package/README.md +40 -13
- package/dist/dataSources/MariaDB.mjs +3 -3
- package/dist/dataSources/MongoDB.mjs +2 -2
- package/dist/dataSources/PostgreSQL.mjs +3 -3
- package/dist/dataSources/Redis.mjs +3 -3
- package/dist/email/ISocketLabsClient.d.mts +8 -0
- package/dist/email/ISocketLabsClient.mjs +2 -0
- package/dist/email/ISocketLabsMessage.d.mts +20 -0
- package/dist/email/ISocketLabsMessage.mjs +4 -0
- package/dist/email/ISocketLabsSendResult.d.mts +12 -0
- package/dist/email/ISocketLabsSendResult.mjs +2 -0
- package/dist/email/ISocketLabsSenderOptions.d.mts +30 -0
- package/dist/email/ISocketLabsSenderOptions.mjs +3 -0
- package/dist/email/SocketLabsLib.d.mts +1 -0
- package/dist/email/SocketLabsLib.mjs +30 -21
- package/dist/email/createSocketLabsSender.d.mts +20 -0
- package/dist/email/createSocketLabsSender.mjs +66 -0
- package/dist/files/scanVirus.mjs +1 -1
- package/dist/files/storeUploadAsTemp.mjs +2 -2
- package/dist/graphQL/schema/mutations/login4Ever.mjs +1 -1
- package/dist/graphQL/schema/mutations/loginAdmin.mjs +1 -1
- package/dist/graphQL/schema/mutations/loginRememberme.mjs +1 -1
- package/dist/graphQL/schema/mutations/logout.mjs +3 -3
- package/dist/graphQL/schema/mutations/refresh.mjs +3 -3
- package/dist/graphQL/schema/mutations/resetPwd.mjs +1 -1
- package/dist/graphQL/schema/mutations/updatePassword.mjs +1 -1
- package/dist/koa/IKoaErrorHandlerContext.d.mts +11 -0
- package/dist/koa/IKoaErrorHandlerContext.mjs +2 -0
- package/dist/koa/IKoaErrorHandlerOptions.d.mts +28 -0
- package/dist/koa/IKoaErrorHandlerOptions.mjs +3 -0
- package/dist/koa/createKoaErrorHandler.d.mts +11 -0
- package/dist/koa/createKoaErrorHandler.mjs +37 -0
- package/dist/koa/middleware/authenticatedAuthorizationHandler/index.mjs +2 -2
- package/dist/koa/middleware/authenticatedLogoutHandler/index.mjs +2 -2
- package/dist/koa/middleware/authenticatedResourceHandler/index.mjs +2 -2
- package/dist/koa/tdwKoaErrorHandler.mjs +15 -23
- package/dist/lib/Constants.d.mts +0 -2
- package/dist/lib/Constants.mjs +0 -2
- package/dist/lib/MongoDB/throwMongoErrors.mjs +1 -1
- package/dist/lib/OBJECTID_0_OBJ.d.mts +6 -0
- package/dist/lib/OBJECTID_0_OBJ.mjs +8 -0
- package/dist/lib/PostgreSQL/clock/CLOCK_SQL.d.mts +7 -0
- package/dist/lib/PostgreSQL/clock/CLOCK_SQL.mjs +8 -0
- package/dist/lib/PostgreSQL/clock/DB_NOW_SQL.d.mts +5 -0
- package/dist/lib/PostgreSQL/clock/DB_NOW_SQL.mjs +6 -0
- package/dist/lib/PostgreSQL/clock/IClock.d.mts +4 -0
- package/dist/lib/PostgreSQL/clock/IClock.mjs +2 -0
- package/dist/lib/PostgreSQL/clock/IDbClock.d.mts +11 -0
- package/dist/lib/PostgreSQL/clock/IDbClock.mjs +2 -0
- package/dist/lib/PostgreSQL/clock/IDbClockOptions.d.mts +11 -0
- package/dist/lib/PostgreSQL/clock/IDbClockOptions.mjs +2 -0
- package/dist/lib/PostgreSQL/clock/IDbClockSeam.d.mts +10 -0
- package/dist/lib/PostgreSQL/clock/IDbClockSeam.mjs +2 -0
- package/dist/lib/PostgreSQL/clock/createDbClock.d.mts +23 -0
- package/dist/lib/PostgreSQL/clock/createDbClock.mjs +54 -0
- package/dist/lib/PostgreSQL/clock/lockTaken.d.mts +11 -0
- package/dist/lib/PostgreSQL/clock/lockTaken.mjs +17 -0
- package/dist/lib/PostgreSQL/counter/IDbCounter.d.mts +9 -0
- package/dist/lib/PostgreSQL/counter/IDbCounter.mjs +2 -0
- package/dist/lib/PostgreSQL/error/DB_CLOCK_REASONS.d.mts +12 -0
- package/dist/lib/PostgreSQL/error/DB_CLOCK_REASONS.mjs +20 -0
- package/dist/lib/PostgreSQL/error/DB_CONNECT_REASONS.d.mts +11 -0
- package/dist/lib/PostgreSQL/error/DB_CONNECT_REASONS.mjs +12 -0
- package/dist/lib/PostgreSQL/error/DB_INTERNAL_REASONS.d.mts +23 -0
- package/dist/lib/PostgreSQL/error/DB_INTERNAL_REASONS.mjs +35 -0
- package/dist/lib/PostgreSQL/error/DB_PARSE_REASONS.d.mts +13 -0
- package/dist/lib/PostgreSQL/error/DB_PARSE_REASONS.mjs +14 -0
- package/dist/lib/PostgreSQL/error/DB_STATE_REASONS.d.mts +7 -0
- package/dist/lib/PostgreSQL/error/DB_STATE_REASONS.mjs +8 -0
- package/dist/lib/PostgreSQL/error/DB_TX_REASONS.d.mts +9 -0
- package/dist/lib/PostgreSQL/error/DB_TX_REASONS.mjs +10 -0
- package/dist/lib/PostgreSQL/error/DbClockError.d.mts +6 -0
- package/dist/lib/PostgreSQL/error/DbClockError.mjs +27 -0
- package/dist/lib/PostgreSQL/error/DbConnectError.d.mts +11 -0
- package/dist/lib/PostgreSQL/error/DbConnectError.mjs +18 -0
- package/dist/lib/PostgreSQL/error/DbParseError.d.mts +11 -0
- package/dist/lib/PostgreSQL/error/DbParseError.mjs +16 -0
- package/dist/lib/PostgreSQL/error/DbStateError.d.mts +10 -0
- package/dist/lib/PostgreSQL/error/DbStateError.mjs +14 -0
- package/dist/lib/PostgreSQL/error/DbTxError.d.mts +6 -0
- package/dist/lib/PostgreSQL/error/DbTxError.mjs +10 -0
- package/dist/lib/PostgreSQL/error/IConstraintEntry.d.mts +17 -0
- package/dist/lib/PostgreSQL/error/IConstraintEntry.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IConstraintEntryBuilder.d.mts +20 -0
- package/dist/lib/PostgreSQL/error/IConstraintEntryBuilder.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IConstraintTable.d.mts +7 -0
- package/dist/lib/PostgreSQL/error/IConstraintTable.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbClockReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/IDbClockReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbConnectReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/IDbConnectReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbErrorCounter.d.mts +4 -0
- package/dist/lib/PostgreSQL/error/IDbErrorCounter.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbErrorCounterName.d.mts +7 -0
- package/dist/lib/PostgreSQL/error/IDbErrorCounterName.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbErrorFactory.d.mts +16 -0
- package/dist/lib/PostgreSQL/error/IDbErrorFactory.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbInternalReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/IDbInternalReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbParseReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/IDbParseReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbStateReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/IDbStateReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IDbTxReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/IDbTxReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/ILockOrderReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/ILockOrderReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IMapDbErrorOptions.d.mts +22 -0
- package/dist/lib/PostgreSQL/error/IMapDbErrorOptions.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IRoleAssertionReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/error/IRoleAssertionReason.mjs +2 -0
- package/dist/lib/PostgreSQL/error/IRoleAssertionSubject.d.mts +12 -0
- package/dist/lib/PostgreSQL/error/IRoleAssertionSubject.mjs +2 -0
- package/dist/lib/PostgreSQL/error/LOCK_ORDER_REASONS.d.mts +11 -0
- package/dist/lib/PostgreSQL/error/LOCK_ORDER_REASONS.mjs +12 -0
- package/dist/lib/PostgreSQL/error/LockOrderError.d.mts +6 -0
- package/dist/lib/PostgreSQL/error/LockOrderError.mjs +10 -0
- package/dist/lib/PostgreSQL/error/ROLE_ASSERT_REASONS.d.mts +21 -0
- package/dist/lib/PostgreSQL/error/ROLE_ASSERT_REASONS.mjs +35 -0
- package/dist/lib/PostgreSQL/error/RoleAssertionError.d.mts +19 -0
- package/dist/lib/PostgreSQL/error/RoleAssertionError.mjs +58 -0
- package/dist/lib/PostgreSQL/error/buildConstraintEntry.d.mts +15 -0
- package/dist/lib/PostgreSQL/error/buildConstraintEntry.mjs +16 -0
- package/dist/lib/PostgreSQL/error/constraintNameOf.d.mts +6 -0
- package/dist/lib/PostgreSQL/error/constraintNameOf.mjs +17 -0
- package/dist/lib/PostgreSQL/error/errorNameOf.d.mts +5 -0
- package/dist/lib/PostgreSQL/error/errorNameOf.mjs +12 -0
- package/dist/lib/PostgreSQL/error/lookupConstraint.d.mts +7 -0
- package/dist/lib/PostgreSQL/error/lookupConstraint.mjs +8 -0
- package/dist/lib/PostgreSQL/error/mapDbError.d.mts +28 -0
- package/dist/lib/PostgreSQL/error/mapDbError.mjs +52 -0
- package/dist/lib/PostgreSQL/error/sqlstateField.d.mts +4 -0
- package/dist/lib/PostgreSQL/error/sqlstateField.mjs +5 -0
- package/dist/lib/PostgreSQL/error/sqlstateOf.d.mts +5 -0
- package/dist/lib/PostgreSQL/error/sqlstateOf.mjs +12 -0
- package/dist/lib/PostgreSQL/guard/IAffectedResult.d.mts +4 -0
- package/dist/lib/PostgreSQL/guard/IAffectedResult.mjs +2 -0
- package/dist/lib/PostgreSQL/guard/IGuardCounter.d.mts +3 -0
- package/dist/lib/PostgreSQL/guard/IGuardCounter.mjs +2 -0
- package/dist/lib/PostgreSQL/guard/IVersionGuardCode.d.mts +5 -0
- package/dist/lib/PostgreSQL/guard/IVersionGuardCode.mjs +2 -0
- package/dist/lib/PostgreSQL/guard/IVersionGuardField.d.mts +3 -0
- package/dist/lib/PostgreSQL/guard/IVersionGuardField.mjs +2 -0
- package/dist/lib/PostgreSQL/guard/IVersionGuardInput.d.mts +29 -0
- package/dist/lib/PostgreSQL/guard/IVersionGuardInput.mjs +2 -0
- package/dist/lib/PostgreSQL/guard/VERSION_GUARD_FIELDS.d.mts +2 -0
- package/dist/lib/PostgreSQL/guard/VERSION_GUARD_FIELDS.mjs +3 -0
- package/dist/lib/PostgreSQL/guard/assertAffected.d.mts +10 -0
- package/dist/lib/PostgreSQL/guard/assertAffected.mjs +17 -0
- package/dist/lib/PostgreSQL/guard/guardVersion.d.mts +21 -0
- package/dist/lib/PostgreSQL/guard/guardVersion.mjs +47 -0
- package/dist/lib/PostgreSQL/lock/CLAIM_LIMIT_MAX.d.mts +2 -0
- package/dist/lib/PostgreSQL/lock/CLAIM_LIMIT_MAX.mjs +3 -0
- package/dist/lib/PostgreSQL/lock/IClaimRegistry.d.mts +6 -0
- package/dist/lib/PostgreSQL/lock/IClaimRegistry.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/IClaimRequest.d.mts +7 -0
- package/dist/lib/PostgreSQL/lock/IClaimRequest.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/ILockAdmission.d.mts +4 -0
- package/dist/lib/PostgreSQL/lock/ILockAdmission.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/ILockOrderSpec.d.mts +19 -0
- package/dist/lib/PostgreSQL/lock/ILockOrderSpec.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/ILockOrderTracker.d.mts +41 -0
- package/dist/lib/PostgreSQL/lock/ILockOrderTracker.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/ILockTrackerConfig.d.mts +5 -0
- package/dist/lib/PostgreSQL/lock/ILockTrackerConfig.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/ILockTrackerOptions.d.mts +7 -0
- package/dist/lib/PostgreSQL/lock/ILockTrackerOptions.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/IRowLockMode.d.mts +3 -0
- package/dist/lib/PostgreSQL/lock/IRowLockMode.mjs +2 -0
- package/dist/lib/PostgreSQL/lock/ROW_LOCK_MODES.d.mts +2 -0
- package/dist/lib/PostgreSQL/lock/ROW_LOCK_MODES.mjs +3 -0
- package/dist/lib/PostgreSQL/lock/claimRowsSkipLocked.d.mts +16 -0
- package/dist/lib/PostgreSQL/lock/claimRowsSkipLocked.mjs +32 -0
- package/dist/lib/PostgreSQL/lock/createLockOrderTracker.d.mts +14 -0
- package/dist/lib/PostgreSQL/lock/createLockOrderTracker.mjs +60 -0
- package/dist/lib/PostgreSQL/lock/lockedRow.d.mts +7 -0
- package/dist/lib/PostgreSQL/lock/lockedRow.mjs +12 -0
- package/dist/lib/PostgreSQL/lock/lockedRows.d.mts +3 -0
- package/dist/lib/PostgreSQL/lock/lockedRows.mjs +8 -0
- package/dist/lib/PostgreSQL/lock/rowLockModeOf.d.mts +3 -0
- package/dist/lib/PostgreSQL/lock/rowLockModeOf.mjs +9 -0
- package/dist/lib/PostgreSQL/lock/uuidOf.d.mts +2 -0
- package/dist/lib/PostgreSQL/lock/uuidOf.mjs +10 -0
- package/dist/lib/PostgreSQL/lock/uuidsOf.d.mts +5 -0
- package/dist/lib/PostgreSQL/lock/uuidsOf.mjs +13 -0
- package/dist/lib/PostgreSQL/parse/IArrayParser.d.mts +2 -0
- package/dist/lib/PostgreSQL/parse/IArrayParser.mjs +2 -0
- package/dist/lib/PostgreSQL/parse/IDriverTypes.d.mts +4 -0
- package/dist/lib/PostgreSQL/parse/IDriverTypes.mjs +2 -0
- package/dist/lib/PostgreSQL/parse/IStringParser.d.mts +2 -0
- package/dist/lib/PostgreSQL/parse/IStringParser.mjs +2 -0
- package/dist/lib/PostgreSQL/parse/ITypeParserEntry.d.mts +9 -0
- package/dist/lib/PostgreSQL/parse/ITypeParserEntry.mjs +2 -0
- package/dist/lib/PostgreSQL/parse/TYPE_PARSERS.d.mts +12 -0
- package/dist/lib/PostgreSQL/parse/TYPE_PARSERS.mjs +38 -0
- package/dist/lib/PostgreSQL/parse/arrayOf.d.mts +7 -0
- package/dist/lib/PostgreSQL/parse/arrayOf.mjs +50 -0
- package/dist/lib/PostgreSQL/parse/createTypeRegistry.d.mts +13 -0
- package/dist/lib/PostgreSQL/parse/createTypeRegistry.mjs +26 -0
- package/dist/lib/PostgreSQL/parse/parseDate.d.mts +7 -0
- package/dist/lib/PostgreSQL/parse/parseDate.mjs +19 -0
- package/dist/lib/PostgreSQL/parse/parseInt8.d.mts +6 -0
- package/dist/lib/PostgreSQL/parse/parseInt8.mjs +17 -0
- package/dist/lib/PostgreSQL/parse/parseTime.d.mts +7 -0
- package/dist/lib/PostgreSQL/parse/parseTime.mjs +24 -0
- package/dist/lib/PostgreSQL/parse/parseTimestamptz.d.mts +17 -0
- package/dist/lib/PostgreSQL/parse/parseTimestamptz.mjs +79 -0
- package/dist/lib/PostgreSQL/parse/parseUuid.d.mts +3 -0
- package/dist/lib/PostgreSQL/parse/parseUuid.mjs +9 -0
- package/dist/lib/PostgreSQL/pool/DEFAULT_CONNECT_TIMEOUT_MS.d.mts +2 -0
- package/dist/lib/PostgreSQL/pool/DEFAULT_CONNECT_TIMEOUT_MS.mjs +3 -0
- package/dist/lib/PostgreSQL/pool/DEFAULT_KEEPALIVE_INITIAL_DELAY_MS.d.mts +2 -0
- package/dist/lib/PostgreSQL/pool/DEFAULT_KEEPALIVE_INITIAL_DELAY_MS.mjs +3 -0
- package/dist/lib/PostgreSQL/pool/ICreatePoolOptions.d.mts +28 -0
- package/dist/lib/PostgreSQL/pool/ICreatePoolOptions.mjs +2 -0
- package/dist/lib/PostgreSQL/pool/IDbDriver.d.mts +12 -0
- package/dist/lib/PostgreSQL/pool/IDbDriver.mjs +2 -0
- package/dist/lib/PostgreSQL/pool/IPoolCounter.d.mts +4 -0
- package/dist/lib/PostgreSQL/pool/IPoolCounter.mjs +2 -0
- package/dist/lib/PostgreSQL/pool/IPoolCounterName.d.mts +7 -0
- package/dist/lib/PostgreSQL/pool/IPoolCounterName.mjs +2 -0
- package/dist/lib/PostgreSQL/pool/IPoolEvents.d.mts +4 -0
- package/dist/lib/PostgreSQL/pool/IPoolEvents.mjs +2 -0
- package/dist/lib/PostgreSQL/pool/IPoolLogger.d.mts +8 -0
- package/dist/lib/PostgreSQL/pool/IPoolLogger.mjs +2 -0
- package/dist/lib/PostgreSQL/pool/REQUIRED_SESSION_TIME_ZONE.d.mts +2 -0
- package/dist/lib/PostgreSQL/pool/REQUIRED_SESSION_TIME_ZONE.mjs +3 -0
- package/dist/lib/PostgreSQL/pool/createPool.d.mts +31 -0
- package/dist/lib/PostgreSQL/pool/createPool.mjs +67 -0
- package/dist/lib/PostgreSQL/role/IAssertRoleOptions.d.mts +10 -0
- package/dist/lib/PostgreSQL/role/IAssertRoleOptions.mjs +2 -0
- package/dist/lib/PostgreSQL/role/IRoleAssertion.d.mts +6 -0
- package/dist/lib/PostgreSQL/role/IRoleAssertion.mjs +2 -0
- package/dist/lib/PostgreSQL/role/IRoleGrant.d.mts +19 -0
- package/dist/lib/PostgreSQL/role/IRoleGrant.mjs +2 -0
- package/dist/lib/PostgreSQL/role/IRolePool.d.mts +6 -0
- package/dist/lib/PostgreSQL/role/IRolePool.mjs +2 -0
- package/dist/lib/PostgreSQL/role/assertRole.d.mts +36 -0
- package/dist/lib/PostgreSQL/role/assertRole.mjs +54 -0
- package/dist/lib/PostgreSQL/tx/DEFAULT_LOCK_TIMEOUT_MS.d.mts +2 -0
- package/dist/lib/PostgreSQL/tx/DEFAULT_LOCK_TIMEOUT_MS.mjs +3 -0
- package/dist/lib/PostgreSQL/tx/IRetryDelay.d.mts +2 -0
- package/dist/lib/PostgreSQL/tx/IRetryDelay.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITx.d.mts +9 -0
- package/dist/lib/PostgreSQL/tx/ITx.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxClient.d.mts +12 -0
- package/dist/lib/PostgreSQL/tx/ITxClient.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxCounter.d.mts +4 -0
- package/dist/lib/PostgreSQL/tx/ITxCounter.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxCounterName.d.mts +10 -0
- package/dist/lib/PostgreSQL/tx/ITxCounterName.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxFailureReason.d.mts +3 -0
- package/dist/lib/PostgreSQL/tx/ITxFailureReason.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxIsolation.d.mts +3 -0
- package/dist/lib/PostgreSQL/tx/ITxIsolation.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxOptions.d.mts +27 -0
- package/dist/lib/PostgreSQL/tx/ITxOptions.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxPool.d.mts +5 -0
- package/dist/lib/PostgreSQL/tx/ITxPool.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/ITxResult.d.mts +6 -0
- package/dist/lib/PostgreSQL/tx/ITxResult.mjs +2 -0
- package/dist/lib/PostgreSQL/tx/MAX_LOCK_TIMEOUT_MS.d.mts +2 -0
- package/dist/lib/PostgreSQL/tx/MAX_LOCK_TIMEOUT_MS.mjs +3 -0
- package/dist/lib/PostgreSQL/tx/TX_FAILURE_REASONS.d.mts +7 -0
- package/dist/lib/PostgreSQL/tx/TX_FAILURE_REASONS.mjs +8 -0
- package/dist/lib/PostgreSQL/tx/TX_ISOLATION_LEVELS.d.mts +2 -0
- package/dist/lib/PostgreSQL/tx/TX_ISOLATION_LEVELS.mjs +3 -0
- package/dist/lib/PostgreSQL/tx/TX_RETRY_BASE_DELAY_MS.d.mts +2 -0
- package/dist/lib/PostgreSQL/tx/TX_RETRY_BASE_DELAY_MS.mjs +3 -0
- package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX.d.mts +2 -0
- package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX.mjs +3 -0
- package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX_CEILING.d.mts +2 -0
- package/dist/lib/PostgreSQL/tx/TX_RETRY_MAX_CEILING.mjs +3 -0
- package/dist/lib/PostgreSQL/tx/defaultRetryDelay.d.mts +3 -0
- package/dist/lib/PostgreSQL/tx/defaultRetryDelay.mjs +4 -0
- package/dist/lib/PostgreSQL/tx/jitteredDelay.d.mts +7 -0
- package/dist/lib/PostgreSQL/tx/jitteredDelay.mjs +16 -0
- package/dist/lib/PostgreSQL/tx/withTx.d.mts +39 -0
- package/dist/lib/PostgreSQL/tx/withTx.mjs +41 -0
- package/dist/lib/PostgreSQL/url/IDatabaseUrlOptions.d.mts +10 -0
- package/dist/lib/PostgreSQL/url/IDatabaseUrlOptions.mjs +2 -0
- package/dist/lib/PostgreSQL/url/IDatabaseUrlReason.d.mts +14 -0
- package/dist/lib/PostgreSQL/url/IDatabaseUrlReason.mjs +2 -0
- package/dist/lib/PostgreSQL/url/LOOPBACK_HOSTS.d.mts +2 -0
- package/dist/lib/PostgreSQL/url/LOOPBACK_HOSTS.mjs +3 -0
- package/dist/lib/PostgreSQL/url/databaseUrlReason.d.mts +20 -0
- package/dist/lib/PostgreSQL/url/databaseUrlReason.mjs +99 -0
- package/dist/lib/PostgreSQL/url/isAbsolutePath.d.mts +2 -0
- package/dist/lib/PostgreSQL/url/isAbsolutePath.mjs +14 -0
- package/dist/lib/PostgreSQL/url/isValidHost.d.mts +6 -0
- package/dist/lib/PostgreSQL/url/isValidHost.mjs +20 -0
- package/dist/lib/tokenOptions.mjs +2 -2
- package/dist/lib/tokens.mjs +3 -2
- package/dist/lib/tryCatchRethrow.mjs +1 -1
- package/dist/private/email/orFalse.mjs +1 -1
- package/dist/private/files/reEncode.mjs +1 -1
- package/dist/private/graphQL/schema/mutations/setLastLoginSQL.mjs +1 -1
- package/dist/private/graphQL/schema/mutations/setRedisLoginSession.mjs +3 -3
- package/dist/private/lib/ISentryClient.d.mts +10 -0
- package/dist/private/lib/ISentryClient.mjs +2 -0
- package/dist/private/lib/PostgreSQL/ICivilDate.d.mts +6 -0
- package/dist/private/lib/PostgreSQL/ICivilDate.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IClientConstructor.d.mts +3 -0
- package/dist/private/lib/PostgreSQL/IClientConstructor.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IClientShape.d.mts +10 -0
- package/dist/private/lib/PostgreSQL/IClientShape.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IClockSlot.d.mts +11 -0
- package/dist/private/lib/PostgreSQL/IClockSlot.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IConnectCallback.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/IConnectCallback.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IConnectSettings.d.mts +8 -0
- package/dist/private/lib/PostgreSQL/IConnectSettings.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IHelperRank.d.mts +5 -0
- package/dist/private/lib/PostgreSQL/IHelperRank.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IInternalSink.d.mts +9 -0
- package/dist/private/lib/PostgreSQL/IInternalSink.mjs +2 -0
- package/dist/private/lib/PostgreSQL/ILockOrderPlan.d.mts +8 -0
- package/dist/private/lib/PostgreSQL/ILockOrderPlan.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IModeOrder.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/IModeOrder.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IPostgresState.d.mts +9 -0
- package/dist/private/lib/PostgreSQL/IPostgresState.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IRoleCheck.d.mts +4 -0
- package/dist/private/lib/PostgreSQL/IRoleCheck.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IRoleColumnCheck.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/IRoleColumnCheck.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IRoleObjectCheck.d.mts +6 -0
- package/dist/private/lib/PostgreSQL/IRoleObjectCheck.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IRolePlan.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/IRolePlan.mjs +2 -0
- package/dist/private/lib/PostgreSQL/IRoleRow.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/IRoleRow.mjs +2 -0
- package/dist/private/lib/PostgreSQL/ITrackerState.d.mts +10 -0
- package/dist/private/lib/PostgreSQL/ITrackerState.mjs +2 -0
- package/dist/private/lib/PostgreSQL/ITxHandleState.d.mts +6 -0
- package/dist/private/lib/PostgreSQL/ITxHandleState.mjs +2 -0
- package/dist/private/lib/PostgreSQL/ITxSettings.d.mts +14 -0
- package/dist/private/lib/PostgreSQL/ITxSettings.mjs +2 -0
- package/dist/private/lib/PostgreSQL/POSTGRES_STATE_KEY.d.mts +5 -0
- package/dist/private/lib/PostgreSQL/POSTGRES_STATE_KEY.mjs +6 -0
- package/dist/private/lib/PostgreSQL/POSTGRES_STATE_LAYOUT.d.mts +6 -0
- package/dist/private/lib/PostgreSQL/POSTGRES_STATE_LAYOUT.mjs +7 -0
- package/dist/private/lib/PostgreSQL/ROLE_ATTRIBUTES.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/ROLE_ATTRIBUTES.mjs +9 -0
- package/dist/private/lib/PostgreSQL/ROLE_CATALOG_SQL.d.mts +26 -0
- package/dist/private/lib/PostgreSQL/ROLE_CATALOG_SQL.mjs +84 -0
- package/dist/private/lib/PostgreSQL/ROLE_PRIVILEGES.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/ROLE_PRIVILEGES.mjs +7 -0
- package/dist/private/lib/PostgreSQL/TX_BEGIN_STATEMENTS.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/TX_BEGIN_STATEMENTS.mjs +11 -0
- package/dist/private/lib/PostgreSQL/admitLock.d.mts +10 -0
- package/dist/private/lib/PostgreSQL/admitLock.mjs +33 -0
- package/dist/private/lib/PostgreSQL/assertPoolOptions.d.mts +12 -0
- package/dist/private/lib/PostgreSQL/assertPoolOptions.mjs +19 -0
- package/dist/private/lib/PostgreSQL/assertVersionGuardInput.d.mts +6 -0
- package/dist/private/lib/PostgreSQL/assertVersionGuardInput.mjs +14 -0
- package/dist/private/lib/PostgreSQL/catalogFlag.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/catalogFlag.mjs +7 -0
- package/dist/private/lib/PostgreSQL/catalogRow.d.mts +4 -0
- package/dist/private/lib/PostgreSQL/catalogRow.mjs +11 -0
- package/dist/private/lib/PostgreSQL/catalogRows.d.mts +8 -0
- package/dist/private/lib/PostgreSQL/catalogRows.mjs +12 -0
- package/dist/private/lib/PostgreSQL/catalogText.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/catalogText.mjs +7 -0
- package/dist/private/lib/PostgreSQL/checkRoleOnClient.d.mts +10 -0
- package/dist/private/lib/PostgreSQL/checkRoleOnClient.mjs +31 -0
- package/dist/private/lib/PostgreSQL/checkedClient.d.mts +8 -0
- package/dist/private/lib/PostgreSQL/checkedClient.mjs +22 -0
- package/dist/private/lib/PostgreSQL/civilCalendar.d.mts +13 -0
- package/dist/private/lib/PostgreSQL/civilCalendar.mjs +48 -0
- package/dist/private/lib/PostgreSQL/clockInstant.d.mts +11 -0
- package/dist/private/lib/PostgreSQL/clockInstant.mjs +18 -0
- package/dist/private/lib/PostgreSQL/clockSlot.d.mts +3 -0
- package/dist/private/lib/PostgreSQL/clockSlot.mjs +11 -0
- package/dist/private/lib/PostgreSQL/clockStatement.d.mts +6 -0
- package/dist/private/lib/PostgreSQL/clockStatement.mjs +22 -0
- package/dist/private/lib/PostgreSQL/connectAndCheck.d.mts +8 -0
- package/dist/private/lib/PostgreSQL/connectAndCheck.mjs +47 -0
- package/dist/private/lib/PostgreSQL/constraintDetails.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/constraintDetails.mjs +21 -0
- package/dist/private/lib/PostgreSQL/constraintField.d.mts +4 -0
- package/dist/private/lib/PostgreSQL/constraintField.mjs +5 -0
- package/dist/private/lib/PostgreSQL/errorCodeOf.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/errorCodeOf.mjs +7 -0
- package/dist/private/lib/PostgreSQL/internalFailure.d.mts +9 -0
- package/dist/private/lib/PostgreSQL/internalFailure.mjs +10 -0
- package/dist/private/lib/PostgreSQL/isNameList.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/isNameList.mjs +6 -0
- package/dist/private/lib/PostgreSQL/isOneOf.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/isOneOf.mjs +5 -0
- package/dist/private/lib/PostgreSQL/isQualifiedName.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/isQualifiedName.mjs +7 -0
- package/dist/private/lib/PostgreSQL/isRoleName.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/isRoleName.mjs +7 -0
- package/dist/private/lib/PostgreSQL/lockOrderPlan.d.mts +8 -0
- package/dist/private/lib/PostgreSQL/lockOrderPlan.mjs +66 -0
- package/dist/private/lib/PostgreSQL/mapTypedError.d.mts +3 -0
- package/dist/private/lib/PostgreSQL/mapTypedError.mjs +28 -0
- package/dist/private/lib/PostgreSQL/mapViolation.d.mts +3 -0
- package/dist/private/lib/PostgreSQL/mapViolation.mjs +32 -0
- package/dist/private/lib/PostgreSQL/membershipOutsider.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/membershipOutsider.mjs +17 -0
- package/dist/private/lib/PostgreSQL/missingColumn.d.mts +9 -0
- package/dist/private/lib/PostgreSQL/missingColumn.mjs +15 -0
- package/dist/private/lib/PostgreSQL/missingGrant.d.mts +5 -0
- package/dist/private/lib/PostgreSQL/missingGrant.mjs +7 -0
- package/dist/private/lib/PostgreSQL/missingObject.d.mts +10 -0
- package/dist/private/lib/PostgreSQL/missingObject.mjs +14 -0
- package/dist/private/lib/PostgreSQL/poolUrlSecrets.d.mts +8 -0
- package/dist/private/lib/PostgreSQL/poolUrlSecrets.mjs +41 -0
- package/dist/private/lib/PostgreSQL/postgresState.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/postgresState.mjs +32 -0
- package/dist/private/lib/PostgreSQL/rankCheckOption.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/rankCheckOption.mjs +7 -0
- package/dist/private/lib/PostgreSQL/readField.d.mts +5 -0
- package/dist/private/lib/PostgreSQL/readField.mjs +10 -0
- package/dist/private/lib/PostgreSQL/roleCheckOf.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/roleCheckOf.mjs +39 -0
- package/dist/private/lib/PostgreSQL/roleFailureSubject.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/roleFailureSubject.mjs +12 -0
- package/dist/private/lib/PostgreSQL/rolePlan.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/rolePlan.mjs +26 -0
- package/dist/private/lib/PostgreSQL/runRoleChecks.d.mts +17 -0
- package/dist/private/lib/PostgreSQL/runRoleChecks.mjs +48 -0
- package/dist/private/lib/PostgreSQL/runTxAttempt.d.mts +12 -0
- package/dist/private/lib/PostgreSQL/runTxAttempt.mjs +50 -0
- package/dist/private/lib/PostgreSQL/runTxBody.d.mts +11 -0
- package/dist/private/lib/PostgreSQL/runTxBody.mjs +19 -0
- package/dist/private/lib/PostgreSQL/runTxWithRetries.d.mts +10 -0
- package/dist/private/lib/PostgreSQL/runTxWithRetries.mjs +31 -0
- package/dist/private/lib/PostgreSQL/scrubSecrets.d.mts +2 -0
- package/dist/private/lib/PostgreSQL/scrubSecrets.mjs +6 -0
- package/dist/private/lib/PostgreSQL/txFailure.d.mts +4 -0
- package/dist/private/lib/PostgreSQL/txFailure.mjs +7 -0
- package/dist/private/lib/PostgreSQL/txHandle.d.mts +9 -0
- package/dist/private/lib/PostgreSQL/txHandle.mjs +26 -0
- package/dist/private/lib/PostgreSQL/txSettings.d.mts +7 -0
- package/dist/private/lib/PostgreSQL/txSettings.mjs +48 -0
- package/dist/private/lib/PostgreSQL/versionText.d.mts +5 -0
- package/dist/private/lib/PostgreSQL/versionText.mjs +12 -0
- package/dist/private/lib/access/assertResetAllowed.mjs +1 -1
- package/dist/private/lib/access/db/deleteUserByEmail.mjs +1 -1
- package/dist/private/lib/access/db/enableEmailAccess.mjs +1 -1
- package/dist/private/lib/access/db/userData4VerifyEmail.mjs +1 -1
- package/dist/private/lib/access/handleBadDB.mjs +1 -1
- package/dist/private/lib/createSentryClient.d.mts +7 -0
- package/dist/private/lib/createSentryClient.mjs +20 -0
- package/dist/private/lib/importOptional.d.mts +7 -0
- package/dist/private/lib/importOptional.mjs +27 -0
- package/dist/private/lib/loadEnv.d.mts +12 -0
- package/dist/private/lib/loadEnv.mjs +14 -0
- package/dist/private/lib/sentry.d.mts +3 -0
- package/dist/private/lib/sentry.mjs +12 -0
- package/package.json +563 -7
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IKoaErrorHandlerContext } from './IKoaErrorHandlerContext.mjs';
|
|
2
|
+
import { IKoaErrorHandlerOptions } from './IKoaErrorHandlerOptions.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Builds a Koa error middleware: `await next()` in a `try`, and on a throw sets `ctx.status`, sets `ctx.body`, calls
|
|
5
|
+
* `report`, then emits `'error'` on the app, all in one synchronous `catch` block so `emit` listeners see the final
|
|
6
|
+
* context. It never rethrows what `next()` threw.
|
|
7
|
+
*
|
|
8
|
+
* Importing it loads no environment file, no Sentry, no `graphql` and no `koa`: it has no peer dependency.
|
|
9
|
+
* `tdwKoaErrorHandler` is this factory configured for GraphQL errors, Sentry and dotenv.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createKoaErrorHandler<TCtx extends IKoaErrorHandlerContext = IKoaErrorHandlerContext>(options?: IKoaErrorHandlerOptions<TCtx>): (ctx: TCtx, next: () => Promise<unknown>) => Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Statuses that must not carry a body (RFC 9110). Copied into a `Set` per handler, never mutated. */
|
|
2
|
+
const NO_BODY_STATUSES = [100, 101, 102, 204, 205, 304];
|
|
3
|
+
// `||`, not `??`: status 0 and NaN must give 500 too
|
|
4
|
+
const defaultStatusOf = (err) => err?.status || 500;
|
|
5
|
+
const defaultBodyOf = (err) => ({ message: err?.message });
|
|
6
|
+
/**
|
|
7
|
+
* Builds a Koa error middleware: `await next()` in a `try`, and on a throw sets `ctx.status`, sets `ctx.body`, calls
|
|
8
|
+
* `report`, then emits `'error'` on the app, all in one synchronous `catch` block so `emit` listeners see the final
|
|
9
|
+
* context. It never rethrows what `next()` threw.
|
|
10
|
+
*
|
|
11
|
+
* Importing it loads no environment file, no Sentry, no `graphql` and no `koa`: it has no peer dependency.
|
|
12
|
+
* `tdwKoaErrorHandler` is this factory configured for GraphQL errors, Sentry and dotenv.
|
|
13
|
+
*/
|
|
14
|
+
export function createKoaErrorHandler(options) {
|
|
15
|
+
const statusOf = options?.statusOf ?? defaultStatusOf;
|
|
16
|
+
const bodyOf = options?.bodyOf ?? defaultBodyOf;
|
|
17
|
+
const report = options?.report;
|
|
18
|
+
const noBodyStatuses = new Set(options?.noBodyStatuses ?? NO_BODY_STATUSES);
|
|
19
|
+
return async function koaErrorHandler(ctx, next) {
|
|
20
|
+
try {
|
|
21
|
+
await next();
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
ctx.status = statusOf(err, ctx);
|
|
25
|
+
// Read back, not the value just assigned: Koa's setter can store a different number (it drops the body of 204/205/304)
|
|
26
|
+
if (!noBodyStatuses.has(ctx.status)) {
|
|
27
|
+
const body = bodyOf(err, ctx);
|
|
28
|
+
if (body !== undefined) {
|
|
29
|
+
ctx.body = body;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
report?.(err, ctx);
|
|
33
|
+
ctx.app.emit('error', err, ctx);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=createKoaErrorHandler.mjs.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { redisClient } from "../../../dataSources/Redis.mjs";
|
|
2
2
|
import { isSessionBlocked } from "../../../lib/isSessionBlocked.mjs";
|
|
3
|
+
import { loadEnv } from "../../../private/lib/loadEnv.mjs";
|
|
3
4
|
import { verifyIntrospectionCode } from "../../../private/lib/verifyIntrospectionCode.mjs";
|
|
4
5
|
import { throwForbiddenError } from "../../../graphQL/throw/throwForbiddenError.mjs";
|
|
5
6
|
import { throwRefreshTokenExpiredOrDeleted } from "../../../graphQL/throw/throwRefreshTokenExpiredOrDeleted.mjs";
|
|
6
|
-
import * as dotenv from 'dotenv';
|
|
7
7
|
import { Types } from 'mongoose';
|
|
8
8
|
import { verifySignedRefreshToken } from './verifySignedRefreshToken.mjs';
|
|
9
|
-
|
|
9
|
+
loadEnv();
|
|
10
10
|
export const authenticatedAuthorizationHandler = (keys) => async (ctx, next) => {
|
|
11
11
|
/***************************
|
|
12
12
|
* CLIENT:
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { redisClient } from "../../../dataSources/Redis.mjs";
|
|
2
2
|
import { isValidUuidV4 } from "../../../lib/isValidUuidV4.mjs";
|
|
3
|
+
import { loadEnv } from "../../../private/lib/loadEnv.mjs";
|
|
3
4
|
import { verifyIntrospectionCode } from "../../../private/lib/verifyIntrospectionCode.mjs";
|
|
4
5
|
import { throwAlreadyDone } from "../../../graphQL/throw/throwAlreadyDone.mjs";
|
|
5
6
|
import { throwPreconditionFailedNoAuthCookie } from "../../../graphQL/throw/throwPreconditionFailedNoAuthCookie.mjs";
|
|
6
7
|
import { throwPreconditionFailedNoAuthHeader } from "../../../graphQL/throw/throwPreconditionFailedNoAuthHeader.mjs";
|
|
7
|
-
import * as dotenv from 'dotenv';
|
|
8
8
|
import { verifySignedRefreshToken } from '../authenticatedAuthorizationHandler/verifySignedRefreshToken.mjs';
|
|
9
|
-
|
|
9
|
+
loadEnv();
|
|
10
10
|
const requireIntrospectionOrThrow = (header, throwOnFail) => {
|
|
11
11
|
if (typeof header !== 'undefined' && verifyIntrospectionCode(header['x-introspectioncode'])) {
|
|
12
12
|
return true;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { redisClient } from "../../../dataSources/Redis.mjs";
|
|
2
2
|
import { isSessionBlocked } from "../../../lib/isSessionBlocked.mjs";
|
|
3
3
|
import { isValidUuidV4 } from "../../../lib/isValidUuidV4.mjs";
|
|
4
|
+
import { loadEnv } from "../../../private/lib/loadEnv.mjs";
|
|
4
5
|
import { verifyIntrospectionCode } from "../../../private/lib/verifyIntrospectionCode.mjs";
|
|
5
6
|
import { throwAccessTokenExpiredOrDeleted } from "../../../graphQL/throw/throwAccessTokenExpiredOrDeleted.mjs";
|
|
6
7
|
import { throwAccessTokenRequired } from "../../../graphQL/throw/throwAccessTokenRequired.mjs";
|
|
7
8
|
import { throwForbiddenError } from "../../../graphQL/throw/throwForbiddenError.mjs";
|
|
8
9
|
import { throwMissingMalformedInvalidToken } from "../../../graphQL/throw/throwMissingMalformedInvalidToken.mjs";
|
|
9
10
|
import { throwPreconditionFailedNoAuthHeader } from "../../../graphQL/throw/throwPreconditionFailedNoAuthHeader.mjs";
|
|
10
|
-
import * as dotenv from 'dotenv';
|
|
11
11
|
import { Types } from 'mongoose';
|
|
12
|
-
|
|
12
|
+
loadEnv();
|
|
13
13
|
/**
|
|
14
14
|
* Find out access token in Bearer header
|
|
15
15
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
1
|
+
import { loadEnv } from "../private/lib/loadEnv.mjs";
|
|
2
|
+
import * as Sentry from "../private/lib/sentry.mjs";
|
|
3
3
|
import { GraphQLError } from 'graphql';
|
|
4
|
-
|
|
4
|
+
import { createKoaErrorHandler } from './createKoaErrorHandler.mjs';
|
|
5
|
+
loadEnv();
|
|
5
6
|
// check status
|
|
6
7
|
function resolveErrorStatus(errKoa, isIstanceOfGQL) {
|
|
7
8
|
if (isIstanceOfGQL) {
|
|
@@ -10,13 +11,9 @@ function resolveErrorStatus(errKoa, isIstanceOfGQL) {
|
|
|
10
11
|
return errKoa.status || 500;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
|
+
* the factory skips this for status codes that do not allow a body
|
|
14
15
|
*/
|
|
15
|
-
function buildErrorBody(errKoa, isIstanceOfGQL
|
|
16
|
-
const allowBody = ![100, 101, 102, 204, 205, 304].includes(status);
|
|
17
|
-
if (!allowBody) {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
16
|
+
function buildErrorBody(errKoa, isIstanceOfGQL) {
|
|
20
17
|
const body = {
|
|
21
18
|
message: errKoa.message
|
|
22
19
|
};
|
|
@@ -33,20 +30,15 @@ function maybeCaptureSentryError(errKoa, isIstanceOfGQL) {
|
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const errKoa = err;
|
|
42
|
-
const isIstanceOfGQL = err instanceof GraphQLError;
|
|
43
|
-
ctx.status = resolveErrorStatus(errKoa, isIstanceOfGQL);
|
|
44
|
-
const body = buildErrorBody(errKoa, isIstanceOfGQL, ctx.status);
|
|
45
|
-
if (body) {
|
|
46
|
-
ctx.body = body;
|
|
47
|
-
}
|
|
48
|
-
maybeCaptureSentryError(errKoa, isIstanceOfGQL);
|
|
49
|
-
ctx.app.emit('error', errKoa, ctx);
|
|
33
|
+
const handle = createKoaErrorHandler({
|
|
34
|
+
statusOf: (err) => resolveErrorStatus(err, err instanceof GraphQLError),
|
|
35
|
+
bodyOf: (err) => buildErrorBody(err, err instanceof GraphQLError),
|
|
36
|
+
report: (err) => {
|
|
37
|
+
maybeCaptureSentryError(err, err instanceof GraphQLError);
|
|
50
38
|
}
|
|
39
|
+
});
|
|
40
|
+
// Not async: returns the factory's promise as is, so there is no extra microtask tick. Name and length (2) stay as before.
|
|
41
|
+
export function tdwKoaErrorHandler(ctx, next) {
|
|
42
|
+
return handle(ctx, next);
|
|
51
43
|
}
|
|
52
44
|
//# sourceMappingURL=tdwKoaErrorHandler.mjs.map
|
package/dist/lib/Constants.d.mts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { Types } from 'mongoose';
|
|
2
1
|
export declare const OBJECTID_0_STR = "000000000000000000000000";
|
|
3
|
-
export declare const OBJECTID_0_OBJ: Types.ObjectId;
|
|
4
2
|
export declare const EMAIL_MAX_LEN = 255;
|
|
5
3
|
export declare const MIN_PWD_LENGTH = 10;
|
|
6
4
|
export declare const MAX_PWD_LENGTH = 72;
|
package/dist/lib/Constants.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { throwIfMongoErr } from "./throwIfMongoErr.mjs";
|
|
2
|
-
import * as Sentry from
|
|
2
|
+
import * as Sentry from "../../private/lib/sentry.mjs";
|
|
3
3
|
import { throwInternalError } from "../../graphQL/throw/throwInternalError.mjs";
|
|
4
4
|
export const throwMongoDBErrors = (e) => {
|
|
5
5
|
throwIfMongoErr(e);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OBJECTID_0_STR } from "./Constants.mjs";
|
|
2
|
+
import { Types } from 'mongoose';
|
|
3
|
+
/**
|
|
4
|
+
* The all-zero sentinel id as a Mongoose `Types.ObjectId`. It has its own subpath so that `lib/Constants` and the
|
|
5
|
+
* helpers that import it do not load `mongoose`.
|
|
6
|
+
*/
|
|
7
|
+
export const OBJECTID_0_OBJ = new Types.ObjectId(OBJECTID_0_STR);
|
|
8
|
+
//# sourceMappingURL=OBJECTID_0_OBJ.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The statement of a clock: one row, one `bigint` column `ms`. `clock_timestamp()` is the wall clock at the moment the
|
|
3
|
+
* statement runs (unlike `now()` and `transaction_timestamp()`, which stay at the start of the transaction), as epoch
|
|
4
|
+
* milliseconds cut toward zero by `trunc` (a cast to `bigint` would round). `extract(epoch FROM <timestamptz>)` does not
|
|
5
|
+
* depend on the session time zone. It takes no parameter: no time is bound from the process.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CLOCK_SQL = "SELECT trunc(extract(epoch FROM clock_timestamp()) * 1000)::bigint AS ms";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The statement of a clock: one row, one `bigint` column `ms`. `clock_timestamp()` is the wall clock at the moment the
|
|
3
|
+
* statement runs (unlike `now()` and `transaction_timestamp()`, which stay at the start of the transaction), as epoch
|
|
4
|
+
* milliseconds cut toward zero by `trunc` (a cast to `bigint` would round). `extract(epoch FROM <timestamptz>)` does not
|
|
5
|
+
* depend on the session time zone. It takes no parameter: no time is bound from the process.
|
|
6
|
+
*/
|
|
7
|
+
export const CLOCK_SQL = 'SELECT trunc(extract(epoch FROM clock_timestamp()) * 1000)::bigint AS ms';
|
|
8
|
+
//# sourceMappingURL=CLOCK_SQL.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The database time as a SQL expression of type `timestamptz`, for a statement that decides inside the database (a lease
|
|
3
|
+
* that compares with it, say). It is the expression {@link CLOCK_SQL} reads.
|
|
4
|
+
*/
|
|
5
|
+
export const DB_NOW_SQL = 'clock_timestamp()';
|
|
6
|
+
//# sourceMappingURL=DB_NOW_SQL.mjs.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IClock } from './IClock.mjs';
|
|
2
|
+
/** The clock of one transaction: the plain port plus the asynchronous read behind it. */
|
|
3
|
+
export interface IDbClock extends IClock {
|
|
4
|
+
/** The instant of the transaction in epoch milliseconds; never touches the database. */
|
|
5
|
+
now(): number;
|
|
6
|
+
/**
|
|
7
|
+
* Reads the instant: the first call in the transaction runs the one statement, every later call and every `now()` has
|
|
8
|
+
* the same value. Concurrent first calls share one statement.
|
|
9
|
+
*/
|
|
10
|
+
read(): Promise<number>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IDbClockSeam } from './IDbClockSeam.mjs';
|
|
2
|
+
/** What `createDbClock` takes. */
|
|
3
|
+
export interface IDbClockOptions {
|
|
4
|
+
/**
|
|
5
|
+
* True for a transaction that writes: its clock refuses to answer before a lock helper has returned. Required, with no
|
|
6
|
+
* default, so that the choice is made in the code that opens the transaction.
|
|
7
|
+
*/
|
|
8
|
+
readonly write: boolean;
|
|
9
|
+
/** A replacement for the statement (a test build). Default: none, the clock reads `CLOCK_SQL`. */
|
|
10
|
+
readonly seam?: IDbClockSeam | undefined;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A replacement for the clock statement, for a test build. The statement must answer the same shape as `CLOCK_SQL`: one
|
|
3
|
+
* row, one `bigint` column `ms`, and it takes no parameter. `allowed` is computed by the caller from its own environment
|
|
4
|
+
* and must be exactly `true`; anything else, a missing value included, refuses the seam with `DbClockError`
|
|
5
|
+
* `SEAM_REFUSED`, so a forgotten flag fails closed. The kit reads no environment variable itself.
|
|
6
|
+
*/
|
|
7
|
+
export interface IDbClockSeam {
|
|
8
|
+
readonly statement: string;
|
|
9
|
+
readonly allowed: boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ITx } from "../tx/ITx.mjs";
|
|
2
|
+
import type { IDbClock } from './IDbClock.mjs';
|
|
3
|
+
import type { IDbClockOptions } from './IDbClockOptions.mjs';
|
|
4
|
+
/**
|
|
5
|
+
* Makes the clock of a transaction: the server time as epoch milliseconds, read from the database once per transaction, so
|
|
6
|
+
* that every comparison in one request uses one instant and no application host clock decides a deadline.
|
|
7
|
+
*
|
|
8
|
+
* `now()` is synchronous and never touches the database: it answers the instant that was read. `read()` is the
|
|
9
|
+
* asynchronous one: the first call runs the one statement (`CLOCK_SQL`, or the statement of the seam), every later call
|
|
10
|
+
* returns the same value, and concurrent first calls share one statement. A read that failed is not retried: its failure
|
|
11
|
+
* is the answer of every later call. The lock helpers call `lockTaken` after the lock they took, which reads for a bound
|
|
12
|
+
* clock, so in a write transaction `now()` is ready as soon as the first lock helper returns.
|
|
13
|
+
*
|
|
14
|
+
* A transaction flagged `write: true` must take a lock before it reads the time, so that the instant it stamps on its rows
|
|
15
|
+
* is later than the commit of every transaction that held the same lock before it. `now()` and `read()` before the first
|
|
16
|
+
* lock helper has returned throw `DbClockError` `WRITE_BEFORE_LOCK`, a defect of the calling code. A read-only
|
|
17
|
+
* transaction has no such guard.
|
|
18
|
+
*
|
|
19
|
+
* Call it once, where the transaction opens (inside `withTx`), before or after the first lock helper. The checks, in
|
|
20
|
+
* order: `TypeError` for a `write` that is not a boolean; the seam (`TypeError` out of its type, `SEAM_REFUSED` when it is
|
|
21
|
+
* not allowed); `ALREADY_BOUND` for a second clock on the same handle. Nothing is sent to the database before the first read.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createDbClock(tx: ITx, options: IDbClockOptions): IDbClock;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { DbClockError } from "../error/DbClockError.mjs";
|
|
2
|
+
import { clockInstant } from "../../../private/lib/PostgreSQL/clockInstant.mjs";
|
|
3
|
+
import { clockSlot } from "../../../private/lib/PostgreSQL/clockSlot.mjs";
|
|
4
|
+
import { clockStatement } from "../../../private/lib/PostgreSQL/clockStatement.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* Makes the clock of a transaction: the server time as epoch milliseconds, read from the database once per transaction, so
|
|
7
|
+
* that every comparison in one request uses one instant and no application host clock decides a deadline.
|
|
8
|
+
*
|
|
9
|
+
* `now()` is synchronous and never touches the database: it answers the instant that was read. `read()` is the
|
|
10
|
+
* asynchronous one: the first call runs the one statement (`CLOCK_SQL`, or the statement of the seam), every later call
|
|
11
|
+
* returns the same value, and concurrent first calls share one statement. A read that failed is not retried: its failure
|
|
12
|
+
* is the answer of every later call. The lock helpers call `lockTaken` after the lock they took, which reads for a bound
|
|
13
|
+
* clock, so in a write transaction `now()` is ready as soon as the first lock helper returns.
|
|
14
|
+
*
|
|
15
|
+
* A transaction flagged `write: true` must take a lock before it reads the time, so that the instant it stamps on its rows
|
|
16
|
+
* is later than the commit of every transaction that held the same lock before it. `now()` and `read()` before the first
|
|
17
|
+
* lock helper has returned throw `DbClockError` `WRITE_BEFORE_LOCK`, a defect of the calling code. A read-only
|
|
18
|
+
* transaction has no such guard.
|
|
19
|
+
*
|
|
20
|
+
* Call it once, where the transaction opens (inside `withTx`), before or after the first lock helper. The checks, in
|
|
21
|
+
* order: `TypeError` for a `write` that is not a boolean; the seam (`TypeError` out of its type, `SEAM_REFUSED` when it is
|
|
22
|
+
* not allowed); `ALREADY_BOUND` for a second clock on the same handle. Nothing is sent to the database before the first read.
|
|
23
|
+
*/
|
|
24
|
+
export function createDbClock(tx, options) {
|
|
25
|
+
const { write } = options;
|
|
26
|
+
if (typeof write !== 'boolean')
|
|
27
|
+
throw new TypeError('write must be a boolean');
|
|
28
|
+
const statement = clockStatement(options.seam);
|
|
29
|
+
const slot = clockSlot(tx);
|
|
30
|
+
if (slot.read !== undefined)
|
|
31
|
+
throw new DbClockError('ALREADY_BOUND');
|
|
32
|
+
const fetchInstant = async () => {
|
|
33
|
+
const { rows } = await tx.query(statement);
|
|
34
|
+
const instant = clockInstant(rows);
|
|
35
|
+
slot.instant = instant;
|
|
36
|
+
return instant;
|
|
37
|
+
};
|
|
38
|
+
const read = () => {
|
|
39
|
+
if (write && !slot.locked)
|
|
40
|
+
return Promise.reject(new DbClockError('WRITE_BEFORE_LOCK'));
|
|
41
|
+
slot.pending ??= fetchInstant();
|
|
42
|
+
return slot.pending;
|
|
43
|
+
};
|
|
44
|
+
slot.read = read;
|
|
45
|
+
return {
|
|
46
|
+
now() {
|
|
47
|
+
if (slot.instant !== undefined)
|
|
48
|
+
return slot.instant;
|
|
49
|
+
throw new DbClockError(write && !slot.locked ? 'WRITE_BEFORE_LOCK' : 'NOT_READ');
|
|
50
|
+
},
|
|
51
|
+
read
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=createDbClock.mjs.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ITx } from "../tx/ITx.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Called by a lock helper after the statement that took its lock. Records that the transaction holds a lock and, when a
|
|
4
|
+
* clock is bound and has not read yet, reads the instant now: the instant of the request is then the first one taken
|
|
5
|
+
* after the first lock. When no clock is bound the read waits for the caller (`IDbClock.read`), which is allowed because
|
|
6
|
+
* the lock is already taken. A transaction without a clock pays nothing: no statement is added.
|
|
7
|
+
*
|
|
8
|
+
* The state sits in a slot keyed by the transaction handle, held by the process-wide registry, so a retry that gets a
|
|
9
|
+
* fresh handle starts with an empty slot, and a second copy of this package reaches the same slot.
|
|
10
|
+
*/
|
|
11
|
+
export declare function lockTaken(tx: ITx): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { clockSlot } from "../../../private/lib/PostgreSQL/clockSlot.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Called by a lock helper after the statement that took its lock. Records that the transaction holds a lock and, when a
|
|
4
|
+
* clock is bound and has not read yet, reads the instant now: the instant of the request is then the first one taken
|
|
5
|
+
* after the first lock. When no clock is bound the read waits for the caller (`IDbClock.read`), which is allowed because
|
|
6
|
+
* the lock is already taken. A transaction without a clock pays nothing: no statement is added.
|
|
7
|
+
*
|
|
8
|
+
* The state sits in a slot keyed by the transaction handle, held by the process-wide registry, so a retry that gets a
|
|
9
|
+
* fresh handle starts with an empty slot, and a second copy of this package reaches the same slot.
|
|
10
|
+
*/
|
|
11
|
+
export async function lockTaken(tx) {
|
|
12
|
+
const slot = clockSlot(tx);
|
|
13
|
+
slot.locked = true;
|
|
14
|
+
if (slot.read !== undefined)
|
|
15
|
+
await slot.read();
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=lockTaken.mjs.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one function shape that a caller passes to count an event: called once per event with the name of the counter.
|
|
3
|
+
* The kit keeps no registry and exposes no metrics endpoint; a caller that wants a number passes a function, one that
|
|
4
|
+
* does not passes nothing.
|
|
5
|
+
*
|
|
6
|
+
* Generic over the name so each part of the kit narrows it to the names it emits, and so a counter typed over a wider
|
|
7
|
+
* closed list of names is accepted as it is: `(name: 'a' | 'b') => void` is assignable to `IDbCounter<'a'>`.
|
|
8
|
+
*/
|
|
9
|
+
export type IDbCounter<TName extends string = string> = (name: TName) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of a {@link DbClockError}, all defects of the calling code or of the configuration:
|
|
3
|
+
*
|
|
4
|
+
* - `WRITE_BEFORE_LOCK`: `now()` or `read()` in a transaction flagged as a write before a lock helper returned.
|
|
5
|
+
* - `NOT_READ`: `now()` before the instant was read (a read-only transaction that did not await `read()`, or a clock
|
|
6
|
+
* created after the lock helpers ran).
|
|
7
|
+
* - `ALREADY_BOUND`: a second clock for the same transaction.
|
|
8
|
+
* - `SEAM_REFUSED`: the test seam was asked for where the caller said it is not allowed.
|
|
9
|
+
* - `BAD_RESULT`: the statement answered no row, or a value that is not the text of an `int8`.
|
|
10
|
+
* - `UNSAFE_INSTANT`: the instant is outside the range of integers a JavaScript number holds exactly.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DB_CLOCK_REASONS: readonly ["WRITE_BEFORE_LOCK", "NOT_READ", "ALREADY_BOUND", "SEAM_REFUSED", "BAD_RESULT", "UNSAFE_INSTANT"];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of a {@link DbClockError}, all defects of the calling code or of the configuration:
|
|
3
|
+
*
|
|
4
|
+
* - `WRITE_BEFORE_LOCK`: `now()` or `read()` in a transaction flagged as a write before a lock helper returned.
|
|
5
|
+
* - `NOT_READ`: `now()` before the instant was read (a read-only transaction that did not await `read()`, or a clock
|
|
6
|
+
* created after the lock helpers ran).
|
|
7
|
+
* - `ALREADY_BOUND`: a second clock for the same transaction.
|
|
8
|
+
* - `SEAM_REFUSED`: the test seam was asked for where the caller said it is not allowed.
|
|
9
|
+
* - `BAD_RESULT`: the statement answered no row, or a value that is not the text of an `int8`.
|
|
10
|
+
* - `UNSAFE_INSTANT`: the instant is outside the range of integers a JavaScript number holds exactly.
|
|
11
|
+
*/
|
|
12
|
+
export const DB_CLOCK_REASONS = [
|
|
13
|
+
'WRITE_BEFORE_LOCK',
|
|
14
|
+
'NOT_READ',
|
|
15
|
+
'ALREADY_BOUND',
|
|
16
|
+
'SEAM_REFUSED',
|
|
17
|
+
'BAD_RESULT',
|
|
18
|
+
'UNSAFE_INSTANT'
|
|
19
|
+
];
|
|
20
|
+
//# sourceMappingURL=DB_CLOCK_REASONS.mjs.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of a connection that the pool refuses (see {@link DbConnectError}):
|
|
3
|
+
*
|
|
4
|
+
* - `URL_INVALID`: the connection string is not a `postgres://` or `postgresql://` URL the pool accepts.
|
|
5
|
+
* - `CONNECT_TIMEOUT`: the connection, the login and the session check did not finish in `connectTimeoutMs`.
|
|
6
|
+
* - `CONNECT_FAILED`: the driver or the server refused (refused connection, name not found, login refused, server
|
|
7
|
+
* shutting down). `code` carries the short driver or SQLSTATE code when there is one.
|
|
8
|
+
* - `TIMEZONE_NOT_UTC`: the session time zone is not `UTC`; the role-level `timezone` setting is missing or was
|
|
9
|
+
* overridden.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DB_CONNECT_REASONS: readonly ["URL_INVALID", "CONNECT_TIMEOUT", "CONNECT_FAILED", "TIMEZONE_NOT_UTC"];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of a connection that the pool refuses (see {@link DbConnectError}):
|
|
3
|
+
*
|
|
4
|
+
* - `URL_INVALID`: the connection string is not a `postgres://` or `postgresql://` URL the pool accepts.
|
|
5
|
+
* - `CONNECT_TIMEOUT`: the connection, the login and the session check did not finish in `connectTimeoutMs`.
|
|
6
|
+
* - `CONNECT_FAILED`: the driver or the server refused (refused connection, name not found, login refused, server
|
|
7
|
+
* shutting down). `code` carries the short driver or SQLSTATE code when there is one.
|
|
8
|
+
* - `TIMEZONE_NOT_UTC`: the session time zone is not `UTC`; the role-level `timezone` setting is missing or was
|
|
9
|
+
* overridden.
|
|
10
|
+
*/
|
|
11
|
+
export const DB_CONNECT_REASONS = ['URL_INVALID', 'CONNECT_TIMEOUT', 'CONNECT_FAILED', 'TIMEZONE_NOT_UTC'];
|
|
12
|
+
//# sourceMappingURL=DB_CONNECT_REASONS.mjs.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of the error that `mapDbError` and `guardVersion` ask their error factory for with
|
|
3
|
+
* `errors.internal(reason)`. They are for the log and the developer: an application that formats errors for a response
|
|
4
|
+
* should keep the reason out of the body. The two reasons of `withTx` (`TX_FAILURE_REASONS`) are separate.
|
|
5
|
+
*
|
|
6
|
+
* - `CONSTRAINT_UNMAPPED`: a violation (SQLSTATE 23505, 23514 or 23503) names a constraint that the table does not hold,
|
|
7
|
+
* or names none. The name, when it is a plain identifier, is logged.
|
|
8
|
+
* - `CONSTRAINT_INTERNAL`: the constraint is in the table and the table maps it to the internal code (a violation that
|
|
9
|
+
* can only be a defect). The name is logged.
|
|
10
|
+
* - `DETAILS_NOT_SUPPLIED`: the table says the caller supplies detail fields for this constraint and the call did not
|
|
11
|
+
* supply all of them; the error would break the details its code is typed with.
|
|
12
|
+
* - `DB_ERROR`: the driver reported a SQLSTATE that is not one of the three above (a missing grant, a statement timeout,
|
|
13
|
+
* a server shutting down, ...). The SQLSTATE is logged.
|
|
14
|
+
* - `DB_VALUE_UNREADABLE`, `DB_CONNECTION`, `DB_TX_MISUSE`: a `DbParseError`, a `DbConnectError` or a `DbTxError`. The
|
|
15
|
+
* closed reason of the typed error is logged.
|
|
16
|
+
* - `UNEXPECTED_ERROR`: anything else (a `TypeError`, an error of another library, a value that is no error). The name
|
|
17
|
+
* of its class is logged, never its message.
|
|
18
|
+
* - `VERSION_UNCHANGED`: `guardVersion` re-read a visible row that still has the version the failed update was guarded
|
|
19
|
+
* with, so the update missed for a reason the guard cannot name.
|
|
20
|
+
* - `REREAD_UNREADABLE`: the statement that `guardVersion` was given answered more than one row, or a row without a
|
|
21
|
+
* readable version column.
|
|
22
|
+
*/
|
|
23
|
+
export declare const DB_INTERNAL_REASONS: readonly ["CONSTRAINT_UNMAPPED", "CONSTRAINT_INTERNAL", "DETAILS_NOT_SUPPLIED", "DB_ERROR", "DB_VALUE_UNREADABLE", "DB_CONNECTION", "DB_TX_MISUSE", "UNEXPECTED_ERROR", "VERSION_UNCHANGED", "REREAD_UNREADABLE"];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of the error that `mapDbError` and `guardVersion` ask their error factory for with
|
|
3
|
+
* `errors.internal(reason)`. They are for the log and the developer: an application that formats errors for a response
|
|
4
|
+
* should keep the reason out of the body. The two reasons of `withTx` (`TX_FAILURE_REASONS`) are separate.
|
|
5
|
+
*
|
|
6
|
+
* - `CONSTRAINT_UNMAPPED`: a violation (SQLSTATE 23505, 23514 or 23503) names a constraint that the table does not hold,
|
|
7
|
+
* or names none. The name, when it is a plain identifier, is logged.
|
|
8
|
+
* - `CONSTRAINT_INTERNAL`: the constraint is in the table and the table maps it to the internal code (a violation that
|
|
9
|
+
* can only be a defect). The name is logged.
|
|
10
|
+
* - `DETAILS_NOT_SUPPLIED`: the table says the caller supplies detail fields for this constraint and the call did not
|
|
11
|
+
* supply all of them; the error would break the details its code is typed with.
|
|
12
|
+
* - `DB_ERROR`: the driver reported a SQLSTATE that is not one of the three above (a missing grant, a statement timeout,
|
|
13
|
+
* a server shutting down, ...). The SQLSTATE is logged.
|
|
14
|
+
* - `DB_VALUE_UNREADABLE`, `DB_CONNECTION`, `DB_TX_MISUSE`: a `DbParseError`, a `DbConnectError` or a `DbTxError`. The
|
|
15
|
+
* closed reason of the typed error is logged.
|
|
16
|
+
* - `UNEXPECTED_ERROR`: anything else (a `TypeError`, an error of another library, a value that is no error). The name
|
|
17
|
+
* of its class is logged, never its message.
|
|
18
|
+
* - `VERSION_UNCHANGED`: `guardVersion` re-read a visible row that still has the version the failed update was guarded
|
|
19
|
+
* with, so the update missed for a reason the guard cannot name.
|
|
20
|
+
* - `REREAD_UNREADABLE`: the statement that `guardVersion` was given answered more than one row, or a row without a
|
|
21
|
+
* readable version column.
|
|
22
|
+
*/
|
|
23
|
+
export const DB_INTERNAL_REASONS = [
|
|
24
|
+
'CONSTRAINT_UNMAPPED',
|
|
25
|
+
'CONSTRAINT_INTERNAL',
|
|
26
|
+
'DETAILS_NOT_SUPPLIED',
|
|
27
|
+
'DB_ERROR',
|
|
28
|
+
'DB_VALUE_UNREADABLE',
|
|
29
|
+
'DB_CONNECTION',
|
|
30
|
+
'DB_TX_MISUSE',
|
|
31
|
+
'UNEXPECTED_ERROR',
|
|
32
|
+
'VERSION_UNCHANGED',
|
|
33
|
+
'REREAD_UNREADABLE'
|
|
34
|
+
];
|
|
35
|
+
//# sourceMappingURL=DB_INTERNAL_REASONS.mjs.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of a failed parse (see {@link DbParseError}):
|
|
3
|
+
*
|
|
4
|
+
* - `MALFORMED`: the text is not in the shape the type has under the session settings the parsers expect (`infinity`,
|
|
5
|
+
* a BC date, another `DateStyle`, a letter in an integer).
|
|
6
|
+
* - `OUT_OF_RANGE`: the text has the shape, but the value is not one the parsers return (`24:00:00`, a calendar date
|
|
7
|
+
* that does not exist, an instant whose UTC year is outside 1 to 9999).
|
|
8
|
+
* - `TIME_HAS_SECONDS`: a `time` with non-zero seconds or a fraction of a second. Only `HH:mm` is returned, so the
|
|
9
|
+
* value is refused, never rounded.
|
|
10
|
+
* - `UNSUPPORTED_TYPE`: the type has no parser here and the driver's own would hand over a `Date`
|
|
11
|
+
* (`timestamp without time zone` and its array).
|
|
12
|
+
*/
|
|
13
|
+
export declare const DB_PARSE_REASONS: readonly ["MALFORMED", "OUT_OF_RANGE", "TIME_HAS_SECONDS", "UNSUPPORTED_TYPE"];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of a failed parse (see {@link DbParseError}):
|
|
3
|
+
*
|
|
4
|
+
* - `MALFORMED`: the text is not in the shape the type has under the session settings the parsers expect (`infinity`,
|
|
5
|
+
* a BC date, another `DateStyle`, a letter in an integer).
|
|
6
|
+
* - `OUT_OF_RANGE`: the text has the shape, but the value is not one the parsers return (`24:00:00`, a calendar date
|
|
7
|
+
* that does not exist, an instant whose UTC year is outside 1 to 9999).
|
|
8
|
+
* - `TIME_HAS_SECONDS`: a `time` with non-zero seconds or a fraction of a second. Only `HH:mm` is returned, so the
|
|
9
|
+
* value is refused, never rounded.
|
|
10
|
+
* - `UNSUPPORTED_TYPE`: the type has no parser here and the driver's own would hand over a `Date`
|
|
11
|
+
* (`timestamp without time zone` and its array).
|
|
12
|
+
*/
|
|
13
|
+
export const DB_PARSE_REASONS = ['MALFORMED', 'OUT_OF_RANGE', 'TIME_HAS_SECONDS', 'UNSUPPORTED_TYPE'];
|
|
14
|
+
//# sourceMappingURL=DB_PARSE_REASONS.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of a {@link DbStateError}:
|
|
3
|
+
*
|
|
4
|
+
* - `LAYOUT_MISMATCH`: the process-wide registry that the clock shares between copies of this package holds a value that
|
|
5
|
+
* is not this layout of it. Another copy of the package with a different layout, or other code, put it there.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DB_STATE_REASONS: readonly ["LAYOUT_MISMATCH"];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of a {@link DbStateError}:
|
|
3
|
+
*
|
|
4
|
+
* - `LAYOUT_MISMATCH`: the process-wide registry that the clock shares between copies of this package holds a value that
|
|
5
|
+
* is not this layout of it. Another copy of the package with a different layout, or other code, put it there.
|
|
6
|
+
*/
|
|
7
|
+
export const DB_STATE_REASONS = ['LAYOUT_MISMATCH'];
|
|
8
|
+
//# sourceMappingURL=DB_STATE_REASONS.mjs.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of a misuse of a transaction (see {@link DbTxError}), both a defect of the calling code:
|
|
3
|
+
*
|
|
4
|
+
* - `HANDLE_CLOSED`: a statement was sent through the handle of a transaction that has already committed, rolled back
|
|
5
|
+
* or started to commit. The handle would otherwise reach a connection that the pool has handed to someone else.
|
|
6
|
+
* - `COMMIT_ROLLED_BACK`: the server answered `COMMIT` with the command tag `ROLLBACK`, which is what it does for a
|
|
7
|
+
* transaction that a failed statement had aborted, and no failed statement of the handle is known to say why.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DB_TX_REASONS: readonly ["HANDLE_CLOSED", "COMMIT_ROLLED_BACK"];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of a misuse of a transaction (see {@link DbTxError}), both a defect of the calling code:
|
|
3
|
+
*
|
|
4
|
+
* - `HANDLE_CLOSED`: a statement was sent through the handle of a transaction that has already committed, rolled back
|
|
5
|
+
* or started to commit. The handle would otherwise reach a connection that the pool has handed to someone else.
|
|
6
|
+
* - `COMMIT_ROLLED_BACK`: the server answered `COMMIT` with the command tag `ROLLBACK`, which is what it does for a
|
|
7
|
+
* transaction that a failed statement had aborted, and no failed statement of the handle is known to say why.
|
|
8
|
+
*/
|
|
9
|
+
export const DB_TX_REASONS = ['HANDLE_CLOSED', 'COMMIT_ROLLED_BACK'];
|
|
10
|
+
//# sourceMappingURL=DB_TX_REASONS.mjs.map
|