@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,6 @@
|
|
|
1
|
+
import type { IDbClockReason } from './IDbClockReason.mjs';
|
|
2
|
+
/** The programming or configuration error of the database clock. The message is fixed and holds no value. */
|
|
3
|
+
export declare class DbClockError extends Error {
|
|
4
|
+
readonly reason: IDbClockReason;
|
|
5
|
+
constructor(reason: IDbClockReason);
|
|
6
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** The fixed message of each reason: no value, no statement text, no driver text. */
|
|
2
|
+
function messageOf(reason) {
|
|
3
|
+
switch (reason) {
|
|
4
|
+
case 'WRITE_BEFORE_LOCK':
|
|
5
|
+
return 'the clock of a write transaction is read after the first lock helper has returned, not before';
|
|
6
|
+
case 'NOT_READ':
|
|
7
|
+
return 'the instant of this transaction was not read yet: await clock.read() once before now()';
|
|
8
|
+
case 'ALREADY_BOUND':
|
|
9
|
+
return 'this transaction already has a clock';
|
|
10
|
+
case 'SEAM_REFUSED':
|
|
11
|
+
return 'the test seam of the clock is not allowed here';
|
|
12
|
+
case 'BAD_RESULT':
|
|
13
|
+
return 'the clock statement did not answer one int8 value';
|
|
14
|
+
case 'UNSAFE_INSTANT':
|
|
15
|
+
return 'the database instant is not a safe integer number of milliseconds';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** The programming or configuration error of the database clock. The message is fixed and holds no value. */
|
|
19
|
+
export class DbClockError extends Error {
|
|
20
|
+
reason;
|
|
21
|
+
constructor(reason) {
|
|
22
|
+
super(messageOf(reason));
|
|
23
|
+
this.name = 'DbClockError';
|
|
24
|
+
this.reason = reason;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=DbClockError.mjs.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IDbConnectReason } from './IDbConnectReason.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* The typed error of a refused connection. It carries a closed reason and a fixed message, and no `cause`: the
|
|
4
|
+
* platform error that led to it is not kept, because its text can quote the connection string and so the password.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DbConnectError extends Error {
|
|
7
|
+
readonly reason: IDbConnectReason;
|
|
8
|
+
/** The driver or SQLSTATE code (`ECONNREFUSED`, `28P01`), or undefined. Never free text. */
|
|
9
|
+
readonly code: string | undefined;
|
|
10
|
+
constructor(reason: IDbConnectReason, code?: string);
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** A short code that is safe to keep: letters, digits and underscore, at most 32 characters. */
|
|
2
|
+
const SAFE_CODE = /^\w{1,32}$/;
|
|
3
|
+
/**
|
|
4
|
+
* The typed error of a refused connection. It carries a closed reason and a fixed message, and no `cause`: the
|
|
5
|
+
* platform error that led to it is not kept, because its text can quote the connection string and so the password.
|
|
6
|
+
*/
|
|
7
|
+
export class DbConnectError extends Error {
|
|
8
|
+
reason;
|
|
9
|
+
/** The driver or SQLSTATE code (`ECONNREFUSED`, `28P01`), or undefined. Never free text. */
|
|
10
|
+
code;
|
|
11
|
+
constructor(reason, code) {
|
|
12
|
+
super(`database connection refused: ${reason}`);
|
|
13
|
+
this.name = 'DbConnectError';
|
|
14
|
+
this.reason = reason;
|
|
15
|
+
this.code = code !== undefined && SAFE_CODE.test(code) ? code : undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=DbConnectError.mjs.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IDbParseReason } from './IDbParseReason.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* The typed error of the string parsers. It carries a closed reason and a fixed message built from the reason and the
|
|
4
|
+
* name of the type, never from the value, so no stored value can reach a log line through it. It has no `cause`.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DbParseError extends Error {
|
|
7
|
+
readonly reason: IDbParseReason;
|
|
8
|
+
/** The name of the type as `format_type` prints it (`date`, `time without time zone`, ...). */
|
|
9
|
+
readonly typeName: string;
|
|
10
|
+
constructor(reason: IDbParseReason, typeName: string);
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The typed error of the string parsers. It carries a closed reason and a fixed message built from the reason and the
|
|
3
|
+
* name of the type, never from the value, so no stored value can reach a log line through it. It has no `cause`.
|
|
4
|
+
*/
|
|
5
|
+
export class DbParseError extends Error {
|
|
6
|
+
reason;
|
|
7
|
+
/** The name of the type as `format_type` prints it (`date`, `time without time zone`, ...). */
|
|
8
|
+
typeName;
|
|
9
|
+
constructor(reason, typeName) {
|
|
10
|
+
super(`database value of type ${typeName} cannot be read: ${reason}`);
|
|
11
|
+
this.name = 'DbParseError';
|
|
12
|
+
this.reason = reason;
|
|
13
|
+
this.typeName = typeName;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=DbParseError.mjs.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IDbStateReason } from './IDbStateReason.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* The error of a second copy of this package that cannot share its state with the first. It is thrown when a module that
|
|
4
|
+
* keeps per-transaction state is loaded, so a mismatch stops the process at start and never splits the state silently.
|
|
5
|
+
* The message is fixed and holds no value.
|
|
6
|
+
*/
|
|
7
|
+
export declare class DbStateError extends Error {
|
|
8
|
+
readonly reason: IDbStateReason;
|
|
9
|
+
constructor(reason: IDbStateReason);
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The error of a second copy of this package that cannot share its state with the first. It is thrown when a module that
|
|
3
|
+
* keeps per-transaction state is loaded, so a mismatch stops the process at start and never splits the state silently.
|
|
4
|
+
* The message is fixed and holds no value.
|
|
5
|
+
*/
|
|
6
|
+
export class DbStateError extends Error {
|
|
7
|
+
reason;
|
|
8
|
+
constructor(reason) {
|
|
9
|
+
super(`shared state of the PostgreSQL kit refused: ${reason}: keep one version of @axiumine/koa-utils installed`);
|
|
10
|
+
this.name = 'DbStateError';
|
|
11
|
+
this.reason = reason;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=DbStateError.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IDbTxReason } from './IDbTxReason.mjs';
|
|
2
|
+
/** The typed error of a misused transaction. It carries a closed reason and a fixed message, and no `cause`. */
|
|
3
|
+
export declare class DbTxError extends Error {
|
|
4
|
+
readonly reason: IDbTxReason;
|
|
5
|
+
constructor(reason: IDbTxReason);
|
|
6
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The typed error of a misused transaction. It carries a closed reason and a fixed message, and no `cause`. */
|
|
2
|
+
export class DbTxError extends Error {
|
|
3
|
+
reason;
|
|
4
|
+
constructor(reason) {
|
|
5
|
+
super(`database transaction misused: ${reason}`);
|
|
6
|
+
this.name = 'DbTxError';
|
|
7
|
+
this.reason = reason;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=DbTxError.mjs.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One row of a constraint table: what the violation of one constraint becomes.
|
|
3
|
+
*
|
|
4
|
+
* - `code`: the code of the error the factory builds (`errors.make(code, details)`). The table's internal code
|
|
5
|
+
* (`internalCode` of `mapDbError`, default `INTERNAL`) is allowed and means "this constraint is known, and a violation
|
|
6
|
+
* of it can only be a defect": the name is logged, the response carries nothing of it.
|
|
7
|
+
* - `fixed`: the details that the constraint itself determines. They are written in the table, so the mapper does not
|
|
8
|
+
* guess them from the driver text.
|
|
9
|
+
* - `supplied`: the keys of the details that only the caller knows. `mapDbError` copies these keys from the `details`
|
|
10
|
+
* the caller passed and no others, and never reads them out of the message or the `detail` of the driver, which quote
|
|
11
|
+
* the failing row.
|
|
12
|
+
*/
|
|
13
|
+
export interface IConstraintEntry<TCode extends string = string> {
|
|
14
|
+
readonly code: TCode;
|
|
15
|
+
readonly fixed?: Readonly<Record<string, unknown>>;
|
|
16
|
+
readonly supplied?: readonly string[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IConstraintEntry } from './IConstraintEntry.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* The typed view of `buildConstraintEntry` over an application's codes: `TCode` is the closed list of its codes and
|
|
4
|
+
* `TDetailsByCode` maps each code that has documented details to the shape of them. The compiler then checks, per row:
|
|
5
|
+
*
|
|
6
|
+
* - a code without documented details takes no second argument;
|
|
7
|
+
* - a code with documented details takes `fixed` (keys of its details, with their types) and `supplied` (the keys that
|
|
8
|
+
* `fixed` leaves out), so a row cannot name a key the code does not have, nor supply a key it already fixes;
|
|
9
|
+
* - the code must be one of `TCode`.
|
|
10
|
+
*
|
|
11
|
+
* Instantiate it once, next to the table: `const constraintEntry: IConstraintEntryBuilder<ErrorCode, ErrorDetailsByCode> =
|
|
12
|
+
* buildConstraintEntry`. The runtime function is the same; only the view differs.
|
|
13
|
+
*/
|
|
14
|
+
export interface IConstraintEntryBuilder<TCode extends string, TDetailsByCode extends object> {
|
|
15
|
+
(code: Exclude<TCode, keyof TDetailsByCode>): IConstraintEntry<TCode>;
|
|
16
|
+
<TWith extends Extract<keyof TDetailsByCode, TCode>, const TFixed extends Partial<TDetailsByCode[TWith]> = object>(code: TWith, parts: {
|
|
17
|
+
readonly fixed?: TFixed;
|
|
18
|
+
readonly supplied?: readonly Exclude<keyof TDetailsByCode[TWith], keyof TFixed>[];
|
|
19
|
+
}): IConstraintEntry<TCode>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IConstraintEntry } from './IConstraintEntry.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* A constraint table: the name of a constraint, as the driver reports it in the `constraint` field of the error, to
|
|
4
|
+
* its row. It is data, not logic: the application owns it, the kit only reads it. Generic over the closed list of codes
|
|
5
|
+
* the application uses; a table of `IConstraintEntry<'A' | 'B'>` is accepted where `IConstraintTable` is wanted.
|
|
6
|
+
*/
|
|
7
|
+
export type IConstraintTable<TCode extends string = string> = Readonly<Record<string, IConstraintEntry<TCode>>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IDbCounter } from "../counter/IDbCounter.mjs";
|
|
2
|
+
import type { IDbErrorCounterName } from "./IDbErrorCounterName.mjs";
|
|
3
|
+
/** The counter callback of `mapDbError`: called once per event with one of the two names of {@link IDbErrorCounterName}. */
|
|
4
|
+
export type IDbErrorCounter = IDbCounter<IDbErrorCounterName>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The counters `mapDbError` increments, and the second one also `guardVersion`:
|
|
3
|
+
*
|
|
4
|
+
* - `db_constraint_unmapped_total`: a violation named a constraint that the table does not hold (reason `CONSTRAINT_UNMAPPED`).
|
|
5
|
+
* - `db_error_internal_total`: any other failure that became the internal error.
|
|
6
|
+
*/
|
|
7
|
+
export type IDbErrorCounterName = 'db_constraint_unmapped_total' | 'db_error_internal_total';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one error-factory port of the kit: how a part of the kit builds the error it hands to its caller, so that the kit
|
|
3
|
+
* imports no error class of the application. The application passes an object that builds its own family of errors
|
|
4
|
+
* (an HTTP error with a code and details, say), and the kit stays free of it.
|
|
5
|
+
*
|
|
6
|
+
* `withTx` reads `internal` only; the parts of the kit that map a driver error read all three members. The type is
|
|
7
|
+
* generic over the error class so the application's own type flows through.
|
|
8
|
+
*/
|
|
9
|
+
export interface IDbErrorFactory<TError extends Error = Error> {
|
|
10
|
+
/** True for an error of the application's family, which a part of the kit must pass through unchanged. */
|
|
11
|
+
is(error: unknown): error is TError;
|
|
12
|
+
/** Builds the error for a closed code, with optional details. */
|
|
13
|
+
make(code: string, details?: unknown): TError;
|
|
14
|
+
/** Builds the error for a failure the caller can do nothing about; `reason` is a closed word for the log. */
|
|
15
|
+
internal(reason: string): TError;
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IDbErrorCounter } from "./IDbErrorCounter.mjs";
|
|
2
|
+
import type { IDbErrorFactory } from "./IDbErrorFactory.mjs";
|
|
3
|
+
import type { IPoolLogger } from "../pool/IPoolLogger.mjs";
|
|
4
|
+
import type { IConstraintTable } from './IConstraintTable.mjs';
|
|
5
|
+
/** The options of `mapDbError`. */
|
|
6
|
+
export interface IMapDbErrorOptions<TError extends Error = Error> {
|
|
7
|
+
/** Builds every error `mapDbError` answers: `is` recognises an error of your family, `make` and `internal` build one. */
|
|
8
|
+
readonly errors: IDbErrorFactory<TError>;
|
|
9
|
+
/** The constraint table: which constraint means which code. The application owns it; the kit holds none. */
|
|
10
|
+
readonly table: IConstraintTable;
|
|
11
|
+
/** The logger of the request or of the service; only `error` is called. The reason and the constraint name are written to it. */
|
|
12
|
+
readonly logger: Pick<IPoolLogger, 'error'>;
|
|
13
|
+
/** Where `mapDbError` counts. Default: nowhere. */
|
|
14
|
+
readonly counter?: IDbErrorCounter;
|
|
15
|
+
/**
|
|
16
|
+
* The details fields that only the caller knows, for the constraint it expects to violate. Only the keys that the row
|
|
17
|
+
* of the table lists as `supplied` are used; a key for a row that lists none is ignored.
|
|
18
|
+
*/
|
|
19
|
+
readonly details?: Readonly<Record<string, unknown>>;
|
|
20
|
+
/** The code of a table row that means "a defect". Default `INTERNAL`, the code `errors.internal` is expected to build. */
|
|
21
|
+
readonly internalCode?: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a failed assertion names besides the role. Every field is optional and none is ever a value from the driver. A
|
|
3
|
+
* field given as `undefined` means the same as a field left out.
|
|
4
|
+
*/
|
|
5
|
+
export interface IRoleAssertionSubject {
|
|
6
|
+
/** The role it is a member of (`ROLE_MEMBERSHIP`), or the schema, table, sequence or function (`GRANT_MISSING`). */
|
|
7
|
+
readonly object?: string | undefined;
|
|
8
|
+
readonly privilege?: string | undefined;
|
|
9
|
+
readonly column?: string | undefined;
|
|
10
|
+
/** The short driver or SQLSTATE code of a `CHECK_FAILED`. */
|
|
11
|
+
readonly code?: string | undefined;
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of a {@link LockOrderError}, all defects of the calling code:
|
|
3
|
+
*
|
|
4
|
+
* - `RANK_INVERSION`: a lock of a lower rank was requested after one of a higher rank.
|
|
5
|
+
* - `MODE_REQUIRED`: a helper that belongs to another order than the default one, in a transaction that is in the default
|
|
6
|
+
* mode.
|
|
7
|
+
* - `NOT_IN_MODE_ORDER`: a helper that is not one of the locks of the order of a transaction that is in a mode other than
|
|
8
|
+
* the default one.
|
|
9
|
+
* - `TRACKER_STARTED`: the mode of a transaction was set after a lock was recorded in it.
|
|
10
|
+
*/
|
|
11
|
+
export declare const LOCK_ORDER_REASONS: readonly ["RANK_INVERSION", "MODE_REQUIRED", "NOT_IN_MODE_ORDER", "TRACKER_STARTED"];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of a {@link LockOrderError}, all defects of the calling code:
|
|
3
|
+
*
|
|
4
|
+
* - `RANK_INVERSION`: a lock of a lower rank was requested after one of a higher rank.
|
|
5
|
+
* - `MODE_REQUIRED`: a helper that belongs to another order than the default one, in a transaction that is in the default
|
|
6
|
+
* mode.
|
|
7
|
+
* - `NOT_IN_MODE_ORDER`: a helper that is not one of the locks of the order of a transaction that is in a mode other than
|
|
8
|
+
* the default one.
|
|
9
|
+
* - `TRACKER_STARTED`: the mode of a transaction was set after a lock was recorded in it.
|
|
10
|
+
*/
|
|
11
|
+
export const LOCK_ORDER_REASONS = ['RANK_INVERSION', 'MODE_REQUIRED', 'NOT_IN_MODE_ORDER', 'TRACKER_STARTED'];
|
|
12
|
+
//# sourceMappingURL=LOCK_ORDER_REASONS.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ILockOrderReason } from './ILockOrderReason.mjs';
|
|
2
|
+
/** The programming error of the lock-order tracker. The message names the ranks and the helper; it holds no id. */
|
|
3
|
+
export declare class LockOrderError extends Error {
|
|
4
|
+
readonly reason: ILockOrderReason;
|
|
5
|
+
constructor(reason: ILockOrderReason, message: string);
|
|
6
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The programming error of the lock-order tracker. The message names the ranks and the helper; it holds no id. */
|
|
2
|
+
export class LockOrderError extends Error {
|
|
3
|
+
reason;
|
|
4
|
+
constructor(reason, message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = 'LockOrderError';
|
|
7
|
+
this.reason = reason;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=LockOrderError.mjs.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of a failed role assertion (see {@link RoleAssertionError}). The first one that applies is
|
|
3
|
+
* reported, in this order:
|
|
4
|
+
*
|
|
5
|
+
* - `INVALID_EXPECTATION`: the options of the call are malformed (a role or object name that is not a plain
|
|
6
|
+
* identifier, a privilege the kind of object cannot hold, a column list on a function). A defect of the calling code,
|
|
7
|
+
* found before the pool is asked for a connection.
|
|
8
|
+
* - `ROLE_MISMATCH`: `current_user` is not the expected role.
|
|
9
|
+
* - `ROLE_SUPERUSER`, `ROLE_CREATEROLE`, `ROLE_CREATEDB`, `ROLE_BYPASSRLS`, `ROLE_REPLICATION`: the role has that
|
|
10
|
+
* attribute.
|
|
11
|
+
* - `ROLE_OWNS_OBJECTS`: the catalog lists at least one object owned by the role.
|
|
12
|
+
* - `ROLE_MEMBERSHIP`: the role is a member, directly or through another role, of a role that the call did not allow.
|
|
13
|
+
* `object` names the first such role.
|
|
14
|
+
* - `SESSION_ROLE_DIFFERS`: `current_user` is the expected role but `session_user` is another: the connection logged in
|
|
15
|
+
* as one role and switched to this one (`SET ROLE`), so the login holds more.
|
|
16
|
+
* - `GRANT_MISSING`: an expected privilege is not held. `object`, `privilege` and (for a column-level grant) `column`
|
|
17
|
+
* name the first one that is missing, in the order of the list.
|
|
18
|
+
* - `CHECK_FAILED`: the check could not be made (no connection, a catalog query that failed). `code` holds the short
|
|
19
|
+
* driver or SQLSTATE code when there is one.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ROLE_ASSERT_REASONS: readonly ["INVALID_EXPECTATION", "ROLE_MISMATCH", "ROLE_SUPERUSER", "ROLE_CREATEROLE", "ROLE_CREATEDB", "ROLE_BYPASSRLS", "ROLE_REPLICATION", "ROLE_OWNS_OBJECTS", "ROLE_MEMBERSHIP", "SESSION_ROLE_DIFFERS", "GRANT_MISSING", "CHECK_FAILED"];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed reasons of a failed role assertion (see {@link RoleAssertionError}). The first one that applies is
|
|
3
|
+
* reported, in this order:
|
|
4
|
+
*
|
|
5
|
+
* - `INVALID_EXPECTATION`: the options of the call are malformed (a role or object name that is not a plain
|
|
6
|
+
* identifier, a privilege the kind of object cannot hold, a column list on a function). A defect of the calling code,
|
|
7
|
+
* found before the pool is asked for a connection.
|
|
8
|
+
* - `ROLE_MISMATCH`: `current_user` is not the expected role.
|
|
9
|
+
* - `ROLE_SUPERUSER`, `ROLE_CREATEROLE`, `ROLE_CREATEDB`, `ROLE_BYPASSRLS`, `ROLE_REPLICATION`: the role has that
|
|
10
|
+
* attribute.
|
|
11
|
+
* - `ROLE_OWNS_OBJECTS`: the catalog lists at least one object owned by the role.
|
|
12
|
+
* - `ROLE_MEMBERSHIP`: the role is a member, directly or through another role, of a role that the call did not allow.
|
|
13
|
+
* `object` names the first such role.
|
|
14
|
+
* - `SESSION_ROLE_DIFFERS`: `current_user` is the expected role but `session_user` is another: the connection logged in
|
|
15
|
+
* as one role and switched to this one (`SET ROLE`), so the login holds more.
|
|
16
|
+
* - `GRANT_MISSING`: an expected privilege is not held. `object`, `privilege` and (for a column-level grant) `column`
|
|
17
|
+
* name the first one that is missing, in the order of the list.
|
|
18
|
+
* - `CHECK_FAILED`: the check could not be made (no connection, a catalog query that failed). `code` holds the short
|
|
19
|
+
* driver or SQLSTATE code when there is one.
|
|
20
|
+
*/
|
|
21
|
+
export const ROLE_ASSERT_REASONS = [
|
|
22
|
+
'INVALID_EXPECTATION',
|
|
23
|
+
'ROLE_MISMATCH',
|
|
24
|
+
'ROLE_SUPERUSER',
|
|
25
|
+
'ROLE_CREATEROLE',
|
|
26
|
+
'ROLE_CREATEDB',
|
|
27
|
+
'ROLE_BYPASSRLS',
|
|
28
|
+
'ROLE_REPLICATION',
|
|
29
|
+
'ROLE_OWNS_OBJECTS',
|
|
30
|
+
'ROLE_MEMBERSHIP',
|
|
31
|
+
'SESSION_ROLE_DIFFERS',
|
|
32
|
+
'GRANT_MISSING',
|
|
33
|
+
'CHECK_FAILED'
|
|
34
|
+
];
|
|
35
|
+
//# sourceMappingURL=ROLE_ASSERT_REASONS.mjs.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IRoleAssertionReason } from './IRoleAssertionReason.mjs';
|
|
2
|
+
import type { IRoleAssertionSubject } from './IRoleAssertionSubject.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* The typed error of `assertRole`. The message is built from the role name, the closed reason and, for a missing grant,
|
|
5
|
+
* the object and the privilege; each name passes a shape check and a text that fails it prints as `?`, so a connection
|
|
6
|
+
* string given by mistake as a role name is not repeated. The error carries no `cause`: the driver error that led to
|
|
7
|
+
* `CHECK_FAILED` can quote an argument, and is not kept.
|
|
8
|
+
*/
|
|
9
|
+
export declare class RoleAssertionError extends Error {
|
|
10
|
+
readonly reason: IRoleAssertionReason;
|
|
11
|
+
/** The role the caller expected (`?` when the text given was not a plain name). */
|
|
12
|
+
readonly role: string;
|
|
13
|
+
readonly object: string | undefined;
|
|
14
|
+
readonly privilege: string | undefined;
|
|
15
|
+
readonly column: string | undefined;
|
|
16
|
+
/** The driver or SQLSTATE code of a `CHECK_FAILED`, or undefined. Never free text. */
|
|
17
|
+
readonly code: string | undefined;
|
|
18
|
+
constructor(reason: IRoleAssertionReason, role: string, subject?: IRoleAssertionSubject);
|
|
19
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** A short code that is safe to keep: letters, digits and underscore, at most 32 characters. */
|
|
2
|
+
const SAFE_CODE = /^\w{1,32}$/;
|
|
3
|
+
/** Text that is safe to put in a message: a name of letters, digits, `_`, `$` and `.`, never a URL or a sentence. */
|
|
4
|
+
const PRINTABLE_NAME = /^[A-Za-z_][\w$.]{0,126}$/;
|
|
5
|
+
/** The text itself when it is a plain name, otherwise `?`. Anything that is not a string is `?` too. */
|
|
6
|
+
function printable(value) {
|
|
7
|
+
return typeof value === 'string' && PRINTABLE_NAME.test(value) ? value : '?';
|
|
8
|
+
}
|
|
9
|
+
/** The subject with every name passed through {@link printable} and a code kept only when it is a short code. */
|
|
10
|
+
function safeSubject(subject) {
|
|
11
|
+
return {
|
|
12
|
+
...(subject.object === undefined ? {} : { object: printable(subject.object) }),
|
|
13
|
+
...(subject.privilege === undefined ? {} : { privilege: printable(subject.privilege) }),
|
|
14
|
+
...(subject.column === undefined ? {} : { column: printable(subject.column) }),
|
|
15
|
+
...(subject.code !== undefined && SAFE_CODE.test(subject.code) ? { code: subject.code } : {})
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** The part of the message after the reason: what is missing, or whose member the role is, or the code. */
|
|
19
|
+
function subjectText(reason, subject) {
|
|
20
|
+
if (reason === 'GRANT_MISSING') {
|
|
21
|
+
const column = subject.column === undefined ? '' : ` column ${subject.column}`;
|
|
22
|
+
return ` (${subject.privilege ?? '?'} on ${subject.object ?? '?'}${column})`;
|
|
23
|
+
}
|
|
24
|
+
if (reason === 'ROLE_MEMBERSHIP')
|
|
25
|
+
return ` (member of ${subject.object ?? '?'})`;
|
|
26
|
+
if (reason === 'CHECK_FAILED' && subject.code !== undefined)
|
|
27
|
+
return ` (${subject.code})`;
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The typed error of `assertRole`. The message is built from the role name, the closed reason and, for a missing grant,
|
|
32
|
+
* the object and the privilege; each name passes a shape check and a text that fails it prints as `?`, so a connection
|
|
33
|
+
* string given by mistake as a role name is not repeated. The error carries no `cause`: the driver error that led to
|
|
34
|
+
* `CHECK_FAILED` can quote an argument, and is not kept.
|
|
35
|
+
*/
|
|
36
|
+
export class RoleAssertionError extends Error {
|
|
37
|
+
reason;
|
|
38
|
+
/** The role the caller expected (`?` when the text given was not a plain name). */
|
|
39
|
+
role;
|
|
40
|
+
object;
|
|
41
|
+
privilege;
|
|
42
|
+
column;
|
|
43
|
+
/** The driver or SQLSTATE code of a `CHECK_FAILED`, or undefined. Never free text. */
|
|
44
|
+
code;
|
|
45
|
+
constructor(reason, role, subject = {}) {
|
|
46
|
+
const safe = safeSubject(subject);
|
|
47
|
+
const name = printable(role);
|
|
48
|
+
super(`role assertion failed for ${name}: ${reason}${subjectText(reason, safe)}`);
|
|
49
|
+
this.name = 'RoleAssertionError';
|
|
50
|
+
this.reason = reason;
|
|
51
|
+
this.role = name;
|
|
52
|
+
this.object = safe.object;
|
|
53
|
+
this.privilege = safe.privilege;
|
|
54
|
+
this.column = safe.column;
|
|
55
|
+
this.code = safe.code;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=RoleAssertionError.mjs.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IConstraintEntry } from './IConstraintEntry.mjs';
|
|
2
|
+
/** What {@link buildConstraintEntry} reads of its second argument. */
|
|
3
|
+
interface IConstraintParts {
|
|
4
|
+
readonly fixed?: object;
|
|
5
|
+
readonly supplied?: readonly PropertyKey[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Builds and freezes one row of a constraint table. `fixed` and `supplied` are copied, so the caller's arguments are not
|
|
9
|
+
* shared with the row, and an empty `supplied` list is dropped.
|
|
10
|
+
*
|
|
11
|
+
* It checks nothing about the code and the details: that is the job of the typed view of it, `IConstraintEntryBuilder`,
|
|
12
|
+
* which an application instantiates over its own codes and its details-by-code map.
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildConstraintEntry<TCode extends string>(code: TCode, parts?: IConstraintParts): IConstraintEntry<TCode>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds and freezes one row of a constraint table. `fixed` and `supplied` are copied, so the caller's arguments are not
|
|
3
|
+
* shared with the row, and an empty `supplied` list is dropped.
|
|
4
|
+
*
|
|
5
|
+
* It checks nothing about the code and the details: that is the job of the typed view of it, `IConstraintEntryBuilder`,
|
|
6
|
+
* which an application instantiates over its own codes and its details-by-code map.
|
|
7
|
+
*/
|
|
8
|
+
export function buildConstraintEntry(code, parts = {}) {
|
|
9
|
+
const entry = { code };
|
|
10
|
+
if (parts.fixed !== undefined)
|
|
11
|
+
entry.fixed = Object.freeze({ ...parts.fixed });
|
|
12
|
+
if (parts.supplied !== undefined && parts.supplied.length > 0)
|
|
13
|
+
entry.supplied = Object.freeze(parts.supplied.map(String));
|
|
14
|
+
return Object.freeze(entry);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=buildConstraintEntry.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The name of the constraint that a violation names (the `constraint` field of the driver error), or `undefined` when
|
|
3
|
+
* there is none or when it is not a plain identifier. For the violation of a unique index that backs no constraint,
|
|
4
|
+
* the server puts the name of the index there.
|
|
5
|
+
*/
|
|
6
|
+
export declare function constraintNameOf(error: unknown): string | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { readField } from "../../../private/lib/PostgreSQL/readField.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* A name the server gave to a constraint or an index: at most 63 bytes (the identifier limit), and here letters,
|
|
4
|
+
* digits, `_` and `$` only. A name outside that shape is a quoted identifier with something unusual in it; it is
|
|
5
|
+
* neither looked up nor logged.
|
|
6
|
+
*/
|
|
7
|
+
const SAFE_NAME = /^[A-Za-z0-9_$]{1,63}$/;
|
|
8
|
+
/**
|
|
9
|
+
* The name of the constraint that a violation names (the `constraint` field of the driver error), or `undefined` when
|
|
10
|
+
* there is none or when it is not a plain identifier. For the violation of a unique index that backs no constraint,
|
|
11
|
+
* the server puts the name of the index there.
|
|
12
|
+
*/
|
|
13
|
+
export function constraintNameOf(error) {
|
|
14
|
+
const name = readField(error, 'constraint');
|
|
15
|
+
return typeof name === 'string' && SAFE_NAME.test(name) ? name : undefined;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=constraintNameOf.mjs.map
|