@effect-app/infra 4.0.0-beta.22 → 4.0.0-beta.220

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/CHANGELOG.md +1640 -0
  2. package/_check.sh +1 -1
  3. package/dist/CUPS.d.ts +7 -7
  4. package/dist/CUPS.d.ts.map +1 -1
  5. package/dist/CUPS.js +10 -12
  6. package/dist/Emailer/Sendgrid.d.ts +14 -14
  7. package/dist/Emailer/Sendgrid.d.ts.map +1 -1
  8. package/dist/Emailer/Sendgrid.js +16 -15
  9. package/dist/Emailer/fake.d.ts +1 -1
  10. package/dist/Emailer/service.d.ts +10 -4
  11. package/dist/Emailer/service.d.ts.map +1 -1
  12. package/dist/Emailer/service.js +3 -3
  13. package/dist/Emailer.d.ts +1 -1
  14. package/dist/MainFiberSet.d.ts +9 -9
  15. package/dist/MainFiberSet.d.ts.map +1 -1
  16. package/dist/MainFiberSet.js +3 -3
  17. package/dist/Model/Repository/Registry.d.ts +20 -0
  18. package/dist/Model/Repository/Registry.d.ts.map +1 -0
  19. package/dist/Model/Repository/Registry.js +17 -0
  20. package/dist/Model/Repository/ext.d.ts +33 -15
  21. package/dist/Model/Repository/ext.d.ts.map +1 -1
  22. package/dist/Model/Repository/ext.js +54 -2
  23. package/dist/Model/Repository/internal/internal.d.ts +6 -6
  24. package/dist/Model/Repository/internal/internal.d.ts.map +1 -1
  25. package/dist/Model/Repository/internal/internal.js +103 -51
  26. package/dist/Model/Repository/legacy.d.ts +1 -1
  27. package/dist/Model/Repository/makeRepo.d.ts +7 -6
  28. package/dist/Model/Repository/makeRepo.d.ts.map +1 -1
  29. package/dist/Model/Repository/makeRepo.js +5 -1
  30. package/dist/Model/Repository/service.d.ts +28 -23
  31. package/dist/Model/Repository/service.d.ts.map +1 -1
  32. package/dist/Model/Repository/validation.d.ts +46 -17
  33. package/dist/Model/Repository/validation.d.ts.map +1 -1
  34. package/dist/Model/Repository/validation.js +5 -5
  35. package/dist/Model/Repository.d.ts +2 -1
  36. package/dist/Model/Repository.d.ts.map +1 -1
  37. package/dist/Model/Repository.js +2 -1
  38. package/dist/Model/dsl.d.ts +4 -4
  39. package/dist/Model/dsl.d.ts.map +1 -1
  40. package/dist/Model/filter/filterApi.d.ts +5 -5
  41. package/dist/Model/filter/filterApi.d.ts.map +1 -1
  42. package/dist/Model/filter/types/errors.d.ts +1 -1
  43. package/dist/Model/filter/types/fields.d.ts +1 -1
  44. package/dist/Model/filter/types/path/common.d.ts +1 -1
  45. package/dist/Model/filter/types/path/eager.d.ts +1 -1
  46. package/dist/Model/filter/types/path/eager.d.ts.map +1 -1
  47. package/dist/Model/filter/types/path/eager.js +1 -1
  48. package/dist/Model/filter/types/path/index.d.ts +1 -1
  49. package/dist/Model/filter/types/utils.d.ts +1 -1
  50. package/dist/Model/filter/types/validator.d.ts +1 -1
  51. package/dist/Model/filter/types.d.ts +1 -1
  52. package/dist/Model/query/dsl.d.ts +139 -16
  53. package/dist/Model/query/dsl.d.ts.map +1 -1
  54. package/dist/Model/query/dsl.js +187 -1
  55. package/dist/Model/query/new-kid-interpreter.d.ts +76 -7
  56. package/dist/Model/query/new-kid-interpreter.d.ts.map +1 -1
  57. package/dist/Model/query/new-kid-interpreter.js +122 -6
  58. package/dist/Model/query.d.ts +1 -1
  59. package/dist/Model.d.ts +2 -1
  60. package/dist/Model.d.ts.map +1 -1
  61. package/dist/Model.js +2 -1
  62. package/dist/QueueMaker/SQLQueue.d.ts +5 -7
  63. package/dist/QueueMaker/SQLQueue.d.ts.map +1 -1
  64. package/dist/QueueMaker/SQLQueue.js +130 -116
  65. package/dist/QueueMaker/errors.d.ts +2 -2
  66. package/dist/QueueMaker/errors.d.ts.map +1 -1
  67. package/dist/QueueMaker/memQueue.d.ts +7 -4
  68. package/dist/QueueMaker/memQueue.d.ts.map +1 -1
  69. package/dist/QueueMaker/memQueue.js +75 -63
  70. package/dist/QueueMaker/sbqueue.d.ts +6 -3
  71. package/dist/QueueMaker/sbqueue.d.ts.map +1 -1
  72. package/dist/QueueMaker/sbqueue.js +52 -53
  73. package/dist/QueueMaker/service.d.ts +1 -1
  74. package/dist/RequestContext.d.ts +74 -35
  75. package/dist/RequestContext.d.ts.map +1 -1
  76. package/dist/RequestContext.js +13 -14
  77. package/dist/RequestFiberSet.d.ts +7 -7
  78. package/dist/RequestFiberSet.d.ts.map +1 -1
  79. package/dist/RequestFiberSet.js +3 -3
  80. package/dist/Store/ContextMapContainer.d.ts +19 -3
  81. package/dist/Store/ContextMapContainer.d.ts.map +1 -1
  82. package/dist/Store/ContextMapContainer.js +13 -3
  83. package/dist/Store/Cosmos/query.d.ts +5 -1
  84. package/dist/Store/Cosmos/query.d.ts.map +1 -1
  85. package/dist/Store/Cosmos/query.js +113 -34
  86. package/dist/Store/Cosmos.d.ts +1 -1
  87. package/dist/Store/Cosmos.d.ts.map +1 -1
  88. package/dist/Store/Cosmos.js +335 -243
  89. package/dist/Store/Disk.d.ts +2 -2
  90. package/dist/Store/Disk.d.ts.map +1 -1
  91. package/dist/Store/Disk.js +72 -35
  92. package/dist/Store/Memory.d.ts +6 -4
  93. package/dist/Store/Memory.d.ts.map +1 -1
  94. package/dist/Store/Memory.js +242 -58
  95. package/dist/Store/SQL/Pg.d.ts +4 -0
  96. package/dist/Store/SQL/Pg.d.ts.map +1 -0
  97. package/dist/Store/SQL/Pg.js +231 -0
  98. package/dist/Store/SQL/query.d.ts +42 -0
  99. package/dist/Store/SQL/query.d.ts.map +1 -0
  100. package/dist/Store/SQL/query.js +479 -0
  101. package/dist/Store/SQL.d.ts +20 -0
  102. package/dist/Store/SQL.d.ts.map +1 -0
  103. package/dist/Store/SQL.js +446 -0
  104. package/dist/Store/codeFilter.d.ts +1 -1
  105. package/dist/Store/codeFilter.d.ts.map +1 -1
  106. package/dist/Store/codeFilter.js +4 -2
  107. package/dist/Store/index.d.ts +5 -2
  108. package/dist/Store/index.d.ts.map +1 -1
  109. package/dist/Store/index.js +15 -3
  110. package/dist/Store/service.d.ts +22 -8
  111. package/dist/Store/service.d.ts.map +1 -1
  112. package/dist/Store/service.js +24 -6
  113. package/dist/Store/utils.d.ts +1 -1
  114. package/dist/Store/utils.d.ts.map +1 -1
  115. package/dist/Store/utils.js +3 -4
  116. package/dist/Store.d.ts +1 -1
  117. package/dist/adapters/SQL/Model.d.ts +31 -42
  118. package/dist/adapters/SQL/Model.d.ts.map +1 -1
  119. package/dist/adapters/SQL/Model.js +29 -38
  120. package/dist/adapters/SQL.d.ts +1 -1
  121. package/dist/adapters/ServiceBus.d.ts +11 -11
  122. package/dist/adapters/ServiceBus.d.ts.map +1 -1
  123. package/dist/adapters/ServiceBus.js +25 -21
  124. package/dist/adapters/cosmos-client.d.ts +3 -3
  125. package/dist/adapters/cosmos-client.d.ts.map +1 -1
  126. package/dist/adapters/cosmos-client.js +3 -3
  127. package/dist/adapters/index.d.ts +8 -2
  128. package/dist/adapters/index.d.ts.map +1 -1
  129. package/dist/adapters/index.js +8 -2
  130. package/dist/adapters/logger.d.ts +1 -1
  131. package/dist/adapters/logger.d.ts.map +1 -1
  132. package/dist/adapters/memQueue.d.ts +3 -3
  133. package/dist/adapters/memQueue.d.ts.map +1 -1
  134. package/dist/adapters/memQueue.js +3 -3
  135. package/dist/adapters/mongo-client.d.ts +3 -3
  136. package/dist/adapters/mongo-client.d.ts.map +1 -1
  137. package/dist/adapters/mongo-client.js +3 -3
  138. package/dist/adapters/redis-client.d.ts +3 -3
  139. package/dist/adapters/redis-client.d.ts.map +1 -1
  140. package/dist/adapters/redis-client.js +3 -3
  141. package/dist/api/ContextProvider.d.ts +8 -8
  142. package/dist/api/ContextProvider.d.ts.map +1 -1
  143. package/dist/api/ContextProvider.js +6 -6
  144. package/dist/api/codec.d.ts +1 -1
  145. package/dist/api/internal/RequestContextMiddleware.d.ts +2 -2
  146. package/dist/api/internal/RequestContextMiddleware.d.ts.map +1 -1
  147. package/dist/api/internal/RequestContextMiddleware.js +9 -6
  148. package/dist/api/internal/auth.d.ts +44 -6
  149. package/dist/api/internal/auth.d.ts.map +1 -1
  150. package/dist/api/internal/auth.js +160 -29
  151. package/dist/api/internal/events.d.ts +3 -3
  152. package/dist/api/internal/events.d.ts.map +1 -1
  153. package/dist/api/internal/events.js +10 -8
  154. package/dist/api/internal/health.d.ts +1 -1
  155. package/dist/api/layerUtils.d.ts +6 -6
  156. package/dist/api/layerUtils.d.ts.map +1 -1
  157. package/dist/api/layerUtils.js +5 -5
  158. package/dist/api/middlewares.d.ts +1 -1
  159. package/dist/api/reportError.d.ts +1 -1
  160. package/dist/api/routing/middleware/RouterMiddleware.d.ts +4 -4
  161. package/dist/api/routing/middleware/RouterMiddleware.d.ts.map +1 -1
  162. package/dist/api/routing/middleware/middleware.d.ts +39 -3
  163. package/dist/api/routing/middleware/middleware.d.ts.map +1 -1
  164. package/dist/api/routing/middleware/middleware.js +48 -16
  165. package/dist/api/routing/middleware.d.ts +1 -2
  166. package/dist/api/routing/middleware.d.ts.map +1 -1
  167. package/dist/api/routing/middleware.js +1 -2
  168. package/dist/api/routing/schema/jwt.d.ts +1 -1
  169. package/dist/api/routing/schema/jwt.d.ts.map +1 -1
  170. package/dist/api/routing/tsort.d.ts +1 -1
  171. package/dist/api/routing/tsort.d.ts.map +1 -1
  172. package/dist/api/routing/utils.d.ts +3 -3
  173. package/dist/api/routing/utils.d.ts.map +1 -1
  174. package/dist/api/routing.d.ts +80 -37
  175. package/dist/api/routing.d.ts.map +1 -1
  176. package/dist/api/routing.js +109 -41
  177. package/dist/api/setupRequest.d.ts +8 -5
  178. package/dist/api/setupRequest.d.ts.map +1 -1
  179. package/dist/api/setupRequest.js +12 -7
  180. package/dist/api/util.d.ts +1 -1
  181. package/dist/arbs.d.ts +1 -1
  182. package/dist/arbs.d.ts.map +1 -1
  183. package/dist/arbs.js +5 -3
  184. package/dist/errorReporter.d.ts +4 -4
  185. package/dist/errorReporter.d.ts.map +1 -1
  186. package/dist/errorReporter.js +20 -25
  187. package/dist/errors.d.ts +1 -1
  188. package/dist/fileUtil.d.ts +1 -1
  189. package/dist/fileUtil.d.ts.map +1 -1
  190. package/dist/index.d.ts +1 -1
  191. package/dist/logger/jsonLogger.d.ts +1 -1
  192. package/dist/logger/logFmtLogger.d.ts +1 -1
  193. package/dist/logger/shared.d.ts +1 -1
  194. package/dist/logger/shared.js +2 -2
  195. package/dist/logger.d.ts +1 -1
  196. package/dist/logger.d.ts.map +1 -1
  197. package/dist/otel.d.ts +75 -0
  198. package/dist/otel.d.ts.map +1 -0
  199. package/dist/otel.js +65 -0
  200. package/dist/rateLimit.d.ts +9 -3
  201. package/dist/rateLimit.d.ts.map +1 -1
  202. package/dist/rateLimit.js +5 -11
  203. package/dist/test.d.ts +2 -2
  204. package/dist/test.d.ts.map +1 -1
  205. package/dist/test.js +1 -1
  206. package/dist/vitest.d.ts +1 -1
  207. package/examples/query.ts +42 -38
  208. package/package.json +46 -37
  209. package/src/CUPS.ts +9 -11
  210. package/src/Emailer/Sendgrid.ts +17 -14
  211. package/src/Emailer/service.ts +9 -3
  212. package/src/MainFiberSet.ts +5 -6
  213. package/src/Model/Repository/Registry.ts +33 -0
  214. package/src/Model/Repository/ext.ts +96 -10
  215. package/src/Model/Repository/internal/internal.ts +218 -149
  216. package/src/Model/Repository/makeRepo.ts +12 -10
  217. package/src/Model/Repository/service.ts +31 -22
  218. package/src/Model/Repository/validation.ts +4 -4
  219. package/src/Model/Repository.ts +1 -0
  220. package/src/Model/dsl.ts +3 -3
  221. package/src/Model/filter/types/path/eager.ts +1 -2
  222. package/src/Model/query/dsl.ts +348 -18
  223. package/src/Model/query/new-kid-interpreter.ts +206 -6
  224. package/src/Model.ts +1 -0
  225. package/src/QueueMaker/SQLQueue.ts +144 -152
  226. package/src/QueueMaker/memQueue.ts +104 -103
  227. package/src/QueueMaker/sbqueue.ts +70 -86
  228. package/src/RequestContext.ts +14 -16
  229. package/src/RequestFiberSet.ts +2 -2
  230. package/src/Store/ContextMapContainer.ts +41 -2
  231. package/src/Store/Cosmos/query.ts +140 -43
  232. package/src/Store/Cosmos.ts +482 -349
  233. package/src/Store/Disk.ts +102 -65
  234. package/src/Store/Memory.ts +275 -87
  235. package/src/Store/SQL/Pg.ts +361 -0
  236. package/src/Store/SQL/query.ts +539 -0
  237. package/src/Store/SQL.ts +731 -0
  238. package/src/Store/codeFilter.ts +3 -1
  239. package/src/Store/index.ts +17 -2
  240. package/src/Store/service.ts +41 -10
  241. package/src/Store/utils.ts +23 -22
  242. package/src/adapters/SQL/Model.ts +41 -40
  243. package/src/adapters/ServiceBus.ts +125 -121
  244. package/src/adapters/cosmos-client.ts +2 -2
  245. package/src/adapters/index.ts +7 -0
  246. package/src/adapters/memQueue.ts +2 -2
  247. package/src/adapters/mongo-client.ts +2 -2
  248. package/src/adapters/redis-client.ts +2 -2
  249. package/src/api/ContextProvider.ts +12 -13
  250. package/src/api/internal/RequestContextMiddleware.ts +15 -5
  251. package/src/api/internal/auth.ts +246 -44
  252. package/src/api/internal/events.ts +13 -9
  253. package/src/api/layerUtils.ts +8 -8
  254. package/src/api/routing/middleware/RouterMiddleware.ts +4 -4
  255. package/src/api/routing/middleware/middleware.ts +55 -14
  256. package/src/api/routing/middleware.ts +0 -2
  257. package/src/api/routing.ts +296 -131
  258. package/src/api/setupRequest.ts +28 -8
  259. package/src/arbs.ts +4 -2
  260. package/src/errorReporter.ts +62 -74
  261. package/src/logger/shared.ts +1 -1
  262. package/src/otel.ts +152 -0
  263. package/src/rateLimit.ts +30 -22
  264. package/src/test.ts +1 -1
  265. package/test/auth.test.ts +101 -0
  266. package/test/contextProvider.test.ts +11 -11
  267. package/test/controller.test.ts +21 -30
  268. package/test/dist/auth.test.d.ts.map +1 -0
  269. package/test/dist/contextProvider.test.d.ts.map +1 -1
  270. package/test/dist/controller.test.d.ts.map +1 -1
  271. package/test/dist/date-query.test.d.ts.map +1 -0
  272. package/test/dist/fixtures.d.ts +26 -12
  273. package/test/dist/fixtures.d.ts.map +1 -1
  274. package/test/dist/fixtures.js +12 -10
  275. package/test/dist/query.test.d.ts.map +1 -1
  276. package/test/dist/rawQuery.test.d.ts.map +1 -1
  277. package/test/dist/repository-ext.test.d.ts.map +1 -0
  278. package/test/dist/requires.test.d.ts.map +1 -1
  279. package/test/dist/router-generator.test.d.ts.map +1 -0
  280. package/test/dist/routing-interruptibility.test.d.ts.map +1 -0
  281. package/test/dist/rpc-e2e-invalidation.test.d.ts.map +1 -0
  282. package/test/dist/rpc-multi-middleware.test.d.ts.map +1 -1
  283. package/test/dist/rpc-stream-fullstack.test.d.ts.map +1 -0
  284. package/test/dist/sql-store.test.d.ts.map +1 -0
  285. package/test/fixtures.ts +11 -9
  286. package/test/query.test.ts +813 -38
  287. package/test/rawQuery.test.ts +301 -20
  288. package/test/repository-ext.test.ts +60 -0
  289. package/test/requires.test.ts +6 -6
  290. package/test/router-generator.test.ts +183 -0
  291. package/test/routing-interruptibility.test.ts +63 -0
  292. package/test/rpc-e2e-invalidation.test.ts +251 -0
  293. package/test/rpc-multi-middleware.test.ts +78 -9
  294. package/test/rpc-stream-fullstack.test.ts +300 -0
  295. package/test/sql-store.test.ts +1592 -0
  296. package/test/validateSample.test.ts +15 -12
  297. package/tsconfig.examples.json +1 -1
  298. package/tsconfig.json +0 -1
  299. package/tsconfig.json.bak +2 -2
  300. package/tsconfig.src.json +35 -35
  301. package/tsconfig.test.json +2 -2
  302. package/dist/Operations.d.ts +0 -55
  303. package/dist/Operations.d.ts.map +0 -1
  304. package/dist/Operations.js +0 -102
  305. package/dist/OperationsRepo.d.ts +0 -41
  306. package/dist/OperationsRepo.d.ts.map +0 -1
  307. package/dist/OperationsRepo.js +0 -14
  308. package/eslint.config.mjs +0 -24
  309. package/src/Operations.ts +0 -235
  310. package/src/OperationsRepo.ts +0 -16
