effect 4.0.0-beta.6 → 4.0.0-beta.7

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 (273) hide show
  1. package/dist/Cache.d.ts +2 -2
  2. package/dist/Cache.d.ts.map +1 -1
  3. package/dist/Cache.js +1 -1
  4. package/dist/Cache.js.map +1 -1
  5. package/dist/Config.d.ts +2 -2
  6. package/dist/Config.js +3 -3
  7. package/dist/Config.js.map +1 -1
  8. package/dist/DateTime.d.ts +23 -161
  9. package/dist/DateTime.d.ts.map +1 -1
  10. package/dist/DateTime.js +6 -51
  11. package/dist/DateTime.js.map +1 -1
  12. package/dist/Duration.d.ts +12 -12
  13. package/dist/Duration.d.ts.map +1 -1
  14. package/dist/Duration.js +12 -12
  15. package/dist/Duration.js.map +1 -1
  16. package/dist/Effect.d.ts +13 -13
  17. package/dist/Effect.d.ts.map +1 -1
  18. package/dist/Effect.js +1 -1
  19. package/dist/Effect.js.map +1 -1
  20. package/dist/Formatter.d.ts +131 -47
  21. package/dist/Formatter.d.ts.map +1 -1
  22. package/dist/Formatter.js +228 -50
  23. package/dist/Formatter.js.map +1 -1
  24. package/dist/JsonSchema.d.ts +299 -10
  25. package/dist/JsonSchema.d.ts.map +1 -1
  26. package/dist/JsonSchema.js +323 -4
  27. package/dist/JsonSchema.js.map +1 -1
  28. package/dist/LayerMap.d.ts +4 -4
  29. package/dist/LayerMap.d.ts.map +1 -1
  30. package/dist/LogLevel.d.ts +27 -0
  31. package/dist/LogLevel.d.ts.map +1 -1
  32. package/dist/LogLevel.js +28 -100
  33. package/dist/LogLevel.js.map +1 -1
  34. package/dist/Logger.d.ts +4 -4
  35. package/dist/Logger.d.ts.map +1 -1
  36. package/dist/Metric.d.ts +2 -2
  37. package/dist/Metric.d.ts.map +1 -1
  38. package/dist/Metric.js +1 -1
  39. package/dist/Metric.js.map +1 -1
  40. package/dist/Pool.d.ts +1 -1
  41. package/dist/Pool.d.ts.map +1 -1
  42. package/dist/Pool.js +1 -1
  43. package/dist/Pool.js.map +1 -1
  44. package/dist/Random.d.ts +1 -1
  45. package/dist/Random.d.ts.map +1 -1
  46. package/dist/Random.js +3 -12
  47. package/dist/Random.js.map +1 -1
  48. package/dist/RcMap.d.ts +2 -2
  49. package/dist/RcMap.d.ts.map +1 -1
  50. package/dist/RcMap.js +1 -1
  51. package/dist/RcMap.js.map +1 -1
  52. package/dist/RcRef.d.ts +1 -1
  53. package/dist/RcRef.d.ts.map +1 -1
  54. package/dist/RequestResolver.d.ts +6 -6
  55. package/dist/RequestResolver.d.ts.map +1 -1
  56. package/dist/RequestResolver.js.map +1 -1
  57. package/dist/Schedule.d.ts +20 -11
  58. package/dist/Schedule.d.ts.map +1 -1
  59. package/dist/Schedule.js +23 -9
  60. package/dist/Schedule.js.map +1 -1
  61. package/dist/Schema.d.ts +4 -4
  62. package/dist/Schema.d.ts.map +1 -1
  63. package/dist/ScopedCache.d.ts +2 -2
  64. package/dist/ScopedCache.d.ts.map +1 -1
  65. package/dist/ScopedCache.js +1 -1
  66. package/dist/ScopedCache.js.map +1 -1
  67. package/dist/Stream.d.ts +19 -19
  68. package/dist/Stream.d.ts.map +1 -1
  69. package/dist/Stream.js +3 -3
  70. package/dist/Stream.js.map +1 -1
  71. package/dist/index.d.ts +134 -0
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +134 -0
  74. package/dist/index.js.map +1 -1
  75. package/dist/internal/dateTime.js +3 -11
  76. package/dist/internal/dateTime.js.map +1 -1
  77. package/dist/internal/effect.js +2 -2
  78. package/dist/internal/effect.js.map +1 -1
  79. package/dist/internal/random.d.ts +2 -0
  80. package/dist/internal/random.d.ts.map +1 -0
  81. package/dist/internal/random.js +13 -0
  82. package/dist/internal/random.js.map +1 -0
  83. package/dist/internal/rcRef.js +1 -1
  84. package/dist/internal/rcRef.js.map +1 -1
  85. package/dist/testing/TestClock.d.ts +4 -4
  86. package/dist/testing/TestClock.d.ts.map +1 -1
  87. package/dist/testing/TestClock.js +1 -1
  88. package/dist/testing/TestClock.js.map +1 -1
  89. package/dist/testing/TestSchema.d.ts +6 -6
  90. package/dist/testing/TestSchema.d.ts.map +1 -1
  91. package/dist/unstable/ai/AiError.d.ts +10 -10
  92. package/dist/unstable/ai/AiError.d.ts.map +1 -1
  93. package/dist/unstable/ai/Chat.d.ts +3 -3
  94. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  95. package/dist/unstable/ai/Chat.js +2 -2
  96. package/dist/unstable/ai/Chat.js.map +1 -1
  97. package/dist/unstable/ai/LanguageModel.d.ts +2 -2
  98. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  99. package/dist/unstable/ai/McpServer.d.ts +1 -1
  100. package/dist/unstable/ai/McpServer.d.ts.map +1 -1
  101. package/dist/unstable/ai/McpServer.js.map +1 -1
  102. package/dist/unstable/ai/Prompt.d.ts +17 -17
  103. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  104. package/dist/unstable/ai/Response.d.ts +23 -23
  105. package/dist/unstable/ai/Response.d.ts.map +1 -1
  106. package/dist/unstable/ai/Response.js +1 -1
  107. package/dist/unstable/ai/Response.js.map +1 -1
  108. package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
  109. package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
  110. package/dist/unstable/cluster/ClusterCron.js +1 -1
  111. package/dist/unstable/cluster/ClusterCron.js.map +1 -1
  112. package/dist/unstable/cluster/Entity.d.ts +3 -3
  113. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  114. package/dist/unstable/cluster/EntityResource.d.ts +2 -2
  115. package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
  116. package/dist/unstable/cluster/K8sHttpClient.js +1 -1
  117. package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
  118. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  119. package/dist/unstable/cluster/Sharding.d.ts +2 -2
  120. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  121. package/dist/unstable/cluster/Sharding.js +1 -1
  122. package/dist/unstable/cluster/Sharding.js.map +1 -1
  123. package/dist/unstable/cluster/ShardingConfig.d.ts +21 -21
  124. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  125. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  126. package/dist/unstable/cluster/SqlRunnerStorage.js +1 -1
  127. package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
  128. package/dist/unstable/cluster/internal/entityManager.js +1 -1
  129. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  130. package/dist/unstable/encoding/Sse.d.ts +2 -2
  131. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  132. package/dist/unstable/encoding/Sse.js.map +1 -1
  133. package/dist/unstable/http/Cookies.d.ts +1 -1
  134. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  135. package/dist/unstable/http/Cookies.js +2 -2
  136. package/dist/unstable/http/Cookies.js.map +1 -1
  137. package/dist/unstable/http/HttpClient.d.ts +4 -4
  138. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  139. package/dist/unstable/http/HttpClientRequest.d.ts +11 -11
  140. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  141. package/dist/unstable/http/HttpClientRequest.js +8 -1
  142. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  143. package/dist/unstable/http/HttpMethod.d.ts +4 -4
  144. package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
  145. package/dist/unstable/http/HttpMethod.js +3 -3
  146. package/dist/unstable/http/HttpMethod.js.map +1 -1
  147. package/dist/unstable/observability/Otlp.d.ts +12 -12
  148. package/dist/unstable/observability/Otlp.d.ts.map +1 -1
  149. package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
  150. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  151. package/dist/unstable/observability/OtlpExporter.js +1 -1
  152. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  153. package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
  154. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  155. package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
  156. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  157. package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
  158. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  159. package/dist/unstable/persistence/Persistable.d.ts +2 -2
  160. package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
  161. package/dist/unstable/persistence/PersistedQueue.d.ts +12 -12
  162. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  163. package/dist/unstable/persistence/PersistedQueue.js +6 -6
  164. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  165. package/dist/unstable/persistence/Persistence.d.ts +1 -1
  166. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  167. package/dist/unstable/persistence/Persistence.js +2 -2
  168. package/dist/unstable/persistence/Persistence.js.map +1 -1
  169. package/dist/unstable/persistence/RateLimiter.d.ts +3 -3
  170. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  171. package/dist/unstable/persistence/RateLimiter.js +1 -1
  172. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  173. package/dist/unstable/process/ChildProcess.d.ts +1 -1
  174. package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
  175. package/dist/unstable/reactivity/Atom.d.ts +6 -6
  176. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  177. package/dist/unstable/reactivity/Atom.js +3 -3
  178. package/dist/unstable/reactivity/Atom.js.map +1 -1
  179. package/dist/unstable/reactivity/AtomHttpApi.d.ts +1 -1
  180. package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
  181. package/dist/unstable/reactivity/AtomHttpApi.js +1 -1
  182. package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
  183. package/dist/unstable/reactivity/AtomRpc.d.ts +1 -1
  184. package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
  185. package/dist/unstable/reactivity/AtomRpc.js +1 -1
  186. package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
  187. package/dist/unstable/rpc/Rpc.d.ts +2 -2
  188. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  189. package/dist/unstable/rpc/RpcClient.d.ts +5 -26
  190. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  191. package/dist/unstable/rpc/RpcClient.js +3 -11
  192. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  193. package/dist/unstable/socket/Socket.d.ts +4 -4
  194. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  195. package/dist/unstable/sql/SqlModel.d.ts +2 -2
  196. package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
  197. package/dist/unstable/sql/SqlModel.js +3 -3
  198. package/dist/unstable/sql/SqlModel.js.map +1 -1
  199. package/dist/unstable/sql/SqlSchema.d.ts +16 -5
  200. package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
  201. package/dist/unstable/sql/SqlSchema.js +17 -7
  202. package/dist/unstable/sql/SqlSchema.js.map +1 -1
  203. package/dist/unstable/workflow/DurableClock.d.ts +3 -3
  204. package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
  205. package/dist/unstable/workflow/DurableClock.js +3 -3
  206. package/dist/unstable/workflow/DurableClock.js.map +1 -1
  207. package/package.json +1 -1
  208. package/src/Cache.ts +3 -3
  209. package/src/Config.ts +3 -3
  210. package/src/DateTime.ts +24 -164
  211. package/src/Duration.ts +15 -15
  212. package/src/Effect.ts +15 -15
  213. package/src/Formatter.ts +252 -50
  214. package/src/JsonSchema.ts +383 -10
  215. package/src/LayerMap.ts +5 -5
  216. package/src/LogLevel.ts +31 -0
  217. package/src/Logger.ts +5 -5
  218. package/src/Metric.ts +4 -4
  219. package/src/Pool.ts +4 -4
  220. package/src/Random.ts +5 -14
  221. package/src/RcMap.ts +5 -5
  222. package/src/RcRef.ts +1 -1
  223. package/src/RequestResolver.ts +9 -9
  224. package/src/Schedule.ts +44 -25
  225. package/src/Schema.ts +4 -4
  226. package/src/ScopedCache.ts +3 -3
  227. package/src/Stream.ts +34 -34
  228. package/src/index.ts +134 -0
  229. package/src/internal/dateTime.ts +9 -30
  230. package/src/internal/effect.ts +21 -21
  231. package/src/internal/random.ts +20 -0
  232. package/src/internal/rcRef.ts +2 -2
  233. package/src/testing/TestClock.ts +5 -5
  234. package/src/testing/TestSchema.ts +8 -8
  235. package/src/unstable/ai/AiError.ts +1 -1
  236. package/src/unstable/ai/Chat.ts +10 -10
  237. package/src/unstable/ai/LanguageModel.ts +3 -3
  238. package/src/unstable/ai/McpServer.ts +2 -2
  239. package/src/unstable/ai/Prompt.ts +17 -17
  240. package/src/unstable/ai/Response.ts +23 -23
  241. package/src/unstable/cluster/ClusterCron.ts +2 -2
  242. package/src/unstable/cluster/Entity.ts +5 -5
  243. package/src/unstable/cluster/EntityResource.ts +4 -4
  244. package/src/unstable/cluster/K8sHttpClient.ts +1 -1
  245. package/src/unstable/cluster/MessageStorage.ts +1 -4
  246. package/src/unstable/cluster/Sharding.ts +3 -3
  247. package/src/unstable/cluster/ShardingConfig.ts +10 -11
  248. package/src/unstable/cluster/SqlRunnerStorage.ts +1 -1
  249. package/src/unstable/cluster/internal/entityManager.ts +3 -3
  250. package/src/unstable/encoding/Sse.ts +2 -4
  251. package/src/unstable/http/Cookies.ts +3 -3
  252. package/src/unstable/http/HttpClient.ts +4 -4
  253. package/src/unstable/http/HttpClientRequest.ts +15 -11
  254. package/src/unstable/http/HttpMethod.ts +16 -4
  255. package/src/unstable/observability/Otlp.ts +12 -12
  256. package/src/unstable/observability/OtlpExporter.ts +3 -3
  257. package/src/unstable/observability/OtlpLogger.ts +4 -4
  258. package/src/unstable/observability/OtlpMetrics.ts +4 -4
  259. package/src/unstable/observability/OtlpTracer.ts +4 -4
  260. package/src/unstable/persistence/Persistable.ts +2 -2
  261. package/src/unstable/persistence/PersistedQueue.ts +18 -18
  262. package/src/unstable/persistence/Persistence.ts +3 -3
  263. package/src/unstable/persistence/RateLimiter.ts +4 -4
  264. package/src/unstable/process/ChildProcess.ts +1 -1
  265. package/src/unstable/reactivity/Atom.ts +13 -13
  266. package/src/unstable/reactivity/AtomHttpApi.ts +3 -3
  267. package/src/unstable/reactivity/AtomRpc.ts +3 -3
  268. package/src/unstable/rpc/Rpc.ts +3 -3
  269. package/src/unstable/rpc/RpcClient.ts +8 -51
  270. package/src/unstable/socket/Socket.ts +4 -4
  271. package/src/unstable/sql/SqlModel.ts +5 -5
  272. package/src/unstable/sql/SqlSchema.ts +41 -25
  273. package/src/unstable/workflow/DurableClock.ts +8 -8
