@daiso-tech/core 0.31.1 → 0.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/async/_module-exports.d.ts +1 -0
  2. package/dist/async/_module-exports.js +1 -0
  3. package/dist/async/_module-exports.js.map +1 -1
  4. package/dist/async/async.errors.d.ts +14 -0
  5. package/dist/async/async.errors.js +14 -0
  6. package/dist/async/async.errors.js.map +1 -1
  7. package/dist/async/async.events.d.ts +105 -0
  8. package/dist/async/async.events.js +82 -0
  9. package/dist/async/async.events.js.map +1 -0
  10. package/dist/async/backof-policies/_shared.d.ts +1 -1
  11. package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.d.ts +2 -2
  12. package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js +1 -1
  13. package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.d.ts +2 -2
  14. package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +1 -1
  15. package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.d.ts +2 -2
  16. package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +1 -1
  17. package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.d.ts +2 -2
  18. package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +1 -1
  19. package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.d.ts +15 -0
  20. package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.js +50 -0
  21. package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.js.map +1 -0
  22. package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.d.ts +23 -0
  23. package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.js +44 -0
  24. package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.js.map +1 -0
  25. package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +66 -54
  26. package/dist/async/utilities/lazy-promise/lazy-promise.js +148 -94
  27. package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
  28. package/dist/async/utilities/retry/retry-or-fail.d.ts +1 -1
  29. package/dist/async/utilities/retry/retry-or-fail.js +1 -1
  30. package/dist/async/utilities/retry/retry-or-fail.js.map +1 -1
  31. package/dist/async/utilities/retry/retry.d.ts +1 -1
  32. package/dist/async/utilities/retry/retry.js.map +1 -1
  33. package/dist/cache/contracts/cache.errors.d.ts +13 -0
  34. package/dist/cache/contracts/cache.errors.js +13 -0
  35. package/dist/cache/contracts/cache.errors.js.map +1 -1
  36. package/dist/cache/contracts/cache.events.d.ts +26 -2
  37. package/dist/cache/contracts/cache.events.js +26 -2
  38. package/dist/cache/contracts/cache.events.js.map +1 -1
  39. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js +3 -3
  40. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js.map +1 -1
  41. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js +3 -3
  42. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js.map +1 -1
  43. package/dist/cache/implementations/derivables/cache/cache.d.ts +13 -8
  44. package/dist/cache/implementations/derivables/cache/cache.js +17 -33
  45. package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
  46. package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +3 -22
  47. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +2 -42
  48. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
  49. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +2 -2
  50. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +1 -1
  51. package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +2 -2
  52. package/dist/cache/implementations/test-utilities/cache.test-suite.js +1 -1
  53. package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.d.ts +2 -2
  54. package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js +1 -1
  55. package/dist/collection/contracts/collection.errors.d.ts +17 -0
  56. package/dist/collection/contracts/collection.errors.js +17 -0
  57. package/dist/collection/contracts/collection.errors.js.map +1 -1
  58. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +5 -8
  59. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +5 -19
  60. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
  61. package/dist/event-bus/contracts/event-bus.errors.d.ts +15 -0
  62. package/dist/event-bus/contracts/event-bus.errors.js +15 -0
  63. package/dist/event-bus/contracts/event-bus.errors.js.map +1 -1
  64. package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +13 -8
  65. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +9 -28
  66. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
  67. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +3 -29
  68. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +2 -48
  69. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
  70. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.d.ts +2 -2
  71. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +1 -1
  72. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +2 -2
  73. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +1 -1
  74. package/dist/lock/contracts/lock.errors.d.ts +18 -0
  75. package/dist/lock/contracts/lock.errors.js +18 -0
  76. package/dist/lock/contracts/lock.errors.js.map +1 -1
  77. package/dist/lock/contracts/lock.events.d.ts +22 -0
  78. package/dist/lock/contracts/lock.events.js +22 -0
  79. package/dist/lock/contracts/lock.events.js.map +1 -1
  80. package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +14 -8
  81. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +7 -24
  82. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
  83. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +3 -25
  84. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +2 -47
  85. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
  86. package/dist/serde/contracts/deserializer.contract.d.ts +1 -1
  87. package/dist/serde/contracts/deserializer.contract.js +1 -1
  88. package/dist/serde/contracts/deserializer.contract.js.map +1 -1
  89. package/dist/serde/contracts/serde.errors.d.ts +14 -2
  90. package/dist/serde/contracts/serde.errors.js +16 -4
  91. package/dist/serde/contracts/serde.errors.js.map +1 -1
  92. package/dist/serde/contracts/serializer.contract.d.ts +1 -1
  93. package/dist/serde/contracts/serializer.contract.js +1 -1
  94. package/dist/serde/contracts/serializer.contract.js.map +1 -1
  95. package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js +3 -3
  96. package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js.map +1 -1
  97. package/dist/serde/implementations/adapters/redis-serde/redis-serde.js +3 -3
  98. package/dist/serde/implementations/adapters/redis-serde/redis-serde.js.map +1 -1
  99. package/dist/serde/implementations/adapters/sql-serde/sql-serde.js +3 -3
  100. package/dist/serde/implementations/adapters/sql-serde/sql-serde.js.map +1 -1
  101. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +3 -3
  102. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js.map +1 -1
  103. package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.d.ts +2 -2
  104. package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js +1 -1
  105. package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.d.ts +2 -2
  106. package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +1 -1
  107. package/dist/utilities/classes/_module.d.ts +1 -0
  108. package/dist/utilities/classes/_module.js +1 -0
  109. package/dist/utilities/classes/_module.js.map +1 -1
  110. package/dist/utilities/classes/key-prefixer/key-prefixer.d.ts +20 -2
  111. package/dist/utilities/classes/key-prefixer/key-prefixer.js +20 -2
  112. package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -1
  113. package/dist/utilities/classes/sync-event-bus/_module.d.ts +1 -0
  114. package/dist/utilities/classes/sync-event-bus/_module.js +2 -0
  115. package/dist/utilities/classes/sync-event-bus/_module.js.map +1 -0
  116. package/dist/utilities/classes/sync-event-bus/sync-event-bus.d.ts +16 -0
  117. package/dist/utilities/classes/sync-event-bus/sync-event-bus.js +53 -0
  118. package/dist/utilities/classes/sync-event-bus/sync-event-bus.js.map +1 -0
  119. package/dist/utilities/contracts/_module.d.ts +1 -0
  120. package/dist/utilities/contracts/_module.js +1 -0
  121. package/dist/utilities/contracts/_module.js.map +1 -1
  122. package/dist/utilities/contracts/sync-event-bus-listenable.d.ts +13 -0
  123. package/dist/utilities/contracts/sync-event-bus-listenable.js +5 -0
  124. package/dist/utilities/contracts/sync-event-bus-listenable.js.map +1 -0
  125. package/dist/utilities/errors.d.ts +2 -0
  126. package/dist/utilities/errors.js +2 -0
  127. package/dist/utilities/errors.js.map +1 -1
  128. package/dist/utilities/functions/invokable.d.ts +4 -0
  129. package/dist/utilities/functions/invokable.js +9 -0
  130. package/dist/utilities/functions/invokable.js.map +1 -1
  131. package/package.json +3 -4
