@clayroach/effect 3.19.14-source-capture.7 → 3.19.14-source-capture.8

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 (371) hide show
  1. package/dist/cjs/Utils.js +1 -1
  2. package/dist/cjs/Utils.js.map +1 -1
  3. package/dist/cjs/internal/clock.js +1 -1
  4. package/dist/cjs/internal/clock.js.map +1 -1
  5. package/dist/esm/Utils.js +1 -1
  6. package/dist/esm/Utils.js.map +1 -1
  7. package/dist/esm/internal/clock.js +1 -1
  8. package/dist/esm/internal/clock.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/Arbitrary.ts +0 -1101
  11. package/src/Array.ts +0 -3589
  12. package/src/BigDecimal.ts +0 -1349
  13. package/src/BigInt.ts +0 -643
  14. package/src/Boolean.ts +0 -287
  15. package/src/Brand.ts +0 -360
  16. package/src/Cache.ts +0 -281
  17. package/src/Cause.ts +0 -1555
  18. package/src/Channel.ts +0 -2355
  19. package/src/ChildExecutorDecision.ts +0 -146
  20. package/src/Chunk.ts +0 -1495
  21. package/src/Clock.ts +0 -111
  22. package/src/Config.ts +0 -542
  23. package/src/ConfigError.ts +0 -270
  24. package/src/ConfigProvider.ts +0 -333
  25. package/src/ConfigProviderPathPatch.ts +0 -100
  26. package/src/Console.ts +0 -226
  27. package/src/Context.ts +0 -585
  28. package/src/Cron.ts +0 -706
  29. package/src/Data.ts +0 -596
  30. package/src/DateTime.ts +0 -1686
  31. package/src/DefaultServices.ts +0 -34
  32. package/src/Deferred.ts +0 -301
  33. package/src/Differ.ts +0 -450
  34. package/src/Duration.ts +0 -1000
  35. package/src/Effect.ts +0 -14839
  36. package/src/Effectable.ts +0 -107
  37. package/src/Either.ts +0 -1040
  38. package/src/Encoding.ts +0 -195
  39. package/src/Equal.ts +0 -98
  40. package/src/Equivalence.ts +0 -235
  41. package/src/ExecutionPlan.ts +0 -308
  42. package/src/ExecutionStrategy.ts +0 -119
  43. package/src/Exit.ts +0 -467
  44. package/src/FastCheck.ts +0 -9
  45. package/src/Fiber.ts +0 -744
  46. package/src/FiberHandle.ts +0 -540
  47. package/src/FiberId.ts +0 -195
  48. package/src/FiberMap.ts +0 -656
  49. package/src/FiberRef.ts +0 -431
  50. package/src/FiberRefs.ts +0 -204
  51. package/src/FiberRefsPatch.ts +0 -105
  52. package/src/FiberSet.ts +0 -491
  53. package/src/FiberStatus.ts +0 -108
  54. package/src/Function.ts +0 -1222
  55. package/src/GlobalValue.ts +0 -53
  56. package/src/Graph.ts +0 -3732
  57. package/src/GroupBy.ts +0 -103
  58. package/src/HKT.ts +0 -45
  59. package/src/Hash.ts +0 -195
  60. package/src/HashMap.ts +0 -519
  61. package/src/HashRing.ts +0 -317
  62. package/src/HashSet.ts +0 -2346
  63. package/src/Inspectable.ts +0 -287
  64. package/src/Iterable.ts +0 -1119
  65. package/src/JSONSchema.ts +0 -1044
  66. package/src/KeyedPool.ts +0 -167
  67. package/src/Layer.ts +0 -1251
  68. package/src/LayerMap.ts +0 -436
  69. package/src/List.ts +0 -977
  70. package/src/LogLevel.ts +0 -285
  71. package/src/LogSpan.ts +0 -25
  72. package/src/Logger.ts +0 -702
  73. package/src/Mailbox.ts +0 -268
  74. package/src/ManagedRuntime.ts +0 -180
  75. package/src/Match.ts +0 -1477
  76. package/src/MergeDecision.ts +0 -95
  77. package/src/MergeState.ts +0 -172
  78. package/src/MergeStrategy.ts +0 -107
  79. package/src/Metric.ts +0 -780
  80. package/src/MetricBoundaries.ts +0 -69
  81. package/src/MetricHook.ts +0 -151
  82. package/src/MetricKey.ts +0 -224
  83. package/src/MetricKeyType.ts +0 -262
  84. package/src/MetricLabel.ts +0 -47
  85. package/src/MetricPair.ts +0 -71
  86. package/src/MetricPolling.ts +0 -148
  87. package/src/MetricRegistry.ts +0 -48
  88. package/src/MetricState.ts +0 -257
  89. package/src/Micro.ts +0 -4405
  90. package/src/ModuleVersion.ts +0 -18
  91. package/src/MutableHashMap.ts +0 -411
  92. package/src/MutableHashSet.ts +0 -706
  93. package/src/MutableList.ts +0 -297
  94. package/src/MutableQueue.ts +0 -227
  95. package/src/MutableRef.ts +0 -202
  96. package/src/NonEmptyIterable.ts +0 -32
  97. package/src/Number.ts +0 -1071
  98. package/src/Option.ts +0 -2170
  99. package/src/Order.ts +0 -373
  100. package/src/Ordering.ts +0 -111
  101. package/src/ParseResult.ts +0 -2031
  102. package/src/PartitionedSemaphore.ts +0 -200
  103. package/src/Pipeable.ts +0 -566
  104. package/src/Pool.ts +0 -204
  105. package/src/Predicate.ts +0 -1405
  106. package/src/Pretty.ts +0 -205
  107. package/src/PrimaryKey.ts +0 -23
  108. package/src/PubSub.ts +0 -182
  109. package/src/Queue.ts +0 -644
  110. package/src/Random.ts +0 -204
  111. package/src/RateLimiter.ts +0 -138
  112. package/src/RcMap.ts +0 -141
  113. package/src/RcRef.ts +0 -122
  114. package/src/Readable.ts +0 -93
  115. package/src/Record.ts +0 -1274
  116. package/src/RedBlackTree.ts +0 -421
  117. package/src/Redacted.ts +0 -144
  118. package/src/Ref.ts +0 -180
  119. package/src/RegExp.ts +0 -38
  120. package/src/Reloadable.ts +0 -127
  121. package/src/Request.ts +0 -347
  122. package/src/RequestBlock.ts +0 -118
  123. package/src/RequestResolver.ts +0 -366
  124. package/src/Resource.ts +0 -119
  125. package/src/Runtime.ts +0 -383
  126. package/src/RuntimeFlags.ts +0 -368
  127. package/src/RuntimeFlagsPatch.ts +0 -183
  128. package/src/STM.ts +0 -2045
  129. package/src/Schedule.ts +0 -2219
  130. package/src/ScheduleDecision.ts +0 -62
  131. package/src/ScheduleInterval.ts +0 -151
  132. package/src/ScheduleIntervals.ts +0 -122
  133. package/src/Scheduler.ts +0 -353
  134. package/src/Schema.ts +0 -10914
  135. package/src/SchemaAST.ts +0 -3043
  136. package/src/Scope.ts +0 -204
  137. package/src/ScopedCache.ts +0 -151
  138. package/src/ScopedRef.ts +0 -117
  139. package/src/Secret.ts +0 -88
  140. package/src/SingleProducerAsyncInput.ts +0 -67
  141. package/src/Sink.ts +0 -1461
  142. package/src/SortedMap.ts +0 -287
  143. package/src/SortedSet.ts +0 -390
  144. package/src/Stream.ts +0 -6468
  145. package/src/StreamEmit.ts +0 -136
  146. package/src/StreamHaltStrategy.ts +0 -123
  147. package/src/Streamable.ts +0 -45
  148. package/src/String.ts +0 -778
  149. package/src/Struct.ts +0 -243
  150. package/src/Subscribable.ts +0 -100
  151. package/src/SubscriptionRef.ts +0 -298
  152. package/src/Supervisor.ts +0 -240
  153. package/src/Symbol.ts +0 -29
  154. package/src/SynchronizedRef.ts +0 -270
  155. package/src/TArray.ts +0 -495
  156. package/src/TDeferred.ts +0 -100
  157. package/src/TMap.ts +0 -515
  158. package/src/TPriorityQueue.ts +0 -223
  159. package/src/TPubSub.ts +0 -200
  160. package/src/TQueue.ts +0 -432
  161. package/src/TRandom.ts +0 -129
  162. package/src/TReentrantLock.ts +0 -224
  163. package/src/TRef.ts +0 -178
  164. package/src/TSemaphore.ts +0 -129
  165. package/src/TSet.ts +0 -365
  166. package/src/TSubscriptionRef.ts +0 -192
  167. package/src/Take.ts +0 -258
  168. package/src/TestAnnotation.ts +0 -158
  169. package/src/TestAnnotationMap.ts +0 -119
  170. package/src/TestAnnotations.ts +0 -117
  171. package/src/TestClock.ts +0 -556
  172. package/src/TestConfig.ts +0 -47
  173. package/src/TestContext.ts +0 -36
  174. package/src/TestLive.ts +0 -53
  175. package/src/TestServices.ts +0 -390
  176. package/src/TestSized.ts +0 -55
  177. package/src/Tracer.ts +0 -198
  178. package/src/Trie.ts +0 -840
  179. package/src/Tuple.ts +0 -305
  180. package/src/Types.ts +0 -353
  181. package/src/Unify.ts +0 -113
  182. package/src/UpstreamPullRequest.ts +0 -117
  183. package/src/UpstreamPullStrategy.ts +0 -121
  184. package/src/Utils.ts +0 -809
  185. package/src/index.ts +0 -1561
  186. package/src/internal/array.ts +0 -8
  187. package/src/internal/blockedRequests.ts +0 -520
  188. package/src/internal/cache.ts +0 -733
  189. package/src/internal/cause.ts +0 -1050
  190. package/src/internal/channel/channelExecutor.ts +0 -1200
  191. package/src/internal/channel/channelState.ts +0 -134
  192. package/src/internal/channel/childExecutorDecision.ts +0 -96
  193. package/src/internal/channel/continuation.ts +0 -200
  194. package/src/internal/channel/mergeDecision.ts +0 -113
  195. package/src/internal/channel/mergeState.ts +0 -120
  196. package/src/internal/channel/mergeStrategy.ts +0 -72
  197. package/src/internal/channel/singleProducerAsyncInput.ts +0 -259
  198. package/src/internal/channel/subexecutor.ts +0 -229
  199. package/src/internal/channel/upstreamPullRequest.ts +0 -84
  200. package/src/internal/channel/upstreamPullStrategy.ts +0 -87
  201. package/src/internal/channel.ts +0 -2603
  202. package/src/internal/clock.ts +0 -95
  203. package/src/internal/completedRequestMap.ts +0 -9
  204. package/src/internal/concurrency.ts +0 -54
  205. package/src/internal/config.ts +0 -716
  206. package/src/internal/configError.ts +0 -304
  207. package/src/internal/configProvider/pathPatch.ts +0 -97
  208. package/src/internal/configProvider.ts +0 -799
  209. package/src/internal/console.ts +0 -153
  210. package/src/internal/context.ts +0 -337
  211. package/src/internal/core-effect.ts +0 -2293
  212. package/src/internal/core-stream.ts +0 -998
  213. package/src/internal/core.ts +0 -3273
  214. package/src/internal/data.ts +0 -36
  215. package/src/internal/dataSource.ts +0 -327
  216. package/src/internal/dateTime.ts +0 -1277
  217. package/src/internal/defaultServices/console.ts +0 -100
  218. package/src/internal/defaultServices.ts +0 -163
  219. package/src/internal/deferred.ts +0 -46
  220. package/src/internal/differ/chunkPatch.ts +0 -211
  221. package/src/internal/differ/contextPatch.ts +0 -232
  222. package/src/internal/differ/hashMapPatch.ts +0 -220
  223. package/src/internal/differ/hashSetPatch.ts +0 -176
  224. package/src/internal/differ/orPatch.ts +0 -311
  225. package/src/internal/differ/readonlyArrayPatch.ts +0 -210
  226. package/src/internal/differ.ts +0 -200
  227. package/src/internal/doNotation.ts +0 -80
  228. package/src/internal/effect/circular.ts +0 -905
  229. package/src/internal/effectable.ts +0 -131
  230. package/src/internal/either.ts +0 -110
  231. package/src/internal/encoding/base64.ts +0 -286
  232. package/src/internal/encoding/base64Url.ts +0 -29
  233. package/src/internal/encoding/common.ts +0 -51
  234. package/src/internal/encoding/hex.ts +0 -315
  235. package/src/internal/errors.ts +0 -7
  236. package/src/internal/executionPlan.ts +0 -114
  237. package/src/internal/executionStrategy.ts +0 -74
  238. package/src/internal/fiber.ts +0 -388
  239. package/src/internal/fiberId.ts +0 -267
  240. package/src/internal/fiberMessage.ts +0 -82
  241. package/src/internal/fiberRefs/patch.ts +0 -144
  242. package/src/internal/fiberRefs.ts +0 -297
  243. package/src/internal/fiberRuntime.ts +0 -3915
  244. package/src/internal/fiberScope.ts +0 -71
  245. package/src/internal/fiberStatus.ts +0 -119
  246. package/src/internal/groupBy.ts +0 -530
  247. package/src/internal/hashMap/array.ts +0 -49
  248. package/src/internal/hashMap/bitwise.ts +0 -32
  249. package/src/internal/hashMap/config.ts +0 -14
  250. package/src/internal/hashMap/keySet.ts +0 -8
  251. package/src/internal/hashMap/node.ts +0 -391
  252. package/src/internal/hashMap.ts +0 -586
  253. package/src/internal/hashSet.ts +0 -323
  254. package/src/internal/keyedPool.ts +0 -244
  255. package/src/internal/layer/circular.ts +0 -228
  256. package/src/internal/layer.ts +0 -1487
  257. package/src/internal/logSpan.ts +0 -20
  258. package/src/internal/logger-circular.ts +0 -24
  259. package/src/internal/logger.ts +0 -485
  260. package/src/internal/mailbox.ts +0 -561
  261. package/src/internal/managedRuntime/circular.ts +0 -6
  262. package/src/internal/managedRuntime.ts +0 -134
  263. package/src/internal/matcher.ts +0 -652
  264. package/src/internal/metric/boundaries.ts +0 -75
  265. package/src/internal/metric/hook.ts +0 -483
  266. package/src/internal/metric/key.ts +0 -167
  267. package/src/internal/metric/keyType.ts +0 -238
  268. package/src/internal/metric/label.ts +0 -41
  269. package/src/internal/metric/pair.ts +0 -48
  270. package/src/internal/metric/polling.ts +0 -149
  271. package/src/internal/metric/registry.ts +0 -187
  272. package/src/internal/metric/state.ts +0 -290
  273. package/src/internal/metric.ts +0 -577
  274. package/src/internal/opCodes/cause.ts +0 -35
  275. package/src/internal/opCodes/channel.ts +0 -83
  276. package/src/internal/opCodes/channelChildExecutorDecision.ts +0 -17
  277. package/src/internal/opCodes/channelMergeDecision.ts +0 -11
  278. package/src/internal/opCodes/channelMergeState.ts +0 -17
  279. package/src/internal/opCodes/channelMergeStrategy.ts +0 -11
  280. package/src/internal/opCodes/channelState.ts +0 -23
  281. package/src/internal/opCodes/channelUpstreamPullRequest.ts +0 -11
  282. package/src/internal/opCodes/channelUpstreamPullStrategy.ts +0 -11
  283. package/src/internal/opCodes/config.ts +0 -65
  284. package/src/internal/opCodes/configError.ts +0 -35
  285. package/src/internal/opCodes/continuation.ts +0 -11
  286. package/src/internal/opCodes/deferred.ts +0 -11
  287. package/src/internal/opCodes/effect.ts +0 -89
  288. package/src/internal/opCodes/layer.ts +0 -59
  289. package/src/internal/opCodes/streamHaltStrategy.ts +0 -23
  290. package/src/internal/option.ts +0 -80
  291. package/src/internal/pool.ts +0 -432
  292. package/src/internal/pubsub.ts +0 -1762
  293. package/src/internal/query.ts +0 -204
  294. package/src/internal/queue.ts +0 -766
  295. package/src/internal/random.ts +0 -161
  296. package/src/internal/rateLimiter.ts +0 -93
  297. package/src/internal/rcMap.ts +0 -285
  298. package/src/internal/rcRef.ts +0 -192
  299. package/src/internal/redBlackTree/iterator.ts +0 -200
  300. package/src/internal/redBlackTree/node.ts +0 -68
  301. package/src/internal/redBlackTree.ts +0 -1245
  302. package/src/internal/redacted.ts +0 -73
  303. package/src/internal/ref.ts +0 -171
  304. package/src/internal/reloadable.ts +0 -140
  305. package/src/internal/request.ts +0 -177
  306. package/src/internal/resource.ts +0 -76
  307. package/src/internal/ringBuffer.ts +0 -68
  308. package/src/internal/runtime.ts +0 -558
  309. package/src/internal/runtimeFlags.ts +0 -188
  310. package/src/internal/runtimeFlagsPatch.ts +0 -103
  311. package/src/internal/schedule/decision.ts +0 -47
  312. package/src/internal/schedule/interval.ts +0 -101
  313. package/src/internal/schedule/intervals.ts +0 -180
  314. package/src/internal/schedule.ts +0 -2199
  315. package/src/internal/schema/errors.ts +0 -191
  316. package/src/internal/schema/schemaId.ts +0 -106
  317. package/src/internal/schema/util.ts +0 -50
  318. package/src/internal/scopedCache.ts +0 -644
  319. package/src/internal/scopedRef.ts +0 -118
  320. package/src/internal/secret.ts +0 -89
  321. package/src/internal/singleShotGen.ts +0 -35
  322. package/src/internal/sink.ts +0 -2120
  323. package/src/internal/stack.ts +0 -10
  324. package/src/internal/stm/core.ts +0 -817
  325. package/src/internal/stm/entry.ts +0 -59
  326. package/src/internal/stm/journal.ts +0 -123
  327. package/src/internal/stm/opCodes/stm.ts +0 -71
  328. package/src/internal/stm/opCodes/stmState.ts +0 -17
  329. package/src/internal/stm/opCodes/strategy.ts +0 -17
  330. package/src/internal/stm/opCodes/tExit.ts +0 -29
  331. package/src/internal/stm/opCodes/tryCommit.ts +0 -11
  332. package/src/internal/stm/stm.ts +0 -1453
  333. package/src/internal/stm/stmState.ts +0 -136
  334. package/src/internal/stm/tArray.ts +0 -550
  335. package/src/internal/stm/tDeferred.ts +0 -81
  336. package/src/internal/stm/tExit.ts +0 -190
  337. package/src/internal/stm/tMap.ts +0 -824
  338. package/src/internal/stm/tPriorityQueue.ts +0 -267
  339. package/src/internal/stm/tPubSub.ts +0 -551
  340. package/src/internal/stm/tQueue.ts +0 -393
  341. package/src/internal/stm/tRandom.ts +0 -140
  342. package/src/internal/stm/tReentrantLock.ts +0 -352
  343. package/src/internal/stm/tRef.ts +0 -195
  344. package/src/internal/stm/tSemaphore.ts +0 -113
  345. package/src/internal/stm/tSet.ts +0 -259
  346. package/src/internal/stm/tSubscriptionRef.ts +0 -286
  347. package/src/internal/stm/tryCommit.ts +0 -34
  348. package/src/internal/stm/txnId.ts +0 -14
  349. package/src/internal/stm/versioned.ts +0 -4
  350. package/src/internal/stream/debounceState.ts +0 -57
  351. package/src/internal/stream/emit.ts +0 -123
  352. package/src/internal/stream/haltStrategy.ts +0 -94
  353. package/src/internal/stream/handoff.ts +0 -187
  354. package/src/internal/stream/handoffSignal.ts +0 -59
  355. package/src/internal/stream/pull.ts +0 -34
  356. package/src/internal/stream/sinkEndReason.ts +0 -30
  357. package/src/internal/stream/zipAllState.ts +0 -88
  358. package/src/internal/stream/zipChunksState.ts +0 -56
  359. package/src/internal/stream.ts +0 -8801
  360. package/src/internal/string-utils.ts +0 -107
  361. package/src/internal/subscriptionRef.ts +0 -138
  362. package/src/internal/supervisor/patch.ts +0 -190
  363. package/src/internal/supervisor.ts +0 -303
  364. package/src/internal/synchronizedRef.ts +0 -114
  365. package/src/internal/take.ts +0 -199
  366. package/src/internal/testing/sleep.ts +0 -27
  367. package/src/internal/testing/suspendedWarningData.ts +0 -85
  368. package/src/internal/testing/warningData.ts +0 -94
  369. package/src/internal/tracer.ts +0 -293
  370. package/src/internal/trie.ts +0 -722
  371. package/src/internal/version.ts +0 -7
