@daiso-tech/core 0.32.0 → 0.33.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/async/async.errors.d.ts +14 -0
- package/dist/async/async.errors.js +14 -0
- package/dist/async/async.errors.js.map +1 -1
- package/dist/async/async.events.d.ts +23 -0
- package/dist/async/async.events.js +23 -0
- package/dist/async/async.events.js.map +1 -1
- package/dist/async/backof-policies/_shared.d.ts +1 -1
- package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.d.ts +2 -2
- package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js +1 -1
- package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.d.ts +2 -2
- package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +1 -1
- package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.d.ts +2 -2
- package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +1 -1
- package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.d.ts +2 -2
- package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +1 -1
- package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +7 -41
- package/dist/async/utilities/lazy-promise/lazy-promise.js +7 -8
- package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/cache/contracts/cache-factory.contract.d.ts +3 -3
- package/dist/cache/contracts/cache.contract.d.ts +0 -22
- package/dist/cache/contracts/cache.errors.d.ts +14 -1
- package/dist/cache/contracts/cache.errors.js +14 -1
- package/dist/cache/contracts/cache.errors.js.map +1 -1
- package/dist/cache/contracts/cache.events.d.ts +28 -14
- package/dist/cache/contracts/cache.events.js +28 -3
- package/dist/cache/contracts/cache.events.js.map +1 -1
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js +3 -3
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js.map +1 -1
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +0 -1
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js +3 -3
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/cache.d.ts +9 -139
- package/dist/cache/implementations/derivables/cache/cache.js +38 -229
- package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +6 -6
- 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 +2 -2
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +1 -1
- package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +4 -4
- package/dist/cache/implementations/test-utilities/cache.test-suite.js +239 -433
- package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.d.ts +2 -2
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js +1 -1
- package/dist/collection/contracts/collection.errors.d.ts +17 -0
- package/dist/collection/contracts/collection.errors.js +17 -0
- package/dist/collection/contracts/collection.errors.js.map +1 -1
- package/dist/event-bus/contracts/event-bus-factory.contract.d.ts +3 -3
- package/dist/event-bus/contracts/event-bus.contract.d.ts +2 -44
- package/dist/event-bus/contracts/event-bus.contract.js.map +1 -1
- package/dist/event-bus/contracts/event-bus.errors.d.ts +16 -1
- package/dist/event-bus/contracts/event-bus.errors.js +16 -1
- package/dist/event-bus/contracts/event-bus.errors.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +6 -77
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +11 -131
- 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 +4 -4
- 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.d.ts +2 -2
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +4 -4
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +691 -1432
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
- package/dist/lock/contracts/lock-provider-factory.contract.d.ts +3 -3
- package/dist/lock/contracts/lock-provider.contract.d.ts +10 -20
- package/dist/lock/contracts/lock.contract.d.ts +1 -10
- package/dist/lock/contracts/lock.errors.d.ts +18 -0
- package/dist/lock/contracts/lock.errors.js +18 -0
- package/dist/lock/contracts/lock.errors.js.map +1 -1
- package/dist/lock/contracts/lock.events.d.ts +22 -0
- package/dist/lock/contracts/lock.events.js +22 -0
- package/dist/lock/contracts/lock.events.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +12 -155
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +31 -228
- 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 -5
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js +7 -30
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +8 -58
- package/dist/lock/implementations/derivables/lock-provider/lock.js +33 -105
- package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +9 -8
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +2 -2
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +178 -659
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
- package/dist/serde/contracts/deserializer.contract.d.ts +1 -1
- package/dist/serde/contracts/deserializer.contract.js +1 -1
- package/dist/serde/contracts/deserializer.contract.js.map +1 -1
- package/dist/serde/contracts/serde.errors.d.ts +14 -2
- package/dist/serde/contracts/serde.errors.js +16 -4
- package/dist/serde/contracts/serde.errors.js.map +1 -1
- package/dist/serde/contracts/serializer.contract.d.ts +1 -1
- package/dist/serde/contracts/serializer.contract.js +1 -1
- package/dist/serde/contracts/serializer.contract.js.map +1 -1
- package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js +3 -3
- package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/redis-serde/redis-serde.js +3 -3
- package/dist/serde/implementations/adapters/redis-serde/redis-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/sql-serde/sql-serde.js +3 -3
- package/dist/serde/implementations/adapters/sql-serde/sql-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +3 -3
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js.map +1 -1
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.d.ts +2 -2
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js +1 -1
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.d.ts +2 -2
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +1 -1
- package/dist/utilities/classes/key-prefixer/_module.d.ts +0 -1
- package/dist/utilities/classes/key-prefixer/_module.js +0 -1
- package/dist/utilities/classes/key-prefixer/_module.js.map +1 -1
- package/dist/utilities/classes/key-prefixer/key-prefixer.d.ts +2 -11
- package/dist/utilities/classes/key-prefixer/key-prefixer.js +4 -46
- package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -1
- package/dist/utilities/errors.d.ts +2 -0
- package/dist/utilities/errors.js +2 -0
- package/dist/utilities/errors.js.map +1 -1
- package/package.json +3 -4
- package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.d.ts +0 -15
- package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.js +0 -50
- package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.js.map +0 -1
- package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.d.ts +0 -23
- package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.js +0 -44
- package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.js.map +0 -1
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.d.ts +0 -28
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js +0 -5
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js.map +0 -1
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { LazyPromise } from "../../../../async/_module-exports.js";
|
|
5
5
|
import type { EventClass, EventInstance, EventListener, Unsubscribe } from "../../../../event-bus/contracts/_module-exports.js";
|
|
6
|
-
import { type IEventBus, type
|
|
7
|
-
import type {
|
|
6
|
+
import { type IEventBus, type IEventBusAdapter, type BaseEvent } from "../../../../event-bus/contracts/_module-exports.js";
|
|
7
|
+
import type { KeyPrefixer, Factory, AsyncLazy } from "../../../../utilities/_module-exports.js";
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
* IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
|
|
11
11
|
* @group Derivables
|
|
12
12
|
*/
|
|
13
13
|
export type EventBusSettingsBase = {
|
|
14
|
-
keyPrefixer:
|
|
14
|
+
keyPrefixer: KeyPrefixer;
|
|
15
15
|
/**
|
|
16
16
|
* You can pass a <i>{@link Factory}</i> of <i>{@link LazyPromise}</i> to configure default settings for all <i>{@link LazyPromise}</i> instances used in the <i>EventBus</i> class.
|
|
17
17
|
* @default
|
|
@@ -23,19 +23,13 @@ export type EventBusSettingsBase = {
|
|
|
23
23
|
*/
|
|
24
24
|
lazyPromiseFactory?: Factory<AsyncLazy<any>, LazyPromise<any>>;
|
|
25
25
|
};
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
|
|
29
|
-
* @group Derivables
|
|
30
|
-
*/
|
|
31
|
-
export type EventBusAdapterFactoryable = AsyncFactoryable<string, IEventBusAdapter>;
|
|
32
26
|
/**
|
|
33
27
|
*
|
|
34
28
|
* IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
|
|
35
29
|
* @group Derivables
|
|
36
30
|
*/
|
|
37
31
|
export type EventBusSettings = EventBusSettingsBase & {
|
|
38
|
-
adapter:
|
|
32
|
+
adapter: IEventBusAdapter;
|
|
39
33
|
};
|
|
40
34
|
/**
|
|
41
35
|
* <i>EventBus</i> class can be derived from any <i>{@link IEventBusAdapter}</i>.
|
|
@@ -43,10 +37,9 @@ export type EventBusSettings = EventBusSettingsBase & {
|
|
|
43
37
|
* IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
|
|
44
38
|
* @group Derivables
|
|
45
39
|
*/
|
|
46
|
-
export declare class EventBus<TEvents extends BaseEvent = BaseEvent> implements
|
|
47
|
-
private readonly adapterFactoryable;
|
|
40
|
+
export declare class EventBus<TEvents extends BaseEvent = BaseEvent> implements IEventBus<TEvents> {
|
|
48
41
|
private readonly store;
|
|
49
|
-
private readonly
|
|
42
|
+
private readonly adapter;
|
|
50
43
|
private readonly lazyPromiseFactory;
|
|
51
44
|
private keyPrefixer;
|
|
52
45
|
/**
|
|
@@ -61,78 +54,14 @@ export declare class EventBus<TEvents extends BaseEvent = BaseEvent> implements
|
|
|
61
54
|
* adapter: new MemoryEventBusAdapter()
|
|
62
55
|
* });
|
|
63
56
|
* ```
|
|
64
|
-
*
|
|
65
|
-
* You can pass factory function that will create an adapter for every group.
|
|
66
|
-
* @example
|
|
67
|
-
* ```ts
|
|
68
|
-
* import type { IEventBusAdapter } from "@daiso-tech/core/event-bus/contracts";
|
|
69
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
70
|
-
* import { EventBus } from "@daiso-tech/core/event-bus";
|
|
71
|
-
* import { KeyPrefixer, type FactoryFn } from "@daiso-tech/core/utilities";
|
|
72
|
-
*
|
|
73
|
-
* type Store = Partial<Record<string, IEventBusAdapter>>;
|
|
74
|
-
*
|
|
75
|
-
* function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
|
|
76
|
-
* return (prefix) => {
|
|
77
|
-
* let adapter = store[prefix];
|
|
78
|
-
* if (adapter === undefined) {
|
|
79
|
-
* adapter = new MemoryEventBusAdapter();
|
|
80
|
-
* store[prefix] = adapter;
|
|
81
|
-
* }
|
|
82
|
-
* return adapter;
|
|
83
|
-
* }
|
|
84
|
-
* }
|
|
85
|
-
*
|
|
86
|
-
* const store: Store = {}
|
|
87
|
-
* const eventBus = new EventBus({
|
|
88
|
-
* keyPrefixer: new KeyPrefixer("event-bus"),
|
|
89
|
-
* adapter: cahceAdapterFactory(store)
|
|
90
|
-
* });
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* You can also pass factory object that implements <i>{@link IFactoryObject}</i> contract. This useful for depedency injection libraries.
|
|
94
|
-
* @example
|
|
95
|
-
* ```ts
|
|
96
|
-
* import type { IEventBusAdapter } from "@daiso-tech/core/event-bus/contracts";
|
|
97
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
98
|
-
* import { EventBus } from "@daiso-tech/core/event-bus";
|
|
99
|
-
* import { KeyPrefixer, type IFactoryObject, type Promiseable } from "@daiso-tech/core/utilities";
|
|
100
|
-
*
|
|
101
|
-
* type Store = Partial<Record<string, IEventBusAdapter>>;
|
|
102
|
-
*
|
|
103
|
-
* class EventBusAdapterFactory implements IFactoryObject<string, IEventBusAdapter> {
|
|
104
|
-
* constructor(private readonly store: Store) {}
|
|
105
|
-
*
|
|
106
|
-
* async use(prefix: string): Promiseable<IEventBusAdapter> {
|
|
107
|
-
* let adapter = this.store[prefix];
|
|
108
|
-
* if (adapter === undefined) {
|
|
109
|
-
* adapter = new MemoryEventBusAdapter();
|
|
110
|
-
* store[prefix] = adapter;
|
|
111
|
-
* }
|
|
112
|
-
* return adapter;
|
|
113
|
-
* }
|
|
114
|
-
* }
|
|
115
|
-
*
|
|
116
|
-
* const store: Store = {}
|
|
117
|
-
* const eventBus = new EventBus({
|
|
118
|
-
* keyPrefixer: new KeyPrefixer("event-bus"),
|
|
119
|
-
* adapter: new EventBusAdapterFactory(store)
|
|
120
|
-
* });
|
|
121
|
-
* ```
|
|
122
57
|
*/
|
|
123
58
|
constructor(settings: EventBusSettings);
|
|
124
59
|
private createLazyPromise;
|
|
125
|
-
withGroup(group: OneOrMore<string>): IEventBus<TEvents>;
|
|
126
|
-
getGroup(): string | null;
|
|
127
60
|
addListener<TEventClass extends EventClass<TEvents>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
128
61
|
removeListener<TEventClass extends EventClass<TEvents>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
129
|
-
addListenerMany<TEventClassArr extends EventClass<TEvents>[]>(events: [...TEventClassArr], listener: EventListener<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
|
|
130
|
-
removeListenerMany<TEventClassArr extends EventClass<TEvents>[]>(events: [...TEventClassArr], listener: EventListener<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
|
|
131
62
|
listenOnce<TEventClass extends EventClass<TEvents>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
132
63
|
asPromise<TEventClass extends EventClass<TEvents>>(event: TEventClass): LazyPromise<EventInstance<TEventClass>>;
|
|
133
64
|
subscribeOnce<TEventClass extends EventClass<TEvents>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
|
|
134
65
|
subscribe<TEventClass extends EventClass<TEvents>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
|
|
135
|
-
subscribeMany<TEventClassArr extends EventClass<TEvents>[]>(events: [...TEventClassArr], listener: EventListener<EventInstance<Items<TEventClassArr>>>): LazyPromise<Unsubscribe>;
|
|
136
|
-
dispatchMany(events: TEvents[]): LazyPromise<void>;
|
|
137
66
|
dispatch(event: TEvents): LazyPromise<void>;
|
|
138
67
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { LazyPromise } from "../../../../async/_module-exports.js";
|
|
5
5
|
import { UnableToDispatchEventBusError, UnableToRemoveListenerEventBusError, UnableToAddListenerEventBusError, } from "../../../../event-bus/contracts/_module-exports.js";
|
|
6
|
-
import { getConstructorName,
|
|
6
|
+
import { getConstructorName, resolveFactory, resolveInvokable, } from "../../../../utilities/_module-exports.js";
|
|
7
7
|
import { ListenerStore } from "../../../../event-bus/implementations/derivables/event-bus/listener-store.js";
|
|
8
8
|
/**
|
|
9
9
|
* <i>EventBus</i> class can be derived from any <i>{@link IEventBusAdapter}</i>.
|
|
@@ -12,9 +12,8 @@ import { ListenerStore } from "../../../../event-bus/implementations/derivables/
|
|
|
12
12
|
* @group Derivables
|
|
13
13
|
*/
|
|
14
14
|
export class EventBus {
|
|
15
|
-
adapterFactoryable;
|
|
16
15
|
store = new ListenerStore();
|
|
17
|
-
|
|
16
|
+
adapter;
|
|
18
17
|
lazyPromiseFactory;
|
|
19
18
|
keyPrefixer;
|
|
20
19
|
/**
|
|
@@ -29,92 +28,22 @@ export class EventBus {
|
|
|
29
28
|
* adapter: new MemoryEventBusAdapter()
|
|
30
29
|
* });
|
|
31
30
|
* ```
|
|
32
|
-
*
|
|
33
|
-
* You can pass factory function that will create an adapter for every group.
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* import type { IEventBusAdapter } from "@daiso-tech/core/event-bus/contracts";
|
|
37
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
38
|
-
* import { EventBus } from "@daiso-tech/core/event-bus";
|
|
39
|
-
* import { KeyPrefixer, type FactoryFn } from "@daiso-tech/core/utilities";
|
|
40
|
-
*
|
|
41
|
-
* type Store = Partial<Record<string, IEventBusAdapter>>;
|
|
42
|
-
*
|
|
43
|
-
* function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
|
|
44
|
-
* return (prefix) => {
|
|
45
|
-
* let adapter = store[prefix];
|
|
46
|
-
* if (adapter === undefined) {
|
|
47
|
-
* adapter = new MemoryEventBusAdapter();
|
|
48
|
-
* store[prefix] = adapter;
|
|
49
|
-
* }
|
|
50
|
-
* return adapter;
|
|
51
|
-
* }
|
|
52
|
-
* }
|
|
53
|
-
*
|
|
54
|
-
* const store: Store = {}
|
|
55
|
-
* const eventBus = new EventBus({
|
|
56
|
-
* keyPrefixer: new KeyPrefixer("event-bus"),
|
|
57
|
-
* adapter: cahceAdapterFactory(store)
|
|
58
|
-
* });
|
|
59
|
-
* ```
|
|
60
|
-
*
|
|
61
|
-
* You can also pass factory object that implements <i>{@link IFactoryObject}</i> contract. This useful for depedency injection libraries.
|
|
62
|
-
* @example
|
|
63
|
-
* ```ts
|
|
64
|
-
* import type { IEventBusAdapter } from "@daiso-tech/core/event-bus/contracts";
|
|
65
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
66
|
-
* import { EventBus } from "@daiso-tech/core/event-bus";
|
|
67
|
-
* import { KeyPrefixer, type IFactoryObject, type Promiseable } from "@daiso-tech/core/utilities";
|
|
68
|
-
*
|
|
69
|
-
* type Store = Partial<Record<string, IEventBusAdapter>>;
|
|
70
|
-
*
|
|
71
|
-
* class EventBusAdapterFactory implements IFactoryObject<string, IEventBusAdapter> {
|
|
72
|
-
* constructor(private readonly store: Store) {}
|
|
73
|
-
*
|
|
74
|
-
* async use(prefix: string): Promiseable<IEventBusAdapter> {
|
|
75
|
-
* let adapter = this.store[prefix];
|
|
76
|
-
* if (adapter === undefined) {
|
|
77
|
-
* adapter = new MemoryEventBusAdapter();
|
|
78
|
-
* store[prefix] = adapter;
|
|
79
|
-
* }
|
|
80
|
-
* return adapter;
|
|
81
|
-
* }
|
|
82
|
-
* }
|
|
83
|
-
*
|
|
84
|
-
* const store: Store = {}
|
|
85
|
-
* const eventBus = new EventBus({
|
|
86
|
-
* keyPrefixer: new KeyPrefixer("event-bus"),
|
|
87
|
-
* adapter: new EventBusAdapterFactory(store)
|
|
88
|
-
* });
|
|
89
|
-
* ```
|
|
90
31
|
*/
|
|
91
32
|
constructor(settings) {
|
|
92
33
|
const { keyPrefixer, adapter, lazyPromiseFactory = (invokable) => new LazyPromise(invokable), } = settings;
|
|
93
34
|
this.lazyPromiseFactory = resolveFactory(lazyPromiseFactory);
|
|
94
|
-
this.
|
|
35
|
+
this.adapter = adapter;
|
|
95
36
|
this.keyPrefixer = keyPrefixer;
|
|
96
|
-
this.adapterPromise = new LazyPromise(() => resolveAsyncFactoryable(this.adapterFactoryable, this.keyPrefixer.keyPrefix));
|
|
97
37
|
}
|
|
98
38
|
createLazyPromise(asyncFn) {
|
|
99
39
|
return this.lazyPromiseFactory(asyncFn);
|
|
100
40
|
}
|
|
101
|
-
withGroup(group) {
|
|
102
|
-
return new EventBus({
|
|
103
|
-
keyPrefixer: this.keyPrefixer.withGroup(group),
|
|
104
|
-
adapter: this.adapterFactoryable,
|
|
105
|
-
lazyPromiseFactory: this.lazyPromiseFactory,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
getGroup() {
|
|
109
|
-
return this.keyPrefixer.resolvedGroup;
|
|
110
|
-
}
|
|
111
41
|
addListener(event, listener) {
|
|
112
42
|
return this.createLazyPromise(async () => {
|
|
113
43
|
const eventName = this.keyPrefixer.create(event.name);
|
|
114
44
|
const resolvedListener = this.store.getOrAdd([eventName.prefixed, listener], resolveInvokable(listener));
|
|
115
45
|
try {
|
|
116
|
-
|
|
117
|
-
await adapter.addListener(eventName.prefixed, resolvedListener);
|
|
46
|
+
await this.adapter.addListener(eventName.prefixed, resolvedListener);
|
|
118
47
|
}
|
|
119
48
|
catch (error) {
|
|
120
49
|
this.store.getAndRemove([eventName.prefixed, listener]);
|
|
@@ -133,38 +62,13 @@ export class EventBus {
|
|
|
133
62
|
return;
|
|
134
63
|
}
|
|
135
64
|
try {
|
|
136
|
-
|
|
137
|
-
await adapter.removeListener(eventName.prefixed, resolvedListener);
|
|
65
|
+
await this.adapter.removeListener(eventName.prefixed, resolvedListener);
|
|
138
66
|
}
|
|
139
67
|
catch (error) {
|
|
140
68
|
throw new UnableToRemoveListenerEventBusError(`A listener with name of "${resolvedListener.name}" could not removed of "${String(event)}" event`, error);
|
|
141
69
|
}
|
|
142
70
|
});
|
|
143
71
|
}
|
|
144
|
-
addListenerMany(events, listener) {
|
|
145
|
-
return this.createLazyPromise(async () => {
|
|
146
|
-
if (events.length === 0) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
const promises = [];
|
|
150
|
-
for (const event of events) {
|
|
151
|
-
promises.push(this.addListener(event, listener));
|
|
152
|
-
}
|
|
153
|
-
await Promise.all(promises);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
removeListenerMany(events, listener) {
|
|
157
|
-
return this.createLazyPromise(async () => {
|
|
158
|
-
if (events.length === 0) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
const promises = [];
|
|
162
|
-
for (const event of events) {
|
|
163
|
-
promises.push(this.removeListener(event, listener));
|
|
164
|
-
}
|
|
165
|
-
await Promise.all(promises);
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
72
|
listenOnce(event, listener) {
|
|
169
73
|
return this.createLazyPromise(async () => {
|
|
170
74
|
const wrappedListener = async (event_) => {
|
|
@@ -179,8 +83,7 @@ export class EventBus {
|
|
|
179
83
|
const eventName = this.keyPrefixer.create(event.name);
|
|
180
84
|
const resolvedListener = this.store.getOrAdd([eventName.prefixed, listener], wrappedListener);
|
|
181
85
|
try {
|
|
182
|
-
|
|
183
|
-
await adapter.addListener(eventName.prefixed, resolvedListener);
|
|
86
|
+
await this.adapter.addListener(eventName.prefixed, resolvedListener);
|
|
184
87
|
}
|
|
185
88
|
catch (error) {
|
|
186
89
|
this.store.getAndRemove([eventName.prefixed, listener]);
|
|
@@ -205,48 +108,25 @@ export class EventBus {
|
|
|
205
108
|
});
|
|
206
109
|
}
|
|
207
110
|
subscribe(event, listener) {
|
|
208
|
-
return this.subscribeMany([event], listener);
|
|
209
|
-
}
|
|
210
|
-
subscribeMany(events, listener) {
|
|
211
111
|
return this.createLazyPromise(async () => {
|
|
212
|
-
await this.
|
|
112
|
+
await this.addListener(event, listener);
|
|
213
113
|
const unsubscribe = () => {
|
|
214
114
|
return this.createLazyPromise(async () => {
|
|
215
|
-
await this.
|
|
115
|
+
await this.removeListener(event, listener);
|
|
216
116
|
});
|
|
217
117
|
};
|
|
218
118
|
return unsubscribe;
|
|
219
119
|
});
|
|
220
120
|
}
|
|
221
|
-
|
|
121
|
+
dispatch(event) {
|
|
222
122
|
return this.createLazyPromise(async () => {
|
|
223
123
|
try {
|
|
224
|
-
|
|
225
|
-
const promises = events
|
|
226
|
-
.map((event) => ({
|
|
227
|
-
eventName: getConstructorName(event),
|
|
228
|
-
event,
|
|
229
|
-
}))
|
|
230
|
-
.map(({ event, eventName }) => ({
|
|
231
|
-
eventName: this.keyPrefixer.create(eventName),
|
|
232
|
-
event,
|
|
233
|
-
}))
|
|
234
|
-
.map(({ event, eventName }) => ({
|
|
235
|
-
eventName: eventName.prefixed,
|
|
236
|
-
event,
|
|
237
|
-
}))
|
|
238
|
-
.map(({ eventName, event }) => adapter.dispatch(eventName, event));
|
|
239
|
-
await Promise.all(promises);
|
|
124
|
+
await this.adapter.dispatch(this.keyPrefixer.create(getConstructorName(event)).prefixed, event);
|
|
240
125
|
}
|
|
241
126
|
catch (error) {
|
|
242
|
-
throw new UnableToDispatchEventBusError(`Events of type
|
|
127
|
+
throw new UnableToDispatchEventBusError(`Events of type "${getConstructorName(event)}" could not be dispatched`, error);
|
|
243
128
|
}
|
|
244
129
|
});
|
|
245
130
|
}
|
|
246
|
-
dispatch(event) {
|
|
247
|
-
return this.createLazyPromise(async () => {
|
|
248
|
-
await this.dispatchMany([event]);
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
131
|
}
|
|
252
132
|
//# sourceMappingURL=event-bus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus/event-bus.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAQzD,OAAO,
|
|
1
|
+
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus/event-bus.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAQzD,OAAO,EAIH,6BAA6B,EAC7B,mCAAmC,EACnC,gCAAgC,GACnC,MAAM,0CAA0C,CAAC;AAQlD,OAAO,EACH,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,oEAAoE,CAAC;AA+BnG;;;;;GAKG;AACH,MAAM,OAAO,QAAQ;IAGA,KAAK,GAAG,IAAI,aAAa,EAAE,CAAC;IAC5B,OAAO,CAAmB;IAC1B,kBAAkB,CAGjC;IACM,WAAW,CAAc;IAEjC;;;;;;;;;;;;OAYG;IACH,YAAY,QAA0B;QAClC,MAAM,EACF,WAAW,EACX,OAAO,EACP,kBAAkB,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,WAAW,CAAC,SAAS,CAAC,GACjE,GAAG,QAAQ,CAAC;QACb,IAAI,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I,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;gBAC/C,CAAC,CAAC,CAAC;YACP,CAAC,CAAC;YACF,OAAO,WAAW,CAAC;QACvB,CAAC,CAAC,CAAC;IACP,CAAC;IAED,QAAQ,CAAC,KAAc;QACnB,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,IAAI,EAAE;YACrC,IAAI,CAAC;gBACD,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CACvB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,EAC3D,KAAK,CACR,CAAC;YACN,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACtB,MAAM,IAAI,6BAA6B,CACnC,mBAAmB,kBAAkB,CAAC,KAAK,CAAC,2BAA2B,EACvE,KAAK,CACR,CAAC;YACN,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
4
|
import type { LazyPromise } from "../../../../async/_module-exports.js";
|
|
5
|
-
import { type
|
|
6
|
-
import { type
|
|
5
|
+
import { type IEventBus, type IEventBusFactory, type BaseEvent, type IEventBusAdapter } from "../../../../event-bus/contracts/_module-exports.js";
|
|
6
|
+
import { type EventBusSettingsBase } from "../../../../event-bus/implementations/derivables/event-bus/_module.js";
|
|
7
7
|
import type { AsyncLazy, Factory, KeyPrefixer } from "../../../../utilities/_module-exports.js";
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
* IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
|
|
11
11
|
* @group Derivables
|
|
12
12
|
*/
|
|
13
|
-
export type EventBusAdapters<TAdapters extends string = string> = Partial<Record<TAdapters,
|
|
13
|
+
export type EventBusAdapters<TAdapters extends string = string> = Partial<Record<TAdapters, IEventBusAdapter>>;
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
16
16
|
* IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
|
|
@@ -126,5 +126,5 @@ export declare class EventBusFactory<TAdapters extends string = string> implemen
|
|
|
126
126
|
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
127
127
|
* ```
|
|
128
128
|
*/
|
|
129
|
-
use<TEvents extends BaseEvent = BaseEvent>(adapterName?: TAdapters | undefined):
|
|
129
|
+
use<TEvents extends BaseEvent = BaseEvent>(adapterName?: TAdapters | undefined): IEventBus<TEvents>;
|
|
130
130
|
}
|
package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus-factory.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"event-bus-factory.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAKN,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACH,QAAQ,GAEX,MAAM,6DAA6D,CAAC;AAMrE,OAAO,EACH,6BAA6B,EAC7B,wBAAwB,GAC3B,MAAM,gCAAgC,CAAC;AAuBxC;;;;GAIG;AACH,MAAM,OAAO,eAAe;IA6CH;IA1CrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,YACqB,QAA4C;QAA5C,aAAQ,GAAR,QAAQ,CAAoC;IAC9D,CAAC;IAEJ,cAAc,CAAC,WAAwB;QACnC,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,WAAW;SACd,CAAC,CAAC;IACP,CAAC;IAED,qBAAqB,CACjB,OAAkD;QAElD,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,kBAAkB,EAAE,OAAO;SAC9B,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsDG;IACH,GAAG,CACC,cAAqC,IAAI,CAAC,QAAQ,CAAC,cAAc;QAEjE,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,6BAA6B,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAClE,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,wBAAwB,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,IAAI,QAAQ,CAAC;YAChB,OAAO;YACP,GAAG,IAAI,CAAC,QAAQ;SACnB,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -8,7 +8,7 @@ import type { IFlexibleSerde } from "../../../serde/contracts/_module-exports.js
|
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
* IMPORT_PATH: ```"@daiso-tech/core/event-bus/test-utilities"```
|
|
11
|
-
* @group
|
|
11
|
+
* @group TestUtilities
|
|
12
12
|
*/
|
|
13
13
|
export type EventBusAdapterTestSuiteSettings = {
|
|
14
14
|
expect: ExpectStatic;
|
|
@@ -22,6 +22,6 @@ export type EventBusAdapterTestSuiteSettings = {
|
|
|
22
22
|
* The <i>eventBusAdapterTestSuite</i> function simplifies the process of testing your custom implementation of <i>{@link IEventBusAdapter}</i> with vitest.
|
|
23
23
|
*
|
|
24
24
|
* IMPORT_PATH: ```"@daiso-tech/core/event-bus/test-utilities"```
|
|
25
|
-
* @group
|
|
25
|
+
* @group TestUtilities
|
|
26
26
|
*/
|
|
27
27
|
export declare function eventBusAdapterTestSuite(settings: EventBusAdapterTestSuiteSettings): void;
|
|
@@ -12,7 +12,7 @@ import { NoOpSerdeAdapter } from "../../../serde/implementations/adapters/_modul
|
|
|
12
12
|
* The <i>eventBusAdapterTestSuite</i> function simplifies the process of testing your custom implementation of <i>{@link IEventBusAdapter}</i> with vitest.
|
|
13
13
|
*
|
|
14
14
|
* IMPORT_PATH: ```"@daiso-tech/core/event-bus/test-utilities"```
|
|
15
|
-
* @group
|
|
15
|
+
* @group TestUtilities
|
|
16
16
|
*/
|
|
17
17
|
export function eventBusAdapterTestSuite(settings) {
|
|
18
18
|
const { expect, test, createAdapter, beforeEach, serde = new Serde(new NoOpSerdeAdapter()), } = settings;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
4
|
import { type TestAPI, type SuiteAPI, type ExpectStatic, type beforeEach } from "vitest";
|
|
5
|
-
import { type
|
|
5
|
+
import { type IEventBus } from "../../../event-bus/contracts/_module-exports.js";
|
|
6
6
|
import { type Promisable } from "../../../utilities/_module-exports.js";
|
|
7
7
|
import type { IFlexibleSerde } from "../../../serde/contracts/_module-exports.js";
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
* IMPORT_PATH: ```"@daiso-tech/core/event-bus/test-utilities"```
|
|
11
|
-
* @group
|
|
11
|
+
* @group TestUtilities
|
|
12
12
|
*/
|
|
13
13
|
export type EventBusTestSuiteSettings = {
|
|
14
14
|
expect: ExpectStatic;
|
|
@@ -16,12 +16,12 @@ export type EventBusTestSuiteSettings = {
|
|
|
16
16
|
test: TestAPI;
|
|
17
17
|
describe: SuiteAPI;
|
|
18
18
|
beforeEach: typeof beforeEach;
|
|
19
|
-
createEventBus: () => Promisable<
|
|
19
|
+
createEventBus: () => Promisable<IEventBus>;
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
22
|
* The <i>eventBusTestSuite</i> function simplifies the process of testing your custom implementation of <i>{@link IEventBus}</i> with vitest.
|
|
23
23
|
*
|
|
24
24
|
* IMPORT_PATH: ```"@daiso-tech/core/event-bus/test-utilities"```
|
|
25
|
-
* @group
|
|
25
|
+
* @group TestUtilities
|
|
26
26
|
*/
|
|
27
27
|
export declare function eventBusTestSuite(settings: EventBusTestSuiteSettings): void;
|