@daiso-tech/core 0.37.3 → 0.38.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 (155) hide show
  1. package/dist/async/_module-exports.d.ts +1 -1
  2. package/dist/async/_module-exports.js +1 -1
  3. package/dist/async/_module-exports.js.map +1 -1
  4. package/dist/async/async.errors.d.ts +0 -20
  5. package/dist/async/async.errors.js +0 -16
  6. package/dist/async/async.errors.js.map +1 -1
  7. package/dist/async/middlewares/_module.d.ts +0 -1
  8. package/dist/async/middlewares/_module.js +0 -1
  9. package/dist/async/middlewares/_module.js.map +1 -1
  10. package/dist/async/middlewares/bulkhead/bulkhead.middleware.js +1 -1
  11. package/dist/async/middlewares/bulkhead/bulkhead.middleware.js.map +1 -1
  12. package/dist/async/middlewares/fallback/_module.d.ts +1 -0
  13. package/dist/async/middlewares/fallback/_module.js +1 -0
  14. package/dist/async/middlewares/fallback/_module.js.map +1 -1
  15. package/dist/async/middlewares/fallback/fallback.middleware.d.ts +25 -49
  16. package/dist/async/middlewares/fallback/fallback.middleware.js +52 -14
  17. package/dist/async/middlewares/fallback/fallback.middleware.js.map +1 -1
  18. package/dist/async/middlewares/fallback/fallback.types.d.ts +42 -0
  19. package/dist/async/middlewares/fallback/fallback.types.js +6 -0
  20. package/dist/async/middlewares/fallback/fallback.types.js.map +1 -0
  21. package/dist/async/middlewares/hedging/_module.d.ts +2 -2
  22. package/dist/async/middlewares/hedging/_module.js +2 -2
  23. package/dist/async/middlewares/hedging/_module.js.map +1 -1
  24. package/dist/async/middlewares/hedging/{_shared.d.ts → hedging.types.d.ts} +37 -9
  25. package/dist/async/middlewares/hedging/hedging.types.js +6 -0
  26. package/dist/async/middlewares/hedging/hedging.types.js.map +1 -0
  27. package/dist/async/middlewares/hedging/{sequential-hedging/sequential-hedging.middleware.d.ts → sequential-hedging.middleware.d.ts} +3 -3
  28. package/dist/async/middlewares/hedging/sequential-hedging.middleware.js +133 -0
  29. package/dist/async/middlewares/hedging/sequential-hedging.middleware.js.map +1 -0
  30. package/dist/async/middlewares/observe/_module.d.ts +1 -0
  31. package/dist/async/middlewares/observe/_module.js +1 -0
  32. package/dist/async/middlewares/observe/_module.js.map +1 -1
  33. package/dist/async/middlewares/observe/observe.middleware.d.ts +37 -87
  34. package/dist/async/middlewares/observe/observe.middleware.js +53 -2
  35. package/dist/async/middlewares/observe/observe.middleware.js.map +1 -1
  36. package/dist/async/middlewares/observe/observe.types.d.ts +91 -0
  37. package/dist/async/middlewares/observe/observe.types.js +6 -0
  38. package/dist/async/middlewares/observe/observe.types.js.map +1 -0
  39. package/dist/async/middlewares/retry/_module.d.ts +1 -0
  40. package/dist/async/middlewares/retry/_module.js +1 -0
  41. package/dist/async/middlewares/retry/_module.js.map +1 -1
  42. package/dist/async/middlewares/retry/retry.middleware.d.ts +36 -86
  43. package/dist/async/middlewares/retry/retry.middleware.js +70 -22
  44. package/dist/async/middlewares/retry/retry.middleware.js.map +1 -1
  45. package/dist/async/middlewares/retry/retry.types.d.ts +77 -0
  46. package/dist/async/middlewares/retry/retry.types.js +7 -0
  47. package/dist/async/middlewares/retry/retry.types.js.map +1 -0
  48. package/dist/async/middlewares/timeout/_module.d.ts +1 -0
  49. package/dist/async/middlewares/timeout/_module.js +1 -0
  50. package/dist/async/middlewares/timeout/_module.js.map +1 -1
  51. package/dist/async/middlewares/timeout/timeout.middleware.d.ts +1 -47
  52. package/dist/async/middlewares/timeout/timeout.middleware.js +1 -1
  53. package/dist/async/middlewares/timeout/timeout.middleware.js.map +1 -1
  54. package/dist/async/middlewares/timeout/timeout.type.d.ts +51 -0
  55. package/dist/async/middlewares/timeout/timeout.type.js +6 -0
  56. package/dist/async/middlewares/timeout/timeout.type.js.map +1 -0
  57. package/dist/async/utilities/promise-queue/promise-queue.js +19 -8
  58. package/dist/async/utilities/promise-queue/promise-queue.js.map +1 -1
  59. package/dist/event-bus/contracts/event-bus.contract.d.ts +0 -6
  60. package/dist/event-bus/contracts/event-bus.contract.js +1 -7
  61. package/dist/event-bus/contracts/event-bus.contract.js.map +1 -1
  62. package/dist/event-bus/contracts/event-bus.errors.d.ts +0 -32
  63. package/dist/event-bus/contracts/event-bus.errors.js +1 -49
  64. package/dist/event-bus/contracts/event-bus.errors.js.map +1 -1
  65. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +6 -11
  66. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
  67. package/dist/lock/contracts/lock.contract.d.ts +2 -18
  68. package/dist/lock/contracts/lock.errors.d.ts +0 -24
  69. package/dist/lock/contracts/lock.errors.js +0 -46
  70. package/dist/lock/contracts/lock.errors.js.map +1 -1
  71. package/dist/lock/implementations/derivables/lock-provider/lock.js +4 -4
  72. package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
  73. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +15 -19
  74. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
  75. package/dist/utilities/_module-exports.d.ts +1 -1
  76. package/dist/utilities/_module-exports.js +1 -1
  77. package/dist/utilities/_module-exports.js.map +1 -1
  78. package/dist/utilities/classes/hooks/async-hooks.d.ts +6 -4
  79. package/dist/utilities/classes/hooks/async-hooks.js +3 -1
  80. package/dist/utilities/classes/hooks/async-hooks.js.map +1 -1
  81. package/dist/utilities/classes/hooks/hooks.d.ts +1 -1
  82. package/dist/utilities/classes/hooks/hooks.js +1 -1
  83. package/dist/utilities/classes/hooks/hooks.js.map +1 -1
  84. package/dist/utilities/classes/namespace/namespace.d.ts +2 -2
  85. package/dist/utilities/classes/namespace/namespace.js.map +1 -1
  86. package/dist/utilities/functions/{_module-exports.d.ts → _module.d.ts} +5 -1
  87. package/dist/utilities/functions/{_module-exports.js → _module.js} +6 -2
  88. package/dist/utilities/functions/_module.js.map +1 -0
  89. package/dist/utilities/functions/error-policy.d.ts +54 -0
  90. package/dist/utilities/functions/error-policy.js +63 -0
  91. package/dist/utilities/functions/error-policy.js.map +1 -0
  92. package/dist/utilities/functions/invokable.d.ts +57 -1
  93. package/dist/utilities/functions/invokable.js +3 -1
  94. package/dist/utilities/functions/invokable.js.map +1 -1
  95. package/dist/utilities/functions/is-class.d.ts +5 -0
  96. package/dist/utilities/functions/is-class.js +11 -0
  97. package/dist/utilities/functions/is-class.js.map +1 -0
  98. package/dist/utilities/functions/is-standard-schema.d.ts +2 -0
  99. package/dist/utilities/functions/is-standard-schema.js +5 -0
  100. package/dist/utilities/functions/is-standard-schema.js.map +1 -0
  101. package/dist/utilities/functions/lazy.d.ts +27 -1
  102. package/dist/utilities/functions/lazy.js.map +1 -1
  103. package/dist/utilities/functions/option.d.ts +32 -0
  104. package/dist/utilities/functions/option.js +25 -0
  105. package/dist/utilities/functions/option.js.map +1 -0
  106. package/dist/utilities/functions/resolve-one-or-more.d.ts +5 -1
  107. package/dist/utilities/functions/resolve-one-or-more.js.map +1 -1
  108. package/dist/utilities/functions/result.d.ts +81 -1
  109. package/dist/utilities/functions/result.js +46 -2
  110. package/dist/utilities/functions/result.js.map +1 -1
  111. package/dist/utilities/types/_module.d.ts +1 -7
  112. package/dist/utilities/types/_module.js +1 -7
  113. package/dist/utilities/types/_module.js.map +1 -1
  114. package/dist/utilities/types/any-class.type.d.ts +3 -0
  115. package/dist/utilities/types/any-class.type.js +2 -0
  116. package/dist/utilities/types/any-class.type.js.map +1 -0
  117. package/package.json +1 -1
  118. package/dist/async/middlewares/_shared.d.ts +0 -15
  119. package/dist/async/middlewares/_shared.js +0 -15
  120. package/dist/async/middlewares/_shared.js.map +0 -1
  121. package/dist/async/middlewares/hedging/_shared.js +0 -5
  122. package/dist/async/middlewares/hedging/_shared.js.map +0 -1
  123. package/dist/async/middlewares/hedging/concurrent-hedging/_module.d.ts +0 -1
  124. package/dist/async/middlewares/hedging/concurrent-hedging/_module.js +0 -2
  125. package/dist/async/middlewares/hedging/concurrent-hedging/_module.js.map +0 -1
  126. package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.d.ts +0 -51
  127. package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js +0 -138
  128. package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js.map +0 -1
  129. package/dist/async/middlewares/hedging/sequential-hedging/_module.d.ts +0 -1
  130. package/dist/async/middlewares/hedging/sequential-hedging/_module.js +0 -2
  131. package/dist/async/middlewares/hedging/sequential-hedging/_module.js.map +0 -1
  132. package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js +0 -104
  133. package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js.map +0 -1
  134. package/dist/utilities/functions/_module-exports.js.map +0 -1
  135. package/dist/utilities/types/at-least-one.type.d.ts +0 -8
  136. package/dist/utilities/types/at-least-one.type.js +0 -5
  137. package/dist/utilities/types/at-least-one.type.js.map +0 -1
  138. package/dist/utilities/types/factory.type.d.ts +0 -44
  139. package/dist/utilities/types/factory.type.js +0 -5
  140. package/dist/utilities/types/factory.type.js.map +0 -1
  141. package/dist/utilities/types/invokable.type.d.ts +0 -20
  142. package/dist/utilities/types/invokable.type.js +0 -5
  143. package/dist/utilities/types/invokable.type.js.map +0 -1
  144. package/dist/utilities/types/items.type.d.ts +0 -8
  145. package/dist/utilities/types/items.type.js +0 -5
  146. package/dist/utilities/types/items.type.js.map +0 -1
  147. package/dist/utilities/types/lazy.type.d.ts +0 -31
  148. package/dist/utilities/types/lazy.type.js +0 -5
  149. package/dist/utilities/types/lazy.type.js.map +0 -1
  150. package/dist/utilities/types/one-or-more.type.d.ts +0 -8
  151. package/dist/utilities/types/one-or-more.type.js +0 -5
  152. package/dist/utilities/types/one-or-more.type.js.map +0 -1
  153. package/dist/utilities/types/result.type.d.ts +0 -18
  154. package/dist/utilities/types/result.type.js +0 -5
  155. package/dist/utilities/types/result.type.js.map +0 -1