package/src/Stream.ts CHANGED
@@ -472,7 +472,7 @@ export const fromEffectSchedule = <A, E, R, X, AS extends A, ES, RS>(
472
472
  * @since 2.0.0
473
473
  * @category Constructors
474
474
  */
475
- export const tick = (interval: Duration.DurationInput): Stream<void> =>
475
+ export const tick = (interval: Duration.Input): Stream<void> =>
476
476
  fromPull(Effect.sync(() => {
477
477
  let first = true
478
478
  const effect = Effect.succeed(Arr.of<void>(undefined))
@@ -3317,7 +3317,7 @@ export const timeout: {
3317
3317
  * @since 2.0.0
3318
3318
  * @category Rate Limiting
3319
3319
  */
3320
- (duration: Duration.DurationInput): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
3320
+ (duration: Duration.Input): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
3321
3321
  /**
3322
3322
  * Ends the stream if it does not produce a value within the specified duration.
3323
3323
  *
@@ -3341,10 +3341,10 @@ export const timeout: {
3341
3341
  * @since 2.0.0
3342
3342
  * @category Rate Limiting
3343
3343
  */
3344
- <A, E, R>(self: Stream<A, E, R>, duration: Duration.DurationInput): Stream<A, E, R>
3344
+ <A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R>
3345
3345
  } = dual(
3346
3346
  2,
3347
- <A, E, R>(self: Stream<A, E, R>, duration: Duration.DurationInput): Stream<A, E, R> =>
3347
+ <A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R> =>
3348
3348
  transformPull(self, (pull, _scope) =>
3349
3349
  Effect.succeed(Effect.timeoutOrElse(pull, {
3350
3350
  duration,
@@ -12175,7 +12175,7 @@ export const debounce: {
12175
12175
  * @since 2.0.0
12176
12176
  * @category Rate Limiting
12177
12177
  */
12178
- (duration: Duration.DurationInput): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
12178
+ (duration: Duration.Input): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
12179
12179
  /**
12180
12180
  * Drops earlier elements within the debounce window and emits only the latest element after the pause.
12181
12181
  *
@@ -12199,15 +12199,15 @@ export const debounce: {
12199
12199
  * @since 2.0.0
12200
12200
  * @category Rate Limiting
12201
12201
  */
12202
- <A, E, R>(self: Stream<A, E, R>, duration: Duration.DurationInput): Stream<A, E, R>
12202
+ <A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R>
12203
12203
  } = dual(
12204
12204
  2,
12205
- <A, E, R>(self: Stream<A, E, R>, duration: Duration.DurationInput): Stream<A, E, R> =>
12205
+ <A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R> =>
12206
12206
  transformPull(
12207
12207
  self,
12208
12208
  Effect.fnUntraced(function*(pull, scope) {
12209
12209
  const clock = yield* Clock
12210
- const durationMs = Duration.toMillis(Duration.fromDurationInputUnsafe(duration))
12210
+ const durationMs = Duration.toMillis(Duration.fromInputUnsafe(duration))
12211
12211
  let lastArr: Arr.NonEmptyReadonlyArray<A> | undefined
12212
12212
  let cause: Cause.Cause<Cause.Done | E> | undefined
12213
12213
  let emitAtMs = Infinity
@@ -12347,7 +12347,7 @@ export const throttleEffect: {
12347
12347
  options: {
12348
12348
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>
12349
12349
  readonly units: number
12350
- readonly duration: Duration.DurationInput
12350
+ readonly duration: Duration.Input
12351
12351
  readonly burst?: number | undefined
12352
12352
  readonly strategy?: "enforce" | "shape" | undefined
12353
12353
  }
@@ -12393,7 +12393,7 @@ export const throttleEffect: {
12393
12393
  options: {
12394
12394
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>
12395
12395
  readonly units: number
12396
- readonly duration: Duration.DurationInput
12396
+ readonly duration: Duration.Input
12397
12397
  readonly burst?: number | undefined
12398
12398
  readonly strategy?: "enforce" | "shape" | undefined
12399
12399
  }
@@ -12405,7 +12405,7 @@ export const throttleEffect: {
12405
12405
  options: {
12406
12406
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>
12407
12407
  readonly units: number
12408
- readonly duration: Duration.DurationInput
12408
+ readonly duration: Duration.Input
12409
12409
  readonly burst?: number | undefined
12410
12410
  readonly strategy?: "enforce" | "shape" | undefined
12411
12411
  }
@@ -12422,12 +12422,12 @@ const throttleEnforceEffect = <A, E, R, E2, R2>(
12422
12422
  self: Stream<A, E, R>,
12423
12423
  cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>,
12424
12424
  units: number,
12425
- duration: Duration.DurationInput,
12425
+ duration: Duration.Input,
12426
12426
  burst: number
12427
12427
  ): Stream<A, E | E2, R | R2> =>
12428
12428
  transformPull(self, (pull) =>
12429
12429
  Effect.clockWith((clock) => {
12430
- const durationMs = Duration.toMillis(Duration.fromDurationInputUnsafe(duration))
12430
+ const durationMs = Duration.toMillis(Duration.fromInputUnsafe(duration))
12431
12431
  const max = units + burst < 0 ? Number.POSITIVE_INFINITY : units + burst
12432
12432
  let tokens = units
12433
12433
  let timestampMs = clock.currentTimeMillisUnsafe()
@@ -12458,12 +12458,12 @@ const throttleShapeEffect = <A, E, R, E2, R2>(
12458
12458
  self: Stream<A, E, R>,
12459
12459
  cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>,
12460
12460
  units: number,
12461
- duration: Duration.DurationInput,
12461
+ duration: Duration.Input,
12462
12462
  burst: number
12463
12463
  ): Stream<A, E | E2, R | R2> =>
12464
12464
  transformPull(self, (pull) =>
12465
12465
  Effect.clockWith((clock) => {
12466
- const durationMs = Duration.toMillis(Duration.fromDurationInputUnsafe(duration))
12466
+ const durationMs = Duration.toMillis(Duration.fromInputUnsafe(duration))
12467
12467
  const max = units + burst < 0 ? Number.POSITIVE_INFINITY : units + burst
12468
12468
  let tokens = units
12469
12469
  let timestampMs = clock.currentTimeMillisUnsafe()
@@ -12576,7 +12576,7 @@ export const throttle: {
12576
12576
  options: {
12577
12577
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => number
12578
12578
  readonly units: number
12579
- readonly duration: Duration.DurationInput
12579
+ readonly duration: Duration.Input
12580
12580
  readonly burst?: number | undefined
12581
12581
  readonly strategy?: "enforce" | "shape" | undefined
12582
12582
  }
@@ -12621,7 +12621,7 @@ export const throttle: {
12621
12621
  options: {
12622
12622
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => number
12623
12623
  readonly units: number
12624
- readonly duration: Duration.DurationInput
12624
+ readonly duration: Duration.Input
12625
12625
  readonly burst?: number | undefined
12626
12626
  readonly strategy?: "enforce" | "shape" | undefined
12627
12627
  }
@@ -12633,7 +12633,7 @@ export const throttle: {
12633
12633
  options: {
12634
12634
  readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => number
12635
12635
  readonly units: number
12636
- readonly duration: Duration.DurationInput
12636
+ readonly duration: Duration.Input
12637
12637
  readonly burst?: number | undefined
12638
12638
  readonly strategy?: "enforce" | "shape" | undefined
12639
12639
  }
@@ -12771,7 +12771,7 @@ export const groupedWithin: {
12771
12771
  * @since 2.0.0
12772
12772
  * @category Grouping
12773
12773
  */
12774
- (chunkSize: number, duration: Duration.DurationInput): <A, E, R>(self: Stream<A, E, R>) => Stream<Array<A>, E, R>
12774
+ (chunkSize: number, duration: Duration.Input): <A, E, R>(self: Stream<A, E, R>) => Stream<Array<A>, E, R>
12775
12775
  /**
12776
12776
  * Partitions the stream into arrays, emitting when the chunk size is reached
12777
12777
  * or the duration passes.
@@ -12795,11 +12795,11 @@ export const groupedWithin: {
12795
12795
  * @since 2.0.0
12796
12796
  * @category Grouping
12797
12797
  */
12798
- <A, E, R>(self: Stream<A, E, R>, chunkSize: number, duration: Duration.DurationInput): Stream<Array<A>, E, R>
12798
+ <A, E, R>(self: Stream<A, E, R>, chunkSize: number, duration: Duration.Input): Stream<Array<A>, E, R>
12799
12799
  } = dual(3, <A, E, R>(
12800
12800
  self: Stream<A, E, R>,
12801
12801
  chunkSize: number,
12802
- duration: Duration.DurationInput
12802
+ duration: Duration.Input
12803
12803
  ): Stream<Array<A>, E, R> =>
12804
12804
  aggregateWithin(
12805
12805
  self,
@@ -12874,7 +12874,7 @@ export const groupBy: {
12874
12874
  f: (a: NoInfer<A>) => Effect.Effect<readonly [K, V], E2, R2>,
12875
12875
  options?: {
12876
12876
  readonly bufferSize?: number | undefined
12877
- readonly idleTimeToLive?: Duration.DurationInput | undefined
12877
+ readonly idleTimeToLive?: Duration.Input | undefined
12878
12878
  }
12879
12879
  ): <E, R>(self: Stream<A, E, R>) => Stream<readonly [K, Stream<V>], E | E2, R | R2>
12880
12880
  /**
@@ -12913,7 +12913,7 @@ export const groupBy: {
12913
12913
  f: (a: NoInfer<A>) => Effect.Effect<readonly [K, V], E2, R2>,
12914
12914
  options?: {
12915
12915
  readonly bufferSize?: number | undefined
12916
- readonly idleTimeToLive?: Duration.DurationInput | undefined
12916
+ readonly idleTimeToLive?: Duration.Input | undefined
12917
12917
  }
12918
12918
  ): Stream<readonly [K, Stream<V>], E | E2, R | R2>
12919
12919
  } = dual((args) => isStream(args[0]), <A, E, R, K, V, E2, R2>(
@@ -12921,7 +12921,7 @@ export const groupBy: {
12921
12921
  f: (a: NoInfer<A>) => Effect.Effect<readonly [K, V], E2, R2>,
12922
12922
  options?: {
12923
12923
  readonly bufferSize?: number | undefined
12924
- readonly idleTimeToLive?: Duration.DurationInput | undefined
12924
+ readonly idleTimeToLive?: Duration.Input | undefined
12925
12925
  }
12926
12926
  ): Stream<readonly [K, Stream<V>], E | E2, R | R2> =>
12927
12927
  groupByImpl(
@@ -13003,7 +13003,7 @@ export const groupByKey: {
13003
13003
  f: (a: NoInfer<A>) => K,
13004
13004
  options?: {
13005
13005
  readonly bufferSize?: number | undefined
13006
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13006
+ readonly idleTimeToLive?: Duration.Input | undefined
13007
13007
  }
13008
13008
  ): <E, R>(self: Stream<A, E, R>) => Stream<readonly [K, Stream<A>], E, R>
13009
13009
  /**
@@ -13040,7 +13040,7 @@ export const groupByKey: {
13040
13040
  f: (a: NoInfer<A>) => K,
13041
13041
  options?: {
13042
13042
  readonly bufferSize?: number | undefined
13043
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13043
+ readonly idleTimeToLive?: Duration.Input | undefined
13044
13044
  }
13045
13045
  ): Stream<readonly [K, Stream<A>], E, R>
13046
13046
  } = dual((args) => isStream(args[0]), <A, E, R, K>(
@@ -13048,7 +13048,7 @@ export const groupByKey: {
13048
13048
  f: (a: NoInfer<A>) => K,
13049
13049
  options?: {
13050
13050
  readonly bufferSize?: number | undefined
13051
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13051
+ readonly idleTimeToLive?: Duration.Input | undefined
13052
13052
  }
13053
13053
  ): Stream<readonly [K, Stream<A>], E, R> =>
13054
13054
  suspend(() => {
@@ -13146,7 +13146,7 @@ const groupByImpl = <A, E, R, K, V, E2, R2>(
13146
13146
  ) => Effect.Effect<void, E2, R2>,
13147
13147
  options?: {
13148
13148
  readonly bufferSize?: number | undefined
13149
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13149
+ readonly idleTimeToLive?: Duration.Input | undefined
13150
13150
  }
13151
13151
  ): Stream<readonly [K, Stream<V>], E | E2, R | R2> =>
13152
13152
  transformPullBracket(
@@ -13880,12 +13880,12 @@ export const share: {
13880
13880
  options: {
13881
13881
  readonly capacity: "unbounded"
13882
13882
  readonly replay?: number | undefined
13883
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13883
+ readonly idleTimeToLive?: Duration.Input | undefined
13884
13884
  } | {
13885
13885
  readonly capacity: number
13886
13886
  readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
13887
13887
  readonly replay?: number | undefined
13888
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13888
+ readonly idleTimeToLive?: Duration.Input | undefined
13889
13889
  }
13890
13890
  ): <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<Stream<A, E>, never, Scope.Scope | R>
13891
13891
  /**
@@ -13924,12 +13924,12 @@ export const share: {
13924
13924
  options: {
13925
13925
  readonly capacity: "unbounded"
13926
13926
  readonly replay?: number | undefined
13927
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13927
+ readonly idleTimeToLive?: Duration.Input | undefined
13928
13928
  } | {
13929
13929
  readonly capacity: number
13930
13930
  readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
13931
13931
  readonly replay?: number | undefined
13932
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13932
+ readonly idleTimeToLive?: Duration.Input | undefined
13933
13933
  }
13934
13934
  ): Effect.Effect<Stream<A, E>, never, Scope.Scope | R>
13935
13935
  } = dual(2, <A, E, R>(
@@ -13937,12 +13937,12 @@ export const share: {
13937
13937
  options: {
13938
13938
  readonly capacity: "unbounded"
13939
13939
  readonly replay?: number | undefined
13940
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13940
+ readonly idleTimeToLive?: Duration.Input | undefined
13941
13941
  } | {
13942
13942
  readonly capacity: number
13943
13943
  readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
13944
13944
  readonly replay?: number | undefined
13945
- readonly idleTimeToLive?: Duration.DurationInput | undefined
13945
+ readonly idleTimeToLive?: Duration.Input | undefined
13946
13946
  }
13947
13947
  ): Effect.Effect<Stream<A, E>, never, Scope.Scope | R> =>
13948
13948
  Effect.map(
package/src/index.ts CHANGED
@@ -1137,6 +1137,57 @@ export * as FileSystem from "./FileSystem.ts"
1137
1137
  export * as Filter from "./Filter.ts"
1138
1138
 
1139
1139
  /**
1140
+ * Utilities for converting arbitrary JavaScript values into human-readable
1141
+ * strings, with support for circular references, redaction, and common JS
1142
+ * types that `JSON.stringify` handles poorly.
1143
+ *
1144
+ * Mental model:
1145
+ * - A `Formatter<Value, Format>` is a callable `(value: Value) => Format`.
1146
+ * - {@link format} is the general-purpose pretty-printer: it handles
1147
+ * primitives, arrays, objects, `BigInt`, `Symbol`, `Date`, `RegExp`,
1148
+ * `Set`, `Map`, class instances, and circular references.
1149
+ * - {@link formatJson} is a safe `JSON.stringify` wrapper that silently
1150
+ * drops circular references and applies redaction.
1151
+ * - Both functions accept a `space` option for indentation control.
1152
+ *
1153
+ * Common tasks:
1154
+ * - Pretty-print any value for debugging / logging -> {@link format}
1155
+ * - Serialize to JSON safely (no circular throws) -> {@link formatJson}
1156
+ * - Format a single object property key -> {@link formatPropertyKey}
1157
+ * - Format a property path like `["a"]["b"]` -> {@link formatPath}
1158
+ * - Format a `Date` to ISO string safely -> {@link formatDate}
1159
+ *
1160
+ * Gotchas:
1161
+ * - {@link format} output is **not** valid JSON; use {@link formatJson} when
1162
+ * you need parseable JSON.
1163
+ * - {@link format} calls `toString()` on objects by default; pass
1164
+ * `ignoreToString: true` to disable.
1165
+ * - {@link formatJson} silently omits circular references (the key is
1166
+ * dropped from the output).
1167
+ * - Values implementing the `Redactable` protocol are automatically
1168
+ * redacted by both {@link format} and {@link formatJson}.
1169
+ *
1170
+ * **Example** (Pretty-print a value)
1171
+ *
1172
+ * ```ts
1173
+ * import { Formatter } from "effect"
1174
+ *
1175
+ * const obj = { name: "Alice", scores: [100, 97] }
1176
+ * console.log(Formatter.format(obj))
1177
+ * // {"name":"Alice","scores":[100,97]}
1178
+ *
1179
+ * console.log(Formatter.format(obj, { space: 2 }))
1180
+ * // {
1181
+ * // "name": "Alice",
1182
+ * // "scores": [
1183
+ * // 100,
1184
+ * // 97
1185
+ * // ]
1186
+ * // }
1187
+ * ```
1188
+ *
1189
+ * See also: {@link Formatter}, {@link format}, {@link formatJson}
1190
+ *
1140
1191
  * @since 4.0.0
1141
1192
  */
1142
1193
  export * as Formatter from "./Formatter.ts"
@@ -1401,6 +1452,89 @@ export * as JsonPatch from "./JsonPatch.ts"
1401
1452
  export * as JsonPointer from "./JsonPointer.ts"
1402
1453
 
1403
1454
  /**
1455
+ * Convert JSON Schema documents between dialects (Draft-07, Draft-2020-12,
1456
+ * OpenAPI 3.0, OpenAPI 3.1). All dialects are normalized to an internal
1457
+ * `Document<"draft-2020-12">` representation before optional conversion to
1458
+ * an output dialect.
1459
+ *
1460
+ * ## Mental model
1461
+ *
1462
+ * - **JsonSchema** — a plain object with string keys; represents any single
1463
+ * JSON Schema node.
1464
+ * - **Dialect** — one of `"draft-07"`, `"draft-2020-12"`, `"openapi-3.1"`,
1465
+ * or `"openapi-3.0"`.
1466
+ * - **Document** — a structured container holding a root `schema`, its
1467
+ * companion `definitions`, and the target `dialect`. Definitions are
1468
+ * stored separately from the root schema so they can be relocated when
1469
+ * converting between dialects.
1470
+ * - **MultiDocument** — same as `Document` but carries multiple root
1471
+ * schemas (at least one). Useful when generating several schemas that
1472
+ * share a single definitions pool.
1473
+ * - **Definitions** — a `Record<string, JsonSchema>` keyed by definition
1474
+ * name. The ref pointer prefix depends on the dialect.
1475
+ * - **`from*` functions** — parse a raw JSON Schema object into the
1476
+ * canonical `Document<"draft-2020-12">`.
1477
+ * - **`to*` functions** — convert from the canonical representation to a
1478
+ * specific output dialect.
1479
+ *
1480
+ * ## Common tasks
1481
+ *
1482
+ * - Parse a Draft-07 schema → {@link fromSchemaDraft07}
1483
+ * - Parse a Draft-2020-12 schema → {@link fromSchemaDraft2020_12}
1484
+ * - Parse an OpenAPI 3.1 schema → {@link fromSchemaOpenApi3_1}
1485
+ * - Parse an OpenAPI 3.0 schema → {@link fromSchemaOpenApi3_0}
1486
+ * - Convert to Draft-07 output → {@link toDocumentDraft07}
1487
+ * - Convert to OpenAPI 3.1 output → {@link toMultiDocumentOpenApi3_1}
1488
+ * - Resolve a `$ref` against definitions → {@link resolve$ref}
1489
+ * - Inline the root `$ref` of a document → {@link resolveTopLevel$ref}
1490
+ *
1491
+ * ## Gotchas
1492
+ *
1493
+ * - All `from*` functions normalize to `Document<"draft-2020-12">`
1494
+ * regardless of the input dialect.
1495
+ * - Unsupported or unrecognized JSON Schema keywords are silently dropped
1496
+ * during conversion.
1497
+ * - Draft-07 tuple syntax (`items` as array + `additionalItems`) is
1498
+ * converted to 2020-12 form (`prefixItems` + `items`), and vice-versa.
1499
+ * - OpenAPI 3.0 `nullable: true` is expanded into `type` arrays or
1500
+ * `anyOf` unions. The `nullable` keyword is removed.
1501
+ * - OpenAPI 3.0 singular `example` is converted to `examples` (array).
1502
+ * - {@link resolve$ref} only looks up the last segment of the ref path in
1503
+ * the definitions map; it does not follow arbitrary JSON Pointer paths.
1504
+ *
1505
+ * ## Quickstart
1506
+ *
1507
+ * **Example** (Parse a Draft-07 schema and convert to Draft-07 output)
1508
+ *
1509
+ * ```ts
1510
+ * import { JsonSchema } from "effect"
1511
+ *
1512
+ * const raw: JsonSchema.JsonSchema = {
1513
+ * type: "object",
1514
+ * properties: {
1515
+ * name: { type: "string" }
1516
+ * },
1517
+ * required: ["name"]
1518
+ * }
1519
+ *
1520
+ * // Parse into canonical form
1521
+ * const doc = JsonSchema.fromSchemaDraft07(raw)
1522
+ *
1523
+ * // Convert back to Draft-07
1524
+ * const draft07 = JsonSchema.toDocumentDraft07(doc)
1525
+ *
1526
+ * console.log(draft07.dialect) // "draft-07"
1527
+ * console.log(draft07.schema) // { type: "object", properties: { name: { type: "string" } }, required: ["name"] }
1528
+ * ```
1529
+ *
1530
+ * ## See also
1531
+ *
1532
+ * - {@link Document}
1533
+ * - {@link MultiDocument}
1534
+ * - {@link fromSchemaDraft07}
1535
+ * - {@link toDocumentDraft07}
1536
+ * - {@link resolve$ref}
1537
+ *
1404
1538
  * @since 4.0.0
1405
1539
  */
1406
1540
  export * as JsonSchema from "./JsonSchema.ts"
@@ -12,7 +12,6 @@ import * as Inspectable from "../Inspectable.ts"
12
12
  import * as order from "../Order.ts"
13
13
  import { pipeArguments } from "../Pipeable.ts"
14
14
  import * as Predicate from "../Predicate.ts"
15
- import * as Result from "../Result.ts"
16
15
  import type { Mutable } from "../Types.ts"
17
16
  import * as UndefinedOr from "../UndefinedOr.ts"
18
17
  import * as effect from "./effect.ts"
@@ -467,32 +466,12 @@ export const setZoneNamedUnsafe: {
467
466
 
468
467
  /** @internal */
469
468
  export const distance: {
470
- (other: DateTime.DateTime): (self: DateTime.DateTime) => number
471
- (self: DateTime.DateTime, other: DateTime.DateTime): number
472
- } = dual(2, (self: DateTime.DateTime, other: DateTime.DateTime): number => toEpochMillis(other) - toEpochMillis(self))
473
-
474
- /** @internal */
475
- export const distanceDurationResult: {
476
- (other: DateTime.DateTime): (self: DateTime.DateTime) => Result.Result<Duration.Duration, Duration.Duration>
477
- (self: DateTime.DateTime, other: DateTime.DateTime): Result.Result<Duration.Duration, Duration.Duration>
478
- } = dual(
479
- 2,
480
- (self: DateTime.DateTime, other: DateTime.DateTime): Result.Result<Duration.Duration, Duration.Duration> => {
481
- const diffMillis = distance(self, other)
482
- return diffMillis > 0
483
- ? Result.succeed(Duration.millis(diffMillis))
484
- : Result.fail(Duration.millis(-diffMillis))
485
- }
486
- )
487
-
488
- /** @internal */
489
- export const distanceDuration: {
490
469
  (other: DateTime.DateTime): (self: DateTime.DateTime) => Duration.Duration
491
470
  (self: DateTime.DateTime, other: DateTime.DateTime): Duration.Duration
492
471
  } = dual(
493
472
  2,
494
473
  (self: DateTime.DateTime, other: DateTime.DateTime): Duration.Duration =>
495
- Duration.millis(Math.abs(distance(self, other)))
474
+ Duration.millis(toEpochMillis(other) - toEpochMillis(self))
496
475
  )
497
476
 
498
477
  /** @internal */
@@ -911,22 +890,22 @@ export const match: {
911
890
 
912
891
  /** @internal */
913
892
  export const addDuration: {
914
- (duration: Duration.DurationInput): <A extends DateTime.DateTime>(self: A) => A
915
- <A extends DateTime.DateTime>(self: A, duration: Duration.DurationInput): A
893
+ (duration: Duration.Input): <A extends DateTime.DateTime>(self: A) => A
894
+ <A extends DateTime.DateTime>(self: A, duration: Duration.Input): A
916
895
  } = dual(
917
896
  2,
918
- (self: DateTime.DateTime, duration: Duration.DurationInput): DateTime.DateTime =>
919
- mapEpochMillis(self, (millis) => millis + Duration.toMillis(Duration.fromDurationInputUnsafe(duration)))
897
+ (self: DateTime.DateTime, duration: Duration.Input): DateTime.DateTime =>
898
+ mapEpochMillis(self, (millis) => millis + Duration.toMillis(Duration.fromInputUnsafe(duration)))
920
899
  )
921
900
 
922
901
  /** @internal */
923
902
  export const subtractDuration: {
924
- (duration: Duration.DurationInput): <A extends DateTime.DateTime>(self: A) => A
925
- <A extends DateTime.DateTime>(self: A, duration: Duration.DurationInput): A
903
+ (duration: Duration.Input): <A extends DateTime.DateTime>(self: A) => A
904
+ <A extends DateTime.DateTime>(self: A, duration: Duration.Input): A
926
905
  } = dual(
927
906
  2,
928
- (self: DateTime.DateTime, duration: Duration.DurationInput): DateTime.DateTime =>
929
- mapEpochMillis(self, (millis) => millis - Duration.toMillis(Duration.fromDurationInputUnsafe(duration)))
907
+ (self: DateTime.DateTime, duration: Duration.Input): DateTime.DateTime =>
908
+ mapEpochMillis(self, (millis) => millis - Duration.toMillis(Duration.fromInputUnsafe(duration)))
930
909
  )
931
910
 
932
911
  const addMillis = (date: Date, amount: number): void => {
@@ -3404,24 +3404,24 @@ export const isSuccess: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect
3404
3404
  /** @internal */
3405
3405
  export const delay: {
3406
3406
  (
3407
- duration: Duration.DurationInput
3407
+ duration: Duration.Input
3408
3408
  ): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
3409
3409
  <A, E, R>(
3410
3410
  self: Effect.Effect<A, E, R>,
3411
- duration: Duration.DurationInput
3411
+ duration: Duration.Input
3412
3412
  ): Effect.Effect<A, E, R>
3413
3413
  } = dual(
3414
3414
  2,
3415
3415
  <A, E, R>(
3416
3416
  self: Effect.Effect<A, E, R>,
3417
- duration: Duration.DurationInput
3417
+ duration: Duration.Input
3418
3418
  ): Effect.Effect<A, E, R> => andThen(sleep(duration), self)
3419
3419
  )
3420
3420
 
3421
3421
  /** @internal */
3422
3422
  export const timeoutOrElse: {
3423
3423
  <A2, E2, R2>(options: {
3424
- readonly duration: Duration.DurationInput
3424
+ readonly duration: Duration.Input
3425
3425
  readonly onTimeout: LazyArg<Effect.Effect<A2, E2, R2>>
3426
3426
  }): <A, E, R>(
3427
3427
  self: Effect.Effect<A, E, R>
@@ -3429,7 +3429,7 @@ export const timeoutOrElse: {
3429
3429
  <A, E, R, A2, E2, R2>(
3430
3430
  self: Effect.Effect<A, E, R>,
3431
3431
  options: {
3432
- readonly duration: Duration.DurationInput
3432
+ readonly duration: Duration.Input
3433
3433
  readonly onTimeout: LazyArg<Effect.Effect<A2, E2, R2>>
3434
3434
  }
3435
3435
  ): Effect.Effect<A | A2, E | E2, R | R2>
@@ -3438,7 +3438,7 @@ export const timeoutOrElse: {
3438
3438
  <A, E, R, A2, E2, R2>(
3439
3439
  self: Effect.Effect<A, E, R>,
3440
3440
  options: {
3441
- readonly duration: Duration.DurationInput
3441
+ readonly duration: Duration.Input
3442
3442
  readonly onTimeout: LazyArg<Effect.Effect<A2, E2, R2>>
3443
3443
  }
3444
3444
  ): Effect.Effect<A | A2, E | E2, R | R2> =>
@@ -3451,19 +3451,19 @@ export const timeoutOrElse: {
3451
3451
  /** @internal */
3452
3452
  export const timeout: {
3453
3453
  (
3454
- duration: Duration.DurationInput
3454
+ duration: Duration.Input
3455
3455
  ): <A, E, R>(
3456
3456
  self: Effect.Effect<A, E, R>
3457
3457
  ) => Effect.Effect<A, E | Cause.TimeoutError, R>
3458
3458
  <A, E, R>(
3459
3459
  self: Effect.Effect<A, E, R>,
3460
- duration: Duration.DurationInput
3460
+ duration: Duration.Input
3461
3461
  ): Effect.Effect<A, E | Cause.TimeoutError, R>
3462
3462
  } = dual(
3463
3463
  2,
3464
3464
  <A, E, R>(
3465
3465
  self: Effect.Effect<A, E, R>,
3466
- duration: Duration.DurationInput
3466
+ duration: Duration.Input
3467
3467
  ): Effect.Effect<A, E | TimeoutError, R> =>
3468
3468
  timeoutOrElse(self, {
3469
3469
  duration,
@@ -3474,19 +3474,19 @@ export const timeout: {
3474
3474
  /** @internal */
3475
3475
  export const timeoutOption: {
3476
3476
  (
3477
- duration: Duration.DurationInput
3477
+ duration: Duration.Input
3478
3478
  ): <A, E, R>(
3479
3479
  self: Effect.Effect<A, E, R>
3480
3480
  ) => Effect.Effect<Option.Option<A>, E, R>
3481
3481
  <A, E, R>(
3482
3482
  self: Effect.Effect<A, E, R>,
3483
- duration: Duration.DurationInput
3483
+ duration: Duration.Input
3484
3484
  ): Effect.Effect<Option.Option<A>, E, R>
3485
3485
  } = dual(
3486
3486
  2,
3487
3487
  <A, E, R>(
3488
3488
  self: Effect.Effect<A, E, R>,
3489
- duration: Duration.DurationInput
3489
+ duration: Duration.Input
3490
3490
  ): Effect.Effect<Option.Option<A>, E, R> =>
3491
3491
  raceFirst(
3492
3492
  asSome(self),
@@ -3874,19 +3874,19 @@ export const acquireUseRelease = <Resource, E, R, A, E2, R2, E3, R3>(
3874
3874
 
3875
3875
  /** @internal */
3876
3876
  export const cachedInvalidateWithTTL: {
3877
- (timeToLive: Duration.DurationInput): <A, E, R>(
3877
+ (timeToLive: Duration.Input): <A, E, R>(
3878
3878
  self: Effect.Effect<A, E, R>
3879
3879
  ) => Effect.Effect<[Effect.Effect<A, E, R>, Effect.Effect<void>]>
3880
3880
  <A, E, R>(
3881
3881
  self: Effect.Effect<A, E, R>,
3882
- timeToLive: Duration.DurationInput
3882
+ timeToLive: Duration.Input
3883
3883
  ): Effect.Effect<[Effect.Effect<A, E, R>, Effect.Effect<void>]>
3884
3884
  } = dual(2, <A, E, R>(
3885
3885
  self: Effect.Effect<A, E, R>,
3886
- ttl: Duration.DurationInput
3886
+ ttl: Duration.Input
3887
3887
  ): Effect.Effect<[Effect.Effect<A, E, R>, Effect.Effect<void>]> =>
3888
3888
  sync(() => {
3889
- const ttlMillis = Duration.toMillis(Duration.fromDurationInputUnsafe(ttl))
3889
+ const ttlMillis = Duration.toMillis(Duration.fromInputUnsafe(ttl))
3890
3890
  const isFinite = Number.isFinite(ttlMillis)
3891
3891
  const latch = makeLatchUnsafe(false)
3892
3892
  let expiresAt = 0
@@ -3919,17 +3919,17 @@ export const cachedInvalidateWithTTL: {
3919
3919
  /** @internal */
3920
3920
  export const cachedWithTTL: {
3921
3921
  (
3922
- timeToLive: Duration.DurationInput
3922
+ timeToLive: Duration.Input
3923
3923
  ): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Effect.Effect<A, E, R>>
3924
3924
  <A, E, R>(
3925
3925
  self: Effect.Effect<A, E, R>,
3926
- timeToLive: Duration.DurationInput
3926
+ timeToLive: Duration.Input
3927
3927
  ): Effect.Effect<Effect.Effect<A, E, R>>
3928
3928
  } = dual(
3929
3929
  2,
3930
3930
  <A, E, R>(
3931
3931
  self: Effect.Effect<A, E, R>,
3932
- timeToLive: Duration.DurationInput
3932
+ timeToLive: Duration.Input
3933
3933
  ): Effect.Effect<Effect.Effect<A, E, R>> => map(cachedInvalidateWithTTL(self, timeToLive), (tuple) => tuple[0])
3934
3934
  )
3935
3935
 
@@ -5345,8 +5345,8 @@ export const clockWith = <A, E, R>(f: (clock: Clock.Clock) => Effect.Effect<A, E
5345
5345
  withFiber((fiber) => f(fiber.getRef(ClockRef)))
5346
5346
 
5347
5347
  /** @internal */
5348
- export const sleep = (duration: Duration.DurationInput): Effect.Effect<void> =>
5349
- clockWith((clock) => clock.sleep(Duration.fromDurationInputUnsafe(duration)))
5348
+ export const sleep = (duration: Duration.Input): Effect.Effect<void> =>
5349
+ clockWith((clock) => clock.sleep(Duration.fromInputUnsafe(duration)))
5350
5350
 
5351
5351
  /** @internal */
5352
5352
  export const currentTimeMillis: Effect.Effect<number> = clockWith((clock) => clock.currentTimeMillis)
@@ -0,0 +1,20 @@
1
+ import * as ServiceMap from "../ServiceMap.ts"
2
+
3
+ /** @internal */
4
+ export interface Random {
5
+ nextIntUnsafe(): number
6
+ nextDoubleUnsafe(): number
7
+ }
8
+
9
+ /** @internal */
10
+ export const Random: ServiceMap.Reference<Random> = ServiceMap.Reference<Random>("effect/Random", {
11
+ defaultValue: () => ({
12
+ nextIntUnsafe() {
13
+ return Math.floor(Math.random() * (Number.MAX_SAFE_INTEGER - Number.MIN_SAFE_INTEGER + 1)) +
14
+ Number.MIN_SAFE_INTEGER
15
+ },
16
+ nextDoubleUnsafe() {
17
+ return Math.random()
18
+ }
19
+ })
20
+ })
@@ -70,7 +70,7 @@ class RcRefImpl<A, E> implements RcRef.RcRef<A, E> {
70
70
  /** @internal */
71
71
  export const make = <A, E, R>(options: {
72
72
  readonly acquire: Effect.Effect<A, E, R>
73
- readonly idleTimeToLive?: Duration.DurationInput | undefined
73
+ readonly idleTimeToLive?: Duration.Input | undefined
74
74
  }) =>
75
75
  Effect.withFiber<RcRef.RcRef<A, E>, never, R | Scope.Scope>((fiber) => {
76
76
  const services = fiber.services as ServiceMap.ServiceMap<R | Scope.Scope>
@@ -79,7 +79,7 @@ export const make = <A, E, R>(options: {
79
79
  options.acquire as Effect.Effect<A, E>,
80
80
  services,
81
81
  scope,
82
- options.idleTimeToLive ? Duration.fromDurationInputUnsafe(options.idleTimeToLive) : undefined
82
+ options.idleTimeToLive ? Duration.fromInputUnsafe(options.idleTimeToLive) : undefined
83
83
  )
84
84
  return Effect.as(
85
85
  Scope.addFinalizerExit(scope, () => {