@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
@@ -1,3 +1,4 @@
1
1
  export * from "../async/backof-policies/_module.js";
2
2
  export * from "../async/utilities/_module.js";
3
3
  export * from "../async/async.errors.js";
4
+ export * from "../async/async.events.js";
@@ -1,4 +1,5 @@
1
1
  export * from "../async/backof-policies/_module.js";
2
2
  export * from "../async/utilities/_module.js";
3
3
  export * from "../async/async.errors.js";
4
+ export * from "../async/async.events.js";
4
5
  //# sourceMappingURL=_module-exports.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_module-exports.js","sourceRoot":"","sources":["../../src/async/_module-exports.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"_module-exports.js","sourceRoot":"","sources":["../../src/async/_module-exports.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
@@ -10,6 +10,7 @@ export declare class AsyncError extends Error {
10
10
  constructor(message: string, cause?: unknown);
11
11
  }
12
12
  /**
13
+ * This error is thrown when the <i>LazyPromise</i> is aborted.
13
14
  *
14
15
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
15
16
  * @group Errors
@@ -18,6 +19,7 @@ export declare class AbortAsyncError extends AsyncError {
18
19
  constructor(message: string, cause?: unknown);
19
20
  }
20
21
  /**
22
+ * This error is thrown when the <i>LazyPromise</i> has exceeded the given time limit.
21
23
  *
22
24
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
23
25
  * @group Errors
@@ -35,6 +37,7 @@ export type RetryAsyncErrorData = {
35
37
  maxAttempts: number;
36
38
  };
37
39
  /**
40
+ * This error is thrown when the <i>LazyPromise</i> has failed all retry attempts.
38
41
  *
39
42
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
40
43
  * @group Errors
@@ -43,3 +46,14 @@ export declare class RetryAsyncError extends AsyncError {
43
46
  readonly maxAttempts: number;
44
47
  constructor(message: string, { cause, maxAttempts }: RetryAsyncErrorData);
45
48
  }
49
+ /**
50
+ *
51
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
52
+ * @group Errors
53
+ */
54
+ export declare const ASYNC_ERRORS: {
55
+ readonly Base: typeof AsyncError;
56
+ readonly Abort: typeof AbortAsyncError;
57
+ readonly Timeout: typeof TimeoutAsyncError;
58
+ readonly Retry: typeof RetryAsyncError;
59
+ };
@@ -13,6 +13,7 @@ export class AsyncError extends Error {
13
13
  }
14
14
  }
15
15
  /**
16
+ * This error is thrown when the <i>LazyPromise</i> is aborted.
16
17
  *
17
18
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
18
19
  * @group Errors
@@ -24,6 +25,7 @@ export class AbortAsyncError extends AsyncError {
24
25
  }
25
26
  }
26
27
  /**
28
+ * This error is thrown when the <i>LazyPromise</i> has exceeded the given time limit.
27
29
  *
28
30
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
29
31
  * @group Errors
@@ -35,6 +37,7 @@ export class TimeoutAsyncError extends AsyncError {
35
37
  }
36
38
  }
37
39
  /**
40
+ * This error is thrown when the <i>LazyPromise</i> has failed all retry attempts.
38
41
  *
39
42
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
40
43
  * @group Errors
@@ -47,4 +50,15 @@ export class RetryAsyncError extends AsyncError {
47
50
  this.maxAttempts = maxAttempts;
48
51
  }
49
52
  }
53
+ /**
54
+ *
55
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
56
+ * @group Errors
57
+ */
58
+ export const ASYNC_ERRORS = {
59
+ Base: AsyncError,
60
+ Abort: AbortAsyncError,
61
+ Timeout: TimeoutAsyncError,
62
+ Retry: RetryAsyncError,
63
+ };
50
64
  //# sourceMappingURL=async.errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"async.errors.js","sourceRoot":"","sources":["../../src/async/async.errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACjC,YAAY,OAAe,EAAE,KAAe;QACxC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;IAChC,CAAC;CACJ;AAED;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC3C,YAAY,OAAe,EAAE,KAAe;QACxC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACtB,IAAI,CAAC,IA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AC,IAAI,CAAC;IACvC,CAAC;CACJ;AAYD;;;;;GAKG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC3B,WAAW,CAAS;IAEpC,YAAY,OAAe,EAAE,EAAE,KAAK,EAAE,WAAW,EAAuB;QACpE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;CACJ;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,eAAe;IACtB,OAAO,EAAE,iBAAiB;IAC1B,KAAK,EAAE,eAAe;CAChB,CAAC"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @module Async