@@ -2,22 +2,31 @@
2
2
  /* eslint-disable @typescript-eslint/no-unsafe-argument */
3
3
  /* eslint-disable @typescript-eslint/no-empty-object-type */
4
4
  /* eslint-disable @typescript-eslint/no-explicit-any */
5
- import { Config, Effect, Layer, type NonEmptyReadonlyArray, Predicate, S, type Scope } from "effect-app"
5
+ import { Config, Effect, Layer, type NonEmptyReadonlyArray, Predicate, Ref, S, type Scope, Stream } from "effect-app"
6
+ import { getMeta } from "effect-app/client"
6
7
  import { type HttpHeaders } from "effect-app/http"
8
+ import { Invalidation } from "effect-app/rpc"
7
9
  import { type GetEffectContext, type GetEffectError, type RpcContextMap } from "effect-app/rpc/RpcContextMap"
8
10
  import { type TypeTestId } from "effect-app/TypeTest"
9
11
  import { typedKeysOf, typedValuesOf } from "effect-app/utils"
10
12
  import { type Yieldable } from "effect/Effect"
11
13
  import { Rpc, RpcGroup, type RpcSerialization, RpcServer } from "effect/unstable/rpc"
12
14
  import { type LayerUtils } from "./layerUtils.js"
13
- import { type RouterMiddleware } from "./routing/middleware.js"
15
+ import { RequestType as RequestTypeAnnotation } from "./routing/middleware.js"
14
16
 