@@ -1,2 +1,3 @@
1
1
  export * from "../../../async/middlewares/observe/observe.middleware.js";
2
+ export * from "../../../async/middlewares/observe/observe.types.js";
2
3
  //# sourceMappingURL=_module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../src/async/middlewares/observe/_module.ts"],"names":[],"mappings":"AAAA,cAAc,mDAAmD,CAAC"}
1
+ {"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../src/async/middlewares/observe/_module.ts"],"names":[],"mappings":"AAAA,cAAc,mDAAmD,CAAC;AAClE,cAAc,8CAA8C,CAAC"}
@@ -1,93 +1,9 @@
1
1
  /**
2
2
  * @module Async
3
3
  */
4
- import { TimeSpan, type HookContext } from "../../../utilities/_module-exports.js";
5
- import { type AsyncMiddlewareFn, type Invokable } from "../../../utilities/_module-exports.js";
6
- /**
7
- *
8
- * IMPORT_PATH: `"@daiso-tech/core/async"`
9
- * @group Middlewares
10
- */
11
- export type OnObserveStartData<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = {
12
- args: TParameters;
13
- context: TContext;
14
- };
15
- /**
16
- *
17
- * IMPORT_PATH: `"@daiso-tech/core/async"`
18
- * @group Middlewares
19
- */
20
- export type OnObserveStart<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = Invokable<[data: OnObserveStartData<TParameters, TContext>]>;
21
- /**
22
- *
23
- * IMPORT_PATH: `"@daiso-tech/core/async"`
24
- * @group Middlewares
25
- */
26
- export type OnObserveSuccessData<TParameters extends unknown[] = unknown[], TReturn = unknown, TContext extends HookContext = HookContext> = {
27
- returnValue: TReturn;
28
- args: TParameters;
29
- context: TContext;
30
- };
31
- /**
32
- *
33
- * IMPORT_PATH: `"@daiso-tech/core/async"`
34
- * @group Middlewares
35
- */
36
- export type OnObserveSuccess<TParameters extends unknown[] = unknown[], TReturn = unknown, TContext extends HookContext = HookContext> = Invokable<[data: OnObserveSuccessData<TParameters, TReturn, TContext>]>;
37
- /**
38
- *
39
- * IMPORT_PATH: `"@daiso-tech/core/async"`
40
- * @group Middlewares
41
- */
42
- export type OnObserveErrorData<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = {
43
- error: unknown;
44
- args: TParameters;
45
- context: TContext;
46
- };
47
- /**
48
- *
49
- * IMPORT_PATH: `"@daiso-tech/core/async"`
50
- * @group Middlewares
51
- */
52
- export type OnObserveFinallyData<TContext extends HookContext = HookContext> = {
53
- executionTime: TimeSpan;
54
- context: TContext;
55
- };
56
- /**
57
- *
58
- * IMPORT_PATH: `"@daiso-tech/core/async"`
59
- * @group Middlewares
60
- */
61
- export type OnObserveError<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = Invokable<[data: OnObserveErrorData<TParameters, TContext>]>;
62
- /**
63
- *
64
- * IMPORT_PATH: `"@daiso-tech/core/async"`
65
- * @group Middlewares
66
- */
67
- export type OnObserveFinally<TContext extends HookContext = HookContext> = Invokable<[data: OnObserveFinallyData<TContext>]>;
68
- /**
69
- *
70
- * IMPORT_PATH: `"@daiso-tech/core/async"`
71
- * @group Middlewares
72
- */
73
- export type ObserveCallbacks<TParameters extends unknown[] = unknown[], TReturn = unknown, TContext extends HookContext = HookContext> = {
74
- /**
75
- * Callback {@link Invokable | `Invokable`} that will be called when before the underlying {@link Invokable | `Invokable`} is called.
76
- */
77
- onStart?: OnObserveStart<TParameters, TContext>;
78
- /**
79
- * Callback {@link Invokable | `Invokable`} that will be called when the underlying {@link Invokable | `Invokable`} is successfully called.
80
- */
81
- onSuccess?: OnObserveSuccess<TParameters, TReturn, TContext>;
82
- /**
83
- * Callback {@link Invokable | `Invokable`} that will be called when the underlying {@link Invokable | `Invokable`} throws an error.
84
- */
85
- onError?: OnObserveError<TParameters, TContext>;
86
- /**
87
- * Callback {@link Invokable | `Invokable`} that will be called when the underlying {@link Invokable | `Invokable`} throws an error or is successfully called.
88
- */
89
- onFinally?: OnObserveFinally<TContext>;
90
- };
4
+ import { type HookContext } from "../../../utilities/_module-exports.js";
5
+ import { type AsyncMiddlewareFn } from "../../../utilities/_module-exports.js";
6
+ import type { ObserveCallbacks } from "../../../async/middlewares/observe/observe.types.js";
91
7
  /**
92
8
  * The `observe` middleware tracks an async function's state and runs callbacks when it fails with an error or succeeds.
93
9
  *
@@ -126,5 +42,39 @@ export type ObserveCallbacks<TParameters extends unknown[] = unknown[], TReturn
126
42
  * // Will log if the function errored, arguments and the error.
127
43
  * // Will log the execution time and arguments
128
44
  * ```
45
+ *
46
+ * The middleware works also when the function returns a {@link Result | `Result`} type.
47
+ * @example
48
+ * ```ts
49
+ * import { observe, LazyPromise } from "@daiso-tech/core/async";
50
+ * import { AsyncHooks, TimeSpan, Result, resultFailure, resultSuccess } from "@daiso-tech/core/utilities";
51
+ *
52
+ * await new AsyncHooks(
53
+ * // Lets pretend this function can throw and takes time to execute.
54
+ * async (a: number, b: number): Promise<Result<number, Error>> => {
55
+ * const shouldThrow1 = Math.round(Math.random() * 100);
56
+ * if (shouldThrow1 > 50) {
57
+ * return resultFailure(new Error("Unexpected error occured"));
58
+ * }
59
+ * await LazyPromise.delay(TimeSpan.fromMilliseconds(Math.random() * 1000));
60
+ * const shouldThrow2 = Math.round(Math.random() * 100);
61
+ * if (shouldThrow2 > 50) {
62
+ * return resultFailure(new Error("Unexpected error occured"));
63
+ * }
64
+ * return resultSuccess(a / b);
65
+ * },
66
+ * observe({
67
+ * onStart: (data) => console.log("START:", data),
68
+ * onSuccess: (data) => console.log("SUCCESS:", data),
69
+ * onError: (data) => console.error("ERROR:", data),
70
+ * onFinally: (data) => console.log("FINALLY:", data),
71
+ * })
72
+ * )
73
+ * .invoke(20, 10);
74
+ * // Will log when the function execution has started and the arguments.
75
+ * // Will log if the function succeded, the arguments and the return value.
76
+ * // Will log if the function errored, arguments and the error.
77
+ * // Will log the execution time and arguments
78
+ * ```
129
79
  */
