@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.
Files changed (149) hide show
  1. package/README.md +2 -4
  2. package/dist/async/_module-exports.d.ts +0 -1
  3. package/dist/async/_module-exports.js +0 -1
  4. package/dist/async/_module-exports.js.map +1 -1
  5. package/dist/async/async.errors.d.ts +19 -12
  6. package/dist/async/async.errors.js +27 -16
  7. package/dist/async/async.errors.js.map +1 -1
  8. package/dist/async/middlewares/_module.d.ts +3 -0
  9. package/dist/async/middlewares/_module.js +3 -0
  10. package/dist/async/middlewares/_module.js.map +1 -1
  11. package/dist/async/middlewares/_shared.d.ts +10 -0
  12. package/dist/async/middlewares/_shared.js +5 -0
  13. package/dist/async/middlewares/_shared.js.map +1 -0
  14. package/dist/async/middlewares/bulkhead/_module.d.ts +1 -0
  15. package/dist/async/middlewares/bulkhead/_module.js +2 -0
  16. package/dist/async/middlewares/bulkhead/_module.js.map +1 -0
  17. package/dist/async/middlewares/bulkhead/bulkhead.middleware.d.ts +80 -0
  18. package/dist/async/middlewares/bulkhead/bulkhead.middleware.js +46 -0
  19. package/dist/async/middlewares/bulkhead/bulkhead.middleware.js.map +1 -0
  20. package/dist/async/middlewares/dynamic/dynamic.middleware.d.ts +2 -2
  21. package/dist/async/middlewares/dynamic/dynamic.middleware.js +5 -5
  22. package/dist/async/middlewares/dynamic/dynamic.middleware.js.map +1 -1
  23. package/dist/async/middlewares/fallback/fallback.middleware.d.ts +10 -8
  24. package/dist/async/middlewares/fallback/fallback.middleware.js +1 -1
  25. package/dist/async/middlewares/fallback/fallback.middleware.js.map +1 -1
  26. package/dist/async/middlewares/hedging/_module.d.ts +2 -0
  27. package/dist/async/middlewares/hedging/_module.js +3 -0
  28. package/dist/async/middlewares/hedging/_module.js.map +1 -0
  29. package/dist/async/middlewares/hedging/_shared.d.ts +93 -0
  30. package/dist/async/middlewares/hedging/_shared.js +5 -0
  31. package/dist/async/middlewares/hedging/_shared.js.map +1 -0
  32. package/dist/async/middlewares/hedging/concurrent-hedging/_module.d.ts +1 -0
  33. package/dist/async/middlewares/hedging/concurrent-hedging/_module.js +2 -0
  34. package/dist/async/middlewares/hedging/concurrent-hedging/_module.js.map +1 -0
  35. package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.d.ts +51 -0
  36. package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js +138 -0
  37. package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js.map +1 -0
  38. package/dist/async/middlewares/hedging/sequential-hedging/_module.d.ts +1 -0
  39. package/dist/async/middlewares/hedging/sequential-hedging/_module.js +2 -0
  40. package/dist/async/middlewares/hedging/sequential-hedging/_module.js.map +1 -0
  41. package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.d.ts +51 -0
  42. package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js +104 -0
  43. package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js.map +1 -0
  44. package/dist/async/middlewares/observe/observe.middleware.d.ts +14 -16
  45. package/dist/async/middlewares/observe/observe.middleware.js +1 -1
  46. package/dist/async/middlewares/observe/observe.middleware.js.map +1 -1
  47. package/dist/async/middlewares/retry/retry.middleware.d.ts +41 -36
  48. package/dist/async/middlewares/retry/retry.middleware.js +31 -28
  49. package/dist/async/middlewares/retry/retry.middleware.js.map +1 -1
  50. package/dist/async/middlewares/timeout/timeout.middleware.d.ts +34 -39
  51. package/dist/async/middlewares/timeout/timeout.middleware.js +30 -47
  52. package/dist/async/middlewares/timeout/timeout.middleware.js.map +1 -1
  53. package/dist/async/utilities/_module.d.ts +2 -0
  54. package/dist/async/utilities/_module.js +2 -0
  55. package/dist/async/utilities/_module.js.map +1 -1
  56. package/dist/async/utilities/abort-and-fail/abort-and-fail.d.ts +3 -0
  57. package/dist/async/utilities/abort-and-fail/abort-and-fail.js +6 -7
  58. package/dist/async/utilities/abort-and-fail/abort-and-fail.js.map +1 -1
  59. package/dist/async/utilities/lazy-promise/lazy-promise.js +0 -1
  60. package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
  61. package/dist/async/utilities/promise-queue/_module.d.ts +1 -0
  62. package/dist/async/utilities/promise-queue/_module.js +2 -0
  63. package/dist/async/utilities/promise-queue/_module.js.map +1 -0
  64. package/dist/async/utilities/promise-queue/promise-queue.d.ts +32 -0
  65. package/dist/async/utilities/promise-queue/promise-queue.js +107 -0
  66. package/dist/async/utilities/promise-queue/promise-queue.js.map +1 -0
  67. package/dist/async/utilities/timeout-and-fail/_module.d.ts +1 -0
  68. package/dist/async/utilities/timeout-and-fail/_module.js +2 -0
  69. package/dist/async/utilities/timeout-and-fail/_module.js.map +1 -0
  70. package/dist/async/utilities/timeout-and-fail/timeout-and-fail.d.ts +7 -0
  71. package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js +19 -0
  72. package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js.map +1 -0
  73. package/dist/cache/contracts/cache.contract.d.ts +2 -2
  74. package/dist/cache/contracts/cache.events.d.ts +43 -47
  75. package/dist/cache/contracts/cache.events.js +5 -103
  76. package/dist/cache/contracts/cache.events.js.map +1 -1
  77. package/dist/cache/implementations/derivables/cache/cache.d.ts +15 -15
  78. package/dist/cache/implementations/derivables/cache/cache.js +94 -79
  79. package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
  80. package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +1 -1
  81. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
  82. package/dist/cache/implementations/test-utilities/cache.test-suite.js +138 -147
  83. package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
  84. package/dist/event-bus/contracts/_module-exports.d.ts +0 -1
  85. package/dist/event-bus/contracts/_module-exports.js +0 -1
  86. package/dist/event-bus/contracts/_module-exports.js.map +1 -1
  87. package/dist/event-bus/contracts/event-bus-adapter.contract.d.ts +6 -1
  88. package/dist/event-bus/contracts/event-bus-factory.contract.d.ts +2 -3
  89. package/dist/event-bus/contracts/event-bus-factory.contract.js.map +1 -1
  90. package/dist/event-bus/contracts/event-bus.contract.d.ts +12 -23
  91. package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +10 -10
  92. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +30 -30
  93. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
  94. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +13 -7
  95. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +11 -5
  96. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
  97. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.d.ts +0 -2
  98. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +13 -20
  99. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js.map +1 -1
  100. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +0 -2
  101. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +187 -207
  102. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
  103. package/dist/lock/contracts/lock-provider.contract.d.ts +2 -2
  104. package/dist/lock/contracts/lock.events.d.ts +35 -44
  105. package/dist/lock/contracts/lock.events.js +8 -90
  106. package/dist/lock/contracts/lock.events.js.map +1 -1
  107. package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +9 -9
  108. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +12 -12
  109. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
  110. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +2 -2
  111. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
  112. package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +2 -2
  113. package/dist/lock/implementations/derivables/lock-provider/lock.js +69 -50
  114. package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
  115. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +1 -1
  116. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
  117. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +212 -212
  118. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
  119. package/dist/serde/contracts/flexible-serde.contract.d.ts +0 -11
  120. package/dist/serde/implementations/derivables/serde.d.ts +1 -32
  121. package/dist/serde/implementations/derivables/serde.js +0 -45
  122. package/dist/serde/implementations/derivables/serde.js.map +1 -1
  123. package/dist/utilities/classes/hooks/async-hooks.d.ts +107 -20
  124. package/dist/utilities/classes/hooks/async-hooks.js +47 -18
  125. package/dist/utilities/classes/hooks/async-hooks.js.map +1 -1
  126. package/dist/utilities/classes/hooks/hooks.d.ts +39 -21
  127. package/dist/utilities/classes/hooks/hooks.js +19 -18
  128. package/dist/utilities/classes/hooks/hooks.js.map +1 -1
  129. package/dist/utilities/classes/key-prefixer/key-prefixer.js +2 -2
  130. package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -1
  131. package/dist/utilities/contracts/_module.d.ts +0 -1
  132. package/dist/utilities/contracts/_module.js +0 -1
  133. package/dist/utilities/contracts/_module.js.map +1 -1
  134. package/dist/utilities/functions/invokable.d.ts +9 -5
  135. package/dist/utilities/functions/invokable.js +10 -0
  136. package/dist/utilities/functions/invokable.js.map +1 -1
  137. package/package.json +22 -2
  138. package/dist/async/async.events.d.ts +0 -105
  139. package/dist/async/async.events.js +0 -82
  140. package/dist/async/async.events.js.map +0 -1
  141. package/dist/event-bus/contracts/_shared.d.ts +0 -12
  142. package/dist/event-bus/contracts/_shared.js +0 -15
  143. package/dist/event-bus/contracts/_shared.js.map +0 -1
  144. package/dist/test.d.ts +0 -1
  145. package/dist/test.js +0 -34
  146. package/dist/test.js.map +0 -1
  147. package/dist/utilities/contracts/sync-event-bus-listenable.d.ts +0 -13
  148. package/dist/utilities/contracts/sync-event-bus-listenable.js +0 -5
  149. 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 { CacheEvents } from "../../cache/contracts/cache.events.js";
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<CacheEvents<TType>>;
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 { BaseEvent } from "../../event-bus/contracts/_module-exports.js";
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 declare class KeyFoundCacheEvent<TType = unknown> extends BaseEvent<{
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 declare class KeyNotFoundCacheEvent extends BaseEvent<{
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 declare class KeyAddedCacheEvent<TType = unknown> extends BaseEvent<{
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 declare class KeyUpdatedCacheEvent<TType = unknown> extends BaseEvent<{
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 declare class KeyRemovedCacheEvent extends BaseEvent<{
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 declare class KeyIncrementedCacheEvent extends BaseEvent<{
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 declare class KeyDecrementedCacheEvent extends BaseEvent<{
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 all keys all cleared.
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 declare class KeysClearedCacheEvent extends BaseEvent<{}> {
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 declare class UnexpectedErrorCacheEvent extends BaseEvent<{
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 declare const CACHE_EVENTS: {
109
- KeyFound: typeof KeyFoundCacheEvent;
110
- KeyNotFound: typeof KeyNotFoundCacheEvent;
111
- KeyAdded: typeof KeyAddedCacheEvent;
112
- KeyUpdated: typeof KeyUpdatedCacheEvent;
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 type CacheEvents<TType = unknown> = KeyFoundCacheEvent<TType> | KeyNotFoundCacheEvent | KeyAddedCacheEvent<TType> | KeyUpdatedCacheEvent<TType> | KeyRemovedCacheEvent | KeyIncrementedCacheEvent | KeyDecrementedCacheEvent | KeysClearedCacheEvent | UnexpectedErrorCacheEvent;
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 declare function registerCacheEventsToSerde(serde: OneOrMore<IFlexibleSerde>): void;
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
- KeyFound: KeyFoundCacheEvent,
85
- KeyNotFound: KeyNotFoundCacheEvent,
86
- KeyAdded: KeyAddedCacheEvent,
87
- KeyUpdated: KeyUpdatedCacheEvent,
88
- KeyRemoved: KeyRemovedCacheEvent,
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;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE,OAAO,EACH,IAAI,EACJ,gBAAgB,GAGnB,MAAM,gCAAgC,CAAC;AAExC;;;;;GAKG;AACH,MAAM,OAAO,kBAAoC,SAAQ,SAGvD;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,qBAAsB,SAAQ,SAEzC;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,kBAAoC,SAAQ,SAIvD;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,oBAAsC,SAAQ,SAGzD;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,oBAAqB,SAAQ,SAExC;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,wBAAyB,SAAQ,SAG5C;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,wBAAyB,SAAQ,SAG5C;CAAG;AAEL;;;;;GAKG;AACH,mEAAmE;AACnE,MAAM,OAAO,qBAAsB,SAAQ,SAAa;CAAG;AAE3D;;;;GAIG;AACH,MAAM,OAAO,yBAA0B,SAAQ,SAK7C;CAAG;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,QAAQ,EAAE,kBAAkB;IAC5B,WAAW,EAAE,qBAAqB;IAClC,QAAQ,EAAE,kBAAkB;IAC5B,UAAU,EAAE,oBAAoB;IAChC,UAAU,EAAE,oBAAoB;IAChC,cAAc,EAAE,wBAAwB;IACxC,cAAc,EAAE,wBAAwB;IACxC,WAAW,EAAE,qBAAqB;IAClC,eAAe,EAAE,yBAAyB;CAC7C,CAAC;AAkBF;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CACtC,KAAgC;IAEhC,KAAK,MAAM,MAAM,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,MAAM;aACD,aAAa,CAAC,kBAAkB,EAAE,IAAI,CAAC;aACvC,aAAa,CAAC,qBAAqB,EAAE,IAAI,CAAC;aAC1C,aAAa,CAAC,kBAAkB,EAAE,IAAI,CAAC;aACvC,aAAa,CAAC,oBAAoB,EAAE,IAAI,CAAC;aACzC,aAAa,CAAC,oBAAoB,EAAE,IAAI,CAAC;aACzC,aAAa,CAAC,wBAAwB,EAAE,IAAI,CAAC;aAC7C,aAAa,CAAC,wBAAwB,EAAE,IAAI,CAAC;aAC7C,aAAa,CAAC,qBAAqB,EAAE,IAAI,CAAC;aAC1C,aAAa,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;AACL,CAAC"}
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 { CacheEvents, IDatabaseCacheAdapter } from "../../../../cache/contracts/_module-exports.js";
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, EventClass, EventInstance, EventListener } from "../../../../event-bus/contracts/_module-exports.js";
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<any>;
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 CacheEvents | `CacheEvents`} of the {@link ICache | `ICache`} instance.
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<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): LazyPromise<void>;
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 CacheEvents | `CacheEvents`} of the {@link ICache | `ICache`} instance.
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<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): LazyPromise<void>;
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 CacheEvents | `CacheEvents`} of the {@link ICache | `ICache`} instance.
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<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): LazyPromise<void>;
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 CacheEvents | `CacheEvents`} of the {@link ICache | `ICache`} instance.
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<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass): LazyPromise<EventInstance<TEventClass>>;
120
+ asPromise<TEventName extends keyof CacheEventMap<TType>>(eventName: TEventName): LazyPromise<CacheEventMap<TType>[TEventName]>;
121
121
  /**
122
- * You can listen to the following {@link CacheEvents | `CacheEvents`} of the {@link ICache | `ICache`} instance.
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<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
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 CacheEvents | `CacheEvents`} of the {@link ICache | `ICache`} instance.
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<TEventClass extends EventClass<CacheEvents<TType>>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
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>;