3
+ */
4
+ import type { AbortAsyncError, RetryAsyncError, TimeoutAsyncError } from "../async/async.errors.js";
5
+ import { BaseEvent } from "../event-bus/contracts/_shared.js";
6
+ /**
7
+ * This event is dispatched when the <i>LazyPromise</i> has been rejected.
8
+ *
9
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
10
+ * @group Events
11
+ */
12
+ export declare class FailureAsyncEvent extends BaseEvent<{
13
+ error: unknown;
14
+ }> {
15
+ }
16
+ /**
17
+ * This event is dispatched when the <i>LazyPromise</i> has been fulfilled.
18
+ *
19
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
20
+ * @group Events
21
+ */
22
+ export declare class SuccessAsyncEvent<TValue> extends BaseEvent<{
23
+ value: TValue;
24
+ }> {
25
+ }
26
+ /**
27
+ * This event is dispatched when the <i>LazyPromise</i> has been fulfilled or rejected.
28
+ *
29
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
30
+ * @group Events
31
+ */
32
+ export declare class FinallyAsyncEvent extends BaseEvent<{}> {
33
+ }
34
+ /**
35
+ * This event is dispatched on every retry attempt of the <i>LazyPromise</i>.
36
+ *
37
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
38
+ * @group Events
39
+ */
40
+ export declare class RetryAttemptAsyncEvent extends BaseEvent<{
41
+ attempt: number;
42
+ error: unknown;
43
+ }> {
44
+ }
45
+ /**
46
+ * This event is dispatched when the rety attempt of the <i>LazyPromise</i> has exceeded the given time limit.
47
+ *
48
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
49
+ * @group Events
50
+ */
51
+ export declare class RetryTimeoutAsyncEvent extends BaseEvent<{
52
+ error: TimeoutAsyncError;
53
+ }> {
54
+ }
55
+ /**
56
+ * This event is dispatched when the <i>LazyPromise</i> has failed all retry attempts.
57
+ *
58
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
59
+ * @group Events
60
+ */
61
+ export declare class RetryFailureAsyncEvent extends BaseEvent<{
62
+ error: RetryAsyncError;
63
+ }> {
64
+ }
65
+ /**
66
+ * This event is dispatched when <i>LazyPromise</i> has exceeded the given total time limit.
67
+ *
68
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
69
+ * @group Events
70
+ */
71
+ export declare class TotalTimeoutFailureAsyncEvent extends BaseEvent<{
72
+ error: TimeoutAsyncError;
73
+ }> {
74
+ }
75
+ /**
76
+ * This event is dispatched when <i>LazyPromise</i> is aborted.
77
+ *
78
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
79
+ * @group Events
80
+ */
81
+ export declare class AbortAsyncEvent extends BaseEvent<{
82
+ error: AbortAsyncError;
83
+ }> {
84
+ }
85
+ /**
86
+ *
87
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
88
+ * @group Events
89
+ */
90
+ export declare const ASYNC_EVENTS: {
91
+ readonly Failure: typeof FailureAsyncEvent;
92
+ readonly Success: typeof SuccessAsyncEvent;
93
+ readonly Finally: typeof FinallyAsyncEvent;
94
+ readonly RetryAttempt: typeof RetryAttemptAsyncEvent;
95
+ readonly RetryTimeout: typeof RetryTimeoutAsyncEvent;
96
+ readonly RetryFailure: typeof RetryFailureAsyncEvent;
97
+ readonly TotalTimeoutFailure: typeof TotalTimeoutFailureAsyncEvent;
98
+ readonly Abort: typeof AbortAsyncEvent;
99
+ };
100
+ /**
101
+ *
102
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
103
+ * @group Events
104
+ */
105
+ export type AsyncEvents<TValue> = FailureAsyncEvent | SuccessAsyncEvent<TValue> | FinallyAsyncEvent | RetryAttemptAsyncEvent | RetryTimeoutAsyncEvent | RetryFailureAsyncEvent | TotalTimeoutFailureAsyncEvent | AbortAsyncEvent;
@@ -0,0 +1,82 @@
1
+ import { BaseEvent } from "../event-bus/contracts/_shared.js";
2
+ /**
3
+ * This event is dispatched when the <i>LazyPromise</i> has been rejected.
4
+ *
5
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
6
+ * @group Events
7
+ */
8
+ export class FailureAsyncEvent extends BaseEvent {
9
+ }
10
+ /**
11
+ * This event is dispatched when the <i>LazyPromise</i> has been fulfilled.
12
+ *
13
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
14
+ * @group Events
15
+ */
16
+ export class SuccessAsyncEvent extends BaseEvent {
17
+ }
18
+ /**
19
+ * This event is dispatched when the <i>LazyPromise</i> has been fulfilled or rejected.
20
+ *
21
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
22
+ * @group Events
23
+ */
24
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
25
+ export class FinallyAsyncEvent extends BaseEvent {
26
+ }
27
+ /**
28
+ * This event is dispatched on every retry attempt of the <i>LazyPromise</i>.
29
+ *
30
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
31
+ * @group Events
32
+ */
33
+ export class RetryAttemptAsyncEvent extends BaseEvent {
34
+ }
35
+ /**
36
+ * This event is dispatched when the rety attempt of the <i>LazyPromise</i> has exceeded the given time limit.
37
+ *
38
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
39
+ * @group Events
40
+ */
41
+ export class RetryTimeoutAsyncEvent extends BaseEvent {
42
+ }
43
+ /**
44
+ * This event is dispatched when the <i>LazyPromise</i> has failed all retry attempts.
45
+ *
46
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
47
+ * @group Events
48
+ */
49
+ export class RetryFailureAsyncEvent extends BaseEvent {
50
+ }
51
+ /**
52
+ * This event is dispatched when <i>LazyPromise</i> has exceeded the given total time limit.
53
+ *
54
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
55
+ * @group Events
56
+ */
57
+ export class TotalTimeoutFailureAsyncEvent extends BaseEvent {
58
+ }
59
+ /**
60
+ * This event is dispatched when <i>LazyPromise</i> is aborted.
61
+ *
62
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
63
+ * @group Events
64
+ */
65
+ export class AbortAsyncEvent extends BaseEvent {
66
+ }
67
+ /**
68
+ *
69
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
70
+ * @group Events
71
+ */
72
+ export const ASYNC_EVENTS = {
73
+ Failure: FailureAsyncEvent,
74
+ Success: SuccessAsyncEvent,
75
+ Finally: FinallyAsyncEvent,
76
+ RetryAttempt: RetryAttemptAsyncEvent,
77
+ RetryTimeout: RetryTimeoutAsyncEvent,
78
+ RetryFailure: RetryFailureAsyncEvent,
79
+ TotalTimeoutFailure: TotalTimeoutFailureAsyncEvent,
80
+ Abort: AbortAsyncEvent,
81
+ };
82
+ //# sourceMappingURL=async.events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async.events.js","sourceRoot":"","sources":["../../src/async/async.events.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,OAAO,iBAAkB,SAAQ,SAErC;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,iBAA0B,SAAQ,SAE7C;CAAG;AAEL;;;;;GAKG;AACH,mEAAmE;AACnE,MAAM,OAAO,iBAAkB,SAAQ,SAAa;CAAG;AAEvD;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,SAG1C;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,SAE1C;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,SAE1C;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,6BAA8B,SAAQ,SAEjD;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,eAAgB,SAAQ,SAEnC;CAAG;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,iBAAiB;IAC1B,YAAY,EAAE,sBAAsB;IACpC,YAAY,EAAE,sBAAsB;IACpC,YAAY,EAAE,sBAAsB;IACpC,mBAAmB,EAAE,6BAA6B;IAClD,KAAK,EAAE,eAAe;CAChB,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * @returns Amount milliseconds to wait
6
6
  *
