@axiumine/koa-utils 8.0.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +658 -228
- package/README.md +8 -4
- package/dist/dataSources/PostgreSQL.mjs +5 -5
- package/dist/email/SocketLabsLib.d.mts +2 -1
- package/dist/email/SocketLabsLib.mjs +5 -3
- package/dist/files/storeUploadAsTemp.mjs +2 -0
- package/dist/graphQL/schema/mutations/emailChangeHashVerify.mjs +2 -1
- package/dist/graphQL/schema/mutations/logout.mjs +1 -1
- package/dist/graphQL/schema/mutations/resetPwd.mjs +3 -1
- package/dist/koa/middleware/authenticatedAuthorizationHandler/index.d.mts +1 -1
- package/dist/koa/middleware/authenticatedAuthorizationHandler/verifySignedRefreshToken.mjs +12 -9
- package/dist/koa/middleware/authenticatedLogoutHandler/index.d.mts +1 -1
- package/dist/koa/middleware/authenticatedResourceHandler/index.d.mts +1 -1
- package/dist/koa/middleware/debug/index.d.mts +1 -1
- package/dist/lib/ArrayLib.d.mts +0 -1
- package/dist/lib/ArrayLib.mjs +0 -1
- package/dist/lib/DateLib.mjs +1 -1
- package/dist/lib/MariaDB/throwSqlErrors.mjs +3 -1
- package/dist/lib/MongoDB/IMongoDBError.d.mts +2 -3
- package/dist/lib/MongoDB/throwIfMongoErr.mjs +4 -2
- package/dist/lib/NumLib.d.mts +0 -1
- package/dist/lib/NumLib.mjs +1 -1
- 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/StringLib.d.mts +0 -1
- package/dist/lib/StringLib.mjs +0 -1
- package/dist/lib/db/log/logGraphql.d.mts +8 -6
- package/dist/lib/db/log/logGraphql.mjs +9 -23
- package/dist/lib/db/log/logThrow.d.mts +9 -0
- package/dist/lib/db/log/logThrow.mjs +11 -11
- package/dist/lib/hash.mjs +1 -6
- package/dist/lib/isSessionBlocked.d.mts +1 -1
- package/dist/lib/throwIfNotValidEnumValue.mjs +1 -0
- package/dist/lib/tryCatchRethrow.mjs +5 -3
- package/dist/private/files/reEncode.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/db/abandonUser.mjs +2 -3
- package/dist/private/lib/access/db/getResetPwd.mjs +4 -2
- package/dist/private/lib/access/db/setEmailHash.mjs +3 -1
- package/dist/private/lib/access/db/userData4VerifyEmail.d.mts +1 -1
- package/dist/private/lib/access/db/userData4VerifyEmail.mjs +4 -2
- package/dist/private/lib/access/handleIfHashBad.mjs +1 -0
- package/dist/private/lib/access/pathTools.mjs +2 -5
- package/package.json +504 -4
|
@@ -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
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A short name for the class of an error, for a log line: the `name` property when it is a plain identifier of at most
|
|
3
|
+
* 40 characters (`TypeError`, `DbConnectError`), else `undefined`. Never the message.
|
|
4
|
+
*/
|
|
5
|
+
export declare function errorNameOf(error: unknown): string | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { readField } from "../../../private/lib/PostgreSQL/readField.mjs";
|
|
2
|
+
/** A plain identifier of at most 40 characters, starting with a letter. */
|
|
3
|
+
const CLASS_NAME = /^[A-Za-z]\w{0,39}$/;
|
|
4
|
+
/**
|
|
5
|
+
* A short name for the class of an error, for a log line: the `name` property when it is a plain identifier of at most
|
|
6
|
+
* 40 characters (`TypeError`, `DbConnectError`), else `undefined`. Never the message.
|
|
7
|
+
*/
|
|
8
|
+
export function errorNameOf(error) {
|
|
9
|
+
const name = readField(error, 'name');
|
|
10
|
+
return typeof name === 'string' && CLASS_NAME.test(name) ? name : undefined;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=errorNameOf.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IConstraintEntry } from './IConstraintEntry.mjs';
|
|
2
|
+
import type { IConstraintTable } from './IConstraintTable.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* The row for a constraint name, or `undefined`. Only own keys count, so a name such as `constructor` or `__proto__` (the
|
|
5
|
+
* server accepts any quoted identifier) finds nothing: the table is searched by its own entries, never indexed by the name.
|
|
6
|
+
*/
|
|
7
|
+
export declare function lookupConstraint<TCode extends string>(table: IConstraintTable<TCode>, name: string): IConstraintEntry<TCode> | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The row for a constraint name, or `undefined`. Only own keys count, so a name such as `constructor` or `__proto__` (the
|
|
3
|
+
* server accepts any quoted identifier) finds nothing: the table is searched by its own entries, never indexed by the name.
|
|
4
|
+
*/
|
|
5
|
+
export function lookupConstraint(table, name) {
|
|
6
|
+
return Object.entries(table).find(([key]) => key === name)?.[1];
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=lookupConstraint.mjs.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IMapDbErrorOptions } from './IMapDbErrorOptions.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* The one translation of a database failure into the closed vocabulary of your own error family. It answers an error of
|
|
4
|
+
* `options.errors` for every input, so the catch block of a handler is `throw mapDbError(error, { errors, table, logger })`.
|
|
5
|
+
*
|
|
6
|
+
* What it does, in order:
|
|
7
|
+
*
|
|
8
|
+
* 1. An error that `errors.is` recognises (what `withTx` throws, or an error of yours) is returned as it is, the same
|
|
9
|
+
* object, without a log line or a count.
|
|
10
|
+
* 2. A `DbParseError`, a `DbConnectError` or a `DbTxError` becomes `errors.internal` with a reason of its own
|
|
11
|
+
* (`DB_VALUE_UNREADABLE`, `DB_CONNECTION`, `DB_TX_MISUSE`).
|
|
12
|
+
* 3. SQLSTATE `23505` (unique), `23514` (check) and `23503` (foreign key) are looked up by the name of the constraint in
|
|
13
|
+
* the error (the `constraint` field the server fills) in `options.table`:
|
|
14
|
+
* - a row gives `errors.make(code, details)` with the details the row fixes and the ones the caller supplied
|
|
15
|
+
* (`options.details`, only the keys the row lists);
|
|
16
|
+
* - a name that is not in the table, or no name at all, gives `errors.internal('CONSTRAINT_UNMAPPED')`: the name is
|
|
17
|
+
* logged and counted, the response carries nothing of it.
|
|
18
|
+
* 4. Any other SQLSTATE gives `errors.internal('DB_ERROR')`, anything else `errors.internal('UNEXPECTED_ERROR')`.
|
|
19
|
+
*
|
|
20
|
+
* What an internal error of this function carries is a reason from `DB_INTERNAL_REASONS` and nothing else. The log line
|
|
21
|
+
* carries the reason, the SQLSTATE, the constraint name (when it is a plain identifier), the closed reason of a typed
|
|
22
|
+
* error and, for an unexpected error, the name of its class. Nothing else of the failure is read: not the message, not the
|
|
23
|
+
* `detail` (it quotes the failing row, so the bound values), not `query`, `values` or `parameters` if a wrapper put them on
|
|
24
|
+
* the error, not the stack.
|
|
25
|
+
*
|
|
26
|
+
* It does not throw, and it reads `options.errors.make` only for a row of the table.
|
|
27
|
+
*/
|
|
28
|
+
export declare function mapDbError<TError extends Error>(error: unknown, options: IMapDbErrorOptions<TError>): TError;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { errorNameOf } from "./errorNameOf.mjs";
|
|
2
|
+
import { sqlstateOf } from "./sqlstateOf.mjs";
|
|
3
|
+
import { internalFailure } from "../../../private/lib/PostgreSQL/internalFailure.mjs";
|
|
4
|
+
import { mapTypedError } from "../../../private/lib/PostgreSQL/mapTypedError.mjs";
|
|
5
|
+
import { mapViolation } from "../../../private/lib/PostgreSQL/mapViolation.mjs";
|
|
6
|
+
/** Unique violation, check violation and foreign key violation: the three that are looked up by constraint name. */
|
|
7
|
+
const VIOLATION_SQLSTATES = new Set(['23505', '23514', '23503']);
|
|
8
|
+
/**
|
|
9
|
+
* The one translation of a database failure into the closed vocabulary of your own error family. It answers an error of
|
|
10
|
+
* `options.errors` for every input, so the catch block of a handler is `throw mapDbError(error, { errors, table, logger })`.
|
|
11
|
+
*
|
|
12
|
+
* What it does, in order:
|
|
13
|
+
*
|
|
14
|
+
* 1. An error that `errors.is` recognises (what `withTx` throws, or an error of yours) is returned as it is, the same
|
|
15
|
+
* object, without a log line or a count.
|
|
16
|
+
* 2. A `DbParseError`, a `DbConnectError` or a `DbTxError` becomes `errors.internal` with a reason of its own
|
|
17
|
+
* (`DB_VALUE_UNREADABLE`, `DB_CONNECTION`, `DB_TX_MISUSE`).
|
|
18
|
+
* 3. SQLSTATE `23505` (unique), `23514` (check) and `23503` (foreign key) are looked up by the name of the constraint in
|
|
19
|
+
* the error (the `constraint` field the server fills) in `options.table`:
|
|
20
|
+
* - a row gives `errors.make(code, details)` with the details the row fixes and the ones the caller supplied
|
|
21
|
+
* (`options.details`, only the keys the row lists);
|
|
22
|
+
* - a name that is not in the table, or no name at all, gives `errors.internal('CONSTRAINT_UNMAPPED')`: the name is
|
|
23
|
+
* logged and counted, the response carries nothing of it.
|
|
24
|
+
* 4. Any other SQLSTATE gives `errors.internal('DB_ERROR')`, anything else `errors.internal('UNEXPECTED_ERROR')`.
|
|
25
|
+
*
|
|
26
|
+
* What an internal error of this function carries is a reason from `DB_INTERNAL_REASONS` and nothing else. The log line
|
|
27
|
+
* carries the reason, the SQLSTATE, the constraint name (when it is a plain identifier), the closed reason of a typed
|
|
28
|
+
* error and, for an unexpected error, the name of its class. Nothing else of the failure is read: not the message, not the
|
|
29
|
+
* `detail` (it quotes the failing row, so the bound values), not `query`, `values` or `parameters` if a wrapper put them on
|
|
30
|
+
* the error, not the stack.
|
|
31
|
+
*
|
|
32
|
+
* It does not throw, and it reads `options.errors.make` only for a row of the table.
|
|
33
|
+
*/
|
|
34
|
+
export function mapDbError(error, options) {
|
|
35
|
+
if (options.errors.is(error))
|
|
36
|
+
return error;
|
|
37
|
+
const typed = mapTypedError(error, options);
|
|
38
|
+
if (typed !== undefined)
|
|
39
|
+
return typed;
|
|
40
|
+
const sqlstate = sqlstateOf(error);
|
|
41
|
+
if (sqlstate === undefined) {
|
|
42
|
+
const name = errorNameOf(error);
|
|
43
|
+
return internalFailure(options, 'db_error_internal_total', 'unexpected error at the database boundary', {
|
|
44
|
+
reason: 'UNEXPECTED_ERROR',
|
|
45
|
+
...(name === undefined ? {} : { errorName: name })
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (VIOLATION_SQLSTATES.has(sqlstate))
|
|
49
|
+
return mapViolation(error, sqlstate, options);
|
|
50
|
+
return internalFailure(options, 'db_error_internal_total', 'database error', { reason: 'DB_ERROR', sqlstate });
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=mapDbError.mjs.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SQLSTATE of an error from the driver, or `undefined` for anything that has no safe five-character `code`.
|
|
3
|
+
* The message, the `detail` (which quotes the failing row), the `query` and the `parameters` are never read.
|
|
4
|
+
*/
|
|
5
|
+
export declare function sqlstateOf(error: unknown): string | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { readField } from "../../../private/lib/PostgreSQL/readField.mjs";
|
|
2
|
+
/** A SQLSTATE is five characters of digits and upper-case letters; anything else is not logged. */
|
|
3
|
+
const SQLSTATE = /^[0-9A-Z]{5}$/;
|
|
4
|
+
/**
|
|
5
|
+
* The SQLSTATE of an error from the driver, or `undefined` for anything that has no safe five-character `code`.
|
|
6
|
+
* The message, the `detail` (which quotes the failing row), the `query` and the `parameters` are never read.
|
|
7
|
+
*/
|
|
8
|
+
export function sqlstateOf(error) {
|
|
9
|
+
const code = readField(error, 'code');
|
|
10
|
+
return typeof code === 'string' && SQLSTATE.test(code) ? code : undefined;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=sqlstateOf.mjs.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The codes `guardVersion` passes to `errors.make`: `NOT_FOUND` (with the details `{ entity }`), `STALE_VERSION` and
|
|
3
|
+
* `STALE_REV` (no details). The application's factory maps them to the codes of its own family.
|
|
4
|
+
*/
|
|
5
|
+
export type IVersionGuardCode = 'NOT_FOUND' | 'STALE_VERSION' | 'STALE_REV';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { IDbErrorFactory } from "../error/IDbErrorFactory.mjs";
|
|
2
|
+
import type { IPoolLogger } from "../pool/IPoolLogger.mjs";
|
|
3
|
+
import type { IGuardCounter } from './IGuardCounter.mjs';
|
|
4
|
+
import type { IVersionGuardField } from './IVersionGuardField.mjs';
|
|
5
|
+
/** The input of `guardVersion`. */
|
|
6
|
+
export interface IVersionGuardInput<TError extends Error = Error> {
|
|
7
|
+
/**
|
|
8
|
+
* The statement that reads the row again, in the transaction of the failed update. It carries the visibility predicate
|
|
9
|
+
* of the actor (for a row of a group: the actor is an active member of it) and the id, and answers no row when the row
|
|
10
|
+
* is absent or the actor may not see it, and one row with the column named by `field` otherwise. The text is a
|
|
11
|
+
* literal; the values are parameters.
|
|
12
|
+
*/
|
|
13
|
+
readonly reread: {
|
|
14
|
+
readonly text: string;
|
|
15
|
+
readonly values?: readonly unknown[];
|
|
16
|
+
};
|
|
17
|
+
/** The version (or rev) that the failed update was guarded with: the one the client sent. */
|
|
18
|
+
readonly expected: number;
|
|
19
|
+
/** The guarded column: `version` (`STALE_VERSION`) or `rev` (`STALE_REV`). */
|
|
20
|
+
readonly field: IVersionGuardField;
|
|
21
|
+
/** The kind of row, for `NOT_FOUND` (`order`, `membership`, ...): the details are `{ entity }`. */
|
|
22
|
+
readonly entity: string;
|
|
23
|
+
/** Builds every error `guardVersion` answers: `make` for `NOT_FOUND`, `STALE_VERSION` and `STALE_REV`, `internal` for the rest. */
|
|
24
|
+
readonly errors: Pick<IDbErrorFactory<TError>, 'make' | 'internal'>;
|
|
25
|
+
/** Where the internal cases are logged; only `error` is called. */
|
|
26
|
+
readonly logger: Pick<IPoolLogger, 'error'>;
|
|
27
|
+
/** Where `guardVersion` counts. Default: nowhere. */
|
|
28
|
+
readonly counter?: IGuardCounter;
|
|
29
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IAffectedResult } from './IAffectedResult.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Throws `onMismatch` unless the statement affected exactly `expected` rows. `onMismatch` is the error to throw, or a
|
|
4
|
+
* function that builds it (so that a call that succeeds builds no error); it comes from the caller, built with the
|
|
5
|
+
* caller's own error family, so nothing here imports one. A count the server did not report (`null`, the answer of a
|
|
6
|
+
* statement that is not a `SELECT`, `INSERT`, `UPDATE` or `DELETE`) is not `expected`: nothing was proved, so nothing is
|
|
7
|
+
* reported as a success. `expected` is a whole number from 0; anything else is a `TypeError`, thrown before the count is
|
|
8
|
+
* read.
|
|
9
|
+
*/
|
|
10
|
+
export declare function assertAffected(result: IAffectedResult, expected: number, onMismatch: Error | (() => Error)): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throws `onMismatch` unless the statement affected exactly `expected` rows. `onMismatch` is the error to throw, or a
|
|
3
|
+
* function that builds it (so that a call that succeeds builds no error); it comes from the caller, built with the
|
|
4
|
+
* caller's own error family, so nothing here imports one. A count the server did not report (`null`, the answer of a
|
|
5
|
+
* statement that is not a `SELECT`, `INSERT`, `UPDATE` or `DELETE`) is not `expected`: nothing was proved, so nothing is
|
|
6
|
+
* reported as a success. `expected` is a whole number from 0; anything else is a `TypeError`, thrown before the count is
|
|
7
|
+
* read.
|
|
8
|
+
*/
|
|
9
|
+
export function assertAffected(result, expected, onMismatch) {
|
|
10
|
+
if (!Number.isSafeInteger(expected) || expected < 0) {
|
|
11
|
+
throw new TypeError('expected must be a whole number of rows from 0');
|
|
12
|
+
}
|
|
13
|
+
if (result.rowCount === expected)
|
|
14
|
+
return;
|
|
15
|
+
throw typeof onMismatch === 'function' ? onMismatch() : onMismatch;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=assertAffected.mjs.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ITx } from "../tx/ITx.mjs";
|
|
2
|
+
import type { IVersionGuardInput } from './IVersionGuardInput.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Says why an update guarded by `WHERE id = $1 AND version = $2` (or `rev`) affected no row, and answers the error for the
|
|
5
|
+
* caller to throw (it does not throw it, so `throw await guardVersion(...)` ends the flow for the compiler too):
|
|
6
|
+
*
|
|
7
|
+
* - `errors.make('NOT_FOUND', { entity })` when the re-read finds no row: the row is absent, or the actor may not see it.
|
|
8
|
+
* The two cases are one answer on purpose, so a call by id never confirms that a row exists to someone who may not see
|
|
9
|
+
* it, and a stale version of such a row is `NOT_FOUND`, never `STALE_VERSION`;
|
|
10
|
+
* - `errors.make('STALE_VERSION')` (`field` `version`) or `errors.make('STALE_REV')` (`field` `rev`) when the actor sees
|
|
11
|
+
* the row and it has another version than `expected`;
|
|
12
|
+
* - `errors.internal('VERSION_UNCHANGED')` when the actor sees the row and it still has `expected`: the update missed for
|
|
13
|
+
* a reason this guard cannot name, which a version-only guard should not have;
|
|
14
|
+
* - `errors.internal('REREAD_UNREADABLE')` when the statement answered more than one row or no readable column.
|
|
15
|
+
*
|
|
16
|
+
* A failure of the re-read itself is thrown unchanged, for `mapDbError` or `withTx` to classify. Call it in the
|
|
17
|
+
* transaction of the update, so that the re-read sees what the update saw. It builds no SQL and logs no bound value: the
|
|
18
|
+
* statement runs as given, a literal with parameters written by the caller, who owns the table and the visibility rule.
|
|
19
|
+
* `TypeError` for a `field`, an `expected` or an `entity` out of shape, before any statement.
|
|
20
|
+
*/
|
|
21
|
+
export declare function guardVersion<TError extends Error>(tx: Pick<ITx, 'query'>, input: IVersionGuardInput<TError>): Promise<TError>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { assertVersionGuardInput } from "../../../private/lib/PostgreSQL/assertVersionGuardInput.mjs";
|
|
2
|
+
import { internalFailure } from "../../../private/lib/PostgreSQL/internalFailure.mjs";
|
|
3
|
+
import { readField } from "../../../private/lib/PostgreSQL/readField.mjs";
|
|
4
|
+
import { versionText } from "../../../private/lib/PostgreSQL/versionText.mjs";
|
|
5
|
+
/** Logs, counts and builds the internal error for a re-read that cannot decide. */
|
|
6
|
+
function undecided(input, reason) {
|
|
7
|
+
return internalFailure(input, 'db_error_internal_total', 'version guard cannot decide', {
|
|
8
|
+
reason,
|
|
9
|
+
field: input.field,
|
|
10
|
+
entity: input.entity
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Says why an update guarded by `WHERE id = $1 AND version = $2` (or `rev`) affected no row, and answers the error for the
|
|
15
|
+
* caller to throw (it does not throw it, so `throw await guardVersion(...)` ends the flow for the compiler too):
|
|
16
|
+
*
|
|
17
|
+
* - `errors.make('NOT_FOUND', { entity })` when the re-read finds no row: the row is absent, or the actor may not see it.
|
|
18
|
+
* The two cases are one answer on purpose, so a call by id never confirms that a row exists to someone who may not see
|
|
19
|
+
* it, and a stale version of such a row is `NOT_FOUND`, never `STALE_VERSION`;
|
|
20
|
+
* - `errors.make('STALE_VERSION')` (`field` `version`) or `errors.make('STALE_REV')` (`field` `rev`) when the actor sees
|
|
21
|
+
* the row and it has another version than `expected`;
|
|
22
|
+
* - `errors.internal('VERSION_UNCHANGED')` when the actor sees the row and it still has `expected`: the update missed for
|
|
23
|
+
* a reason this guard cannot name, which a version-only guard should not have;
|
|
24
|
+
* - `errors.internal('REREAD_UNREADABLE')` when the statement answered more than one row or no readable column.
|
|
25
|
+
*
|
|
26
|
+
* A failure of the re-read itself is thrown unchanged, for `mapDbError` or `withTx` to classify. Call it in the
|
|
27
|
+
* transaction of the update, so that the re-read sees what the update saw. It builds no SQL and logs no bound value: the
|
|
28
|
+
* statement runs as given, a literal with parameters written by the caller, who owns the table and the visibility rule.
|
|
29
|
+
* `TypeError` for a `field`, an `expected` or an `entity` out of shape, before any statement.
|
|
30
|
+
*/
|
|
31
|
+
export async function guardVersion(tx, input) {
|
|
32
|
+
assertVersionGuardInput(input);
|
|
33
|
+
const answer = await tx.query(input.reread.text, input.reread.values);
|
|
34
|
+
const [row, ...more] = answer.rows;
|
|
35
|
+
if (row === undefined)
|
|
36
|
+
return input.errors.make('NOT_FOUND', { entity: input.entity });
|
|
37
|
+
if (more.length > 0)
|
|
38
|
+
return undecided(input, 'REREAD_UNREADABLE');
|
|
39
|
+
const current = versionText(readField(row, input.field));
|
|
40
|
+
if (current === undefined)
|
|
41
|
+
return undecided(input, 'REREAD_UNREADABLE');
|
|
42
|
+
if (current === String(input.expected))
|
|
43
|
+
return undecided(input, 'VERSION_UNCHANGED');
|
|
44
|
+
const stale = input.field === 'version' ? 'STALE_VERSION' : 'STALE_REV';
|
|
45
|
+
return input.errors.make(stale);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=guardVersion.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed lists of `claimRowsSkipLocked`: a table name, then a predicate name, then the whole statement. The statements
|
|
3
|
+
* are yours and are written in your code, never built from input; the kit only picks one by two names that must be own
|
|
4
|
+
* keys here. Each statement takes the number of rows as `$1`.
|
|
5
|
+
*/
|
|
6
|
+
export type IClaimRegistry = Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** What `claimRowsSkipLocked` takes: two names from the closed lists and a bound on the rows. */
|
|
2
|
+
export interface IClaimRequest {
|
|
3
|
+
readonly table: string;
|
|
4
|
+
readonly predicate: string;
|
|
5
|
+
/** A whole number from 1 to `CLAIM_LIMIT_MAX`. */
|
|
6
|
+
readonly limit: number;
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `createLockOrderTracker` takes: the order of the locks of each mode, the rank each helper takes, and the mode a
|
|
3
|
+
* transaction is in until it says otherwise. The names are yours (`'standard'`, `'group'`, `'lockGroupShare'`); the kit
|
|
4
|
+
* ships no order. The spec is checked once, when the tracker is made, and copied: changing the object afterwards changes
|
|
5
|
+
* nothing.
|
|
6
|
+
*/
|
|
7
|
+
export interface ILockOrderSpec<TMode extends string = string, THelper extends string = string> {
|
|
8
|
+
/** The ranks of each mode, lowest first, as distinct names. The rank of a name is its position, counted from 1. */
|
|
9
|
+
readonly orders: Readonly<Record<TMode, readonly string[]>>;
|
|
10
|
+
/**
|
|
11
|
+
* The rank each helper takes, by mode. A mode left out, or `undefined`, means the helper does not belong to that
|
|
12
|
+
* order. A helper must take a rank in at least one mode, and the name must be in the order of that mode.
|
|
13
|
+
*/
|
|
14
|
+
readonly helpers: Readonly<Record<THelper, {
|
|
15
|
+
readonly [TKey in NoInfer<TMode>]?: string | undefined;
|
|
16
|
+
}>>;
|
|
17
|
+
/** The mode of a transaction that was not given one. */
|
|
18
|
+
readonly defaultMode: NoInfer<TMode>;
|
|
19
|
+
}
|