@daiso-tech/core 0.39.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +12 -12
- 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/contracts/database-cache-adapter.contract.d.ts +10 -10
- 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 +10 -10
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js.map +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-adapter.contract.d.ts +3 -3
- package/dist/event-bus/contracts/event-bus.contract.d.ts +10 -10
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.d.ts +3 -3
- 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 +18 -24
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +51 -51
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.d.ts +11 -4
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.js +17 -12
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.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 +36 -37
- 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 +86 -674
- 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 +59 -14
- package/dist/lock/contracts/lock-adapter.contract.d.ts +22 -10
- 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 +72 -58
- package/dist/lock/contracts/lock.errors.d.ts +18 -15
- package/dist/lock/contracts/lock.errors.js +22 -17
- package/dist/lock/contracts/lock.errors.js.map +1 -1
- package/dist/lock/contracts/lock.events.d.ts +21 -37
- package/dist/lock/contracts/lock.events.js +2 -2
- 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 +33 -13
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js +182 -56
- 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 +25 -9
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +80 -36
- 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 +11 -12
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +164 -79
- 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 +7 -6
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js +7 -4
- 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 +27 -9
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +87 -32
- 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 +7 -6
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js +56 -24
- 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 +7 -7
- 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 -33
- package/dist/lock/implementations/derivables/lock-provider/lock.js +178 -234
- 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 +312 -191
- 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 +378 -95
- 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 +3110 -1611
- 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/contracts/deinitizable.contract.d.ts +1 -1
- package/dist/utilities/contracts/initizable.contract.d.ts +1 -1
- package/dist/utilities/contracts/prunable.contract.d.ts +1 -1
- 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,805 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module SharedLock
|
|
3
|
+
*/
|
|
4
|
+
import { UnexpectedError, } from "../../../../utilities/_module-exports.js";
|
|
5
|
+
import { TimeSpan } from "../../../../time-span/implementations/_module-exports.js";
|
|
6
|
+
/**
|
|
7
|
+
* To utilize the `MongodbSharedLockAdapter`, you must install the [`"mongodb"`](https://www.npmjs.com/package/mongodb) package.
|
|
8
|
+
*
|
|
9
|
+
* Note in order to use `MongodbSharedLockAdapter` correctly, ensure you use a single, consistent database across all server instances.
|
|
10
|
+
*
|
|
11
|
+
* IMPORT_PATH: `"@daiso-tech/core/shared-lock/adapters"`
|
|
12
|
+
* @group Adapters
|
|
13
|
+
*/
|
|
14
|
+
export class MongodbSharedLockAdapter {
|
|
15
|
+
static isSlotNotExpired = (slot) => slot.expiration === null || slot.expiration > new Date();
|
|
16
|
+
collection;
|
|
17
|
+
/**
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { MongodbSharedLockAdapter } from "@daiso-tech/core/shared-lock/adapters";
|
|
21
|
+
* import { MongoClient } from "mongodb";
|
|
22
|
+
*
|
|
23
|
+
* const client = await MongoClient.connect("YOUR_MONGODB_CONNECTION_STRING");
|
|
24
|
+
* const database = client.db("database");
|
|
25
|
+
* const lockAdapter = new MongodbSharedLockAdapter({
|
|
26
|
+
* database
|
|
27
|
+
* });
|
|
28
|
+
* // You need initialize the adapter once before using it.
|
|
29
|
+
* await lockAdapter.init()
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
constructor(settings) {
|
|
33
|
+
const { collectionName = "sharedLock", collectionSettings, database, } = settings;
|
|
34
|
+
this.collection = database.collection(collectionName, collectionSettings);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates all related indexes.
|
|
38
|
+
* Note the `init` method needs to be called once before using the adapter.
|
|
39
|
+
*/
|
|
40
|
+
async init() {
|
|
41
|
+
// Should throw if the index already exists thats why the try catch is used.
|
|
42
|
+
try {
|
|
43
|
+
await this.collection.createIndex({
|
|
44
|
+
key: 1,
|
|
45
|
+
}, {
|
|
46
|
+
unique: true,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
/* EMPTY */
|
|
51
|
+
}
|
|
52
|
+
// Should throw if the index already exists thats why the try catch is used.
|
|
53
|
+
try {
|
|
54
|
+
await this.collection.createIndex("expiration", {
|
|
55
|
+
expireAfterSeconds: 0,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
/* EMPTY */
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Removes the collection where the lock keys are stored and all it's related indexes.
|
|
64
|
+
* Note all lock data will be removed.
|
|
65
|
+
*/
|
|
66
|
+
async deInit() {
|
|
67
|
+
// Should throw if the collection already does not exists thats why the try catch is used.
|
|
68
|
+
try {
|
|
69
|
+
await this.collection.dropIndexes();
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
/* EMPTY */
|
|
73
|
+
}
|
|
74
|
+
// Should throw if the collection already does not exists thats why the try catch is used.
|
|
75
|
+
try {
|
|
76
|
+
await this.collection.drop();
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
/* EMPTY */
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
updateSemaphoreExpiration() {
|
|
83
|
+
const hasUnexpireableSlotQuery = {
|
|
84
|
+
$in: [
|
|
85
|
+
null,
|
|
86
|
+
{
|
|
87
|
+
$map: {
|
|
88
|
+
input: "$reader.slots",
|
|
89
|
+
as: "slot",
|
|
90
|
+
in: "$$slot.expiration",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
const hasNoSlotsQuery = {
|
|
96
|
+
$eq: [{ $size: "$reader.slots" }, 0],
|
|
97
|
+
};
|
|
98
|
+
return [
|
|
99
|
+
{
|
|
100
|
+
$set: {
|
|
101
|
+
expiration: {
|
|
102
|
+
$cond: {
|
|
103
|
+
if: {
|
|
104
|
+
$ne: ["$reader", null],
|
|
105
|
+
},
|
|
106
|
+
then: {
|
|
107
|
+
$cond: {
|
|
108
|
+
// Check if there is at least one unexpirable slot
|
|
109
|
+
if: hasUnexpireableSlotQuery,
|
|
110
|
+
// If there are at least one unexpirable slot we set the expiration to null
|
|
111
|
+
then: null,
|
|
112
|
+
// If all slots are expireable we set the expiration to highest expiration
|
|
113
|
+
else: {
|
|
114
|
+
$max: "$reader.slots.expiration",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
else: "$expiration",
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
$set: {
|
|
125
|
+
expiration: {
|
|
126
|
+
$cond: {
|
|
127
|
+
if: {
|
|
128
|
+
$ne: ["$reader", null],
|
|
129
|
+
},
|
|
130
|
+
then: {
|
|
131
|
+
$cond: {
|
|
132
|
+
// Are there slots acquired
|
|
133
|
+
if: hasNoSlotsQuery,
|
|
134
|
+
// If there are no slots acquired we immediatley expire the semaphore
|
|
135
|
+
then: TimeSpan.fromMinutes(1).toStartDate(),
|
|
136
|
+
// If there are slots acquired we do nothing
|
|
137
|
+
else: "$expiration",
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
else: "$expiration",
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
removeWriterWhenReaderIsActive() {
|
|
148
|
+
return [
|
|
149
|
+
{
|
|
150
|
+
$set: {
|
|
151
|
+
writer: {
|
|
152
|
+
$cond: {
|
|
153
|
+
if: {
|
|
154
|
+
$ne: ["$reader", null],
|
|
155
|
+
},
|
|
156
|
+
then: null,
|
|
157
|
+
else: "$writer",
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
...this.updateSemaphoreExpiration(),
|
|
163
|
+
];
|
|
164
|
+
}
|
|
165
|
+
async acquireWriter(key, lockId, ttl) {
|
|
166
|
+
const expiration = ttl?.toEndDate() ?? null;
|
|
167
|
+
const isExpiredQuery = {
|
|
168
|
+
$and: [
|
|
169
|
+
{
|
|
170
|
+
$ne: ["$writer.expiration", null],
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
$lte: ["$writer.expiration", new Date()],
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
};
|
|
177
|
+
const sharedLock = await this.collection.findOneAndUpdate({
|
|
178
|
+
key,
|
|
179
|
+
}, [
|
|
180
|
+
{
|
|
181
|
+
$set: {
|
|
182
|
+
key,
|
|
183
|
+
reader: {
|
|
184
|
+
$ifNull: ["$reader", null],
|
|
185
|
+
},
|
|
186
|
+
"writer.owner": {
|
|
187
|
+
$ifNull: ["$writer.owner", lockId],
|
|
188
|
+
},
|
|
189
|
+
"writer.expiration": {
|
|
190
|
+
$ifNull: ["$writer.expiration", expiration],
|
|
191
|
+
},
|
|
192
|
+
expiration: {
|
|
193
|
+
$ifNull: ["$expiration", expiration],
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
$set: {
|
|
199
|
+
"writer.owner": {
|
|
200
|
+
$cond: {
|
|
201
|
+
if: isExpiredQuery,
|
|
202
|
+
then: lockId,
|
|
203
|
+
else: "$writer.owner",
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
"writer.expiration": {
|
|
207
|
+
$cond: {
|
|
208
|
+
if: isExpiredQuery,
|
|
209
|
+
then: expiration,
|
|
210
|
+
else: "$writer.expiration",
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
expiration: {
|
|
214
|
+
$cond: {
|
|
215
|
+
if: isExpiredQuery,
|
|
216
|
+
then: expiration,
|
|
217
|
+
else: "$expiration",
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
...this.removeWriterWhenReaderIsActive(),
|
|
223
|
+
], {
|
|
224
|
+
upsert: true,
|
|
225
|
+
projection: {
|
|
226
|
+
_id: 0,
|
|
227
|
+
writer: 1,
|
|
228
|
+
reader: 1,
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
if (sharedLock === null) {
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
const { writer: writerLock, reader: readerSemaphore } = sharedLock;
|
|
235
|
+
if (readerSemaphore !== null) {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
if (writerLock === null) {
|
|
239
|
+
throw new UnexpectedError("Invalid ISharedLockAdapterState, expected either the writer field must be defined, but not both.");
|
|
240
|
+
}
|
|
241
|
+
if (writerLock.owner === lockId) {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
if (writerLock.expiration === null) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
return writerLock.expiration <= new Date();
|
|
248
|
+
}
|
|
249
|
+
async releaseWriter(key, lockId) {
|
|
250
|
+
const isWriterActive = {
|
|
251
|
+
writer: {
|
|
252
|
+
$ne: null,
|
|
253
|
+
},
|
|
254
|
+
reader: {
|
|
255
|
+
$eq: null,
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
const isUnexpirableQuery = {
|
|
259
|
+
"writer.expiration": {
|
|
260
|
+
$eq: null,
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
const isUnexpiredQuery = {
|
|
264
|
+
"writer.expiration": {
|
|
265
|
+
$gt: new Date(),
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
const sharedLock = await this.collection.findOneAndDelete({
|
|
269
|
+
key,
|
|
270
|
+
"writer.owner": lockId,
|
|
271
|
+
$or: [isWriterActive, isUnexpirableQuery, isUnexpiredQuery],
|
|
272
|
+
}, {
|
|
273
|
+
projection: {
|
|
274
|
+
_id: 0,
|
|
275
|
+
writer: 1,
|
|
276
|
+
reader: 1,
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
if (sharedLock === null) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
const { writer: writerLock, reader: readerSemaphore } = sharedLock;
|
|
283
|
+
if (readerSemaphore !== null) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
if (writerLock === null) {
|
|
287
|
+
throw new UnexpectedError("Invalid ISharedLockAdapterState, expected either the writer field must be defined, but not both.");
|
|
288
|
+
}
|
|
289
|
+
const { expiration } = writerLock;
|
|
290
|
+
const hasNoExpiration = expiration === null;
|
|
291
|
+
if (hasNoExpiration) {
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
const { owner: currentOwner } = writerLock;
|
|
295
|
+
const isNotExpired = expiration > new Date();
|
|
296
|
+
const isCurrentOwner = lockId === currentOwner;
|
|
297
|
+
return isNotExpired && isCurrentOwner;
|
|
298
|
+
}
|
|
299
|
+
async forceReleaseWriter(key) {
|
|
300
|
+
const sharedLock = await this.collection.findOneAndDelete({
|
|
301
|
+
key,
|
|
302
|
+
writer: {
|
|
303
|
+
$ne: null,
|
|
304
|
+
},
|
|
305
|
+
reader: {
|
|
306
|
+
$eq: null,
|
|
307
|
+
},
|
|
308
|
+
}, {
|
|
309
|
+
projection: {
|
|
310
|
+
_id: 0,
|
|
311
|
+
reader: 1,
|
|
312
|
+
writer: 1,
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
if (sharedLock === null) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
const { writer: writerLock, reader: readerSemaphore } = sharedLock;
|
|
319
|
+
if (readerSemaphore !== null) {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
if (writerLock === null) {
|
|
323
|
+
throw new UnexpectedError("Invalid ISharedLockAdapterState, expected either the writer field must be defined, but not both.");
|
|
324
|
+
}
|
|
325
|
+
if (writerLock.expiration === null) {
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
328
|
+
const isNotExpired = writerLock.expiration >= new Date();
|
|
329
|
+
return isNotExpired;
|
|
330
|
+
}
|
|
331
|
+
async refreshWriter(key, lockId, ttl) {
|
|
332
|
+
const isUnexpiredQuery = {
|
|
333
|
+
$and: [
|
|
334
|
+
{
|
|
335
|
+
$ne: ["$writer", null],
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
$eq: ["$reader", null],
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
$ne: ["$writer.expiration", null],
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
$gt: ["$writer.expiration", new Date()],
|
|
345
|
+
},
|
|
346
|
+
],
|
|
347
|
+
};
|
|
348
|
+
const sharedLock = await this.collection.findOneAndUpdate({
|
|
349
|
+
key,
|
|
350
|
+
}, [
|
|
351
|
+
{
|
|
352
|
+
$set: {
|
|
353
|
+
"writer.expiration": {
|
|
354
|
+
$cond: {
|
|
355
|
+
if: isUnexpiredQuery,
|
|
356
|
+
then: ttl.toEndDate(),
|
|
357
|
+
else: "$writer.expiration",
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
expiration: {
|
|
361
|
+
$cond: {
|
|
362
|
+
if: isUnexpiredQuery,
|
|
363
|
+
then: ttl.toEndDate(),
|
|
364
|
+
else: "$expiration",
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
...this.removeWriterWhenReaderIsActive(),
|
|
370
|
+
], {
|
|
371
|
+
projection: {
|
|
372
|
+
_id: 0,
|
|
373
|
+
reader: 1,
|
|
374
|
+
writer: 1,
|
|
375
|
+
},
|
|
376
|
+
});
|
|
377
|
+
if (sharedLock === null) {
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
const { writer: writerLock, reader: readerSemaphore } = sharedLock;
|
|
381
|
+
if (readerSemaphore !== null) {
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
if (writerLock === null) {
|
|
385
|
+
throw new UnexpectedError("Invalid ISharedLockAdapterState, expected either the writer field must be defined, but not both.");
|
|
386
|
+
}
|
|
387
|
+
if (writerLock.owner !== lockId) {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
if (writerLock.expiration === null) {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
if (writerLock.expiration <= new Date()) {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
initSemaphoreIfNotExistsStage(key, limit) {
|
|
399
|
+
// Initialies the fields if they dont exist when upserting
|
|
400
|
+
return {
|
|
401
|
+
$set: {
|
|
402
|
+
key,
|
|
403
|
+
writer: {
|
|
404
|
+
$ifNull: ["$writer", null],
|
|
405
|
+
},
|
|
406
|
+
"reader.limit": {
|
|
407
|
+
$ifNull: ["$reader.limit", limit],
|
|
408
|
+
},
|
|
409
|
+
"reader.slots": {
|
|
410
|
+
$ifNull: ["$reader.slots", []],
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
removeExpiredSlotsStage() {
|
|
416
|
+
return {
|
|
417
|
+
$set: {
|
|
418
|
+
"reader.slots": {
|
|
419
|
+
// We filter all slots that are not expired
|
|
420
|
+
$filter: {
|
|
421
|
+
input: "$reader.slots",
|
|
422
|
+
as: "slot",
|
|
423
|
+
cond: {
|
|
424
|
+
$or: [
|
|
425
|
+
// We filter all slots that have no ttl
|
|
426
|
+
{
|
|
427
|
+
$eq: ["$$slot.expiration", null],
|
|
428
|
+
},
|
|
429
|
+
// We filter all slots that have ttl but are not expired
|
|
430
|
+
{
|
|
431
|
+
$gt: ["$$slot.expiration", new Date()],
|
|
432
|
+
},
|
|
433
|
+
],
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
removeReaderWhenWriterIsActive() {
|
|
441
|
+
return {
|
|
442
|
+
$set: {
|
|
443
|
+
reader: {
|
|
444
|
+
$cond: {
|
|
445
|
+
if: {
|
|
446
|
+
$ne: ["$writer", null],
|
|
447
|
+
},
|
|
448
|
+
then: null,
|
|
449
|
+
else: "$reader",
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
expiration: {
|
|
453
|
+
$cond: {
|
|
454
|
+
if: {
|
|
455
|
+
$ne: ["$writer", null],
|
|
456
|
+
},
|
|
457
|
+
then: "$writer.expiration",
|
|
458
|
+
else: "$expiration",
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
async acquireReader(settings) {
|
|
465
|
+
const { key, lockId, limit, ttl } = settings;
|
|
466
|
+
const hasNotReachedLimitQuery = {
|
|
467
|
+
$lt: [
|
|
468
|
+
{
|
|
469
|
+
$size: "$reader.slots",
|
|
470
|
+
},
|
|
471
|
+
"$reader.limit",
|
|
472
|
+
],
|
|
473
|
+
};
|
|
474
|
+
const hasAlreadyAcquiredSlotQuery = {
|
|
475
|
+
$not: [
|
|
476
|
+
{
|
|
477
|
+
$in: [
|
|
478
|
+
lockId,
|
|
479
|
+
// We select the ids of each element in the $slots
|
|
480
|
+
{
|
|
481
|
+
$map: {
|
|
482
|
+
input: "$reader.slots",
|
|
483
|
+
as: "slot",
|
|
484
|
+
in: "$$slot.id",
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
],
|
|
488
|
+
},
|
|
489
|
+
],
|
|
490
|
+
};
|
|
491
|
+
const sharedLock = await this.collection.findOneAndUpdate({
|
|
492
|
+
key,
|
|
493
|
+
}, [
|
|
494
|
+
this.initSemaphoreIfNotExistsStage(key, limit),
|
|
495
|
+
this.removeExpiredSlotsStage(),
|
|
496
|
+
{
|
|
497
|
+
$set: {
|
|
498
|
+
"reader.limit": {
|
|
499
|
+
$cond: {
|
|
500
|
+
if: {
|
|
501
|
+
$eq: [
|
|
502
|
+
{
|
|
503
|
+
$size: "$reader.slots",
|
|
504
|
+
},
|
|
505
|
+
0,
|
|
506
|
+
],
|
|
507
|
+
},
|
|
508
|
+
then: limit,
|
|
509
|
+
else: "$reader.limit",
|
|
510
|
+
},
|
|
511
|
+
},
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
$set: {
|
|
516
|
+
"reader.slots": {
|
|
517
|
+
$cond: {
|
|
518
|
+
// We check if the limit is not reached and slot id does not exist
|
|
519
|
+
if: {
|
|
520
|
+
$and: [
|
|
521
|
+
hasNotReachedLimitQuery,
|
|
522
|
+
hasAlreadyAcquiredSlotQuery,
|
|
523
|
+
],
|
|
524
|
+
},
|
|
525
|
+
// If the limit is not reached and slot id does not exist we append the slot
|
|
526
|
+
then: {
|
|
527
|
+
$concatArrays: [
|
|
528
|
+
"$reader.slots",
|
|
529
|
+
[
|
|
530
|
+
{
|
|
531
|
+
id: lockId,
|
|
532
|
+
expiration: ttl?.toEndDate() ?? null,
|
|
533
|
+
},
|
|
534
|
+
],
|
|
535
|
+
],
|
|
536
|
+
},
|
|
537
|
+
// If the limit is reached or slot id does exist we do nonthing
|
|
538
|
+
else: "$reader.slots",
|
|
539
|
+
},
|
|
540
|
+
},
|
|
541
|
+
},
|
|
542
|
+
},
|
|
543
|
+
...this.updateSemaphoreExpiration(),
|
|
544
|
+
this.removeReaderWhenWriterIsActive(),
|
|
545
|
+
], {
|
|
546
|
+
upsert: true,
|
|
547
|
+
projection: {
|
|
548
|
+
_id: 0,
|
|
549
|
+
writer: 1,
|
|
550
|
+
reader: 1,
|
|
551
|
+
},
|
|
552
|
+
});
|
|
553
|
+
if (sharedLock === null) {
|
|
554
|
+
return true;
|
|
555
|
+
}
|
|
556
|
+
const { writer: writerLock, reader: readerSemaphore } = sharedLock;
|
|
557
|
+
if (writerLock !== null) {
|
|
558
|
+
return false;
|
|
559
|
+
}
|
|
560
|
+
if (readerSemaphore === null) {
|
|
561
|
+
throw new UnexpectedError("Invalid ISharedLockAdapterState, expected either the writer field must be defined, but not both.");
|
|
562
|
+
}
|
|
563
|
+
// We need to filter out expired slots from semaphoreData to ensure the data is current.
|
|
564
|
+
// The update that handles slot expiration runs after this function.
|
|
565
|
+
const unexpiredSlots = readerSemaphore.slots.filter(MongodbSharedLockAdapter.isSlotNotExpired);
|
|
566
|
+
const hasReachedLimit = unexpiredSlots.length >= readerSemaphore.limit;
|
|
567
|
+
if (hasReachedLimit) {
|
|
568
|
+
return false;
|
|
569
|
+
}
|
|
570
|
+
const hasAlreadyAcquiredSlot = unexpiredSlots.some((slot) => slot.id === lockId);
|
|
571
|
+
if (hasAlreadyAcquiredSlot) {
|
|
572
|
+
return true;
|
|
573
|
+
}
|
|
574
|
+
return true;
|
|
575
|
+
}
|
|
576
|
+
async releaseReader(key, slotId) {
|
|
577
|
+
const sharedLock = await this.collection.findOneAndUpdate({
|
|
578
|
+
key,
|
|
579
|
+
writer: {
|
|
580
|
+
$eq: null,
|
|
581
|
+
},
|
|
582
|
+
reader: {
|
|
583
|
+
$ne: null,
|
|
584
|
+
},
|
|
585
|
+
}, [
|
|
586
|
+
this.removeExpiredSlotsStage(),
|
|
587
|
+
{
|
|
588
|
+
$set: {
|
|
589
|
+
"reader.slots": {
|
|
590
|
+
$filter: {
|
|
591
|
+
input: "$reader.slots",
|
|
592
|
+
as: "slot",
|
|
593
|
+
cond: {
|
|
594
|
+
$ne: ["$$slot.id", slotId],
|
|
595
|
+
},
|
|
596
|
+
},
|
|
597
|
+
},
|
|
598
|
+
},
|
|
599
|
+
},
|
|
600
|
+
...this.updateSemaphoreExpiration(),
|
|
601
|
+
this.removeReaderWhenWriterIsActive(),
|
|
602
|
+
], {
|
|
603
|
+
projection: {
|
|
604
|
+
_id: 0,
|
|
605
|
+
writer: 1,
|
|
606
|
+
reader: 1,
|
|
607
|
+
},
|
|
608
|
+
});
|
|
609
|
+
if (sharedLock === null) {
|
|
610
|
+
return false;
|
|
611
|
+
}
|
|
612
|
+
const { writer: writerLock, reader: readerSemaphore } = sharedLock;
|
|
613
|
+
if (writerLock !== null) {
|
|
614
|
+
return false;
|
|
615
|
+
}
|
|
616
|
+
if (readerSemaphore === null) {
|
|
617
|
+
throw new UnexpectedError("Invalid ISharedLockAdapterState, expected either the writer field must be defined, but not both.");
|
|
618
|
+
}
|
|
619
|
+
const hasSlot = readerSemaphore.slots.some((slot) => slot.id === slotId &&
|
|
620
|
+
MongodbSharedLockAdapter.isSlotNotExpired(slot));
|
|
621
|
+
if (hasSlot) {
|
|
622
|
+
return true;
|
|
623
|
+
}
|
|
624
|
+
return false;
|
|
625
|
+
}
|
|
626
|
+
async forceReleaseAllReaders(key) {
|
|
627
|
+
const sharedLock = await this.collection.findOneAndDelete({
|
|
628
|
+
key,
|
|
629
|
+
writer: {
|
|
630
|
+
$eq: null,
|
|
631
|
+
},
|
|
632
|
+
reader: {
|
|
633
|
+
$ne: null,
|
|
634
|
+
},
|
|
635
|
+
}, {
|
|
636
|
+
projection: {
|
|
637
|
+
_id: 0,
|
|
638
|
+
writer: 1,
|
|
639
|
+
reader: 1,
|
|
640
|
+
},
|
|
641
|
+
});
|
|
642
|
+
if (sharedLock === null) {
|
|
643
|
+
return false;
|
|
644
|
+
}
|
|
645
|
+
const { writer: writerLock, reader: readerSemaphore } = sharedLock;
|
|
646
|
+
if (writerLock !== null) {
|
|
647
|
+
return false;
|
|
648
|
+
}
|
|
649
|
+
if (readerSemaphore === null) {
|
|
650
|
+
throw new UnexpectedError("Invalid ISharedLockAdapterState, expected either the writer field must be defined, but not both.");
|
|
651
|
+
}
|
|
652
|
+
const unexpiredSlots = readerSemaphore.slots.filter(MongodbSharedLockAdapter.isSlotNotExpired);
|
|
653
|
+
return unexpiredSlots.length > 0;
|
|
654
|
+
}
|
|
655
|
+
async refreshReader(key, slotId, ttl) {
|
|
656
|
+
const isExpireableQuery = {
|
|
657
|
+
$ne: ["$$slot.expiration", null],
|
|
658
|
+
};
|
|
659
|
+
const isUnexpiredQuery = {
|
|
660
|
+
$gt: ["$$slot.expiration", new Date()],
|
|
661
|
+
};
|
|
662
|
+
const sharedLock = await this.collection.findOneAndUpdate({
|
|
663
|
+
key,
|
|
664
|
+
writer: {
|
|
665
|
+
$eq: null,
|
|
666
|
+
},
|
|
667
|
+
reader: {
|
|
668
|
+
$ne: null,
|
|
669
|
+
},
|
|
670
|
+
}, [
|
|
671
|
+
this.removeExpiredSlotsStage(),
|
|
672
|
+
{
|
|
673
|
+
$set: {
|
|
674
|
+
"reader.slots": {
|
|
675
|
+
$map: {
|
|
676
|
+
input: "$reader.slots",
|
|
677
|
+
as: "slot",
|
|
678
|
+
in: {
|
|
679
|
+
$cond: {
|
|
680
|
+
if: {
|
|
681
|
+
$and: [
|
|
682
|
+
{
|
|
683
|
+
$eq: ["$$slot.id", slotId],
|
|
684
|
+
},
|
|
685
|
+
isExpireableQuery,
|
|
686
|
+
isUnexpiredQuery,
|
|
687
|
+
],
|
|
688
|
+
},
|
|
689
|
+
then: {
|
|
690
|
+
id: "$$slot.id",
|
|
691
|
+
expiration: ttl.toEndDate(),
|
|
692
|
+
},
|
|
693
|
+
else: "$$slot",
|
|
694
|
+
},
|
|
695
|
+
},
|
|
696
|
+
},
|
|
697
|
+
},
|
|
698
|
+
},
|
|
699
|
+
},
|
|
700
|
+
...this.updateSemaphoreExpiration(),
|
|
701
|
+
this.removeReaderWhenWriterIsActive(),
|
|
702
|
+
], {
|
|
703
|
+
projection: {
|
|
704
|
+
_id: 0,
|
|
705
|
+
reader: 1,
|
|
706
|
+
writer: 1,
|
|
707
|
+
},
|
|
708
|
+
returnDocument: "after",
|
|
709
|
+
});
|
|
710
|
+
if (sharedLock === null) {
|
|
711
|
+
return false;
|
|
712
|
+
}
|
|
713
|
+
const { writer: writerLock, reader: readerSemaphore } = sharedLock;
|
|
714
|
+
if (writerLock !== null) {
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
717
|
+
if (readerSemaphore === null) {
|
|
718
|
+
throw new UnexpectedError("Invalid ISharedLockAdapterState, expected either the writer field must be defined, but not both.");
|
|
719
|
+
}
|
|
720
|
+
const hasRefreshed = readerSemaphore.slots
|
|
721
|
+
.filter(MongodbSharedLockAdapter.isSlotNotExpired)
|
|
722
|
+
.some((slot) => slot.id === slotId && slot.expiration !== null);
|
|
723
|
+
return hasRefreshed;
|
|
724
|
+
}
|
|
725
|
+
async forceRelease(key) {
|
|
726
|
+
const sharedLock = await this.collection.findOneAndDelete({
|
|
727
|
+
key,
|
|
728
|
+
});
|
|
729
|
+
if (sharedLock === null) {
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
const { writer: writerLock, reader: readerSemaphore } = sharedLock;
|
|
733
|
+
if (writerLock !== null && writerLock.expiration === null) {
|
|
734
|
+
return true;
|
|
735
|
+
}
|
|
736
|
+
if (writerLock !== null && writerLock.expiration !== null) {
|
|
737
|
+
const isNotExpired = writerLock.expiration >= new Date();
|
|
738
|
+
return isNotExpired;
|
|
739
|
+
}
|
|
740
|
+
if (readerSemaphore !== null) {
|
|
741
|
+
const unexpiredSlots = readerSemaphore.slots.filter(MongodbSharedLockAdapter.isSlotNotExpired);
|
|
742
|
+
return unexpiredSlots.length > 0;
|
|
743
|
+
}
|
|
744
|
+
throw new UnexpectedError("Invalid ISharedLockAdapterState, expected either the writer field must be defined, but not both.");
|
|
745
|
+
}
|
|
746
|
+
async getState(key) {
|
|
747
|
+
const sharedLock = await this.collection.findOne({ key }, {
|
|
748
|
+
projection: {
|
|
749
|
+
_id: 0,
|
|
750
|
+
reader: 1,
|
|
751
|
+
writer: 1,
|
|
752
|
+
},
|
|
753
|
+
});
|
|
754
|
+
if (sharedLock === null) {
|
|
755
|
+
return null;
|
|
756
|
+
}
|
|
757
|
+
const { writer, reader } = sharedLock;
|
|
758
|
+
const unexpiredSlots = reader?.slots.filter((slot) => {
|
|
759
|
+
return slot.expiration === null || slot.expiration > new Date();
|
|
760
|
+
});
|
|
761
|
+
if (writer === null &&
|
|
762
|
+
reader !== null &&
|
|
763
|
+
unexpiredSlots !== undefined &&
|
|
764
|
+
unexpiredSlots.length === 0) {
|
|
765
|
+
return null;
|
|
766
|
+
}
|
|
767
|
+
if (writer === null &&
|
|
768
|
+
reader !== null &&
|
|
769
|
+
unexpiredSlots !== undefined) {
|
|
770
|
+
return {
|
|
771
|
+
writer: null,
|
|
772
|
+
reader: {
|
|
773
|
+
limit: reader.limit,
|
|
774
|
+
acquiredSlots: new Map(unexpiredSlots.map((slot) => [slot.id, slot.expiration])),
|
|
775
|
+
},
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
if (reader === null && writer !== null && writer.expiration === null) {
|
|
779
|
+
return {
|
|
780
|
+
reader: null,
|
|
781
|
+
writer: {
|
|
782
|
+
owner: writer.owner,
|
|
783
|
+
expiration: writer.expiration,
|
|
784
|
+
},
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
if (reader === null &&
|
|
788
|
+
writer !== null &&
|
|
789
|
+
writer.expiration !== null &&
|
|
790
|
+
writer.expiration <= new Date()) {
|
|
791
|
+
return null;
|
|
792
|
+
}
|
|
793
|
+
if (writer !== null) {
|
|
794
|
+
return {
|
|
795
|
+
reader: null,
|
|
796
|
+
writer: {
|
|
797
|
+
owner: writer.owner,
|
|
798
|
+
expiration: writer.expiration,
|
|
799
|
+
},
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
throw new UnexpectedError("Invalid ISharedLockAdapterState, expected either the writer field must be defined, but not both.");
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
//# sourceMappingURL=mongodb-shared-lock-adapter.js.map
|