effect 4.0.0-beta.4 → 4.0.0-beta.6

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 (310) hide show
  1. package/dist/Cause.d.ts +1 -1
  2. package/dist/Cause.d.ts.map +1 -1
  3. package/dist/Channel.d.ts.map +1 -1
  4. package/dist/Channel.js +6 -4
  5. package/dist/Channel.js.map +1 -1
  6. package/dist/Config.d.ts +1 -1
  7. package/dist/Data.d.ts +3 -2
  8. package/dist/Data.d.ts.map +1 -1
  9. package/dist/Data.js +9 -8
  10. package/dist/Data.js.map +1 -1
  11. package/dist/Effect.d.ts +0 -226
  12. package/dist/Effect.d.ts.map +1 -1
  13. package/dist/Effect.js +0 -118
  14. package/dist/Effect.js.map +1 -1
  15. package/dist/Encoding.d.ts +194 -0
  16. package/dist/Encoding.d.ts.map +1 -0
  17. package/dist/Encoding.js +352 -0
  18. package/dist/Encoding.js.map +1 -0
  19. package/dist/Equal.js.map +1 -1
  20. package/dist/FileSystem.d.ts +1 -1
  21. package/dist/FileSystem.d.ts.map +1 -1
  22. package/dist/FileSystem.js +5 -5
  23. package/dist/FileSystem.js.map +1 -1
  24. package/dist/Filter.d.ts +30 -1
  25. package/dist/Filter.d.ts.map +1 -1
  26. package/dist/Filter.js +15 -0
  27. package/dist/Filter.js.map +1 -1
  28. package/dist/Formatter.js +1 -1
  29. package/dist/Formatter.js.map +1 -1
  30. package/dist/Graph.d.ts.map +1 -1
  31. package/dist/Graph.js +2 -2
  32. package/dist/Graph.js.map +1 -1
  33. package/dist/Latch.d.ts +109 -0
  34. package/dist/Latch.d.ts.map +1 -0
  35. package/dist/Latch.js +72 -0
  36. package/dist/Latch.js.map +1 -0
  37. package/dist/Pipeable.d.ts +17 -0
  38. package/dist/Pipeable.d.ts.map +1 -1
  39. package/dist/Pipeable.js +19 -1
  40. package/dist/Pipeable.js.map +1 -1
  41. package/dist/PlatformError.d.ts +8 -7
  42. package/dist/PlatformError.d.ts.map +1 -1
  43. package/dist/PlatformError.js +2 -2
  44. package/dist/PlatformError.js.map +1 -1
  45. package/dist/Pool.d.ts +5 -3
  46. package/dist/Pool.d.ts.map +1 -1
  47. package/dist/Pool.js +6 -4
  48. package/dist/Pool.js.map +1 -1
  49. package/dist/PubSub.d.ts +3 -2
  50. package/dist/PubSub.d.ts.map +1 -1
  51. package/dist/PubSub.js +3 -2
  52. package/dist/PubSub.js.map +1 -1
  53. package/dist/Request.d.ts +1 -1
  54. package/dist/Request.d.ts.map +1 -1
  55. package/dist/Request.js +2 -1
  56. package/dist/Request.js.map +1 -1
  57. package/dist/RequestResolver.d.ts +0 -20
  58. package/dist/RequestResolver.d.ts.map +1 -1
  59. package/dist/RequestResolver.js +0 -20
  60. package/dist/RequestResolver.js.map +1 -1
  61. package/dist/Schedule.d.ts +2 -2
  62. package/dist/Schedule.d.ts.map +1 -1
  63. package/dist/Schedule.js +30 -16
  64. package/dist/Schedule.js.map +1 -1
  65. package/dist/Schema.d.ts +192 -42
  66. package/dist/Schema.d.ts.map +1 -1
  67. package/dist/Schema.js +385 -71
  68. package/dist/Schema.js.map +1 -1
  69. package/dist/SchemaGetter.d.ts +2 -2
  70. package/dist/SchemaGetter.d.ts.map +1 -1
  71. package/dist/SchemaGetter.js +12 -14
  72. package/dist/SchemaGetter.js.map +1 -1
  73. package/dist/SchemaRepresentation.d.ts +44 -43
  74. package/dist/SchemaRepresentation.d.ts.map +1 -1
  75. package/dist/SchemaRepresentation.js +5 -2
  76. package/dist/SchemaRepresentation.js.map +1 -1
  77. package/dist/SchemaTransformation.d.ts +37 -0
  78. package/dist/SchemaTransformation.d.ts.map +1 -1
  79. package/dist/SchemaTransformation.js +80 -0
  80. package/dist/SchemaTransformation.js.map +1 -1
  81. package/dist/Semaphore.d.ts +211 -0
  82. package/dist/Semaphore.d.ts.map +1 -0
  83. package/dist/{PartitionedSemaphore.js → Semaphore.js} +97 -13
  84. package/dist/Semaphore.js.map +1 -0
  85. package/dist/Stream.d.ts.map +1 -1
  86. package/dist/Stream.js +9 -8
  87. package/dist/Stream.js.map +1 -1
  88. package/dist/Struct.d.ts +16 -0
  89. package/dist/Struct.d.ts.map +1 -1
  90. package/dist/Struct.js +22 -0
  91. package/dist/Struct.js.map +1 -1
  92. package/dist/SubscriptionRef.d.ts +2 -1
  93. package/dist/SubscriptionRef.d.ts.map +1 -1
  94. package/dist/SubscriptionRef.js +2 -1
  95. package/dist/SubscriptionRef.js.map +1 -1
  96. package/dist/SynchronizedRef.d.ts +2 -1
  97. package/dist/SynchronizedRef.d.ts.map +1 -1
  98. package/dist/SynchronizedRef.js +2 -1
  99. package/dist/SynchronizedRef.js.map +1 -1
  100. package/dist/Types.d.ts +14 -6
  101. package/dist/Types.d.ts.map +1 -1
  102. package/dist/index.d.ts +14 -5
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +14 -5
  105. package/dist/index.js.map +1 -1
  106. package/dist/internal/core.js +11 -3
  107. package/dist/internal/core.js.map +1 -1
  108. package/dist/internal/effect.js.map +1 -1
  109. package/dist/internal/rcRef.js +2 -1
  110. package/dist/internal/rcRef.js.map +1 -1
  111. package/dist/testing/TestClock.d.ts +3 -2
  112. package/dist/testing/TestClock.d.ts.map +1 -1
  113. package/dist/testing/TestClock.js +5 -3
  114. package/dist/testing/TestClock.js.map +1 -1
  115. package/dist/unstable/ai/AiError.d.ts +39 -39
  116. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  117. package/dist/unstable/ai/Chat.js +2 -1
  118. package/dist/unstable/ai/Chat.js.map +1 -1
  119. package/dist/unstable/ai/McpSchema.d.ts +51 -51
  120. package/dist/unstable/ai/Prompt.d.ts +20 -20
  121. package/dist/unstable/ai/Response.d.ts +25 -25
  122. package/dist/unstable/cli/CliError.d.ts +5 -5
  123. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  124. package/dist/unstable/cluster/ClusterWorkflowEngine.js +2 -1
  125. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  126. package/dist/unstable/cluster/Entity.d.ts +2 -1
  127. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  128. package/dist/unstable/cluster/Entity.js.map +1 -1
  129. package/dist/unstable/cluster/Envelope.d.ts +1 -1
  130. package/dist/unstable/cluster/K8sHttpClient.d.ts +1 -1
  131. package/dist/unstable/cluster/Message.d.ts +5 -5
  132. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  133. package/dist/unstable/cluster/MessageStorage.js +2 -1
  134. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  135. package/dist/unstable/cluster/Reply.d.ts +3 -3
  136. package/dist/unstable/cluster/Runner.d.ts +1 -1
  137. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  138. package/dist/unstable/cluster/Runners.js +4 -3
  139. package/dist/unstable/cluster/Runners.js.map +1 -1
  140. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  141. package/dist/unstable/cluster/Sharding.js +7 -5
  142. package/dist/unstable/cluster/Sharding.js.map +1 -1
  143. package/dist/unstable/cluster/internal/entityManager.js +4 -3
  144. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  145. package/dist/unstable/cluster/internal/entityReaper.js +2 -1
  146. package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
  147. package/dist/unstable/cluster/internal/resourceRef.js +2 -1
  148. package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
  149. package/dist/unstable/devtools/DevToolsSchema.d.ts +36 -36
  150. package/dist/unstable/encoding/Sse.d.ts +1 -1
  151. package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
  152. package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
  153. package/dist/unstable/eventlog/EventLog.js +2 -1
  154. package/dist/unstable/eventlog/EventLog.js.map +1 -1
  155. package/dist/unstable/eventlog/EventLogRemote.d.ts +5 -5
  156. package/dist/unstable/http/Cookies.d.ts +1 -1
  157. package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
  158. package/dist/unstable/http/HttpEffect.js +18 -26
  159. package/dist/unstable/http/HttpEffect.js.map +1 -1
  160. package/dist/unstable/http/Multipart.d.ts +2 -2
  161. package/dist/unstable/http/UrlParams.d.ts +1 -1
  162. package/dist/unstable/httpapi/HttpApiBuilder.js +2 -2
  163. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  164. package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
  165. package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
  166. package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
  167. package/dist/unstable/persistence/KeyValueStore.js +6 -6
  168. package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
  169. package/dist/unstable/persistence/PersistedCache.d.ts +6 -5
  170. package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
  171. package/dist/unstable/persistence/PersistedCache.js +2 -1
  172. package/dist/unstable/persistence/PersistedCache.js.map +1 -1
  173. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  174. package/dist/unstable/persistence/PersistedQueue.js +6 -5
  175. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  176. package/dist/unstable/process/ChildProcessSpawner.d.ts +6 -0
  177. package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
  178. package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
  179. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  180. package/dist/unstable/reactivity/Atom.js +12 -9
  181. package/dist/unstable/reactivity/Atom.js.map +1 -1
  182. package/dist/unstable/reactivity/Hydration.d.ts +39 -0
  183. package/dist/unstable/reactivity/Hydration.d.ts.map +1 -0
  184. package/dist/unstable/reactivity/Hydration.js +76 -0
  185. package/dist/unstable/reactivity/Hydration.js.map +1 -0
  186. package/dist/unstable/reactivity/index.d.ts +4 -0
  187. package/dist/unstable/reactivity/index.d.ts.map +1 -1
  188. package/dist/unstable/reactivity/index.js +4 -0
  189. package/dist/unstable/reactivity/index.js.map +1 -1
  190. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  191. package/dist/unstable/rpc/RpcClient.js +3 -2
  192. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  193. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  194. package/dist/unstable/rpc/RpcServer.js +5 -3
  195. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  196. package/dist/unstable/rpc/Utils.d.ts.map +1 -1
  197. package/dist/unstable/rpc/Utils.js +2 -1
  198. package/dist/unstable/rpc/Utils.js.map +1 -1
  199. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  200. package/dist/unstable/socket/Socket.js +3 -2
  201. package/dist/unstable/socket/Socket.js.map +1 -1
  202. package/dist/unstable/sql/Statement.js +0 -1
  203. package/dist/unstable/sql/Statement.js.map +1 -1
  204. package/dist/unstable/workers/Worker.d.ts.map +1 -1
  205. package/dist/unstable/workers/Worker.js +2 -1
  206. package/dist/unstable/workers/Worker.js.map +1 -1
  207. package/dist/unstable/workflow/DurableDeferred.js +2 -2
  208. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  209. package/dist/unstable/workflow/Workflow.d.ts +1 -1
  210. package/dist/unstable/workflow/WorkflowEngine.d.ts +2 -1
  211. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  212. package/dist/unstable/workflow/WorkflowEngine.js +2 -1
  213. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  214. package/package.json +1 -2
  215. package/src/Cause.ts +1 -1
  216. package/src/Channel.ts +6 -4
  217. package/src/Data.ts +10 -9
  218. package/src/Effect.ts +0 -246
  219. package/src/Encoding.ts +879 -0
  220. package/src/Equal.ts +2 -2
  221. package/src/FileSystem.ts +7 -8
  222. package/src/Filter.ts +48 -1
  223. package/src/Formatter.ts +1 -1
  224. package/src/Graph.ts +8 -5
  225. package/src/Latch.ts +112 -0
  226. package/src/Pipeable.ts +32 -1
  227. package/src/PlatformError.ts +5 -5
  228. package/src/Pool.ts +9 -7
  229. package/src/PubSub.ts +10 -9
  230. package/src/Request.ts +3 -2
  231. package/src/RequestResolver.ts +0 -20
  232. package/src/Schedule.ts +217 -115
  233. package/src/Schema.ts +567 -105
  234. package/src/SchemaGetter.ts +12 -14
  235. package/src/SchemaRepresentation.ts +5 -2
  236. package/src/SchemaTransformation.ts +104 -0
  237. package/src/Semaphore.ts +356 -0
  238. package/src/Stream.ts +9 -8
  239. package/src/Struct.ts +26 -0
  240. package/src/SubscriptionRef.ts +3 -2
  241. package/src/SynchronizedRef.ts +3 -2
  242. package/src/Types.ts +12 -2
  243. package/src/index.ts +17 -6
  244. package/src/internal/core.ts +10 -2
  245. package/src/internal/effect.ts +3 -2
  246. package/src/internal/rcRef.ts +2 -1
  247. package/src/testing/TestClock.ts +8 -6
  248. package/src/unstable/ai/AiError.ts +1 -1
  249. package/src/unstable/ai/Chat.ts +2 -1
  250. package/src/unstable/ai/Prompt.ts +20 -20
  251. package/src/unstable/ai/Response.ts +22 -22
  252. package/src/unstable/cluster/ClusterWorkflowEngine.ts +3 -2
  253. package/src/unstable/cluster/Entity.ts +2 -1
  254. package/src/unstable/cluster/Envelope.ts +1 -1
  255. package/src/unstable/cluster/MessageStorage.ts +2 -1
  256. package/src/unstable/cluster/Runners.ts +6 -5
  257. package/src/unstable/cluster/Sharding.ts +8 -6
  258. package/src/unstable/cluster/internal/entityManager.ts +6 -5
  259. package/src/unstable/cluster/internal/entityReaper.ts +2 -1
  260. package/src/unstable/cluster/internal/resourceRef.ts +2 -1
  261. package/src/unstable/eventlog/EventLog.ts +2 -1
  262. package/src/unstable/http/HttpEffect.ts +17 -25
  263. package/src/unstable/http/Multipart.ts +2 -2
  264. package/src/unstable/http/UrlParams.ts +1 -1
  265. package/src/unstable/httpapi/HttpApiBuilder.ts +2 -2
  266. package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
  267. package/src/unstable/persistence/KeyValueStore.ts +6 -6
  268. package/src/unstable/persistence/PersistedCache.ts +20 -9
  269. package/src/unstable/persistence/PersistedQueue.ts +7 -6
  270. package/src/unstable/process/ChildProcessSpawner.ts +6 -0
  271. package/src/unstable/reactivity/Atom.ts +7 -5
  272. package/src/unstable/reactivity/Hydration.ts +112 -0
  273. package/src/unstable/reactivity/index.ts +5 -0
  274. package/src/unstable/rpc/RpcClient.ts +4 -3
  275. package/src/unstable/rpc/RpcServer.ts +6 -4
  276. package/src/unstable/rpc/Utils.ts +2 -1
  277. package/src/unstable/socket/Socket.ts +3 -2
  278. package/src/unstable/sql/Statement.ts +0 -1
  279. package/src/unstable/workers/Worker.ts +2 -1
  280. package/src/unstable/workflow/DurableDeferred.ts +2 -2
  281. package/src/unstable/workflow/WorkflowEngine.ts +3 -2
  282. package/dist/PartitionedSemaphore.d.ts +0 -52
  283. package/dist/PartitionedSemaphore.d.ts.map +0 -1
  284. package/dist/PartitionedSemaphore.js.map +0 -1
  285. package/dist/encoding/Base64.d.ts +0 -67
  286. package/dist/encoding/Base64.d.ts.map +0 -1
  287. package/dist/encoding/Base64.js +0 -146
  288. package/dist/encoding/Base64.js.map +0 -1
  289. package/dist/encoding/Base64Url.d.ts +0 -60
  290. package/dist/encoding/Base64Url.d.ts.map +0 -1
  291. package/dist/encoding/Base64Url.js +0 -89
  292. package/dist/encoding/Base64Url.js.map +0 -1
  293. package/dist/encoding/EncodingError.d.ts +0 -31
  294. package/dist/encoding/EncodingError.d.ts.map +0 -1
  295. package/dist/encoding/EncodingError.js +0 -22
  296. package/dist/encoding/EncodingError.js.map +0 -1
  297. package/dist/encoding/Hex.d.ts +0 -61
  298. package/dist/encoding/Hex.d.ts.map +0 -1
  299. package/dist/encoding/Hex.js +0 -115
  300. package/dist/encoding/Hex.js.map +0 -1
  301. package/dist/encoding/index.d.ts +0 -26
  302. package/dist/encoding/index.d.ts.map +0 -1
  303. package/dist/encoding/index.js +0 -27
  304. package/dist/encoding/index.js.map +0 -1
  305. package/src/PartitionedSemaphore.ts +0 -182
  306. package/src/encoding/Base64.ts +0 -366
  307. package/src/encoding/Base64Url.ts +0 -104
  308. package/src/encoding/EncodingError.ts +0 -35
  309. package/src/encoding/Hex.ts +0 -390
  310. package/src/encoding/index.ts +0 -31