package/src/Layer.ts DELETED
@@ -1,1251 +0,0 @@
1
- /**
2
- * A `Layer<ROut, E, RIn>` describes how to build one or more services in your
3
- * application. Services can be injected into effects via
4
- * `Effect.provideService`. Effects can require services via `Effect.service`.
5
- *
6
- * Layer can be thought of as recipes for producing bundles of services, given
7
- * their dependencies (other services).
8
- *
9
- * Construction of services can be effectful and utilize resources that must be
10
- * acquired and safely released when the services are done being utilized.
11
- *
12
- * By default layers are shared, meaning that if the same layer is used twice
13
- * the layer will only be allocated a single time.
14
- *
15
- * Because of their excellent composition properties, layers are the idiomatic
16
- * way in Effect-TS to create services that depend on other services.
17
- *
18
- * @since 2.0.0
19
- */
20
- import type * as Cause from "./Cause.js"
21
- import type * as Clock from "./Clock.js"
22
- import type { ConfigProvider } from "./ConfigProvider.js"
23
- import * as Context from "./Context.js"
24
- import type * as Effect from "./Effect.js"
25
- import type * as Exit from "./Exit.js"
26
- import type { FiberRef } from "./FiberRef.js"
27
- import { dual, type LazyArg } from "./Function.js"
28
- import { clockTag } from "./internal/clock.js"
29
- import * as core from "./internal/core.js"
30
- import * as defaultServices from "./internal/defaultServices.js"
31
- import * as fiberRuntime from "./internal/fiberRuntime.js"
32
- import * as internal from "./internal/layer.js"
33
- import * as circularLayer from "./internal/layer/circular.js"
34
- import * as query from "./internal/query.js"
35
- import { randomTag } from "./internal/random.js"
36
- import type { LogLevel } from "./LogLevel.js"
37
- import type * as Option from "./Option.js"
38
- import type { Pipeable } from "./Pipeable.js"
39
- import type * as Random from "./Random.js"
40
- import type * as Request from "./Request.js"
41
- import type * as Runtime from "./Runtime.js"
42
- import type * as Schedule from "./Schedule.js"
43
- import * as Scheduler from "./Scheduler.js"
44
- import type * as Scope from "./Scope.js"
45
- import type * as Stream from "./Stream.js"
46
- import type * as Tracer from "./Tracer.js"
47
- import type * as Types from "./Types.js"
48
-
49
- /**
50
- * @since 2.0.0
51
- * @category symbols
52
- */
53
- export const LayerTypeId: unique symbol = internal.LayerTypeId
54
-
55
- /**
56
- * @since 2.0.0
57
- * @category symbols
58
- */
59
- export type LayerTypeId = typeof LayerTypeId
60
-
61
- /**
62
- * @since 2.0.0
63
- * @category models
64
- */
65
- export interface Layer<in ROut, out E = never, out RIn = never> extends Layer.Variance<ROut, E, RIn>, Pipeable {}
66
-
67
- /**
68
- * @since 2.0.0
69
- */
70
- export declare namespace Layer {
71
- /**
72
- * @since 2.0.0
73
- * @category models
74
- */
75
- export interface Variance<in ROut, out E, out RIn> {
76
- readonly [LayerTypeId]: {
77
- readonly _ROut: Types.Contravariant<ROut>
78
- readonly _E: Types.Covariant<E>
79
- readonly _RIn: Types.Covariant<RIn>
80
- }
81
- }
82
- /**
83
- * @since 3.9.0
84
- * @category type-level
85
- */
86
- export interface Any {
87
- readonly [LayerTypeId]: {
88
- readonly _ROut: Types.Contravariant<never>
89
- readonly _E: Types.Covariant<any>
90
- readonly _RIn: Types.Covariant<any>
91
- }
92
- }
93
- /**
94
- * @since 2.0.0
95
- * @category type-level
96
- */
97
- export type Context<T extends Any> = [T] extends [Layer<infer _ROut, infer _E, infer _RIn>] ? _RIn
98
- : never
99
- /**
100
- * @since 2.0.0
101
- * @category type-level
102
- */
103
- export type Error<T extends Any> = [T] extends [Layer<infer _ROut, infer _E, infer _RIn>] ? _E
104
- : never
105
- /**
106
- * @since 2.0.0
107
- * @category type-level
108
- */
109
- export type Success<T extends Any> = [T] extends [Layer<infer _ROut, infer _E, infer _RIn>] ? _ROut
110
- : never
111
- }
112
-
113
- /**
114
- * @since 2.0.0
115
- * @category symbols
116
- */
117
- export const MemoMapTypeId: unique symbol = internal.MemoMapTypeId
118
-
119
- /**
120
- * @since 2.0.0
121
- * @category symbols
122
- */
123
- export type MemoMapTypeId = typeof MemoMapTypeId
124
-
125
- /**
126
- * @since 2.0.0
127
- * @category models
128
- */
129
- export interface MemoMap {
130
- readonly [MemoMapTypeId]: MemoMapTypeId
131
-
132
- /** @internal */
133
- readonly getOrElseMemoize: <RIn, E, ROut>(
134
- layer: Layer<ROut, E, RIn>,
135
- scope: Scope.Scope
136
- ) => Effect.Effect<Context.Context<ROut>, E, RIn>
137
- }
138
-
139
- /**
140
- * @since 3.13.0
141
- * @category models
142
- */
143
- export interface CurrentMemoMap {
144
- readonly _: unique symbol
145
- }
146
-
147
- /**
148
- * @since 3.13.0
149
- * @category models
150
- */
151
- export const CurrentMemoMap: Context.Reference<CurrentMemoMap, MemoMap> = internal.CurrentMemoMap
152
-
153
- /**
154
- * Returns `true` if the specified value is a `Layer`, `false` otherwise.
155
- *
156
- * @since 2.0.0
157
- * @category getters
158
- */
159
- export const isLayer: (u: unknown) => u is Layer<unknown, unknown, unknown> = internal.isLayer
160
-
161
- /**
162
- * Returns `true` if the specified `Layer` is a fresh version that will not be
163
- * shared, `false` otherwise.
164
- *
165
- * @since 2.0.0
166
- * @category getters
167
- */
168
- export const isFresh: <RIn, E, ROut>(self: Layer<ROut, E, RIn>) => boolean = internal.isFresh
169
-
170
- /**
171
- * @since 3.3.0
172
- * @category tracing
173
- */
174
- export const annotateLogs: {
175
- (key: string, value: unknown): <A, E, R>(self: Layer<A, E, R>) => Layer<A, E, R>
176
- (values: Record<string, unknown>): <A, E, R>(self: Layer<A, E, R>) => Layer<A, E, R>
177
- <A, E, R>(self: Layer<A, E, R>, key: string, value: unknown): Layer<A, E, R>
178
- <A, E, R>(self: Layer<A, E, R>, values: Record<string, unknown>): Layer<A, E, R>
179
- } = internal.annotateLogs
180
-
181
- /**
182
- * @since 3.3.0
183
- * @category tracing
184
- */
185
- export const annotateSpans: {
186
- (key: string, value: unknown): <A, E, R>(self: Layer<A, E, R>) => Layer<A, E, R>
187
- (values: Record<string, unknown>): <A, E, R>(self: Layer<A, E, R>) => Layer<A, E, R>
188
- <A, E, R>(self: Layer<A, E, R>, key: string, value: unknown): Layer<A, E, R>
189
- <A, E, R>(self: Layer<A, E, R>, values: Record<string, unknown>): Layer<A, E, R>
190
- } = internal.annotateSpans
191
-
192
- /**
193
- * Builds a layer into a scoped value.
194
- *
195
- * @since 2.0.0
196
- * @category destructors
197
- */
198
- export const build: <RIn, E, ROut>(
199
- self: Layer<ROut, E, RIn>
200
- ) => Effect.Effect<Context.Context<ROut>, E, Scope.Scope | RIn> = internal.build
201
-
202
- /**
203
- * Builds a layer into an `Effect` value. Any resources associated with this
204
- * layer will be released when the specified scope is closed unless their scope
205
- * has been extended. This allows building layers where the lifetime of some of
206
- * the services output by the layer exceed the lifetime of the effect the
207
- * layer is provided to.
208
- *
209
- * @since 2.0.0
210
- * @category destructors
211
- */
212
- export const buildWithScope: {
213
- (scope: Scope.Scope): <RIn, E, ROut>(self: Layer<ROut, E, RIn>) => Effect.Effect<Context.Context<ROut>, E, RIn>
214
- <RIn, E, ROut>(self: Layer<ROut, E, RIn>, scope: Scope.Scope): Effect.Effect<Context.Context<ROut>, E, RIn>
215
- } = internal.buildWithScope
216
-
217
- /**
218
- * Recovers from all errors.
219
- *
220
- * @since 2.0.0
221
- * @category error handling
222
- */
223
- export const catchAll: {
224
- <E, RIn2, E2, ROut2>(
225
- onError: (error: E) => Layer<ROut2, E2, RIn2>
226
- ): <RIn, ROut>(self: Layer<ROut, E, RIn>) => Layer<ROut & ROut2, E2, RIn2 | RIn>
227
- <RIn, E, ROut, RIn2, E2, ROut2>(
228
- self: Layer<ROut, E, RIn>,
229
- onError: (error: E) => Layer<ROut2, E2, RIn2>
230
- ): Layer<ROut & ROut2, E2, RIn | RIn2>
231
- } = internal.catchAll
232
-
233
- /**
234
- * Recovers from all errors.
235
- *
236
- * @since 2.0.0
237
- * @category error handling
238
- */
239
- export const catchAllCause: {
240
- <E, RIn2, E2, ROut2>(
241
- onError: (cause: Cause.Cause<E>) => Layer<ROut2, E2, RIn2>
242
- ): <RIn, ROut>(self: Layer<ROut, E, RIn>) => Layer<ROut & ROut2, E2, RIn2 | RIn>
243
- <RIn, E, ROut, RIn2, E2, ROut22>(
244
- self: Layer<ROut, E, RIn>,
245
- onError: (cause: Cause.Cause<E>) => Layer<ROut22, E2, RIn2>
246
- ): Layer<ROut & ROut22, E2, RIn | RIn2>
247
- } = internal.catchAllCause
248
-
249
- /**
250
- * Constructs a `Layer` that passes along the specified context as an
251
- * output.
252
- *
253
- * @since 2.0.0
254
- * @category constructors
255
- */
256
- export const context: <R>() => Layer<R, never, R> = internal.context
257
-
258
- /**
259
- * Constructs a layer that dies with the specified defect.
260
- *
261
- * @since 2.0.0
262
- * @category constructors
263
- */
264
- export const die: (defect: unknown) => Layer<unknown> = internal.die
265
-
266
- /**
267
- * Constructs a layer that dies with the specified defect.
268
- *
269
- * @since 2.0.0
270
- * @category constructors
271
- */
272
- export const dieSync: (evaluate: LazyArg<unknown>) => Layer<unknown> = internal.dieSync
273
-
274
- /**
275
- * Replaces the layer's output with `never` and includes the layer only for its
276
- * side-effects.
277
- *
278
- * @since 2.0.0
279
- * @category mapping
280
- */
281
- export const discard: <RIn, E, ROut>(self: Layer<ROut, E, RIn>) => Layer<never, E, RIn> = internal.discard
282
-
283
- /**
284
- * Constructs a layer from the specified effect.
285
- *
286
- * @since 2.0.0
287
- * @category constructors
288
- */
289
- export const effect: {
290
- <I, S>(tag: Context.Tag<I, S>): <E, R>(effect: Effect.Effect<Types.NoInfer<S>, E, R>) => Layer<I, E, R>
291
- <I, S, E, R>(tag: Context.Tag<I, S>, effect: Effect.Effect<Types.NoInfer<S>, E, R>): Layer<I, E, R>
292
- } = internal.fromEffect
293
-
294
- /**
295
- * Constructs a layer from the specified effect, discarding its output.
296
- *
297
- * @since 2.0.0
298
- * @category constructors
299
- */
300
- export const effectDiscard: <X, E, R>(effect: Effect.Effect<X, E, R>) => Layer<never, E, R> = internal.fromEffectDiscard
301
-
302
- /**
303
- * Constructs a layer from the specified effect, which must return one or more
304
- * services.
305
- *
306
- * @since 2.0.0
307
- * @category constructors
308
- */
309
- export const effectContext: <A, E, R>(effect: Effect.Effect<Context.Context<A>, E, R>) => Layer<A, E, R> =
310
- internal.fromEffectContext
311
-
312
- /**
313
- * A Layer that constructs an empty Context.
314
- *
315
- * @since 2.0.0
316
- * @category constructors
317
- */
318
- export const empty: Layer<never> = internal.empty
319
-
320
- /**
321
- * Extends the scope of this layer, returning a new layer that when provided
322
- * to an effect will not immediately release its associated resources when
323
- * that effect completes execution but instead when the scope the resulting
324
- * effect depends on is closed.
325
- *
326
- * @since 2.0.0
327
- * @category utils
328
- */
329
- export const extendScope: <RIn, E, ROut>(self: Layer<ROut, E, RIn>) => Layer<ROut, E, Scope.Scope | RIn> =
330
- internal.extendScope
331
-
332
- /**
333
- * Constructs a layer that fails with the specified error.
334
- *
335
- * @since 2.0.0
336
- * @category constructors
337
- */
338
- export const fail: <E>(error: E) => Layer<unknown, E> = internal.fail
339
-
340
- /**
341
- * Constructs a layer that fails with the specified error.
342
- *
343
- * @since 2.0.0
344
- * @category constructors
345
- */
346
- export const failSync: <E>(evaluate: LazyArg<E>) => Layer<unknown, E> = internal.failSync
347
-
348
- /**
349
- * Constructs a layer that fails with the specified cause.
350
- *
351
- * @since 2.0.0
352
- * @category constructors
353
- */
354
- export const failCause: <E>(cause: Cause.Cause<E>) => Layer<unknown, E> = internal.failCause
355
-
356
- /**
357
- * Constructs a layer that fails with the specified cause.
358
- *
359
- * @since 2.0.0
360
- * @category constructors
361
- */
362
- export const failCauseSync: <E>(evaluate: LazyArg<Cause.Cause<E>>) => Layer<unknown, E> = internal.failCauseSync
363
-
364
- /**
365
- * Constructs a layer dynamically based on the output of this layer.
366
- *
367
- * @since 2.0.0
368
- * @category sequencing
369
- */
370
- export const flatMap: {
371
- <A, A2, E2, R2>(
372
- f: (context: Context.Context<A>) => Layer<A2, E2, R2>
373
- ): <E, R>(self: Layer<A, E, R>) => Layer<A2, E2 | E, R2 | R>
374
- <A, E, R, A2, E2, R2>(
375
- self: Layer<A, E, R>,
376
- f: (context: Context.Context<A>) => Layer<A2, E2, R2>
377
- ): Layer<A2, E | E2, R | R2>
378
- } = internal.flatMap
379
-
380
- /**
381
- * Flattens layers nested in the context of an effect.
382
- *
383
- * @since 2.0.0
384
- * @category sequencing
385
- */
386
- export const flatten: {
387
- <I, A, E2, R2>(tag: Context.Tag<I, Layer<A, E2, R2>>): <E, R>(self: Layer<I, E, R>) => Layer<A, E2 | E, R2 | R>
388
- <I, E, R, A, E2, R2>(self: Layer<I, E, R>, tag: Context.Tag<I, Layer<A, E2, R2>>): Layer<A, E | E2, R | R2>
389
- } = internal.flatten
390
-
391
- /**
392
- * Creates a fresh version of this layer that will not be shared.
393
- *
394
- * @since 2.0.0
395
- * @category utils
396
- */
397
- export const fresh: <A, E, R>(self: Layer<A, E, R>) => Layer<A, E, R> = internal.fresh
398
-
399
- /**
400
- * @since 3.17.0
401
- * @category Testing
402
- */
403
- export type PartialEffectful<A extends object> = Types.Simplify<
404
- & {
405
- [
406
- K in keyof A as A[K] extends
407
- | Effect.Effect<any, any, any>
408
- | Stream.Stream<any, any, any>
409
- | ((...args: any) => Effect.Effect<any, any, any> | Stream.Stream<any, any, any>) ? K
410
- : never
411
- ]?: A[K]
412
- }
413
- & {
414
- [
415
- K in keyof A as A[K] extends
416
- | Effect.Effect<any, any, any>
417
- | Stream.Stream<any, any, any>
418
- | ((...args: any) => Effect.Effect<any, any, any> | Stream.Stream<any, any, any>) ? never
419
- : K
420
- ]: A[K]
421
- }
422
- >
423
-
424
- /**
425
- * Creates a mock layer for testing purposes. You can provide a partial
426
- * implementation of the service, and any methods not provided will
427
- * throw an `UnimplementedError` defect when called.
428
- *
429
- * **Example**
430
- *
431
- * ```ts
432
- * import { Context, Effect, Layer } from "effect"
433
- *
434
- * class MyService extends Context.Tag("MyService")<
435
- * MyService,
436
- * {
437
- * one: Effect.Effect<number>
438
- * two(): Effect.Effect<number>
439
- * }
440
- * >() {}
441
- *
442
- * const MyServiceTest = Layer.mock(MyService, {
443
- * two: () => Effect.succeed(2)
444
- * })
445
- * ```
446
- *
447
- * @since 3.17.0
448
- * @category Testing
449
- */
450
- export const mock: {
451
- <I, S extends object>(tag: Context.Tag<I, S>): (service: PartialEffectful<S>) => Layer<I>
452
- <I, S extends object>(tag: Context.Tag<I, S>, service: PartialEffectful<S>): Layer<I>
453
- } = internal.mock
454
-
455
- const fromFunction: <I1, S1, I2, S2>(
456
- tagA: Context.Tag<I1, S1>,
457
- tagB: Context.Tag<I2, S2>,
458
- f: (a: Types.NoInfer<S1>) => Types.NoInfer<S2>
459
- ) => Layer<I2, never, I1> = internal.fromFunction
460
-
461
- export {
462
- /**
463
- * Constructs a layer from the context using the specified function.
464
- *
465
- * @since 2.0.0
466
- * @category constructors
467
- */
468
- fromFunction as function
469
- }
470
-
471
- /**
472
- * Builds this layer and uses it until it is interrupted. This is useful when
473
- * your entire application is a layer, such as an HTTP server.
474
- *
475
- * @since 2.0.0
476
- * @category conversions
477
- */
478
- export const launch: <RIn, E, ROut>(self: Layer<ROut, E, RIn>) => Effect.Effect<never, E, RIn> = internal.launch
479
-
480
- /**
481
- * Returns a new layer whose output is mapped by the specified function.
482
- *
483
- * @since 2.0.0
484
- * @category mapping
485
- */
486
- export const map: {
487
- <A, B>(f: (context: Context.Context<A>) => Context.Context<B>): <E, R>(self: Layer<A, E, R>) => Layer<B, E, R>
488
- <A, E, R, B>(self: Layer<A, E, R>, f: (context: Context.Context<A>) => Context.Context<B>): Layer<B, E, R>
489
- } = internal.map
490
-
491
- /**
492
- * Returns a layer with its error channel mapped using the specified function.
493
- *
494
- * @since 2.0.0
495
- * @category mapping
496
- */
497
- export const mapError: {
498
- <E, E2>(f: (error: E) => E2): <A, R>(self: Layer<A, E, R>) => Layer<A, E2, R>
499
- <A, E, R, E2>(self: Layer<A, E, R>, f: (error: E) => E2): Layer<A, E2, R>
500
- } = internal.mapError
501
-
502
- /**
503
- * Feeds the error or output services of this layer into the input of either
504
- * the specified `failure` or `success` layers, resulting in a new layer with
505
- * the inputs of this layer, and the error or outputs of the specified layer.
506
- *
507
- * @since 2.0.0
508
- * @category folding
509
- */
510
- export const match: {
511
- <E, A2, E2, R2, A, A3, E3, R3>(
512
- options: {
513
- readonly onFailure: (error: E) => Layer<A2, E2, R2>
514
- readonly onSuccess: (context: Context.Context<A>) => Layer<A3, E3, R3>
515
- }
516
- ): <R>(self: Layer<A, E, R>) => Layer<A2 & A3, E2 | E3, R2 | R3 | R>
517
- <A, E, R, A2, E2, R2, A3, E3, R3>(
518
- self: Layer<A, E, R>,
519
- options: {
520
- readonly onFailure: (error: E) => Layer<A2, E2, R2>
521
- readonly onSuccess: (context: Context.Context<A>) => Layer<A3, E3, R3>
522
- }
523
- ): Layer<A2 & A3, E2 | E3, R | R2 | R3>
524
- } = internal.match
525
-
526
- /**
527
- * Feeds the error or output services of this layer into the input of either
528
- * the specified `failure` or `success` layers, resulting in a new layer with
529
- * the inputs of this layer, and the error or outputs of the specified layer.
530
- *
531
- * @since 2.0.0
532
- * @category folding
533
- */
534
- export const matchCause: {
535
- <E, A2, E2, R2, A, A3, E3, R3>(
536
- options: {
537
- readonly onFailure: (cause: Cause.Cause<E>) => Layer<A2, E2, R2>
538
- readonly onSuccess: (context: Context.Context<A>) => Layer<A3, E3, R3>
539
- }
540
- ): <R>(self: Layer<A, E, R>) => Layer<A2 & A3, E2 | E3, R2 | R3 | R>
541
- <A, E, R, A2, E2, R2, A3, E3, R3>(
542
- self: Layer<A, E, R>,
543
- options: {
544
- readonly onFailure: (cause: Cause.Cause<E>) => Layer<A2, E2, R2>
545
- readonly onSuccess: (context: Context.Context<A>) => Layer<A3, E3, R3>
546
- }
547
- ): Layer<A2 & A3, E2 | E3, R | R2 | R3>
548
- } = internal.matchCause
549
-
550
- /**
551
- * Returns a scoped effect that, if evaluated, will return the lazily computed
552
- * result of this layer.
553
- *
554
- * @since 2.0.0
555
- * @category utils
556
- */
557
- export const memoize: <RIn, E, ROut>(
558
- self: Layer<ROut, E, RIn>
559
- ) => Effect.Effect<Layer<ROut, E, RIn>, never, Scope.Scope> = internal.memoize
560
-
561
- /**
562
- * Merges this layer with the specified layer concurrently, producing a new layer with combined input and output types.
563
- *
564
- * @since 2.0.0
565
- * @category zipping
566
- */
567
- export const merge: {
568
- <RIn2, E2, ROut2>(
569
- that: Layer<ROut2, E2, RIn2>
570
- ): <RIn, E1, ROut>(self: Layer<ROut, E1, RIn>) => Layer<ROut2 | ROut, E2 | E1, RIn2 | RIn>
571
- <RIn, E1, ROut, RIn2, E2, ROut2>(
572
- self: Layer<ROut, E1, RIn>,
573
- that: Layer<ROut2, E2, RIn2>
574
- ): Layer<ROut | ROut2, E1 | E2, RIn | RIn2>
575
- } = internal.merge
576
-
577
- /**
578
- * Combines all the provided layers concurrently, creating a new layer with merged input, error, and output types.
579
- *
580
- * @since 2.0.0
581
- * @category zipping
582
- */
583
- export const mergeAll: <Layers extends readonly [Layer<never, any, any>, ...Array<Layer<never, any, any>>]>(
584
- ...layers: Layers
585
- ) => Layer<
586
- { [k in keyof Layers]: Layer.Success<Layers[k]> }[number],
587
- { [k in keyof Layers]: Layer.Error<Layers[k]> }[number],
588
- { [k in keyof Layers]: Layer.Context<Layers[k]> }[number]
589
- > = internal.mergeAll
590
-
591
- /**
592
- * Translates effect failure into death of the fiber, making all failures
593
- * unchecked and not a part of the type of the layer.
594
- *
595
- * @since 2.0.0
596
- * @category error handling
597
- */
598
- export const orDie: <A, E, R>(self: Layer<A, E, R>) => Layer<A, never, R> = internal.orDie
599
-
600
- /**
601
- * Executes this layer and returns its output, if it succeeds, but otherwise
602
- * executes the specified layer.
603
- *
604
- * @since 2.0.0
605
- * @category error handling
606
- */
607
- export const orElse: {
608
- <A2, E2, R2>(that: LazyArg<Layer<A2, E2, R2>>): <A, E, R>(self: Layer<A, E, R>) => Layer<A & A2, E2 | E, R2 | R>
609
- <A, E, R, A2, E2, R2>(self: Layer<A, E, R>, that: LazyArg<Layer<A2, E2, R2>>): Layer<A & A2, E | E2, R | R2>
610
- } = internal.orElse
611
-
612
- /**
613
- * Returns a new layer that produces the outputs of this layer but also
614
- * passes through the inputs.
615
- *
616
- * @since 2.0.0
617
- * @category utils
618
- */
619
- export const passthrough: <RIn, E, ROut>(self: Layer<ROut, E, RIn>) => Layer<RIn | ROut, E, RIn> = internal.passthrough
620
-
621
- /**
622
- * Projects out part of one of the services output by this layer using the
623
- * specified function.
624
- *
625
- * @since 2.0.0
626
- * @category utils
627
- */
628
- export const project: {
629
- <I1, S1, I2, S2>(
630
- tagA: Context.Tag<I1, S1>,
631
- tagB: Context.Tag<I2, S2>,
632
- f: (a: Types.NoInfer<S1>) => Types.NoInfer<S2>
633
- ): <RIn, E>(self: Layer<I1, E, RIn>) => Layer<I2, E, RIn>
634
- <RIn, E, I1, S1, I2, S2>(
635
- self: Layer<I1, E, RIn>,
636
- tagA: Context.Tag<I1, S1>,
637
- tagB: Context.Tag<I2, S2>,
638
- f: (a: Types.NoInfer<S1>) => Types.NoInfer<S2>
639
- ): Layer<I2, E, RIn>
640
- } = internal.project
641
-
642
- /**
643
- * @since 2.0.0
644
- * @category utils
645
- */
646
- export const locallyEffect: {
647
- <RIn, E, ROut, RIn2, E2, ROut2>(
648
- f: (_: Effect.Effect<RIn, E, Context.Context<ROut>>) => Effect.Effect<RIn2, E2, Context.Context<ROut2>>
649
- ): (self: Layer<ROut, E, RIn>) => Layer<ROut2, E2, RIn2>
650
- <RIn, E, ROut, RIn2, E2, ROut2>(
651
- self: Layer<ROut, E, RIn>,
652
- f: (_: Effect.Effect<RIn, E, Context.Context<ROut>>) => Effect.Effect<RIn2, E2, Context.Context<ROut2>>
653
- ): Layer<ROut2, E2, RIn2>
654
- } = internal.locallyEffect
655
-
656
- /**
657
- * @since 2.0.0
658
- * @category utils
659
- */
660
- export const locally: {
661
- <X>(
662
- ref: FiberRef<X>,
663
- value: X
664
- ): <A, E, R>(self: Layer<A, E, R>) => Layer<A, E, R>
665
- <A, E, R, X>(
666
- self: Layer<A, E, R>,
667
- ref: FiberRef<X>,
668
- value: X
669
- ): Layer<A, E, R>
670
- } = internal.fiberRefLocally
671
-
672
- /**
673
- * @since 2.0.0
674
- * @category utils
675
- */
676
- export const locallyWith: {
677
- <X>(ref: FiberRef<X>, value: (_: X) => X): <A, E, R>(self: Layer<A, E, R>) => Layer<A, E, R>
678
- <A, E, R, X>(self: Layer<A, E, R>, ref: FiberRef<X>, value: (_: X) => X): Layer<A, E, R>
679
- } = internal.fiberRefLocallyWith
680
-
681
- /**
682
- * @since 2.0.0
683
- * @category utils
684
- */
685
- export const locallyScoped: <A>(self: FiberRef<A>, value: A) => Layer<never> = internal.fiberRefLocallyScoped
686
-
687
- /**
688
- * @since 2.0.0
689
- * @category utils
690
- */
691
- export const fiberRefLocallyScopedWith: <A>(self: FiberRef<A>, value: (_: A) => A) => Layer<never> =
692
- internal.fiberRefLocallyScopedWith
693
-
694
- /**
695
- * Retries constructing this layer according to the specified schedule.
696
- *
697
- * @since 2.0.0
698
- * @category retrying
699
- */
700
- export const retry: {
701
- <X, E, RIn2>(
702
- schedule: Schedule.Schedule<X, NoInfer<E>, RIn2>
703
- ): <ROut, RIn>(self: Layer<ROut, E, RIn>) => Layer<ROut, E, RIn2 | RIn>
704
- <ROut, E, RIn, X, RIn2>(
705
- self: Layer<ROut, E, RIn>,
706
- schedule: Schedule.Schedule<X, E, RIn2>
707
- ): Layer<ROut, E, RIn | RIn2>
708
- } = internal.retry
709
-
710
- /**
711
- * A layer that constructs a scope and closes it when the workflow the layer
712
- * is provided to completes execution, whether by success, failure, or
713
- * interruption. This can be used to close a scope when providing a layer to a
714
- * workflow.
715
- *
716
- * @since 2.0.0
717
- * @category constructors
718
- */
719
- export const scope: Layer<Scope.Scope> = internal.scope
720
-
721
- /**
722
- * Constructs a layer from the specified scoped effect.
723
- *
724
- * @since 2.0.0
725
- * @category constructors
726
- */
727
- export const scoped: {
728
- <I, S>(
729
- tag: Context.Tag<I, S>
730
- ): <E, R>(effect: Effect.Effect<Types.NoInfer<S>, E, R>) => Layer<I, E, Exclude<R, Scope.Scope>>
731
- <I, S, E, R>(
732
- tag: Context.Tag<I, S>,
733
- effect: Effect.Effect<Types.NoInfer<S>, E, R>
734
- ): Layer<I, E, Exclude<R, Scope.Scope>>
735
- } = internal.scoped
736
-
737
- /**
738
- * Constructs a layer from the specified scoped effect.
739
- *
740
- * @since 2.0.0
741
- * @category constructors
742
- */
743
- export const scopedDiscard: <X, E, R>(effect: Effect.Effect<X, E, R>) => Layer<never, E, Exclude<R, Scope.Scope>> =
744
- internal.scopedDiscard
745
-
746
- /**
747
- * Constructs a layer from the specified scoped effect, which must return one
748
- * or more services.
749
- *
750
- * @since 2.0.0
751
- * @category constructors
752
- */
753
- export const scopedContext: <A, E, R>(
754
- effect: Effect.Effect<Context.Context<A>, E, R>
755
- ) => Layer<A, E, Exclude<R, Scope.Scope>> = internal.scopedContext
756
-
757
- /**
758
- * Constructs a layer that accesses and returns the specified service from the
759
- * context.
760
- *
761
- * @since 2.0.0
762
- * @category constructors
763
- */
764
- export const service: <I, S>(tag: Context.Tag<I, S>) => Layer<I, never, I> = internal.service
765
-
766
- /**
767
- * Constructs a layer from the specified value.
768
- *
769
- * @since 2.0.0
770
- * @category constructors
771
- */
772
- export const succeed: {
773
- <I, S>(tag: Context.Tag<I, S>): (resource: Types.NoInfer<S>) => Layer<I>
774
- <I, S>(tag: Context.Tag<I, S>, resource: Types.NoInfer<S>): Layer<I>
775
- } = internal.succeed
776
-
777
- /**
778
- * Constructs a layer from the specified value, which must return one or more
779
- * services.
780
- *
781
- * @since 2.0.0
782
- * @category constructors
783
- */
784
- export const succeedContext: <A>(context: Context.Context<A>) => Layer<A> = internal.succeedContext
785
-
786
- /**
787
- * Lazily constructs a layer. This is useful to avoid infinite recursion when
788
- * creating layers that refer to themselves.
789
- *
790
- * @since 2.0.0
791
- * @category constructors
792
- */
793
- export const suspend: <RIn, E, ROut>(evaluate: LazyArg<Layer<ROut, E, RIn>>) => Layer<ROut, E, RIn> = internal.suspend
794
-
795
- /**
796
- * Lazily constructs a layer from the specified value.
797
- *
798
- * @since 2.0.0
799
- * @category constructors
800
- */
801
- export const sync: {
802
- <I, S>(tag: Context.Tag<I, S>): (evaluate: LazyArg<Types.NoInfer<S>>) => Layer<I>
803
- <I, S>(tag: Context.Tag<I, S>, evaluate: LazyArg<Types.NoInfer<S>>): Layer<I>
804
- } = internal.sync
805
-
806
- /**
807
- * Lazily constructs a layer from the specified value, which must return one or more
808
- * services.
809
- *
810
- * @since 2.0.0
811
- * @category constructors
812
- */
813
- export const syncContext: <A>(evaluate: LazyArg<Context.Context<A>>) => Layer<A> = internal.syncContext
814
-
815
- /**
816
- * Performs the specified effect if this layer succeeds.
817
- *
818
- * @since 2.0.0
819
- * @category sequencing
820
- */
821
- export const tap: {
822
- <ROut, XR extends ROut, RIn2, E2, X>(
823
- f: (context: Context.Context<XR>) => Effect.Effect<X, E2, RIn2>
824
- ): <RIn, E>(self: Layer<ROut, E, RIn>) => Layer<ROut, E2 | E, RIn2 | RIn>
825
- <RIn, E, ROut, XR extends ROut, RIn2, E2, X>(
826
- self: Layer<ROut, E, RIn>,
827
- f: (context: Context.Context<XR>) => Effect.Effect<X, E2, RIn2>
828
- ): Layer<ROut, E | E2, RIn | RIn2>
829
- } = internal.tap
830
-
831
- /**
832
- * Performs the specified effect if this layer fails.
833
- *
834
- * @since 2.0.0
835
- * @category sequencing
836
- */
837
- export const tapError: {
838
- <E, XE extends E, RIn2, E2, X>(
839
- f: (e: XE) => Effect.Effect<X, E2, RIn2>
840
- ): <RIn, ROut>(self: Layer<ROut, E, RIn>) => Layer<ROut, E | E2, RIn2 | RIn>
841
- <RIn, E, XE extends E, ROut, RIn2, E2, X>(
842
- self: Layer<ROut, E, RIn>,
843
- f: (e: XE) => Effect.Effect<X, E2, RIn2>
844
- ): Layer<ROut, E | E2, RIn | RIn2>
845
- } = internal.tapError
846
-
847
- /**
848
- * Performs the specified effect if this layer fails.
849
- *
850
- * @since 2.0.0
851
- * @category sequencing
852
- */
853
- export const tapErrorCause: {
854
- <E, XE extends E, RIn2, E2, X>(
855
- f: (cause: Cause.Cause<XE>) => Effect.Effect<X, E2, RIn2>
856
- ): <RIn, ROut>(self: Layer<ROut, E, RIn>) => Layer<ROut, E | E2, RIn2 | RIn>
857
- <RIn, E, XE extends E, ROut, RIn2, E2, X>(
858
- self: Layer<ROut, E, RIn>,
859
- f: (cause: Cause.Cause<XE>) => Effect.Effect<X, E2, RIn2>
860
- ): Layer<ROut, E | E2, RIn | RIn2>
861
- } = internal.tapErrorCause
862
-
863
- /**
864
- * Converts a layer that requires no services into a scoped runtime, which can
865
- * be used to execute effects.
866
- *
867
- * @since 2.0.0
868
- * @category conversions
869
- */
870
- export const toRuntime: <RIn, E, ROut>(
871
- self: Layer<ROut, E, RIn>
872
- ) => Effect.Effect<Runtime.Runtime<ROut>, E, Scope.Scope | RIn> = internal.toRuntime
873
-
874
- /**
875
- * Converts a layer that requires no services into a scoped runtime, which can
876
- * be used to execute effects.
877
- *
878
- * @since 2.0.0
879
- * @category conversions
880
- */
881
- export const toRuntimeWithMemoMap: {
882
- (
883
- memoMap: MemoMap
884
- ): <RIn, E, ROut>(self: Layer<ROut, E, RIn>) => Effect.Effect<Runtime.Runtime<ROut>, E, Scope.Scope | RIn>
885
- <RIn, E, ROut>(
886
- self: Layer<ROut, E, RIn>,
887
- memoMap: MemoMap
888
- ): Effect.Effect<Runtime.Runtime<ROut>, E, Scope.Scope | RIn>
889
- } = internal.toRuntimeWithMemoMap
890
-
891
- /**
892
- * Feeds the output services of this builder into the input of the specified
893
- * builder, resulting in a new builder with the inputs of this builder as
894
- * well as any leftover inputs, and the outputs of the specified builder.
895
- *
896
- * @since 2.0.0
897
- * @category utils
898
- */
899
- export const provide: {
900
- <RIn, E, ROut>(
901
- that: Layer<ROut, E, RIn>
902
- ): <RIn2, E2, ROut2>(self: Layer<ROut2, E2, RIn2>) => Layer<ROut2, E | E2, RIn | Exclude<RIn2, ROut>>
903
- <const Layers extends readonly [Layer.Any, ...Array<Layer.Any>]>(
904
- that: Layers
905
- ): <A, E, R>(
906
- self: Layer<A, E, R>
907
- ) => Layer<
908
- A,
909
- E | { [k in keyof Layers]: Layer.Error<Layers[k]> }[number],
910
- | { [k in keyof Layers]: Layer.Context<Layers[k]> }[number]
911
- | Exclude<R, { [k in keyof Layers]: Layer.Success<Layers[k]> }[number]>
912
- >
913
- <RIn2, E2, ROut2, RIn, E, ROut>(
914
- self: Layer<ROut2, E2, RIn2>,
915
- that: Layer<ROut, E, RIn>
916
- ): Layer<ROut2, E | E2, RIn | Exclude<RIn2, ROut>>
917
- <A, E, R, const Layers extends readonly [Layer.Any, ...Array<Layer.Any>]>(
918
- self: Layer<A, E, R>,
919
- that: Layers
920
- ): Layer<
921
- A,
922
- E | { [k in keyof Layers]: Layer.Error<Layers[k]> }[number],
923
- | { [k in keyof Layers]: Layer.Context<Layers[k]> }[number]
924
- | Exclude<R, { [k in keyof Layers]: Layer.Success<Layers[k]> }[number]>
925
- >
926
- } = internal.provide
927
-
928
- /**
929
- * Feeds the output services of this layer into the input of the specified
930
- * layer, resulting in a new layer with the inputs of this layer, and the
931
- * outputs of both layers.
932
- *
933
- * @since 2.0.0
934
- * @category utils
935
- */
936
- export const provideMerge: {
937
- <RIn, E, ROut>(
938
- self: Layer<ROut, E, RIn>
939
- ): <RIn2, E2, ROut2>(that: Layer<ROut2, E2, RIn2>) => Layer<ROut | ROut2, E | E2, RIn | Exclude<RIn2, ROut>>
940
- <RIn2, E2, ROut2, RIn, E, ROut>(
941
- that: Layer<ROut2, E2, RIn2>,
942
- self: Layer<ROut, E, RIn>
943
- ): Layer<ROut2 | ROut, E2 | E, RIn | Exclude<RIn2, ROut>>
944
- } = internal.provideMerge
945
-
946
- /**
947
- * Combines this layer with the specified layer concurrently, creating a new layer with merged input types and
948
- * combined output types using the provided function.
949
- *
950
- * @since 2.0.0
951
- * @category zipping
952
- */
953
- export const zipWith: {
954
- <B, E2, R2, A, C>(
955
- that: Layer<B, E2, R2>,
956
- f: (a: Context.Context<A>, b: Context.Context<B>) => Context.Context<C>
957
- ): <E, R>(self: Layer<A, E, R>) => Layer<C, E2 | E, R2 | R>
958
- <A, E, R, B, E2, R2, C>(
959
- self: Layer<A, E, R>,
960
- that: Layer<B, E2, R2>,
961
- f: (a: Context.Context<A>, b: Context.Context<B>) => Context.Context<C>
962
- ): Layer<C, E | E2, R | R2>
963
- } = internal.zipWith
964
-
965
- /**
966
- * @since 2.0.0
967
- * @category utils
968
- */
969
- export const unwrapEffect: <A, E1, R1, E, R>(self: Effect.Effect<Layer<A, E1, R1>, E, R>) => Layer<A, E | E1, R | R1> =
970
- internal.unwrapEffect
971
-
972
- /**
973
- * @since 2.0.0
974
- * @category utils
975
- */
976
- export const unwrapScoped: <A, E1, R1, E, R>(
977
- self: Effect.Effect<Layer<A, E1, R1>, E, R>
978
- ) => Layer<A, E | E1, R1 | Exclude<R, Scope.Scope>> = internal.unwrapScoped
979
-
980
- /**
981
- * @since 2.0.0
982
- * @category clock
983
- */
984
- export const setClock: <A extends Clock.Clock>(clock: A) => Layer<never> = <A extends Clock.Clock>(
985
- clock: A
986
- ): Layer<never> =>
987
- scopedDiscard(
988
- fiberRuntime.fiberRefLocallyScopedWith(defaultServices.currentServices, Context.add(clockTag, clock))
989
- )
990
-
991
- /**
992
- * Sets the current `ConfigProvider`.
993
- *
994
- * @since 2.0.0
995
- * @category config
996
- */
997
- export const setConfigProvider: (configProvider: ConfigProvider) => Layer<never> = circularLayer.setConfigProvider
998
-
999
- /**
1000
- * Adds the provided span to the span stack.
1001
- *
1002
- * @since 2.0.0
1003
- * @category tracing
1004
- */
1005
- export const parentSpan: (span: Tracer.AnySpan) => Layer<Tracer.ParentSpan> = circularLayer.parentSpan
1006
-
1007
- /**
1008
- * @since 3.15.0
1009
- * @category Random
1010
- */
1011
- export const setRandom = <A extends Random.Random>(random: A): Layer<never> =>
1012
- scopedDiscard(
1013
- fiberRuntime.fiberRefLocallyScopedWith(defaultServices.currentServices, Context.add(randomTag, random))
1014
- )
1015
-
1016
- /**
1017
- * @since 2.0.0
1018
- * @category requests & batching
1019
- */
1020
- export const setRequestBatching: (requestBatching: boolean) => Layer<never> = (
1021
- requestBatching: boolean
1022
- ) =>
1023
- scopedDiscard(
1024
- fiberRuntime.fiberRefLocallyScoped(core.currentRequestBatching, requestBatching)
1025
- )
1026
-
1027
- /**
1028
- * @since 2.0.0
1029
- * @category requests & batching
1030
- */
1031
- export const setRequestCaching: (requestCaching: boolean) => Layer<never> = (
1032
- requestCaching: boolean
1033
- ) =>
1034
- scopedDiscard(
1035
- fiberRuntime.fiberRefLocallyScoped(query.currentCacheEnabled, requestCaching)
1036
- )
1037
-
1038
- /**
1039
- * @since 2.0.0
1040
- * @category requests & batching
1041
- */
1042
- export const setRequestCache: {
1043
- <E, R>(
1044
- cache: Effect.Effect<Request.Cache, E, R>
1045
- ): Layer<never, E, Exclude<R, Scope.Scope>>
1046
- (
1047
- cache: Request.Cache
1048
- ): Layer<never>
1049
- } = (<E, R>(cache: Request.Cache | Effect.Effect<Request.Cache, E, R>) =>
1050
- scopedDiscard(
1051
- core.isEffect(cache) ?
1052
- core.flatMap(cache, (x) => fiberRuntime.fiberRefLocallyScoped(query.currentCache as any, x)) :
1053
- fiberRuntime.fiberRefLocallyScoped(query.currentCache as any, cache)
1054
- )) as any
1055
-
1056
- /**
1057
- * @since 2.0.0
1058
- * @category scheduler
1059
- */
1060
- export const setScheduler: (scheduler: Scheduler.Scheduler) => Layer<never> = (
1061
- scheduler: Scheduler.Scheduler
1062
- ): Layer<never> =>
1063
- scopedDiscard(
1064
- fiberRuntime.fiberRefLocallyScoped(Scheduler.currentScheduler, scheduler)
1065
- )
1066
-
1067
- /**
1068
- * Create and add a span to the current span stack.
1069
- *
1070
- * The span is ended when the Layer is released.
1071
- *
1072
- * @since 2.0.0
1073
- * @category tracing
1074
- */
1075
- export const span: (
1076
- name: string,
1077
- options?: Tracer.SpanOptions & {
1078
- readonly onEnd?:
1079
- | ((span: Tracer.Span, exit: Exit.Exit<unknown, unknown>) => Effect.Effect<void>)
1080
- | undefined
1081
- }
1082
- ) => Layer<Tracer.ParentSpan> = circularLayer.span
1083
-
1084
- /**
1085
- * Create a Layer that sets the current Tracer
1086
- *
1087
- * @since 2.0.0
1088
- * @category tracing
1089
- */
1090
- export const setTracer: (tracer: Tracer.Tracer) => Layer<never> = circularLayer.setTracer
1091
-
1092
- /**
1093
- * @since 2.0.0
1094
- * @category tracing
1095
- */
1096
- export const setTracerEnabled: (enabled: boolean) => Layer<never> = (enabled: boolean) =>
1097
- scopedDiscard(
1098
- fiberRuntime.fiberRefLocallyScoped(core.currentTracerEnabled, enabled)
1099
- )
1100
-
1101
- /**
1102
- * @since 2.0.0
1103
- * @category tracing
1104
- */
1105
- export const setTracerTiming: (enabled: boolean) => Layer<never> = (enabled: boolean) =>
1106
- scopedDiscard(
1107
- fiberRuntime.fiberRefLocallyScoped(core.currentTracerTimingEnabled, enabled)
1108
- )
1109
-
1110
- /**
1111
- * A layer that enables source location capture for forked fibers.
1112
- *
1113
- * When enabled, `Effect.fork` and similar operations will capture the call
1114
- * site (file, line, column) and store it in a FiberRef that can be read by
1115
- * Supervisors. This enables automatic tracing with meaningful span names
1116
- * like `"sendEmail (user-handlers.ts:42)"` instead of `"anonymous"`.
1117
- *
1118
- * @example
1119
- * ```ts
1120
- * import { Effect, Layer } from "effect"
1121
- *
1122
- * // Enable source capture for entire program
1123
- * Effect.runPromise(
1124
- * program.pipe(Effect.provide(Layer.enableSourceCapture))
1125
- * )
1126
- * ```
1127
- *
1128
- * @since 3.15.0
1129
- * @category tracing
1130
- */
1131
- export const enableSourceCapture: Layer<never> = internal.enableSourceCapture
1132
-
1133
- /**
1134
- * @since 2.0.0
1135
- * @category logging
1136
- */
1137
- export const setUnhandledErrorLogLevel: (level: Option.Option<LogLevel>) => Layer<never> = (
1138
- level: Option.Option<LogLevel>
1139
- ): Layer<never> =>
1140
- scopedDiscard(
1141
- fiberRuntime.fiberRefLocallyScoped(core.currentUnhandledErrorLogLevel, level)
1142
- )
1143
-
1144
- /**
1145
- * @since 3.17.0
1146
- * @category logging
1147
- */
1148
- export const setVersionMismatchErrorLogLevel: (level: Option.Option<LogLevel>) => Layer<never> = (
1149
- level: Option.Option<LogLevel>
1150
- ): Layer<never> =>
1151
- scopedDiscard(
1152
- fiberRuntime.fiberRefLocallyScoped(core.currentVersionMismatchErrorLogLevel, level)
1153
- )
1154
-
1155
- /**
1156
- * @since 2.0.0
1157
- * @category tracing
1158
- */
1159
- export const withSpan: {
1160
- (
1161
- name: string,
1162
- options?: Tracer.SpanOptions & {
1163
- readonly onEnd?:
1164
- | ((span: Tracer.Span, exit: Exit.Exit<unknown, unknown>) => Effect.Effect<void>)
1165
- | undefined
1166
- }
1167
- ): <A, E, R>(self: Layer<A, E, R>) => Layer<A, E, Exclude<R, Tracer.ParentSpan>>
1168
- <A, E, R>(
1169
- self: Layer<A, E, R>,
1170
- name: string,
1171
- options?: Tracer.SpanOptions & {
1172
- readonly onEnd?:
1173
- | ((span: Tracer.Span, exit: Exit.Exit<unknown, unknown>) => Effect.Effect<void>)
1174
- | undefined
1175
- }
1176
- ): Layer<A, E, Exclude<R, Tracer.ParentSpan>>
1177
- } = internal.withSpan
1178
-
1179
- /**
1180
- * @since 2.0.0
1181
- * @category tracing
1182
- */
1183
- export const withParentSpan: {
1184
- (span: Tracer.AnySpan): <A, E, R>(self: Layer<A, E, R>) => Layer<A, E, Exclude<R, Tracer.ParentSpan>>
1185
- <A, E, R>(self: Layer<A, E, R>, span: Tracer.AnySpan): Layer<A, E, Exclude<R, Tracer.ParentSpan>>
1186
- } = internal.withParentSpan
1187
-
1188
- // -----------------------------------------------------------------------------
1189
- // memo map
1190
- // -----------------------------------------------------------------------------
1191
-
1192
- /**
1193
- * Constructs a `MemoMap` that can be used to build additional layers.
1194
- *
1195
- * @since 2.0.0
1196
- * @category memo map
1197
- */
1198
- export const makeMemoMap: Effect.Effect<MemoMap> = internal.makeMemoMap
1199
-
1200
- /**
1201
- * Builds a layer into an `Effect` value, using the specified `MemoMap` to memoize
1202
- * the layer construction.
1203
- *
1204
- * @since 2.0.0
1205
- * @category memo map
1206
- */
1207
- export const buildWithMemoMap: {
1208
- (
1209
- memoMap: MemoMap,
1210
- scope: Scope.Scope
1211
- ): <RIn, E, ROut>(self: Layer<ROut, E, RIn>) => Effect.Effect<Context.Context<ROut>, E, RIn>
1212
- <RIn, E, ROut>(
1213
- self: Layer<ROut, E, RIn>,
1214
- memoMap: MemoMap,
1215
- scope: Scope.Scope
1216
- ): Effect.Effect<Context.Context<ROut>, E, RIn>
1217
- } = internal.buildWithMemoMap
1218
-
1219
- /**
1220
- * Updates a service in the context with a new implementation.
1221
- *
1222
- * **Details**
1223
- *
1224
- * This function modifies the existing implementation of a service in the
1225
- * context. It retrieves the current service, applies the provided
1226
- * transformation function `f`, and replaces the old service with the
1227
- * transformed one.
1228
- *
1229
- * **When to Use**
1230
- *
1231
- * This is useful for adapting or extending a service's behavior during the
1232
- * creation of a layer.
1233
- *
1234
- * @since 3.13.0
1235
- * @category utils
1236
- */
1237
- export const updateService = dual<
1238
- <I, A>(
1239
- tag: Context.Tag<I, A>,
1240
- f: (a: A) => A
1241
- ) => <A1, E1, R1>(layer: Layer<A1, E1, R1>) => Layer<A1, E1, I | R1>,
1242
- <A1, E1, R1, I, A>(
1243
- layer: Layer<A1, E1, R1>,
1244
- tag: Context.Tag<I, A>,
1245
- f: (a: A) => A
1246
- ) => Layer<A1, E1, I | R1>
1247
- >(3, (layer, tag, f) =>
1248
- provide(
1249
- layer,
1250
- map(context(), (c) => Context.add(c, tag, f(Context.unsafeGet(c, tag))))
1251
- ))