@evolu/common 7.4.0 → 8.0.0-next.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 (251) hide show
  1. package/README.md +4 -61
  2. package/dist/src/Array.d.ts +343 -102
  3. package/dist/src/Array.d.ts.map +1 -1
  4. package/dist/src/Array.js +181 -85
  5. package/dist/src/Assert.d.ts +57 -11
  6. package/dist/src/Assert.d.ts.map +1 -1
  7. package/dist/src/Assert.js +47 -11
  8. package/dist/src/BigInt.d.ts +6 -1
  9. package/dist/src/BigInt.d.ts.map +1 -1
  10. package/dist/src/BigInt.js +5 -0
  11. package/dist/src/Brand.d.ts +40 -12
  12. package/dist/src/Brand.d.ts.map +1 -1
  13. package/dist/src/Brand.js +5 -0
  14. package/dist/src/Buffer.d.ts +6 -1
  15. package/dist/src/Buffer.d.ts.map +1 -1
  16. package/dist/src/Buffer.js +7 -2
  17. package/dist/src/Cache.d.ts +10 -2
  18. package/dist/src/Cache.d.ts.map +1 -1
  19. package/dist/src/Cache.js +6 -0
  20. package/dist/src/Callbacks.d.ts +10 -7
  21. package/dist/src/Callbacks.d.ts.map +1 -1
  22. package/dist/src/Callbacks.js +23 -13
  23. package/dist/src/Console.d.ts +361 -69
  24. package/dist/src/Console.d.ts.map +1 -1
  25. package/dist/src/Console.js +217 -117
  26. package/dist/src/Crypto.d.ts +70 -21
  27. package/dist/src/Crypto.d.ts.map +1 -1
  28. package/dist/src/Crypto.js +72 -27
  29. package/dist/src/Eq.d.ts +22 -2
  30. package/dist/src/Eq.d.ts.map +1 -1
  31. package/dist/src/Eq.js +21 -1
  32. package/dist/src/Error.d.ts +23 -12
  33. package/dist/src/Error.d.ts.map +1 -1
  34. package/dist/src/Error.js +27 -11
  35. package/dist/src/Function.d.ts +128 -56
  36. package/dist/src/Function.d.ts.map +1 -1
  37. package/dist/src/Function.js +118 -14
  38. package/dist/src/Identicon.d.ts +5 -0
  39. package/dist/src/Identicon.d.ts.map +1 -1
  40. package/dist/src/Identicon.js +6 -1
  41. package/dist/src/Lookup.d.ts +160 -0
  42. package/dist/src/Lookup.d.ts.map +1 -0
  43. package/dist/src/Lookup.js +192 -0
  44. package/dist/src/Microtask.d.ts +21 -0
  45. package/dist/src/Microtask.d.ts.map +1 -0
  46. package/dist/src/Microtask.js +37 -0
  47. package/dist/src/Number.d.ts +18 -4
  48. package/dist/src/Number.d.ts.map +1 -1
  49. package/dist/src/Number.js +23 -1
  50. package/dist/src/Object.d.ts +110 -5
  51. package/dist/src/Object.d.ts.map +1 -1
  52. package/dist/src/Object.js +108 -5
  53. package/dist/src/Option.d.ts +58 -0
  54. package/dist/src/Option.d.ts.map +1 -0
  55. package/dist/src/Option.js +43 -0
  56. package/dist/src/Order.d.ts +5 -0
  57. package/dist/src/Order.d.ts.map +1 -1
  58. package/dist/src/Order.js +8 -3
  59. package/dist/src/Platform.d.ts +36 -2
  60. package/dist/src/Platform.d.ts.map +1 -1
  61. package/dist/src/Platform.js +10 -6
  62. package/dist/src/Polyfills.d.ts +27 -0
  63. package/dist/src/Polyfills.d.ts.map +1 -0
  64. package/dist/src/Polyfills.js +299 -0
  65. package/dist/src/Random.d.ts +18 -7
  66. package/dist/src/Random.d.ts.map +1 -1
  67. package/dist/src/Random.js +9 -7
  68. package/dist/src/Redacted.d.ts +7 -4
  69. package/dist/src/Redacted.d.ts.map +1 -1
  70. package/dist/src/Redacted.js +5 -0
  71. package/dist/src/Ref.d.ts +31 -16
  72. package/dist/src/Ref.d.ts.map +1 -1
  73. package/dist/src/Ref.js +35 -7
  74. package/dist/src/RefCount.d.ts +62 -0
  75. package/dist/src/RefCount.d.ts.map +1 -0
  76. package/dist/src/RefCount.js +83 -0
  77. package/dist/src/Relation.d.ts +84 -29
  78. package/dist/src/Relation.d.ts.map +1 -1
  79. package/dist/src/Relation.js +83 -105
  80. package/dist/src/Resource.d.ts +263 -0
  81. package/dist/src/Resource.d.ts.map +1 -0
  82. package/dist/src/Resource.js +389 -0
  83. package/dist/src/Result.d.ts +390 -374
  84. package/dist/src/Result.d.ts.map +1 -1
  85. package/dist/src/Result.js +142 -70
  86. package/dist/src/Schedule.d.ts +953 -0
  87. package/dist/src/Schedule.d.ts.map +1 -0
  88. package/dist/src/Schedule.js +1199 -0
  89. package/dist/src/Set.d.ts +181 -0
  90. package/dist/src/Set.d.ts.map +1 -0
  91. package/dist/src/Set.js +137 -0
  92. package/dist/src/Skiplist.d.ts +6 -1
  93. package/dist/src/Skiplist.d.ts.map +1 -1
  94. package/dist/src/Skiplist.js +5 -0
  95. package/dist/src/Sqlite.d.ts +160 -60
  96. package/dist/src/Sqlite.d.ts.map +1 -1
  97. package/dist/src/Sqlite.js +290 -190
  98. package/dist/src/Store.d.ts +36 -28
  99. package/dist/src/Store.d.ts.map +1 -1
  100. package/dist/src/Store.js +55 -15
  101. package/dist/src/String.d.ts +5 -0
  102. package/dist/src/String.d.ts.map +1 -1
  103. package/dist/src/String.js +5 -0
  104. package/dist/src/Task.d.ts +2263 -423
  105. package/dist/src/Task.d.ts.map +1 -1
  106. package/dist/src/Task.js +1488 -348
  107. package/dist/src/Test.d.ts +122 -0
  108. package/dist/src/Test.d.ts.map +1 -0
  109. package/dist/src/Test.js +66 -0
  110. package/dist/src/Time.d.ts +201 -48
  111. package/dist/src/Time.d.ts.map +1 -1
  112. package/dist/src/Time.js +190 -86
  113. package/dist/src/Tracer.d.ts +48 -0
  114. package/dist/src/Tracer.d.ts.map +1 -0
  115. package/dist/src/Tracer.js +6 -0
  116. package/dist/src/Type.d.ts +582 -209
  117. package/dist/src/Type.d.ts.map +1 -1
  118. package/dist/src/Type.js +362 -240
  119. package/dist/src/Types.d.ts +160 -6
  120. package/dist/src/Types.d.ts.map +1 -1
  121. package/dist/src/Types.js +22 -2
  122. package/dist/src/WebSocket.d.ts +113 -58
  123. package/dist/src/WebSocket.d.ts.map +1 -1
  124. package/dist/src/WebSocket.js +210 -118
  125. package/dist/src/Worker.d.ts +245 -60
  126. package/dist/src/Worker.d.ts.map +1 -1
  127. package/dist/src/Worker.js +220 -64
  128. package/dist/src/index.d.ts +25 -3
  129. package/dist/src/index.d.ts.map +1 -1
  130. package/dist/src/index.js +19 -3
  131. package/dist/src/local-first/Db.d.ts +24 -213
  132. package/dist/src/local-first/Db.d.ts.map +1 -1
  133. package/dist/src/local-first/Db.js +622 -293
  134. package/dist/src/local-first/Error.d.ts +12 -0
  135. package/dist/src/local-first/Error.d.ts.map +1 -0
  136. package/dist/src/local-first/Error.js +6 -0
  137. package/dist/src/local-first/Evolu.d.ts +330 -285
  138. package/dist/src/local-first/Evolu.d.ts.map +1 -1
  139. package/dist/src/local-first/Evolu.js +472 -402
  140. package/dist/src/local-first/LocalAuth.d.ts +10 -10
  141. package/dist/src/local-first/LocalAuth.d.ts.map +1 -1
  142. package/dist/src/local-first/LocalAuth.js +6 -1
  143. package/dist/src/local-first/Owner.d.ts +70 -27
  144. package/dist/src/local-first/Owner.d.ts.map +1 -1
  145. package/dist/src/local-first/Owner.js +27 -14
  146. package/dist/src/local-first/Protocol.d.ts +58 -50
  147. package/dist/src/local-first/Protocol.d.ts.map +1 -1
  148. package/dist/src/local-first/Protocol.js +253 -155
  149. package/dist/src/local-first/Query.d.ts +133 -43
  150. package/dist/src/local-first/Query.d.ts.map +1 -1
  151. package/dist/src/local-first/Query.js +139 -90
  152. package/dist/src/local-first/Relay.d.ts +18 -38
  153. package/dist/src/local-first/Relay.d.ts.map +1 -1
  154. package/dist/src/local-first/Relay.js +59 -171
  155. package/dist/src/local-first/Schema.d.ts +139 -144
  156. package/dist/src/local-first/Schema.d.ts.map +1 -1
  157. package/dist/src/local-first/Schema.js +78 -163
  158. package/dist/src/local-first/Shared.d.ts +125 -0
  159. package/dist/src/local-first/Shared.d.ts.map +1 -0
  160. package/dist/src/local-first/Shared.js +569 -0
  161. package/dist/src/local-first/Storage.d.ts +50 -53
  162. package/dist/src/local-first/Storage.d.ts.map +1 -1
  163. package/dist/src/local-first/Storage.js +121 -173
  164. package/dist/src/local-first/Timestamp.d.ts +28 -35
  165. package/dist/src/local-first/Timestamp.d.ts.map +1 -1
  166. package/dist/src/local-first/Timestamp.js +24 -25
  167. package/dist/src/local-first/index.d.ts +2 -15
  168. package/dist/src/local-first/index.d.ts.map +1 -1
  169. package/dist/src/local-first/index.js +2 -15
  170. package/package.json +36 -26
  171. package/src/Array.ts +467 -106
  172. package/src/Assert.ts +87 -12
  173. package/src/BigInt.ts +7 -1
  174. package/src/Brand.ts +41 -12
  175. package/src/Buffer.ts +10 -4
  176. package/src/Cache.ts +11 -2
  177. package/src/Callbacks.ts +33 -23
  178. package/src/Console.ts +567 -178
  179. package/src/Crypto.ts +111 -62
  180. package/src/Eq.ts +30 -3
  181. package/src/Error.ts +50 -34
  182. package/src/Function.ts +140 -68
  183. package/src/Identicon.ts +7 -1
  184. package/src/Lookup.ts +415 -0
  185. package/src/Microtask.ts +58 -0
  186. package/src/Number.ts +40 -7
  187. package/src/Object.ts +155 -16
  188. package/src/Option.ts +74 -0
  189. package/src/Order.ts +11 -3
  190. package/src/Platform.ts +43 -7
  191. package/src/Polyfills.ts +465 -0
  192. package/src/Random.ts +25 -11
  193. package/src/Redacted.ts +8 -4
  194. package/src/Ref.ts +72 -21
  195. package/src/RefCount.ts +170 -0
  196. package/src/Relation.ts +188 -136
  197. package/src/Resource.ts +864 -0
  198. package/src/Result.ts +548 -381
  199. package/src/Schedule.ts +1471 -0
  200. package/src/Set.ts +247 -0
  201. package/src/Skiplist.ts +7 -1
  202. package/src/Sqlite.ts +409 -304
  203. package/src/Store.ts +94 -48
  204. package/src/String.ts +6 -0
  205. package/src/Task.ts +3685 -740
  206. package/src/Test.ts +162 -0
  207. package/src/Time.ts +348 -145
  208. package/src/Tracer.ts +54 -0
  209. package/src/Type.ts +1064 -630
  210. package/src/Types.ts +202 -7
  211. package/src/WebSocket.ts +311 -178
  212. package/src/Worker.ts +527 -147
  213. package/src/index.ts +74 -3
  214. package/src/local-first/Db.ts +871 -597
  215. package/src/local-first/Error.ts +17 -0
  216. package/src/local-first/Evolu.ts +884 -823
  217. package/src/local-first/LocalAuth.ts +10 -10
  218. package/src/local-first/Owner.ts +94 -42
  219. package/src/local-first/Protocol.ts +440 -303
  220. package/src/local-first/Query.ts +243 -194
  221. package/src/local-first/Relay.ts +91 -252
  222. package/src/local-first/Schema.ts +284 -394
  223. package/src/local-first/Shared.ts +932 -0
  224. package/src/local-first/Storage.ts +209 -282
  225. package/src/local-first/Timestamp.ts +38 -45
  226. package/src/local-first/index.ts +2 -16
  227. package/LICENSE +0 -21
  228. package/dist/src/Instances.d.ts +0 -34
  229. package/dist/src/Instances.d.ts.map +0 -1
  230. package/dist/src/Instances.js +0 -44
  231. package/dist/src/Resources.d.ts +0 -118
  232. package/dist/src/Resources.d.ts.map +0 -1
  233. package/dist/src/Resources.js +0 -197
  234. package/dist/src/local-first/Platform.d.ts +0 -25
  235. package/dist/src/local-first/Platform.d.ts.map +0 -1
  236. package/dist/src/local-first/Platform.js +0 -1
  237. package/dist/src/local-first/Public.d.ts +0 -22
  238. package/dist/src/local-first/Public.d.ts.map +0 -1
  239. package/dist/src/local-first/Public.js +0 -15
  240. package/dist/src/local-first/PublicKysely.d.ts +0 -148
  241. package/dist/src/local-first/PublicKysely.d.ts.map +0 -1
  242. package/dist/src/local-first/PublicKysely.js +0 -184
  243. package/dist/src/local-first/Sync.d.ts +0 -112
  244. package/dist/src/local-first/Sync.d.ts.map +0 -1
  245. package/dist/src/local-first/Sync.js +0 -529
  246. package/src/Instances.ts +0 -90
  247. package/src/Resources.ts +0 -367
  248. package/src/local-first/Platform.ts +0 -27
  249. package/src/local-first/Public.ts +0 -42
  250. package/src/local-first/PublicKysely.ts +0 -239
  251. package/src/local-first/Sync.ts +0 -960