15
17
  export * from "./routing/middleware.js"
16
18
 
19
+ export const applyRequestTypeInterruptibility = <A, E, R>(
20
+ requestType: "command" | "query",
21
+ effect: Effect.Effect<A, E, R>
22
+ ) => requestType === "command" ? Rpc.uninterruptible(effect) : effect
23
+
17
24
  // it's the result of extending S.Req setting success, config
18
25
  // it's a schema plus some metadata
19
26
  export type AnyRequestModule = S.Top & {
20
27
  _tag: string // unique identifier for the request module
28
+ type: "command" | "query"
29
+ stream: boolean
21
30
  config: any // ?
22
31
  success: S.Top // validates the success response
23
32
  error: S.Top // validates the failure response
@@ -65,7 +74,10 @@ interface HandlerBase<Action extends AnyRequestModule, RT extends RequestType, A
65
74
  new(): {}
66
75
  _tag: RT
67
76
  stack: string
68
- handler: (req: S.Schema.Type<Action>, headers: HttpHeaders.Headers) => Effect.Effect<A, E, R>
77
+ handler: (
78
+ req: S.Schema.Type<Action>,
79
+ headers: HttpHeaders.Headers
80
+ ) => Effect.Effect<A, E, R> | Stream.Stream<A, E, R>
69
81
  }
