effect 4.0.0-beta.93 → 4.0.0-beta.97

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 (488) hide show
  1. package/dist/Array.d.ts.map +1 -1
  2. package/dist/BigDecimal.d.ts.map +1 -1
  3. package/dist/BigDecimal.js.map +1 -1
  4. package/dist/BigInt.d.ts.map +1 -1
  5. package/dist/Boolean.d.ts.map +1 -1
  6. package/dist/Brand.d.ts.map +1 -1
  7. package/dist/Cache.d.ts.map +1 -1
  8. package/dist/Cause.d.ts.map +1 -1
  9. package/dist/Channel.d.ts.map +1 -1
  10. package/dist/ChannelSchema.d.ts.map +1 -1
  11. package/dist/Chunk.d.ts.map +1 -1
  12. package/dist/Combiner.d.ts.map +1 -1
  13. package/dist/Config.d.ts +1 -1
  14. package/dist/Config.d.ts.map +1 -1
  15. package/dist/Config.js.map +1 -1
  16. package/dist/ConfigProvider.d.ts +44 -6
  17. package/dist/ConfigProvider.d.ts.map +1 -1
  18. package/dist/ConfigProvider.js +63 -24
  19. package/dist/ConfigProvider.js.map +1 -1
  20. package/dist/Console.d.ts.map +1 -1
  21. package/dist/Context.d.ts.map +1 -1
  22. package/dist/Cron.d.ts +4 -1
  23. package/dist/Cron.d.ts.map +1 -1
  24. package/dist/Cron.js +98 -53
  25. package/dist/Cron.js.map +1 -1
  26. package/dist/Crypto.d.ts.map +1 -1
  27. package/dist/Data.d.ts.map +1 -1
  28. package/dist/DateTime.d.ts +12 -12
  29. package/dist/DateTime.d.ts.map +1 -1
  30. package/dist/Deferred.d.ts.map +1 -1
  31. package/dist/Duration.d.ts.map +1 -1
  32. package/dist/Effect.d.ts +130 -0
  33. package/dist/Effect.d.ts.map +1 -1
  34. package/dist/Effect.js +43 -0
  35. package/dist/Effect.js.map +1 -1
  36. package/dist/Effectable.d.ts.map +1 -1
  37. package/dist/Encoding.d.ts.map +1 -1
  38. package/dist/Equal.d.ts.map +1 -1
  39. package/dist/Equivalence.d.ts.map +1 -1
  40. package/dist/ErrorReporter.d.ts.map +1 -1
  41. package/dist/ExecutionPlan.d.ts +2 -2
  42. package/dist/ExecutionPlan.d.ts.map +1 -1
  43. package/dist/Fiber.d.ts.map +1 -1
  44. package/dist/FiberHandle.d.ts +8 -8
  45. package/dist/FiberHandle.d.ts.map +1 -1
  46. package/dist/FiberMap.d.ts +8 -8
  47. package/dist/FiberMap.d.ts.map +1 -1
  48. package/dist/FiberSet.d.ts +4 -4
  49. package/dist/FiberSet.d.ts.map +1 -1
  50. package/dist/FileSystem.d.ts +7 -0
  51. package/dist/FileSystem.d.ts.map +1 -1
  52. package/dist/FileSystem.js +3 -0
  53. package/dist/FileSystem.js.map +1 -1
  54. package/dist/Filter.d.ts.map +1 -1
  55. package/dist/Function.d.ts.map +1 -1
  56. package/dist/Graph.d.ts.map +1 -1
  57. package/dist/Graph.js.map +1 -1
  58. package/dist/Hash.d.ts.map +1 -1
  59. package/dist/HashMap.d.ts.map +1 -1
  60. package/dist/HashRing.d.ts.map +1 -1
  61. package/dist/Inspectable.d.ts.map +1 -1
  62. package/dist/Inspectable.js.map +1 -1
  63. package/dist/Iterable.d.ts.map +1 -1
  64. package/dist/Latch.d.ts.map +1 -1
  65. package/dist/Layer.d.ts +1 -1
  66. package/dist/Layer.d.ts.map +1 -1
  67. package/dist/Layer.js +6 -3
  68. package/dist/Layer.js.map +1 -1
  69. package/dist/LayerMap.d.ts.map +1 -1
  70. package/dist/LayerMap.js +1 -1
  71. package/dist/LayerMap.js.map +1 -1
  72. package/dist/LayerRef.d.ts +252 -0
  73. package/dist/LayerRef.d.ts.map +1 -0
  74. package/dist/LayerRef.js +171 -0
  75. package/dist/LayerRef.js.map +1 -0
  76. package/dist/LogLevel.d.ts.map +1 -1
  77. package/dist/Logger.d.ts.map +1 -1
  78. package/dist/ManagedRuntime.d.ts.map +1 -1
  79. package/dist/Metric.d.ts.map +1 -1
  80. package/dist/MutableHashMap.d.ts.map +1 -1
  81. package/dist/MutableHashSet.d.ts.map +1 -1
  82. package/dist/MutableList.d.ts.map +1 -1
  83. package/dist/MutableRef.d.ts.map +1 -1
  84. package/dist/NonEmptyIterable.d.ts.map +1 -1
  85. package/dist/Number.d.ts.map +1 -1
  86. package/dist/Optic.d.ts.map +1 -1
  87. package/dist/Option.d.ts.map +1 -1
  88. package/dist/Order.d.ts.map +1 -1
  89. package/dist/Ordering.d.ts.map +1 -1
  90. package/dist/PartitionedSemaphore.d.ts.map +1 -1
  91. package/dist/Pipeable.d.ts.map +1 -1
  92. package/dist/PlatformError.d.ts.map +1 -1
  93. package/dist/Pool.d.ts.map +1 -1
  94. package/dist/PrimaryKey.d.ts.map +1 -1
  95. package/dist/PubSub.d.ts.map +1 -1
  96. package/dist/Pull.d.ts.map +1 -1
  97. package/dist/Queue.d.ts.map +1 -1
  98. package/dist/Random.d.ts.map +1 -1
  99. package/dist/RcMap.d.ts.map +1 -1
  100. package/dist/Record.d.ts.map +1 -1
  101. package/dist/Redactable.d.ts.map +1 -1
  102. package/dist/Redacted.d.ts.map +1 -1
  103. package/dist/Ref.d.ts.map +1 -1
  104. package/dist/RegExp.d.ts.map +1 -1
  105. package/dist/Request.d.ts +1 -1
  106. package/dist/Request.d.ts.map +1 -1
  107. package/dist/RequestResolver.d.ts.map +1 -1
  108. package/dist/Resource.d.ts.map +1 -1
  109. package/dist/Result.d.ts.map +1 -1
  110. package/dist/Runtime.d.ts.map +1 -1
  111. package/dist/Schedule.d.ts +1206 -4013
  112. package/dist/Schedule.d.ts.map +1 -1
  113. package/dist/Schedule.js +244 -1348
  114. package/dist/Schedule.js.map +1 -1
  115. package/dist/Scheduler.d.ts.map +1 -1
  116. package/dist/Scheduler.js.map +1 -1
  117. package/dist/Schema.d.ts +123 -30
  118. package/dist/Schema.d.ts.map +1 -1
  119. package/dist/Schema.js +40 -0
  120. package/dist/Schema.js.map +1 -1
  121. package/dist/SchemaAST.d.ts.map +1 -1
  122. package/dist/SchemaAST.js.map +1 -1
  123. package/dist/SchemaGetter.d.ts.map +1 -1
  124. package/dist/SchemaIssue.d.ts.map +1 -1
  125. package/dist/SchemaIssue.js.map +1 -1
  126. package/dist/SchemaParser.d.ts +1 -1
  127. package/dist/SchemaParser.d.ts.map +1 -1
  128. package/dist/SchemaParser.js.map +1 -1
  129. package/dist/SchemaRepresentation.d.ts +106 -106
  130. package/dist/SchemaTransformation.d.ts +38 -2
  131. package/dist/SchemaTransformation.d.ts.map +1 -1
  132. package/dist/SchemaTransformation.js +38 -2
  133. package/dist/SchemaTransformation.js.map +1 -1
  134. package/dist/ScopedCache.d.ts.map +1 -1
  135. package/dist/ScopedRef.d.ts.map +1 -1
  136. package/dist/Semaphore.d.ts.map +1 -1
  137. package/dist/Sink.d.ts.map +1 -1
  138. package/dist/Stdio.d.ts.map +1 -1
  139. package/dist/Stream.d.ts +2 -2
  140. package/dist/Stream.d.ts.map +1 -1
  141. package/dist/Stream.js +1 -1
  142. package/dist/String.d.ts.map +1 -1
  143. package/dist/String.js.map +1 -1
  144. package/dist/Struct.d.ts.map +1 -1
  145. package/dist/SubscriptionRef.d.ts.map +1 -1
  146. package/dist/SynchronizedRef.d.ts.map +1 -1
  147. package/dist/Take.d.ts.map +1 -1
  148. package/dist/Terminal.d.ts.map +1 -1
  149. package/dist/Tracer.d.ts.map +1 -1
  150. package/dist/Trie.d.ts.map +1 -1
  151. package/dist/Tuple.d.ts.map +1 -1
  152. package/dist/TxChunk.d.ts.map +1 -1
  153. package/dist/TxDeferred.d.ts.map +1 -1
  154. package/dist/TxHashMap.d.ts.map +1 -1
  155. package/dist/TxHashSet.d.ts.map +1 -1
  156. package/dist/TxPriorityQueue.d.ts.map +1 -1
  157. package/dist/TxPubSub.d.ts.map +1 -1
  158. package/dist/TxQueue.d.ts.map +1 -1
  159. package/dist/TxReentrantLock.d.ts.map +1 -1
  160. package/dist/TxRef.d.ts.map +1 -1
  161. package/dist/TxSemaphore.d.ts.map +1 -1
  162. package/dist/TxSubscriptionRef.d.ts.map +1 -1
  163. package/dist/Types.d.ts +1 -1
  164. package/dist/Types.d.ts.map +1 -1
  165. package/dist/UndefinedOr.d.ts.map +1 -1
  166. package/dist/Utils.d.ts.map +1 -1
  167. package/dist/internal/effect.js +2 -0
  168. package/dist/internal/effect.js.map +1 -1
  169. package/dist/internal/schema/schema.d.ts.map +1 -1
  170. package/dist/testing/TestClock.d.ts.map +1 -1
  171. package/dist/testing/TestConsole.d.ts.map +1 -1
  172. package/dist/testing/TestSchema.d.ts +2 -2
  173. package/dist/testing/TestSchema.d.ts.map +1 -1
  174. package/dist/testing/TestSchema.js.map +1 -1
  175. package/dist/unstable/ai/AiError.d.ts +1 -1
  176. package/dist/unstable/ai/AiError.d.ts.map +1 -1
  177. package/dist/unstable/ai/Chat.d.ts +2 -2
  178. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  179. package/dist/unstable/ai/IdGenerator.d.ts.map +1 -1
  180. package/dist/unstable/ai/LanguageModel.d.ts +2 -2
  181. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  182. package/dist/unstable/ai/McpSchema.d.ts +221 -221
  183. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  184. package/dist/unstable/ai/McpServer.d.ts.map +1 -1
  185. package/dist/unstable/ai/Model.d.ts.map +1 -1
  186. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  187. package/dist/unstable/ai/Response.d.ts.map +1 -1
  188. package/dist/unstable/ai/Telemetry.d.ts.map +1 -1
  189. package/dist/unstable/ai/Tokenizer.d.ts.map +1 -1
  190. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  191. package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
  192. package/dist/unstable/cli/Argument.d.ts +2 -2
  193. package/dist/unstable/cli/Argument.d.ts.map +1 -1
  194. package/dist/unstable/cli/Argument.js.map +1 -1
  195. package/dist/unstable/cli/CliError.d.ts.map +1 -1
  196. package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
  197. package/dist/unstable/cli/Command.d.ts.map +1 -1
  198. package/dist/unstable/cli/Completions.d.ts.map +1 -1
  199. package/dist/unstable/cli/Flag.d.ts +2 -2
  200. package/dist/unstable/cli/Flag.d.ts.map +1 -1
  201. package/dist/unstable/cli/Flag.js.map +1 -1
  202. package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -1
  203. package/dist/unstable/cli/Param.d.ts +2 -2
  204. package/dist/unstable/cli/Param.d.ts.map +1 -1
  205. package/dist/unstable/cli/Param.js.map +1 -1
  206. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  207. package/dist/unstable/cli/Primitive.js.map +1 -1
  208. package/dist/unstable/cli/Prompt.d.ts.map +1 -1
  209. package/dist/unstable/cli/Prompt.js.map +1 -1
  210. package/dist/unstable/cli/internal/ansi.d.ts.map +1 -1
  211. package/dist/unstable/cli/internal/ansi.js.map +1 -1
  212. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  213. package/dist/unstable/cli/internal/help.d.ts.map +1 -1
  214. package/dist/unstable/cli/internal/parser.js.map +1 -1
  215. package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
  216. package/dist/unstable/cluster/ClusterCron.js +1 -1
  217. package/dist/unstable/cluster/ClusterCron.js.map +1 -1
  218. package/dist/unstable/cluster/ClusterError.d.ts.map +1 -1
  219. package/dist/unstable/cluster/ClusterSchema.d.ts +1 -1
  220. package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
  221. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +1 -1
  222. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  223. package/dist/unstable/cluster/ClusterWorkflowEngine.js +2 -1
  224. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  225. package/dist/unstable/cluster/DeliverAt.d.ts.map +1 -1
  226. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  227. package/dist/unstable/cluster/Entity.js +5 -3
  228. package/dist/unstable/cluster/Entity.js.map +1 -1
  229. package/dist/unstable/cluster/EntityAddress.d.ts.map +1 -1
  230. package/dist/unstable/cluster/EntityId.d.ts.map +1 -1
  231. package/dist/unstable/cluster/EntityProxy.d.ts.map +1 -1
  232. package/dist/unstable/cluster/EntityProxyServer.d.ts.map +1 -1
  233. package/dist/unstable/cluster/EntityType.d.ts.map +1 -1
  234. package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
  235. package/dist/unstable/cluster/HttpRunner.d.ts.map +1 -1
  236. package/dist/unstable/cluster/MachineId.d.ts.map +1 -1
  237. package/dist/unstable/cluster/Message.d.ts.map +1 -1
  238. package/dist/unstable/cluster/MessageStorage.d.ts +25 -29
  239. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  240. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  241. package/dist/unstable/cluster/Runner.d.ts.map +1 -1
  242. package/dist/unstable/cluster/RunnerAddress.d.ts.map +1 -1
  243. package/dist/unstable/cluster/RunnerHealth.d.ts.map +1 -1
  244. package/dist/unstable/cluster/RunnerServer.d.ts +1 -1
  245. package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
  246. package/dist/unstable/cluster/Runners.d.ts +8 -8
  247. package/dist/unstable/cluster/ShardId.d.ts.map +1 -1
  248. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  249. package/dist/unstable/cluster/Sharding.js +6 -5
  250. package/dist/unstable/cluster/Sharding.js.map +1 -1
  251. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  252. package/dist/unstable/cluster/ShardingRegistrationEvent.d.ts +6 -8
  253. package/dist/unstable/cluster/ShardingRegistrationEvent.d.ts.map +1 -1
  254. package/dist/unstable/cluster/SingleRunner.d.ts.map +1 -1
  255. package/dist/unstable/cluster/Singleton.d.ts.map +1 -1
  256. package/dist/unstable/cluster/SingletonAddress.d.ts.map +1 -1
  257. package/dist/unstable/cluster/Snowflake.d.ts +1 -1
  258. package/dist/unstable/cluster/Snowflake.d.ts.map +1 -1
  259. package/dist/unstable/cluster/Snowflake.js +1 -1
  260. package/dist/unstable/cluster/Snowflake.js.map +1 -1
  261. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  262. package/dist/unstable/cluster/SqlRunnerStorage.d.ts +1 -1
  263. package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
  264. package/dist/unstable/cluster/internal/entityManager.js +14 -14
  265. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  266. package/dist/unstable/cluster/internal/resourceMap.js +39 -14
  267. package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
  268. package/dist/unstable/devtools/DevTools.d.ts.map +1 -1
  269. package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
  270. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  271. package/dist/unstable/encoding/Sse.d.ts +2 -2
  272. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  273. package/dist/unstable/eventlog/Event.d.ts.map +1 -1
  274. package/dist/unstable/eventlog/EventGroup.d.ts.map +1 -1
  275. package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
  276. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  277. package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
  278. package/dist/unstable/eventlog/EventLog.js +2 -2
  279. package/dist/unstable/eventlog/EventLog.js.map +1 -1
  280. package/dist/unstable/eventlog/EventLogEncryption.d.ts.map +1 -1
  281. package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
  282. package/dist/unstable/eventlog/EventLogRemote.d.ts +21 -21
  283. package/dist/unstable/eventlog/EventLogServer.d.ts.map +1 -1
  284. package/dist/unstable/eventlog/EventLogServerEncrypted.d.ts +1 -1
  285. package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts +3 -4
  286. package/dist/unstable/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
  287. package/dist/unstable/eventlog/EventLogSessionAuth.d.ts.map +1 -1
  288. package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
  289. package/dist/unstable/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -1
  290. package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -1
  291. package/dist/unstable/http/Cookies.d.ts +1 -1
  292. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  293. package/dist/unstable/http/Etag.d.ts.map +1 -1
  294. package/dist/unstable/http/Headers.d.ts.map +1 -1
  295. package/dist/unstable/http/HttpBody.d.ts.map +1 -1
  296. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  297. package/dist/unstable/http/HttpClientError.d.ts +1 -1
  298. package/dist/unstable/http/HttpClientError.d.ts.map +1 -1
  299. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  300. package/dist/unstable/http/HttpClientResponse.d.ts +1 -1
  301. package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
  302. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  303. package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
  304. package/dist/unstable/http/HttpIncomingMessage.d.ts +2 -2
  305. package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
  306. package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
  307. package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
  308. package/dist/unstable/http/HttpMiddleware.d.ts +1 -1
  309. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  310. package/dist/unstable/http/HttpRouter.d.ts +4 -4
  311. package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
  312. package/dist/unstable/http/HttpRouter.js.map +1 -1
  313. package/dist/unstable/http/HttpServer.d.ts.map +1 -1
  314. package/dist/unstable/http/HttpServerError.d.ts +1 -1
  315. package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
  316. package/dist/unstable/http/HttpServerRequest.d.ts +8 -8
  317. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  318. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  319. package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
  320. package/dist/unstable/http/HttpServerResponse.d.ts +1 -1
  321. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  322. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  323. package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -1
  324. package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
  325. package/dist/unstable/http/Multipart.d.ts +4 -3
  326. package/dist/unstable/http/Multipart.d.ts.map +1 -1
  327. package/dist/unstable/http/Multipart.js.map +1 -1
  328. package/dist/unstable/http/Url.d.ts.map +1 -1
  329. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  330. package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
  331. package/dist/unstable/httpapi/HttpApi.js +2 -4
  332. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  333. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  334. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  335. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  336. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +26 -26
  337. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  338. package/dist/unstable/httpapi/HttpApiError.d.ts +1 -1
  339. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  340. package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
  341. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
  342. package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
  343. package/dist/unstable/httpapi/HttpApiSchema.d.ts +1 -1
  344. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  345. package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
  346. package/dist/unstable/httpapi/HttpApiSwagger.d.ts.map +1 -1
  347. package/dist/unstable/httpapi/HttpApiTest.d.ts +1 -1
  348. package/dist/unstable/observability/Otlp.d.ts.map +1 -1
  349. package/dist/unstable/observability/OtlpExporter.js +3 -1
  350. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  351. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  352. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  353. package/dist/unstable/observability/OtlpResource.d.ts.map +1 -1
  354. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  355. package/dist/unstable/observability/PrometheusMetrics.d.ts.map +1 -1
  356. package/dist/unstable/observability/internal/otlpEnv.d.ts.map +1 -1
  357. package/dist/unstable/persistence/KeyValueStore.d.ts.map +1 -1
  358. package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
  359. package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
  360. package/dist/unstable/persistence/PersistedQueue.d.ts +1 -1
  361. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  362. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  363. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  364. package/dist/unstable/persistence/Redis.d.ts.map +1 -1
  365. package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
  366. package/dist/unstable/process/ChildProcess.js.map +1 -1
  367. package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
  368. package/dist/unstable/reactivity/AsyncResult.d.ts +2 -2
  369. package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
  370. package/dist/unstable/reactivity/Atom.d.ts +4 -4
  371. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  372. package/dist/unstable/reactivity/Atom.js.map +1 -1
  373. package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
  374. package/dist/unstable/reactivity/AtomRef.d.ts.map +1 -1
  375. package/dist/unstable/reactivity/AtomRegistry.d.ts +2 -2
  376. package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
  377. package/dist/unstable/reactivity/AtomRegistry.js +28 -37
  378. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  379. package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
  380. package/dist/unstable/reactivity/Hydration.d.ts.map +1 -1
  381. package/dist/unstable/reactivity/Reactivity.d.ts.map +1 -1
  382. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  383. package/dist/unstable/rpc/RpcClient.d.ts +2 -1
  384. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  385. package/dist/unstable/rpc/RpcClient.js +5 -5
  386. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  387. package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
  388. package/dist/unstable/rpc/RpcMessage.d.ts +7 -7
  389. package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
  390. package/dist/unstable/rpc/RpcMessage.js +2 -2
  391. package/dist/unstable/rpc/RpcMessage.js.map +1 -1
  392. package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
  393. package/dist/unstable/rpc/RpcSchema.d.ts +1 -1
  394. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  395. package/dist/unstable/rpc/RpcSerialization.js +8 -8
  396. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  397. package/dist/unstable/rpc/RpcServer.d.ts +2 -2
  398. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  399. package/dist/unstable/rpc/RpcServer.js +5 -5
  400. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  401. package/dist/unstable/rpc/RpcWorker.d.ts.map +1 -1
  402. package/dist/unstable/rpc/Utils.d.ts.map +1 -1
  403. package/dist/unstable/schema/Model.d.ts +24 -38
  404. package/dist/unstable/schema/Model.d.ts.map +1 -1
  405. package/dist/unstable/schema/VariantSchema.d.ts +1 -1
  406. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  407. package/dist/unstable/socket/Socket.d.ts +1 -1
  408. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  409. package/dist/unstable/socket/SocketServer.d.ts.map +1 -1
  410. package/dist/unstable/sql/Migrator.d.ts.map +1 -1
  411. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  412. package/dist/unstable/sql/SqlError.d.ts +2 -2
  413. package/dist/unstable/sql/SqlError.d.ts.map +1 -1
  414. package/dist/unstable/sql/SqlError.js.map +1 -1
  415. package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
  416. package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
  417. package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
  418. package/dist/unstable/sql/SqlStream.d.ts.map +1 -1
  419. package/dist/unstable/sql/Statement.d.ts.map +1 -1
  420. package/dist/unstable/workers/Transferable.d.ts.map +1 -1
  421. package/dist/unstable/workers/Worker.d.ts.map +1 -1
  422. package/dist/unstable/workers/WorkerError.d.ts.map +1 -1
  423. package/dist/unstable/workflow/Activity.d.ts +1 -1
  424. package/dist/unstable/workflow/Activity.d.ts.map +1 -1
  425. package/dist/unstable/workflow/Activity.js +1 -1
  426. package/dist/unstable/workflow/Activity.js.map +1 -1
  427. package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
  428. package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
  429. package/dist/unstable/workflow/DurableQueue.d.ts.map +1 -1
  430. package/dist/unstable/workflow/DurableQueue.js +1 -1
  431. package/dist/unstable/workflow/DurableQueue.js.map +1 -1
  432. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  433. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  434. package/dist/unstable/workflow/WorkflowEngine.js +1 -1
  435. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  436. package/dist/unstable/workflow/WorkflowProxy.d.ts.map +1 -1
  437. package/dist/unstable/workflow/WorkflowProxyServer.d.ts.map +1 -1
  438. package/package.json +11 -12
  439. package/src/Config.ts +1 -1
  440. package/src/ConfigProvider.ts +79 -27
  441. package/src/Cron.ts +109 -57
  442. package/src/Effect.ts +131 -0
  443. package/src/FileSystem.ts +13 -0
  444. package/src/Layer.ts +6 -6
  445. package/src/LayerMap.ts +1 -1
  446. package/src/LayerRef.ts +379 -0
  447. package/src/Schedule.ts +1437 -4445
  448. package/src/Schema.ts +133 -33
  449. package/src/SchemaParser.ts +2 -2
  450. package/src/SchemaTransformation.ts +42 -2
  451. package/src/Stream.ts +1 -1
  452. package/src/internal/effect.ts +19 -0
  453. package/src/testing/TestSchema.ts +2 -2
  454. package/src/unstable/ai/Chat.ts +1 -1
  455. package/src/unstable/ai/LanguageModel.ts +3 -3
  456. package/src/unstable/cli/Argument.ts +14 -7
  457. package/src/unstable/cli/Flag.ts +6 -3
  458. package/src/unstable/cli/Param.ts +6 -3
  459. package/src/unstable/cli/Primitive.ts +2 -2
  460. package/src/unstable/cluster/ClusterCron.ts +4 -3
  461. package/src/unstable/cluster/ClusterWorkflowEngine.ts +5 -3
  462. package/src/unstable/cluster/Entity.ts +13 -14
  463. package/src/unstable/cluster/Sharding.ts +137 -134
  464. package/src/unstable/cluster/Snowflake.ts +2 -2
  465. package/src/unstable/cluster/internal/entityManager.ts +27 -25
  466. package/src/unstable/cluster/internal/resourceMap.ts +59 -25
  467. package/src/unstable/encoding/Sse.ts +3 -3
  468. package/src/unstable/eventlog/EventLog.ts +4 -3
  469. package/src/unstable/http/HttpClientResponse.ts +2 -3
  470. package/src/unstable/http/HttpIncomingMessage.ts +4 -5
  471. package/src/unstable/http/HttpRouter.ts +8 -10
  472. package/src/unstable/http/HttpServerRequest.ts +20 -19
  473. package/src/unstable/http/HttpServerResponse.ts +2 -2
  474. package/src/unstable/http/Multipart.ts +3 -3
  475. package/src/unstable/httpapi/HttpApi.ts +2 -4
  476. package/src/unstable/httpapi/HttpApiClient.ts +2 -2
  477. package/src/unstable/httpapi/HttpApiEndpoint.ts +7 -7
  478. package/src/unstable/httpapi/HttpApiSchema.ts +1 -1
  479. package/src/unstable/observability/OtlpExporter.ts +1 -1
  480. package/src/unstable/reactivity/Atom.ts +10 -7
  481. package/src/unstable/reactivity/AtomRegistry.ts +35 -44
  482. package/src/unstable/rpc/RpcClient.ts +10 -9
  483. package/src/unstable/rpc/RpcMessage.ts +8 -9
  484. package/src/unstable/rpc/RpcSerialization.ts +16 -16
  485. package/src/unstable/rpc/RpcServer.ts +5 -5
  486. package/src/unstable/workflow/Activity.ts +6 -5
  487. package/src/unstable/workflow/DurableQueue.ts +4 -3
  488. package/src/unstable/workflow/WorkflowEngine.ts +4 -3