7
7
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
8
- * @group Backoff policies
8
+ * @group BackoffPolicies
9
9
  */
10
10
  export type BackoffPolicy = (attempt: number, error: unknown) => number;
11
11
  /**
@@ -6,7 +6,7 @@ import { type BackoffPolicy } from "../../../async/backof-policies/_shared.js";
6
6
  /**
7
7
  *
8
8
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
9
- * @group Backoff policies
9
+ * @group BackoffPolicies
10
10
  */
11
11
  export type ConstantBackoffPolicySettings = {
12
12
  /**
@@ -27,6 +27,6 @@ export type ConstantBackoffPolicySettings = {
27
27
  * Constant backoff policy with jitter
28
28
  *
29
29
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
30
- * @group Backoff policies
30
+ * @group BackoffPolicies
31
31
  */
32
32
  export declare function constantBackoffPolicy(settings?: ConstantBackoffPolicySettings | ((error: unknown) => ConstantBackoffPolicySettings)): BackoffPolicy;
@@ -7,7 +7,7 @@ import { withJitter, } from "../../../async/backof-policies/_shared.js";
7
7
  * Constant backoff policy with jitter
8
8
  *
9
9
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
10
- * @group Backoff policies
10
+ * @group BackoffPolicies
11
11
  */
12
12
  export function constantBackoffPolicy(settings = {}) {
13
13
  return (_attempt, error) => {
@@ -6,7 +6,7 @@ import type { BackoffPolicy } from "../../../async/backof-policies/_shared.js";
6
6
  /**
7
7
  *
8
8
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
9
- * @group Backoff policies
9
+ * @group BackoffPolicies
10
10
  */
11
11
  export type ExponentialBackoffPolicySettings = {
12
12
  /**
@@ -35,6 +35,6 @@ export type ExponentialBackoffPolicySettings = {
35
35
  * Exponential backoff policy with jitter
36
36
  *
37
37
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
38
- * @group Backoff policies
38
+ * @group BackoffPolicies
39
39
  */
40
40
  export declare function exponentialBackoffPolicy(settings?: ExponentialBackoffPolicySettings | ((error: unknown) => ExponentialBackoffPolicySettings)): BackoffPolicy;
@@ -7,7 +7,7 @@ import { withJitter } from "../../../async/backof-policies/_shared.js";
7
7
  * Exponential backoff policy with jitter
8
8
  *
9
9
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
10
- * @group Backoff policies
10
+ * @group BackoffPolicies
11
11
  */
12
12
  export function exponentialBackoffPolicy(settings = {}) {
13
13
  return (attempt, error) => {
@@ -6,7 +6,7 @@ import type { BackoffPolicy } from "../../../async/backof-policies/_shared.js";
6
6
  /**
7
7
  *
8
8
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
9
- * @group Backoff policies
9
+ * @group BackoffPolicies
10
10
  */
11
11
  export type LinearBackoffPolicySettings = {
12
12
  /**
@@ -31,6 +31,6 @@ export type LinearBackoffPolicySettings = {
31
31
  * Linear backoff policy with jitter
32
32
  *
33
33
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
34
- * @group Backoff policies
34
+ * @group BackoffPolicies
35
35
  */
36
36
  export declare function linearBackoffPolicy(settings?: LinearBackoffPolicySettings | ((error: unknown) => LinearBackoffPolicySettings)): BackoffPolicy;
@@ -7,7 +7,7 @@ import { withJitter } from "../../../async/backof-policies/_shared.js";
7
7
  * Linear backoff policy with jitter
8
8
  *
9
9
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
10
- * @group Backoff policies
10
+ * @group BackoffPolicies
11
11
  */
12
12
  export function linearBackoffPolicy(settings = {}) {
13
13
  return (attempt, error) => {
@@ -6,7 +6,7 @@ import type { BackoffPolicy } from "../../../async/backof-policies/_shared.js";
6
6
  /**
7
7
  *
8
8
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
9
- * @group Backoff policies
9
+ * @group BackoffPolicies
10
10
  */
11
11
  export type PolynomialBackoffPolicySettings = {
12
12
  /**
@@ -35,6 +35,6 @@ export type PolynomialBackoffPolicySettings = {
35
35
  * Polynomial backoff policy with jitter
36
36
  *
37
37
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
38
- * @group Backoff policies
38
+ * @group BackoffPolicies
39
39
  */
40
40
  export declare function polynomialBackoffPolicy(settings?: PolynomialBackoffPolicySettings | ((error: unknown) => PolynomialBackoffPolicySettings)): BackoffPolicy;
@@ -7,7 +7,7 @@ import { withJitter } from "../../../async/backof-policies/_shared.js";
7
7
  * Polynomial backoff policy with jitter
8
8
  *
9
9
  * IMPORT_PATH: ```"@daiso-tech/core/async"```
10
- * @group Backoff policies
10
+ * @group BackoffPolicies
11
11
  */
12
12
  export function polynomialBackoffPolicy(settings = {}) {
13
13
  return (attempt, error) => {
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module Async
3
+ */
4
+ import { type Invokable } from "../../../utilities/_module-exports.js";
5
+ import type { ILazyPromiseListener } from "../../../async/utilities/lazy-promise/lazy-promise-listener.contract.js";
6
+ /**
7
+ * @internal
8
+ */
9
+ export declare class LazyPromiseEventBus<TEventMap extends Record<string, unknown>> implements ILazyPromiseListener<TEventMap> {
10
+ private readonly eventMap;
11
+ dispatch<TEventName extends keyof TEventMap>(eventName: Extract<TEventName, string>, event: TEventMap[TEventName]): void;
12
+ addListener<TEventName extends keyof TEventMap>(eventName: Extract<TEventName, string>, listener: Invokable<[event: TEventMap[TEventName]]>): void;
13
+ removeListener<TEventName extends keyof TEventMap>(eventName: Extract<TEventName, string>, listener: Invokable<[event: TEventMap[TEventName]]>): void;
14
+ clear(): void;
15
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @module Async
3
+ */
4
+ import { callInvokable } from "../../../utilities/_module-exports.js";
5
+ /**
6
+ * @internal
7
+ */
8
+ export class LazyPromiseEventBus {
9
+ eventMap = new Map();
10
+ dispatch(eventName, event) {
11
+ if (this.eventMap.size === 0) {
12
+ return;
13
+ }
14
+ const eventListeners = this.eventMap.get(eventName);
15
+ if (eventListeners === undefined) {
16
+ return;
17
+ }
18
+ if (eventListeners.size === 0) {
19
+ return;
20
+ }
21
+ for (const eventListener of eventListeners) {
22
+ callInvokable(eventListener, event);
23
+ }
24
+ }
25
+ addListener(eventName, listener) {
26
+ let eventListeners = this.eventMap.get(eventName);
27
+ if (eventListeners === undefined) {
28
+ eventListeners = new Set();
29
+ this.eventMap.set(eventName, eventListeners);
30
+ }
31
+ eventListeners.add(listener);
32
+ }
33
+ removeListener(eventName, listener) {
34
+ const eventListeners = this.eventMap.get(eventName);
35
+ if (eventListeners === undefined) {
36
+ return;
37
+ }
38
+ eventListeners.delete(listener);
39
+ if (eventListeners.size === 0) {
40
+ this.eventMap.delete(eventName);
41
+ }
42
+ }
43
+ clear() {
44
+ for (const eventListeners of this.eventMap.values()) {
45
+ eventListeners.clear();
46
+ }
47
+ this.eventMap.clear();
48
+ }
49
+ }
50
+ //# sourceMappingURL=lazy-promise-event-bus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy-promise-event-bus.js","sourceRoot":"","sources":["../../../../src/async/utilities/lazy-promise/lazy-promise-event-bus.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAkB,MAAM,gCAAgC,CAAC;AAG/E;;GA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AAC,CAAC;QACpC,CAAC;IACL,CAAC;IAED,KAAK;QACD,KAAK,MAAM,cAAc,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAClD,cAAc,CAAC,KAAK,EAAE,CAAC;QAC3B,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACJ"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @module Async
3
+ */
4
+ import { type Invokable } from "../../../utilities/_module-exports.js";
5
+ /**
6
+ *
7
+ * IMPORT_PATH: ```"@daiso-tech/core/async"```
8
+ * @group Utilities
9
+ */
10
+ export type ILazyPromiseListener<TEventMap extends Record<string, unknown>> = {
11
+ addListener<TEventName extends keyof TEventMap>(eventName: Extract<TEventName, string>, listener: Invokable<[event: TEventMap[TEventName]]>): void;
12
+ removeListener<TEventName extends keyof TEventMap>(eventName: Extract<TEventName, string>, listener: Invokable<[event: TEventMap[TEventName]]>): void;
13
+ };
14
+ /**
15
+ * @internal
16
+ */
17
+ export declare class LazyPromiseEventBus<TEventMap extends Record<string, unknown>> implements ILazyPromiseListener<TEventMap> {
18
+ private readonly eventMap;
19
+ dispatch<TEventName extends keyof TEventMap>(eventName: Extract<TEventName, string>, event: TEventMap[TEventName]): void;
20
+ addListener<TEventName extends keyof TEventMap>(eventName: Extract<TEventName, string>, listener: Invokable<[event: TEventMap[TEventName]]>): void;
21
+ removeListener<TEventName extends keyof TEventMap>(eventName: Extract<TEventName, string>, listener: Invokable<[event: TEventMap[TEventName]]>): void;
22
+ clear(): void;
23
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @module Async
3
+ */
4
+ import { callInvokable } from "../../../utilities/_module-exports.js";
5
+ /**
6
+ * @internal
7
+ */
8
+ export class LazyPromiseEventBus {
9
+ eventMap = new Map();
10
+ dispatch(eventName, event) {
11
+ const eventListeners = this.eventMap.get(eventName);
12
+ if (eventListeners === undefined) {
13
+ return;
14
+ }
15
+ for (const eventListener of eventListeners) {
16
+ callInvokable(eventListener, event);
17
+ }
18
+ }
19
+ addListener(eventName, listener) {
20
+ let eventListeners = this.eventMap.get(eventName);
21
+ if (eventListeners === undefined) {
22
+ eventListeners = new Set();
23
+ this.eventMap.set(eventName, eventListeners);
24
+ }
25
+ eventListeners.add(listener);
26
+ }
27
+ removeListener(eventName, listener) {
28
+ const eventListeners = this.eventMap.get(eventName);
29
+ if (eventListeners === undefined) {
30
+ return;
31
+ }
32
+ eventListeners.delete(listener);
33
+ if (eventListeners.size === 0) {
34
+ this.eventMap.delete(eventName);
35
+ }
36
+ }
37
+ clear() {
38
+ for (const eventListeners of this.eventMap.values()) {
39
+ eventListeners.clear();
40
+ }
41
+ this.eventMap.clear();
42
+ }
43
+ }
44
+ //# sourceMappingURL=lazy-promise-listener.contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy-promise-listener.contract.js","sourceRoot":"","sources":["../../../../src/async/utilities/lazy-promise/lazy-promise-listener.contract.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAkB,MAAM,gCAAgC,CAAC;AAmB/E;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAGX,QAAQ,GAAG,IAAI,GAAG,EAAwC,CAAC;IAE5E,QAAQ,CACJ,SAAsC,EACtC,KAA4B;QAE5B,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACpD,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YAC/B,OAAO;QACX,CAAC;QACD,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;YACzC,aAAa,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;IACL,CAAC;IAED,WAAW,CACP,SAAsC,EACtC,QAAmD;QAEnD,IAAI,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,cAAc,KAAK,SA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