70
82
 
71
83
  export interface Handler<Action extends AnyRequestModule, RT extends RequestType, R> extends
@@ -98,35 +110,47 @@ type RpcRouteR<
98
110
  ] ? R
99
111
  : never
100
112
 
101
- type Match<
113
+ type EffectMatch<
102
114
  Resource extends Record<string, any>,
103
115
  RequestContextMap extends Record<string, any>,
104
116
  RT extends RequestType,
105
117
  Key extends keyof Resource
106
- > = {
107
- // note: the defaults of = never prevent the whole router to error (??)
108
- <A extends GetSuccessShape<Resource[Key], RT>, R2 = never, E = never>(
109
- f: Effect.Effect<A, E, R2>
110
- ): Handler<
111
- Resource[Key],
112
- RT,
113
- Exclude<
114
- Exclude<R2, GetEffectContext<RequestContextMap, Resource[Key]["config"]>>,
115
- Scope.Scope
116
- >
118
+ > = <A extends GetSuccessShape<Resource[Key], RT>, R2 = never, E = never>(
119
+ f: (req: S.Schema.Type<Resource[Key]>) => Effect.Effect<A, E, R2>
120
+ ) => Handler<
121
+ Resource[Key],
122
+ RT,
123
+ Exclude<
124
+ Exclude<R2, GetEffectContext<RequestContextMap, Resource[Key]["config"]>>,
125
+ Scope.Scope
117
126
  >
127
+ >
118
128
 
119
- <A extends GetSuccessShape<Resource[Key], RT>, R2 = never, E = never>(
120
- f: (req: S.Schema.Type<Resource[Key]>) => Effect.Effect<A, E, R2>
121
- ): Handler<
122
- Resource[Key],
123
- RT,
124
- Exclude<
125
- Exclude<R2, GetEffectContext<RequestContextMap, Resource[Key]["config"]>>,
126
- Scope.Scope
127
- >
129
+ type StreamMatch<
130
+ Resource extends Record<string, any>,
131
+ RequestContextMap extends Record<string, any>,
132
+ RT extends RequestType,
133
+ Key extends keyof Resource
134
+ > = <A extends GetSuccessShape<Resource[Key], RT>, R2 = never, E = never>(
135
+ f: (req: S.Schema.Type<Resource[Key]>) => Stream.Stream<A, E, R2>
136
+ ) => Handler<
137
+ Resource[Key],
138
+ RT,
139
+ Exclude<
140
+ Exclude<R2, GetEffectContext<RequestContextMap, Resource[Key]["config"]>>,
141
+ Scope.Scope
128
142
  >
129
- }
143
+ >
144
+
145
+ // Stream resources only accept Stream / Effect<Stream> handlers; non-stream resources
146
+ // only accept Effect handlers. Discriminated by the request module's `stream` flag.
147
+ type Match<
148
+ Resource extends Record<string, any>,
149
+ RequestContextMap extends Record<string, any>,
150
+ RT extends RequestType,
151
+ Key extends keyof Resource
152
+ > = Resource[Key] extends { stream: true } ? StreamMatch<Resource, RequestContextMap, RT, Key>
153
+ : EffectMatch<Resource, RequestContextMap, RT, Key>
130
154
 
131
155
  export type RouteMatcher<
132
156
  RequestContextMap extends Record<string, any>,
@@ -156,38 +180,81 @@ export const skipOnProd = Effect
156
180
  })
157
181
  .pipe(Effect.orDie)
158
182
 