130
80
  export declare function observe<TParameters extends unknown[], TReturn, TContext extends HookContext>(settings: NoInfer<ObserveCallbacks<TParameters, TReturn, TContext>>): AsyncMiddlewareFn<TParameters, TReturn, TContext>;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @module Async
3
3
  */
4
- import { TimeSpan } from "../../../utilities/_module-exports.js";
4
+ import { isResult, RESULT, TimeSpan, } from "../../../utilities/_module-exports.js";
5
5
  import { callInvokable, } from "../../../utilities/_module-exports.js";
6
6
  /**
7
7
  * The `observe` middleware tracks an async function's state and runs callbacks when it fails with an error or succeeds.
@@ -41,6 +41,40 @@ import { callInvokable, } from "../../../utilities/_module-exports.js";
41
41
  * // Will log if the function errored, arguments and the error.
42
42
  * // Will log the execution time and arguments
43
43
  * ```
44
+ *
45
+ * The middleware works also when the function returns a {@link Result | `Result`} type.
46
+ * @example
47
+ * ```ts
48
+ * import { observe, LazyPromise } from "@daiso-tech/core/async";
49
+ * import { AsyncHooks, TimeSpan, Result, resultFailure, resultSuccess } from "@daiso-tech/core/utilities";
50
+ *
51
+ * await new AsyncHooks(
52
+ * // Lets pretend this function can throw and takes time to execute.
53
+ * async (a: number, b: number): Promise<Result<number, Error>> => {
54
+ * const shouldThrow1 = Math.round(Math.random() * 100);
55
+ * if (shouldThrow1 > 50) {
56
+ * return resultFailure(new Error("Unexpected error occured"));
57
+ * }
58
+ * await LazyPromise.delay(TimeSpan.fromMilliseconds(Math.random() * 1000));
59
+ * const shouldThrow2 = Math.round(Math.random() * 100);
60
+ * if (shouldThrow2 > 50) {
61
+ * return resultFailure(new Error("Unexpected error occured"));
62
+ * }
63
+ * return resultSuccess(a / b);
64
+ * },
65
+ * observe({
66
+ * onStart: (data) => console.log("START:", data),
67
+ * onSuccess: (data) => console.log("SUCCESS:", data),
68
+ * onError: (data) => console.error("ERROR:", data),
69
+ * onFinally: (data) => console.log("FINALLY:", data),
70
+ * })
71
+ * )
72
+ * .invoke(20, 10);
73
+ * // Will log when the function execution has started and the arguments.
74
+ * // Will log if the function succeded, the arguments and the return value.
75
+ * // Will log if the function errored, arguments and the error.
76
+ * // Will log the execution time and arguments
77
+ * ```
44
78
  */
