@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,17 @@
|
|
|
1
|
+
import type { ITxClient } from "../../../lib/PostgreSQL/tx/ITxClient.mjs";
|
|
2
|
+
import type { IRolePlan } from './IRolePlan.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* The checks of `assertRole`, on one connection, in this order. The first failure is thrown as a `RoleAssertionError`
|
|
5
|
+
* and ends the check; nothing after it is asked.
|
|
6
|
+
*
|
|
7
|
+
* 1. `current_user` is the expected role (`ROLE_MISMATCH`).
|
|
8
|
+
* 2. The role has none of the five attributes (`ROLE_SUPERUSER`, `ROLE_CREATEROLE`, `ROLE_CREATEDB`, `ROLE_BYPASSRLS`,
|
|
9
|
+
* `ROLE_REPLICATION`), in that order.
|
|
10
|
+
* 3. The role owns nothing (`ROLE_OWNS_OBJECTS`).
|
|
11
|
+
* 4. The role is a member of no role the call did not allow (`ROLE_MEMBERSHIP`).
|
|
12
|
+
* 5. `session_user` is `current_user` (`SESSION_ROLE_DIFFERS`).
|
|
13
|
+
* 6. Each expected grant is held, in the order of the list (`GRANT_MISSING`).
|
|
14
|
+
*
|
|
15
|
+
* Answers the number of grants checked. A catalog answer that is not what the statements give throws a `TypeError`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function runRoleChecks(client: ITxClient, plan: IRolePlan): Promise<number>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { RoleAssertionError } from "../../../lib/PostgreSQL/error/RoleAssertionError.mjs";
|
|
2
|
+
import { catalogFlag } from './catalogFlag.mjs';
|
|
3
|
+
import { catalogRow } from './catalogRow.mjs';
|
|
4
|
+
import { catalogText } from './catalogText.mjs';
|
|
5
|
+
import { membershipOutsider } from './membershipOutsider.mjs';
|
|
6
|
+
import { missingGrant } from './missingGrant.mjs';
|
|
7
|
+
import { readField } from './readField.mjs';
|
|
8
|
+
import { ROLE_ATTRIBUTES } from './ROLE_ATTRIBUTES.mjs';
|
|
9
|
+
import { ROLE_CATALOG_SQL } from './ROLE_CATALOG_SQL.mjs';
|
|
10
|
+
/**
|
|
11
|
+
* The checks of `assertRole`, on one connection, in this order. The first failure is thrown as a `RoleAssertionError`
|
|
12
|
+
* and ends the check; nothing after it is asked.
|
|
13
|
+
*
|
|
14
|
+
* 1. `current_user` is the expected role (`ROLE_MISMATCH`).
|
|
15
|
+
* 2. The role has none of the five attributes (`ROLE_SUPERUSER`, `ROLE_CREATEROLE`, `ROLE_CREATEDB`, `ROLE_BYPASSRLS`,
|
|
16
|
+
* `ROLE_REPLICATION`), in that order.
|
|
17
|
+
* 3. The role owns nothing (`ROLE_OWNS_OBJECTS`).
|
|
18
|
+
* 4. The role is a member of no role the call did not allow (`ROLE_MEMBERSHIP`).
|
|
19
|
+
* 5. `session_user` is `current_user` (`SESSION_ROLE_DIFFERS`).
|
|
20
|
+
* 6. Each expected grant is held, in the order of the list (`GRANT_MISSING`).
|
|
21
|
+
*
|
|
22
|
+
* Answers the number of grants checked. A catalog answer that is not what the statements give throws a `TypeError`.
|
|
23
|
+
*/
|
|
24
|
+
export async function runRoleChecks(client, plan) {
|
|
25
|
+
const fail = (reason, subject) => new RoleAssertionError(reason, plan.role, subject);
|
|
26
|
+
const identity = await catalogRow(client, ROLE_CATALOG_SQL.identity);
|
|
27
|
+
const effective = catalogText(identity['effective_role']);
|
|
28
|
+
if (effective !== plan.role)
|
|
29
|
+
throw fail('ROLE_MISMATCH');
|
|
30
|
+
for (const [key, reason] of ROLE_ATTRIBUTES) {
|
|
31
|
+
if (catalogFlag(readField(identity, key)))
|
|
32
|
+
throw fail(reason);
|
|
33
|
+
}
|
|
34
|
+
if (catalogFlag((await catalogRow(client, ROLE_CATALOG_SQL.ownsObjects))['owns']))
|
|
35
|
+
throw fail('ROLE_OWNS_OBJECTS');
|
|
36
|
+
const outsider = await membershipOutsider(client, plan.allowed);
|
|
37
|
+
if (outsider !== undefined)
|
|
38
|
+
throw fail('ROLE_MEMBERSHIP', { object: outsider });
|
|
39
|
+
if (catalogText(identity['login_role']) !== effective)
|
|
40
|
+
throw fail('SESSION_ROLE_DIFFERS');
|
|
41
|
+
for (const check of plan.checks) {
|
|
42
|
+
const missing = await missingGrant(client, check);
|
|
43
|
+
if (missing !== undefined)
|
|
44
|
+
throw fail('GRANT_MISSING', missing);
|
|
45
|
+
}
|
|
46
|
+
return plan.checks.length;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=runRoleChecks.mjs.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ITx } from "../../../lib/PostgreSQL/tx/ITx.mjs";
|
|
2
|
+
import type { ITxPool } from "../../../lib/PostgreSQL/tx/ITxPool.mjs";
|
|
3
|
+
import type { ITxSettings } from './ITxSettings.mjs';
|
|
4
|
+
/**
|
|
5
|
+
* One attempt: a connection, the transaction, `fn`, and the commit or the rollback.
|
|
6
|
+
*
|
|
7
|
+
* The connection gets a listener for its `error` event for as long as it is held, because an event nobody handles ends
|
|
8
|
+
* the process. A connection that emitted one, and one whose rollback failed, is destroyed instead of returned to the
|
|
9
|
+
* pool. A rollback that fails does not hide the error that caused it. A `COMMIT` the server answers with the tag
|
|
10
|
+
* `ROLLBACK` throws the first failed statement of the handle, or `DbTxError` `COMMIT_ROLLED_BACK` when none is known.
|
|
11
|
+
*/
|
|
12
|
+
export declare function runTxAttempt<T>(pool: ITxPool, settings: ITxSettings, fn: (tx: ITx) => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { sqlstateField } from "../../../lib/PostgreSQL/error/sqlstateField.mjs";
|
|
2
|
+
import { sqlstateOf } from "../../../lib/PostgreSQL/error/sqlstateOf.mjs";
|
|
3
|
+
import { runTxBody } from './runTxBody.mjs';
|
|
4
|
+
/**
|
|
5
|
+
* One attempt: a connection, the transaction, `fn`, and the commit or the rollback.
|
|
6
|
+
*
|
|
7
|
+
* The connection gets a listener for its `error` event for as long as it is held, because an event nobody handles ends
|
|
8
|
+
* the process. A connection that emitted one, and one whose rollback failed, is destroyed instead of returned to the
|
|
9
|
+
* pool. A rollback that fails does not hide the error that caused it. A `COMMIT` the server answers with the tag
|
|
10
|
+
* `ROLLBACK` throws the first failed statement of the handle, or `DbTxError` `COMMIT_ROLLED_BACK` when none is known.
|
|
11
|
+
*/
|
|
12
|
+
export async function runTxAttempt(pool, settings, fn) {
|
|
13
|
+
const client = await pool.connect();
|
|
14
|
+
let destroy = false;
|
|
15
|
+
const onClientError = (error) => {
|
|
16
|
+
destroy = true;
|
|
17
|
+
settings.count('db_tx_client_errors_total');
|
|
18
|
+
settings.logger.error('database client error during transaction', {
|
|
19
|
+
reason: 'CLIENT_ERROR',
|
|
20
|
+
...sqlstateField(sqlstateOf(error))
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
client.on('error', onClientError);
|
|
24
|
+
const state = { open: true, failed: false, failure: undefined };
|
|
25
|
+
let result;
|
|
26
|
+
try {
|
|
27
|
+
result = await runTxBody(client, settings, fn, state);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
state.open = false;
|
|
31
|
+
try {
|
|
32
|
+
await client.query('ROLLBACK');
|
|
33
|
+
}
|
|
34
|
+
catch (rollbackError) {
|
|
35
|
+
destroy = true;
|
|
36
|
+
settings.count('db_tx_rollback_failures_total');
|
|
37
|
+
settings.logger.error('database transaction rollback failed', {
|
|
38
|
+
reason: 'ROLLBACK_FAILED',
|
|
39
|
+
...sqlstateField(sqlstateOf(rollbackError))
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
client.removeListener('error', onClientError);
|
|
46
|
+
client.release(destroy);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=runTxAttempt.mjs.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ITx } from "../../../lib/PostgreSQL/tx/ITx.mjs";
|
|
2
|
+
import type { ITxClient } from "../../../lib/PostgreSQL/tx/ITxClient.mjs";
|
|
3
|
+
import type { ITxHandleState } from './ITxHandleState.mjs';
|
|
4
|
+
import type { ITxSettings } from './ITxSettings.mjs';
|
|
5
|
+
/**
|
|
6
|
+
* The body of one attempt, from `BEGIN` to the answer of `COMMIT`: the two opening statements, `fn` with its handle,
|
|
7
|
+
* then the commit. The handle is closed before the commit starts. A `COMMIT` the server answers with the tag `ROLLBACK`
|
|
8
|
+
* (what it does for a transaction that a failed statement aborted) throws the first failed statement of the handle, or
|
|
9
|
+
* `DbTxError` `COMMIT_ROLLED_BACK` when none is known. It sends no `ROLLBACK`; the caller does that for any throw.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runTxBody<T>(client: ITxClient, settings: ITxSettings, fn: (tx: ITx) => Promise<T>, state: ITxHandleState): Promise<T>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DbTxError } from "../../../lib/PostgreSQL/error/DbTxError.mjs";
|
|
2
|
+
import { txHandle } from './txHandle.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* The body of one attempt, from `BEGIN` to the answer of `COMMIT`: the two opening statements, `fn` with its handle,
|
|
5
|
+
* then the commit. The handle is closed before the commit starts. A `COMMIT` the server answers with the tag `ROLLBACK`
|
|
6
|
+
* (what it does for a transaction that a failed statement aborted) throws the first failed statement of the handle, or
|
|
7
|
+
* `DbTxError` `COMMIT_ROLLED_BACK` when none is known. It sends no `ROLLBACK`; the caller does that for any throw.
|
|
8
|
+
*/
|
|
9
|
+
export async function runTxBody(client, settings, fn, state) {
|
|
10
|
+
await client.query(settings.begin);
|
|
11
|
+
await client.query(settings.setLockTimeout);
|
|
12
|
+
const result = await fn(txHandle(client, state));
|
|
13
|
+
state.open = false;
|
|
14
|
+
const committed = await client.query('COMMIT');
|
|
15
|
+
if (committed.command === 'ROLLBACK')
|
|
16
|
+
throw state.failed ? state.failure : new DbTxError('COMMIT_ROLLED_BACK');
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=runTxBody.mjs.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ITx } from "../../../lib/PostgreSQL/tx/ITx.mjs";
|
|
2
|
+
import type { ITxPool } from "../../../lib/PostgreSQL/tx/ITxPool.mjs";
|
|
3
|
+
import type { ITxSettings } from './ITxSettings.mjs';
|
|
4
|
+
/**
|
|
5
|
+
* The retry loop of `withTx`, written as a recursion so that it has no exit that cannot be reached. `retries` is the
|
|
6
|
+
* number of retries already made. An attempt that fails with 55P03 ends the loop at once; one that fails with 40001 or
|
|
7
|
+
* 40P01 is run again after the injected delay until `settings.retryMax` retries are spent; any other failure is
|
|
8
|
+
* rethrown unchanged. The recursive call is outside the `try`, so a failure of a later attempt is not classified twice.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runTxWithRetries<T>(pool: ITxPool, settings: ITxSettings, fn: (tx: ITx) => Promise<T>, retries: number): Promise<T>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { sqlstateOf } from "../../../lib/PostgreSQL/error/sqlstateOf.mjs";
|
|
2
|
+
import { runTxAttempt } from './runTxAttempt.mjs';
|
|
3
|
+
import { txFailure } from './txFailure.mjs';
|
|
4
|
+
const SERIALIZATION_FAILURE = '40001';
|
|
5
|
+
const DEADLOCK_DETECTED = '40P01';
|
|
6
|
+
const LOCK_NOT_AVAILABLE = '55P03';
|
|
7
|
+
/**
|
|
8
|
+
* The retry loop of `withTx`, written as a recursion so that it has no exit that cannot be reached. `retries` is the
|
|
9
|
+
* number of retries already made. An attempt that fails with 55P03 ends the loop at once; one that fails with 40001 or
|
|
10
|
+
* 40P01 is run again after the injected delay until `settings.retryMax` retries are spent; any other failure is
|
|
11
|
+
* rethrown unchanged. The recursive call is outside the `try`, so a failure of a later attempt is not classified twice.
|
|
12
|
+
*/
|
|
13
|
+
export async function runTxWithRetries(pool, settings, fn, retries) {
|
|
14
|
+
try {
|
|
15
|
+
return await runTxAttempt(pool, settings, fn);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
const sqlstate = sqlstateOf(error);
|
|
19
|
+
if (sqlstate === LOCK_NOT_AVAILABLE)
|
|
20
|
+
throw txFailure(settings, 'LOCK_TIMEOUT', sqlstate, retries + 1);
|
|
21
|
+
if (sqlstate !== SERIALIZATION_FAILURE && sqlstate !== DEADLOCK_DETECTED)
|
|
22
|
+
throw error;
|
|
23
|
+
if (retries >= settings.retryMax)
|
|
24
|
+
throw txFailure(settings, 'TX_RETRY_EXHAUSTED', sqlstate, retries + 1);
|
|
25
|
+
settings.count('db_tx_retries_total');
|
|
26
|
+
settings.logger.warn('database transaction retried', { reason: 'TX_RETRY', sqlstate, retry: retries + 1 });
|
|
27
|
+
await settings.retryDelay(retries + 1);
|
|
28
|
+
}
|
|
29
|
+
return runTxWithRetries(pool, settings, fn, retries + 1);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=runTxWithRetries.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const REDACTED = '[REDACTED]';
|
|
2
|
+
/** Replaces every occurrence of a secret in a text with a marker. */
|
|
3
|
+
export function scrubSecrets(text, secrets) {
|
|
4
|
+
return secrets.reduce((current, secret) => current.split(secret).join(REDACTED), text);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=scrubSecrets.mjs.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ITxFailureReason } from "../../../lib/PostgreSQL/tx/ITxFailureReason.mjs";
|
|
2
|
+
import type { ITxSettings } from './ITxSettings.mjs';
|
|
3
|
+
/** Counts and logs a failure that ends the loop, and builds the error the caller gets from the error factory. */
|
|
4
|
+
export declare function txFailure(settings: ITxSettings, reason: ITxFailureReason, sqlstate: string, attempts: number): Error;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Counts and logs a failure that ends the loop, and builds the error the caller gets from the error factory. */
|
|
2
|
+
export function txFailure(settings, reason, sqlstate, attempts) {
|
|
3
|
+
settings.count(reason === 'LOCK_TIMEOUT' ? 'db_tx_lock_timeouts_total' : 'db_tx_retry_exhausted_total');
|
|
4
|
+
settings.logger.error('database transaction failed', { reason, sqlstate, attempts });
|
|
5
|
+
return settings.errors.internal(reason);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=txFailure.mjs.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ITx } from "../../../lib/PostgreSQL/tx/ITx.mjs";
|
|
2
|
+
import type { ITxClient } from "../../../lib/PostgreSQL/tx/ITxClient.mjs";
|
|
3
|
+
import type { ITxHandleState } from './ITxHandleState.mjs';
|
|
4
|
+
/**
|
|
5
|
+
* The handle one attempt gives to the function: a frozen object with the one member `query`. It refuses a statement
|
|
6
|
+
* once `state.open` is false, and it remembers the first statement that failed, so a failure the function swallows is
|
|
7
|
+
* still known at commit.
|
|
8
|
+
*/
|
|
9
|
+
export declare function txHandle(client: ITxClient, state: ITxHandleState): ITx;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DbTxError } from "../../../lib/PostgreSQL/error/DbTxError.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* The handle one attempt gives to the function: a frozen object with the one member `query`. It refuses a statement
|
|
4
|
+
* once `state.open` is false, and it remembers the first statement that failed, so a failure the function swallows is
|
|
5
|
+
* still known at commit.
|
|
6
|
+
*/
|
|
7
|
+
export function txHandle(client, state) {
|
|
8
|
+
return Object.freeze({
|
|
9
|
+
async query(text, values) {
|
|
10
|
+
if (!state.open)
|
|
11
|
+
throw new DbTxError('HANDLE_CLOSED');
|
|
12
|
+
try {
|
|
13
|
+
const result = values === undefined ? await client.query(text) : await client.query(text, values);
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (!state.failed) {
|
|
18
|
+
state.failed = true;
|
|
19
|
+
state.failure = error;
|
|
20
|
+
}
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=txHandle.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ITxOptions } from "../../../lib/PostgreSQL/tx/ITxOptions.mjs";
|
|
2
|
+
import type { ITxSettings } from './ITxSettings.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Checks the options before anything is checked out and builds the two statements that open a transaction. The checks
|
|
5
|
+
* run in the order isolation, lock timeout, retry count; the first that fails throws a `TypeError`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function txSettings(options: ITxOptions): ITxSettings;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DEFAULT_LOCK_TIMEOUT_MS } from "../../../lib/PostgreSQL/tx/DEFAULT_LOCK_TIMEOUT_MS.mjs";
|
|
2
|
+
import { defaultRetryDelay } from "../../../lib/PostgreSQL/tx/defaultRetryDelay.mjs";
|
|
3
|
+
import { MAX_LOCK_TIMEOUT_MS } from "../../../lib/PostgreSQL/tx/MAX_LOCK_TIMEOUT_MS.mjs";
|
|
4
|
+
import { TX_ISOLATION_LEVELS } from "../../../lib/PostgreSQL/tx/TX_ISOLATION_LEVELS.mjs";
|
|
5
|
+
import { TX_RETRY_MAX } from "../../../lib/PostgreSQL/tx/TX_RETRY_MAX.mjs";
|
|
6
|
+
import { TX_RETRY_MAX_CEILING } from "../../../lib/PostgreSQL/tx/TX_RETRY_MAX_CEILING.mjs";
|
|
7
|
+
import { TX_BEGIN_STATEMENTS } from './TX_BEGIN_STATEMENTS.mjs';
|
|
8
|
+
const isWholeNumberIn = (value, min, max) => Number.isInteger(value) && value >= min && value <= max;
|
|
9
|
+
function beginStatementsOf(isolation) {
|
|
10
|
+
const statements = TX_BEGIN_STATEMENTS.get(isolation ?? 'READ COMMITTED');
|
|
11
|
+
if (statements === undefined)
|
|
12
|
+
throw new TypeError(`isolation must be one of ${TX_ISOLATION_LEVELS.join(', ')}`);
|
|
13
|
+
return statements;
|
|
14
|
+
}
|
|
15
|
+
function lockTimeoutMsOf(value) {
|
|
16
|
+
const lockTimeoutMs = value ?? DEFAULT_LOCK_TIMEOUT_MS;
|
|
17
|
+
if (!isWholeNumberIn(lockTimeoutMs, 1, MAX_LOCK_TIMEOUT_MS)) {
|
|
18
|
+
throw new TypeError(`lockTimeoutMs must be a whole number of milliseconds from 1 to ${String(MAX_LOCK_TIMEOUT_MS)}`);
|
|
19
|
+
}
|
|
20
|
+
return lockTimeoutMs;
|
|
21
|
+
}
|
|
22
|
+
function retryMaxOf(value) {
|
|
23
|
+
const retryMax = value ?? TX_RETRY_MAX;
|
|
24
|
+
if (!isWholeNumberIn(retryMax, 0, TX_RETRY_MAX_CEILING)) {
|
|
25
|
+
throw new TypeError(`retryMax must be a whole number from 0 to ${String(TX_RETRY_MAX_CEILING)}`);
|
|
26
|
+
}
|
|
27
|
+
return retryMax;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Checks the options before anything is checked out and builds the two statements that open a transaction. The checks
|
|
31
|
+
* run in the order isolation, lock timeout, retry count; the first that fails throws a `TypeError`.
|
|
32
|
+
*/
|
|
33
|
+
export function txSettings(options) {
|
|
34
|
+
const [readWrite, readOnly] = beginStatementsOf(options.isolation);
|
|
35
|
+
const lockTimeoutMs = lockTimeoutMsOf(options.lockTimeoutMs);
|
|
36
|
+
const retryMax = retryMaxOf(options.retryMax);
|
|
37
|
+
return {
|
|
38
|
+
logger: options.logger,
|
|
39
|
+
errors: options.errors,
|
|
40
|
+
count: options.counter ?? (() => undefined),
|
|
41
|
+
begin: options.readOnly === true ? readOnly : readWrite,
|
|
42
|
+
// The number was checked above to be a whole number in range, so the text holds digits only.
|
|
43
|
+
setLockTimeout: `SET LOCAL lock_timeout = ${String(lockTimeoutMs)}`,
|
|
44
|
+
retryMax,
|
|
45
|
+
retryDelay: options.retryDelay ?? defaultRetryDelay
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=txSettings.mjs.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A version column value as text, or `undefined` when it is no version: a safe integer (`integer` columns arrive as
|
|
3
|
+
* numbers) or a string of 1 to 19 digits (`bigint` columns arrive as decimal strings, which a number cannot hold exactly).
|
|
4
|
+
*/
|
|
5
|
+
export declare function versionText(value: unknown): string | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** A decimal string of up to 19 digits: what the driver hands over for a `bigint` column. */
|
|
2
|
+
const BIGINT_TEXT = /^\d{1,19}$/;
|
|
3
|
+
/**
|
|
4
|
+
* A version column value as text, or `undefined` when it is no version: a safe integer (`integer` columns arrive as
|
|
5
|
+
* numbers) or a string of 1 to 19 digits (`bigint` columns arrive as decimal strings, which a number cannot hold exactly).
|
|
6
|
+
*/
|
|
7
|
+
export function versionText(value) {
|
|
8
|
+
if (typeof value === 'number')
|
|
9
|
+
return Number.isSafeInteger(value) ? String(value) : undefined;
|
|
10
|
+
return typeof value === 'string' && BIGINT_TEXT.test(value) ? value : undefined;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=versionText.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DateLib } from "../../../lib/DateLib.mjs";
|
|
2
|
-
import * as Sentry from
|
|
2
|
+
import * as Sentry from "../sentry.mjs";
|
|
3
3
|
import { throwForbiddenError } from "../../../graphQL/throw/throwForbiddenError.mjs";
|
|
4
4
|
import { safeEqualSecret } from './safeEqualSecret.mjs';
|
|
5
5
|
/** Minutes a reset link stays valid after the request was made. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_VERIFY_EMAIL_PATHS } from "../../../../lib/access/accessPaths.mjs";
|
|
2
2
|
import { UserBase } from "../../../../graphQL/models/MongoDB/UserBase.mjs";
|
|
3
|
-
import * as Sentry from
|
|
3
|
+
import * as Sentry from "../../sentry.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* Hard delete of an abandoned pending registration, keyed by the login-email path.
|
|
6
6
|
*
|
|
@@ -2,7 +2,7 @@ import { DEFAULT_VERIFY_EMAIL_PATHS } from "../../../../lib/access/accessPaths.m
|
|
|
2
2
|
import { defaultVerifyEmailMailer } from "../../../../lib/access/verifyEmailMailer.mjs";
|
|
3
3
|
import { UserBase } from "../../../../graphQL/models/MongoDB/UserBase.mjs";
|
|
4
4
|
import { buildUnset } from "../pathTools.mjs";
|
|
5
|
-
import * as Sentry from
|
|
5
|
+
import * as Sentry from "../../sentry.mjs";
|
|
6
6
|
/**
|
|
7
7
|
* Mark the address verified, clear the pending-verification fields, welcome the user.
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@ import { DEFAULT_VERIFY_EMAIL_PATHS } from "../../../../lib/access/accessPaths.m
|
|
|
2
2
|
import { UserBase } from "../../../../graphQL/models/MongoDB/UserBase.mjs";
|
|
3
3
|
import { EMAIL_CHECK_LINK } from "../Constants.mjs";
|
|
4
4
|
import { buildProjection } from "../pathTools.mjs";
|
|
5
|
-
import * as Sentry from
|
|
5
|
+
import * as Sentry from "../../sentry.mjs";
|
|
6
6
|
export const createUserData4VerifyEmail = (model, paths) => async function userData4VerifyEmail(uEmail) {
|
|
7
7
|
// Every field the guard chain reads must be listed. This is a .lean() read, so a field left out
|
|
8
8
|
// of the projection is simply absent on the returned object, with no error — which is how a
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ISentryClient } from "./ISentryClient.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* The Sentry client of this package: the SDK itself when it is installed, no-ops when it is not.
|
|
4
|
+
*
|
|
5
|
+
* @param sdk the `@sentry/node` module, or `null` when it is not installed
|
|
6
|
+
*/
|
|
7
|
+
export declare function createSentryClient(sdk: ISentryClient | null): ISentryClient;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// A scope whose every method is a chainable no-op, like the real setters (`scope.setTag(...).setLevel(...)`).
|
|
2
|
+
// `then` is left undefined: a callback that returns the scope from an async function would otherwise treat it as a
|
|
3
|
+
// thenable and wait forever.
|
|
4
|
+
const noopSetter = () => NOOP_SCOPE;
|
|
5
|
+
const NOOP_SCOPE = new Proxy({}, { get: (_target, property) => (property === 'then' ? undefined : noopSetter) });
|
|
6
|
+
// What the package reports to when `@sentry/node` is not installed: nothing. The event id is '' as no event exists.
|
|
7
|
+
const NOOP_CLIENT = {
|
|
8
|
+
captureException: () => '',
|
|
9
|
+
captureMessage: () => '',
|
|
10
|
+
withScope: (callback) => callback(NOOP_SCOPE)
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The Sentry client of this package: the SDK itself when it is installed, no-ops when it is not.
|
|
14
|
+
*
|
|
15
|
+
* @param sdk the `@sentry/node` module, or `null` when it is not installed
|
|
16
|
+
*/
|
|
17
|
+
export function createSentryClient(sdk) {
|
|
18
|
+
return sdk ?? NOOP_CLIENT;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=createSentryClient.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load an optional peer dependency. Resolves `null` when `specifier` is not installed, rethrows every other failure.
|
|
3
|
+
*
|
|
4
|
+
* The caller passes its own `() => import('pkg')`, so the specifier stays a string literal at the call site where
|
|
5
|
+
* `tsc` types it and bundlers can see it. `specifier` repeats that name for the error match.
|
|
6
|
+
*/
|
|
7
|
+
export declare function importOptional<T>(specifier: string, load: () => Promise<T>): Promise<T | null>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Node raises ERR_MODULE_NOT_FOUND for a missing ESM package; a CommonJS resolver (or a tool that wraps one) uses MODULE_NOT_FOUND.
|
|
2
|
+
const MISSING_CODES = new Set(['ERR_MODULE_NOT_FOUND', 'MODULE_NOT_FOUND']);
|
|
3
|
+
/**
|
|
4
|
+
* True only when `error` says that `specifier` itself is not installed. An installed package that fails to load one of
|
|
5
|
+
* its own dependencies raises the same code for a different name; that one must surface, so the name is matched too.
|
|
6
|
+
*/
|
|
7
|
+
function isMissingPackage(error, specifier) {
|
|
8
|
+
const { code, message } = (error ?? {});
|
|
9
|
+
return MISSING_CODES.has(code) && typeof message === 'string' && message.includes(`'${specifier}'`);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Load an optional peer dependency. Resolves `null` when `specifier` is not installed, rethrows every other failure.
|
|
13
|
+
*
|
|
14
|
+
* The caller passes its own `() => import('pkg')`, so the specifier stays a string literal at the call site where
|
|
15
|
+
* `tsc` types it and bundlers can see it. `specifier` repeats that name for the error match.
|
|
16
|
+
*/
|
|
17
|
+
export async function importOptional(specifier, load) {
|
|
18
|
+
try {
|
|
19
|
+
return await load();
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (isMissingPackage(error, specifier))
|
|
23
|
+
return null;
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=importOptional.mjs.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The one method of `dotenv` this package calls. */
|
|
2
|
+
interface IEnvLoader {
|
|
3
|
+
config(): unknown;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Load the environment file of the current directory into `process.env` when `dotenv` is installed; do nothing when
|
|
7
|
+
* it is not. Call it once at module scope, after the imports, where `dotenv.config()` used to run.
|
|
8
|
+
*
|
|
9
|
+
* @param loader replaces `dotenv`; `null` stands for "not installed"
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadEnv(loader?: IEnvLoader | null): void;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { importOptional } from "./importOptional.mjs";
|
|
2
|
+
// dotenv is an optional peer. Top-level await is safe: every `exports` entry has only `import` and `types` conditions,
|
|
3
|
+
// so no CommonJS consumer can load this package. One ESM instance, so call sites stay synchronous.
|
|
4
|
+
const dotenv = await importOptional('dotenv', () => import('dotenv'));
|
|
5
|
+
/**
|
|
6
|
+
* Load the environment file of the current directory into `process.env` when `dotenv` is installed; do nothing when
|
|
7
|
+
* it is not. Call it once at module scope, after the imports, where `dotenv.config()` used to run.
|
|
8
|
+
*
|
|
9
|
+
* @param loader replaces `dotenv`; `null` stands for "not installed"
|
|
10
|
+
*/
|
|
11
|
+
export function loadEnv(loader = dotenv) {
|
|
12
|
+
loader?.config();
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=loadEnv.mjs.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createSentryClient } from "./createSentryClient.mjs";
|
|
2
|
+
import { importOptional } from "./importOptional.mjs";
|
|
3
|
+
// @sentry/node is an optional peer. Top-level await is safe: every `exports` entry has only `import` and `types`
|
|
4
|
+
// conditions, so no CommonJS consumer can load this package. One ESM instance, so call sites stay synchronous and run
|
|
5
|
+
// in the same order as with a static import (see `tryCatchRethrow`, `scanVirus`).
|
|
6
|
+
const client = createSentryClient(await importOptional('@sentry/node', () => import('@sentry/node')));
|
|
7
|
+
// Same names and signatures as the SDK: a module swaps `import * as Sentry from '@sentry/node'` for this file and its
|
|
8
|
+
// `Sentry.captureException(...)` calls stay as they are.
|
|
9
|
+
export const captureException = client.captureException;
|
|
10
|
+
export const captureMessage = client.captureMessage;
|
|
11
|
+
export const withScope = client.withScope;
|
|
12
|
+
//# sourceMappingURL=sentry.mjs.map
|