159
- export const makeRouter = <
160
- Self,
161
- RequestContextMap extends Record<string, RpcContextMap.Any>,
162
- MakeMiddlewareE,
163
- MakeMiddlewareR,
164
- ContextProviderA,
165
- ContextProviderE,
166
- ContextProviderR,
167
- RequestContextId
168
- >(
169
- middleware: RouterMiddleware<
170
- Self,
171
- RequestContextMap,
172
- MakeMiddlewareE,
173
- MakeMiddlewareR,
174
- ContextProviderA,
175
- ContextProviderE,
176
- ContextProviderR,
177
- RequestContextId
178
- >
183
+ // Type helpers to extract middleware information from a resource's request classes.
184
+ type MiddlewareOf<M extends Record<string, any>> = Exclude<
185
+ { [K in keyof M]: M[K] extends { readonly middleware?: infer MW } ? NonNullable<MW> : never }[keyof M],
186
+ never
187
+ >
188
+ type ProvidesOf<MW> = MW extends { readonly provides: infer P } ? P : never
189
+ type RequestContextMapOf<MW> = MW extends {
190
+ requestContextMap: infer RCM extends Record<string, RpcContextMap.Any>
191
+ } ? RCM
192
+ : Record<string, never>
193
+ type LayerNormalize<L> = L extends Layer.Layer<any, infer E, infer R> ? Layer.Layer<never, E, R>
194
+ : Layer.Layer<never, never, never>
195
+ type LayerSuccess<L> = L extends Layer.Layer<infer A, any, any> ? A : never
196
+
197
+ /**
198
+ * Middleware tags are typically passed to `makeRpcClient` as the class value, so
199
+ * the captured `MW` is a constructor type. Layers carry the *instance* type as
200
+ * their success channel. Bridge the two so the constraint compares like-with-like.
201
+ *
202
+ * Effect middleware classes declare `new(_: never): Shape` which the standard
203
+ * `T extends abstract new (...args: any) => infer I` form sometimes fails to
204
+ * narrow. Use the `prototype` member instead — it is always the instance type.
205
+ */
206
+ type MWService<MW> = MW extends { readonly prototype: infer P } ? P : MW
207
+
208
+ /**
209
+ * Type-level guard: emits a structural mismatch on `Resource` when the middleware
210
+ * service identifier extracted from the resource's request classes is not provided
211
+ * by the layer passed to `makeRouter`. When `MW` is `never` (no middleware on the
212
+ * resource) or already a subtype of the layer's success, this resolves to `unknown`
213
+ * and intersects harmlessly with `Resource`.
214
+ */
215
+ type EnsureMiddlewareProvided<Live, MW> = [MW] extends [never] ? unknown
216
+ : [MWService<MW>] extends [LayerSuccess<Live>] ? unknown
217
+ : {
218
+ readonly __middlewareNotProvidedByRouterLayer: {
219
+ readonly expected: MWService<MW>
220
+ readonly providedByLayer: LayerSuccess<Live>
221
+ }
222
+ }
223
+
224
+ // Safe wrappers that check the constraint before calling GetEffectContext/GetEffectError.
225
+ // These avoid TypeScript constraint errors when the RC map type is deferred (generic).
226
+ type SafeGetEffectContext<RCM, Config> = RCM extends Record<string, RpcContextMap.Any> ? GetEffectContext<RCM, Config>
227
+ : never
228
+ type SafeGetEffectError<RCM, Config> = RCM extends Record<string, RpcContextMap.Any> ? GetEffectError<RCM, Config>
229
+ : never
230
+
231
+ export const makeRouter = <Live extends Layer.Layer<any, any, any> = Layer.Layer<any, never, never>>(
232
+ middlewareLive?: Live
179
233
  ) => {
234
+ type ResourceMWDefault = LayerNormalize<Live>
235
+
180
236
  /**
181
- * Create a Router for specified resource
182
- * if `check` is provided, the router will only be created if the effect succeeds with true
237
+ * Create a Router for specified resource.
238
+ * Middleware schema/tag is read from the request classes (stored via `makeRpcClient`).
239
+ * The middleware **Live** layer is the one passed to `makeRouter`.
240
+ * If `check` is provided, the router will only be created if the effect succeeds with true.
183
241
  */
184
242
  function matchFor<
185
- const ModuleName extends string,
186
- const Resource extends Record<string, any>
243
+ const Resource extends Record<string, any>,
244
+ MW = MiddlewareOf<Resource>
187
245
  >(
188
- rsc: Resource & { meta: { moduleName: ModuleName } },
246
+ rsc: Resource & EnsureMiddlewareProvided<Live, MW>,
189
247
  options?: { check?: Effect.Effect<boolean> }
190
248
  ) {
249
+ // MW is a defaulted type parameter so TypeScript evaluates MiddlewareOf<Resource>
250
+ // eagerly at each call site, producing a concrete type instead of a deferred conditional.
251
+ type ResourceRequestContextMap = RequestContextMapOf<MW>
252
+ type ResourceContextProviderA = ProvidesOf<MW>
253
+
254
+ type HandlerContext<Action extends AnyRequestModule> =
255
+ | SafeGetEffectContext<ResourceRequestContextMap, Action["config"]>
256
+ | ResourceContextProviderA
257
+
191
258
  type HandlerWithInputGen<
192
259
  Action extends AnyRequestModule,
193
260
  RT extends RequestType
@@ -200,7 +267,7 @@ export const makeRouter = <
200
267
  S.Schema.Type<GetFailure<Action>> | S.SchemaError,
201
268
  // the actual implementation of the handler may just require the dynamic context provided by the middleware
202
269
  // and the per request context provided by the context provider
203
- GetEffectContext<RequestContextMap, Action["config"]> | ContextProviderA
270
+ HandlerContext<Action>
204
271
  >,
205
272
  GetSuccessShape<Action, RT>,
206
273
  never
@@ -216,40 +283,41 @@ export const makeRouter = <
216
283
  S.Schema.Type<GetFailure<Action>> | S.SchemaError,
217
284
  // the actual implementation of the handler may just require the dynamic context provided by the middleware
218
285
  // and the per request context provided by the context provider
219
- GetEffectContext<RequestContextMap, Action["config"]> | ContextProviderA
286
+ HandlerContext<Action>
220
287
  >
221
288
 
222
- type HandlerEff<
289
+ type HandlerWithInputStream<
223
290
  Action extends AnyRequestModule,
224
291
  RT extends RequestType
225
- > = Effect.Effect<
292
+ > = (
293
+ req: S.Schema.Type<Action>
294
+ ) => Stream.Stream<
226
295
  GetSuccessShape<Action, RT>,
227
296
  S.Schema.Type<GetFailure<Action>> | S.SchemaError,
228
- // the actual implementation of the handler may just require the dynamic context provided by the middleware
229
- // and the per request context provided by the context provider
230
- GetEffectContext<RequestContextMap, Action["config"]> | ContextProviderA
297
+ HandlerContext<Action>
231
298
  >
232
299
 
233
- type Handlers<Action extends AnyRequestModule, RT extends RequestType> =
234
- | HandlerWithInputGen<Action, RT>
235
- | HandlerWithInputEff<Action, RT>
236
- | HandlerEff<Action, RT>
300
+ // Stream resources only accept `(req) => Stream`; non-stream only Effect / Generator.
301
+ type Handlers<Action extends AnyRequestModule, RT extends RequestType> = Action extends { stream: true }
302
+ ? HandlerWithInputStream<Action, RT>
303
+ : HandlerWithInputGen<Action, RT> | HandlerWithInputEff<Action, RT>
237
304
 
238
305
  type HandlersDecoded<Action extends AnyRequestModule> = Handlers<Action, RequestTypes.DECODED>
239
306
 
240
- type HandlersRaw<Action extends AnyRequestModule> =
241
- | { raw: HandlerWithInputGen<Action, RequestTypes.RAW> }
242
- | { raw: HandlerWithInputEff<Action, RequestTypes.RAW> }
243
- | { raw: HandlerEff<Action, RequestTypes.RAW> }
307
+ type HandlersRaw<Action extends AnyRequestModule> = Action extends { stream: true }
308
+ ? { raw: HandlerWithInputStream<Action, RequestTypes.RAW> }
309
+ :
310
+ | { raw: HandlerWithInputGen<Action, RequestTypes.RAW> }
311
+ | { raw: HandlerWithInputEff<Action, RequestTypes.RAW> }
244
312
 
245
313
  type AnyHandlers<Action extends AnyRequestModule> = HandlersRaw<Action> | HandlersDecoded<Action>
246
314
 
247
- const { meta } = rsc
315
+ const meta = getMeta(rsc)
248
316
 
249
317
  type RequestModules = FilterRequestModules<Resource>
250
318
  const requestModules = typedKeysOf(rsc).reduce((acc, cur) => {
251
319
  if (Predicate.isObjectKeyword(rsc[cur]) && rsc[cur]["success"]) {
252
- acc[cur as keyof RequestModules] = rsc[cur] as RequestModules[keyof RequestModules]
320
+ acc[cur as keyof RequestModules] = rsc[cur]
253
321
  }
254
322
  return acc
255
323
  }, {} as RequestModules)
@@ -260,19 +328,13 @@ export const makeRouter = <
260
328
  // handlerImpl is the actual handler implementation
261
329
  if (handlerImpl[Symbol.toStringTag] === "GeneratorFunction") handlerImpl = Effect.fnUntraced(handlerImpl)
262
330
  const stack = new Error().stack?.split("\n").slice(2).join("\n")
263
- return Effect.isEffect(handlerImpl)
264
- ? class {
265
- static request = rsc[cur]
266
- static stack = stack
267
- static _tag = RequestTypes.DECODED
268
- static handler = () => handlerImpl
269
- }
270
- : class {
271
- static request = rsc[cur]
272
- static stack = stack
273
- static _tag = RequestTypes.DECODED
274
- static handler = handlerImpl
275
- }
331
+ // oxlint-disable-next-line typescript/no-extraneous-class
332
+ return class {
333
+ static request = rsc[cur]
334
+ static stack = stack
335
+ static _tag = RequestTypes.DECODED
336
+ static handler = handlerImpl
337
+ }
276
338
  }, {
277
339
  success: rsc[cur].success,
278
340
  successRaw: S.toEncoded(rsc[cur].success),
@@ -283,24 +345,18 @@ export const makeRouter = <
283
345
  (handlerImpl: any) => {
284
346
  if (handlerImpl[Symbol.toStringTag] === "GeneratorFunction") handlerImpl = Effect.fnUntraced(handlerImpl)
285
347
  const stack = new Error().stack?.split("\n").slice(2).join("\n")
286
- return Effect.isEffect(handlerImpl)
287
- ? class {
288
- static request = rsc[cur]
289
- static stack = stack
290
- static _tag = RequestTypes.RAW
291
- static handler = () => handlerImpl
292
- }
293
- : class {
294
- static request = rsc[cur]
295
- static stack = stack
296
- static _tag = RequestTypes.RAW
297
- static handler = handlerImpl
298
- }
348
+ // oxlint-disable-next-line typescript/no-extraneous-class
349
+ return class {
350
+ static request = rsc[cur]
351
+ static stack = stack
352
+ static _tag = RequestTypes.RAW
353
+ static handler = handlerImpl
354
+ }
299
355
  }
300
356
  })
301
357
  return prev
302
358
  },
