@daiso-tech/core 0.34.0 → 0.35.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/README.md +2 -4
- package/dist/async/_module-exports.d.ts +0 -1
- package/dist/async/_module-exports.js +0 -1
- package/dist/async/_module-exports.js.map +1 -1
- package/dist/async/async.errors.d.ts +19 -12
- package/dist/async/async.errors.js +27 -16
- package/dist/async/async.errors.js.map +1 -1
- package/dist/async/middlewares/_module.d.ts +3 -0
- package/dist/async/middlewares/_module.js +3 -0
- package/dist/async/middlewares/_module.js.map +1 -1
- package/dist/async/middlewares/_shared.d.ts +10 -0
- package/dist/async/middlewares/_shared.js +5 -0
- package/dist/async/middlewares/_shared.js.map +1 -0
- package/dist/async/middlewares/bulkhead/_module.d.ts +1 -0
- package/dist/async/middlewares/bulkhead/_module.js +2 -0
- package/dist/async/middlewares/bulkhead/_module.js.map +1 -0
- package/dist/async/middlewares/bulkhead/bulkhead.middleware.d.ts +80 -0
- package/dist/async/middlewares/bulkhead/bulkhead.middleware.js +46 -0
- package/dist/async/middlewares/bulkhead/bulkhead.middleware.js.map +1 -0
- package/dist/async/middlewares/dynamic/dynamic.middleware.d.ts +2 -2
- package/dist/async/middlewares/dynamic/dynamic.middleware.js +5 -5
- package/dist/async/middlewares/dynamic/dynamic.middleware.js.map +1 -1
- package/dist/async/middlewares/fallback/fallback.middleware.d.ts +10 -8
- package/dist/async/middlewares/fallback/fallback.middleware.js +1 -1
- package/dist/async/middlewares/fallback/fallback.middleware.js.map +1 -1
- package/dist/async/middlewares/hedging/_module.d.ts +2 -0
- package/dist/async/middlewares/hedging/_module.js +3 -0
- package/dist/async/middlewares/hedging/_module.js.map +1 -0
- package/dist/async/middlewares/hedging/_shared.d.ts +93 -0
- package/dist/async/middlewares/hedging/_shared.js +5 -0
- package/dist/async/middlewares/hedging/_shared.js.map +1 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/_module.d.ts +1 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/_module.js +2 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/_module.js.map +1 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.d.ts +51 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js +138 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js.map +1 -0
- package/dist/async/middlewares/hedging/sequential-hedging/_module.d.ts +1 -0
- package/dist/async/middlewares/hedging/sequential-hedging/_module.js +2 -0
- package/dist/async/middlewares/hedging/sequential-hedging/_module.js.map +1 -0
- package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.d.ts +51 -0
- package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js +104 -0
- package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js.map +1 -0
- package/dist/async/middlewares/observe/observe.middleware.d.ts +14 -16
- package/dist/async/middlewares/observe/observe.middleware.js +1 -1
- package/dist/async/middlewares/observe/observe.middleware.js.map +1 -1
- package/dist/async/middlewares/retry/retry.middleware.d.ts +41 -36
- package/dist/async/middlewares/retry/retry.middleware.js +31 -28
- package/dist/async/middlewares/retry/retry.middleware.js.map +1 -1
- package/dist/async/middlewares/timeout/timeout.middleware.d.ts +34 -39
- package/dist/async/middlewares/timeout/timeout.middleware.js +30 -47
- package/dist/async/middlewares/timeout/timeout.middleware.js.map +1 -1
- package/dist/async/utilities/_module.d.ts +2 -0
- package/dist/async/utilities/_module.js +2 -0
- package/dist/async/utilities/_module.js.map +1 -1
- package/dist/async/utilities/abort-and-fail/abort-and-fail.d.ts +3 -0
- package/dist/async/utilities/abort-and-fail/abort-and-fail.js +6 -7
- package/dist/async/utilities/abort-and-fail/abort-and-fail.js.map +1 -1
- package/dist/async/utilities/lazy-promise/lazy-promise.js +0 -1
- package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/async/utilities/promise-queue/_module.d.ts +1 -0
- package/dist/async/utilities/promise-queue/_module.js +2 -0
- package/dist/async/utilities/promise-queue/_module.js.map +1 -0
- package/dist/async/utilities/promise-queue/promise-queue.d.ts +32 -0
- package/dist/async/utilities/promise-queue/promise-queue.js +107 -0
- package/dist/async/utilities/promise-queue/promise-queue.js.map +1 -0
- package/dist/async/utilities/timeout-and-fail/_module.d.ts +1 -0
- package/dist/async/utilities/timeout-and-fail/_module.js +2 -0
- package/dist/async/utilities/timeout-and-fail/_module.js.map +1 -0
- package/dist/async/utilities/timeout-and-fail/timeout-and-fail.d.ts +7 -0
- package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js +19 -0
- package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js.map +1 -0
- package/dist/cache/contracts/cache.contract.d.ts +2 -2
- package/dist/cache/contracts/cache.events.d.ts +43 -47
- package/dist/cache/contracts/cache.events.js +5 -103
- package/dist/cache/contracts/cache.events.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/cache.d.ts +15 -15
- package/dist/cache/implementations/derivables/cache/cache.js +94 -79
- package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +1 -1
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache.test-suite.js +138 -147
- package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
- package/dist/event-bus/contracts/_module-exports.d.ts +0 -1
- package/dist/event-bus/contracts/_module-exports.js +0 -1
- package/dist/event-bus/contracts/_module-exports.js.map +1 -1
- package/dist/event-bus/contracts/event-bus-adapter.contract.d.ts +6 -1
- package/dist/event-bus/contracts/event-bus-factory.contract.d.ts +2 -3
- package/dist/event-bus/contracts/event-bus-factory.contract.js.map +1 -1
- package/dist/event-bus/contracts/event-bus.contract.d.ts +12 -23
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +10 -10
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +30 -30
- 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 +13 -7
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +11 -5
- 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 +0 -2
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +13 -20
- 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.d.ts +0 -2
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +187 -207
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
- package/dist/lock/contracts/lock-provider.contract.d.ts +2 -2
- package/dist/lock/contracts/lock.events.d.ts +35 -44
- package/dist/lock/contracts/lock.events.js +8 -90
- package/dist/lock/contracts/lock.events.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +9 -9
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +12 -12
- 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 +2 -2
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +2 -2
- package/dist/lock/implementations/derivables/lock-provider/lock.js +69 -50
- 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 +1 -1
- 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.js +212 -212
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
- package/dist/serde/contracts/flexible-serde.contract.d.ts +0 -11
- package/dist/serde/implementations/derivables/serde.d.ts +1 -32
- package/dist/serde/implementations/derivables/serde.js +0 -45
- package/dist/serde/implementations/derivables/serde.js.map +1 -1
- package/dist/utilities/classes/hooks/async-hooks.d.ts +107 -20
- package/dist/utilities/classes/hooks/async-hooks.js +47 -18
- package/dist/utilities/classes/hooks/async-hooks.js.map +1 -1
- package/dist/utilities/classes/hooks/hooks.d.ts +39 -21
- package/dist/utilities/classes/hooks/hooks.js +19 -18
- package/dist/utilities/classes/hooks/hooks.js.map +1 -1
- package/dist/utilities/classes/key-prefixer/key-prefixer.js +2 -2
- package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -1
- package/dist/utilities/contracts/_module.d.ts +0 -1
- package/dist/utilities/contracts/_module.js +0 -1
- package/dist/utilities/contracts/_module.js.map +1 -1
- package/dist/utilities/functions/invokable.d.ts +9 -5
- package/dist/utilities/functions/invokable.js +10 -0
- package/dist/utilities/functions/invokable.js.map +1 -1
- package/package.json +22 -2
- package/dist/async/async.events.d.ts +0 -105
- package/dist/async/async.events.js +0 -82
- package/dist/async/async.events.js.map +0 -1
- package/dist/event-bus/contracts/_shared.d.ts +0 -12
- package/dist/event-bus/contracts/_shared.js +0 -15
- package/dist/event-bus/contracts/_shared.js.map +0 -1
- package/dist/test.d.ts +0 -1
- package/dist/test.js +0 -34
- package/dist/test.js.map +0 -1
- package/dist/utilities/contracts/sync-event-bus-listenable.d.ts +0 -13
- package/dist/utilities/contracts/sync-event-bus-listenable.js +0 -5
- package/dist/utilities/contracts/sync-event-bus-listenable.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeout-and-fail.js","sourceRoot":"","sources":["../../../../src/async/utilities/timeout-and-fail/timeout-and-fail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAChC,OAA4B,EAC5B,IAAc,EACd,KAAmC,EACnC,MAAmB;IAEnB,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;QAC9B,KAAK,CAAC,IAAI,iBAAiB,CAAC,0BAA0B,CAAC,CAAC,CAAC;IAC7D,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IAC1B,IAAI,CAAC;QACD,OAAO,MAAM,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;YAAS,CAAC;QACP,YAAY,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;AACL,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { LazyPromise } from "../../async/_module-exports.js";
|
|
5
5
|
import type { TimeSpan } from "../../utilities/_module-exports.js";
|
|
6
6
|
import type { AsyncLazyable, NoneFunc, OneOrMore } from "../../utilities/_module-exports.js";
|
|
7
|
-
import type {
|
|
7
|
+
import type { CacheEventMap } from "../../cache/contracts/cache.events.js";
|
|
8
8
|
import type { IEventListenable } from "../../event-bus/contracts/_module-exports.js";
|
|
9
9
|
/**
|
|
10
10
|
* The `ICacheListenable` contract defines a way for listening {@link ICache | `ICache`} operation events.
|
|
@@ -12,7 +12,7 @@ import type { IEventListenable } from "../../event-bus/contracts/_module-exports
|
|
|
12
12
|
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
13
13
|
* @group Contracts
|
|
14
14
|
*/
|
|
15
|
-
export type ICacheListenable<TType = unknown> = IEventListenable<
|
|
15
|
+
export type ICacheListenable<TType = unknown> = IEventListenable<CacheEventMap<TType>>;
|
|
16
16
|
/**
|
|
17
17
|
* The `ICacheBase` contract defines a way for as key-value pairs independent of data storage.
|
|
18
18
|
*
|
|
@@ -1,131 +1,127 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Cache
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import type { IFlexibleSerde } from "../../serde/contracts/_module-exports.js";
|
|
6
|
-
import { type OneOrMore, type TimeSpan } from "../../utilities/_module-exports.js";
|
|
4
|
+
import type { TimeSpan } from "../../utilities/_module-exports.js";
|
|
7
5
|
/**
|
|
8
6
|
* The event is dispatched when key is found.
|
|
9
7
|
*
|
|
10
8
|
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
11
9
|
* @group Events
|
|
12
10
|
*/
|
|
13
|
-
export
|
|
11
|
+
export type FoundCacheEventt<TType = unknown> = {
|
|
14
12
|
key: string;
|
|
15
13
|
value: TType;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
14
|
+
};
|
|
18
15
|
/**
|
|
19
16
|
* The event is dispatched when key is not found.
|
|
20
17
|
*
|
|
21
18
|
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
22
19
|
* @group Events
|
|
23
20
|
*/
|
|
24
|
-
export
|
|
21
|
+
export type NotFoundCacheEvent = {
|
|
25
22
|
key: string;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
23
|
+
};
|
|
28
24
|
/**
|
|
29
25
|
* The event is dispatched when key is added.
|
|
30
26
|
*
|
|
31
27
|
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
32
28
|
* @group Events
|
|
33
29
|
*/
|
|
34
|
-
export
|
|
30
|
+
export type AddedCacheEvent<TType = unknown> = {
|
|
31
|
+
type: "added";
|
|
35
32
|
key: string;
|
|
36
33
|
value: TType;
|
|
37
34
|
ttl: TimeSpan | null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
35
|
+
};
|
|
40
36
|
/**
|
|
41
37
|
* The event is dispatched when key is updated.
|
|
42
38
|
*
|
|
43
39
|
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
44
40
|
* @group Events
|
|
45
41
|
*/
|
|
46
|
-
export
|
|
42
|
+
export type UpdatedCacheEvent<TType = unknown> = {
|
|
43
|
+
type: "updated";
|
|
47
44
|
key: string;
|
|
48
45
|
value: TType;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
46
|
+
};
|
|
51
47
|
/**
|
|
52
48
|
* The event is dispatched when key is removed.
|
|
53
49
|
*
|
|
54
50
|
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
55
51
|
* @group Events
|
|
56
52
|
*/
|
|
57
|
-
export
|
|
53
|
+
export type RemovedCacheEvent = {
|
|
54
|
+
type: "removed";
|
|
58
55
|
key: string;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
56
|
+
};
|
|
61
57
|
/**
|
|
62
58
|
* The event is dispatched when key is incremented.
|
|
63
59
|
*
|
|
64
60
|
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
65
61
|
* @group Events
|
|
66
62
|
*/
|
|
67
|
-
export
|
|
63
|
+
export type IncrementedCacheEvent = {
|
|
64
|
+
type: "incremented";
|
|
68
65
|
key: string;
|
|
69
66
|
value: number;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
67
|
+
};
|
|
72
68
|
/**
|
|
73
69
|
* The event is dispatched when key is decremented.
|
|
74
70
|
*
|
|
75
71
|
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
76
72
|
* @group Events
|
|
77
73
|
*/
|
|
78
|
-
export
|
|
74
|
+
export type DecrementedCacheEvent = {
|
|
75
|
+
type: "decremented";
|
|
79
76
|
key: string;
|
|
80
77
|
value: number;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
78
|
+
};
|
|
83
79
|
/**
|
|
84
|
-
* The event is dispatched when
|
|
80
|
+
* The event is dispatched when key is updated or added.
|
|
85
81
|
*
|
|
86
82
|
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
87
83
|
* @group Events
|
|
88
84
|
*/
|
|
89
|
-
export
|
|
90
|
-
}
|
|
85
|
+
export type WrittenCacheEvent<TType = unknown> = AddedCacheEvent<TType> | UpdatedCacheEvent<TType> | RemovedCacheEvent | IncrementedCacheEvent | DecrementedCacheEvent;
|
|
91
86
|
/**
|
|
87
|
+
* The event is dispatched when all keys all cleared of the cache.
|
|
92
88
|
*
|
|
93
89
|
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
94
90
|
* @group Events
|
|
95
91
|
*/
|
|
96
|
-
export
|
|
97
|
-
keys?: string[];
|
|
98
|
-
value?: unknown;
|
|
99
|
-
method: string;
|
|
100
|
-
error: unknown;
|
|
101
|
-
}> {
|
|
102
|
-
}
|
|
92
|
+
export type ClearedCacheEvent = {};
|
|
103
93
|
/**
|
|
104
94
|
*
|
|
105
95
|
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
106
96
|
* @group Events
|
|
107
97
|
*/
|
|
108
|
-
export
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
KeyRemoved: typeof KeyRemovedCacheEvent;
|
|
114
|
-
KeyIncremented: typeof KeyIncrementedCacheEvent;
|
|
115
|
-
KeyDecremented: typeof KeyDecrementedCacheEvent;
|
|
116
|
-
KeysCleared: typeof KeysClearedCacheEvent;
|
|
117
|
-
UnexpectedError: typeof UnexpectedErrorCacheEvent;
|
|
98
|
+
export type UnexpectedErrorCacheEvent = {
|
|
99
|
+
keys?: string[];
|
|
100
|
+
value?: unknown;
|
|
101
|
+
method: string;
|
|
102
|
+
error: unknown;
|
|
118
103
|
};
|
|
119
104
|
/**
|
|
120
105
|
*
|
|
121
106
|
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
122
107
|
* @group Events
|
|
123
108
|
*/
|
|
124
|
-
export
|
|
109
|
+
export declare const CACHE_EVENTS: {
|
|
110
|
+
readonly FOUND: "FOUND";
|
|
111
|
+
readonly NOT_FOUND: "NOT_FOUND";
|
|
112
|
+
readonly WRITTEN: "WRITTEN";
|
|
113
|
+
readonly CLEARED: "CLEARED";
|
|
114
|
+
readonly UNEXPECTED_ERROR: "UNEXPECTED_ERROR";
|
|
115
|
+
};
|
|
125
116
|
/**
|
|
126
|
-
* The `registerCacheEventsToSerde` function registers all {@link ICache | `ICache`} related events with `IFlexibleSerde`, ensuring they will properly be serialized and deserialized.
|
|
127
117
|
*
|
|
128
118
|
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
129
119
|
* @group Events
|
|
130
120
|
*/
|
|
131
|
-
export
|
|
121
|
+
export type CacheEventMap<TType = unknown> = {
|
|
122
|
+
[CACHE_EVENTS.FOUND]: FoundCacheEventt<TType>;
|
|
123
|
+
[CACHE_EVENTS.NOT_FOUND]: NotFoundCacheEvent;
|
|
124
|
+
[CACHE_EVENTS.WRITTEN]: WrittenCacheEvent<TType>;
|
|
125
|
+
[CACHE_EVENTS.CLEARED]: ClearedCacheEvent;
|
|
126
|
+
[CACHE_EVENTS.UNEXPECTED_ERROR]: UnexpectedErrorCacheEvent;
|
|
127
|
+
};
|
|
@@ -1,114 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Cache
|
|
3
3
|
*/
|
|
4
|
-
import { BaseEvent } from "../../event-bus/contracts/_module-exports.js";
|
|
5
|
-
import { CORE, resolveOneOrMore, } from "../../utilities/_module-exports.js";
|
|
6
|
-
/**
|
|
7
|
-
* The event is dispatched when key is found.
|
|
8
|
-
*
|
|
9
|
-
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
10
|
-
* @group Events
|
|
11
|
-
*/
|
|
12
|
-
export class KeyFoundCacheEvent extends BaseEvent {
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* The event is dispatched when key is not found.
|
|
16
|
-
*
|
|
17
|
-
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
18
|
-
* @group Events
|
|
19
|
-
*/
|
|
20
|
-
export class KeyNotFoundCacheEvent extends BaseEvent {
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The event is dispatched when key is added.
|
|
24
|
-
*
|
|
25
|
-
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
26
|
-
* @group Events
|
|
27
|
-
*/
|
|
28
|
-
export class KeyAddedCacheEvent extends BaseEvent {
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* The event is dispatched when key is updated.
|
|
32
|
-
*
|
|
33
|
-
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
34
|
-
* @group Events
|
|
35
|
-
*/
|
|
36
|
-
export class KeyUpdatedCacheEvent extends BaseEvent {
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* The event is dispatched when key is removed.
|
|
40
|
-
*
|
|
41
|
-
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
42
|
-
* @group Events
|
|
43
|
-
*/
|
|
44
|
-
export class KeyRemovedCacheEvent extends BaseEvent {
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* The event is dispatched when key is incremented.
|
|
48
|
-
*
|
|
49
|
-
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
50
|
-
* @group Events
|
|
51
|
-
*/
|
|
52
|
-
export class KeyIncrementedCacheEvent extends BaseEvent {
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* The event is dispatched when key is decremented.
|
|
56
|
-
*
|
|
57
|
-
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
58
|
-
* @group Events
|
|
59
|
-
*/
|
|
60
|
-
export class KeyDecrementedCacheEvent extends BaseEvent {
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* The event is dispatched when all keys all cleared.
|
|
64
|
-
*
|
|
65
|
-
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
66
|
-
* @group Events
|
|
67
|
-
*/
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
69
|
-
export class KeysClearedCacheEvent extends BaseEvent {
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
74
|
-
* @group Events
|
|
75
|
-
*/
|
|
76
|
-
export class UnexpectedErrorCacheEvent extends BaseEvent {
|
|
77
|
-
}
|
|
78
4
|
/**
|
|
79
5
|
*
|
|
80
6
|
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
81
7
|
* @group Events
|
|
82
8
|
*/
|
|
83
9
|
export const CACHE_EVENTS = {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
KeyIncremented: KeyIncrementedCacheEvent,
|
|
90
|
-
KeyDecremented: KeyDecrementedCacheEvent,
|
|
91
|
-
KeysCleared: KeysClearedCacheEvent,
|
|
92
|
-
UnexpectedError: UnexpectedErrorCacheEvent,
|
|
10
|
+
FOUND: "FOUND",
|
|
11
|
+
NOT_FOUND: "NOT_FOUND",
|
|
12
|
+
WRITTEN: "WRITTEN",
|
|
13
|
+
CLEARED: "CLEARED",
|
|
14
|
+
UNEXPECTED_ERROR: "UNEXPECTED_ERROR",
|
|
93
15
|
};
|
|
94
|
-
/**
|
|
95
|
-
* The `registerCacheEventsToSerde` function registers all {@link ICache | `ICache`} related events with `IFlexibleSerde`, ensuring they will properly be serialized and deserialized.
|
|
96
|
-
*
|
|
97
|
-
* IMPORT_PATH: `"@daiso-tech/core/cache/contracts"`
|
|
98
|
-
* @group Events
|
|
99
|
-
*/
|
|
100
|
-
export function registerCacheEventsToSerde(serde) {
|
|
101
|
-
for (const serde_ of resolveOneOrMore(serde)) {
|
|
102
|
-
serde_
|
|
103
|
-
.registerEvent(KeyFoundCacheEvent, CORE)
|
|
104
|
-
.registerEvent(KeyNotFoundCacheEvent, CORE)
|
|
105
|
-
.registerEvent(KeyAddedCacheEvent, CORE)
|
|
106
|
-
.registerEvent(KeyUpdatedCacheEvent, CORE)
|
|
107
|
-
.registerEvent(KeyRemovedCacheEvent, CORE)
|
|
108
|
-
.registerEvent(KeyIncrementedCacheEvent, CORE)
|
|
109
|
-
.registerEvent(KeyDecrementedCacheEvent, CORE)
|
|
110
|
-
.registerEvent(KeysClearedCacheEvent, CORE)
|
|
111
|
-
.registerEvent(UnexpectedErrorCacheEvent, CORE);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
16
|
//# sourceMappingURL=cache.events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.events.js","sourceRoot":"","sources":["../../../src/cache/contracts/cache.events.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"cache.events.js","sourceRoot":"","sources":["../../../src/cache/contracts/cache.events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAwHH;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,gBAAgB,EAAE,kBAAkB;CAC9B,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Cache
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { CacheEventMap, IDatabaseCacheAdapter } from "../../../../cache/contracts/_module-exports.js";
|
|
5
5
|
import { type ICache, type ICacheAdapter } from "../../../../cache/contracts/_module-exports.js";
|
|
6
6
|
import { type AsyncLazyable, type OneOrMore } from "../../../../utilities/_module-exports.js";
|
|
7
7
|
import { type NoneFunc, type TimeSpan, KeyPrefixer } from "../../../../utilities/_module-exports.js";
|
|
8
8
|
import { LazyPromise } from "../../../../async/_module-exports.js";
|
|
9
|
-
import type { IEventBus, Unsubscribe,
|
|
9
|
+
import type { IEventBus, Unsubscribe, EventListener } from "../../../../event-bus/contracts/_module-exports.js";
|
|
10
10
|
import type { AsyncLazy, Factory } from "../../../../utilities/_module-exports.js";
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
@@ -38,7 +38,7 @@ export type CacheSettingsBase = {
|
|
|
38
38
|
* })
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
eventBus?: IEventBus
|
|
41
|
+
eventBus?: IEventBus;
|
|
42
42
|
/**
|
|
43
43
|
* You can decide the default ttl value. If null is passed then no ttl will be used by default.
|
|
44
44
|
* @default {null}
|
|
@@ -99,35 +99,35 @@ export declare class Cache<TType = unknown> implements ICache<TType> {
|
|
|
99
99
|
*/
|
|
100
100
|
constructor(settings: CacheSettings);
|
|
101
101
|
/**
|
|
102
|
-
* You can listen to the following {@link
|
|
102
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
103
103
|
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
104
104
|
*/
|
|
105
|
-
addListener<
|
|
105
|
+
addListener<TEventName extends keyof CacheEventMap<TType>>(eventName: TEventName, listener: EventListener<CacheEventMap<TType>[TEventName]>): LazyPromise<void>;
|
|
106
106
|
/**
|
|
107
|
-
* You can listen to the following {@link
|
|
107
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
108
108
|
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
109
109
|
*/
|
|
110
|
-
removeListener<
|
|
110
|
+
removeListener<TEventName extends keyof CacheEventMap<TType>>(eventName: TEventName, listener: EventListener<CacheEventMap<TType>[TEventName]>): LazyPromise<void>;
|
|
111
111
|
/**
|
|
112
|
-
* You can listen to the following {@link
|
|
112
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
113
113
|
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
114
114
|
*/
|
|
115
|
-
listenOnce<
|
|
115
|
+
listenOnce<TEventName extends keyof CacheEventMap<TType>>(eventName: TEventName, listener: EventListener<CacheEventMap<TType>[TEventName]>): LazyPromise<void>;
|
|
116
116
|
/**
|
|
117
|
-
* You can listen to the following {@link
|
|
117
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
118
118
|
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
119
119
|
*/
|
|
120
|
-
asPromise<
|
|
120
|
+
asPromise<TEventName extends keyof CacheEventMap<TType>>(eventName: TEventName): LazyPromise<CacheEventMap<TType>[TEventName]>;
|
|
121
121
|
/**
|
|
122
|
-
* You can listen to the following {@link
|
|
122
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
123
123
|
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
124
124
|
*/
|
|
125
|
-
subscribeOnce<
|
|
125
|
+
subscribeOnce<TEventName extends keyof CacheEventMap<TType>>(eventName: TEventName, listener: EventListener<CacheEventMap<TType>[TEventName]>): LazyPromise<Unsubscribe>;
|
|
126
126
|
/**
|
|
127
|
-
* You can listen to the following {@link
|
|
127
|
+
* You can listen to the following {@link CacheEventMap | `CacheEventMap`} of the {@link ICache | `ICache`} instance.
|
|
128
128
|
* To understand how this method works, refer to {@link IEventListenable | `IEventListenable `}.
|
|
129
129
|
*/
|
|
130
|
-
subscribe<
|
|
130
|
+
subscribe<TEventName extends keyof CacheEventMap<TType>>(eventName: TEventName, listener: EventListener<CacheEventMap<TType>[TEventName]>): LazyPromise<Unsubscribe>;
|
|
131
131
|
private createLazyPromise;
|
|
132
132
|
exists(key: OneOrMore<string>): LazyPromise<boolean>;
|
|
133
133
|
missing(key: OneOrMore<string>): LazyPromise<boolean>;
|