@@ -8,6 +8,7 @@ import * as Option from "./Option.ts"
8
8
  import type { Pipeable } from "./Pipeable.ts"
9
9
  import * as PubSub from "./PubSub.ts"
10
10
  import * as Ref from "./Ref.ts"
11
+ import * as Semaphore from "./Semaphore.ts"
11
12
  import * as Stream from "./Stream.ts"
12
13
  import type { Invariant } from "./Types.ts"
13
14
 
@@ -19,7 +20,7 @@ const TypeId = "~effect/SubscriptionRef"
19
20
  */
20
21
  export interface SubscriptionRef<in out A> extends SubscriptionRef.Variance<A>, Pipeable {
21
22
  readonly backing: Ref.Ref<A>
22
- readonly semaphore: Effect.Semaphore
23
+ readonly semaphore: Semaphore.Semaphore
23
24
  readonly pubsub: PubSub.PubSub<A>
24
25
  }
25
26
 
@@ -70,7 +71,7 @@ const Proto = {
70
71
  export const make = <A>(value: A): Effect.Effect<SubscriptionRef<A>> =>
71
72
  Effect.map(PubSub.unbounded<A>({ replay: 1 }), (pubsub) => {
72
73
  const self = Object.create(Proto)
73
- self.semaphore = Effect.makeSemaphoreUnsafe(1)
74
+ self.semaphore = Semaphore.makeUnsafe(1)
74
75
  self.backing = Ref.makeUnsafe(value)
75
76
  self.pubsub = pubsub
76
77
  PubSub.publishUnsafe(self.pubsub, value)
@@ -6,6 +6,7 @@ import { dual } from "./Function.ts"
6
6
  import { PipeInspectableProto } from "./internal/core.ts"
7
7
  import * as Option from "./Option.ts"
8
8
  import * as Ref from "./Ref.ts"
9
+ import * as Semaphore from "./Semaphore.ts"
9
10
 
10
11
  const TypeId = "~effect/SynchronizedRef"
11
12
 
@@ -16,7 +17,7 @@ const TypeId = "~effect/SynchronizedRef"
16
17
  export interface SynchronizedRef<in out A> extends Ref.Ref<A> {
17
18
  readonly [TypeId]: typeof TypeId
18
19
  readonly backing: Ref.Ref<A>
19
- readonly semaphore: Effect.Semaphore
20
+ readonly semaphore: Semaphore.Semaphore
20
21
  }
21
22
 
22
23
  const Proto = {
@@ -36,7 +37,7 @@ const Proto = {
36
37
  */
37
38
  export const makeUnsafe = <A>(value: A): SynchronizedRef<A> => {
38
39
  const self = Object.create(Proto)
39
- self.semaphore = Effect.makeSemaphoreUnsafe(1)
40
+ self.semaphore = Semaphore.makeUnsafe(1)
40
41
  self.backing = Ref.makeUnsafe(value)
41
42
  return self
42
43
  }
package/src/Types.ts CHANGED
@@ -205,7 +205,7 @@ export type ExcludeTag<E, K extends string> = Exclude<E, { readonly _tag: K }>
205
205
  * @category types
206
206
  * @since 2.0.0
207
207
  */
208
- export type ExtractTag<E, K extends string> = Extract<E, { readonly _tag: K }>
208
+ export type ExtractTag<E, K extends string> = E extends { readonly _tag: infer T } ? K extends T ? E : never : never
209
209
 
210
210
  /**
211
211
  * Transforms a union type into an intersection type.
@@ -729,6 +729,15 @@ export declare namespace Contravariant {
729
729
  */
730
730
  export type MatchRecord<S, onTrue, onFalse> = {} extends S ? onTrue : onFalse
731
731
 
732
+ /**
733
+ * Conditional type that returns `void` if `S` is an empty object type,
734
+ * otherwise returns `S`.
735
+ *
736
+ * @since 4.0.0
737
+ * @category types
738
+ */
739
+ export type VoidIfEmpty<S> = MatchRecord<S, void, S>
740
+
732
741
  /**
733
742
  * Excludes function types from a union, keeping only non-function members.
734
743
  *
@@ -914,7 +923,8 @@ export type ReasonTags<E> = E extends { readonly reason: { readonly _tag: string
914
923
  * @category types
915
924
  */
916
925
  export type ExtractReason<E, K extends string> = E extends { readonly reason: infer R }
917
- ? Extract<R, { readonly _tag: K }>
926
+ ? R extends { readonly _tag: infer T } ? K extends T ? R : never
927
+ : never
918
928
  : never
919
929
 
920
930
  /**
package/src/index.ts CHANGED
@@ -865,6 +865,13 @@ export * as Duration from "./Duration.ts"
865
865
  */
866
866
  export * as Effect from "./Effect.ts"
867
867
 
868
+ /**
869
+ * Encoding & decoding for Base64 (RFC4648), Base64Url, and Hex.
870
+ *
871
+ * @since 4.0.0
872
+ */
873
+ export * as Encoding from "./Encoding.ts"
874
+
868
875
  /**
869
876
  * This module provides functionality for defining and working with equality between values.
870
877
  * It includes the `Equal` interface for types that can determine equality with other values
@@ -1398,6 +1405,11 @@ export * as JsonPointer from "./JsonPointer.ts"
1398
1405
  */
1399
1406
  export * as JsonSchema from "./JsonSchema.ts"
1400
1407
 
1408
+ /**
1409
+ * @since 3.8.0
1410
+ */
1411
+ export * as Latch from "./Latch.ts"
1412
+
1401
1413
  /**
1402
1414
  * A `Layer<ROut, E, RIn>` describes how to build one or more services in your
1403
1415
  * application. Services can be injected into effects via
@@ -2269,12 +2281,6 @@ export * as Order from "./Order.ts"
2269
2281
  */
2270
2282
  export * as Ordering from "./Ordering.ts"
2271
2283
 
2272
- /**
2273
- * @since 3.19.4
2274
- * @experimental
2275
- */
2276
- export * as PartitionedSemaphore from "./PartitionedSemaphore.ts"
2277
-
2278
2284
  /**
2279
2285
  * @since 4.0.0
2280
2286
  */
@@ -3137,6 +3143,11 @@ export * as ScopedCache from "./ScopedCache.ts"
3137
3143
  */
3138
3144
  export * as ScopedRef from "./ScopedRef.ts"
3139
3145
 
3146
+ /**
3147
+ * @since 2.0.0
3148
+ */
3149
+ export * as Semaphore from "./Semaphore.ts"
3150
+
3140
3151
  /**
3141
3152
  * This module provides a data structure called `ServiceMap` that can be used
3142
3153
  * for dependency injection in effectful programs. It is essentially a table
@@ -70,7 +70,7 @@ export const PipeInspectableProto = {
70
70
  return { ...this }
71
71
  },
72
72
  toString() {
73
- return format(this, { ignoreToString: true })
73
+ return format(this.toJSON(), { ignoreToString: true, space: 2 })
74
74
  },
75
75
  [NodeInspectSymbol]() {
76
76
  return this.toJSON()
@@ -102,6 +102,14 @@ export const YieldableProto = {
102
102
  }
103
103
  }
104
104
 
105
+ /** @internal */
106
+ export const YieldableErrorProto = {
107
+ ...YieldableProto,
108
+ pipe() {
109
+ return pipeArguments(this, arguments)
110
+ }
111
+ }
112
+
105
113
  /** @internal */
106
114
  export const EffectProto = {
107
115
  [EffectTypeId]: effectVariance,
@@ -581,7 +589,7 @@ export const YieldableError: new(
581
589
  return exitFail(this)
582
590
  }
583
591
  }
584
- Object.assign(YieldableError.prototype, YieldableProto)
592
+ Object.assign(YieldableError.prototype, YieldableErrorProto)
585
593
  return YieldableError as any
586
594
  })()
587
595
 
@@ -14,6 +14,7 @@ import { constant, constFalse, constTrue, constUndefined, constVoid, dual, ident
14
14
  import * as Hash from "../Hash.ts"
15
15
  import { toJson, toStringUnknown } from "../Inspectable.ts"
16
16
  import * as Iterable from "../Iterable.ts"
17
+ import type * as _Latch from "../Latch.ts"
17
18
  import type * as Logger from "../Logger.ts"
18
19
  import type * as LogLevel from "../LogLevel.ts"
19
20
  import type * as Metric from "../Metric.ts"
@@ -4854,7 +4855,7 @@ export const makeSemaphore = (permits: number) => sync(() => makeSemaphoreUnsafe
4854
4855
  const succeedTrue = succeed(true)
4855
4856
  const succeedFalse = succeed(false)
4856
4857
 
4857
- class Latch implements Effect.Latch {
4858
+ class Latch implements _Latch.Latch {
4858
4859
  waiters: Array<(_: Effect.Effect<void>) => void> = []
4859
4860
  scheduled = false
4860
4861
  private isOpen: boolean
@@ -4914,7 +4915,7 @@ class Latch implements Effect.Latch {
4914
4915
  }
4915
4916
 
4916
4917
  /** @internal */
4917
- export const makeLatchUnsafe = (open?: boolean | undefined): Effect.Latch => new Latch(open ?? false)
4918
+ export const makeLatchUnsafe = (open?: boolean | undefined): _Latch.Latch => new Latch(open ?? false)
4918
4919
 
4919
4920
  /** @internal */
4920
4921
  export const makeLatch = (open?: boolean | undefined) => sync(() => makeLatchUnsafe(open))
@@ -6,6 +6,7 @@ import { identity } from "../Function.ts"
6
6
  import { pipeArguments } from "../Pipeable.ts"
7
7
  import type * as RcRef from "../RcRef.ts"
8
8
  import * as Scope from "../Scope.ts"
9
+ import * as Semaphore from "../Semaphore.ts"
9
10
  import * as ServiceMap from "../ServiceMap.ts"
10
11
 
11
12
  const TypeId = "~effect/RcRef"
@@ -47,7 +48,7 @@ class RcRefImpl<A, E> implements RcRef.RcRef<A, E> {
47
48
  }
48
49
 
49
50
  state: State<A> = stateEmpty
50
- readonly semaphore = Effect.makeSemaphoreUnsafe(1)
51
+ readonly semaphore = Semaphore.makeUnsafe(1)
51
52
  readonly acquire: Effect.Effect<A, E>
52
53
  readonly services: ServiceMap.ServiceMap<never>
53
54
  readonly scope: Scope.Scope
@@ -8,8 +8,10 @@ import * as Duration from "../Duration.ts"
8
8
  import * as Effect from "../Effect.ts"
9
9
  import * as Fiber from "../Fiber.ts"
10
10
  import { flow } from "../Function.ts"
11
+ import * as Latch from "../Latch.ts"
11
12
  import * as Layer from "../Layer.ts"
12
13
  import * as Order from "../Order.ts"
14
+ import * as Semaphore from "../Semaphore.ts"
13
15
 
14
16
  /**
15
17
  * A `TestClock` simplifies deterministically and efficiently testing effects
@@ -155,7 +157,7 @@ export declare namespace TestClock {
155
157
  * const timestamp = testClock.currentTimeMillisUnsafe()
156
158
  * console.log(timestamp) // Current test time
157
159
  *
158
- * // Internal state structure: { timestamp: number, sleeps: Array<[number, Effect.Latch]> }
160
+ * // Internal state structure: { timestamp: number, sleeps: Array<[number, Latch.Latch]> }
159
161
  * })
160
162
  * ```
161
163
  *
@@ -164,7 +166,7 @@ export declare namespace TestClock {
164
166
  */
165
167
  export interface State {
166
168
  readonly timestamp: number
167
- readonly sleeps: ReadonlyArray<[number, Effect.Latch]>
169
+ readonly sleeps: ReadonlyArray<[number, Latch.Latch]>
168
170
  }
169
171
  }
170
172
 
@@ -220,10 +222,10 @@ export const make = Effect.fnUntraced(function*(
220
222
  const sleeps: Array<{
221
223
  readonly sequence: number
222
224
  readonly timestamp: number
223
- readonly latch: Effect.Latch
225
+ readonly latch: Latch.Latch
224
226
  }> = []
225
227
  const liveClock = yield* Clock.clockWith(Effect.succeed)
226
- const warningSemaphore = yield* Effect.makeSemaphore(1)
228
+ const warningSemaphore = yield* Semaphore.make(1)
227
229
 
228
230
  let currentTimestamp: number = new Date(0).getTime()
229
231
  let warningState: WarningState = WarningState.Start()
@@ -292,7 +294,7 @@ export const make = Effect.fnUntraced(function*(
292
294
  const millis = Duration.toMillis(duration)
293
295
  const end = currentTimestamp + millis
294
296
  if (end <= currentTimestamp) return
295
- const latch = Effect.makeLatchUnsafe()
297
+ const latch = Latch.makeUnsafe()
296
298
  sleeps.push({
297
299
  sequence: sequence++,
298
300
  timestamp: end,
@@ -303,7 +305,7 @@ export const make = Effect.fnUntraced(function*(
303
305
  yield* latch.await
304
306
  })
305
307
 
306
- const runSemaphore = yield* Effect.makeSemaphore(1)
308
+ const runSemaphore = yield* Semaphore.make(1)
307
309
  const run = Effect.fnUntraced(function*(step: (currentTimestamp: number) => number) {
308
310
  yield* Fiber.await(yield* Effect.forkScoped(Effect.yieldNow))
309
311
  const endTimestamp = step(currentTimestamp)
@@ -247,7 +247,7 @@ export class NetworkError extends Schema.ErrorClass<NetworkError>(
247
247
  * @since 1.0.0
248
248
  * @category schemas
249
249
  */
250
- export const ProviderMetadata: Schema.Record$<
250
+ export const ProviderMetadata: Schema.$Record<
251
251
  Schema.String,
252
252
  Schema.NullOr<Schema.Codec<Schema.MutableJson, Schema.MutableJson, never, never>>
253
253
  > = Schema.Record(Schema.String, Schema.NullOr(Schema.MutableJson))
@@ -53,6 +53,7 @@ import * as Option from "../../Option.ts"
53
53
  import * as Predicate from "../../Predicate.ts"
54
54
  import * as Ref from "../../Ref.ts"
55
55
  import * as Schema from "../../Schema.ts"
56
+ import * as Semaphore from "../../Semaphore.ts"
56
57
  import * as ServiceMap from "../../ServiceMap.ts"
57
58
  import * as Stream from "../../Stream.ts"
58
59
  import type { NoExcessProperties } from "../../Types.ts"
@@ -325,7 +326,7 @@ const encodeHistoryJson = Schema.encodeUnknownEffect(Schema.fromJsonString(Promp
325
326
  export const empty: Effect.Effect<Service> = Effect.gen(function*() {
326
327
  const history = yield* Ref.make(Prompt.empty)
327
328
  const services = yield* Effect.services<never>()
328
- const semaphore = yield* Effect.makeSemaphore(1)
329
+ const semaphore = yield* Semaphore.make(1)
329
330
 
330
331
  const provideContext = <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
331
332
  Effect.updateServices(effect, (existing) => ServiceMap.merge(services, existing))
@@ -86,7 +86,7 @@ const constEmptyObject = () => ({})
86
86
  * @since 4.0.0
87
87
  * @category models
88
88
  */
89
- export const ProviderOptions: Schema.Record$<
89
+ export const ProviderOptions: Schema.$Record<
90
90
  Schema.String,
91
91
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
92
92
  > = Schema.Record(Schema.String, Schema.NullOr(Schema.Json))
@@ -309,7 +309,7 @@ export const TextPart: Schema.Struct<
309
309
  readonly text: Schema.String
310
310
  readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>
311
311
  readonly options: Schema.withDecodingDefault<
312
- Schema.Record$<
312
+ Schema.$Record<
313
313
  Schema.String,
314
314
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
315
315
  >
@@ -389,7 +389,7 @@ export const ReasoningPart: Schema.Struct<{
389
389
  readonly text: Schema.String
390
390
  readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>
391
391
  readonly options: Schema.withDecodingDefault<
392
- Schema.Record$<
392
+ Schema.$Record<
393
393
  Schema.String,
394
394
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
395
395
  >
@@ -497,7 +497,7 @@ export const FilePart: Schema.Struct<{
497
497
  readonly data: Schema.Union<readonly [Schema.String, Schema.Uint8Array, Schema.URL]>
498
498
  readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>
499
499
  readonly options: Schema.withDecodingDefault<
500
- Schema.Record$<
500
+ Schema.$Record<
501
501
  Schema.String,
502
502
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
503
503
  >
@@ -607,7 +607,7 @@ export const ToolCallPart: Schema.Struct<{
607
607
  readonly providerExecuted: Schema.withDecodingDefault<Schema.Boolean>
608
608
  readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>
609
609
  readonly options: Schema.withDecodingDefault<
610
- Schema.Record$<
610
+ Schema.$Record<
611
611
  Schema.String,
612
612
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
613
613
  >
@@ -723,7 +723,7 @@ export const ToolResultPart: Schema.Struct<{
723
723
  readonly result: Schema.Unknown
724
724
  readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>
725
725
  readonly options: Schema.withDecodingDefault<
726
- Schema.Record$<
726
+ Schema.$Record<
727
727
  Schema.String,
728
728
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
729
729
  >
@@ -841,7 +841,7 @@ export const ToolApprovalResponsePart: Schema.Struct<{
841
841
  readonly reason: Schema.optional<Schema.String>
842
842
  readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>
843
843
  readonly options: Schema.withDecodingDefault<
844
- Schema.Record$<
844
+ Schema.$Record<
845
845
  Schema.String,
846
846
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
847
847
  >
@@ -942,7 +942,7 @@ export const ToolApprovalRequestPart: Schema.Struct<{
942
942
  readonly toolCallId: Schema.String
943
943
  readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>
944
944
  readonly options: Schema.withDecodingDefault<
945
- Schema.Record$<
945
+ Schema.$Record<
946
946
  Schema.String,
947
947
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
948
948
  >
@@ -1087,7 +1087,7 @@ export const ContentFromString: Schema.decodeTo<
1087
1087
  readonly text: Schema.String
1088
1088
  readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>
1089
1089
  readonly options: Schema.withDecodingDefault<
1090
- Schema.Record$<
1090
+ Schema.$Record<
1091
1091
  Schema.String,
1092
1092
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
1093
1093
  >
@@ -1166,7 +1166,7 @@ export const SystemMessage: Schema.Struct<{
1166
1166
  readonly content: Schema.String
1167
1167
  readonly "~effect/ai/Prompt/Message": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Message">>
1168
1168
  readonly options: Schema.withDecodingDefault<
1169
- Schema.Record$<
1169
+ Schema.$Record<
1170
1170
  Schema.String,
1171
1171
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
1172
1172
  >
@@ -1285,7 +1285,7 @@ export const UserMessage: Schema.Struct<{
1285
1285
  readonly text: Schema.String
1286
1286
  readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>
1287
1287
  readonly options: Schema.withDecodingDefault<
1288
- Schema.Record$<
1288
+ Schema.$Record<
1289
1289
  Schema.String,
1290
1290
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
1291
1291
  >
@@ -1297,7 +1297,7 @@ export const UserMessage: Schema.Struct<{
1297
1297
  never,
1298
1298
  never
1299
1299
  >,
1300
- Schema.Array$<
1300
+ Schema.$Array<
1301
1301
  Schema.Union<
1302
1302
  readonly [
1303
1303
  Schema.Struct<{
@@ -1305,7 +1305,7 @@ export const UserMessage: Schema.Struct<{
1305
1305
  readonly text: Schema.String
1306
1306
  readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>
1307
1307
  readonly options: Schema.withDecodingDefault<
1308
- Schema.Record$<
1308
+ Schema.$Record<
1309
1309
  Schema.String,
1310
1310
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
1311
1311
  >
@@ -1318,7 +1318,7 @@ export const UserMessage: Schema.Struct<{
1318
1318
  readonly data: Schema.Union<readonly [Schema.String, Schema.Uint8Array, Schema.URL]>
1319
1319
  readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>
1320
1320
  readonly options: Schema.withDecodingDefault<
1321
- Schema.Record$<
1321
+ Schema.$Record<
1322
1322
  Schema.String,
1323
1323
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
1324
1324
  >
@@ -1331,7 +1331,7 @@ export const UserMessage: Schema.Struct<{
1331
1331
  >
1332
1332
  readonly "~effect/ai/Prompt/Message": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Message">>
1333
1333
  readonly options: Schema.withDecodingDefault<
1334
- Schema.Record$<
1334
+ Schema.$Record<
1335
1335
  Schema.String,
1336
1336
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
1337
1337
  >
@@ -1470,7 +1470,7 @@ export const AssistantMessage: Schema.Struct<{
1470
1470
  readonly text: Schema.String
1471
1471
  readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>
1472
1472
  readonly options: Schema.withDecodingDefault<
1473
- Schema.Record$<
1473
+ Schema.$Record<
1474
1474
  Schema.String,
1475
1475
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
1476
1476
  >
@@ -1482,7 +1482,7 @@ export const AssistantMessage: Schema.Struct<{
1482
1482
  never,
1483
1483
  never
1484
1484
  >,
1485
- Schema.Array$<
1485
+ Schema.$Array<
1486
1486
  Schema.Union<
1487
1487
  readonly [
1488
1488
  typeof TextPart,
@@ -1498,7 +1498,7 @@ export const AssistantMessage: Schema.Struct<{
1498
1498
  >
1499
1499
  readonly "~effect/ai/Prompt/Message": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Message">>
1500
1500
  readonly options: Schema.withDecodingDefault<
1501
- Schema.Record$<
1501
+ Schema.$Record<
1502
1502
  Schema.String,
1503
1503
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
1504
1504
  >
@@ -1613,12 +1613,12 @@ export interface ToolMessageOptions extends ProviderOptions {}
1613
1613
  */
1614
1614
  export const ToolMessage: Schema.Struct<{
1615
1615
  readonly role: Schema.Literal<"tool">
1616
- readonly content: Schema.Array$<
1616
+ readonly content: Schema.$Array<
1617
1617
  Schema.Union<readonly [typeof ToolResultPart, typeof ToolApprovalResponsePart]>
1618
1618
  >
1619
1619
  readonly "~effect/ai/Prompt/Message": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Message">>
1620
1620
  readonly options: Schema.withDecodingDefault<
1621
- Schema.Record$<
1621
+ Schema.$Record<
1622
1622
  Schema.String,
1623
1623
  Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json>>
1624
1624
  >