303
- {} as RouteMatcher<RequestContextMap, Resource>
359
+ {} as RouteMatcher<ResourceRequestContextMap, Resource>
304
360
  )
305
361
 
306
362
  const router3: <
@@ -318,23 +374,19 @@ export const makeRouter = <
318
374
  // retrieves context R from the actual implementation of the handler
319
375
  Impl[K] extends { raw: any }
320
376
  ? Impl[K]["raw"] extends (...args: any[]) => Effect.Effect<any, any, infer R> ? R
321
- : Impl[K]["raw"] extends Effect.Effect<any, any, infer R> ? R
377
+ : Impl[K]["raw"] extends (...args: any[]) => Stream.Stream<any, any, infer R> ? R
322
378
  : Impl[K]["raw"] extends (...args: any[]) => Generator<
323
- Yieldable<any, any, any, infer R>,
324
- any,
325
- any
379
+ Yieldable<any, any, any, infer R>
326
380
  > ? R
327
381
  : never
328
382
  : Impl[K] extends (...args: any[]) => Effect.Effect<any, any, infer R> ? R
329
- : Impl[K] extends Effect.Effect<any, any, infer R> ? R
383
+ : Impl[K] extends (...args: any[]) => Stream.Stream<any, any, infer R> ? R
330
384
  : Impl[K] extends (...args: any[]) => Generator<
331
- Yieldable<any, any, any, infer R>,
332
- any,
333
- any
385
+ Yieldable<any, any, any, infer R>
334
386
  > ? R
335
387
  : never,
336
- | GetEffectContext<RequestContextMap, Resource[K]["config"]>
337
- | ContextProviderA
388
+ | SafeGetEffectContext<ResourceRequestContextMap, Resource[K]["config"]>
389
+ | ResourceContextProviderA
338
390
  >,
339
391
  Scope.Scope
340
392
  >
@@ -359,7 +411,7 @@ export const makeRouter = <
359
411
  match: any
360
412
  ) =>
361
413
  | Effect.Effect<THandlers, MakeE, MakeR>