@@ -2,80 +2,69 @@
2
2
  * @module Async
3
3
  */
4
4
  import type { BackoffPolicy } from "../../../async/backof-policies/_module.js";
5
- import type { AsyncLazy, Invokable, InvokableFn, Promisable, TimeSpan } from "../../../utilities/_module-exports.js";
5
+ import type { AsyncLazy, Invokable, InvokableFn, ISyncEventListenable, Promisable, TimeSpan } from "../../../utilities/_module-exports.js";
6
6
  import type { RetryPolicy } from "../../../async/utilities/retry/_module.js";
7
+ import { type AsyncEvents } from "../../../async/async.events.js";
8
+ import type { EventClass, EventListener, EventInstance } from "../../../event-bus/contracts/event-bus.contract.js";
7
9
  /**
8
10
  *
9
11
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
10
12
  * @group Utilities
11
13
  */
12
- export type LazyPromiseOnFinally = () => Promisable<void>;
13
- /**
14
- *
15
- * IMPORT_PATH: ```"@daiso-tech/core/async"```
16
- * @group Utilities
17
- */
18
- export type LazyPromiseOnSuccess<TValue> = (value: TValue) => Promisable<void>;
19
- /**
20
- *
21
- * IMPORT_PATH: ```"@daiso-tech/core/async"```
22
- * @group Utilities
23
- */
24
- export type LazyPromiseOnError = (error: unknown) => Promisable<void>;
14
+ export type LazyPromiseSettings = {
15
+ backoffPolicy?: BackoffPolicy | null;
16
+ retryAttempts?: number | null;
17
+ retryPolicy?: RetryPolicy | null;
18
+ retryTimeout?: TimeSpan | null;
19
+ totalTimeout?: TimeSpan | null;
20
+ abortSignal?: AbortSignal | null;
21
+ };
25
22
  /**
26
23
  *
27
24
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
28
25
  * @group Utilities
29
26
  */
30
- export type LazyPromiseCallbacks<TValue = unknown> = {
31
- onFinally?: LazyPromiseOnFinally;
32
- onSuccess?: LazyPromiseOnSuccess<TValue>;
33
- onError?: LazyPromiseOnError;
34
- };
27
+ export type LazyPromiseResolve<TValue> = InvokableFn<[
28
+ value: Promisable<TValue>
29
+ ], void>;
35
30
  /**
36
31
  *
37
32
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
38
33
  * @group Utilities
39
34
  */
