@daiso-tech/core 0.40.0 → 0.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/dist/backoff-policies/_module-exports.d.ts +5 -0
- package/dist/backoff-policies/_module-exports.js +6 -0
- package/dist/backoff-policies/_module-exports.js.map +1 -0
- package/dist/{async/backof-policies → backoff-policies}/_shared.d.ts +6 -7
- package/dist/{async/backof-policies → backoff-policies}/_shared.js +1 -1
- package/dist/backoff-policies/_shared.js.map +1 -0
- package/dist/backoff-policies/constant-backoff-policy/_module.d.ts +1 -0
- package/dist/backoff-policies/constant-backoff-policy/_module.js +2 -0
- package/dist/backoff-policies/constant-backoff-policy/_module.js.map +1 -0
- package/dist/{async/backof-policies → backoff-policies}/constant-backoff-policy/constant-backoff-policy.d.ts +6 -8
- package/dist/{async/backof-policies → backoff-policies}/constant-backoff-policy/constant-backoff-policy.js +8 -10
- package/dist/backoff-policies/constant-backoff-policy/constant-backoff-policy.js.map +1 -0
- package/dist/backoff-policies/exponential-backoff-policy/_module.d.ts +1 -0
- package/dist/backoff-policies/exponential-backoff-policy/_module.js +2 -0
- package/dist/backoff-policies/exponential-backoff-policy/_module.js.map +1 -0
- package/dist/{async/backof-policies → backoff-policies}/exponential-backoff-policy/exponential-backoff-policy.d.ts +7 -9
- package/dist/backoff-policies/exponential-backoff-policy/exponential-backoff-policy.js +30 -0
- package/dist/backoff-policies/exponential-backoff-policy/exponential-backoff-policy.js.map +1 -0
- package/dist/backoff-policies/linear-backoff-policy/_module.d.ts +1 -0
- package/dist/backoff-policies/linear-backoff-policy/_module.js +2 -0
- package/dist/backoff-policies/linear-backoff-policy/_module.js.map +1 -0
- package/dist/{async/backof-policies → backoff-policies}/linear-backoff-policy/linear-backoff-policy.d.ts +7 -9
- package/dist/backoff-policies/linear-backoff-policy/linear-backoff-policy.js +30 -0
- package/dist/backoff-policies/linear-backoff-policy/linear-backoff-policy.js.map +1 -0
- package/dist/backoff-policies/polynomial-backoff-policy/_module.d.ts +1 -0
- package/dist/backoff-policies/polynomial-backoff-policy/_module.js +2 -0
- package/dist/backoff-policies/polynomial-backoff-policy/_module.js.map +1 -0
- package/dist/{async/backof-policies → backoff-policies}/polynomial-backoff-policy/polynomial-backoff-policy.d.ts +7 -9
- package/dist/backoff-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +30 -0
- package/dist/backoff-policies/polynomial-backoff-policy/polynomial-backoff-policy.js.map +1 -0
- package/dist/cache/contracts/cache-adapter.contract.d.ts +3 -3
- package/dist/cache/contracts/cache.contract.d.ts +22 -22
- package/dist/cache/contracts/cache.errors.d.ts +7 -14
- package/dist/cache/contracts/cache.errors.js +12 -24
- package/dist/cache/contracts/cache.errors.js.map +1 -1
- package/dist/cache/contracts/cache.events.d.ts +1 -1
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.d.ts +1 -1
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js +4 -4
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +1 -1
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +2 -2
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +3 -2
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +3 -3
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +1 -1
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +1 -1
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +2 -2
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/cache.d.ts +38 -43
- package/dist/cache/implementations/derivables/cache/cache.js +106 -101
- package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.d.ts +1 -1
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.js +3 -3
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +6 -8
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +5 -15
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +1 -1
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +48 -48
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache.test-suite.js +107 -107
- package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js +2 -1
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js.map +1 -1
- package/dist/collection/contracts/async-collection.contract.d.ts +43 -43
- package/dist/collection/contracts/collection.contract.d.ts +15 -1
- package/dist/collection/contracts/collection.contract.js +1 -3
- package/dist/collection/contracts/collection.contract.js.map +1 -1
- package/dist/collection/contracts/collection.errors.d.ts +4 -13
- package/dist/collection/contracts/collection.errors.js +4 -16
- package/dist/collection/contracts/collection.errors.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-validate-iterable.d.ts +6 -0
- package/dist/collection/implementations/async-iterable-collection/_shared/async-validate-iterable.js +3 -0
- package/dist/collection/implementations/async-iterable-collection/_shared/async-validate-iterable.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +40 -51
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +31 -37
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/collection/implementations/iterable-collection/_shared/validate-iterable.d.ts +3 -0
- package/dist/collection/implementations/iterable-collection/_shared/validate-iterable.js +6 -0
- package/dist/collection/implementations/iterable-collection/_shared/validate-iterable.js.map +1 -1
- package/dist/collection/implementations/iterable-collection/iterable-collection.d.ts +3 -3
- package/dist/collection/implementations/iterable-collection/iterable-collection.js +5 -2
- package/dist/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
- package/dist/collection/implementations/list-collection/list-collection.d.ts +3 -3
- package/dist/collection/implementations/list-collection/list-collection.js +5 -2
- package/dist/collection/implementations/list-collection/list-collection.js.map +1 -1
- package/dist/event-bus/contracts/event-bus.contract.d.ts +10 -10
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.d.ts +3 -6
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +7 -9
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +17 -24
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +32 -32
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +1 -3
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +4 -8
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +34 -32
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js.map +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +195 -190
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
- package/dist/hooks/_module-exports.d.ts +3 -0
- package/dist/hooks/_module-exports.js +4 -0
- package/dist/hooks/_module-exports.js.map +1 -0
- package/dist/{utilities/classes/hooks → hooks}/async-hooks.d.ts +15 -26
- package/dist/{utilities/classes/hooks → hooks}/async-hooks.js +4 -6
- package/dist/hooks/async-hooks.js.map +1 -0
- package/dist/{utilities/classes/hooks → hooks}/hooks.d.ts +11 -18
- package/dist/{utilities/classes/hooks → hooks}/hooks.js +4 -5
- package/dist/hooks/hooks.js.map +1 -0
- package/dist/{utilities/classes/hooks → hooks}/types.d.ts +2 -3
- package/dist/hooks/types.js +5 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/lock/contracts/_module-exports.d.ts +4 -2
- package/dist/lock/contracts/_module-exports.js +4 -2
- package/dist/lock/contracts/_module-exports.js.map +1 -1
- package/dist/lock/contracts/database-lock-adapter.contract.d.ts +24 -17
- package/dist/lock/contracts/lock-adapter.contract.d.ts +15 -24
- package/dist/lock/contracts/lock-adapter.contract.js +1 -10
- package/dist/lock/contracts/lock-adapter.contract.js.map +1 -1
- package/dist/lock/contracts/lock-provider.contract.d.ts +5 -5
- package/dist/lock/contracts/lock-state.contract.d.ts +52 -0
- package/dist/lock/contracts/lock-state.contract.js +14 -0
- package/dist/lock/contracts/lock-state.contract.js.map +1 -0
- package/dist/lock/contracts/lock.contract.d.ts +64 -55
- package/dist/lock/contracts/lock.errors.d.ts +13 -20
- package/dist/lock/contracts/lock.errors.js +19 -26
- package/dist/lock/contracts/lock.errors.js.map +1 -1
- package/dist/lock/contracts/lock.events.d.ts +21 -49
- package/dist/lock/contracts/lock.events.js +2 -3
- package/dist/lock/contracts/lock.events.js.map +1 -1
- package/dist/lock/contracts/types.d.ts +11 -0
- package/dist/lock/contracts/types.js +5 -0
- package/dist/lock/contracts/types.js.map +1 -0
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.d.ts +21 -19
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js +92 -61
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.d.ts +8 -5
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +33 -13
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.d.ts +7 -8
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +33 -20
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.d.ts +6 -5
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js +7 -5
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.d.ts +26 -8
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +61 -28
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.d.ts +6 -5
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js +33 -33
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.d.ts +2 -2
- package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js +4 -6
- package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +29 -39
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +31 -35
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +5 -8
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js +27 -23
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +38 -34
- package/dist/lock/implementations/derivables/lock-provider/lock.js +182 -257
- package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/resolve-database-lock-adapter.d.ts +9 -0
- package/dist/lock/implementations/derivables/lock-provider/resolve-database-lock-adapter.js +12 -0
- package/dist/lock/implementations/derivables/lock-provider/resolve-database-lock-adapter.js.map +1 -0
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +12 -13
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +7 -16
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js +310 -207
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.d.ts +1 -1
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js +376 -292
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +15 -5
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +3285 -2976
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
- package/dist/namespace/_module-exports.d.ts +1 -0
- package/dist/namespace/_module-exports.js +2 -0
- package/dist/namespace/_module-exports.js.map +1 -0
- package/dist/namespace/namespace.d.ts +87 -0
- package/dist/namespace/namespace.js +117 -0
- package/dist/namespace/namespace.js.map +1 -0
- package/dist/resilience/_module-exports.d.ts +2 -0
- package/dist/resilience/_module-exports.js +3 -0
- package/dist/resilience/_module-exports.js.map +1 -0
- package/dist/resilience/middlewares/_module.d.ts +5 -0
- package/dist/resilience/middlewares/_module.js +6 -0
- package/dist/resilience/middlewares/_module.js.map +1 -0
- package/dist/resilience/middlewares/dynamic/_module.d.ts +1 -0
- package/dist/resilience/middlewares/dynamic/_module.js +2 -0
- package/dist/resilience/middlewares/dynamic/_module.js.map +1 -0
- package/dist/{async → resilience}/middlewares/dynamic/dynamic.middleware.d.ts +6 -6
- package/dist/{async → resilience}/middlewares/dynamic/dynamic.middleware.js +5 -5
- package/dist/resilience/middlewares/dynamic/dynamic.middleware.js.map +1 -0
- package/dist/resilience/middlewares/fallback/_module.d.ts +2 -0
- package/dist/resilience/middlewares/fallback/_module.js +3 -0
- package/dist/resilience/middlewares/fallback/_module.js.map +1 -0
- package/dist/{async → resilience}/middlewares/fallback/fallback.middleware.d.ts +9 -9
- package/dist/{async → resilience}/middlewares/fallback/fallback.middleware.js +7 -6
- package/dist/resilience/middlewares/fallback/fallback.middleware.js.map +1 -0
- package/dist/{async → resilience}/middlewares/fallback/fallback.types.d.ts +7 -6
- package/dist/{async → resilience}/middlewares/fallback/fallback.types.js +1 -1
- package/dist/resilience/middlewares/fallback/fallback.types.js.map +1 -0
- package/dist/resilience/middlewares/observe/_module.d.ts +2 -0
- package/dist/resilience/middlewares/observe/_module.js +3 -0
- package/dist/resilience/middlewares/observe/_module.js.map +1 -0
- package/dist/{async → resilience}/middlewares/observe/observe.middleware.d.ts +13 -11
- package/dist/{async → resilience}/middlewares/observe/observe.middleware.js +14 -10
- package/dist/resilience/middlewares/observe/observe.middleware.js.map +1 -0
- package/dist/{async → resilience}/middlewares/observe/observe.types.d.ts +13 -12
- package/dist/resilience/middlewares/observe/observe.types.js +5 -0
- package/dist/resilience/middlewares/observe/observe.types.js.map +1 -0
- package/dist/resilience/middlewares/retry/_module.d.ts +2 -0
- package/dist/resilience/middlewares/retry/_module.js +3 -0
- package/dist/resilience/middlewares/retry/_module.js.map +1 -0
- package/dist/{async → resilience}/middlewares/retry/retry.middleware.d.ts +12 -9
- package/dist/{async → resilience}/middlewares/retry/retry.middleware.js +19 -15
- package/dist/resilience/middlewares/retry/retry.middleware.js.map +1 -0
- package/dist/{async → resilience}/middlewares/retry/retry.types.d.ts +14 -12
- package/dist/resilience/middlewares/retry/retry.types.js +7 -0
- package/dist/resilience/middlewares/retry/retry.types.js.map +1 -0
- package/dist/resilience/middlewares/timeout/_module.d.ts +2 -0
- package/dist/resilience/middlewares/timeout/_module.js +3 -0
- package/dist/resilience/middlewares/timeout/_module.js.map +1 -0
- package/dist/{async → resilience}/middlewares/timeout/timeout.middleware.d.ts +9 -7
- package/dist/{async → resilience}/middlewares/timeout/timeout.middleware.js +12 -11
- package/dist/resilience/middlewares/timeout/timeout.middleware.js.map +1 -0
- package/dist/{async → resilience}/middlewares/timeout/timeout.type.d.ts +10 -9
- package/dist/resilience/middlewares/timeout/timeout.type.js +5 -0
- package/dist/resilience/middlewares/timeout/timeout.type.js.map +1 -0
- package/dist/resilience/resilience.errors.d.ts +40 -0
- package/dist/resilience/resilience.errors.js +48 -0
- package/dist/resilience/resilience.errors.js.map +1 -0
- package/dist/resilience/utilities/_module.d.ts +2 -0
- package/dist/resilience/utilities/_module.js +3 -0
- package/dist/resilience/utilities/_module.js.map +1 -0
- package/dist/resilience/utilities/abort-and-fail/_module.d.ts +1 -0
- package/dist/resilience/utilities/abort-and-fail/_module.js +2 -0
- package/dist/resilience/utilities/abort-and-fail/_module.js.map +1 -0
- package/dist/resilience/utilities/abort-and-fail/abort-and-fail.d.ts +7 -0
- package/dist/resilience/utilities/abort-and-fail/abort-and-fail.js +51 -0
- package/dist/resilience/utilities/abort-and-fail/abort-and-fail.js.map +1 -0
- package/dist/resilience/utilities/timeout-and-fail/_module.d.ts +1 -0
- package/dist/resilience/utilities/timeout-and-fail/_module.js +2 -0
- package/dist/resilience/utilities/timeout-and-fail/_module.js.map +1 -0
- package/dist/resilience/utilities/timeout-and-fail/timeout-and-fail.d.ts +7 -0
- package/dist/resilience/utilities/timeout-and-fail/timeout-and-fail.js +23 -0
- package/dist/resilience/utilities/timeout-and-fail/timeout-and-fail.js.map +1 -0
- package/dist/semaphore/contracts/_module-exports.d.ts +9 -0
- package/dist/semaphore/contracts/_module-exports.js +10 -0
- package/dist/semaphore/contracts/_module-exports.js.map +1 -0
- package/dist/semaphore/contracts/database-semaphore-adapter.contract.d.ts +90 -0
- package/dist/semaphore/contracts/database-semaphore-adapter.contract.js +5 -0
- package/dist/semaphore/contracts/database-semaphore-adapter.contract.js.map +1 -0
- package/dist/semaphore/contracts/semaphore-adapter.contract.d.ts +61 -0
- package/dist/semaphore/contracts/semaphore-adapter.contract.js +5 -0
- package/dist/semaphore/contracts/semaphore-adapter.contract.js.map +1 -0
- package/dist/semaphore/contracts/semaphore-provider-factory.contract.d.ts +19 -0
- package/dist/semaphore/contracts/semaphore-provider-factory.contract.js +9 -0
- package/dist/semaphore/contracts/semaphore-provider-factory.contract.js.map +1 -0
- package/dist/semaphore/contracts/semaphore-provider.contract.d.ts +50 -0
- package/dist/semaphore/contracts/semaphore-provider.contract.js +5 -0
- package/dist/semaphore/contracts/semaphore-provider.contract.js.map +1 -0
- package/dist/semaphore/contracts/semaphore-state.contract.d.ts +70 -0
- package/dist/semaphore/contracts/semaphore-state.contract.js +15 -0
- package/dist/semaphore/contracts/semaphore-state.contract.js.map +1 -0
- package/dist/semaphore/contracts/semaphore.contract.d.ts +127 -0
- package/dist/semaphore/contracts/semaphore.contract.js +5 -0
- package/dist/semaphore/contracts/semaphore.contract.js.map +1 -0
- package/dist/semaphore/contracts/semaphore.errors.d.ts +52 -0
- package/dist/semaphore/contracts/semaphore.errors.js +63 -0
- package/dist/semaphore/contracts/semaphore.errors.js.map +1 -0
- package/dist/semaphore/contracts/semaphore.events.d.ts +101 -0
- package/dist/semaphore/contracts/semaphore.events.js +19 -0
- package/dist/semaphore/contracts/semaphore.events.js.map +1 -0
- package/dist/semaphore/contracts/types.d.ts +11 -0
- package/dist/semaphore/contracts/types.js +5 -0
- package/dist/semaphore/contracts/types.js.map +1 -0
- package/dist/semaphore/implementations/adapters/_module-exports.d.ts +5 -0
- package/dist/semaphore/implementations/adapters/_module-exports.js +6 -0
- package/dist/semaphore/implementations/adapters/_module-exports.js.map +1 -0
- package/dist/semaphore/implementations/adapters/kysely-semaphore-adapter/_module.d.ts +1 -0
- package/dist/semaphore/implementations/adapters/kysely-semaphore-adapter/_module.js +2 -0
- package/dist/semaphore/implementations/adapters/kysely-semaphore-adapter/_module.js.map +1 -0
- package/dist/semaphore/implementations/adapters/kysely-semaphore-adapter/kysely-semaphore-adapter.d.ts +97 -0
- package/dist/semaphore/implementations/adapters/kysely-semaphore-adapter/kysely-semaphore-adapter.js +313 -0
- package/dist/semaphore/implementations/adapters/kysely-semaphore-adapter/kysely-semaphore-adapter.js.map +1 -0
- package/dist/semaphore/implementations/adapters/memory-semaphore-adapter/_module.d.ts +1 -0
- package/dist/semaphore/implementations/adapters/memory-semaphore-adapter/_module.js +2 -0
- package/dist/semaphore/implementations/adapters/memory-semaphore-adapter/_module.js.map +1 -0
- package/dist/semaphore/implementations/adapters/memory-semaphore-adapter/memory-semaphore-adapter.d.ts +49 -0
- package/dist/semaphore/implementations/adapters/memory-semaphore-adapter/memory-semaphore-adapter.js +141 -0
- package/dist/semaphore/implementations/adapters/memory-semaphore-adapter/memory-semaphore-adapter.js.map +1 -0
- package/dist/semaphore/implementations/adapters/mongodb-semaphore-adapter/_module.d.ts +1 -0
- package/dist/semaphore/implementations/adapters/mongodb-semaphore-adapter/_module.js +2 -0
- package/dist/semaphore/implementations/adapters/mongodb-semaphore-adapter/_module.js.map +1 -0
- package/dist/semaphore/implementations/adapters/mongodb-semaphore-adapter/mongodb-semaphore-adapter.d.ts +80 -0
- package/dist/semaphore/implementations/adapters/mongodb-semaphore-adapter/mongodb-semaphore-adapter.js +390 -0
- package/dist/semaphore/implementations/adapters/mongodb-semaphore-adapter/mongodb-semaphore-adapter.js.map +1 -0
- package/dist/semaphore/implementations/adapters/no-op-semaphore-adapter/_module.d.ts +1 -0
- package/dist/semaphore/implementations/adapters/no-op-semaphore-adapter/_module.js +2 -0
- package/dist/semaphore/implementations/adapters/no-op-semaphore-adapter/_module.js.map +1 -0
- package/dist/semaphore/implementations/adapters/no-op-semaphore-adapter/no-op-semaphore-adapter.d.ts +18 -0
- package/dist/semaphore/implementations/adapters/no-op-semaphore-adapter/no-op-semaphore-adapter.js +30 -0
- package/dist/semaphore/implementations/adapters/no-op-semaphore-adapter/no-op-semaphore-adapter.js.map +1 -0
- package/dist/semaphore/implementations/adapters/redis-semaphore-adapter/_module.d.ts +1 -0
- package/dist/semaphore/implementations/adapters/redis-semaphore-adapter/_module.js +2 -0
- package/dist/semaphore/implementations/adapters/redis-semaphore-adapter/_module.js.map +1 -0
- package/dist/semaphore/implementations/adapters/redis-semaphore-adapter/redis-semaphore-adapter.d.ts +48 -0
- package/dist/semaphore/implementations/adapters/redis-semaphore-adapter/redis-semaphore-adapter.js +338 -0
- package/dist/semaphore/implementations/adapters/redis-semaphore-adapter/redis-semaphore-adapter.js.map +1 -0
- package/dist/semaphore/implementations/derivables/_module-exports.d.ts +2 -0
- package/dist/semaphore/implementations/derivables/_module-exports.js +3 -0
- package/dist/semaphore/implementations/derivables/_module-exports.js.map +1 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/_module.d.ts +1 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/_module.js +2 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/_module.js.map +1 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/database-semaphore-adapter.d.ts +17 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/database-semaphore-adapter.js +74 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/database-semaphore-adapter.js.map +1 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/is-database-semaphore-adapter.d.ts +8 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/is-database-semaphore-adapter.js +15 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/is-database-semaphore-adapter.js.map +1 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/resolve-database-semaphore-adapter.d.ts +8 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/resolve-database-semaphore-adapter.js +15 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/resolve-database-semaphore-adapter.js.map +1 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore-provider.d.ts +149 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore-provider.js +135 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore-provider.js.map +1 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore-serde-transformer.d.ts +41 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore-serde-transformer.js +77 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore-serde-transformer.js.map +1 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore.d.ts +83 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore.js +336 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider/semaphore.js.map +1 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider-factory/_module.d.ts +1 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider-factory/_module.js +2 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider-factory/_module.js.map +1 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider-factory/semaphore-provider-factory.d.ts +40 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider-factory/semaphore-provider-factory.js +67 -0
- package/dist/semaphore/implementations/derivables/semaphore-provider-factory/semaphore-provider-factory.js.map +1 -0
- package/dist/semaphore/implementations/test-utilities/_module-exports.d.ts +3 -0
- package/dist/semaphore/implementations/test-utilities/_module-exports.js +4 -0
- package/dist/semaphore/implementations/test-utilities/_module-exports.js.map +1 -0
- package/dist/semaphore/implementations/test-utilities/database-semaphore-adapter.test-suite.d.ts +59 -0
- package/dist/semaphore/implementations/test-utilities/database-semaphore-adapter.test-suite.js +536 -0
- package/dist/semaphore/implementations/test-utilities/database-semaphore-adapter.test-suite.js.map +1 -0
- package/dist/semaphore/implementations/test-utilities/semaphore-adapter.test-suite.d.ts +59 -0
- package/dist/semaphore/implementations/test-utilities/semaphore-adapter.test-suite.js +961 -0
- package/dist/semaphore/implementations/test-utilities/semaphore-adapter.test-suite.js.map +1 -0
- package/dist/semaphore/implementations/test-utilities/semaphore-provider.test-suite.d.ts +67 -0
- package/dist/semaphore/implementations/test-utilities/semaphore-provider.test-suite.js +4981 -0
- package/dist/semaphore/implementations/test-utilities/semaphore-provider.test-suite.js.map +1 -0
- package/dist/serde/contracts/_module-exports.d.ts +0 -1
- package/dist/serde/contracts/_module-exports.js +0 -1
- package/dist/serde/contracts/_module-exports.js.map +1 -1
- package/dist/serde/contracts/flexible-serde.contract.d.ts +21 -5
- package/dist/serde/contracts/serde.errors.d.ts +14 -11
- package/dist/serde/contracts/serde.errors.js +15 -14
- package/dist/serde/contracts/serde.errors.js.map +1 -1
- package/dist/serde/implementations/adapters/_module-exports.d.ts +0 -3
- package/dist/serde/implementations/adapters/_module-exports.js +0 -3
- package/dist/serde/implementations/adapters/_module-exports.js.map +1 -1
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +6 -0
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js.map +1 -1
- package/dist/serde/implementations/derivables/serde-transformers.d.ts +38 -30
- package/dist/serde/implementations/derivables/serde-transformers.js +62 -20
- package/dist/serde/implementations/derivables/serde-transformers.js.map +1 -1
- package/dist/serde/implementations/derivables/serde.d.ts +12 -3
- package/dist/serde/implementations/derivables/serde.js +5 -2
- package/dist/serde/implementations/derivables/serde.js.map +1 -1
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js +85 -1
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js.map +1 -1
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +85 -1
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js.map +1 -1
- package/dist/shared-lock/contracts/_module-exports.d.ts +10 -0
- package/dist/shared-lock/contracts/_module-exports.js +11 -0
- package/dist/shared-lock/contracts/_module-exports.js.map +1 -0
- package/dist/shared-lock/contracts/database-shared-lock-adapter.contract.d.ts +145 -0
- package/dist/shared-lock/contracts/database-shared-lock-adapter.contract.js +5 -0
- package/dist/shared-lock/contracts/database-shared-lock-adapter.contract.js.map +1 -0
- package/dist/shared-lock/contracts/shared-lock-adapter.contract.d.ts +96 -0
- package/dist/shared-lock/contracts/shared-lock-adapter.contract.js +5 -0
- package/dist/shared-lock/contracts/shared-lock-adapter.contract.js.map +1 -0
- package/dist/shared-lock/contracts/shared-lock-provider-factory.contract.d.ts +19 -0
- package/dist/shared-lock/contracts/shared-lock-provider-factory.contract.js +9 -0
- package/dist/shared-lock/contracts/shared-lock-provider-factory.contract.js.map +1 -0
- package/dist/shared-lock/contracts/shared-lock-provider.contract.d.ts +53 -0
- package/dist/shared-lock/contracts/shared-lock-provider.contract.js +5 -0
- package/dist/shared-lock/contracts/shared-lock-provider.contract.js.map +1 -0
- package/dist/shared-lock/contracts/shared-lock-state.contract.d.ts +133 -0
- package/dist/shared-lock/contracts/shared-lock-state.contract.js +33 -0
- package/dist/shared-lock/contracts/shared-lock-state.contract.js.map +1 -0
- package/dist/shared-lock/contracts/shared-lock.contract.d.ts +222 -0
- package/dist/shared-lock/contracts/shared-lock.contract.js +13 -0
- package/dist/shared-lock/contracts/shared-lock.contract.js.map +1 -0
- package/dist/shared-lock/contracts/shared-lock.errors.d.ts +124 -0
- package/dist/shared-lock/contracts/shared-lock.errors.js +136 -0
- package/dist/shared-lock/contracts/shared-lock.errors.js.map +1 -0
- package/dist/shared-lock/contracts/shared-lock.events.d.ts +205 -0
- package/dist/shared-lock/contracts/shared-lock.events.js +43 -0
- package/dist/shared-lock/contracts/shared-lock.events.js.map +1 -0
- package/dist/shared-lock/contracts/types.d.ts +10 -0
- package/dist/shared-lock/contracts/types.js +5 -0
- package/dist/shared-lock/contracts/types.js.map +1 -0
- package/dist/shared-lock/implementations/adapters/_module-exports.d.ts +5 -0
- package/dist/shared-lock/implementations/adapters/_module-exports.js +6 -0
- package/dist/shared-lock/implementations/adapters/_module-exports.js.map +1 -0
- package/dist/shared-lock/implementations/adapters/kysely-shared-lock-adapter/_module.d.ts +1 -0
- package/dist/shared-lock/implementations/adapters/kysely-shared-lock-adapter/_module.js +2 -0
- package/dist/shared-lock/implementations/adapters/kysely-shared-lock-adapter/_module.js.map +1 -0
- package/dist/shared-lock/implementations/adapters/kysely-shared-lock-adapter/kysely-shared-lock-adapter.d.ts +114 -0
- package/dist/shared-lock/implementations/adapters/kysely-shared-lock-adapter/kysely-shared-lock-adapter.js +496 -0
- package/dist/shared-lock/implementations/adapters/kysely-shared-lock-adapter/kysely-shared-lock-adapter.js.map +1 -0
- package/dist/shared-lock/implementations/adapters/memory-shared-lock-adapter/_module.d.ts +1 -0
- package/dist/shared-lock/implementations/adapters/memory-shared-lock-adapter/_module.js +2 -0
- package/dist/shared-lock/implementations/adapters/memory-shared-lock-adapter/_module.js.map +1 -0
- package/dist/shared-lock/implementations/adapters/memory-shared-lock-adapter/memory-shared-lock-adapter.d.ts +79 -0
- package/dist/shared-lock/implementations/adapters/memory-shared-lock-adapter/memory-shared-lock-adapter.js +347 -0
- package/dist/shared-lock/implementations/adapters/memory-shared-lock-adapter/memory-shared-lock-adapter.js.map +1 -0
- package/dist/shared-lock/implementations/adapters/mongodb-shared-lock-adapter/_module.d.ts +1 -0
- package/dist/shared-lock/implementations/adapters/mongodb-shared-lock-adapter/_module.js +2 -0
- package/dist/shared-lock/implementations/adapters/mongodb-shared-lock-adapter/_module.js.map +1 -0
- package/dist/shared-lock/implementations/adapters/mongodb-shared-lock-adapter/mongodb-shared-lock-adapter.d.ts +112 -0
- package/dist/shared-lock/implementations/adapters/mongodb-shared-lock-adapter/mongodb-shared-lock-adapter.js +805 -0
- package/dist/shared-lock/implementations/adapters/mongodb-shared-lock-adapter/mongodb-shared-lock-adapter.js.map +1 -0
- package/dist/shared-lock/implementations/adapters/no-op-shared-lock-adapter/_module.d.ts +1 -0
- package/dist/shared-lock/implementations/adapters/no-op-shared-lock-adapter/_module.js +2 -0
- package/dist/shared-lock/implementations/adapters/no-op-shared-lock-adapter/_module.js.map +1 -0
- package/dist/shared-lock/implementations/adapters/no-op-shared-lock-adapter/no-op-shared-lock-adapter.d.ts +23 -0
- package/dist/shared-lock/implementations/adapters/no-op-shared-lock-adapter/no-op-shared-lock-adapter.js +42 -0
- package/dist/shared-lock/implementations/adapters/no-op-shared-lock-adapter/no-op-shared-lock-adapter.js.map +1 -0
- package/dist/shared-lock/implementations/adapters/redis-shared-lock-adapter/_module.d.ts +1 -0
- package/dist/shared-lock/implementations/adapters/redis-shared-lock-adapter/_module.js +2 -0
- package/dist/shared-lock/implementations/adapters/redis-shared-lock-adapter/_module.js.map +1 -0
- package/dist/shared-lock/implementations/adapters/redis-shared-lock-adapter/redis-shared-lock-adapter.d.ts +79 -0
- package/dist/shared-lock/implementations/adapters/redis-shared-lock-adapter/redis-shared-lock-adapter.js +630 -0
- package/dist/shared-lock/implementations/adapters/redis-shared-lock-adapter/redis-shared-lock-adapter.js.map +1 -0
- package/dist/shared-lock/implementations/derivables/_module-exports.d.ts +2 -0
- package/dist/shared-lock/implementations/derivables/_module-exports.js +3 -0
- package/dist/shared-lock/implementations/derivables/_module-exports.js.map +1 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/_module.d.ts +1 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/_module.js +2 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/_module.js.map +1 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/database-shared-lock-adapter.d.ts +27 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/database-shared-lock-adapter.js +208 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/database-shared-lock-adapter.js.map +1 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/is-database-shared-lock-adapter.d.ts +8 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/is-database-shared-lock-adapter.js +12 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/is-database-shared-lock-adapter.js.map +1 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/resolve-database-shared-lock-adapter.d.ts +8 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/resolve-database-shared-lock-adapter.js +15 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/resolve-database-shared-lock-adapter.js.map +1 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock-provider.d.ts +190 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock-provider.js +177 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock-provider.js.map +1 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock-serde-transformer.d.ts +41 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock-serde-transformer.js +77 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock-serde-transformer.js.map +1 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock.d.ts +95 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock.js +542 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider/shared-lock.js.map +1 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider-factory/_module.d.ts +1 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider-factory/_module.js +2 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider-factory/_module.js.map +1 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider-factory/shared-lock-provider-factory.d.ts +97 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider-factory/shared-lock-provider-factory.js +128 -0
- package/dist/shared-lock/implementations/derivables/shared-lock-provider-factory/shared-lock-provider-factory.js.map +1 -0
- package/dist/shared-lock/implementations/test-utilities/_module-exports.d.ts +3 -0
- package/dist/shared-lock/implementations/test-utilities/_module-exports.js +4 -0
- package/dist/shared-lock/implementations/test-utilities/_module-exports.js.map +1 -0
- package/dist/shared-lock/implementations/test-utilities/database-shared-lock-adapter.test-suite.d.ts +59 -0
- package/dist/shared-lock/implementations/test-utilities/database-shared-lock-adapter.test-suite.js +944 -0
- package/dist/shared-lock/implementations/test-utilities/database-shared-lock-adapter.test-suite.js.map +1 -0
- package/dist/shared-lock/implementations/test-utilities/shared-lock-adapter.test-suite.d.ts +59 -0
- package/dist/shared-lock/implementations/test-utilities/shared-lock-adapter.test-suite.js +1921 -0
- package/dist/shared-lock/implementations/test-utilities/shared-lock-adapter.test-suite.js.map +1 -0
- package/dist/shared-lock/implementations/test-utilities/shared-lock-provider.test-suite.d.ts +67 -0
- package/dist/shared-lock/implementations/test-utilities/shared-lock-provider.test-suite.js +9833 -0
- package/dist/shared-lock/implementations/test-utilities/shared-lock-provider.test-suite.js.map +1 -0
- package/dist/task/_module-exports.d.ts +1 -0
- package/dist/task/_module-exports.js +2 -0
- package/dist/task/_module-exports.js.map +1 -0
- package/dist/{async/utilities/abort-and-fail → task}/abort-and-fail.d.ts +1 -1
- package/dist/{async/utilities/abort-and-fail → task}/abort-and-fail.js +1 -1
- package/dist/task/abort-and-fail.js.map +1 -0
- package/dist/task/task.d.ts +194 -0
- package/dist/task/task.js +212 -0
- package/dist/task/task.js.map +1 -0
- package/dist/time-span/contracts/_module-exports.d.ts +1 -0
- package/dist/time-span/contracts/_module-exports.js +2 -0
- package/dist/time-span/contracts/_module-exports.js.map +1 -0
- package/dist/time-span/contracts/time-span.contract.d.ts +19 -0
- package/dist/time-span/contracts/time-span.contract.js +10 -0
- package/dist/time-span/contracts/time-span.contract.js.map +1 -0
- package/dist/time-span/implementations/_module-exports.d.ts +1 -0
- package/dist/time-span/implementations/_module-exports.js +2 -0
- package/dist/time-span/implementations/_module-exports.js.map +1 -0
- package/dist/{utilities/classes/time-span → time-span/implementations}/time-span.d.ts +49 -11
- package/dist/{utilities/classes/time-span → time-span/implementations}/time-span.js +33 -11
- package/dist/time-span/implementations/time-span.js.map +1 -0
- package/dist/utilities/classes/_module.d.ts +0 -3
- package/dist/utilities/classes/_module.js +0 -3
- package/dist/utilities/classes/_module.js.map +1 -1
- package/dist/utilities/contracts/_module.d.ts +1 -1
- package/dist/utilities/contracts/_module.js +1 -1
- package/dist/utilities/contracts/_module.js.map +1 -1
- package/dist/utilities/contracts/comparable.contract.d.ts +49 -0
- package/dist/utilities/contracts/comparable.contract.js +5 -0
- package/dist/utilities/contracts/comparable.contract.js.map +1 -0
- package/dist/utilities/functions/is-standard-schema.d.ts +6 -0
- package/dist/utilities/functions/is-standard-schema.js +6 -0
- package/dist/utilities/functions/is-standard-schema.js.map +1 -1
- package/dist/utilities/functions/lazy.d.ts +3 -3
- package/dist/utilities/functions/lazy.js +3 -3
- package/dist/utilities/functions/lazy.js.map +1 -1
- package/dist/utilities/functions/option.d.ts +3 -0
- package/dist/utilities/functions/option.js +3 -0
- package/dist/utilities/functions/option.js.map +1 -1
- package/dist/utilities/functions/validate.d.ts +5 -0
- package/dist/utilities/functions/validate.js +5 -0
- package/dist/utilities/functions/validate.js.map +1 -1
- package/dist/utilities/types/any-class.type.d.ts +6 -0
- package/dist/utilities/types/any-class.type.js +3 -0
- package/dist/utilities/types/any-class.type.js.map +1 -1
- package/package.json +67 -5
- package/dist/async/_module-exports.d.ts +0 -4
- package/dist/async/_module-exports.js +0 -5
- package/dist/async/_module-exports.js.map +0 -1
- package/dist/async/async.errors.d.ts +0 -47
- package/dist/async/async.errors.js +0 -61
- package/dist/async/async.errors.js.map +0 -1
- package/dist/async/backof-policies/_module.d.ts +0 -5
- package/dist/async/backof-policies/_module.js +0 -6
- package/dist/async/backof-policies/_module.js.map +0 -1
- package/dist/async/backof-policies/_shared.js.map +0 -1
- package/dist/async/backof-policies/constant-backoff-policy/_module.d.ts +0 -1
- package/dist/async/backof-policies/constant-backoff-policy/_module.js +0 -2
- package/dist/async/backof-policies/constant-backoff-policy/_module.js.map +0 -1
- package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js.map +0 -1
- package/dist/async/backof-policies/exponential-backoff-policy/_module.d.ts +0 -1
- package/dist/async/backof-policies/exponential-backoff-policy/_module.js +0 -2
- package/dist/async/backof-policies/exponential-backoff-policy/_module.js.map +0 -1
- package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +0 -35
- package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js.map +0 -1
- package/dist/async/backof-policies/linear-backoff-policy/_module.d.ts +0 -1
- package/dist/async/backof-policies/linear-backoff-policy/_module.js +0 -2
- package/dist/async/backof-policies/linear-backoff-policy/_module.js.map +0 -1
- package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +0 -35
- package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js.map +0 -1
- package/dist/async/backof-policies/polynomial-backoff-policy/_module.d.ts +0 -1
- package/dist/async/backof-policies/polynomial-backoff-policy/_module.js +0 -2
- package/dist/async/backof-policies/polynomial-backoff-policy/_module.js.map +0 -1
- package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +0 -35
- package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js.map +0 -1
- package/dist/async/middlewares/_module.d.ts +0 -7
- package/dist/async/middlewares/_module.js +0 -8
- package/dist/async/middlewares/_module.js.map +0 -1
- package/dist/async/middlewares/bulkhead/_module.d.ts +0 -1
- package/dist/async/middlewares/bulkhead/_module.js +0 -2
- package/dist/async/middlewares/bulkhead/_module.js.map +0 -1
- package/dist/async/middlewares/bulkhead/bulkhead.middleware.d.ts +0 -80
- package/dist/async/middlewares/bulkhead/bulkhead.middleware.js +0 -46
- package/dist/async/middlewares/bulkhead/bulkhead.middleware.js.map +0 -1
- package/dist/async/middlewares/dynamic/_module.d.ts +0 -1
- package/dist/async/middlewares/dynamic/_module.js +0 -2
- package/dist/async/middlewares/dynamic/_module.js.map +0 -1
- package/dist/async/middlewares/dynamic/dynamic.middleware.js.map +0 -1
- package/dist/async/middlewares/fallback/_module.d.ts +0 -2
- package/dist/async/middlewares/fallback/_module.js +0 -3
- package/dist/async/middlewares/fallback/_module.js.map +0 -1
- package/dist/async/middlewares/fallback/fallback.middleware.js.map +0 -1
- package/dist/async/middlewares/fallback/fallback.types.js.map +0 -1
- package/dist/async/middlewares/hedging/_module.d.ts +0 -2
- package/dist/async/middlewares/hedging/_module.js +0 -3
- package/dist/async/middlewares/hedging/_module.js.map +0 -1
- package/dist/async/middlewares/hedging/hedging.types.d.ts +0 -121
- package/dist/async/middlewares/hedging/hedging.types.js +0 -6
- package/dist/async/middlewares/hedging/hedging.types.js.map +0 -1
- package/dist/async/middlewares/hedging/sequential-hedging.middleware.d.ts +0 -51
- package/dist/async/middlewares/hedging/sequential-hedging.middleware.js +0 -133
- package/dist/async/middlewares/hedging/sequential-hedging.middleware.js.map +0 -1
- package/dist/async/middlewares/observe/_module.d.ts +0 -2
- package/dist/async/middlewares/observe/_module.js +0 -3
- package/dist/async/middlewares/observe/_module.js.map +0 -1
- package/dist/async/middlewares/observe/observe.middleware.js.map +0 -1
- package/dist/async/middlewares/observe/observe.types.js +0 -6
- package/dist/async/middlewares/observe/observe.types.js.map +0 -1
- package/dist/async/middlewares/retry/_module.d.ts +0 -2
- package/dist/async/middlewares/retry/_module.js +0 -3
- package/dist/async/middlewares/retry/_module.js.map +0 -1
- package/dist/async/middlewares/retry/retry.middleware.js.map +0 -1
- package/dist/async/middlewares/retry/retry.types.js +0 -7
- package/dist/async/middlewares/retry/retry.types.js.map +0 -1
- package/dist/async/middlewares/timeout/_module.d.ts +0 -2
- package/dist/async/middlewares/timeout/_module.js +0 -3
- package/dist/async/middlewares/timeout/_module.js.map +0 -1
- package/dist/async/middlewares/timeout/timeout.middleware.js.map +0 -1
- package/dist/async/middlewares/timeout/timeout.type.js +0 -6
- package/dist/async/middlewares/timeout/timeout.type.js.map +0 -1
- package/dist/async/utilities/_module.d.ts +0 -4
- package/dist/async/utilities/_module.js +0 -5
- package/dist/async/utilities/_module.js.map +0 -1
- package/dist/async/utilities/abort-and-fail/_module.d.ts +0 -1
- package/dist/async/utilities/abort-and-fail/_module.js +0 -2
- package/dist/async/utilities/abort-and-fail/_module.js.map +0 -1
- package/dist/async/utilities/abort-and-fail/abort-and-fail.js.map +0 -1
- package/dist/async/utilities/lazy-promise/_module.d.ts +0 -1
- package/dist/async/utilities/lazy-promise/_module.js +0 -2
- package/dist/async/utilities/lazy-promise/_module.js.map +0 -1
- package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +0 -153
- package/dist/async/utilities/lazy-promise/lazy-promise.js +0 -176
- package/dist/async/utilities/lazy-promise/lazy-promise.js.map +0 -1
- package/dist/async/utilities/promise-queue/_module.d.ts +0 -1
- package/dist/async/utilities/promise-queue/_module.js +0 -2
- package/dist/async/utilities/promise-queue/_module.js.map +0 -1
- package/dist/async/utilities/promise-queue/promise-queue.d.ts +0 -32
- package/dist/async/utilities/promise-queue/promise-queue.js +0 -118
- package/dist/async/utilities/promise-queue/promise-queue.js.map +0 -1
- package/dist/async/utilities/timeout-and-fail/_module.d.ts +0 -1
- package/dist/async/utilities/timeout-and-fail/_module.js +0 -2
- package/dist/async/utilities/timeout-and-fail/_module.js.map +0 -1
- package/dist/async/utilities/timeout-and-fail/timeout-and-fail.d.ts +0 -7
- package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js +0 -22
- package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js.map +0 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-state.d.ts +0 -40
- package/dist/lock/implementations/derivables/lock-provider/lock-state.js +0 -60
- package/dist/lock/implementations/derivables/lock-provider/lock-state.js.map +0 -1
- package/dist/serde/contracts/serializable.contract.d.ts +0 -12
- package/dist/serde/contracts/serializable.contract.js +0 -5
- package/dist/serde/contracts/serializable.contract.js.map +0 -1
- package/dist/serde/implementations/adapters/mongodb-serde/_module.d.ts +0 -1
- package/dist/serde/implementations/adapters/mongodb-serde/_module.js +0 -2
- package/dist/serde/implementations/adapters/mongodb-serde/_module.js.map +0 -1
- package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.d.ts +0 -13
- package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js +0 -38
- package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js.map +0 -1
- package/dist/serde/implementations/adapters/redis-serde/_module.d.ts +0 -1
- package/dist/serde/implementations/adapters/redis-serde/_module.js +0 -2
- package/dist/serde/implementations/adapters/redis-serde/_module.js.map +0 -1
- package/dist/serde/implementations/adapters/redis-serde/redis-serde.d.ts +0 -13
- package/dist/serde/implementations/adapters/redis-serde/redis-serde.js +0 -39
- package/dist/serde/implementations/adapters/redis-serde/redis-serde.js.map +0 -1
- package/dist/serde/implementations/adapters/sql-serde/_module.d.ts +0 -1
- package/dist/serde/implementations/adapters/sql-serde/_module.js +0 -2
- package/dist/serde/implementations/adapters/sql-serde/_module.js.map +0 -1
- package/dist/serde/implementations/adapters/sql-serde/sql-serde.d.ts +0 -13
- package/dist/serde/implementations/adapters/sql-serde/sql-serde.js +0 -39
- package/dist/serde/implementations/adapters/sql-serde/sql-serde.js.map +0 -1
- package/dist/utilities/classes/hooks/_module.d.ts +0 -3
- package/dist/utilities/classes/hooks/_module.js +0 -4
- package/dist/utilities/classes/hooks/_module.js.map +0 -1
- package/dist/utilities/classes/hooks/async-hooks.js.map +0 -1
- package/dist/utilities/classes/hooks/hooks.js.map +0 -1
- package/dist/utilities/classes/hooks/types.js +0 -5
- package/dist/utilities/classes/hooks/types.js.map +0 -1
- package/dist/utilities/classes/namespace/_module.d.ts +0 -1
- package/dist/utilities/classes/namespace/_module.js +0 -2
- package/dist/utilities/classes/namespace/_module.js.map +0 -1
- package/dist/utilities/classes/namespace/namespace.d.ts +0 -85
- package/dist/utilities/classes/namespace/namespace.js +0 -125
- package/dist/utilities/classes/namespace/namespace.js.map +0 -1
- package/dist/utilities/classes/time-span/_module.d.ts +0 -1
- package/dist/utilities/classes/time-span/_module.js +0 -2
- package/dist/utilities/classes/time-span/_module.js.map +0 -1
- package/dist/utilities/classes/time-span/time-span.js.map +0 -1
- package/dist/utilities/contracts/serialized-error.contract.d.ts +0 -13
- package/dist/utilities/contracts/serialized-error.contract.js +0 -5
- package/dist/utilities/contracts/serialized-error.contract.js.map +0 -1
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module SharedLock
|
|
3
|
+
*/
|
|
4
|
+
import { MysqlAdapter } from "kysely";
|
|
5
|
+
import {} from "../../../../utilities/_module-exports.js";
|
|
6
|
+
import { TimeSpan } from "../../../../time-span/implementations/_module-exports.js";
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
class DatabaseReaderSemaphoreTransaction {
|
|
11
|
+
kysely;
|
|
12
|
+
isMysql;
|
|
13
|
+
constructor(kysely) {
|
|
14
|
+
this.kysely = kysely;
|
|
15
|
+
this.isMysql =
|
|
16
|
+
this.kysely.getExecutor().adapter instanceof MysqlAdapter;
|
|
17
|
+
}
|
|
18
|
+
async findSemaphore(key) {
|
|
19
|
+
const row = await this.kysely
|
|
20
|
+
.selectFrom("readerSemaphore")
|
|
21
|
+
.where("readerSemaphore.key", "=", key)
|
|
22
|
+
.select("limit")
|
|
23
|
+
.executeTakeFirst();
|
|
24
|
+
if (row === undefined) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return row;
|
|
28
|
+
}
|
|
29
|
+
async findSlots(key) {
|
|
30
|
+
const rows = await this.kysely
|
|
31
|
+
.selectFrom("readerSemaphoreSlot")
|
|
32
|
+
.where("readerSemaphoreSlot.key", "=", key)
|
|
33
|
+
.select([
|
|
34
|
+
"readerSemaphoreSlot.id",
|
|
35
|
+
"readerSemaphoreSlot.expiration",
|
|
36
|
+
])
|
|
37
|
+
.execute();
|
|
38
|
+
return rows.map((row) => {
|
|
39
|
+
if (row.expiration === null) {
|
|
40
|
+
return {
|
|
41
|
+
id: row.id,
|
|
42
|
+
expiration: null,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
id: row.id,
|
|
47
|
+
expiration: new Date(Number(row.expiration)),
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async upsertSemaphore(key, limit) {
|
|
52
|
+
await this.kysely
|
|
53
|
+
.insertInto("readerSemaphore")
|
|
54
|
+
.values({ key, limit })
|
|
55
|
+
.$if(!this.isMysql, (eb) => eb.onConflict((eb) => eb.column("key").doUpdateSet({
|
|
56
|
+
key,
|
|
57
|
+
limit,
|
|
58
|
+
})))
|
|
59
|
+
.$if(this.isMysql, (eb) => eb.onDuplicateKeyUpdate({
|
|
60
|
+
key,
|
|
61
|
+
limit,
|
|
62
|
+
}))
|
|
63
|
+
.execute();
|
|
64
|
+
}
|
|
65
|
+
async upsertSlot(key, lockId, expiration) {
|
|
66
|
+
const expirationAsMs = expiration?.getTime() ?? null;
|
|
67
|
+
await this.kysely
|
|
68
|
+
.insertInto("readerSemaphoreSlot")
|
|
69
|
+
.values({
|
|
70
|
+
key,
|
|
71
|
+
id: lockId,
|
|
72
|
+
expiration: expirationAsMs,
|
|
73
|
+
})
|
|
74
|
+
.$if(!this.isMysql, (eb) => eb.onConflict((eb) => eb.column("id").doUpdateSet({
|
|
75
|
+
key,
|
|
76
|
+
id: lockId,
|
|
77
|
+
expiration: expirationAsMs,
|
|
78
|
+
})))
|
|
79
|
+
.$if(this.isMysql, (eb) => eb.onDuplicateKeyUpdate({
|
|
80
|
+
key,
|
|
81
|
+
id: lockId,
|
|
82
|
+
expiration: expirationAsMs,
|
|
83
|
+
}))
|
|
84
|
+
.execute();
|
|
85
|
+
}
|
|
86
|
+
async removeSlot(key, slotId) {
|
|
87
|
+
let row;
|
|
88
|
+
if (this.isMysql) {
|
|
89
|
+
row = await this.kysely
|
|
90
|
+
.selectFrom("readerSemaphoreSlot")
|
|
91
|
+
.select("readerSemaphoreSlot.expiration")
|
|
92
|
+
.where("readerSemaphoreSlot.key", "=", key)
|
|
93
|
+
.where("readerSemaphoreSlot.id", "=", slotId)
|
|
94
|
+
.executeTakeFirst();
|
|
95
|
+
await this.kysely
|
|
96
|
+
.deleteFrom("readerSemaphoreSlot")
|
|
97
|
+
.where("readerSemaphoreSlot.key", "=", key)
|
|
98
|
+
.where("readerSemaphoreSlot.id", "=", slotId)
|
|
99
|
+
.executeTakeFirst();
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
row = await this.kysely
|
|
103
|
+
.deleteFrom("readerSemaphoreSlot")
|
|
104
|
+
.where("readerSemaphoreSlot.key", "=", key)
|
|
105
|
+
.where("readerSemaphoreSlot.id", "=", slotId)
|
|
106
|
+
.returning("readerSemaphoreSlot.expiration")
|
|
107
|
+
.executeTakeFirst();
|
|
108
|
+
}
|
|
109
|
+
if (row === undefined) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
if (row.expiration === null) {
|
|
113
|
+
return {
|
|
114
|
+
expiration: null,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
expiration: new Date(Number(row.expiration)),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
async removeAllSlots(key) {
|
|
122
|
+
let rows;
|
|
123
|
+
if (this.isMysql) {
|
|
124
|
+
rows = await this.kysely
|
|
125
|
+
.selectFrom("readerSemaphoreSlot")
|
|
126
|
+
.where("readerSemaphoreSlot.key", "=", key)
|
|
127
|
+
.select("readerSemaphoreSlot.expiration")
|
|
128
|
+
.execute();
|
|
129
|
+
await this.kysely
|
|
130
|
+
.deleteFrom("readerSemaphoreSlot")
|
|
131
|
+
.where("readerSemaphoreSlot.key", "=", key)
|
|
132
|
+
.execute();
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
rows = await this.kysely
|
|
136
|
+
.deleteFrom("readerSemaphoreSlot")
|
|
137
|
+
.where("readerSemaphoreSlot.key", "=", key)
|
|
138
|
+
.returning("readerSemaphoreSlot.expiration")
|
|
139
|
+
.execute();
|
|
140
|
+
}
|
|
141
|
+
return rows.map((row) => {
|
|
142
|
+
if (row.expiration === null) {
|
|
143
|
+
return {
|
|
144
|
+
expiration: null,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
expiration: new Date(Number(row.expiration)),
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
async updateExpiration(key, slotId, expiration) {
|
|
153
|
+
const result = await this.kysely
|
|
154
|
+
.updateTable("readerSemaphoreSlot")
|
|
155
|
+
.where("readerSemaphoreSlot.key", "=", key)
|
|
156
|
+
.where("readerSemaphoreSlot.id", "=", slotId)
|
|
157
|
+
.where((eb) => eb.and([
|
|
158
|
+
eb("readerSemaphoreSlot.expiration", "is not", null),
|
|
159
|
+
eb("readerSemaphoreSlot.expiration", ">", Date.now()),
|
|
160
|
+
]))
|
|
161
|
+
.set({
|
|
162
|
+
expiration: expiration.getTime(),
|
|
163
|
+
})
|
|
164
|
+
.executeTakeFirst();
|
|
165
|
+
return Number(result.numUpdatedRows);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* @internal
|
|
170
|
+
*/
|
|
171
|
+
class DatabaseWriterLockTransaction {
|
|
172
|
+
kysely;
|
|
173
|
+
isMysql;
|
|
174
|
+
constructor(kysely) {
|
|
175
|
+
this.kysely = kysely;
|
|
176
|
+
this.isMysql =
|
|
177
|
+
this.kysely.getExecutor().adapter instanceof MysqlAdapter;
|
|
178
|
+
}
|
|
179
|
+
async find(key) {
|
|
180
|
+
const row = await this.kysely
|
|
181
|
+
.selectFrom("writerLock")
|
|
182
|
+
.where("writerLock.key", "=", key)
|
|
183
|
+
.select(["writerLock.owner", "writerLock.expiration"])
|
|
184
|
+
.executeTakeFirst();
|
|
185
|
+
if (row === undefined) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
if (row.expiration === null) {
|
|
189
|
+
return {
|
|
190
|
+
owner: row.owner,
|
|
191
|
+
expiration: null,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
owner: row.owner,
|
|
196
|
+
expiration: new Date(Number(row.expiration)),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
async upsert(key, lockId, expiration) {
|
|
200
|
+
const expirationAsMs = expiration?.getTime() ?? null;
|
|
201
|
+
await this.kysely
|
|
202
|
+
.insertInto("writerLock")
|
|
203
|
+
.values({
|
|
204
|
+
key,
|
|
205
|
+
owner: lockId,
|
|
206
|
+
expiration: expirationAsMs,
|
|
207
|
+
})
|
|
208
|
+
.$if(!this.isMysql, (eb) => eb.onConflict((eb) => eb.column("key").doUpdateSet({
|
|
209
|
+
key,
|
|
210
|
+
owner: lockId,
|
|
211
|
+
expiration: expirationAsMs,
|
|
212
|
+
})))
|
|
213
|
+
.$if(this.isMysql, (eb) => eb.onDuplicateKeyUpdate({
|
|
214
|
+
key,
|
|
215
|
+
owner: lockId,
|
|
216
|
+
expiration: expirationAsMs,
|
|
217
|
+
}))
|
|
218
|
+
.execute();
|
|
219
|
+
}
|
|
220
|
+
async remove(key) {
|
|
221
|
+
let result;
|
|
222
|
+
if (this.isMysql) {
|
|
223
|
+
result = await this.kysely
|
|
224
|
+
.selectFrom("writerLock")
|
|
225
|
+
.where("writerLock.key", "=", key)
|
|
226
|
+
.select("writerLock.expiration")
|
|
227
|
+
.executeTakeFirst();
|
|
228
|
+
await this.kysely
|
|
229
|
+
.deleteFrom("writerLock")
|
|
230
|
+
.where("writerLock.key", "=", key)
|
|
231
|
+
.executeTakeFirst();
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
result = await this.kysely
|
|
235
|
+
.deleteFrom("writerLock")
|
|
236
|
+
.where("writerLock.key", "=", key)
|
|
237
|
+
.returning(["writerLock.expiration"])
|
|
238
|
+
.executeTakeFirst();
|
|
239
|
+
}
|
|
240
|
+
if (result === undefined) {
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
if (result.expiration === null) {
|
|
244
|
+
return {
|
|
245
|
+
expiration: null,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
expiration: new Date(Number(result.expiration)),
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
async removeIfOwner(key, lockId) {
|
|
253
|
+
let row;
|
|
254
|
+
if (this.isMysql) {
|
|
255
|
+
row = await this.kysely
|
|
256
|
+
.selectFrom("writerLock")
|
|
257
|
+
.where("writerLock.key", "=", key)
|
|
258
|
+
.where("writerLock.owner", "=", lockId)
|
|
259
|
+
.select(["writerLock.expiration", "writerLock.owner"])
|
|
260
|
+
.executeTakeFirst();
|
|
261
|
+
await this.kysely
|
|
262
|
+
.deleteFrom("writerLock")
|
|
263
|
+
.where("writerLock.key", "=", key)
|
|
264
|
+
.where("writerLock.owner", "=", lockId)
|
|
265
|
+
.execute();
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
row = await this.kysely
|
|
269
|
+
.deleteFrom("writerLock")
|
|
270
|
+
.where("writerLock.key", "=", key)
|
|
271
|
+
.where("writerLock.owner", "=", lockId)
|
|
272
|
+
.returning(["writerLock.expiration", "writerLock.owner"])
|
|
273
|
+
.executeTakeFirst();
|
|
274
|
+
}
|
|
275
|
+
if (row === undefined) {
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
const { expiration } = row;
|
|
279
|
+
if (expiration === null) {
|
|
280
|
+
return {
|
|
281
|
+
owner: row.owner,
|
|
282
|
+
expiration: null,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
owner: row.owner,
|
|
287
|
+
expiration: new Date(Number(expiration)),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
async updateExpiration(key, lockId, expiration) {
|
|
291
|
+
const result = await this.kysely
|
|
292
|
+
.updateTable("writerLock")
|
|
293
|
+
.where("writerLock.key", "=", key)
|
|
294
|
+
.where("writerLock.owner", "=", lockId)
|
|
295
|
+
.where((eb) => eb.and([
|
|
296
|
+
eb("writerLock.expiration", "is not", null),
|
|
297
|
+
eb("writerLock.expiration", ">", Date.now()),
|
|
298
|
+
]))
|
|
299
|
+
.set({
|
|
300
|
+
expiration: expiration.getTime(),
|
|
301
|
+
})
|
|
302
|
+
.executeTakeFirst();
|
|
303
|
+
return Number(result.numUpdatedRows);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* To utilize the `KyselySharedLockAdapter`, you must install the [`"kysely"`](https://www.npmjs.com/package/kysely) package and configure a `Kysely` class instance.
|
|
308
|
+
*
|
|
309
|
+
* Note in order to use `KyselySharedLockAdapter` correctly, ensure you use a single, consistent database across all server instances.
|
|
310
|
+
* The adapter have been tested with `sqlite`, `postgres` and `mysql` databases.
|
|
311
|
+
*
|
|
312
|
+
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/adapters"`
|
|
313
|
+
* @group Adapters
|
|
314
|
+
*/
|
|
315
|
+
export class KyselySharedLockAdapter {
|
|
316
|
+
kysely;
|
|
317
|
+
expiredKeysRemovalInterval;
|
|
318
|
+
shouldRemoveExpiredKeys;
|
|
319
|
+
intervalId = null;
|
|
320
|
+
currentDate;
|
|
321
|
+
/**
|
|
322
|
+
* @example
|
|
323
|
+
* ```ts
|
|
324
|
+
* import { KyselySharedLockAdapter } from "@daiso-tech/core/shared-lock/adapters";
|
|
325
|
+
* import Sqlite from "better-sqlite3";
|
|
326
|
+
*
|
|
327
|
+
* const lockAdapter = new KyselySharedLockAdapter({
|
|
328
|
+
* kysely: new Kysely({
|
|
329
|
+
* dialect: new SqliteDialect({
|
|
330
|
+
* database: new Sqlite("local.db"),
|
|
331
|
+
* }),
|
|
332
|
+
* }),
|
|
333
|
+
* });
|
|
334
|
+
* // You need initialize the adapter once before using it.
|
|
335
|
+
* await lockAdapter.init();
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
constructor(settings) {
|
|
339
|
+
const { kysely, expiredKeysRemovalInterval = TimeSpan.fromMinutes(1), shouldRemoveExpiredKeys = true, currentDate = () => new Date(), } = settings;
|
|
340
|
+
this.expiredKeysRemovalInterval = expiredKeysRemovalInterval;
|
|
341
|
+
this.shouldRemoveExpiredKeys = shouldRemoveExpiredKeys;
|
|
342
|
+
this.kysely = kysely;
|
|
343
|
+
this.currentDate = currentDate;
|
|
344
|
+
}
|
|
345
|
+
async init() {
|
|
346
|
+
// Should throw if the table already exists thats why the try catch is used.
|
|
347
|
+
try {
|
|
348
|
+
await this.kysely.schema
|
|
349
|
+
.createTable("readerSemaphore")
|
|
350
|
+
.addColumn("key", "varchar(255)", (col) => col.notNull().primaryKey())
|
|
351
|
+
.addColumn("limit", "integer", (col) => col.notNull())
|
|
352
|
+
.execute();
|
|
353
|
+
}
|
|
354
|
+
catch {
|
|
355
|
+
/* EMPTY */
|
|
356
|
+
}
|
|
357
|
+
// Should throw if the table already exists thats why the try catch is used.
|
|
358
|
+
try {
|
|
359
|
+
await this.kysely.schema
|
|
360
|
+
.createTable("readerSemaphoreSlot")
|
|
361
|
+
.addColumn("id", "varchar(255)", (col) => col.notNull().primaryKey())
|
|
362
|
+
.addColumn("key", "varchar(255)", (col) => col.notNull())
|
|
363
|
+
.addColumn("expiration", "bigint")
|
|
364
|
+
.addForeignKeyConstraint("readerSemaphoreSlot_key", ["key"], "readerSemaphore", ["key"], (eb) => eb.onDelete("cascade"))
|
|
365
|
+
.execute();
|
|
366
|
+
}
|
|
367
|
+
catch {
|
|
368
|
+
/* EMPTY */
|
|
369
|
+
}
|
|
370
|
+
// Should throw if the index already exists thats why the try catch is used.
|
|
371
|
+
try {
|
|
372
|
+
await this.kysely.schema
|
|
373
|
+
.createIndex("readerSemaphoreSlot_expiration_index")
|
|
374
|
+
.on("readerSemaphoreSlot")
|
|
375
|
+
.columns(["key", "expiresAt"])
|
|
376
|
+
.execute();
|
|
377
|
+
}
|
|
378
|
+
catch {
|
|
379
|
+
/* EMPTY */
|
|
380
|
+
}
|
|
381
|
+
// Should throw if the table already exists thats why the try catch is used.
|
|
382
|
+
try {
|
|
383
|
+
await this.kysely.schema
|
|
384
|
+
.createTable("writerLock")
|
|
385
|
+
.addColumn("key", "varchar(255)", (col) => col.primaryKey().notNull())
|
|
386
|
+
.addColumn("owner", "varchar(255)", (col) => col.notNull())
|
|
387
|
+
.addColumn("expiration", "bigint")
|
|
388
|
+
.execute();
|
|
389
|
+
}
|
|
390
|
+
catch {
|
|
391
|
+
/* EMPTY */
|
|
392
|
+
}
|
|
393
|
+
// Should throw if the index already exists thats why the try catch is used.
|
|
394
|
+
try {
|
|
395
|
+
await this.kysely.schema
|
|
396
|
+
.createIndex("writerLock_expiration")
|
|
397
|
+
.on("writerLock")
|
|
398
|
+
.column("expiration")
|
|
399
|
+
.execute();
|
|
400
|
+
}
|
|
401
|
+
catch {
|
|
402
|
+
/* EMPTY */
|
|
403
|
+
}
|
|
404
|
+
if (this.shouldRemoveExpiredKeys) {
|
|
405
|
+
this.intervalId = setInterval(() => {
|
|
406
|
+
void this.removeAllExpired();
|
|
407
|
+
}, this.expiredKeysRemovalInterval.toMilliseconds());
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
async deInit() {
|
|
411
|
+
if (this.shouldRemoveExpiredKeys && this.intervalId !== null) {
|
|
412
|
+
clearInterval(this.intervalId);
|
|
413
|
+
}
|
|
414
|
+
// Should throw if the index does not exists thats why the try catch is used.
|
|
415
|
+
try {
|
|
416
|
+
await this.kysely.schema
|
|
417
|
+
.dropIndex("readerSemaphoreSlot_expiration_index")
|
|
418
|
+
.on("readerSemaphoreSlot")
|
|
419
|
+
.execute();
|
|
420
|
+
}
|
|
421
|
+
catch {
|
|
422
|
+
/* EMPTY */
|
|
423
|
+
}
|
|
424
|
+
// Should throw if the table does not exists thats why the try catch is used.
|
|
425
|
+
try {
|
|
426
|
+
await this.kysely.schema.dropTable("readerSemaphoreSlot").execute();
|
|
427
|
+
}
|
|
428
|
+
catch {
|
|
429
|
+
/* EMPTY */
|
|
430
|
+
}
|
|
431
|
+
// Should throw if the table does not exists thats why the try catch is used.
|
|
432
|
+
try {
|
|
433
|
+
await this.kysely.schema.dropTable("readerSemaphore").execute();
|
|
434
|
+
}
|
|
435
|
+
catch {
|
|
436
|
+
/* EMPTY */
|
|
437
|
+
}
|
|
438
|
+
// Should throw if the index does not exists thats why the try catch is used.
|
|
439
|
+
try {
|
|
440
|
+
await this.kysely.schema
|
|
441
|
+
.dropIndex("writerLock_expiration")
|
|
442
|
+
.on("writerLock")
|
|
443
|
+
.execute();
|
|
444
|
+
}
|
|
445
|
+
catch {
|
|
446
|
+
/* EMPTY */
|
|
447
|
+
}
|
|
448
|
+
// Should throw if the table does not exists thats why the try catch is used.
|
|
449
|
+
try {
|
|
450
|
+
await this.kysely.schema.dropTable("writerLock").execute();
|
|
451
|
+
}
|
|
452
|
+
catch {
|
|
453
|
+
/* EMPTY */
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
async removeAllExpiredReaders() {
|
|
457
|
+
await this.kysely
|
|
458
|
+
.deleteFrom("readerSemaphore")
|
|
459
|
+
.where((eb) => {
|
|
460
|
+
const hasUnexpiredSlots = eb
|
|
461
|
+
.selectFrom("readerSemaphoreSlot")
|
|
462
|
+
.select(eb.val(1).as("value"))
|
|
463
|
+
.where("readerSemaphoreSlot.key", "=", eb.ref("readerSemaphore.key"))
|
|
464
|
+
.where((eb) => eb.and([
|
|
465
|
+
eb("readerSemaphoreSlot.expiration", "is not", null),
|
|
466
|
+
eb("readerSemaphoreSlot.expiration", ">", Date.now()),
|
|
467
|
+
]));
|
|
468
|
+
return eb.not(eb.exists(hasUnexpiredSlots));
|
|
469
|
+
})
|
|
470
|
+
.execute();
|
|
471
|
+
}
|
|
472
|
+
async removeAllExpiredWriters() {
|
|
473
|
+
await this.kysely
|
|
474
|
+
.deleteFrom("writerLock")
|
|
475
|
+
.where("writerLock.expiration", "<=", this.currentDate().getTime())
|
|
476
|
+
.execute();
|
|
477
|
+
}
|
|
478
|
+
async removeAllExpired() {
|
|
479
|
+
await Promise.all([
|
|
480
|
+
this.removeAllExpiredWriters(),
|
|
481
|
+
this.removeAllExpiredReaders(),
|
|
482
|
+
]);
|
|
483
|
+
}
|
|
484
|
+
async transaction(fn) {
|
|
485
|
+
return await this.kysely
|
|
486
|
+
.transaction()
|
|
487
|
+
.setIsolationLevel("serializable")
|
|
488
|
+
.execute(async (trx) => {
|
|
489
|
+
return await fn({
|
|
490
|
+
reader: new DatabaseReaderSemaphoreTransaction(trx),
|
|
491
|
+
writer: new DatabaseWriterLockTransaction(trx),
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
//# sourceMappingURL=kysely-shared-lock-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kysely-shared-lock-adapter.js","sourceRoot":"","sources":["../../../../../src/shared-lock/implementations/adapters/kysely-shared-lock-adapter/kysely-shared-lock-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,OAAO,EAAE,YAAY,EAAe,MAAM,QAAQ,CAAC;AACnD,OAAO,EAKN,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAgF1E;;GAEG;AACH,MAAM,kCAAkC;IAKP;IAFZ,OAAO,CAAU;IAElC,YAA6B,MAAsC;QAAtC,WAAM,GAAN,MAAM,CAAgC;QAC/D,IAAI,CAAC,OAAO;YACR,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,OAAO,YAAY,YAAY,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,GAAW;QAC3B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM;aACxB,UAAU,CAAC,iBAAiB,CAAC;aAC7B,KAAK,CAAC,qBAAqB,EAAE,GAAG,EAAE,GAAG,CAA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CAAkC,CAAC,GAAG,CAAC;gBACnD,MAAM,EAAE,IAAI,6BAA6B,CAAC,GAAG,CAAC;aACjD,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACX,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../../../shared-lock/implementations/adapters/memory-shared-lock-adapter/memory-shared-lock-adapter.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../../src/shared-lock/implementations/adapters/memory-shared-lock-adapter/_module.ts"],"names":[],"mappings":"AAAA,cAAc,iGAAiG,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module SharedLock
|
|
3
|
+
*/
|
|
4
|
+
import { type IDeinitizable } from "../../../../utilities/_module-exports.js";
|
|
5
|
+
import type { ISharedLockAdapter, ISharedLockAdapterState, SharedLockAcquireSettings } from "../../../../shared-lock/contracts/_module-exports.js";
|
|
6
|
+
import type { TimeSpan } from "../../../../time-span/implementations/_module-exports.js";
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/adapters"`
|
|
10
|
+
* @group Adapters
|
|
11
|
+
*/
|
|
12
|
+
export type MemorySharedWriterLockData = {
|
|
13
|
+
owner: string;
|
|
14
|
+
hasExpiration: true;
|
|
15
|
+
timeoutId: string | number | NodeJS.Timeout;
|
|
16
|
+
expiration: Date;
|
|
17
|
+
} | {
|
|
18
|
+
owner: string;
|
|
19
|
+
hasExpiration: false;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/adapters"`
|
|
24
|
+
* @group Adapters
|
|
25
|
+
*/
|
|
26
|
+
export type MemorySharedReaderSemaphoreData = {
|
|
27
|
+
limit: number;
|
|
28
|
+
slots: Map<string, {
|
|
29
|
+
timeoutId: string | number | NodeJS.Timeout | null;
|
|
30
|
+
expiration: Date | null;
|
|
31
|
+
}>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/adapters"`
|
|
36
|
+
* @group Adapters
|
|
37
|
+
*/
|
|
38
|
+
export type MemorySharedLockData = {
|
|
39
|
+
writerLock: MemorySharedWriterLockData | null;
|
|
40
|
+
readerSemaphore: MemorySharedReaderSemaphoreData | null;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Note the `MemorySharedLockAdapter` is limited to single process usage and cannot be shared across multiple servers or different processes.
|
|
44
|
+
* This adapter is meant to be used for testing.
|
|
45
|
+
*
|
|
46
|
+
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/adapters"`
|
|
47
|
+
* @group Adapters
|
|
48
|
+
*/
|
|
49
|
+
export declare class MemorySharedLockAdapter implements ISharedLockAdapter, IDeinitizable {
|
|
50
|
+
private readonly map;
|
|
51
|
+
/**
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* import { MemorySharedLockAdapter } from "@daiso-tech/core/shared-lock/adapters";
|
|
55
|
+
*
|
|
56
|
+
* const lockAdapter = new MemorySharedLockAdapter();
|
|
57
|
+
* ```
|
|
58
|
+
* You can also provide an `Map`.
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { MemorySharedLockAdapter } from "@daiso-tech/core/shared-lock/adapters";
|
|
62
|
+
*
|
|
63
|
+
* const map = new Map<any, any>();
|
|
64
|
+
* const lockAdapter = new MemorySharedLockAdapter(map);
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
constructor(map?: Map<string, MemorySharedLockData>);
|
|
68
|
+
deInit(): Promise<void>;
|
|
69
|
+
acquireWriter(key: string, lockId: string, ttl: TimeSpan | null): Promise<boolean>;
|
|
70
|
+
releaseWriter(key: string, lockId: string): Promise<boolean>;
|
|
71
|
+
forceReleaseWriter(key: string): Promise<boolean>;
|
|
72
|
+
refreshWriter(key: string, lockId: string, ttl: TimeSpan): Promise<boolean>;
|
|
73
|
+
acquireReader(settings: SharedLockAcquireSettings): Promise<boolean>;
|
|
74
|
+
releaseReader(key: string, lockId: string): Promise<boolean>;
|
|
75
|
+
forceReleaseAllReaders(key: string): Promise<boolean>;
|
|
76
|
+
refreshReader(key: string, lockId: string, ttl: TimeSpan): Promise<boolean>;
|
|
77
|
+
forceRelease(key: string): Promise<boolean>;
|
|
78
|
+
getState(key: string): Promise<ISharedLockAdapterState | null>;
|
|
79
|
+
}
|