362
- | Generator<Yieldable<any, any, MakeE, MakeR>, THandlers, any>
414
+ | Generator<Yieldable<any, any, MakeE, MakeR>, THandlers>
363
415
  ) => {
364
416
  const dependenciesL = (dependencies ? Layer.mergeAll(...dependencies as any) : Layer.empty) as Layer.Layer<
365
417
  LayerUtils.GetLayersSuccess<MakeDependencies>,
@@ -375,6 +427,9 @@ export const makeRouter = <
375
427
 
376
428
  const controllers = yield* finalMake
377
429
 
430
+ // Read the middleware from the resource's request classes at runtime
431
+ const mw = meta.middleware as any
432
+
378
433
  // return make.pipe(Effect.map((c) => controllers(c, dependencies)))
379
434
  const mapped = typedKeysOf(requestModules).reduce((acc, cur) => {
380
435
  const handler = controllers[cur as keyof typeof controllers]
@@ -386,12 +441,105 @@ export const makeRouter = <
386
441
  static success = S.toEncoded(resource.success)
387
442
  } as any
388
443
  : resource,
389
- (payload: any, headers: any) =>
390
- (handler.handler(payload, headers) as Effect.Effect<unknown, unknown, unknown>).pipe(
391
- Effect.withSpan(`Request.${meta.moduleName}.${resource._tag}`, {}, {
392
- captureStackTrace: () => handler.stack // capturing the handler stack is the main reason why we are doing the span here
444
+ (payload: any, headers: any) => {
445
+ const result: any = handler.handler(payload, headers)
446
+ if (resource.stream) {
447
+ // Wrap stream items as { _tag: "value", value } and append a final
448
+ // { _tag: "done", metadata } chunk carrying accumulated invalidation keys.
449
+ // V2: on failure, convert to { _tag: "error", error, metadata } chunk so
450
+ // clients can invalidate queries even when the stream fails.
451
+ const keysRef = Ref.makeUnsafe<ReadonlyArray<Invalidation.InvalidationKey>>([])
452
+ const invalidationSet = Invalidation.makeInvalidationSet(keysRef)
453
+ return Stream.concat(
454
+ (result as Stream.Stream<any, any, any>).pipe(
455
+ Stream.map((item: any) => ({ _tag: "value" as const, value: item })),
456
+ Stream.provideService(Invalidation.InvalidationSet, invalidationSet),
457
+ // V3: after each value chunk, drain accumulated keys and emit a "metadata"
458
+ // chunk if any keys were collected since the last drain. This lets clients
459
+ // invalidate queries mid-stream without waiting for the "done" chunk.
460
+ Stream.flatMap((valueChunk: any) =>
461
+ Stream
462
+ .fromEffect(
463
+ Ref.getAndSet(keysRef, []).pipe(
464
+ Effect.map((keys) =>
465
+ keys.length > 0
466
+ ? [
467
+ valueChunk,
468
+ { _tag: "metadata" as const, metadata: { invalidateQueries: keys } }
469
+ ]
470
+ : [valueChunk]
471
+ )
472
+ )
473
+ )
474
+ .pipe(Stream.flatMap(Stream.fromIterable))
475
+ ),
476
+ // V2: catch stream failures and embed them in the stream as an error chunk
477
+ Stream.catch((err: any) =>
478
+ Stream.fromEffect(
479
+ Ref.get(keysRef).pipe(
480
+ Effect.flatMap((keys) =>
481
+ Effect.fail({
482
+ _tag: "error" as const,
483
+ error: err,
484
+ metadata: { invalidateQueries: keys }
485
+ })
486
+ )
487
+ )
488
+ )
489
+ )
490
+ ),
491
+ Stream.fromEffect(
492
+ Ref.get(keysRef).pipe(
493
+ Effect.map((keys) => ({ _tag: "done" as const, metadata: { invalidateQueries: keys } }))
494
+ )
495
+ )
496
+ )
497
+ }
498
+
499
+ let effect = Effect
500
+ .annotateCurrentSpan({
501
+ "rpc.system": "effect-app",
502
+ "rpc.service": meta.moduleName,
503
+ "rpc.method": resource._tag,
504
+ "code.function.name": resource._tag,
505
+ "code.namespace": meta.moduleName,
506
+ "app.rpc.type": resource.type
393
507
  })
394
- )
508
+ .pipe(Effect.andThen(result as Effect.Effect<unknown, unknown, unknown>))
509
+
510
+ // Commands: provide a request-scoped `InvalidationSet` and wrap both
511
+ // success (`CommandResponseWithMetaData`) and handler-thrown failure
512
+ // (`CommandFailureWithMetaData`) so the client receives accumulated
513
+ // invalidation keys on either path. Middleware-thrown errors bypass the
514
+ // wrap (they fail the outer effect before reaching this `.catch`) and
515
+ // flow raw on the Cause; client decodes them via the rpc's
516
+ // `middlewares[*].error` failure-union channel.
517
+ if (resource.type === "command") {
518
+ const keysRef = Ref.makeUnsafe<ReadonlyArray<Invalidation.InvalidationKey>>([])
519
+ const invalidationSet = Invalidation.makeInvalidationSet(keysRef)
520
+ effect = effect.pipe(
521
+ Effect.provideService(Invalidation.InvalidationSet, invalidationSet),
522
+ Effect.flatMap((value) =>
523
+ Ref.get(keysRef).pipe(
524
+ Effect.map((keys) => ({ payload: value, metadata: { invalidateQueries: keys } }) as any)
525
+ )
526
+ ),
527
+ Effect.catch((err: any) =>
528
+ Ref.get(keysRef).pipe(
529
+ Effect.flatMap((keys) =>
530
+ Effect.fail({
531
+ _tag: "CommandFailureWithMetaData" as const,
532
+ error: err,
533
+ metadata: { invalidateQueries: keys }
534
+ })
535
+ )
536
+ )
537
+ )
538
+ )
539
+ }
540
+
541
+ return applyRequestTypeInterruptibility(resource.type, effect)
542
+ }
395
543
  ] as const
396
544
  return acc
397
545
  }, {} as any) as {
@@ -403,10 +551,10 @@ export const makeRouter = <
403
551
  ) => Effect.Effect<
404
552
  Effect.Success<ReturnType<THandlers[K]["handler"]>>,
405
553
  | Effect.Error<ReturnType<THandlers[K]["handler"]>>
406
- | GetEffectError<RequestContextMap, Resource[K]["config"]>,
554
+ | SafeGetEffectError<ResourceRequestContextMap, Resource[K]["config"]>,
407
555
  Exclude<
408
556
  Effect.Services<ReturnType<THandlers[K]["handler"]>>,
409
- ContextProviderA | GetEffectContext<RequestContextMap, Resource[K]["config"]>
557
+ ResourceContextProviderA | SafeGetEffectContext<ResourceRequestContextMap, Resource[K]["config"]>
410
558
  >
411
559
  >
412
560
  ]