@@ -38,7 +38,7 @@ import * as Semaphore from "../../Semaphore.ts"
38
38
  import * as Stream from "../../Stream.ts"
39
39
  import type * as Rpc from "../rpc/Rpc.ts"
40
40
  import * as RpcClient from "../rpc/RpcClient.ts"
41
- import { type FromServer, RequestId } from "../rpc/RpcMessage.ts"
41
+ import type { FromServer } from "../rpc/RpcMessage.ts"
42
42
  import type { MailboxFull, PersistenceError } from "./ClusterError.ts"
43
43
  import { AlreadyProcessingMessage, EntityNotAssignedToRunner } from "./ClusterError.ts"
44
44
  import * as ClusterMetrics from "./ClusterMetrics.ts"
@@ -1034,148 +1034,151 @@ const make = Effect.gen(function*() {
1034
1034
  MailboxFull | AlreadyProcessingMessage
1035
1035
  >,
1036
1036
  never
1037
- > = yield* ResourceMap.make(Effect.fnUntraced(function*(entity: Entity<string, any>) {
1038
- const client = yield* RpcClient.makeNoSerialization(entity.protocol, {
1039
- spanPrefix: `${entity.type}.client`,
1040
- disableTracing: !Context.get(entity.protocol.annotations, ClusterSchema.ClientTracingEnabled),
1041
- supportsAck: true,
1042
- generateRequestId: () => RequestId(snowflakeGen.nextUnsafe()),
1043
- flatten: true,
1044
- onFromClient(options): Effect.Effect<
1045
- void,
1046
- MailboxFull | AlreadyProcessingMessage | PersistenceError
1047
- > {
1048
- const address = Context.getUnsafe(options.context, ClientAddressTag)
1049
- switch (options.message._tag) {
1050
- case "Request": {
1051
- const fiber = Fiber.getCurrent()!
1052
- const id = Snowflake.Snowflake(options.message.id)
1053
- const rpc = entity.protocol.requests.get(options.message.tag)!
1054
- let respond: (reply: Reply.Reply<any>) => Effect.Effect<void>
1055
- const envelope = Envelope.makeRequest<any>({
1056
- requestId: id,
1057
- address,
1058
- tag: options.message.tag,
1059
- payload: options.message.payload,
1060
- headers: options.message.headers,
1061
- traceId: options.message.traceId,
1062
- spanId: options.message.spanId,
1063
- sampled: options.message.sampled
1064
- })
1065
- const message = new Message.OutgoingRequest({
1066
- envelope,
1067
- lastReceivedReply: Option.none(),
1068
- rpc,
1069
- context: fiber.context as Context.Context<any>,
1070
- respond: (reply) => respond(reply),
1071
- annotations: Context.get(rpc.annotations, ClusterSchema.Dynamic)(
1072
- rpc.annotations,
1073
- envelope as any
1074
- )
1075
- })
1076
- if (!options.discard) {
1077
- const entry: ClientRequestEntry = {
1078
- rpc: rpc as any,
1079
- context: fiber.currentContext,
1080
- message
1037
+ > = yield* ResourceMap.make(
1038
+ Effect.fnUntraced(function*(entity: Entity<string, any>) {
1039
+ const client = yield* RpcClient.makeNoSerialization(entity.protocol, {
1040
+ spanPrefix: `${entity.type}.client`,
1041
+ disableTracing: !Context.get(entity.protocol.annotations, ClusterSchema.ClientTracingEnabled),
1042
+ supportsAck: true,
1043
+ generateRequestId: () => snowflakeGen.nextUnsafe() as any,
1044
+ flatten: true,
1045
+ onFromClient(options): Effect.Effect<
1046
+ void,
1047
+ MailboxFull | AlreadyProcessingMessage | PersistenceError
1048
+ > {
1049
+ const address = Context.getUnsafe(options.context, ClientAddressTag)
1050
+ switch (options.message._tag) {
1051
+ case "Request": {
1052
+ const fiber = Fiber.getCurrent()!
1053
+ const id = Snowflake.Snowflake(options.message.id)
1054
+ const rpc = entity.protocol.requests.get(options.message.tag)!
1055
+ let respond: (reply: Reply.Reply<any>) => Effect.Effect<void>
1056
+ const envelope = Envelope.makeRequest<any>({
1057
+ requestId: id,
1058
+ address,
1059
+ tag: options.message.tag,
1060
+ payload: options.message.payload,
1061
+ headers: options.message.headers,
1062
+ traceId: options.message.traceId,
1063
+ spanId: options.message.spanId,
1064
+ sampled: options.message.sampled
1065
+ })
1066
+ const message = new Message.OutgoingRequest({
1067
+ envelope,
1068
+ lastReceivedReply: Option.none(),
1069
+ rpc,
1070
+ context: fiber.context as Context.Context<any>,
1071
+ respond: (reply) => respond(reply),
1072
+ annotations: Context.get(rpc.annotations, ClusterSchema.Dynamic)(
1073
+ rpc.annotations,
1074
+ envelope as any
1075
+ )
1076
+ })
1077
+ if (!options.discard) {
1078
+ const entry: ClientRequestEntry = {
1079
+ rpc: rpc as any,
1080
+ context: fiber.currentContext,
1081
+ message
1082
+ }
1083
+ clientRequests.set(id, entry)
1084
+ respond = makeClientRespond(entry, client.write)
1085
+ } else {
1086
+ respond = clientRespondDiscard
1081
1087
  }
1082
- clientRequests.set(id, entry)
1083
- respond = makeClientRespond(entry, client.write)
1084
- } else {
1085
- respond = clientRespondDiscard
1088
+ return sendOutgoing(message, options.discard)
1086
1089
  }
1087
- return sendOutgoing(message, options.discard)
1088
- }
1089
- case "Ack": {
1090
- const requestId = Snowflake.Snowflake(options.message.requestId)
1091
- const entry = clientRequests.get(requestId)
1092
- if (!entry) return Effect.void
1093
- return sendOutgoing(
1094
- new Message.OutgoingEnvelope({
1095
- envelope: new Envelope.AckChunk({
1096
- id: snowflakeGen.nextUnsafe(),
1097
- address,
1098
- requestId,
1099
- replyId: entry.lastChunkId!
1090
+ case "Ack": {
1091
+ const requestId = Snowflake.Snowflake(options.message.requestId)
1092
+ const entry = clientRequests.get(requestId)
1093
+ if (!entry) return Effect.void
1094
+ return sendOutgoing(
1095
+ new Message.OutgoingEnvelope({
1096
+ envelope: new Envelope.AckChunk({
1097
+ id: snowflakeGen.nextUnsafe(),
1098
+ address,
1099
+ requestId,
1100
+ replyId: entry.lastChunkId!
1101
+ }),
1102
+ rpc: entry.rpc
1100
1103
  }),
1101
- rpc: entry.rpc
1102
- }),
1103
- false
1104
- )
1105
- }
1106
- case "Interrupt": {
1107
- const requestId = Snowflake.Snowflake(options.message.requestId)
1108
- const entry = clientRequests.get(requestId)!
1109
- if (!entry) return Effect.void
1110
- clientRequests.delete(requestId)
1111
- if (ClusterSchema.isUninterruptibleForClient(entry.message.annotations)) {
1112
- return Effect.void
1113
- }
1114
- // for durable messages, we ignore interrupts on shutdown or as a
1115
- // result of a shard being resassigned
1116
- const isTransientInterrupt = MutableRef.get(isShutdown) ||
1117
- options.message.interruptors.some((id) => internalInterruptors.has(id))
1118
- if (isTransientInterrupt && Context.get(entry.message.annotations, Persisted)) {
1119
- return Effect.void
1104
+ false
1105
+ )
1120
1106
  }
1121
- return Effect.ignore(sendOutgoing(
1122
- new Message.OutgoingEnvelope({
1123
- envelope: new Envelope.Interrupt({
1124
- id: snowflakeGen.nextUnsafe(),
1125
- address,
1126
- requestId
1107
+ case "Interrupt": {
1108
+ const requestId = Snowflake.Snowflake(options.message.requestId)
1109
+ const entry = clientRequests.get(requestId)!
1110
+ if (!entry) return Effect.void
1111
+ clientRequests.delete(requestId)
1112
+ if (ClusterSchema.isUninterruptibleForClient(entry.message.annotations)) {
1113
+ return Effect.void
1114
+ }
1115
+ // for durable messages, we ignore interrupts on shutdown or as a
1116
+ // result of a shard being resassigned
1117
+ const isTransientInterrupt = MutableRef.get(isShutdown) ||
1118
+ options.message.interruptors.some((id) => internalInterruptors.has(id))
1119
+ if (isTransientInterrupt && Context.get(entry.message.annotations, Persisted)) {
1120
+ return Effect.void
1121
+ }
1122
+ return Effect.ignore(sendOutgoing(
1123
+ new Message.OutgoingEnvelope({
1124
+ envelope: new Envelope.Interrupt({
1125
+ id: snowflakeGen.nextUnsafe(),
1126
+ address,
1127
+ requestId
1128
+ }),
1129
+ rpc: entry.rpc
1127
1130
  }),
1128
- rpc: entry.rpc
1129
- }),
1130
- false,
1131
- 3
1132
- ))
1131
+ false,
1132
+ 3
1133
+ ))
1134
+ }
1133
1135
  }
1136
+ return Effect.void
1134
1137
  }
1135
- return Effect.void
1136
- }
1137
- })
1138
-
1139
- yield* Scope.addFinalizer(
1140
- yield* Effect.scope,
1141
- Effect.withFiber((fiber) => {
1142
- internalInterruptors.add(fiber.id)
1143
- return Effect.void
1144
1138
  })
1145
- )
1146
1139
 
1147
- return (entityId: string) => {
1148
- const id = makeEntityId(entityId)
1149
- const address = ClientAddressTag.context(makeEntityAddress({
1150
- shardId: getShardId(id, entity.getShardGroup(entityId as EntityId)),
1151
- entityId: id,
1152
- entityType: entity.type
1153
- }))
1154
- const clientFn = function(tag: string, payload: any, options?: {
1155
- readonly context?: Context.Context<never>
1156
- }) {
1157
- const context = options?.context ? Context.merge(options.context, address) : address
1158
- return client.client(tag, payload, {
1159
- ...options,
1160
- context
1140
+ yield* Scope.addFinalizer(
1141
+ yield* Effect.scope,
1142
+ Effect.withFiber((fiber) => {
1143
+ internalInterruptors.add(fiber.id)
1144
+ return Effect.void
1161
1145
  })
1162
- }
1163
- const proxyClient: any = {}
1164
- return new Proxy(proxyClient, {
1165
- has(_, p) {
1166
- return entity.protocol.requests.has(p as string)
1167
- },
1168
- get(target, p) {
1169
- if (p in target) {
1170
- return target[p]
1171
- } else if (!entity.protocol.requests.has(p as string)) {
1172
- return undefined
1173
- }
1174
- return target[p] = (payload: any, options?: {}) => clientFn(p as string, payload, options)
1146
+ )
1147
+
1148
+ return (entityId: string) => {
1149
+ const id = makeEntityId(entityId)
1150
+ const address = ClientAddressTag.context(makeEntityAddress({
1151
+ shardId: getShardId(id, entity.getShardGroup(entityId as EntityId)),
1152
+ entityId: id,
1153
+ entityType: entity.type
1154
+ }))
1155
+ const clientFn = function(tag: string, payload: any, options?: {
1156
+ readonly context?: Context.Context<never>
1157
+ }) {
1158
+ const context = options?.context ? Context.merge(options.context, address) : address
1159
+ return client.client(tag, payload, {
1160
+ ...options,
1161
+ context
1162
+ })
1175
1163
  }
1176
- })
1177
- }
1178
- }))
1164
+ const proxyClient: any = {}
1165
+ return new Proxy(proxyClient, {
1166
+ has(_, p) {
1167
+ return entity.protocol.requests.has(p as string)
1168
+ },
1169
+ get(target, p) {
1170
+ if (p in target) {
1171
+ return target[p]
1172
+ } else if (!entity.protocol.requests.has(p as string)) {
1173
+ return undefined
1174
+ }
1175
+ return target[p] = (payload: any, options?: {}) => clientFn(p as string, payload, options)
1176
+ }
1177
+ })
1178
+ }
1179
+ }),
1180
+ { referential: true }
1181
+ )
1179
1182
 
1180
1183
  const makeClient = <Type extends string, Rpcs extends Rpc.Any>(entity: Entity<Type, Rpcs>): Effect.Effect<
1181
1184
  (
@@ -1196,7 +1199,7 @@ const make = Effect.gen(function*() {
1196
1199
  return write({
1197
1200
  _tag: "Chunk",
1198
1201
  clientId: 0,
1199
- requestId: RequestId(reply.requestId),
1202
+ requestId: reply.requestId as any,
1200
1203
  values: reply.values
1201
1204
  })
1202
1205
  }
@@ -1205,7 +1208,7 @@ const make = Effect.gen(function*() {
1205
1208
  return write({
1206
1209
  _tag: "Exit",
1207
1210
  clientId: 0,
1208
- requestId: RequestId(reply.requestId),
1211
+ requestId: reply.requestId as any,
1209
1212
  exit: reply.exit
1210
1213
  })
1211
1214
  }
@@ -53,8 +53,8 @@ export type Snowflake = Brand.Branded<bigint, TypeId>
53
53
  * @category constructors
54
54
  * @since 4.0.0
55
55
  */
56
- export const Snowflake = (input: string | bigint): Snowflake =>
57
- typeof input === "string" ? BigInt(input) as Snowflake : input as Snowflake
56
+ export const Snowflake = (input: string | number | bigint): Snowflake =>
57
+ typeof input === "bigint" ? input as Snowflake : BigInt(input) as Snowflake
58
58
 
59
59
  /**
60
60
  * Namespace containing support types for snowflake parts and generators.
@@ -18,7 +18,6 @@ import * as Schema from "../../../Schema.ts"
18
18
  import * as SchemaIssue from "../../../SchemaIssue.ts"
19
19
  import * as Scope from "../../../Scope.ts"
20
20
  import type * as Rpc from "../../rpc/Rpc.ts"
21
- import { RequestId } from "../../rpc/RpcMessage.ts"
22
21
  import * as RpcServer from "../../rpc/RpcServer.ts"
23
22
  import { AlreadyProcessingMessage, EntityNotAssignedToRunner, MailboxFull, MalformedMessage } from "../ClusterError.ts"
24
23
  import * as ClusterMetrics from "../ClusterMetrics.ts"
@@ -67,7 +66,7 @@ export interface EntityManager {
67
66
  export type EntityState = {
68
67
  readonly address: EntityAddress
69
68
  readonly scope: Scope.Scope
70
- readonly activeRequests: Map<bigint, {
69
+ readonly activeRequests: Map<Snowflake.Snowflake, {
71
70
  readonly rpc: Rpc.AnyWithProps
72
71
  readonly message: Message.IncomingRequestLocal<any>
73
72
  sentReply: boolean
@@ -145,7 +144,7 @@ export const make = Effect.fnUntraced(function*<
145
144
  )
146
145
 
147
146
  const activeRequests: EntityState["activeRequests"] = new Map()
148
- let defectRequestIds = new Set<bigint>()
147
+ let defectRequestIds = new Set<Snowflake.Snowflake>()
149
148
  let isRestartingDueToDefect = false
150
149
 
151
150
  // the server is stored in a ref, so if there is a defect, we can
@@ -155,16 +154,18 @@ export const make = Effect.fnUntraced(function*<
155
154
  Effect.fnUntraced(function*(scope) {
156
155
  let isShuttingDown = false
157
156
 
157
+ const handlerContext = Context.mutate(context, (context) =>
158
+ context.pipe(
159
+ Context.add(CurrentAddress, address),
160
+ Context.add(CurrentRunnerAddress, options.runnerAddress),
161
+ Context.add(KeepAliveLatch, keepAliveLatch),
162
+ Context.add(Scope.Scope, scope),
163
+ Context.add(CurrentLogAnnotations, {})
164
+ ))
165
+
158
166
  // Initiate the behavior for the entity
159
167
  const handlers = yield* (entity.protocol.toHandlers(buildHandlers as any).pipe(
160
- Effect.provideService(CurrentLogAnnotations, {}),
161
- Effect.provideContext(Context.mutate(context, (context) =>
162
- context.pipe(
163
- Context.add(CurrentAddress, address),
164
- Context.add(CurrentRunnerAddress, options.runnerAddress),
165
- Context.add(KeepAliveLatch, keepAliveLatch),
166
- Context.add(Scope.Scope, scope)
167
- ))),
168
+ Effect.setContext(handlerContext as Context.Context<any>),
168
169
  Effect.sandbox,
169
170
  Effect.tapError((cause) => Effect.logError("Defect building entity handlers", cause)),
170
171
  Effect.retry(defectRetryPolicy)
@@ -182,7 +183,7 @@ export const make = Effect.fnUntraced(function*<
182
183
  onFromServer(response): Effect.Effect<void> {
183
184
  switch (response._tag) {
184
185
  case "Exit": {
185
- const request = activeRequests.get(response.requestId)
186
+ const request = activeRequests.get(Snowflake.Snowflake(response.requestId))
186
187
  if (!request) return Effect.void
187
188
 
188
189
  request.sentReply = true
@@ -190,7 +191,7 @@ export const make = Effect.fnUntraced(function*<
190
191
  if (
191
192
  isShuttingDown &&
192
193
  Exit.hasInterrupts(response.exit) &&
193
- defectRequestIds.has(response.requestId)
194
+ defectRequestIds.has(Snowflake.Snowflake(response.requestId))
194
195
  ) {
195
196
  return Effect.void
196
197
  }
@@ -208,7 +209,7 @@ export const make = Effect.fnUntraced(function*<
208
209
  if (!isShuttingDown) {
209
210
  return server.write(0, {
210
211
  ...request.message.envelope,
211
- id: RequestId(request.message.envelope.requestId),
212
+ id: request.message.envelope.requestId as any,
212
213
  tag: request.message.envelope.tag as any,
213
214
  payload: new Request({
214
215
  ...request.message.envelope,
@@ -218,7 +219,7 @@ export const make = Effect.fnUntraced(function*<
218
219
  Effect.forkIn(scope)
219
220
  )
220
221
  }
221
- activeRequests.delete(response.requestId)
222
+ activeRequests.delete(Snowflake.Snowflake(response.requestId))
222
223
  return options.storage.unregisterReplyHandler(request.message.envelope.requestId)
223
224
  }
224
225
  return retryRespond(
@@ -235,7 +236,7 @@ export const make = Effect.fnUntraced(function*<
235
236
  ).pipe(
236
237
  Effect.flatMap(() => {
237
238
  processedRequestIds.add(request.message.envelope.requestId)
238
- activeRequests.delete(response.requestId)
239
+ activeRequests.delete(Snowflake.Snowflake(response.requestId))
239
240
 
240
241
  // ensure that the reaper does not remove the entity as we haven't
241
242
  // been "idle" yet
@@ -249,7 +250,7 @@ export const make = Effect.fnUntraced(function*<
249
250
  )
250
251
  }
251
252
  case "Chunk": {
252
- const request = activeRequests.get(response.requestId)
253
+ const request = activeRequests.get(Snowflake.Snowflake(response.requestId))
253
254
  if (!request) return Effect.void
254
255
  const sequence = request.sequence
255
256
  request.sequence++
@@ -280,7 +281,7 @@ export const make = Effect.fnUntraced(function*<
280
281
  }
281
282
  }).pipe(
282
283
  Scope.provide(scope),
283
- Effect.provideContext(handlers)
284
+ Effect.setContext(Context.merge(handlerContext, handlers))
284
285
  )
285
286
 
286
287
  yield* Scope.addFinalizer(
@@ -297,7 +298,7 @@ export const make = Effect.fnUntraced(function*<
297
298
  const { lastSentChunk, message } = request
298
299
  yield* server.write(0, {
299
300
  ...message.envelope,
300
- id: RequestId(message.envelope.requestId),
301
+ id: message.envelope.requestId as any,
301
302
  tag: message.envelope.tag as any,
302
303
  payload: new Request({
303
304
  ...message.envelope,
@@ -473,7 +474,7 @@ export const make = Effect.fnUntraced(function*<
473
474
  server.activeRequests.set(message.envelope.requestId, entry)
474
475
  let write = server.write(0, {
475
476
  ...message.envelope,
476
- id: RequestId(message.envelope.requestId),
477
+ id: message.envelope.requestId as any,
477
478
  payload: new Request({
478
479
  ...message.envelope,
479
480
  lastSentChunk: Option.filter(
@@ -501,10 +502,10 @@ export const make = Effect.fnUntraced(function*<
501
502
  return server.write(
502
503
  0,
503
504
  message.envelope._tag === "AckChunk"
504
- ? { _tag: "Ack", requestId: RequestId(message.envelope.requestId) }
505
+ ? { _tag: "Ack", requestId: message.envelope.requestId as any }
505
506
  : {
506
507
  _tag: "Interrupt",
507
- requestId: RequestId(message.envelope.requestId),
508
+ requestId: message.envelope.requestId as any,
508
509
  interruptors: []
509
510
  }
510
511
  )
@@ -609,9 +610,10 @@ export const make = Effect.fnUntraced(function*<
609
610
  })
610
611
  })
611
612
 
612
- const defaultRetryPolicy = Schedule.exponential(500, 1.5).pipe(
613
- Schedule.either(Schedule.spaced("10 seconds"))
614
- )
613
+ const defaultRetryPolicy = Schedule.min([
614
+ Schedule.exponential(500, 1.5),
615
+ Schedule.spaced("10 seconds")
616
+ ])
615
617
 
616
618
  const makeMessageDecode = <Type extends string, Rpcs extends Rpc.Any>(
617
619
  entity: Entity<Type, Rpcs>,
@@ -4,23 +4,16 @@ import * as Effect from "../../../Effect.ts"
4
4
  import * as Exit from "../../../Exit.ts"
5
5
  import * as MutableHashMap from "../../../MutableHashMap.ts"
6
6
  import * as MutableRef from "../../../MutableRef.ts"
7
- import * as Option from "../../../Option.ts"
8
7
  import * as Scope from "../../../Scope.ts"
9
8
 
10
9
  /** @internal */
11
10
  export class ResourceMap<K, A, E> {
12
11
  readonly lookup: (key: K, scope: Scope.Scope) => Effect.Effect<A, E>
13
- readonly entries: MutableHashMap.MutableHashMap<K, {
14
- readonly scope: Scope.Closeable
15
- readonly deferred: Deferred.Deferred<A, E>
16
- }>
12
+ readonly entries: BackingMap<K, A, E>
17
13
  readonly isClosed: MutableRef.MutableRef<boolean>
18
14
  constructor(
19
15
  lookup: (key: K, scope: Scope.Scope) => Effect.Effect<A, E>,
20
- entries: MutableHashMap.MutableHashMap<K, {
21
- readonly scope: Scope.Closeable
22
- readonly deferred: Deferred.Deferred<A, E>
23
- }>,
16
+ entries: BackingMap<K, A, E>,
24
17
  isClosed: MutableRef.MutableRef<boolean>
25
18
  ) {
26
19
  this.lookup = lookup
@@ -28,22 +21,29 @@ export class ResourceMap<K, A, E> {
28
21
  this.isClosed = isClosed
29
22
  }
30
23
 
31
- static make = Effect.fnUntraced(function*<K, A, E, R>(lookup: (key: K) => Effect.Effect<A, E, R>) {
24
+ static make = Effect.fnUntraced(function*<K, A, E, R>(lookup: (key: K) => Effect.Effect<A, E, R>, options?: {
25
+ readonly referential?: boolean | undefined
26
+ }) {
32
27
  const scope = yield* Effect.scope
33
28
  const services = yield* Effect.context<R>()
34
29
  const isClosed = MutableRef.make(false)
35
30
 
36
- const entries = MutableHashMap.empty<K, {
37
- scope: Scope.Closeable
38
- deferred: Deferred.Deferred<A, E>
39
- }>()
31
+ const entries: BackingMap<K, A, E> = options?.referential ?
32
+ {
33
+ _tag: "Referential",
34
+ map: new Map()
35
+ } :
36
+ {
37
+ _tag: "Equal",
38
+ map: MutableHashMap.empty()
39
+ }
40
40
 
41
41
  yield* Scope.addFinalizerExit(
42
42
  scope,
43
43
  (exit) => {
44
44
  MutableRef.set(isClosed, true)
45
- return Effect.forEach(entries, ([key, { scope }]) => {
46
- MutableHashMap.remove(entries, key)
45
+ return Effect.forEach(entries.map, ([key, { scope }]) => {
46
+ backingDelete(entries, key)
47
47
  return Effect.exit(Scope.close(scope, exit))
48
48
  }, { concurrency: "unbounded", discard: true })
49
49
  }
@@ -61,18 +61,18 @@ export class ResourceMap<K, A, E> {
61
61
  if (MutableRef.get(this.isClosed)) {
62
62
  return Effect.interrupt
63
63
  }
64
- const existing = MutableHashMap.get(this.entries, key)
65
- if (Option.isSome(existing)) {
66
- return Deferred.await(existing.value.deferred)
64
+ const existing = backingGet(this.entries, key)
65
+ if (existing) {
66
+ return Deferred.await(existing.deferred)
67
67
  }
68
68
  const scope = Effect.runSync(Scope.make())
69
69
  const deferred = Deferred.makeUnsafe<A, E>()
70
- MutableHashMap.set(this.entries, key, { scope, deferred })
70
+ backingSet(this.entries, key, { scope, deferred })
71
71
  return Effect.onExit(this.lookup(key, scope), (exit) => {
72
72
  if (exit._tag === "Success") {
73
73
  return Deferred.done(deferred, exit)
74
74
  }
75
- MutableHashMap.remove(this.entries, key)
75
+ backingDelete(this.entries, key)
76
76
  return Deferred.done(deferred, exit)
77
77
  })
78
78
  })
@@ -80,12 +80,12 @@ export class ResourceMap<K, A, E> {
80
80
 
81
81
  remove(key: K): Effect.Effect<void> {
82
82
  return Effect.suspend(() => {
83
- const entry = MutableHashMap.get(this.entries, key)
84
- if (Option.isNone(entry)) {
83
+ const entry = backingGet(this.entries, key)
84
+ if (!entry) {
85
85
  return Effect.void
86
86
  }
87
- MutableHashMap.remove(this.entries, key)
88
- return Scope.close(entry.value.scope, Exit.void)
87
+ backingDelete(this.entries, key)
88
+ return Scope.close(entry.scope, Exit.void)
89
89
  })
90
90
  }
91
91
 
@@ -98,3 +98,37 @@ export class ResourceMap<K, A, E> {
98
98
  }))
99
99
  }
100
100
  }
101
+
102
+ type BackingMap<K, A, E> = {
103
+ readonly _tag: "Equal"
104
+ readonly map: MutableHashMap.MutableHashMap<K, Entry<A, E>>
105
+ } | {
106
+ readonly _tag: "Referential"
107
+ readonly map: Map<K, Entry<A, E>>
108
+ }
109
+
110
+ type Entry<A, E> = {
111
+ readonly scope: Scope.Closeable
112
+ readonly deferred: Deferred.Deferred<A, E>
113
+ }
114
+
115
+ const backingGet = <K, A, E>(map: BackingMap<K, A, E>, key: K): Entry<A, E> | undefined => {
116
+ if (map._tag === "Equal") {
117
+ return MutableHashMap.get(map.map, key).valueOrUndefined
118
+ }
119
+ return map.map.get(key)
120
+ }
121
+ const backingSet = <K, A, E>(map: BackingMap<K, A, E>, key: K, entry: Entry<A, E>): void => {
122
+ if (map._tag === "Equal") {
123
+ MutableHashMap.set(map.map, key, entry)
124
+ } else {
125
+ map.map.set(key, entry)
126
+ }
127
+ }
128
+ const backingDelete = <K, A, E>(map: BackingMap<K, A, E>, key: K): void => {
129
+ if (map._tag === "Equal") {
130
+ MutableHashMap.remove(map.map, key)
131
+ } else {
132
+ map.map.delete(key)
133
+ }
134
+ }
@@ -80,15 +80,15 @@ export const decode = <IE, Done>(): Channel.Channel<
80
80
  * @since 4.0.0
81
81
  */
82
82
  export interface EventCodec extends
83
- Schema.Codec<
83
+ Schema.ConstraintCodec<
84
84
  any,
85
85
  {
86
86
  readonly id?: string | undefined
87
87
  readonly event?: string | undefined
88
88
  readonly data: string
89
89
  },
90
- any,
91
- any
90
+ unknown,
91
+ unknown
92
92
  >
93
93
  {}
94
94
 
@@ -854,9 +854,10 @@ const make = Effect.gen(function*() {
854
854
  Effect.scoped,
855
855
  Effect.catchCause(Effect.logError),
856
856
  Effect.repeat(
857
- Schedule.exponential(200, 1.5).pipe(
858
- Schedule.either(Schedule.spaced({ seconds: 10 }))
859
- )
857
+ Schedule.min([
858
+ Schedule.exponential(200, 1.5),
859
+ Schedule.spaced({ seconds: 10 })
860
+ ])
860
861
  ),
861
862
  Effect.annotateLogs({
862
863
  service: "EventLog",