45
79
  export function observe(settings) {
46
80
  const { onStart = () => { }, onSuccess = () => { }, onError = () => { }, onFinally = () => { }, } = settings;
@@ -52,10 +86,27 @@ export function observe(settings) {
52
86
  context,
53
87
  });
54
88
  const returnValue = await next(...args);
89
+ // Should handle when Result type is returned
90
+ if (isResult(returnValue)) {
91
+ if (returnValue.type === RESULT.SUCCESS) {
92
+ callInvokable(onSuccess, {
93
+ args,
94
+ context,
95
+ returnValue: returnValue.value,
96
+ });
97
+ return returnValue;
98
+ }
99
+ callInvokable(onError, {
100
+ args,
101
+ context,
102
+ error: returnValue.error,
103
+ });
104
+ return returnValue;
105
+ }
55
106
  callInvokable(onSuccess, {
56
107
  args,
57
108
  context,
58
- returnValue,
109
+ returnValue: returnValue,
59
110
  });
60
111
  return returnValue;
61
112
  }
@@ -1 +1 @@
1
- {"version":3,"file":"observe.middleware.js","sourceRoot":"","sources":["../../../../src/async/middlewares/observe/observe.middleware.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAoB,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EACH,aAAa,GAGhB,MAAM,gCAAgC,CAAC;AA4HxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,UAAU,OAAO,CAKnB,QAAmE;IAEnE,MAAM,EACF,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,EAClB,SAAS,GAAG,GAAG,EAAE,GAAE,CAAC,EACpB,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,EAClB,SAAS,GAAG,GAAG,EAAE,GAAE,CAAC,GACvB,GAAG,QAAQ,CAAC;IACb,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC;YACD,aAAa,CAAC,OAAO,EAAE;gBACnB,IAAI;gBACJ,OAAO;aACV,CAAC,CAAC;YACH,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;YACxC,aAAa,CAAC,SAAS,EAAE;gBACrB,IAAI;gBACJ,OAAO;gBACP,WAAW;aACd,CAAC,CAAC;YACH,OAAO,WAAW,CAAC;QACvB,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACtB,aAAa,CAAC,OAAO,EAAE;gBACnB,IAAI;gBACJ,OAAO;gBACP,KAAK;aACR,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;QAChB,CAAC;gBAAS,CAAC;YACP,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC;YACzB,aAAa,CAAC,SAAS,EAAE;gBACrB,OAAO;gBACP,aAAa,EAAE,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC;aACjD,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC;AACN,CAAC"}
1
+ {"version":3,"file":"observe.middleware.js","sourceRoot":"","sources":["../../../../src/async/middlewares/observe/observe.middleware.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,QAAQ,EACR,MAAM,EACN,QAAQ,GAGX,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACH,aAAa,GAEhB,MAAM,gCAAgC,CAAC;AAGxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,MAAM,UAAU,OAAO,CAKnB,QAAmE;IAEnE,MAAM,EACF,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,EAClB,SAAS,GAAG,GAAG,EAAE,GAAE,CAAC,EACpB,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,EAClB,SAAS,GAAG,GAAG,EAAE,GAAE,CAAC,GACvB,GAAG,QAAQ,CAAC;IACb,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC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ities/_module-exports.js";
5
+ import { type HookContext } from "../../../utilities/_module-exports.js";
6
+ import { type Invokable } from "../../../utilities/_module-exports.js";
7
+ /**
8
+ *
9
+ * IMPORT_PATH: `"@daiso-tech/core/async"`
10
+ * @group Middlewares
11
+ */
12
+ export type OnObserveStartData<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = {
13
+ args: TParameters;
14
+ context: TContext;
15
+ };
16
+ /**
17
+ *
18
+ * IMPORT_PATH: `"@daiso-tech/core/async"`
19
+ * @group Middlewares
20
+ */
21
+ export type OnObserveStart<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = Invokable<[data: OnObserveStartData<TParameters, TContext>]>;
22
+ /**
23
+ *
24
+ * IMPORT_PATH: `"@daiso-tech/core/async"`
25
+ * @group Middlewares
26
+ */
27
+ export type OnObserveSuccessData<TParameters extends unknown[] = unknown[], TReturn = unknown, TContext extends HookContext = HookContext> = {
28
+ returnValue: InferResultSuccess<TReturn>;
29
+ args: TParameters;
30
+ context: TContext;
31
+ };
32
+ /**
33
+ *
34
+ * IMPORT_PATH: `"@daiso-tech/core/async"`
35
+ * @group Middlewares
36
+ */
37
+ export type OnObserveSuccess<TParameters extends unknown[] = unknown[], TReturn = unknown, TContext extends HookContext = HookContext> = Invokable<[data: OnObserveSuccessData<TParameters, TReturn, TContext>]>;
38
+ /**
39
+ *
40
+ * IMPORT_PATH: `"@daiso-tech/core/async"`
41
+ * @group Middlewares
42
+ */
43
+ export type OnObserveErrorData<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = {
44
+ error: unknown;
45
+ args: TParameters;
46
+ context: TContext;
47
+ };
48
+ /**
49
+ *
50
+ * IMPORT_PATH: `"@daiso-tech/core/async"`
51
+ * @group Middlewares
52
+ */
53
+ export type OnObserveFinallyData<TContext extends HookContext = HookContext> = {
54
+ executionTime: TimeSpan;
55
+ context: TContext;
56
+ };
57
+ /**
58
+ *
59
+ * IMPORT_PATH: `"@daiso-tech/core/async"`
60
+ * @group Middlewares
61
+ */
62
+ export type OnObserveError<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = Invokable<[data: OnObserveErrorData<TParameters, TContext>]>;
63
+ /**
64
+ *
65
+ * IMPORT_PATH: `"@daiso-tech/core/async"`
66
+ * @group Middlewares
67
+ */
68
+ export type OnObserveFinally<TContext extends HookContext = HookContext> = Invokable<[data: OnObserveFinallyData<TContext>]>;
69
+ /**
70
+ *
71
+ * IMPORT_PATH: `"@daiso-tech/core/async"`
72
+ * @group Middlewares
73
+ */
74
+ export type ObserveCallbacks<TParameters extends unknown[] = unknown[], TReturn = unknown, TContext extends HookContext = HookContext> = {
75
+ /**
76
+ * Callback {@link Invokable | `Invokable`} that will be called when before the underlying {@link Invokable | `Invokable`} is called.
77
+ */
78
+ onStart?: OnObserveStart<TParameters, TContext>;
79
+ /**
80
+ * Callback {@link Invokable | `Invokable`} that will be called when the underlying {@link Invokable | `Invokable`} is successfully called.
81
+ */
82
+ onSuccess?: OnObserveSuccess<TParameters, TReturn, TContext>;
83
+ /**
84
+ * Callback {@link Invokable | `Invokable`} that will be called when the underlying {@link Invokable | `Invokable`} throws an error.
85
+ */
86
+ onError?: OnObserveError<TParameters, TContext>;
87
+ /**
88
+ * Callback {@link Invokable | `Invokable`} that will be called when the underlying {@link Invokable | `Invokable`} throws an error or is successfully called.
89
+ */
90
+ onFinally?: OnObserveFinally<TContext>;
91
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @module Async
3
+ */
4
+ import {} from "../../../utilities/_module-exports.js";
5
+ import {} from "../../../utilities/_module-exports.js";
6
+ //# sourceMappingURL=observe.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe.types.js","sourceRoot":"","sources":["../../../../src/async/middlewares/observe/observe.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAoB,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAkB,MAAM,gCAAgC,CAAC"}
@@ -1 +1,2 @@
1
1
  export * from "../../../async/middlewares/retry/retry.middleware.js";
2
+ export * from "../../../async/middlewares/retry/retry.types.js";
@@ -1,2 +1,3 @@
1
1
  export * from "../../../async/middlewares/retry/retry.middleware.js";
2
+ export * from "../../../async/middlewares/retry/retry.types.js";
2
3
  //# sourceMappingURL=_module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../src/async/middlewares/retry/_module.ts"],"names":[],"mappings":"AAAA,cAAc,+CAA+C,CAAC"}
1
+ {"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../src/async/middlewares/retry/_module.ts"],"names":[],"mappings":"AAAA,cAAc,+CAA+C,CAAC;AAC9D,cAAc,0CAA0C,CAAC"}
@@ -1,96 +1,14 @@
1
1
  /**
2
2
  * @module Async
3
3
  */
4
- import type { TimeSpan } from "../../../utilities/_module-exports.js";
5
- import { type Invokable, type HookContext, type AsyncMiddlewareFn } from "../../../utilities/_module-exports.js";
6
- import { type BackoffPolicy } from "../../../async/backof-policies/_module.js";
7
- import { type ErrorPolicy } from "../../../async/middlewares/_shared.js";
8
- /**
9
- *
10
- * IMPORT_PATH: `"@daiso-tech/core/async"`
11
- * @group Middlewares
12
- */
13
- export type OnRetryAttemptData<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = {
14
- attempt: number;
15
- args: TParameters;
16
- context: TContext;
17
- };
18
- /**
19
- *
20
- * IMPORT_PATH: `"@daiso-tech/core/async"`
21
- * @group Middlewares
22
- */
23
- export type OnRetryAttempt<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = Invokable<[data: OnRetryAttemptData<TParameters, TContext>]>;
24
- /**
25
- *
26
- * IMPORT_PATH: `"@daiso-tech/core/async"`
27
- * @group Middlewares
28
- */
29
- export type OnRetryDelayData<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = {
30
- error: unknown;
31
- attempt: number;
32
- waitTime: TimeSpan;
33
- args: TParameters;
34
- context: TContext;
35
- };
36
- /**
37
- *
38
- * IMPORT_PATH: `"@daiso-tech/core/async"`
39
- * @group Middlewares
40
- */
41
- export type OnRetryDelay<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = Invokable<[data: OnRetryDelayData<TParameters, TContext>]>;
42
- /**
43
- *
44
- * IMPORT_PATH: `"@daiso-tech/core/async"`
45
- * @group Middlewares
46
- */
47
- export type RetryCallbacks<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = {
48
- /**
49
- * Callback {@link Invokable | `Invokable`} that will be called before execution attempt.
50
- */
51
- onExecutionAttempt?: OnRetryAttempt<TParameters, TContext>;
52
- /**
53
- * Callback {@link Invokable | `Invokable`} that will be called before the retry delay starts.
54
- */
55
- onRetryDelay?: OnRetryDelay<TParameters, TContext>;
56
- };
57
- /**
58
- *
59
- * IMPORT_PATH: `"@daiso-tech/core/async"`
60
- * @group Middlewares
61
- */
62
- export type RetrySettings<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = RetryCallbacks<TParameters, TContext> & {
63
- /**
64
- * You can decide maximal times you can retry.
65
- * @default {4}
66
- */
67
- maxAttempts?: number;
68
- /**
69
- * @default
70
- * ```ts
71
- * import { exponentialBackoffPolicy } from "@daiso-tech/core/async";
72
- *
73
- * exponentialBackoffPolicy();
74
- * ```
75
- */
76
- backoffPolicy?: BackoffPolicy;
77
- /**
78
- * You can choose what errors you want to retry. By default all erros will be retried.
79
- *
80
- * @default
81
- * ```ts
82
- * (_error: unknown) => true
83
- * ```
84
- */
85
- errorPolicy?: ErrorPolicy;
86
- };
4
+ import { type HookContext, type AsyncMiddlewareFn } from "../../../utilities/_module-exports.js";
5
+ import type { RetrySettings } from "../../../async/middlewares/retry/retry.types.js";
87
6
  /**
88
7
  * The `retry` middleware enables automatic retries for all errors or specific errors, with configurable backoff policies.
89
8
  * An error will be thrown when all retry attempts fail.
90
9
  *
91
10
  * IMPORT_PATH: `"@daiso-tech/core/async"`
92
11
  * @group Middleware
93
- * @throws {RetryAsyncError} {@link RetryAsyncError}
94
12
  *
95
13
  * @example
96
14
  * ```ts
@@ -100,7 +18,39 @@ export type RetrySettings<TParameters extends unknown[] = unknown[], TContext ex
100
18
  * const data = await new AsyncHooks(
101
19
  * async (url: string, signal?: AbortSignal): Promise<unknown> => {
102
20
  * const response = await fetch(url, { signal });
103
- * return await response.json();
21
+ * const json = await response.json();
22
+ * if (!response.ok) {
23
+ * return json;
24
+ * }
25
+ * return json;
26
+ * },
27
+ * [retry()],
28
+ * {
29
+ * signalBinder: {
30
+ * getSignal: (args) => args[1],
31
+ * forwardSignal: (args, signal) => {
32
+ * args[1] = signal;
33
+ * }
34
+ * }
35
+ * }
36
+ * )
37
+ * .invoke("URL");
38
+ * ```
39
+ *
40
+ * The middleware works also when the function returns a {@link Result | `Result`} type.
41
+ * @example
42
+ * ```ts
43
+ * import { retry } from "@daiso-tech/core/async";
44
+ * import { AsyncHooks, TimeSpan, Result, resultFailure, resultSuccess } from "@daiso-tech/core/utilities";
45
+ *
46
+ * const data = await new AsyncHooks(
47
+ * async (url: string, signal?: AbortSignal): Promise<Result> => {
48
+ * const response = await fetch(url, { signal });
49
+ * const json = await response.json();
50
+ * if (!response.ok) {
51
+ * return resultFailure(json);
52
+ * }
53
+ * return resultSuccess(json);
104
54
  * },
105
55
  * [retry()],
106
56
  * {
@@ -115,4 +65,4 @@ export type RetrySettings<TParameters extends unknown[] = unknown[], TContext ex
115
65
  * .invoke("URL");
116
66
  * ```
117
67
  */
118
- export declare function retry<TParameters extends unknown[], TReturn, TContext extends HookContext>(settings?: NoInfer<RetrySettings<TParameters, TContext>>): AsyncMiddlewareFn<TParameters, TReturn, TContext>;
68
+ export declare function retry<TParameters extends unknown[], TReturn, TContext extends HookContext>(settings?: NoInfer<RetrySettings<TParameters, TContext, TReturn>>): AsyncMiddlewareFn<TParameters, TReturn, TContext>;
@@ -1,18 +1,16 @@
1
1
  /**
2
2
  * @module Async
3
3
  */
4
- import { callInvokable, } from "../../../utilities/_module-exports.js";
5
- import { exponentialBackoffPolicy, } from "../../../async/backof-policies/_module.js";
6
- import { RetryAsyncError } from "../../../async/async.errors.js";
7
- import { LazyPromise } from "../../../async/utilities/_module.js";
8
- import { callErrorPolicy, } from "../../../async/middlewares/_shared.js";
4
+ import { callInvokable, optionNone, optionSome, OPTION, } from "../../../utilities/_module-exports.js";
5
+ import { exponentialBackoffPolicy } from "../../../async/backof-policies/_module.js";
6
+ import { callErrorPolicyOnThrow, callErrorPolicyOnValue, } from "../../../utilities/_module-exports.js";
7
+ import { LazyPromise } from "../../../async/utilities/lazy-promise/_module.js";
9
8
  /**
10
9
  * The `retry` middleware enables automatic retries for all errors or specific errors, with configurable backoff policies.
11
10
  * An error will be thrown when all retry attempts fail.
12
11
  *
13
12
  * IMPORT_PATH: `"@daiso-tech/core/async"`
14
13
  * @group Middleware
15
- * @throws {RetryAsyncError} {@link RetryAsyncError}
16
14
  *
17
15
  * @example
18
16
  * ```ts
@@ -22,7 +20,39 @@ import { callErrorPolicy, } from "../../../async/middlewares/_shared.js";
22
20
  * const data = await new AsyncHooks(
23
21
  * async (url: string, signal?: AbortSignal): Promise<unknown> => {
24
22
  * const response = await fetch(url, { signal });
25
- * return await response.json();
23
+ * const json = await response.json();
24
+ * if (!response.ok) {
25
+ * return json;
26
+ * }
27
+ * return json;
28
+ * },
29
+ * [retry()],
30
+ * {
31
+ * signalBinder: {
32
+ * getSignal: (args) => args[1],
33
+ * forwardSignal: (args, signal) => {
34
+ * args[1] = signal;
35
+ * }
36
+ * }
37
+ * }
38
+ * )
39
+ * .invoke("URL");
40
+ * ```
41
+ *
42
+ * The middleware works also when the function returns a {@link Result | `Result`} type.
43
+ * @example
44
+ * ```ts
45
+ * import { retry } from "@daiso-tech/core/async";
46
+ * import { AsyncHooks, TimeSpan, Result, resultFailure, resultSuccess } from "@daiso-tech/core/utilities";
47
+ *
48
+ * const data = await new AsyncHooks(
49
+ * async (url: string, signal?: AbortSignal): Promise<Result> => {
50
+ * const response = await fetch(url, { signal });
51
+ * const json = await response.json();
52
+ * if (!response.ok) {
53
+ * return resultFailure(json);
54
+ * }
55
+ * return resultSuccess(json);
26
56
  * },
27
57
  * [retry()],
28
58
  * {
@@ -38,27 +68,48 @@ import { callErrorPolicy, } from "../../../async/middlewares/_shared.js";
38
68
  * ```
39
69
  */
40
70
  export function retry(settings = {}) {
41
- const { maxAttempts = 4, backoffPolicy = exponentialBackoffPolicy(), errorPolicy = () => true, onRetryDelay = () => { }, onExecutionAttempt = () => { }, } = settings;
71
+ const { maxAttempts = 4, backoffPolicy = exponentialBackoffPolicy(), errorPolicy, onRetryDelay = () => { }, onExecutionAttempt = () => { }, } = settings;
42
72
  return async (args, next, { context, signal }) => {
43
- const errors = [];
73
+ let result = optionNone();
74
+ let error_ = optionNone();
44
75
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
45
76
  try {
46
77
  callInvokable(onExecutionAttempt, { attempt, args, context });
47
- return await next(...args);
78
+ const value = await next(...args);
79
+ // Handle retrying if an Result type is returned
80
+ result = optionSome(value);
81
+ if (!(await callErrorPolicyOnValue(errorPolicy, value))) {
82
+ return value;
83
+ }
84
+ // We can cast type here because callErrorPolicyOnValue ensures the value is a ResultFailure
85
+ const resultFailure = value;
86
+ if (signal.aborted) {
87
+ break;
88
+ }
89
+ const waitTime = callInvokable(backoffPolicy, attempt, resultFailure.error);
90
+ callInvokable(onRetryDelay, {
91
+ error: resultFailure.error,
92
+ waitTime,
93
+ attempt,
94
+ args,
95
+ context,
96
+ });
97
+ await LazyPromise.delay(waitTime, signal);
98
+ // Handle retrying if an error is thrown
48
99
  }
49
100
  catch (error) {
50
101
  if (signal.aborted) {
51
102
  break;
52
103
  }
53
- if (await callErrorPolicy(errorPolicy, error)) {
54
- errors.push(error);
104
+ if (await callErrorPolicyOnThrow(errorPolicy, error)) {
105
+ error_ = optionSome(error);
55
106
  }
56
107
  else {
57
108
  throw error;
58
109
  }
59
110
  const waitTime = callInvokable(backoffPolicy, attempt, error);
60
111
  callInvokable(onRetryDelay, {
61
- error,
112
+ error: error,
62
113
  waitTime,
63
114
  attempt,
64
115
  args,
@@ -67,16 +118,13 @@ export function retry(settings = {}) {
67
118
  await LazyPromise.delay(waitTime, signal);
68
119
  }
69
120
  }
70
- let errorMessage = `Promise was failed after retried ${String(maxAttempts)} times`;
71
- const lastError = errors[errors.length - 1];
72
- if (lastError) {
73
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
74
- errorMessage = `${errorMessage} and last thrown error was "${String(lastError)}"`;
121
+ if (error_.type === OPTION.SOME) {
122
+ throw error_.value;
123
+ }
124
+ if (result.type === OPTION.SOME) {
125
+ return result.value;
75
126
  }
76
- throw new RetryAsyncError(errorMessage, {
77
- errors,
78
- maxAttempts,
79
- });
127
+ throw new Error("!!__MESSAGE__!!");
80
128
  };
81
129
  }
82
130
  //# sourceMappingURL=retry.middleware.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"retry.middleware.js","sourceRoot":"","sources":["../../../../src/async/middlewares/retry/retry.middleware.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACH,aAAa,GAIhB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACH,wBAAwB,GAE3B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAEH,eAAe,GAClB,MAAM,gCAAgC,CAAC;AA4GxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,KAAK,CAKjB,WAA0D,EAAE;IAE5D,MAAM,EACF,WAAW,GAAG,CAAC,EACf,aAAa,GAAG,wBAAwB,EAAE,EAC1C,WAAW,GAAG,GAAG,EAAE,CAAC,IAAI,EACxB,YAAY,GAAG,GAAG,EAAE,GAAE,CAAC,EACvB,kBAAkB,GAAG,GAAG,EAAE,GAAE,CAAC,GAChC,GAAG,QAAQ,CAAC;IACb,OAAO,KAA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,IAAI,eAAe,CAAC,YAAY,EAAE;YACpC,MAAM;YACN,WAAW;SACd,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC"}
1
+ {"version":3,"file":"retry.middleware.js","sourceRoot":"","sources":["../../../../src/async/middlewares/retry/retry.middleware.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAGH,aAAa,EACb,UAAU,EACV,UAAU,EACV,MAAM,GACT,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAE9E,OAAO,EACH,sBAAsB,EACtB,sBAAsB,GACzB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,MAAM,UAAU,KAAK,CAKjB,WAAmE,EAAE;IAErE,MAAM,EACF,WAAW,GAAG,CAAC,EACf,aAAa,GAAG,wBAAwB,EAAE,EAC1C,WAAW,EACX,YAAY,GAAG,GAAG,EAAE,GAAE,CAAC,EACvB,kBAAkB,GAAG,GAAG,EAAE,GAAE,CAAC,GAChC,GAAG,QAAQ,CAAC;IACb,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;QAC7C,IAAI,MAAM,GAAoB,UAAU,EAAE,CAAC;QAC3C,IAAI,MAAM,GAAW,UAAU,EAAE,CAAC;QAClC,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC;YACtD,IAAI,CAAC;gBACD,aAAa,CAAC,kBAAkB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;gBAC9D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;gBAElC,gDAAgD;g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