@@ -415,13 +563,33 @@ export const makeRouter = <
415
563
  const rpcs = RpcGroup
416
564
  .make(
417
565
  ...typedValuesOf(mapped).map(([resource]) => {
418
- return Rpc
419
- .make(resource._tag, { payload: resource, success: resource.success, error: resource.error })
420
- .annotate(middleware.requestContext, resource.config ?? {})
566
+ const isStream = resource.stream
567
+ const isCommand = resource.type === "command"
568
+ return (isCommand
569
+ ? isStream
570
+ ? Invalidation.makeStreamRpc(resource._tag, {
571
+ payload: resource,
572
+ success: resource.success,
573
+ error: resource.error,
574
+ stream: true as const
575
+ })
576
+ : Invalidation.makeCommandRpc(resource._tag, {
577
+ payload: resource,
578
+ success: resource.success,
579
+ error: resource.error
580
+ })
581
+ : Rpc.make(resource._tag, {
582
+ payload: resource,
583
+ success: resource.success,
584
+ error: resource.error,
585
+ stream: isStream
586
+ }))
587
+ .annotate(mw.requestContext, resource.config ?? {})
588
+ .annotate(RequestTypeAnnotation, resource.type)
421
589
  })
422
590
  )
423
591
  .prefix(`${meta.moduleName}.`)
424
- .middleware(middleware as any)
592
+ .middleware(mw)
425
593
 
426
594
  const rpc = rpcs
427
595
  .toLayer(Effect.gen(function*() {
@@ -437,7 +605,6 @@ export const makeRouter = <
437
605
 
438
606
  return RpcServer
439
607
  .layerHttp({
440
- spanPrefix: "RpcServer." + meta.moduleName,
441
608
  group: rpcs,
442
609
  path: ("/rpc/" + meta.moduleName) as `/${typeof meta.moduleName}`,
443
610
  protocol: "http"
@@ -449,7 +616,7 @@ export const makeRouter = <
449
616
  const routes = layer.pipe(
450
617
  Layer.provide([
451
618
  dependenciesL,
452
- middleware.Default
619
+ (middlewareLive ?? Layer.empty) as Layer.Layer<any, any, any>
453
620
  ])
454
621
  )
455
622
 
@@ -479,8 +646,7 @@ export const makeRouter = <
479
646
  any,
480
647
  any
481
648
  >,
482
- { [K in keyof FilterRequestModules<Resource>]: AnyHandler<Resource[K]> },
483
- any
649
+ { [K in keyof FilterRequestModules<Resource>]: AnyHandler<Resource[K]> }
484
650
  >
485
651
  /** @deprecated */
486
652
  readonly ಠ_ಠ: never
@@ -492,9 +658,9 @@ export const makeRouter = <
492
658
  never,
493
659
  | MakeErrors<Make>
494
660
  | MakeDepsE<Make>
495
- | Layer.Error<typeof middleware.Default>,
661
+ | Layer.Error<ResourceMWDefault>,
496
662
  | MakeDepsIn<Make>
497
- | Layer.Services<typeof middleware.Default>
663
+ | Layer.Services<ResourceMWDefault>
498
664
  | Exclude<
499
665
  MakeContext<Make>,
500
666
  MakeDepsOut<Make>
@@ -511,8 +677,7 @@ export const makeRouter = <
511
677
  // v4: generators yield Yieldable with asEffect()
512
678
  effect: (match: typeof router3) => Generator<
513
679
  Yieldable<any, any, any, any>,
514
- { [K in keyof FilterRequestModules<Resource>]: AnyHandler<Resource[K]> },
515
- any
680
+ { [K in keyof FilterRequestModules<Resource>]: AnyHandler<Resource[K]> }
516
681
  >
517
682
  }
518
683
  >(
@@ -522,9 +687,9 @@ export const makeRouter = <
522
687
  never,
523
688
  | MakeErrors<Make>
524
689
  | MakeDepsE<Make>
525
- | Layer.Error<typeof middleware.Default>,
690
+ | Layer.Error<ResourceMWDefault>,
526
691
  | MakeDepsIn<Make>
527
- | Layer.Services<typeof middleware.Default>
692
+ | Layer.Services<ResourceMWDefault>
528
693
  | Exclude<
529
694
  MakeContext<Make>,
530
695
  MakeDepsOut<Make>
@@ -572,23 +737,23 @@ export type MakeErrors<Make> = /*Make extends { readonly effect: (_: any) => Eff
572
737
  : Make extends { readonly effect: (_: any) => Effect.Effect<any, never, any> } ? never
573
738
  : */
574
739
  // v4: generators yield Yieldable with asEffect()
575
- Make extends { readonly effect: (_: any) => Generator<Yieldable<any, any, never, any>, any, any> } ? never
576
- : Make extends { readonly effect: (_: any) => Generator<Yieldable<any, any, infer E, any>, any, any> } ? E
740
+ Make extends { readonly effect: (_: any) => Generator<Yieldable<any, any, never, any>> } ? never
741
+ : Make extends { readonly effect: (_: any) => Generator<Yieldable<any, any, infer E, any>> } ? E
577
742
  : never
578
743
 
579
744
  export type MakeContext<Make> = /*Make extends { readonly effect: (_: any) => Effect.Effect<any, any, infer R> } ? R
580
745
  : Make extends { readonly effect: (_: any) => Effect.Effect<any, any, never> } ? never
581
746
  : */
582
747
  // v4: generators yield Yieldable with asEffect()
583
- Make extends { readonly effect: (_: any) => Generator<Yieldable<any, any, any, never>, any, any> } ? never
584
- : Make extends { readonly effect: (_: any) => Generator<Yieldable<any, any, any, infer R>, any, any> } ? R
748
+ Make extends { readonly effect: (_: any) => Generator<Yieldable<any, any, any>> } ? never
749
+ : Make extends { readonly effect: (_: any) => Generator<Yieldable<any, any, any, infer R>> } ? R
585
750
  : never
586
751
 
587
752
  export type MakeHandlers<Make, _Handlers extends Record<string, any>> = /*Make extends
588
753
  { readonly effect: (_: any) => Effect.Effect<{ [K in keyof Handlers]: AnyHandler<Handlers[K]> }, any, any> }
589
754
  ? Effect.Success<ReturnType<Make["effect"]>>
590
755
  : */
591
- Make extends { readonly effect: (_: any) => Generator<any, infer S, any> } ? S
756
+ Make extends { readonly effect: (_: any) => Generator<any, infer S> } ? S
592
757
  : never
593
758
 
594
759
  export type MakeDepsE<Make> = Layer.Error<MakeDeps<Make>>