40
- export type LazyPromiseSettingsBase = {
41
- backoffPolicy?: BackoffPolicy | null;
42
- retryAttempts?: number | null;
43
- retryPolicy?: RetryPolicy | null;
44
- retryTimeout?: TimeSpan | null;
45
- totalTimeout?: TimeSpan | null;
46
- };
35
+ export type LazyPromiseReject = InvokableFn<[error: unknown], void>;
47
36
  /**
48
37
  *
49
38
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
50
39
  * @group Utilities
51
40
  */
52
- export type LazyPromiseSettings<TValue = unknown> = LazyPromiseCallbacks<TValue> & LazyPromiseSettingsBase & {
53
- abortSignal?: AbortSignal | null;
54
- };
41
+ export type LazyPromiseCallback<TValue> = InvokableFn<[
42
+ resolve: LazyPromiseResolve<TValue>,
43
+ reject: LazyPromiseReject
44
+ ], Promisable<void>>;
55
45
  /**
56
46
  * The <i>LazyPromise</i> class is used for creating lazy <i>{@link PromiseLike}<i> object that will only execute when awaited or when then method is called.
57
47
  * The class includes helpful methods
58
48
  * - <i>defer</i>
59
- * - <i>setRetryAttempts</i>
60
49
  * - <i>setRetryTimeout</i>
61
50
  * - <i>setRetryPolicy</i>
62
- * - <i>backoffPolicy</i>
51
+ * - <i>setBackoffPolicy</i>
52
+ * - <i>setRetryAttempts</i>
63
53
  * - <i>setTotalTimeout</i>
64
54
  * - <i>setAbortSignal</i>
65
55
  *
66
- * The order in which these methods are called does not affect their methodality. Internally, the following execution order is applied:
56
+ * The order in which these methods are called does not have any affect. Internally, the following execution order is applied:
67
57
  * 1. <i>setRetryTimeout</i>
68
- * 2. <i>setRetryAttempts</i>
69
- * 3. <i>setTotalTimeout</i>
70
- * 4. <i>setAbortSignal</i>
71
- *
72
- * This means that combining all methods ensures the <i>retryAttempts</i> method will continue retrying even if the timeout is triggered,
73
- * while the <i>abort</i> method takes priority to cancel all operations if activated.
58
+ * 2. <i>setRetryPolicy</i>
59
+ * 3. <i>setBackoffPolicy</i>
60
+ * 4. <i>setRetryAttempts</i>
61
+ * 5. <i>setTotalTimeout</i>
62
+ * 6. <i>setAbortSignal</i>
74
63
  *
75
64
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
76
65
  * @group Utilities
77
66
  */