@@ -0,0 +1,953 @@
1
+ /**
2
+ * Composable scheduling strategies.
3
+ *
4
+ * @module
5
+ */
6
+ import type { RandomDep } from "./Random.js";
7
+ import { type NextResult } from "./Result.js";
8
+ import { type Duration, Millis, type TimeDep } from "./Time.js";
9
+ import { PositiveInt } from "./Type.js";
10
+ import type { Predicate } from "./Types.js";
11
+ /**
12
+ * Composable scheduling strategies for {@link retry}, {@link repeat}, rate
13
+ * limiting, and more.
14
+ *
15
+ * A Schedule uses the State pattern: calling `schedule(deps)` creates a step
16
+ * function with internal state captured in closures. Each call to `step(input)`
17
+ * advances that state and returns `Ok([Output, Millis])` or `Err(Done<void>)`
18
+ * to stop. Multiple calls to `schedule(deps)` create independent state
19
+ * instances.
20
+ *
21
+ * ### Example
22
+ *
23
+ * ```ts
24
+ * import {
25
+ * exponential,
26
+ * jitter,
27
+ * maxDelay,
28
+ * retry,
29
+ * take,
30
+ * } from "@evolu/common";
31
+ *
32
+ * const fetchWithRetry = retry(
33
+ * fetchData,
34
+ * // A jittered, capped, limited exponential backoff.
35
+ * jitter(1)(maxDelay("20s")(take(2)(exponential("100ms")))),
36
+ * );
37
+ * ```
38
+ *
39
+ * Or use a preset:
40
+ *
41
+ * ```ts
42
+ * import { retryStrategyAws, retry } from "@evolu/common";
43
+ *
44
+ * const fetchWithRetry = retry(fetchData, retryStrategyAws);
45
+ * ```
46
+ */
47
+ export type Schedule<out Output, in Input = unknown> = (deps: ScheduleDeps) => (input: Input) => NextResult<readonly [Output, Millis]>;
48
+ /**
49
+ * Dependencies provided to a {@link Schedule}.
50
+ *
51
+ * The executor provides these once, and the schedule uses what it needs.
52
+ */
53
+ export type ScheduleDeps = TimeDep & RandomDep;
54
+ /**
55
+ * Base interface for schedule-based task helpers.
56
+ *
57
+ * Used by {@link RetryAttempt}, {@link RepeatAttempt}, and future schedule-driven
58
+ * helpers.
59
+ *
60
+ * @group Composition
61
+ */
62
+ export interface ScheduleStep<Output> {
63
+ /** The current attempt. */
64
+ readonly attempt: PositiveInt;
65
+ /** Output from the {@link Schedule} step. */
66
+ readonly output: Output;
67
+ /** Delay before this step executes. */
68
+ readonly delay: Millis;
69
+ }
70
+ /**
71
+ * A schedule that never stops and has no delay.
72
+ *
73
+ * Outputs the attempt count (0, 1, 2, ...). Useful as a base for composition or
74
+ * for immediate retry without backoff.
75
+ *
76
+ * ### Example
77
+ *
78
+ * ```ts
79
+ * // Retry immediately, up to 5 times
80
+ * const immediate = take(5)(forever);
81
+ * ```
82
+ *
83
+ * @group Constructors
84
+ */
85
+ export declare const forever: Schedule<number>;
86
+ /**
87
+ * A schedule that runs exactly once with no delay.
88
+ *
89
+ * Convenience for `take(1)(forever)`. Useful for one-shot operations.
90
+ *
91
+ * ### Example
92
+ *
93
+ * ```ts
94
+ * // Execute once, no retry
95
+ * const oneShot = once;
96
+ * ```
97
+ *
98
+ * @group Constructors
99
+ */
100
+ export declare const once: Schedule<number>;
101
+ /**
102
+ * A schedule that recurs a fixed number of times.
103
+ *
104
+ * Convenience for `take(n)(forever)`. Outputs the current repetition count (0,
105
+ * 1, 2, ..., n-1).
106
+ *
107
+ * ### Example
108
+ *
109
+ * ```ts
110
+ * // Retry up to 3 times (4 total attempts including initial)
111
+ * const retry = recurs(3);
112
+ * ```
113
+ *
114
+ * @group Constructors
115
+ */
116
+ export declare const recurs: (n: number) => Schedule<number>;
117
+ /**
118
+ * Constant delay schedule.
119
+ *
120
+ * Always waits the same duration after each execution completes. Never stops —
121
+ * combine with {@link take} or {@link maxElapsed} to limit.
122
+ *
123
+ * ### Example
124
+ *
125
+ * ```ts
126
+ * // 1s, 1s, 1s, ... (polling)
127
+ * const poll = spaced("1s");
128
+ *
129
+ * // Retry 3 times with 500ms between each
130
+ * const retry = take(3)(spaced("500ms"));
131
+ *
132
+ * // Heartbeat schedule
133
+ * const heartbeat = spaced("30s");
134
+ * ```
135
+ *
136
+ * @group Constructors
137
+ */
138
+ export declare const spaced: (duration: Duration) => Schedule<Millis>;
139
+ /**
140
+ * Exponential backoff schedule.
141
+ *
142
+ * Computes delay as `base * factor^(attempt - 1)`:
143
+ *
144
+ * - Attempt 1: `base`
145
+ * - Attempt 2: `base * factor`
146
+ * - Attempt 3: `base * factor²`
147
+ * - ...
148
+ *
149
+ * Never stops — combine with {@link take} or {@link maxElapsed} to limit.
150
+ *
151
+ * ### Example
152
+ *
153
+ * ```ts
154
+ * // 100ms, 200ms, 400ms, 800ms, ...
155
+ * const exp = exponential("100ms");
156
+ *
157
+ * // 100ms, 150ms, 225ms, 338ms, ... (gentler growth)
158
+ * const gentle = exponential("100ms", 1.5);
159
+ * ```
160
+ *
161
+ * @group Constructors
162
+ */
163
+ export declare const exponential: (base: Duration, factor?: number) => Schedule<Millis>;
164
+ /**
165
+ * Linear backoff schedule.
166
+ *
167
+ * Delay increases linearly: `base * attempt`:
168
+ *
169
+ * - Attempt 1: `base`
170
+ * - Attempt 2: `base * 2`
171
+ * - Attempt 3: `base * 3`
172
+ * - ...
173
+ *
174
+ * Never stops — combine with {@link take} or {@link maxElapsed} to limit.
175
+ *
176
+ * ### Example
177
+ *
178
+ * ```ts
179
+ * // 100ms, 200ms, 300ms, 400ms, ...
180
+ * const lin = linear("100ms");
181
+ * ```
182
+ *
183
+ * @group Constructors
184
+ */
185
+ export declare const linear: (base: Duration) => Schedule<Millis>;
186
+ /**
187
+ * Fibonacci backoff schedule.
188
+ *
189
+ * Delays follow the Fibonacci sequence, growing more slowly than exponential:
190
+ *
191
+ * - Attempt 1: `initial`
192
+ * - Attempt 2: `initial`
193
+ * - Attempt 3: `initial * 2`
194
+ * - Attempt 4: `initial * 3`
195
+ * - Attempt 5: `initial * 5`
196
+ * - ...
197
+ *
198
+ * Never stops — combine with {@link take} or {@link maxElapsed} to limit.
199
+ *
200
+ * ### Example
201
+ *
202
+ * ```ts
203
+ * // 100ms, 100ms, 200ms, 300ms, 500ms, 800ms, ...
204
+ * const fib = fibonacci("100ms");
205
+ * ```
206
+ *
207
+ * @group Constructors
208
+ */
209
+ export declare const fibonacci: (initial: Duration) => Schedule<Millis>;
210
+ /**
211
+ * Fixed interval schedule aligned to time windows.
212
+ *
213
+ * Recurs on a fixed interval, outputting the repetition count (0, 1, 2, ...).
214
+ * Unlike {@link spaced}, which waits a duration _after_ each execution, `fixed`
215
+ * maintains a consistent cadence from when the schedule started.
216
+ *
217
+ * If execution takes longer than the interval, the next execution happens
218
+ * immediately but subsequent runs still align to the original window
219
+ * boundaries. This prevents "pile-up" while maintaining predictable timing.
220
+ *
221
+ * ### Example
222
+ *
223
+ * ```ts
224
+ * // Health check every 5 seconds, aligned to windows
225
+ * const healthCheck = take(10)(fixed("5s"));
226
+ *
227
+ * // Cron-like behavior: run at consistent intervals
228
+ * const cronLike = fixed("1m");
229
+ * ```
230
+ *
231
+ * @group Constructors
232
+ */
233
+ export declare const fixed: (interval: Duration) => Schedule<number>;
234
+ /**
235
+ * Divides the timeline into fixed windows and sleeps until the next boundary.
236
+ *
237
+ * Similar to {@link fixed}, but always sleeps until the next window boundary
238
+ * regardless of when the last execution started. Outputs the repetition count.
239
+ *
240
+ * Useful for aligning executions to regular intervals from the start time.
241
+ *
242
+ * ### Example
243
+ *
244
+ * ```ts
245
+ * // Execute at regular 5-second boundaries from start
246
+ * const aligned = windowed("5s");
247
+ * // If elapsed is 3s, waits 2s. If elapsed is 7s, waits 3s.
248
+ * ```
249
+ *
250
+ * @group Constructors
251
+ */
252
+ export declare const windowed: (interval: Duration) => Schedule<number>;
253
+ /**
254
+ * A schedule that runs once with a single delay.
255
+ *
256
+ * Convenience for `take(1)(spaced(delay))`. Useful for simple one-shot delays.
257
+ *
258
+ * ### Example
259
+ *
260
+ * ```ts
261
+ * // Wait 1 second then stop
262
+ * const oneShot = fromDelay("1s");
263
+ * ```
264
+ *
265
+ * @group Constructors
266
+ */
267
+ export declare const fromDelay: (delay: Duration) => Schedule<Millis>;
268
+ /**
269
+ * A schedule that runs through a sequence of delays.
270
+ *
271
+ * Convenience for sequencing single-delay schedules. Useful for predefined
272
+ * retry patterns.
273
+ *
274
+ * ### Example
275
+ *
276
+ * ```ts
277
+ * // Custom retry sequence: 100ms, 500ms, 2s
278
+ * const custom = fromDelays("100ms", "500ms", "2s");
279
+ * ```
280
+ *
281
+ * @group Constructors
282
+ */
283
+ export declare const fromDelays: (...delays: ReadonlyArray<Duration>) => Schedule<Millis>;
284
+ /**
285
+ * A schedule that outputs the total elapsed time since the schedule started.
286
+ *
287
+ * Never stops — combine with {@link take} or {@link maxElapsed} to limit. Useful
288
+ * for tracking how long a retry sequence has been running.
289
+ *
290
+ * ### Example
291
+ *
292
+ * ```ts
293
+ * // Track elapsed time alongside retries
294
+ * const withTiming = intersectSchedules(exponential("100ms"), elapsed);
295
+ * // Outputs: [[100, 0], [200, ~100], [400, ~300], ...]
296
+ *
297
+ * // Stop after 30 seconds of elapsed time
298
+ * const timeLimited = whileScheduleOutput((ms: Millis) => ms < 30000)(
299
+ * elapsed,
300
+ * );
301
+ * ```
302
+ *
303
+ * @group Constructors
304
+ */
305
+ export declare const elapsed: Schedule<Millis>;
306
+ /**
307
+ * A schedule that runs for a specified duration then stops.
308
+ *
309
+ * Outputs the elapsed time. Useful for time-boxed operations or combining with
310
+ * other schedules to create time-limited variants.
311
+ *
312
+ * ### Example
313
+ *
314
+ * ```ts
315
+ * // Run for at most 30 seconds
316
+ * const timeLimited = during("30s");
317
+ *
318
+ * // Combine with exponential for time-boxed retry
319
+ * const timedRetry = intersectSchedules(
320
+ * exponential("100ms"),
321
+ * during("10s"),
322
+ * );
323
+ * ```
324
+ *
325
+ * @group Constructors
326
+ */
327
+ export declare const during: (duration: Duration) => Schedule<Millis>;
328
+ /**
329
+ * A schedule that always outputs a constant value.
330
+ *
331
+ * Never stops — combine with {@link take} or {@link maxElapsed} to limit.
332
+ *
333
+ * ### Example
334
+ *
335
+ * ```ts
336
+ * // Always output "retry"
337
+ * const labeled = always("retry");
338
+ *
339
+ * // Combine with timing
340
+ * const withLabel = intersectSchedules(
341
+ * exponential("100ms"),
342
+ * always("backoff"),
343
+ * );
344
+ * ```
345
+ *
346
+ * @group Constructors
347
+ */
348
+ export declare const always: <A>(value: A) => Schedule<A>;
349
+ /**
350
+ * Creates a schedule by unfolding a state.
351
+ *
352
+ * Each step outputs the current state and computes the next state using the
353
+ * provided function. Never stops — combine with {@link take} or
354
+ * {@link maxElapsed} to limit.
355
+ *
356
+ * ### Example
357
+ *
358
+ * ```ts
359
+ * // Counter: 0, 1, 2, 3, ...
360
+ * const counter = unfoldSchedule(0, (n) => n + 1);
361
+ *
362
+ * // Custom backoff: 100, 150, 225, 338, ... (×1.5 each time)
363
+ * const customBackoff = unfoldSchedule(100, (delay) =>
364
+ * Math.round(delay * 1.5),
365
+ * );
366
+ *
367
+ * // State machine
368
+ * type Phase = "init" | "warmup" | "active";
369
+ * const phases = unfoldSchedule<Phase>("init", (phase) => {
370
+ * switch (phase) {
371
+ * case "init":
372
+ * return "warmup";
373
+ * case "warmup":
374
+ * return "active";
375
+ * case "active":
376
+ * return "active";
377
+ * }
378
+ * });
379
+ * ```
380
+ *
381
+ * @group Constructors
382
+ */
383
+ export declare const unfoldSchedule: <State>(initial: State, next: (state: State) => State) => Schedule<State>;
384
+ /**
385
+ * Limits a schedule to a maximum number of attempts.
386
+ *
387
+ * After `n` attempts, returns `Err(Done<void>)` (stop).
388
+ *
389
+ * ### Example
390
+ *
391
+ * ```ts
392
+ * // Exponential backoff, max 3 retries
393
+ * const limited = take(3)(exponential("100ms"));
394
+ * // Attempt 1: 100ms, Attempt 2: 200ms, Attempt 3: 400ms, Attempt 4: Err(Done<void>)
395
+ * ```
396
+ *
397
+ * @group Limiting
398
+ */
399
+ export declare const take: (n: number) => <Output, Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
400
+ /**
401
+ * Limits schedule execution to a maximum elapsed time.
402
+ *
403
+ * After `duration` has elapsed since the schedule started, returns
404
+ * `Err(Done<void>)`.
405
+ *
406
+ * ### Example
407
+ *
408
+ * ```ts
409
+ * // Retry for at most 30 seconds
410
+ * const timeLimited = maxElapsed("30s")(exponential("1s"));
411
+ * ```
412
+ *
413
+ * @group Limiting
414
+ */
415
+ export declare const maxElapsed: (duration: Duration) => <Output, Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
416
+ /**
417
+ * Caps the delay to a maximum value.
418
+ *
419
+ * If the schedule returns a delay greater than `max`, returns `max` instead.
420
+ *
421
+ * ### Example
422
+ *
423
+ * ```ts
424
+ * // Exponential capped at 10 seconds
425
+ * const capped = maxDelay("10s")(exponential("1s"));
426
+ * // 1s, 2s, 4s, 8s, 10s, 10s, 10s, ...
427
+ * ```
428
+ *
429
+ * @group Limiting
430
+ */
431
+ export declare const maxDelay: (max: Duration) => <Output, Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
432
+ /**
433
+ * Adds randomized jitter to delays.
434
+ *
435
+ * Jitter helps prevent "thundering herd" when many clients retry simultaneously
436
+ * after a service recovers. The delay is randomized within a range:
437
+ *
438
+ * - `factor = 0` — no jitter (original delay)
439
+ * - `factor = 0.5` — delay varies ±50% (e.g., 1s becomes 500ms-1500ms)
440
+ * - `factor = 1` — full jitter, delay varies 0-200% (e.g., 1s becomes 0-2s)
441
+ *
442
+ * ### Example
443
+ *
444
+ * ```ts
445
+ * // AWS-style full jitter
446
+ * const awsStyle = jitter(1)(exponential("1s"));
447
+ *
448
+ * // Conservative jitter (±25%)
449
+ * const conservative = jitter(0.25)(exponential("1s"));
450
+ * ```
451
+ *
452
+ * @group Delay
453
+ */
454
+ export declare const jitter: (factor?: number) => <Output, Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
455
+ /**
456
+ * Adds an initial delay before the first attempt.
457
+ *
458
+ * Subsequent attempts use the schedule's normal delays.
459
+ *
460
+ * ### Example
461
+ *
462
+ * ```ts
463
+ * // Wait 1s before first attempt, then exponential backoff
464
+ * const withWarmup = delayed("1s")(exponential("100ms"));
465
+ * ```
466
+ *
467
+ * @group Delay
468
+ */
469
+ export declare const delayed: (initialDelay: Duration) => <Output, Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
470
+ /**
471
+ * Adds a fixed delay to the schedule's existing delay.
472
+ *
473
+ * ### Example
474
+ *
475
+ * ```ts
476
+ * // Add 500ms to each delay
477
+ * const slower = addDelay("500ms")(exponential("100ms"));
478
+ * // Delays: 600ms, 700ms, 900ms, 1300ms, ...
479
+ * ```
480
+ *
481
+ * @group Delay
482
+ */
483
+ export declare const addDelay: (extra: Duration) => (<Output, Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>);
484
+ /**
485
+ * Transforms the delay of a schedule.
486
+ *
487
+ * More flexible than {@link maxDelay} — can implement any delay transformation.
488
+ *
489
+ * ### Example
490
+ *
491
+ * ```ts
492
+ * // Double all delays
493
+ * const slower = modifyDelay((d) => d * 2)(exponential("100ms"));
494
+ *
495
+ * // Cap at 10s (equivalent to maxDelay)
496
+ * const capped = modifyDelay((d) => Math.min(d, 10000))(exponential("1s"));
497
+ * ```
498
+ *
499
+ * @group Delay
500
+ */
501
+ export declare const modifyDelay: (f: (delay: Millis) => number) => <Output, Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
502
+ /**
503
+ * Adjusts delay by subtracting execution time.
504
+ *
505
+ * A simple combinator that subtracts the previous execution time from the
506
+ * schedule's delay. If execution took longer than the delay, returns 0.
507
+ *
508
+ * For window-aligned scheduling, use {@link fixed} instead.
509
+ *
510
+ * ### Example
511
+ *
512
+ * ```ts
513
+ * // Poll every 5s, accounting for execution time
514
+ * const polling = compensate(spaced("5s"));
515
+ * // If poll takes 1s → wait 4s. If poll takes 6s → wait 0s.
516
+ * ```
517
+ *
518
+ * @group Delay
519
+ */
520
+ export declare const compensate: <Output, Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
521
+ /**
522
+ * Continues while the input satisfies a predicate.
523
+ *
524
+ * Stops (returns `Err(Done<void>)`) when {@link Predicate} returns `false`.
525
+ * Useful for input-aware retry strategies, e.g., only retry certain error
526
+ * types.
527
+ *
528
+ * ### Example
529
+ *
530
+ * ```ts
531
+ * interface MyError extends Typed<"Transient" | "Fatal"> {}
532
+ *
533
+ * // Only retry transient errors
534
+ * const retryTransient = whileScheduleInput(
535
+ * (error: MyError) => error.type === "Transient",
536
+ * )(exponential("100ms"));
537
+ * ```
538
+ *
539
+ * @group Filtering
540
+ */
541
+ export declare const whileScheduleInput: <Input>(predicate: Predicate<Input>) => <Output>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
542
+ /**
543
+ * Continues until the input satisfies a predicate.
544
+ *
545
+ * Stops (returns `Err(Done<void>)`) when {@link Predicate} returns `true`.
546
+ * Useful for stopping retry on specific error conditions.
547
+ *
548
+ * ### Example
549
+ *
550
+ * ```ts
551
+ * interface MyError extends Typed<"Transient" | "Fatal"> {}
552
+ *
553
+ * // Stop retrying on fatal errors
554
+ * const stopOnFatal = untilScheduleInput(
555
+ * (error: MyError) => error.type === "Fatal",
556
+ * )(exponential("100ms"));
557
+ * ```
558
+ *
559
+ * @group Filtering
560
+ */
561
+ export declare const untilScheduleInput: <Input>(predicate: Predicate<Input>) => <Output>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
562
+ /**
563
+ * Continues while the output satisfies a predicate.
564
+ *
565
+ * Stops (returns `Err(Done<void>)`) when {@link Predicate} returns `false`.
566
+ *
567
+ * ### Example
568
+ *
569
+ * ```ts
570
+ * // Continue while delay is under 5 seconds
571
+ * const capped = whileScheduleOutput((delay: Millis) => delay < 5000)(
572
+ * exponential("1s"),
573
+ * );
574
+ * ```
575
+ *
576
+ * @group Filtering
577
+ */
578
+ export declare const whileScheduleOutput: <Output>(predicate: Predicate<Output>) => <Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
579
+ /**
580
+ * Continues until the output satisfies a predicate.
581
+ *
582
+ * Stops (returns `Err(Done<void>)`) when {@link Predicate} returns `true`.
583
+ *
584
+ * ### Example
585
+ *
586
+ * ```ts
587
+ * // Stop when delay reaches 1 second
588
+ * const limited = untilScheduleOutput((delay: Millis) => delay >= 1000)(
589
+ * exponential("100ms"),
590
+ * );
591
+ * ```
592
+ *
593
+ * @group Filtering
594
+ */
595
+ export declare const untilScheduleOutput: <Output>(predicate: Predicate<Output>) => <Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
596
+ /**
597
+ * Resets the schedule after a period of inactivity.
598
+ *
599
+ * If `elapsedSincePrevious` is greater than or equal to `duration`, creates a
600
+ * fresh state. Useful for circuit breakers that should "forget" failures after
601
+ * idle time.
602
+ *
603
+ * ### Example
604
+ *
605
+ * ```ts
606
+ * // Reset retry count after 1 minute of success
607
+ * const circuitBreaker = resetScheduleAfter("1m")(
608
+ * take(5)(exponential("1s")),
609
+ * );
610
+ * ```
611
+ *
612
+ * @group State
613
+ */
614
+ export declare const resetScheduleAfter: (duration: Duration) => <Output, Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
615
+ /**
616
+ * Transforms the output of a schedule.
617
+ *
618
+ * The delay (second tuple element) remains unchanged.
619
+ *
620
+ * ### Example
621
+ *
622
+ * ```ts
623
+ * import { exponential, mapSchedule } from "@evolu/common";
624
+ *
625
+ * const schedule = mapSchedule((delay) => ({
626
+ * delay,
627
+ * doubled: delay * 2,
628
+ * }))(exponential("100ms"));
629
+ * ```
630
+ *
631
+ * @group Transform
632
+ */
633
+ export declare const mapSchedule: <A, B>(f: (a: A) => B) => <Input>(schedule: Schedule<A, Input>) => Schedule<B, Input>;
634
+ /**
635
+ * Creates a schedule that outputs its input, or wraps an existing schedule to
636
+ * output input instead of the original output.
637
+ *
638
+ * When called with no arguments, creates a schedule that outputs its input
639
+ * directly (the "identity" schedule). When called with a schedule, wraps it to
640
+ * preserve timing behavior but replace output with input.
641
+ *
642
+ * ### Example
643
+ *
644
+ * ```ts
645
+ * import { exponential, passthrough } from "@evolu/common";
646
+ *
647
+ * interface MyError {
648
+ * readonly message: string;
649
+ * }
650
+ *
651
+ * // Constructor: output equals input
652
+ * const identity = passthrough<MyError>();
653
+ *
654
+ * // Combinator: preserve timing, replace output
655
+ * const withInput = passthrough(exponential("100ms"));
656
+ * ```
657
+ *
658
+ * @group Constructors
659
+ */
660
+ export declare function passthrough<A>(): Schedule<A, A>;
661
+ /** @group Transform */
662
+ export declare function passthrough<Output, Input>(schedule: Schedule<Output, Input>): Schedule<Input, Input>;
663
+ /**
664
+ * Folds over the outputs of a schedule, accumulating state.
665
+ *
666
+ * Each step outputs the accumulated value. Useful for tracking totals,
667
+ * collecting outputs, or building up metadata across attempts.
668
+ *
669
+ * ### Example
670
+ *
671
+ * ```ts
672
+ * // Track total delay spent
673
+ * const withTotal = foldSchedule(
674
+ * 0,
675
+ * (total: number, delay: Millis) => total + delay,
676
+ * )(exponential("100ms"));
677
+ * // Outputs: 100, 300, 700, 1500, ... (cumulative)
678
+ *
679
+ * // Collect all outputs
680
+ * const collected = foldSchedule([] as Millis[], (acc, delay: Millis) => [
681
+ * ...acc,
682
+ * delay,
683
+ * ])(take(3)(spaced("1s")));
684
+ * // Outputs: [1000], [1000, 1000], [1000, 1000, 1000]
685
+ *
686
+ * // Count attempts with custom output
687
+ * const counted = foldSchedule(
688
+ * { attempts: 0, lastDelay: 0 as Millis },
689
+ * (acc, delay: Millis) => ({
690
+ * attempts: acc.attempts + 1,
691
+ * lastDelay: delay,
692
+ * }),
693
+ * )(exponential("100ms"));
694
+ * ```
695
+ *
696
+ * @group Transform
697
+ */
698
+ export declare const foldSchedule: <Z, Output>(initial: Z, f: (acc: Z, output: Output) => Z) => <Input>(schedule: Schedule<Output, Input>) => Schedule<Z, Input>;
699
+ /**
700
+ * Wraps a schedule to output the number of repetitions instead of original
701
+ * output.
702
+ *
703
+ * Outputs 0, 1, 2, ... while preserving the underlying schedule's timing and
704
+ * termination behavior.
705
+ *
706
+ * ### Example
707
+ *
708
+ * ```ts
709
+ * // Track how many retries occurred
710
+ * const counted = repetitions(exponential("100ms"));
711
+ * // Outputs: 0, 1, 2, ... with exponential delays
712
+ * ```
713
+ *
714
+ * @group Transform
715
+ */
716
+ export declare const repetitions: <Output, Input>(schedule: Schedule<Output, Input>) => Schedule<number, Input>;
717
+ /**
718
+ * Outputs the delay between recurrences.
719
+ *
720
+ * Wraps a schedule to output its delay (in milliseconds) instead of the
721
+ * original output. Useful for monitoring or logging delay patterns.
722
+ *
723
+ * ### Example
724
+ *
725
+ * ```ts
726
+ * // Monitor exponential delays
727
+ * const monitorDelays = delays(exponential("100ms"));
728
+ * // Outputs: 100, 200, 400, 800, ... (the delays themselves)
729
+ *
730
+ * // Log delays for debugging
731
+ * const logged = tapScheduleOutput(console.log)(
732
+ * delays(exponential("100ms")),
733
+ * );
734
+ * ```
735
+ *
736
+ * @group Transform
737
+ */
738
+ export declare const delays: <Output, Input>(schedule: Schedule<Output, Input>) => Schedule<Millis, Input>;
739
+ /**
740
+ * Collects all outputs into an array.
741
+ *
742
+ * Each step outputs an array containing all outputs so far.
743
+ *
744
+ * ### Example
745
+ *
746
+ * ```ts
747
+ * // Collect all delays
748
+ * const collected = collectAllScheduleOutputs(take(3)(spaced("100ms")));
749
+ * // Outputs: [100], [100, 100], [100, 100, 100]
750
+ * ```
751
+ *
752
+ * @group Collection
753
+ */
754
+ export declare const collectAllScheduleOutputs: <Output, Input>(schedule: Schedule<Output, Input>) => Schedule<ReadonlyArray<Output>, Input>;
755
+ /**
756
+ * Collects all inputs into an array.
757
+ *
758
+ * Each step outputs an array containing all inputs received so far. Mirror of
759
+ * {@link collectAllScheduleOutputs} but for inputs.
760
+ *
761
+ * ### Example
762
+ *
763
+ * ```ts
764
+ * // Collect all errors during retry
765
+ * const errorHistory = collectScheduleInputs(
766
+ * take(3)(exponential("100ms")),
767
+ * );
768
+ * // After 3 retries, outputs array of all error inputs
769
+ * ```
770
+ *
771
+ * @group Collection
772
+ */
773
+ export declare const collectScheduleInputs: <Output, Input>(schedule: Schedule<Output, Input>) => Schedule<ReadonlyArray<Input>, Input>;
774
+ /**
775
+ * Collects outputs while a predicate is true.
776
+ *
777
+ * More flexible than {@link collectAllScheduleOutputs} — stops collecting when
778
+ * the predicate returns false.
779
+ *
780
+ * ### Example
781
+ *
782
+ * ```ts
783
+ * // Collect delays while under 1 second
784
+ * const smallDelays = collectWhileScheduleOutput(
785
+ * (delay: Millis) => delay < 1000,
786
+ * )(exponential("100ms"));
787
+ * // Outputs: [100], [100, 200], [100, 200, 400], [100, 200, 400, 800], stops
788
+ * ```
789
+ *
790
+ * @group Collection
791
+ */
792
+ export declare const collectWhileScheduleOutput: <Output>(predicate: Predicate<Output>) => <Input>(schedule: Schedule<Output, Input>) => Schedule<ReadonlyArray<Output>, Input>;
793
+ /**
794
+ * Collects outputs until a predicate becomes true.
795
+ *
796
+ * Mirror of {@link collectWhileScheduleOutput} — stops collecting when the
797
+ * predicate returns true (inclusive of the matching output).
798
+ *
799
+ * ### Example
800
+ *
801
+ * ```ts
802
+ * // Collect delays until reaching 1 second
803
+ * const untilLarge = collectUntilScheduleOutput(
804
+ * (delay: Millis) => delay >= 1000,
805
+ * )(exponential("100ms"));
806
+ * // Outputs: [100], [100, 200], [100, 200, 400], [100, 200, 400, 800], stops
807
+ * ```
808
+ *
809
+ * @group Collection
810
+ */
811
+ export declare const collectUntilScheduleOutput: <Output>(predicate: Predicate<Output>) => <Input>(schedule: Schedule<Output, Input>) => Schedule<ReadonlyArray<Output>, Input>;
812
+ /**
813
+ * Sequences schedules: runs each until it stops, then continues with the next.
814
+ *
815
+ * Useful for adaptive strategies that start aggressive and become more
816
+ * conservative over time.
817
+ *
818
+ * ### Example
819
+ *
820
+ * ```ts
821
+ * // Fast retries first, then slower, then final fallback
822
+ * const adaptive = sequenceSchedules(
823
+ * take(3)(exponential("100ms")),
824
+ * take(5)(fixed("500ms")),
825
+ * fixed("1s"),
826
+ * );
827
+ * // Runs: 100ms, 200ms, 400ms, then 500ms×5, then 1s forever
828
+ * ```
829
+ *
830
+ * @group Composition
831
+ */
832
+ export declare const sequenceSchedules: <Output, Input>(...schedules: ReadonlyArray<Schedule<Output, Input>>) => Schedule<Output, Input>;
833
+ /**
834
+ * Combines two schedules with AND semantics.
835
+ *
836
+ * Continues only while both schedules want to continue. Uses the maximum delay.
837
+ *
838
+ * ### Example
839
+ *
840
+ * ```ts
841
+ * // Retry up to 5 times AND within 30 seconds (both conditions must be met)
842
+ * const both = intersectSchedules(
843
+ * take(5)(exponential("1s")),
844
+ * maxElapsed("30s")(forever),
845
+ * );
846
+ * ```
847
+ *
848
+ * @group Composition
849
+ */
850
+ export declare const intersectSchedules: <OutputA, OutputB, Input>(a: Schedule<OutputA, Input>, b: Schedule<OutputB, Input>) => Schedule<[OutputA, OutputB], Input>;
851
+ /**
852
+ * Combines two schedules with OR semantics.
853
+ *
854
+ * Continues while either schedule wants to continue. Uses the minimum delay.
855
+ *
856
+ * ### Example
857
+ *
858
+ * ```ts
859
+ * // Retry up to 5 times OR up to 30 seconds, whichever is longer
860
+ * const either = unionSchedules(
861
+ * take(5)(exponential("1s")),
862
+ * maxElapsed("30s")(forever),
863
+ * );
864
+ * ```
865
+ *
866
+ * @group Composition
867
+ */
868
+ export declare const unionSchedules: <OutputA, OutputB, Input>(a: Schedule<OutputA, Input>, b: Schedule<OutputB, Input>) => Schedule<OutputA | OutputB, Input>;
869
+ /**
870
+ * Selects between two schedules based on input.
871
+ *
872
+ * If {@link Predicate} returns `true`, uses `altSchedule`; otherwise uses the
873
+ * base schedule. Useful for implementing error-aware backoff where certain
874
+ * errors (e.g., throttling) use different delays.
875
+ *
876
+ * ### Example
877
+ *
878
+ * ```ts
879
+ * interface MyError extends Typed<"Throttled" | "NetworkError"> {}
880
+ *
881
+ * const awsWithThrottling = whenInput<MyError, Millis>(
882
+ * (error) => error.type === "Throttled",
883
+ * exponential("1s"), // throttled: 1s base
884
+ * )(exponential("100ms")); // normal: 100ms base
885
+ * ```
886
+ *
887
+ * @group Composition
888
+ */
889
+ export declare const whenInput: <Input, Output>(predicate: Predicate<Input>, altSchedule: Schedule<Output, Input>) => (schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
890
+ /**
891
+ * Executes a side effect for every output without altering the schedule.
892
+ *
893
+ * Useful for logging, monitoring, or debugging without changing schedule
894
+ * behavior.
895
+ *
896
+ * ### Example
897
+ *
898
+ * ```ts
899
+ * // Log each delay for debugging
900
+ * const logged = tapScheduleOutput((delay: Millis) => {
901
+ * console.log(`Next delay: ${delay}ms`);
902
+ * })(exponential("100ms"));
903
+ *
904
+ * // Track metrics
905
+ * const recorded: Array<Millis> = [];
906
+ * const tracked = tapScheduleOutput((delay: Millis) => {
907
+ * recorded.push(delay);
908
+ * })(retryStrategyAws);
909
+ * ```
910
+ *
911
+ * @group Side effects
912
+ */
913
+ export declare const tapScheduleOutput: <Output>(f: (output: Output) => void) => <Input>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
914
+ /**
915
+ * Executes a side effect for every input without altering the schedule.
916
+ *
917
+ * Useful for logging errors during retry or monitoring what values are being
918
+ * processed.
919
+ *
920
+ * ### Example
921
+ *
922
+ * ```ts
923
+ * interface MyError extends Typed<string> {}
924
+ *
925
+ * const retrySchedule: Schedule<Millis, MyError> = exponential("100ms");
926
+ *
927
+ * // Log each error during retry
928
+ * const logged = tapScheduleInput((error: MyError) => {
929
+ * console.log(`Retrying after error: ${error.type}`);
930
+ * })(retrySchedule);
931
+ *
932
+ * // Track retry reasons
933
+ * const reasons: Array<string> = [];
934
+ * const tracked = tapScheduleInput((error: MyError) => {
935
+ * reasons.push(error.type);
936
+ * })(retrySchedule);
937
+ * ```
938
+ *
939
+ * @group Side effects
940
+ */
941
+ export declare const tapScheduleInput: <Input>(f: (input: Input) => void) => <Output>(schedule: Schedule<Output, Input>) => Schedule<Output, Input>;
942
+ /**
943
+ * AWS standard retry strategy.
944
+ *
945
+ * Exponential backoff (100ms base), max 2 retries (3 total attempts), 20s cap,
946
+ * full jitter.
947
+ *
948
+ * @group Retry Strategies
949
+ * @see https://github.com/aws/aws-sdk-java-v2/blob/master/core/retries/src/main/java/software/amazon/awssdk/retries/StandardRetryStrategy.java
950
+ * @see https://github.com/aws/aws-sdk-java-v2/blob/master/core/retries/src/main/java/software/amazon/awssdk/retries/DefaultRetryStrategy.java
951
+ */
952
+ export declare const retryStrategyAws: Schedule<Millis>;
953
+ //# sourceMappingURL=Schedule.d.ts.map