@contember/database 1.4.0-rc.8 → 2.0.0-alpha.8
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/dist/development/index.cjs +102 -0
- package/dist/development/index.cjs.map +1 -0
- package/dist/development/index.js +90 -0
- package/dist/development/index.js.map +1 -0
- package/dist/development/src/Literal.cjs +37 -0
- package/dist/development/src/Literal.cjs.map +1 -0
- package/dist/development/src/Literal.js +37 -0
- package/dist/development/src/Literal.js.map +1 -0
- package/dist/development/src/builders/CaseStatement.cjs +46 -0
- package/dist/development/src/builders/CaseStatement.cjs.map +1 -0
- package/dist/development/src/builders/CaseStatement.js +46 -0
- package/dist/development/src/builders/CaseStatement.js.map +1 -0
- package/dist/development/src/builders/ColumnExpressionFactory.cjs +33 -0
- package/dist/development/src/builders/ColumnExpressionFactory.cjs.map +1 -0
- package/dist/development/src/builders/ColumnExpressionFactory.js +33 -0
- package/dist/development/src/builders/ColumnExpressionFactory.js.map +1 -0
- package/dist/development/src/builders/Compiler.cjs +217 -0
- package/dist/development/src/builders/Compiler.cjs.map +1 -0
- package/dist/development/src/builders/Compiler.js +217 -0
- package/dist/development/src/builders/Compiler.js.map +1 -0
- package/dist/development/src/builders/ConditionBuilder.cjs +156 -0
- package/dist/development/src/builders/ConditionBuilder.cjs.map +1 -0
- package/dist/development/src/builders/ConditionBuilder.js +156 -0
- package/dist/development/src/builders/ConditionBuilder.js.map +1 -0
- package/dist/development/src/builders/ConflictActionType.cjs +9 -0
- package/dist/development/src/builders/ConflictActionType.cjs.map +1 -0
- package/dist/development/src/builders/ConflictActionType.js +9 -0
- package/dist/development/src/builders/ConflictActionType.js.map +1 -0
- package/dist/development/src/builders/DeleteBuilder.cjs +54 -0
- package/dist/development/src/builders/DeleteBuilder.cjs.map +1 -0
- package/dist/development/src/builders/DeleteBuilder.js +54 -0
- package/dist/development/src/builders/DeleteBuilder.js.map +1 -0
- package/dist/development/src/builders/InsertBuilder.cjs +106 -0
- package/dist/development/src/builders/InsertBuilder.cjs.map +1 -0
- package/dist/development/src/builders/InsertBuilder.js +106 -0
- package/dist/development/src/builders/InsertBuilder.js.map +1 -0
- package/dist/development/src/builders/LimitByGroupWrapper.cjs +37 -0
- package/dist/development/src/builders/LimitByGroupWrapper.cjs.map +1 -0
- package/dist/development/src/builders/LimitByGroupWrapper.js +37 -0
- package/dist/development/src/builders/LimitByGroupWrapper.js.map +1 -0
- package/dist/development/src/builders/LockType.cjs +17 -0
- package/dist/development/src/builders/LockType.cjs.map +1 -0
- package/dist/development/src/builders/LockType.js +17 -0
- package/dist/development/src/builders/LockType.js.map +1 -0
- package/dist/development/src/builders/SelectBuilder.cjs +143 -0
- package/dist/development/src/builders/SelectBuilder.cjs.map +1 -0
- package/dist/development/src/builders/SelectBuilder.js +143 -0
- package/dist/development/src/builders/SelectBuilder.js.map +1 -0
- package/dist/development/src/builders/UpdateBuilder.cjs +82 -0
- package/dist/development/src/builders/UpdateBuilder.cjs.map +1 -0
- package/dist/development/src/builders/UpdateBuilder.js +82 -0
- package/dist/development/src/builders/UpdateBuilder.js.map +1 -0
- package/dist/development/src/builders/WindowFunction.cjs +50 -0
- package/dist/development/src/builders/WindowFunction.cjs.map +1 -0
- package/dist/development/src/builders/WindowFunction.js +50 -0
- package/dist/development/src/builders/WindowFunction.js.map +1 -0
- package/dist/development/src/builders/formatUtils.cjs +23 -0
- package/dist/development/src/builders/formatUtils.cjs.map +1 -0
- package/dist/development/src/builders/formatUtils.js +23 -0
- package/dist/development/src/builders/formatUtils.js.map +1 -0
- package/dist/development/src/builders/internal/Returning.cjs +26 -0
- package/dist/development/src/builders/internal/Returning.cjs.map +1 -0
- package/dist/development/src/builders/internal/Returning.js +26 -0
- package/dist/development/src/builders/internal/Returning.js.map +1 -0
- package/dist/development/src/builders/internal/Subqueries.cjs +15 -0
- package/dist/development/src/builders/internal/Subqueries.cjs.map +1 -0
- package/dist/development/src/builders/internal/Subqueries.js +15 -0
- package/dist/development/src/builders/internal/Subqueries.js.map +1 -0
- package/dist/development/src/builders/internal/Where.cjs +53 -0
- package/dist/development/src/builders/internal/Where.cjs.map +1 -0
- package/dist/development/src/builders/internal/Where.js +54 -0
- package/dist/development/src/builders/internal/Where.js.map +1 -0
- package/dist/development/src/builders/internal/With.cjs +52 -0
- package/dist/development/src/builders/internal/With.cjs.map +1 -0
- package/dist/development/src/builders/internal/With.js +53 -0
- package/dist/development/src/builders/internal/With.js.map +1 -0
- package/dist/development/src/builders/utils.cjs +26 -0
- package/dist/development/src/builders/utils.cjs.map +1 -0
- package/dist/development/src/builders/utils.js +26 -0
- package/dist/development/src/builders/utils.js.map +1 -0
- package/dist/development/src/client/AcquiredConnection.cjs +91 -0
- package/dist/development/src/client/AcquiredConnection.cjs.map +1 -0
- package/dist/development/src/client/AcquiredConnection.js +91 -0
- package/dist/development/src/client/AcquiredConnection.js.map +1 -0
- package/dist/development/src/client/Client.cjs +89 -0
- package/dist/development/src/client/Client.cjs.map +1 -0
- package/dist/development/src/client/Client.js +89 -0
- package/dist/development/src/client/Client.js.map +1 -0
- package/dist/development/src/client/Connection.cjs +62 -0
- package/dist/development/src/client/Connection.cjs.map +1 -0
- package/dist/development/src/client/Connection.js +62 -0
- package/dist/development/src/client/Connection.js.map +1 -0
- package/dist/development/src/client/EventManager.cjs +38 -0
- package/dist/development/src/client/EventManager.cjs.map +1 -0
- package/dist/development/src/client/EventManager.js +38 -0
- package/dist/development/src/client/EventManager.js.map +1 -0
- package/dist/development/src/client/Pool.cjs +380 -0
- package/dist/development/src/client/Pool.cjs.map +1 -0
- package/dist/development/src/client/Pool.js +380 -0
- package/dist/development/src/client/Pool.js.map +1 -0
- package/dist/development/src/client/Transaction.cjs +143 -0
- package/dist/development/src/client/Transaction.cjs.map +1 -0
- package/dist/development/src/client/Transaction.js +143 -0
- package/dist/development/src/client/Transaction.js.map +1 -0
- package/dist/development/src/client/errorCodes.cjs +266 -0
- package/dist/development/src/client/errorCodes.cjs.map +1 -0
- package/dist/development/src/client/errorCodes.js +266 -0
- package/dist/development/src/client/errorCodes.js.map +1 -0
- package/dist/development/src/client/errors.cjs +65 -0
- package/dist/development/src/client/errors.cjs.map +1 -0
- package/dist/development/src/client/errors.js +65 -0
- package/dist/development/src/client/errors.js.map +1 -0
- package/dist/development/src/exceptions.cjs +6 -0
- package/dist/development/src/exceptions.cjs.map +1 -0
- package/dist/development/src/exceptions.js +6 -0
- package/dist/development/src/exceptions.js.map +1 -0
- package/dist/development/src/metadata/DatabaseMetadata.cjs +18 -0
- package/dist/development/src/metadata/DatabaseMetadata.cjs.map +1 -0
- package/dist/development/src/metadata/DatabaseMetadata.js +18 -0
- package/dist/development/src/metadata/DatabaseMetadata.js.map +1 -0
- package/dist/{src/metadata/DatabaseMetadataResolver.js → development/src/metadata/DatabaseMetadataResolver.cjs} +49 -59
- package/dist/development/src/metadata/DatabaseMetadataResolver.cjs.map +1 -0
- package/dist/development/src/metadata/DatabaseMetadataResolver.js +96 -0
- package/dist/development/src/metadata/DatabaseMetadataResolver.js.map +1 -0
- package/dist/development/src/metadata/ForeignKeyConstraintMetadata.cjs +56 -0
- package/dist/development/src/metadata/ForeignKeyConstraintMetadata.cjs.map +1 -0
- package/dist/development/src/metadata/ForeignKeyConstraintMetadata.js +56 -0
- package/dist/development/src/metadata/ForeignKeyConstraintMetadata.js.map +1 -0
- package/dist/development/src/metadata/IndexMetadata.cjs +30 -0
- package/dist/development/src/metadata/IndexMetadata.cjs.map +1 -0
- package/dist/development/src/metadata/IndexMetadata.js +30 -0
- package/dist/development/src/metadata/IndexMetadata.js.map +1 -0
- package/dist/development/src/metadata/UniqueConstraintMetadata.cjs +39 -0
- package/dist/development/src/metadata/UniqueConstraintMetadata.cjs.map +1 -0
- package/dist/development/src/metadata/UniqueConstraintMetadata.js +39 -0
- package/dist/development/src/metadata/UniqueConstraintMetadata.js.map +1 -0
- package/dist/development/src/metadata/stringArrayEquals.cjs +12 -0
- package/dist/development/src/metadata/stringArrayEquals.cjs.map +1 -0
- package/dist/development/src/metadata/stringArrayEquals.js +12 -0
- package/dist/development/src/metadata/stringArrayEquals.js.map +1 -0
- package/dist/development/src/queryable/DatabaseQuery.cjs +16 -0
- package/dist/development/src/queryable/DatabaseQuery.cjs.map +1 -0
- package/dist/development/src/queryable/DatabaseQuery.js +16 -0
- package/dist/development/src/queryable/DatabaseQuery.js.map +1 -0
- package/dist/development/src/queryable/DatabaseQueryable.cjs +13 -0
- package/dist/development/src/queryable/DatabaseQueryable.cjs.map +1 -0
- package/dist/development/src/queryable/DatabaseQueryable.js +13 -0
- package/dist/development/src/queryable/DatabaseQueryable.js.map +1 -0
- package/dist/development/src/utils/ConstraintHelper.cjs +44 -0
- package/dist/development/src/utils/ConstraintHelper.cjs.map +1 -0
- package/dist/development/src/utils/ConstraintHelper.js +44 -0
- package/dist/development/src/utils/ConstraintHelper.js.map +1 -0
- package/dist/development/src/utils/Mutex.cjs +49 -0
- package/dist/development/src/utils/Mutex.cjs.map +1 -0
- package/dist/development/src/utils/Mutex.js +49 -0
- package/dist/development/src/utils/Mutex.js.map +1 -0
- package/dist/development/src/utils/assertNever.cjs +7 -0
- package/dist/development/src/utils/assertNever.cjs.map +1 -0
- package/dist/development/src/utils/assertNever.js +7 -0
- package/dist/development/src/utils/assertNever.js.map +1 -0
- package/dist/development/src/utils/asyncIterableTransaction.cjs +26 -0
- package/dist/development/src/utils/asyncIterableTransaction.cjs.map +1 -0
- package/dist/development/src/utils/asyncIterableTransaction.js +26 -0
- package/dist/development/src/utils/asyncIterableTransaction.js.map +1 -0
- package/dist/development/src/utils/createDatabaseIfNotExists.cjs +34 -0
- package/dist/development/src/utils/createDatabaseIfNotExists.cjs.map +1 -0
- package/dist/development/src/utils/createDatabaseIfNotExists.js +34 -0
- package/dist/development/src/utils/createDatabaseIfNotExists.js.map +1 -0
- package/dist/development/src/utils/listen.cjs +118 -0
- package/dist/development/src/utils/listen.cjs.map +1 -0
- package/dist/development/src/utils/listen.js +118 -0
- package/dist/development/src/utils/listen.js.map +1 -0
- package/dist/{src/utils/pgClientFactory.js → development/src/utils/pgClientFactory.cjs} +8 -7
- package/dist/development/src/utils/pgClientFactory.cjs.map +1 -0
- package/dist/development/src/utils/pgClientFactory.js +13 -0
- package/dist/development/src/utils/pgClientFactory.js.map +1 -0
- package/dist/development/src/utils/retryTransaction.cjs +49 -0
- package/dist/development/src/utils/retryTransaction.cjs.map +1 -0
- package/dist/development/src/utils/retryTransaction.js +49 -0
- package/dist/development/src/utils/retryTransaction.js.map +1 -0
- package/dist/development/src/utils/sql.cjs +22 -0
- package/dist/development/src/utils/sql.cjs.map +1 -0
- package/dist/development/src/utils/sql.js +22 -0
- package/dist/development/src/utils/sql.js.map +1 -0
- package/dist/development/src/utils/withDatabaseAdvisoryLock.cjs +15 -0
- package/dist/development/src/utils/withDatabaseAdvisoryLock.cjs.map +1 -0
- package/dist/development/src/utils/withDatabaseAdvisoryLock.js +15 -0
- package/dist/development/src/utils/withDatabaseAdvisoryLock.js.map +1 -0
- package/dist/production/index.cjs +102 -0
- package/dist/production/index.cjs.map +1 -0
- package/dist/production/index.js +90 -0
- package/dist/production/index.js.map +1 -0
- package/dist/production/src/Literal.cjs +37 -0
- package/dist/production/src/Literal.cjs.map +1 -0
- package/dist/production/src/Literal.js +37 -0
- package/dist/production/src/Literal.js.map +1 -0
- package/dist/production/src/builders/CaseStatement.cjs +46 -0
- package/dist/production/src/builders/CaseStatement.cjs.map +1 -0
- package/dist/production/src/builders/CaseStatement.js +46 -0
- package/dist/production/src/builders/CaseStatement.js.map +1 -0
- package/dist/production/src/builders/ColumnExpressionFactory.cjs +33 -0
- package/dist/production/src/builders/ColumnExpressionFactory.cjs.map +1 -0
- package/dist/production/src/builders/ColumnExpressionFactory.js +33 -0
- package/dist/production/src/builders/ColumnExpressionFactory.js.map +1 -0
- package/dist/production/src/builders/Compiler.cjs +217 -0
- package/dist/production/src/builders/Compiler.cjs.map +1 -0
- package/dist/production/src/builders/Compiler.js +217 -0
- package/dist/production/src/builders/Compiler.js.map +1 -0
- package/dist/production/src/builders/ConditionBuilder.cjs +156 -0
- package/dist/production/src/builders/ConditionBuilder.cjs.map +1 -0
- package/dist/production/src/builders/ConditionBuilder.js +156 -0
- package/dist/production/src/builders/ConditionBuilder.js.map +1 -0
- package/dist/production/src/builders/ConflictActionType.cjs +9 -0
- package/dist/production/src/builders/ConflictActionType.cjs.map +1 -0
- package/dist/production/src/builders/ConflictActionType.js +9 -0
- package/dist/production/src/builders/ConflictActionType.js.map +1 -0
- package/dist/production/src/builders/DeleteBuilder.cjs +54 -0
- package/dist/production/src/builders/DeleteBuilder.cjs.map +1 -0
- package/dist/production/src/builders/DeleteBuilder.js +54 -0
- package/dist/production/src/builders/DeleteBuilder.js.map +1 -0
- package/dist/production/src/builders/InsertBuilder.cjs +106 -0
- package/dist/production/src/builders/InsertBuilder.cjs.map +1 -0
- package/dist/production/src/builders/InsertBuilder.js +106 -0
- package/dist/production/src/builders/InsertBuilder.js.map +1 -0
- package/dist/production/src/builders/LimitByGroupWrapper.cjs +37 -0
- package/dist/production/src/builders/LimitByGroupWrapper.cjs.map +1 -0
- package/dist/production/src/builders/LimitByGroupWrapper.js +37 -0
- package/dist/production/src/builders/LimitByGroupWrapper.js.map +1 -0
- package/dist/production/src/builders/LockType.cjs +17 -0
- package/dist/production/src/builders/LockType.cjs.map +1 -0
- package/dist/production/src/builders/LockType.js +17 -0
- package/dist/production/src/builders/LockType.js.map +1 -0
- package/dist/production/src/builders/SelectBuilder.cjs +143 -0
- package/dist/production/src/builders/SelectBuilder.cjs.map +1 -0
- package/dist/production/src/builders/SelectBuilder.js +143 -0
- package/dist/production/src/builders/SelectBuilder.js.map +1 -0
- package/dist/production/src/builders/UpdateBuilder.cjs +82 -0
- package/dist/production/src/builders/UpdateBuilder.cjs.map +1 -0
- package/dist/production/src/builders/UpdateBuilder.js +82 -0
- package/dist/production/src/builders/UpdateBuilder.js.map +1 -0
- package/dist/production/src/builders/WindowFunction.cjs +50 -0
- package/dist/production/src/builders/WindowFunction.cjs.map +1 -0
- package/dist/production/src/builders/WindowFunction.js +50 -0
- package/dist/production/src/builders/WindowFunction.js.map +1 -0
- package/dist/production/src/builders/formatUtils.cjs +23 -0
- package/dist/production/src/builders/formatUtils.cjs.map +1 -0
- package/dist/production/src/builders/formatUtils.js +23 -0
- package/dist/production/src/builders/formatUtils.js.map +1 -0
- package/dist/production/src/builders/internal/Returning.cjs +26 -0
- package/dist/production/src/builders/internal/Returning.cjs.map +1 -0
- package/dist/production/src/builders/internal/Returning.js +26 -0
- package/dist/production/src/builders/internal/Returning.js.map +1 -0
- package/dist/production/src/builders/internal/Subqueries.cjs +15 -0
- package/dist/production/src/builders/internal/Subqueries.cjs.map +1 -0
- package/dist/production/src/builders/internal/Subqueries.js +15 -0
- package/dist/production/src/builders/internal/Subqueries.js.map +1 -0
- package/dist/production/src/builders/internal/Where.cjs +53 -0
- package/dist/production/src/builders/internal/Where.cjs.map +1 -0
- package/dist/production/src/builders/internal/Where.js +54 -0
- package/dist/production/src/builders/internal/Where.js.map +1 -0
- package/dist/production/src/builders/internal/With.cjs +52 -0
- package/dist/production/src/builders/internal/With.cjs.map +1 -0
- package/dist/production/src/builders/internal/With.js +53 -0
- package/dist/production/src/builders/internal/With.js.map +1 -0
- package/dist/production/src/builders/utils.cjs +26 -0
- package/dist/production/src/builders/utils.cjs.map +1 -0
- package/dist/production/src/builders/utils.js +26 -0
- package/dist/production/src/builders/utils.js.map +1 -0
- package/dist/production/src/client/AcquiredConnection.cjs +91 -0
- package/dist/production/src/client/AcquiredConnection.cjs.map +1 -0
- package/dist/production/src/client/AcquiredConnection.js +91 -0
- package/dist/production/src/client/AcquiredConnection.js.map +1 -0
- package/dist/production/src/client/Client.cjs +89 -0
- package/dist/production/src/client/Client.cjs.map +1 -0
- package/dist/production/src/client/Client.js +89 -0
- package/dist/production/src/client/Client.js.map +1 -0
- package/dist/production/src/client/Connection.cjs +62 -0
- package/dist/production/src/client/Connection.cjs.map +1 -0
- package/dist/production/src/client/Connection.js +62 -0
- package/dist/production/src/client/Connection.js.map +1 -0
- package/dist/production/src/client/EventManager.cjs +38 -0
- package/dist/production/src/client/EventManager.cjs.map +1 -0
- package/dist/production/src/client/EventManager.js +38 -0
- package/dist/production/src/client/EventManager.js.map +1 -0
- package/dist/production/src/client/Pool.cjs +380 -0
- package/dist/production/src/client/Pool.cjs.map +1 -0
- package/dist/production/src/client/Pool.js +380 -0
- package/dist/production/src/client/Pool.js.map +1 -0
- package/dist/production/src/client/Transaction.cjs +143 -0
- package/dist/production/src/client/Transaction.cjs.map +1 -0
- package/dist/production/src/client/Transaction.js +143 -0
- package/dist/production/src/client/Transaction.js.map +1 -0
- package/dist/production/src/client/errorCodes.cjs +266 -0
- package/dist/production/src/client/errorCodes.cjs.map +1 -0
- package/dist/production/src/client/errorCodes.js +266 -0
- package/dist/production/src/client/errorCodes.js.map +1 -0
- package/dist/production/src/client/errors.cjs +65 -0
- package/dist/production/src/client/errors.cjs.map +1 -0
- package/dist/production/src/client/errors.js +65 -0
- package/dist/production/src/client/errors.js.map +1 -0
- package/dist/production/src/exceptions.cjs +6 -0
- package/dist/production/src/exceptions.cjs.map +1 -0
- package/dist/production/src/exceptions.js +6 -0
- package/dist/production/src/exceptions.js.map +1 -0
- package/dist/production/src/metadata/DatabaseMetadata.cjs +18 -0
- package/dist/production/src/metadata/DatabaseMetadata.cjs.map +1 -0
- package/dist/production/src/metadata/DatabaseMetadata.js +18 -0
- package/dist/production/src/metadata/DatabaseMetadata.js.map +1 -0
- package/dist/production/src/metadata/DatabaseMetadataResolver.cjs +96 -0
- package/dist/production/src/metadata/DatabaseMetadataResolver.cjs.map +1 -0
- package/dist/production/src/metadata/DatabaseMetadataResolver.js +96 -0
- package/dist/production/src/metadata/DatabaseMetadataResolver.js.map +1 -0
- package/dist/production/src/metadata/ForeignKeyConstraintMetadata.cjs +56 -0
- package/dist/production/src/metadata/ForeignKeyConstraintMetadata.cjs.map +1 -0
- package/dist/production/src/metadata/ForeignKeyConstraintMetadata.js +56 -0
- package/dist/production/src/metadata/ForeignKeyConstraintMetadata.js.map +1 -0
- package/dist/production/src/metadata/IndexMetadata.cjs +30 -0
- package/dist/production/src/metadata/IndexMetadata.cjs.map +1 -0
- package/dist/production/src/metadata/IndexMetadata.js +30 -0
- package/dist/production/src/metadata/IndexMetadata.js.map +1 -0
- package/dist/production/src/metadata/UniqueConstraintMetadata.cjs +39 -0
- package/dist/production/src/metadata/UniqueConstraintMetadata.cjs.map +1 -0
- package/dist/production/src/metadata/UniqueConstraintMetadata.js +39 -0
- package/dist/production/src/metadata/UniqueConstraintMetadata.js.map +1 -0
- package/dist/production/src/metadata/stringArrayEquals.cjs +12 -0
- package/dist/production/src/metadata/stringArrayEquals.cjs.map +1 -0
- package/dist/production/src/metadata/stringArrayEquals.js +12 -0
- package/dist/production/src/metadata/stringArrayEquals.js.map +1 -0
- package/dist/production/src/queryable/DatabaseQuery.cjs +16 -0
- package/dist/production/src/queryable/DatabaseQuery.cjs.map +1 -0
- package/dist/production/src/queryable/DatabaseQuery.js +16 -0
- package/dist/production/src/queryable/DatabaseQuery.js.map +1 -0
- package/dist/production/src/queryable/DatabaseQueryable.cjs +13 -0
- package/dist/production/src/queryable/DatabaseQueryable.cjs.map +1 -0
- package/dist/production/src/queryable/DatabaseQueryable.js +13 -0
- package/dist/production/src/queryable/DatabaseQueryable.js.map +1 -0
- package/dist/production/src/utils/ConstraintHelper.cjs +44 -0
- package/dist/production/src/utils/ConstraintHelper.cjs.map +1 -0
- package/dist/production/src/utils/ConstraintHelper.js +44 -0
- package/dist/production/src/utils/ConstraintHelper.js.map +1 -0
- package/dist/production/src/utils/Mutex.cjs +49 -0
- package/dist/production/src/utils/Mutex.cjs.map +1 -0
- package/dist/production/src/utils/Mutex.js +49 -0
- package/dist/production/src/utils/Mutex.js.map +1 -0
- package/dist/production/src/utils/assertNever.cjs +7 -0
- package/dist/production/src/utils/assertNever.cjs.map +1 -0
- package/dist/production/src/utils/assertNever.js +7 -0
- package/dist/production/src/utils/assertNever.js.map +1 -0
- package/dist/production/src/utils/asyncIterableTransaction.cjs +26 -0
- package/dist/production/src/utils/asyncIterableTransaction.cjs.map +1 -0
- package/dist/production/src/utils/asyncIterableTransaction.js +26 -0
- package/dist/production/src/utils/asyncIterableTransaction.js.map +1 -0
- package/dist/production/src/utils/createDatabaseIfNotExists.cjs +34 -0
- package/dist/production/src/utils/createDatabaseIfNotExists.cjs.map +1 -0
- package/dist/production/src/utils/createDatabaseIfNotExists.js +34 -0
- package/dist/production/src/utils/createDatabaseIfNotExists.js.map +1 -0
- package/dist/production/src/utils/listen.cjs +118 -0
- package/dist/production/src/utils/listen.cjs.map +1 -0
- package/dist/production/src/utils/listen.js +118 -0
- package/dist/production/src/utils/listen.js.map +1 -0
- package/dist/production/src/utils/pgClientFactory.cjs +13 -0
- package/dist/production/src/utils/pgClientFactory.cjs.map +1 -0
- package/dist/production/src/utils/pgClientFactory.js +13 -0
- package/dist/production/src/utils/pgClientFactory.js.map +1 -0
- package/dist/production/src/utils/retryTransaction.cjs +49 -0
- package/dist/production/src/utils/retryTransaction.cjs.map +1 -0
- package/dist/production/src/utils/retryTransaction.js +49 -0
- package/dist/production/src/utils/retryTransaction.js.map +1 -0
- package/dist/production/src/utils/sql.cjs +22 -0
- package/dist/production/src/utils/sql.cjs.map +1 -0
- package/dist/production/src/utils/sql.js +22 -0
- package/dist/production/src/utils/sql.js.map +1 -0
- package/dist/production/src/utils/withDatabaseAdvisoryLock.cjs +15 -0
- package/dist/production/src/utils/withDatabaseAdvisoryLock.cjs.map +1 -0
- package/dist/production/src/utils/withDatabaseAdvisoryLock.js +15 -0
- package/dist/production/src/utils/withDatabaseAdvisoryLock.js.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/{src → types}/builders/QueryBuilder.d.ts +1 -1
- package/dist/{src → types}/builders/QueryBuilder.d.ts.map +1 -1
- package/dist/{src → types}/client/Pool.d.ts +0 -1
- package/dist/types/client/Pool.d.ts.map +1 -0
- package/dist/{src → types}/client/Transaction.d.ts +1 -1
- package/dist/{src → types}/client/Transaction.d.ts.map +1 -1
- package/dist/{src → types}/client/errors.d.ts +0 -2
- package/dist/{src → types}/client/errors.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/dist/{src → types}/types.d.ts +0 -1
- package/dist/types/types.d.ts.map +1 -0
- package/dist/{src → types}/utils/createDatabaseIfNotExists.d.ts.map +1 -1
- package/dist/{src → types}/utils/pgClientFactory.d.ts +2 -2
- package/dist/types/utils/pgClientFactory.d.ts.map +1 -0
- package/dist/types/utils/retryTransaction.d.ts +7 -0
- package/dist/{src → types}/utils/retryTransaction.d.ts.map +1 -1
- package/dist/{src → types}/utils/sql.d.ts.map +1 -1
- package/dist/{src → types}/utils/withDatabaseAdvisoryLock.d.ts.map +1 -1
- package/package.json +23 -11
- package/src/builders/QueryBuilder.ts +1 -1
- package/src/client/errors.ts +1 -3
- package/src/tsconfig.json +1 -1
- package/src/utils/pgClientFactory.ts +9 -7
- package/vitest.config.ts +3 -0
- package/dist/src/Literal.js +0 -34
- package/dist/src/Literal.js.map +0 -1
- package/dist/src/builders/CaseStatement.js +0 -47
- package/dist/src/builders/CaseStatement.js.map +0 -1
- package/dist/src/builders/ColumnExpressionFactory.js +0 -33
- package/dist/src/builders/ColumnExpressionFactory.js.map +0 -1
- package/dist/src/builders/Compiler.js +0 -215
- package/dist/src/builders/Compiler.js.map +0 -1
- package/dist/src/builders/ConditionBuilder.js +0 -156
- package/dist/src/builders/ConditionBuilder.js.map +0 -1
- package/dist/src/builders/ConflictActionType.js +0 -9
- package/dist/src/builders/ConflictActionType.js.map +0 -1
- package/dist/src/builders/DeleteBuilder.js +0 -55
- package/dist/src/builders/DeleteBuilder.js.map +0 -1
- package/dist/src/builders/InsertBuilder.js +0 -109
- package/dist/src/builders/InsertBuilder.js.map +0 -1
- package/dist/src/builders/LimitByGroupWrapper.js +0 -43
- package/dist/src/builders/LimitByGroupWrapper.js.map +0 -1
- package/dist/src/builders/LockType.js +0 -16
- package/dist/src/builders/LockType.js.map +0 -1
- package/dist/src/builders/QueryBuilder.js +0 -3
- package/dist/src/builders/QueryBuilder.js.map +0 -1
- package/dist/src/builders/SelectBuilder.js +0 -134
- package/dist/src/builders/SelectBuilder.js.map +0 -1
- package/dist/src/builders/UpdateBuilder.js +0 -84
- package/dist/src/builders/UpdateBuilder.js.map +0 -1
- package/dist/src/builders/WindowFunction.js +0 -50
- package/dist/src/builders/WindowFunction.js.map +0 -1
- package/dist/src/builders/formatUtils.js +0 -20
- package/dist/src/builders/formatUtils.js.map +0 -1
- package/dist/src/builders/index.js +0 -29
- package/dist/src/builders/index.js.map +0 -1
- package/dist/src/builders/internal/Returning.js +0 -25
- package/dist/src/builders/internal/Returning.js.map +0 -1
- package/dist/src/builders/internal/Subqueries.js +0 -18
- package/dist/src/builders/internal/Subqueries.js.map +0 -1
- package/dist/src/builders/internal/Where.js +0 -39
- package/dist/src/builders/internal/Where.js.map +0 -1
- package/dist/src/builders/internal/With.js +0 -41
- package/dist/src/builders/internal/With.js.map +0 -1
- package/dist/src/builders/utils.js +0 -30
- package/dist/src/builders/utils.js.map +0 -1
- package/dist/src/client/AcquiredConnection.js +0 -82
- package/dist/src/client/AcquiredConnection.js.map +0 -1
- package/dist/src/client/Client.js +0 -54
- package/dist/src/client/Client.js.map +0 -1
- package/dist/src/client/Connection.js +0 -62
- package/dist/src/client/Connection.js.map +0 -1
- package/dist/src/client/EventManager.js +0 -35
- package/dist/src/client/EventManager.js.map +0 -1
- package/dist/src/client/PgClient.js +0 -3
- package/dist/src/client/PgClient.js.map +0 -1
- package/dist/src/client/Pool.d.ts.map +0 -1
- package/dist/src/client/Pool.js +0 -404
- package/dist/src/client/Pool.js.map +0 -1
- package/dist/src/client/Transaction.js +0 -129
- package/dist/src/client/Transaction.js.map +0 -1
- package/dist/src/client/errorCodes.js +0 -266
- package/dist/src/client/errorCodes.js.map +0 -1
- package/dist/src/client/errors.js +0 -55
- package/dist/src/client/errors.js.map +0 -1
- package/dist/src/client/index.js +0 -24
- package/dist/src/client/index.js.map +0 -1
- package/dist/src/exceptions.js +0 -7
- package/dist/src/exceptions.js.map +0 -1
- package/dist/src/index.js +0 -34
- package/dist/src/index.js.map +0 -1
- package/dist/src/metadata/DatabaseMetadata.js +0 -18
- package/dist/src/metadata/DatabaseMetadata.js.map +0 -1
- package/dist/src/metadata/DatabaseMetadataResolver.js.map +0 -1
- package/dist/src/metadata/ForeignKeyConstraintMetadata.js +0 -56
- package/dist/src/metadata/ForeignKeyConstraintMetadata.js.map +0 -1
- package/dist/src/metadata/IndexMetadata.js +0 -31
- package/dist/src/metadata/IndexMetadata.js.map +0 -1
- package/dist/src/metadata/UniqueConstraintMetadata.js +0 -40
- package/dist/src/metadata/UniqueConstraintMetadata.js.map +0 -1
- package/dist/src/metadata/index.js +0 -22
- package/dist/src/metadata/index.js.map +0 -1
- package/dist/src/metadata/stringArrayEquals.js +0 -13
- package/dist/src/metadata/stringArrayEquals.js.map +0 -1
- package/dist/src/queryable/DatabaseQuery.js +0 -17
- package/dist/src/queryable/DatabaseQuery.js.map +0 -1
- package/dist/src/queryable/DatabaseQueryable.js +0 -14
- package/dist/src/queryable/DatabaseQueryable.js.map +0 -1
- package/dist/src/queryable/index.js +0 -19
- package/dist/src/queryable/index.js.map +0 -1
- package/dist/src/tsconfig.tsbuildinfo +0 -1
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -3
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils/ConstraintHelper.js +0 -42
- package/dist/src/utils/ConstraintHelper.js.map +0 -1
- package/dist/src/utils/Mutex.js +0 -49
- package/dist/src/utils/Mutex.js.map +0 -1
- package/dist/src/utils/assertNever.js +0 -8
- package/dist/src/utils/assertNever.js.map +0 -1
- package/dist/src/utils/asyncIterableTransaction.js +0 -32
- package/dist/src/utils/asyncIterableTransaction.js.map +0 -1
- package/dist/src/utils/createDatabaseIfNotExists.js +0 -24
- package/dist/src/utils/createDatabaseIfNotExists.js.map +0 -1
- package/dist/src/utils/index.js +0 -27
- package/dist/src/utils/index.js.map +0 -1
- package/dist/src/utils/listen.js +0 -126
- package/dist/src/utils/listen.js.map +0 -1
- package/dist/src/utils/pgClientFactory.d.ts.map +0 -1
- package/dist/src/utils/pgClientFactory.js.map +0 -1
- package/dist/src/utils/retryTransaction.d.ts +0 -7
- package/dist/src/utils/retryTransaction.js +0 -42
- package/dist/src/utils/retryTransaction.js.map +0 -1
- package/dist/src/utils/sql.js +0 -23
- package/dist/src/utils/sql.js.map +0 -1
- package/dist/src/utils/withDatabaseAdvisoryLock.js +0 -17
- package/dist/src/utils/withDatabaseAdvisoryLock.js.map +0 -1
- package/dist/tests/cases/unit/connection.test.js +0 -128
- package/dist/tests/cases/unit/connection.test.js.map +0 -1
- package/dist/tests/cases/unit/createConnectionMockAlt.js +0 -47
- package/dist/tests/cases/unit/createConnectionMockAlt.js.map +0 -1
- package/dist/tests/cases/unit/eventManager.test.js +0 -131
- package/dist/tests/cases/unit/eventManager.test.js.map +0 -1
- package/dist/tests/cases/unit/pool.test.js +0 -372
- package/dist/tests/cases/unit/pool.test.js.map +0 -1
- package/dist/tests/cases/unit/queryBuilder.test.js +0 -371
- package/dist/tests/cases/unit/queryBuilder.test.js.map +0 -1
- package/dist/tests/src/tags.js +0 -13
- package/dist/tests/src/tags.js.map +0 -1
- package/vite.config.js +0 -3
- /package/dist/{src → types}/Literal.d.ts +0 -0
- /package/dist/{src → types}/Literal.d.ts.map +0 -0
- /package/dist/{src → types}/builders/CaseStatement.d.ts +0 -0
- /package/dist/{src → types}/builders/CaseStatement.d.ts.map +0 -0
- /package/dist/{src → types}/builders/ColumnExpressionFactory.d.ts +0 -0
- /package/dist/{src → types}/builders/ColumnExpressionFactory.d.ts.map +0 -0
- /package/dist/{src → types}/builders/Compiler.d.ts +0 -0
- /package/dist/{src → types}/builders/Compiler.d.ts.map +0 -0
- /package/dist/{src → types}/builders/ConditionBuilder.d.ts +0 -0
- /package/dist/{src → types}/builders/ConditionBuilder.d.ts.map +0 -0
- /package/dist/{src → types}/builders/ConflictActionType.d.ts +0 -0
- /package/dist/{src → types}/builders/ConflictActionType.d.ts.map +0 -0
- /package/dist/{src → types}/builders/DeleteBuilder.d.ts +0 -0
- /package/dist/{src → types}/builders/DeleteBuilder.d.ts.map +0 -0
- /package/dist/{src → types}/builders/InsertBuilder.d.ts +0 -0
- /package/dist/{src → types}/builders/InsertBuilder.d.ts.map +0 -0
- /package/dist/{src → types}/builders/LimitByGroupWrapper.d.ts +0 -0
- /package/dist/{src → types}/builders/LimitByGroupWrapper.d.ts.map +0 -0
- /package/dist/{src → types}/builders/LockType.d.ts +0 -0
- /package/dist/{src → types}/builders/LockType.d.ts.map +0 -0
- /package/dist/{src → types}/builders/SelectBuilder.d.ts +0 -0
- /package/dist/{src → types}/builders/SelectBuilder.d.ts.map +0 -0
- /package/dist/{src → types}/builders/UpdateBuilder.d.ts +0 -0
- /package/dist/{src → types}/builders/UpdateBuilder.d.ts.map +0 -0
- /package/dist/{src → types}/builders/WindowFunction.d.ts +0 -0
- /package/dist/{src → types}/builders/WindowFunction.d.ts.map +0 -0
- /package/dist/{src → types}/builders/formatUtils.d.ts +0 -0
- /package/dist/{src → types}/builders/formatUtils.d.ts.map +0 -0
- /package/dist/{src → types}/builders/index.d.ts +0 -0
- /package/dist/{src → types}/builders/index.d.ts.map +0 -0
- /package/dist/{src → types}/builders/internal/Returning.d.ts +0 -0
- /package/dist/{src → types}/builders/internal/Returning.d.ts.map +0 -0
- /package/dist/{src → types}/builders/internal/Subqueries.d.ts +0 -0
- /package/dist/{src → types}/builders/internal/Subqueries.d.ts.map +0 -0
- /package/dist/{src → types}/builders/internal/Where.d.ts +0 -0
- /package/dist/{src → types}/builders/internal/Where.d.ts.map +0 -0
- /package/dist/{src → types}/builders/internal/With.d.ts +0 -0
- /package/dist/{src → types}/builders/internal/With.d.ts.map +0 -0
- /package/dist/{src → types}/builders/utils.d.ts +0 -0
- /package/dist/{src → types}/builders/utils.d.ts.map +0 -0
- /package/dist/{src → types}/client/AcquiredConnection.d.ts +0 -0
- /package/dist/{src → types}/client/AcquiredConnection.d.ts.map +0 -0
- /package/dist/{src → types}/client/Client.d.ts +0 -0
- /package/dist/{src → types}/client/Client.d.ts.map +0 -0
- /package/dist/{src → types}/client/Connection.d.ts +0 -0
- /package/dist/{src → types}/client/Connection.d.ts.map +0 -0
- /package/dist/{src → types}/client/EventManager.d.ts +0 -0
- /package/dist/{src → types}/client/EventManager.d.ts.map +0 -0
- /package/dist/{src → types}/client/PgClient.d.ts +0 -0
- /package/dist/{src → types}/client/PgClient.d.ts.map +0 -0
- /package/dist/{src → types}/client/errorCodes.d.ts +0 -0
- /package/dist/{src → types}/client/errorCodes.d.ts.map +0 -0
- /package/dist/{src → types}/client/index.d.ts +0 -0
- /package/dist/{src → types}/client/index.d.ts.map +0 -0
- /package/dist/{src → types}/exceptions.d.ts +0 -0
- /package/dist/{src → types}/exceptions.d.ts.map +0 -0
- /package/dist/{src → types}/index.d.ts +0 -0
- /package/dist/{src → types}/index.d.ts.map +0 -0
- /package/dist/{src → types}/metadata/DatabaseMetadata.d.ts +0 -0
- /package/dist/{src → types}/metadata/DatabaseMetadata.d.ts.map +0 -0
- /package/dist/{src → types}/metadata/DatabaseMetadataResolver.d.ts +0 -0
- /package/dist/{src → types}/metadata/DatabaseMetadataResolver.d.ts.map +0 -0
- /package/dist/{src → types}/metadata/ForeignKeyConstraintMetadata.d.ts +0 -0
- /package/dist/{src → types}/metadata/ForeignKeyConstraintMetadata.d.ts.map +0 -0
- /package/dist/{src → types}/metadata/IndexMetadata.d.ts +0 -0
- /package/dist/{src → types}/metadata/IndexMetadata.d.ts.map +0 -0
- /package/dist/{src → types}/metadata/UniqueConstraintMetadata.d.ts +0 -0
- /package/dist/{src → types}/metadata/UniqueConstraintMetadata.d.ts.map +0 -0
- /package/dist/{src → types}/metadata/index.d.ts +0 -0
- /package/dist/{src → types}/metadata/index.d.ts.map +0 -0
- /package/dist/{src → types}/metadata/stringArrayEquals.d.ts +0 -0
- /package/dist/{src → types}/metadata/stringArrayEquals.d.ts.map +0 -0
- /package/dist/{src → types}/queryable/DatabaseQuery.d.ts +0 -0
- /package/dist/{src → types}/queryable/DatabaseQuery.d.ts.map +0 -0
- /package/dist/{src → types}/queryable/DatabaseQueryable.d.ts +0 -0
- /package/dist/{src → types}/queryable/DatabaseQueryable.d.ts.map +0 -0
- /package/dist/{src → types}/queryable/index.d.ts +0 -0
- /package/dist/{src → types}/queryable/index.d.ts.map +0 -0
- /package/dist/{src → types}/utils/ConstraintHelper.d.ts +0 -0
- /package/dist/{src → types}/utils/ConstraintHelper.d.ts.map +0 -0
- /package/dist/{src → types}/utils/Mutex.d.ts +0 -0
- /package/dist/{src → types}/utils/Mutex.d.ts.map +0 -0
- /package/dist/{src → types}/utils/assertNever.d.ts +0 -0
- /package/dist/{src → types}/utils/assertNever.d.ts.map +0 -0
- /package/dist/{src → types}/utils/asyncIterableTransaction.d.ts +0 -0
- /package/dist/{src → types}/utils/asyncIterableTransaction.d.ts.map +0 -0
- /package/dist/{src → types}/utils/createDatabaseIfNotExists.d.ts +0 -0
- /package/dist/{src → types}/utils/index.d.ts +0 -0
- /package/dist/{src → types}/utils/index.d.ts.map +0 -0
- /package/dist/{src → types}/utils/listen.d.ts +0 -0
- /package/dist/{src → types}/utils/listen.d.ts.map +0 -0
- /package/dist/{src → types}/utils/sql.d.ts +0 -0
- /package/dist/{src → types}/utils/withDatabaseAdvisoryLock.d.ts +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("../builders/Compiler.cjs");
|
|
4
|
+
require("../Literal.cjs");
|
|
5
|
+
require("node:timers");
|
|
6
|
+
require("./Mutex.cjs");
|
|
7
|
+
require("pg");
|
|
8
|
+
require("../builders/SelectBuilder.cjs");
|
|
9
|
+
require("../builders/internal/With.cjs");
|
|
10
|
+
require("../builders/internal/Where.cjs");
|
|
11
|
+
require("../client/EventManager.cjs");
|
|
12
|
+
require("@contember/queryable");
|
|
13
|
+
const errors = require("../client/errors.cjs");
|
|
14
|
+
require("../client/Connection.cjs");
|
|
15
|
+
const defaultOptions = {
|
|
16
|
+
maxAttempts: 5,
|
|
17
|
+
minTimeout: 20,
|
|
18
|
+
maxTimeout: 100
|
|
19
|
+
};
|
|
20
|
+
const retryTransaction = async (cb, logger, options = {}) => {
|
|
21
|
+
let attempt = 0;
|
|
22
|
+
const minTimeout = options.minTimeout ?? defaultOptions.minTimeout;
|
|
23
|
+
const maxAttempts = options.maxAttempts ?? defaultOptions.maxAttempts;
|
|
24
|
+
const additionalTimeout = ((options.maxTimeout ?? defaultOptions.maxTimeout) - minTimeout) / maxAttempts;
|
|
25
|
+
const timeout = async (attempt2) => {
|
|
26
|
+
const timeout2 = Math.round(minTimeout + Math.random() * additionalTimeout * attempt2);
|
|
27
|
+
await new Promise((resolve) => setTimeout(resolve, timeout2));
|
|
28
|
+
return timeout2;
|
|
29
|
+
};
|
|
30
|
+
do {
|
|
31
|
+
attempt++;
|
|
32
|
+
try {
|
|
33
|
+
return await cb();
|
|
34
|
+
} catch (e) {
|
|
35
|
+
if (!(e instanceof errors.SerializationFailureError)) {
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
if (attempt < maxAttempts) {
|
|
39
|
+
const timeoutMs = await timeout(attempt);
|
|
40
|
+
logger(`RETRY: Serialization failure (attempt #${attempt}, retrying after ${timeoutMs}ms)`);
|
|
41
|
+
} else {
|
|
42
|
+
logger(`ABORT: Serialization failure (attempt #${attempt})`);
|
|
43
|
+
throw e;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
} while (true);
|
|
47
|
+
};
|
|
48
|
+
exports.retryTransaction = retryTransaction;
|
|
49
|
+
//# sourceMappingURL=retryTransaction.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retryTransaction.cjs","sources":["../../../../../packages/database/src/utils/retryTransaction.ts"],"sourcesContent":["import { SerializationFailureError } from '../client'\n\nexport interface RetryOptions {\n\tmaxAttempts: number\n\tminTimeout: number\n\tmaxTimeout: number\n}\n\nconst defaultOptions: RetryOptions = {\n\tmaxAttempts: 5,\n\tminTimeout: 20,\n\tmaxTimeout: 100,\n}\n\nexport const retryTransaction = async <R>(\n\tcb: () => Promise<R> | R,\n\tlogger: (message: string) => void,\n\toptions: Partial<RetryOptions> = {},\n): Promise<R> => {\n\tlet attempt = 0\n\tconst minTimeout = options.minTimeout ?? defaultOptions.minTimeout\n\tconst maxAttempts = options.maxAttempts ?? defaultOptions.maxAttempts\n\tconst additionalTimeout = ((options.maxTimeout ?? defaultOptions.maxTimeout) - minTimeout) / maxAttempts\n\tconst timeout = async (attempt: number) => {\n\t\tconst timeout = Math.round(minTimeout + Math.random() * additionalTimeout * attempt)\n\t\tawait new Promise(resolve => setTimeout(resolve, timeout))\n\t\treturn timeout\n\t}\n\n\tdo {\n\t\tattempt++\n\t\ttry {\n\t\t\treturn await cb()\n\t\t} catch (e) {\n\t\t\tif (!(e instanceof SerializationFailureError)) {\n\t\t\t\tthrow e\n\t\t\t}\n\t\t\tif (attempt < maxAttempts) {\n\t\t\t\tconst timeoutMs = await timeout(attempt)\n\t\t\t\tlogger(`RETRY: Serialization failure (attempt #${attempt}, retrying after ${timeoutMs}ms)`)\n\t\t\t} else {\n\t\t\t\tlogger(`ABORT: Serialization failure (attempt #${attempt})`)\n\t\t\t\tthrow e\n\t\t\t}\n\t\t}\n\t} while (true)\n}\n"],"names":["attempt","timeout","SerializationFailureError"],"mappings":";;;;;;;;;;;;;;AAQA,MAAM,iBAA+B;AAAA,EACpC,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AACb;AAEO,MAAM,mBAAmB,OAC/B,IACA,QACA,UAAiC,CAAA,MACjB;AAChB,MAAI,UAAU;AACR,QAAA,aAAa,QAAQ,cAAc,eAAe;AAClD,QAAA,cAAc,QAAQ,eAAe,eAAe;AAC1D,QAAM,sBAAsB,QAAQ,cAAc,eAAe,cAAc,cAAc;AACvF,QAAA,UAAU,OAAOA,aAAoB;AACpCC,UAAAA,WAAU,KAAK,MAAM,aAAa,KAAK,OAAO,IAAI,oBAAoBD,QAAO;AACnF,UAAM,IAAI,QAAQ,CAAA,YAAW,WAAW,SAASC,QAAO,CAAC;AAClDA,WAAAA;AAAAA,EAAA;AAGL,KAAA;AACF;AACI,QAAA;AACH,aAAO,MAAM,GAAG;AAAA,aACR,GAAG;AACP,UAAA,EAAE,aAAaC,OAAAA,4BAA4B;AACxC,cAAA;AAAA,MACP;AACA,UAAI,UAAU,aAAa;AACpB,cAAA,YAAY,MAAM,QAAQ,OAAO;AACvC,eAAO,0CAA0C,OAAO,oBAAoB,SAAS,KAAK;AAAA,MAAA,OACpF;AACC,eAAA,0CAA0C,OAAO,GAAG;AACrD,cAAA;AAAA,MACP;AAAA,IACD;AAAA,EACQ,SAAA;AACV;;"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import "../builders/Compiler.js";
|
|
2
|
+
import "../Literal.js";
|
|
3
|
+
import "node:timers";
|
|
4
|
+
import "./Mutex.js";
|
|
5
|
+
import "pg";
|
|
6
|
+
import "../builders/SelectBuilder.js";
|
|
7
|
+
import "../builders/internal/With.js";
|
|
8
|
+
import "../builders/internal/Where.js";
|
|
9
|
+
import "../client/EventManager.js";
|
|
10
|
+
import "@contember/queryable";
|
|
11
|
+
import { SerializationFailureError } from "../client/errors.js";
|
|
12
|
+
import "../client/Connection.js";
|
|
13
|
+
const defaultOptions = {
|
|
14
|
+
maxAttempts: 5,
|
|
15
|
+
minTimeout: 20,
|
|
16
|
+
maxTimeout: 100
|
|
17
|
+
};
|
|
18
|
+
const retryTransaction = async (cb, logger, options = {}) => {
|
|
19
|
+
let attempt = 0;
|
|
20
|
+
const minTimeout = options.minTimeout ?? defaultOptions.minTimeout;
|
|
21
|
+
const maxAttempts = options.maxAttempts ?? defaultOptions.maxAttempts;
|
|
22
|
+
const additionalTimeout = ((options.maxTimeout ?? defaultOptions.maxTimeout) - minTimeout) / maxAttempts;
|
|
23
|
+
const timeout = async (attempt2) => {
|
|
24
|
+
const timeout2 = Math.round(minTimeout + Math.random() * additionalTimeout * attempt2);
|
|
25
|
+
await new Promise((resolve) => setTimeout(resolve, timeout2));
|
|
26
|
+
return timeout2;
|
|
27
|
+
};
|
|
28
|
+
do {
|
|
29
|
+
attempt++;
|
|
30
|
+
try {
|
|
31
|
+
return await cb();
|
|
32
|
+
} catch (e) {
|
|
33
|
+
if (!(e instanceof SerializationFailureError)) {
|
|
34
|
+
throw e;
|
|
35
|
+
}
|
|
36
|
+
if (attempt < maxAttempts) {
|
|
37
|
+
const timeoutMs = await timeout(attempt);
|
|
38
|
+
logger(`RETRY: Serialization failure (attempt #${attempt}, retrying after ${timeoutMs}ms)`);
|
|
39
|
+
} else {
|
|
40
|
+
logger(`ABORT: Serialization failure (attempt #${attempt})`);
|
|
41
|
+
throw e;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} while (true);
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
retryTransaction
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=retryTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retryTransaction.js","sources":["../../../../../packages/database/src/utils/retryTransaction.ts"],"sourcesContent":["import { SerializationFailureError } from '../client'\n\nexport interface RetryOptions {\n\tmaxAttempts: number\n\tminTimeout: number\n\tmaxTimeout: number\n}\n\nconst defaultOptions: RetryOptions = {\n\tmaxAttempts: 5,\n\tminTimeout: 20,\n\tmaxTimeout: 100,\n}\n\nexport const retryTransaction = async <R>(\n\tcb: () => Promise<R> | R,\n\tlogger: (message: string) => void,\n\toptions: Partial<RetryOptions> = {},\n): Promise<R> => {\n\tlet attempt = 0\n\tconst minTimeout = options.minTimeout ?? defaultOptions.minTimeout\n\tconst maxAttempts = options.maxAttempts ?? defaultOptions.maxAttempts\n\tconst additionalTimeout = ((options.maxTimeout ?? defaultOptions.maxTimeout) - minTimeout) / maxAttempts\n\tconst timeout = async (attempt: number) => {\n\t\tconst timeout = Math.round(minTimeout + Math.random() * additionalTimeout * attempt)\n\t\tawait new Promise(resolve => setTimeout(resolve, timeout))\n\t\treturn timeout\n\t}\n\n\tdo {\n\t\tattempt++\n\t\ttry {\n\t\t\treturn await cb()\n\t\t} catch (e) {\n\t\t\tif (!(e instanceof SerializationFailureError)) {\n\t\t\t\tthrow e\n\t\t\t}\n\t\t\tif (attempt < maxAttempts) {\n\t\t\t\tconst timeoutMs = await timeout(attempt)\n\t\t\t\tlogger(`RETRY: Serialization failure (attempt #${attempt}, retrying after ${timeoutMs}ms)`)\n\t\t\t} else {\n\t\t\t\tlogger(`ABORT: Serialization failure (attempt #${attempt})`)\n\t\t\t\tthrow e\n\t\t\t}\n\t\t}\n\t} while (true)\n}\n"],"names":["attempt","timeout"],"mappings":";;;;;;;;;;;;AAQA,MAAM,iBAA+B;AAAA,EACpC,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AACb;AAEO,MAAM,mBAAmB,OAC/B,IACA,QACA,UAAiC,CAAA,MACjB;AAChB,MAAI,UAAU;AACR,QAAA,aAAa,QAAQ,cAAc,eAAe;AAClD,QAAA,cAAc,QAAQ,eAAe,eAAe;AAC1D,QAAM,sBAAsB,QAAQ,cAAc,eAAe,cAAc,cAAc;AACvF,QAAA,UAAU,OAAOA,aAAoB;AACpCC,UAAAA,WAAU,KAAK,MAAM,aAAa,KAAK,OAAO,IAAI,oBAAoBD,QAAO;AACnF,UAAM,IAAI,QAAQ,CAAA,YAAW,WAAW,SAASC,QAAO,CAAC;AAClDA,WAAAA;AAAAA,EAAA;AAGL,KAAA;AACF;AACI,QAAA;AACH,aAAO,MAAM,GAAG;AAAA,aACR,GAAG;AACP,UAAA,EAAE,aAAa,4BAA4B;AACxC,cAAA;AAAA,MACP;AACA,UAAI,UAAU,aAAa;AACpB,cAAA,YAAY,MAAM,QAAQ,OAAO;AACvC,eAAO,0CAA0C,OAAO,oBAAoB,SAAS,KAAK;AAAA,MAAA,OACpF;AACC,eAAA,0CAA0C,OAAO,GAAG;AACrD,cAAA;AAAA,MACP;AAAA,IACD;AAAA,EACQ,SAAA;AACV;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const Literal = require("../Literal.cjs");
|
|
4
|
+
const wrapIdentifier = (value) => '"' + value.replace(/"/g, '""') + '"';
|
|
5
|
+
const aliasLiteral = (raw, alias) => {
|
|
6
|
+
if (!alias) {
|
|
7
|
+
return raw;
|
|
8
|
+
}
|
|
9
|
+
return new Literal.Literal(raw.sql + " as " + wrapIdentifier(alias), raw.parameters);
|
|
10
|
+
};
|
|
11
|
+
const prependSchema = (tableExpression, schema, cteAliases) => {
|
|
12
|
+
if (typeof tableExpression !== "string") {
|
|
13
|
+
return tableExpression;
|
|
14
|
+
}
|
|
15
|
+
return new Literal.Literal(
|
|
16
|
+
cteAliases.has(tableExpression) ? wrapIdentifier(tableExpression) : `${wrapIdentifier(schema)}.${wrapIdentifier(tableExpression)}`
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
exports.aliasLiteral = aliasLiteral;
|
|
20
|
+
exports.prependSchema = prependSchema;
|
|
21
|
+
exports.wrapIdentifier = wrapIdentifier;
|
|
22
|
+
//# sourceMappingURL=sql.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql.cjs","sources":["../../../../../packages/database/src/utils/sql.ts"],"sourcesContent":["import { Literal } from '../Literal'\n\nexport const wrapIdentifier = (value: string) => '\"' + value.replace(/\"/g, '\"\"') + '\"'\n\nexport const aliasLiteral = (raw: Literal, alias?: string): Literal => {\n\tif (!alias) {\n\t\treturn raw\n\t}\n\treturn new Literal(raw.sql + ' as ' + wrapIdentifier(alias), raw.parameters)\n}\n\nexport const prependSchema = (tableExpression: string | Literal, schema: string, cteAliases: Set<string>) => {\n\tif (typeof tableExpression !== 'string') {\n\t\treturn tableExpression\n\t}\n\treturn new Literal(\n\t\tcteAliases.has(tableExpression)\n\t\t\t? wrapIdentifier(tableExpression)\n\t\t\t: `${wrapIdentifier(schema)}.${wrapIdentifier(tableExpression)}`,\n\t)\n}\n"],"names":["Literal"],"mappings":";;;AAEa,MAAA,iBAAiB,CAAC,UAAkB,MAAM,MAAM,QAAQ,MAAM,IAAI,IAAI;AAEtE,MAAA,eAAe,CAAC,KAAc,UAA4B;AACtE,MAAI,CAAC,OAAO;AACJ,WAAA;AAAA,EACR;AACO,SAAA,IAAIA,QAAAA,QAAQ,IAAI,MAAM,SAAS,eAAe,KAAK,GAAG,IAAI,UAAU;AAC5E;AAEO,MAAM,gBAAgB,CAAC,iBAAmC,QAAgB,eAA4B;AACxG,MAAA,OAAO,oBAAoB,UAAU;AACjC,WAAA;AAAA,EACR;AACA,SAAO,IAAIA,QAAA;AAAA,IACV,WAAW,IAAI,eAAe,IAC3B,eAAe,eAAe,IAC9B,GAAG,eAAe,MAAM,CAAC,IAAI,eAAe,eAAe,CAAC;AAAA,EAAA;AAEjE;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Literal } from "../Literal.js";
|
|
2
|
+
const wrapIdentifier = (value) => '"' + value.replace(/"/g, '""') + '"';
|
|
3
|
+
const aliasLiteral = (raw, alias) => {
|
|
4
|
+
if (!alias) {
|
|
5
|
+
return raw;
|
|
6
|
+
}
|
|
7
|
+
return new Literal(raw.sql + " as " + wrapIdentifier(alias), raw.parameters);
|
|
8
|
+
};
|
|
9
|
+
const prependSchema = (tableExpression, schema, cteAliases) => {
|
|
10
|
+
if (typeof tableExpression !== "string") {
|
|
11
|
+
return tableExpression;
|
|
12
|
+
}
|
|
13
|
+
return new Literal(
|
|
14
|
+
cteAliases.has(tableExpression) ? wrapIdentifier(tableExpression) : `${wrapIdentifier(schema)}.${wrapIdentifier(tableExpression)}`
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
aliasLiteral,
|
|
19
|
+
prependSchema,
|
|
20
|
+
wrapIdentifier
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=sql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql.js","sources":["../../../../../packages/database/src/utils/sql.ts"],"sourcesContent":["import { Literal } from '../Literal'\n\nexport const wrapIdentifier = (value: string) => '\"' + value.replace(/\"/g, '\"\"') + '\"'\n\nexport const aliasLiteral = (raw: Literal, alias?: string): Literal => {\n\tif (!alias) {\n\t\treturn raw\n\t}\n\treturn new Literal(raw.sql + ' as ' + wrapIdentifier(alias), raw.parameters)\n}\n\nexport const prependSchema = (tableExpression: string | Literal, schema: string, cteAliases: Set<string>) => {\n\tif (typeof tableExpression !== 'string') {\n\t\treturn tableExpression\n\t}\n\treturn new Literal(\n\t\tcteAliases.has(tableExpression)\n\t\t\t? wrapIdentifier(tableExpression)\n\t\t\t: `${wrapIdentifier(schema)}.${wrapIdentifier(tableExpression)}`,\n\t)\n}\n"],"names":[],"mappings":";AAEa,MAAA,iBAAiB,CAAC,UAAkB,MAAM,MAAM,QAAQ,MAAM,IAAI,IAAI;AAEtE,MAAA,eAAe,CAAC,KAAc,UAA4B;AACtE,MAAI,CAAC,OAAO;AACJ,WAAA;AAAA,EACR;AACO,SAAA,IAAI,QAAQ,IAAI,MAAM,SAAS,eAAe,KAAK,GAAG,IAAI,UAAU;AAC5E;AAEO,MAAM,gBAAgB,CAAC,iBAAmC,QAAgB,eAA4B;AACxG,MAAA,OAAO,oBAAoB,UAAU;AACjC,WAAA;AAAA,EACR;AACA,SAAO,IAAI;AAAA,IACV,WAAW,IAAI,eAAe,IAC3B,eAAe,eAAe,IAC9B,GAAG,eAAe,MAAM,CAAC,IAAI,eAAe,eAAe,CAAC;AAAA,EAAA;AAEjE;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const withDatabaseAdvisoryLock = async (connection, lock, callback) => {
|
|
4
|
+
await connection.query(`select pg_advisory_lock(?)`, [lock]);
|
|
5
|
+
try {
|
|
6
|
+
return await callback();
|
|
7
|
+
} finally {
|
|
8
|
+
const result = await connection.query('select pg_advisory_unlock(?) as "lockReleased"', [lock]);
|
|
9
|
+
if (!result.rows[0].lockReleased) {
|
|
10
|
+
throw new Error("Failed to release migration lock");
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
exports.withDatabaseAdvisoryLock = withDatabaseAdvisoryLock;
|
|
15
|
+
//# sourceMappingURL=withDatabaseAdvisoryLock.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withDatabaseAdvisoryLock.cjs","sources":["../../../../../packages/database/src/utils/withDatabaseAdvisoryLock.ts"],"sourcesContent":["import { Connection } from '../client'\n\nexport const withDatabaseAdvisoryLock = async <Result>(\n\tconnection: Connection.ConnectionLike,\n\tlock: number,\n\tcallback: () => Result | Promise<Result>,\n): Promise<Result> => {\n\tawait connection.query(`select pg_advisory_lock(?)`, [lock])\n\ttry {\n\t\treturn await callback()\n\t} finally {\n\t\tconst result = await connection.query<{lockReleased: boolean}>('select pg_advisory_unlock(?) as \"lockReleased\"', [lock])\n\t\tif (!result.rows[0].lockReleased) {\n\t\t\tthrow new Error('Failed to release migration lock')\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAEO,MAAM,2BAA2B,OACvC,YACA,MACA,aACqB;AACrB,QAAM,WAAW,MAAM,8BAA8B,CAAC,IAAI,CAAC;AACvD,MAAA;AACH,WAAO,MAAM,SAAS;AAAA,EAAA,UACrB;AACD,UAAM,SAAS,MAAM,WAAW,MAA+B,kDAAkD,CAAC,IAAI,CAAC;AACvH,QAAI,CAAC,OAAO,KAAK,CAAC,EAAE,cAAc;AAC3B,YAAA,IAAI,MAAM,kCAAkC;AAAA,IACnD;AAAA,EACD;AACD;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const withDatabaseAdvisoryLock = async (connection, lock, callback) => {
|
|
2
|
+
await connection.query(`select pg_advisory_lock(?)`, [lock]);
|
|
3
|
+
try {
|
|
4
|
+
return await callback();
|
|
5
|
+
} finally {
|
|
6
|
+
const result = await connection.query('select pg_advisory_unlock(?) as "lockReleased"', [lock]);
|
|
7
|
+
if (!result.rows[0].lockReleased) {
|
|
8
|
+
throw new Error("Failed to release migration lock");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
withDatabaseAdvisoryLock
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=withDatabaseAdvisoryLock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withDatabaseAdvisoryLock.js","sources":["../../../../../packages/database/src/utils/withDatabaseAdvisoryLock.ts"],"sourcesContent":["import { Connection } from '../client'\n\nexport const withDatabaseAdvisoryLock = async <Result>(\n\tconnection: Connection.ConnectionLike,\n\tlock: number,\n\tcallback: () => Result | Promise<Result>,\n): Promise<Result> => {\n\tawait connection.query(`select pg_advisory_lock(?)`, [lock])\n\ttry {\n\t\treturn await callback()\n\t} finally {\n\t\tconst result = await connection.query<{lockReleased: boolean}>('select pg_advisory_unlock(?) as \"lockReleased\"', [lock])\n\t\tif (!result.rows[0].lockReleased) {\n\t\t\tthrow new Error('Failed to release migration lock')\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAEO,MAAM,2BAA2B,OACvC,YACA,MACA,aACqB;AACrB,QAAM,WAAW,MAAM,8BAA8B,CAAC,IAAI,CAAC;AACvD,MAAA;AACH,WAAO,MAAM,SAAS;AAAA,EAAA,UACrB;AACD,UAAM,SAAS,MAAM,WAAW,MAA+B,kDAAkD,CAAC,IAAI,CAAC;AACvH,QAAI,CAAC,OAAO,KAAK,CAAC,EAAE,cAAc;AAC3B,YAAA,IAAI,MAAM,kCAAkC;AAAA,IACnD;AAAA,EACD;AACD;"}
|