78
- export declare class LazyPromise<TValue> implements PromiseLike<TValue> {
67
+ export declare class LazyPromise<TValue> implements PromiseLike<TValue>, ISyncEventListenable<AsyncEvents<TValue>> {
79
68
  /**
80
69
  * The <i>wrapFn</i> is convience method used for wrapping async <i>{@link Invokable}</i> with a <i>LazyPromise</i>.
81
70
  * @example
@@ -91,7 +80,7 @@ export declare class LazyPromise<TValue> implements PromiseLike<TValue> {
91
80
  * .setRetryTimeout(TimeSpan.fromMinutes(1));
92
81
  * ```
93
82
  */
94
- static wrapFn<TArgs extends unknown[], TReturn>(fn: Invokable<TArgs, Promisable<TReturn>>, settings?: LazyPromiseSettings<TReturn>): InvokableFn<TArgs, LazyPromise<TReturn>>;
83
+ static wrapFn<TArgs extends unknown[], TReturn>(fn: Invokable<TArgs, Promisable<TReturn>>, settings?: LazyPromiseSettings): InvokableFn<TArgs, LazyPromise<TReturn>>;
95
84
  /**
96
85
  * The <i>delay</i> method creates a <i>{@link LazyPromise}</i> that will be fulfilled after given <i>time</i>.
97
86
  *
@@ -111,22 +100,44 @@ export declare class LazyPromise<TValue> implements PromiseLike<TValue> {
111
100
  /**
112
101
  * The <i>all<i> method works similarly to <i>{@link Promise.all}</i> with the key distinction that it operates lazily.
113
102
  */
114
- static all<TValue>(promises: LazyPromise<TValue>[]): LazyPromise<TValue[]>;
103
+ static all<TValue>(promises: LazyPromise<TValue>[], settings?: LazyPromiseSettings): LazyPromise<TValue[]>;
115
104
  /**
116
105
  * The <i>allSettled<i> method works similarly to <i>{@link Promise.allSettled}</i> with the key distinction that it operates lazily.
117
106
  */
118
- static allSettled<TValue>(promises: LazyPromise<TValue>[]): LazyPromise<PromiseSettledResult<TValue>[]>;
107
+ static allSettled<TValue>(promises: LazyPromise<TValue>[], settings?: LazyPromiseSettings): LazyPromise<PromiseSettledResult<TValue>[]>;
119
108
  /**
120
109
  * The <i>race<i> method works similarly to <i>{@link Promise.race}</i> with the key distinction that it operates lazily.
121
110
  */
122
- static race<TValue>(promises: LazyPromise<TValue>[]): LazyPromise<TValue>;
111
+ static race<TValue>(promises: LazyPromise<TValue>[], settings?: LazyPromiseSettings): LazyPromise<TValue>;
123
112
  /**
124
113
  * The <i>any<i> method works similarly to <i>{@link Promise.any}</i> with the key distinction that it operates lazily.
125
114
  */
126
- static any<TValue>(promises: LazyPromise<TValue>[]): LazyPromise<TValue>;
115
+ static any<TValue>(promises: LazyPromise<TValue>[], settings?: LazyPromiseSettings): LazyPromise<TValue>;
116
+ /**
117
+ * The <i>fromCallback</i> is convience method used for wrapping Node js callback functions with a <i>LazyPromise</i>.
118
+ * @example
119
+ * ```ts
120
+ * import { LazyPromise } from "@daiso-tech/core/async";
121
+ * import { readFile } from "node:fs";
122
+ *
123
+ * const lazyPromise = LazyPromise.fromCallback<Buffer>((resolve, reject) => {
124
+ * readFile("FILE_PATH", (err, data) => {
125
+ * if (err !== null) {
126
+ * reject(err);
127
+ * return;
128
+ * }
129
+ * resolve(data);
130
+ * });
131
+ * });
132
+ * const file = await lazyPromise;
133
+ * console.log(file);
134
+ * ```
135
+ */
136
+ static fromCallback<TValue>(callback: LazyPromiseCallback<TValue>, settings?: LazyPromiseSettings): LazyPromise<TValue>;
127
137
  private promise;
128
138
  private asyncFn;
129
139
  private readonly settings;
140
+ private readonly eventBus;
130
141
  /**
131
142
  * @example
132
143
  * ```ts
@@ -139,19 +150,17 @@ export declare class LazyPromise<TValue> implements PromiseLike<TValue> {
139
150
  * // "I am lazy" will only logged when awaited or then method i called.
140
151
  * await promise;
141
152
  * ```
153
+ *
154
+ * You can pass sync or async <i>{@link Invokable}</i>.
142
155
  */
143
- constructor(asyncFn: AsyncLazy<TValue>, settings?: LazyPromiseSettings<TValue>);
156
+ constructor(invokable: AsyncLazy<TValue>, settings?: LazyPromiseSettings);
157
+ addListener<TEventClass extends EventClass<AsyncEvents<TValue>>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): void;
158
+ removeListener<TEventClass extends EventClass<AsyncEvents<TValue>>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): void;
144
159
  private applyRetryTimeout;
145
160
  private applyRetry;
146
161
  private applyTotalTimeout;
147
162
  private applyAbort;
148
163
  private applySettings;
149
- /**
150
- * @throws {AbortAsyncError} {@link AbortAsyncError}
151
- * @throws {TimeoutAsyncError} {@link TimeoutAsyncError}
152
- * @throws {RetryAsyncError} {@link RetryAsyncError}
153
- */
154
- then<TResult1 = TValue, TResult2 = never>(onfulfilled?: ((value: TValue) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
155
164
  /**
156
165
  * The <i>setBackoffPolicy</i> method is used for setting a custom <i>{@link BackoffPolicy}</i>.
157
166
  * ```ts
@@ -270,9 +279,12 @@ export declare class LazyPromise<TValue> implements PromiseLike<TValue> {
270
279
  * ```
271
280
  */
272
281
  setAbortSignal(abortSignal: AbortSignal | null): LazyPromise<TValue>;
273
- onFinally(cb: LazyPromiseOnFinally): LazyPromise<TValue>;
274
- onSuccess(cb: LazyPromiseOnSuccess<TValue>): LazyPromise<TValue>;
275
- onError(cb: LazyPromiseOnError): LazyPromise<TValue>;
282
+ /**
283
+ * @throws {AbortAsyncError} {@link AbortAsyncError}
284
+ * @throws {TimeoutAsyncError} {@link TimeoutAsyncError}
285
+ * @throws {RetryAsyncError} {@link RetryAsyncError}
286
+ */
287
+ then<TResult1 = TValue, TResult2 = never>(onfulfilled?: ((value: TValue) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
276
288
  /**
277
289
  * The <i>defer</i> method executes the <i>LazyPromise</i> without awaiting it.
278
290
  * @example
@@ -1,37 +1,36 @@
1
- /**
2
- * @module Async
3
- */
4
1
  import { retryOrFail } from "../../../async/utilities/retry/_module.js";
5
2
  import { timeoutAndFail } from "../../../async/utilities/timeout/_module.js";
6
3
  import { abortAndFail } from "../../../async/utilities/abort/_module.js";
7
4
  import {
8
5
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
9
- AbortAsyncError,
10
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
- TimeoutAsyncError,
6
+ TimeoutAsyncError, } from "../../../async/async.errors.js";
7
+ import {
12
8
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
9
  RetryAsyncError, } from "../../../async/async.errors.js";
14
- import { removeUndefinedProperties, resolveAsyncLazyable, resolveInvokable, } from "../../../utilities/_module-exports.js";
10
+ import {
11
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
+ AbortAsyncError, } from "../../../async/async.errors.js";
13
+ import { removeUndefinedProperties, resolveAsyncLazyable, resolveInvokable, SyncEventBus, } from "../../../utilities/_module-exports.js";
15
14
  import { delay } from "../../../async/utilities/_module.js";
15
+ import { AbortAsyncEvent, FailureAsyncEvent, FinallyAsyncEvent, RetryAttemptAsyncEvent, RetryFailureAsyncEvent, RetryTimeoutAsyncEvent, SuccessAsyncEvent, TotalTimeoutFailureAsyncEvent, } from "../../../async/async.events.js";
16
16
  /**
17
17
  * The <i>LazyPromise</i> class is used for creating lazy <i>{@link PromiseLike}<i> object that will only execute when awaited or when then method is called.
18
18
  * The class includes helpful methods
19
19
  * - <i>defer</i>
20
- * - <i>setRetryAttempts</i>
21
20
  * - <i>setRetryTimeout</i>
22
21
  * - <i>setRetryPolicy</i>
23
- * - <i>backoffPolicy</i>
22
+ * - <i>setBackoffPolicy</i>
23
+ * - <i>setRetryAttempts</i>
24
24
  * - <i>setTotalTimeout</i>
25
25
  * - <i>setAbortSignal</i>
26
26
  *
27
- * The order in which these methods are called does not affect their methodality. Internally, the following execution order is applied:
27
+ * The order in which these methods are called does not have any affect. Internally, the following execution order is applied:
28
28
  * 1. <i>setRetryTimeout</i>
29
- * 2. <i>setRetryAttempts</i>
30
- * 3. <i>setTotalTimeout</i>
31
- * 4. <i>setAbortSignal</i>
32
- *
33
- * This means that combining all methods ensures the <i>retryAttempts</i> method will continue retrying even if the timeout is triggered,
34
- * while the <i>abort</i> method takes priority to cancel all operations if activated.
29
+ * 2. <i>setRetryPolicy</i>
30
+ * 3. <i>setBackoffPolicy</i>
31
+ * 4. <i>setRetryAttempts</i>
32
+ * 5. <i>setTotalTimeout</i>
33
+ * 6. <i>setAbortSignal</i>
35
34
  *
36
35
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
37
36
  * @group Utilities
@@ -78,30 +77,56 @@ export class LazyPromise {
78
77
  /**
79
78
  * The <i>all<i> method works similarly to <i>{@link Promise.all}</i> with the key distinction that it operates lazily.
80
79
  */
81
- static all(promises) {
82
- return new LazyPromise(async () => Promise.all(promises));
80
+ static all(promises, settings) {
81
+ return new LazyPromise(async () => Promise.all(promises), settings);
83
82
  }
84
83
  /**
85
84
  * The <i>allSettled<i> method works similarly to <i>{@link Promise.allSettled}</i> with the key distinction that it operates lazily.
86
85
  */
87
- static allSettled(promises) {
88
- return new LazyPromise(async () => Promise.allSettled(promises));
86
+ static allSettled(promises, settings) {
87
+ return new LazyPromise(async () => Promise.allSettled(promises), settings);
89
88
  }
90
89
  /**
91
90
  * The <i>race<i> method works similarly to <i>{@link Promise.race}</i> with the key distinction that it operates lazily.
92
91
  */
93
- static race(promises) {
94
- return new LazyPromise(async () => Promise.race(promises));
92
+ static race(promises, settings) {
93
+ return new LazyPromise(async () => Promise.race(promises), settings);
95
94
  }
96
95
  /**
97
96
  * The <i>any<i> method works similarly to <i>{@link Promise.any}</i> with the key distinction that it operates lazily.
98
97
  */
99
- static any(promises) {
100
- return new LazyPromise(async () => Promise.any(promises));
98
+ static any(promises, settings) {
99
+ return new LazyPromise(async () => Promise.any(promises), settings);
100
+ }
101
+ /**
102
+ * The <i>fromCallback</i> is convience method used for wrapping Node js callback functions with a <i>LazyPromise</i>.
103
+ * @example
104
+ * ```ts
105
+ * import { LazyPromise } from "@daiso-tech/core/async";
106
+ * import { readFile } from "node:fs";
107
+ *
108
+ * const lazyPromise = LazyPromise.fromCallback<Buffer>((resolve, reject) => {
109
+ * readFile("FILE_PATH", (err, data) => {
110
+ * if (err !== null) {
111
+ * reject(err);
112
+ * return;
113
+ * }
114
+ * resolve(data);
115
+ * });
116
+ * });
117
+ * const file = await lazyPromise;
118
+ * console.log(file);
119
+ * ```
120
+ */
121
+ static fromCallback(callback, settings) {
122
+ return new LazyPromise(() => new Promise((resolve, reject) => {
123
+ callback(resolve, reject);
124
+ }), settings);
101
125
  }
102
126
  promise = null;
103
127
  asyncFn;
104
128
  settings;
129
+ eventBus = new SyncEventBus();
105
130
  /**
106
131
  * @example
107
132
  * ```ts
@@ -114,9 +139,11 @@ export class LazyPromise {
114
139
  * // "I am lazy" will only logged when awaited or then method i called.
115
140
  * await promise;
116
141
  * ```
142
+ *
143
+ * You can pass sync or async <i>{@link Invokable}</i>.
117
144
  */
118
- constructor(asyncFn, settings = {}) {
119
- this.asyncFn = () => resolveAsyncLazyable(asyncFn);
145
+ constructor(invokable, settings = {}) {
146
+ this.asyncFn = () => resolveAsyncLazyable(invokable);
120
147
  this.settings = removeUndefinedProperties({
121
148
  retryAttempts: null,
122
149
  backoffPolicy: null,
@@ -130,16 +157,30 @@ export class LazyPromise {
130
157
  ...settings,
131
158
  });
132
159
  }
160
+ addListener(event, listener) {
161
+ this.eventBus.addListener(event, listener);
162
+ }
163
+ removeListener(event, listener) {
164
+ this.eventBus.removeListener(event, listener);
165
+ }
133
166
  applyRetryTimeout() {
134
167
  if (this.settings.retryTimeout === null) {
135
168
  return;
136
169
  }
137
170
  const oldAsyncFn = this.asyncFn;
138
- const newAsyncFn = () => {
139
- if (this.settings.retryTimeout === null) {
140
- throw new Error(`LazyPromise["time"] field is null`);
171
+ const newAsyncFn = async () => {
172
+ try {
173
+ if (this.settings.retryTimeout === null) {
174
+ throw new Error(`LazyPromise["time"] field is null`);
175
+ }
176
+ return await timeoutAndFail(oldAsyncFn, this.settings.retryTimeout);
177
+ }
178
+ catch (error) {
179
+ if (error instanceof TimeoutAsyncError) {
180
+ this.eventBus.dispatch(new RetryTimeoutAsyncEvent({ error }));
181
+ }
182
+ throw error;
141
183
  }
142
- return timeoutAndFail(oldAsyncFn, this.settings.retryTimeout);
143
184
  };
144
185
  this.asyncFn = newAsyncFn;
145
186
  }
@@ -149,15 +190,34 @@ export class LazyPromise {
149
190
  }
150
191
  this.applyRetryTimeout();
151
192
  const oldAsyncFn = this.asyncFn;
152
- const newAsyncFn = () => {
153
- if (this.settings.retryAttempts === null) {
154
- throw new Error(`LazyPromise["attempts"] field is null`);
193
+ const newAsyncFn = async () => {
194
+ try {
195
+ if (this.settings.retryAttempts === null) {
196
+ throw new Error(`LazyPromise["attempts"] field is null`);
197
+ }
198
+ return await retryOrFail(async (attempt) => {
199
+ try {
200
+ return await oldAsyncFn();
201
+ }
202
+ catch (error) {
203
+ this.eventBus.dispatch(new RetryAttemptAsyncEvent({
204
+ attempt,
205
+ error,
206
+ }));
207
+ throw error;
208
+ }
209
+ }, {
210
+ backoffPolicy: this.settings.backoffPolicy ?? undefined,
211
+ retryPolicy: this.settings.retryPolicy ?? undefined,
212
+ maxAttempts: this.settings.retryAttempts,
213
+ });
214
+ }
215
+ catch (error) {
216
+ if (error instanceof RetryAsyncError) {
217
+ this.eventBus.dispatch(new RetryFailureAsyncEvent({ error }));
218
+ }
219
+ throw error;
155
220
  }
156
- return retryOrFail(oldAsyncFn, {
157
- backoffPolicy: this.settings.backoffPolicy ?? undefined,
158
- retryPolicy: this.settings.retryPolicy ?? undefined,
159
- maxAttempts: this.settings.retryAttempts,
160
- });
161
221
  };
162
222
  this.asyncFn = newAsyncFn;
163
223
  }
@@ -167,10 +227,18 @@ export class LazyPromise {
167
227
  }
168
228
  const oldAsyncFn = this.asyncFn;
169
229
  const newAsyncFn = () => {
170
- if (this.settings.totalTimeout === null) {
171
- throw new Error(`LazyPromise["time"] field is null`);
230
+ try {
231
+ if (this.settings.totalTimeout === null) {
232
+ throw new Error(`LazyPromise["time"] field is null`);
233
+ }
234
+ return timeoutAndFail(oldAsyncFn, this.settings.totalTimeout);
235
+ }
236
+ catch (error) {
237
+ if (error instanceof TimeoutAsyncError) {
238
+ this.eventBus.dispatch(new TotalTimeoutFailureAsyncEvent({ error }));
239
+ }
240
+ throw error;
172
241
  }
173
- return timeoutAndFail(oldAsyncFn, this.settings.totalTimeout);
174
242
  };
175
243
  this.asyncFn = newAsyncFn;
176
244
  }
@@ -179,11 +247,19 @@ export class LazyPromise {
179
247
  return;
180
248
  }
181
249
  const oldAsyncFn = this.asyncFn;
182
- const newAsyncFn = () => {
183
- if (this.settings.abortSignal === null) {
184
- throw new Error(`LazyPromise["abortSignal"] field is null`);
250
+ const newAsyncFn = async () => {
251
+ try {
252
+ if (this.settings.abortSignal === null) {
253
+ throw new Error(`LazyPromise["abortSignal"] field is null`);
254
+ }
255
+ return await abortAndFail(oldAsyncFn, this.settings.abortSignal);
256
+ }
257
+ catch (error) {
258
+ if (error instanceof AbortAsyncError) {
259
+ this.eventBus.dispatch(new AbortAsyncEvent({ error }));
260
+ }
261
+ throw error;
185
262
  }
186
- return abortAndFail(oldAsyncFn, this.settings.abortSignal);
187
263
  };
188
264
  this.asyncFn = newAsyncFn;
189
265
  }
@@ -192,21 +268,6 @@ export class LazyPromise {
192
268
  this.applyTotalTimeout();
193
269
  this.applyAbort();
194
270
  }
195
- /**
196
- * @throws {AbortAsyncError} {@link AbortAsyncError}
197
- * @throws {TimeoutAsyncError} {@link TimeoutAsyncError}
198
- * @throws {RetryAsyncError} {@link RetryAsyncError}
199
- */
200
- then(onfulfilled,
201
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
202
- onrejected) {
203
- this.applySettings();
204
- if (this.promise === null) {
205
- this.promise = this.asyncFn();
206
- }
207
- // eslint-disable-next-line @typescript-eslint/use-unknown-in-catch-callback-variable
208
- return this.promise.then(onfulfilled, onrejected);
209
- }
210
271
  /**
211
272
  * The <i>setBackoffPolicy</i> method is used for setting a custom <i>{@link BackoffPolicy}</i>.
212
273
  * ```ts
@@ -355,23 +416,20 @@ export class LazyPromise {
355
416
  abortSignal,
356
417
  });
357
418
  }
358
- onFinally(cb) {
359
- return new LazyPromise(this.asyncFn, {
360
- ...this.settings,
361
- onFinally: cb,
362
- });
363
- }
364
- onSuccess(cb) {
365
- return new LazyPromise(this.asyncFn, {
366
- ...this.settings,
367
- onSuccess: cb,
368
- });
369
- }
370
- onError(cb) {
371
- return new LazyPromise(this.asyncFn, {
372
- ...this.settings,
373
- onError: cb,
374
- });
419
+ /**
420
+ * @throws {AbortAsyncError} {@link AbortAsyncError}
421
+ * @throws {TimeoutAsyncError} {@link TimeoutAsyncError}
422
+ * @throws {RetryAsyncError} {@link RetryAsyncError}
423
+ */
424
+ then(onfulfilled,
425
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
426
+ onrejected) {
427
+ this.applySettings();
428
+ if (this.promise === null) {
429
+ this.promise = this.asyncFn();
430
+ }
431
+ // eslint-disable-next-line @typescript-eslint/use-unknown-in-catch-callback-variable
432
+ return this.promise.then(onfulfilled, onrejected);
375
433
  }
376
434
  /**
377
435
  * The <i>defer</i> method executes the <i>LazyPromise</i> without awaiting it.
@@ -395,25 +453,21 @@ export class LazyPromise {
395
453
  * ```
396
454
  */
397
455
  defer() {
398
- const onSuccesHandler = async (value) => {
399
- try {
400
- await this.settings.onSuccess(value);
401
- return value;
402
- }
403
- finally {
404
- await this.settings.onFinally();
405
- }
456
+ const onFinally = () => {
457
+ this.eventBus.dispatch(new FinallyAsyncEvent({}));
458
+ this.eventBus.clear();
406
459
  };
407
- const onErrorHandler = async (error) => {
408
- try {
409
- await this.settings.onError(error);
410
- return error;
411
- }
412
- finally {
413
- await this.settings.onFinally();
414
- }
460
+ const onSuccess = (value) => {
461
+ this.eventBus.dispatch(new SuccessAsyncEvent({ value }));
462
+ onFinally();
463
+ return value;
464
+ };
465
+ const onFailure = (error) => {
466
+ this.eventBus.dispatch(new FailureAsyncEvent({ error }));
467
+ onFinally();
468
+ return error;
415
469
  };
416
- this.then(onSuccesHandler, onErrorHandler);
470
+ this.then(onSuccess, onFailure);
417
471
  }
418
472
  }
419
473
  //# sourceMappingURL=lazy-promise.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lazy-promise.js","sourceRoot":"","sources":["../../../../src/async/utilities/lazy-promise/lazy-promise.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,OAAO,EAAE,WAA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AAO,CAAC,EAAsB;QAC1B,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE;YACjC,GAAG,IAAI,CAAC,QAAQ;YAChB,OAAO,EAAE,EAAE;SACd,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,KAAK;QACD,MAAM,eAAe,GAAG,KAAK,EAAE,KAAa,EAAmB,EAAE;YAC7D,IAAI,CAAC;gBACD,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;gBACrC,OAAO,KAAK,CAAC;YACjB,CAAC;oBAAS,CAAC;gBACP,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;YACpC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,cAAc,GAAG,KAAK,EAAE,KAAc,EAAoB,EAAE;YAC9D,IAAI,CAAC;gBACD,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBACnC,OAAO,KAAK,CAAC;YACjB,CAAC;oBAAS,CAAC;gBACP,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;YACpC,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IAC/C,CAAC;CACJ"}
1
+ {"version":3,"file":"lazy-promise.js","sourceRoot":"","sources":["../../../../src/async/utilities/lazy-promise/lazy-promise.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO;AACH,6DAA6D;AAC7D,iBAAiB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO;AACH,6DAA6D;AAC7D,eAAe,GAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO;AACH,6D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export declare function retryOrFail<TValue = void>(asyncFn: () => PromiseLike<TValue>, settings?: RetrySettings): Promise<TValue>;
29
+ export declare function retryOrFail<TValue = void>(asyncFn: (attempt: number) => PromiseLike<TValue>, settings?: RetrySettings): Promise<TValue>;
@@ -13,7 +13,7 @@ export async function retryOrFail(asyncFn, settings = {}) {
13
13
  let error_;
14
14
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
15
15
  try {
16
- return await asyncFn();
16
+ return await asyncFn(attempt);
17
17
  }
18
18
  catch (error) {
19
19
  error_ = error;
@@ -1 +1 @@
1
- {"version":3,"file":"retry-or-fail.js","sourceRoot":"","sources":["../../../../src/async/utilities/retry/retry-or-fail.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAyB1D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC7B,OAAkC,EAClC,WAA0B,EAAE;IAE5B,MAAM,EACF,WAAW,GAAG,CAAC,EACf,aAAa,GAAG,wBAAwB,EAAE,EAC1C,WAAW,GAAG,GAAG,EAAE,CAAC,IAAI,GAC3B,GAAG,QAAQ,CAAC;IACb,IAAI,MAAe,CAAC;IACpB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC;QACtD,IAAI,CAAC;YACD,OAAO,MAAM,OAAO,EAAE,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACtB,MAAM,GAAG,KAAK,CAAC;YACf,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;gBACnC,MAAM,KAAK,CAAC;YAChB,CAAC;YACD,IAAI,CAAC,WA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,OAAO,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACtB,MAAM,GAAG,KAAK,CAAC;YACf,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;gBACnC,MAAM,KAAK,CAAC;YAChB,CAAC;YACD,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;gBACtB,MAAM,KAAK,CAAC;YAChB,CAAC;YACD,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC3C,MAAM,KAAK,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;QACjD,CAAC;IACL,CAAC;IAED,IAAI,YAAY,GAAG,oCAAoC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC;IACnF,IAAI,MAAM,EAAE,CAAC;QACT,YAAY,GAAG,GAAG,YAAY,+BAA+B,MAAM,CAAC,MAAiB,CAAC,GAAG,CAAC;IAC9F,CAAC;IACD,MAAM,IAAI,eAAe,CAAC,YAAY,EAAE;QACpC,KAAK,EAAE,MAAM;QACb,WAAW;KACd,CAAC,CAAC;AACP,CAAC"}
@@ -7,4 +7,4 @@ import type { RetrySettings } from "../../../async/utilities/retry/retry-or-fail
7
7
  /**
8
8
  * @internal
9
9
  */
10
- export declare function retry<TValue = void>(asyncFn: () => PromiseLike<TValue>, settings?: RetrySettings): Promise<Result<TValue, RetryAsyncError>>;
10
+ export declare function retry<TValue = void>(asyncFn: (attempt: number) => PromiseLike<TValue>, settings?: RetrySettings): Promise<Result<TValue, RetryAsyncError>>;
@@ -1 +1 @@
1
- {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../../src/async/utilities/retry/retry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAEvE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACvB,OAAkC,EAClC,WAA0B,EAAE;IAE5B,IAAI,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnD,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACtB,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACzB,CAAC;QACD,MAAM,KAAK,CAAC;IAChB,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../../src/async/utilities/retry/retry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAEvE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACvB,OAAiD,EACjD,WAA0B,EAAE;IAE5B,IAAI,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnD,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACtB,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACzB,CAAC;QACD,MAAM,KAAK,CAAC;IAChB,CAAC;AACL,CAAC"}