@effect-app/infra 4.0.0-beta.21 → 4.0.0-beta.211

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 (309) hide show
  1. package/CHANGELOG.md +1556 -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 +98 -50
  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 +16 -16
  53. package/dist/Model/query/dsl.d.ts.map +1 -1
  54. package/dist/Model/query/new-kid-interpreter.d.ts +6 -6
  55. package/dist/Model/query/new-kid-interpreter.d.ts.map +1 -1
  56. package/dist/Model/query/new-kid-interpreter.js +3 -3
  57. package/dist/Model/query.d.ts +1 -1
  58. package/dist/Model.d.ts +2 -1
  59. package/dist/Model.d.ts.map +1 -1
  60. package/dist/Model.js +2 -1
  61. package/dist/QueueMaker/SQLQueue.d.ts +5 -7
  62. package/dist/QueueMaker/SQLQueue.d.ts.map +1 -1
  63. package/dist/QueueMaker/SQLQueue.js +130 -116
  64. package/dist/QueueMaker/errors.d.ts +2 -2
  65. package/dist/QueueMaker/errors.d.ts.map +1 -1
  66. package/dist/QueueMaker/memQueue.d.ts +7 -4
  67. package/dist/QueueMaker/memQueue.d.ts.map +1 -1
  68. package/dist/QueueMaker/memQueue.js +75 -63
  69. package/dist/QueueMaker/sbqueue.d.ts +6 -3
  70. package/dist/QueueMaker/sbqueue.d.ts.map +1 -1
  71. package/dist/QueueMaker/sbqueue.js +52 -53
  72. package/dist/QueueMaker/service.d.ts +1 -1
  73. package/dist/RequestContext.d.ts +74 -35
  74. package/dist/RequestContext.d.ts.map +1 -1
  75. package/dist/RequestContext.js +13 -14
  76. package/dist/RequestFiberSet.d.ts +7 -7
  77. package/dist/RequestFiberSet.d.ts.map +1 -1
  78. package/dist/RequestFiberSet.js +3 -3
  79. package/dist/Store/ContextMapContainer.d.ts +19 -3
  80. package/dist/Store/ContextMapContainer.d.ts.map +1 -1
  81. package/dist/Store/ContextMapContainer.js +13 -3
  82. package/dist/Store/Cosmos/query.d.ts +1 -1
  83. package/dist/Store/Cosmos/query.d.ts.map +1 -1
  84. package/dist/Store/Cosmos/query.js +10 -12
  85. package/dist/Store/Cosmos.d.ts +1 -1
  86. package/dist/Store/Cosmos.d.ts.map +1 -1
  87. package/dist/Store/Cosmos.js +335 -243
  88. package/dist/Store/Disk.d.ts +2 -2
  89. package/dist/Store/Disk.d.ts.map +1 -1
  90. package/dist/Store/Disk.js +72 -35
  91. package/dist/Store/Memory.d.ts +6 -4
  92. package/dist/Store/Memory.d.ts.map +1 -1
  93. package/dist/Store/Memory.js +90 -57
  94. package/dist/Store/SQL/Pg.d.ts +4 -0
  95. package/dist/Store/SQL/Pg.d.ts.map +1 -0
  96. package/dist/Store/SQL/Pg.js +231 -0
  97. package/dist/Store/SQL/query.d.ts +38 -0
  98. package/dist/Store/SQL/query.d.ts.map +1 -0
  99. package/dist/Store/SQL/query.js +367 -0
  100. package/dist/Store/SQL.d.ts +20 -0
  101. package/dist/Store/SQL.d.ts.map +1 -0
  102. package/dist/Store/SQL.js +464 -0
  103. package/dist/Store/codeFilter.d.ts +1 -1
  104. package/dist/Store/codeFilter.d.ts.map +1 -1
  105. package/dist/Store/codeFilter.js +4 -2
  106. package/dist/Store/index.d.ts +5 -2
  107. package/dist/Store/index.d.ts.map +1 -1
  108. package/dist/Store/index.js +15 -3
  109. package/dist/Store/service.d.ts +18 -7
  110. package/dist/Store/service.d.ts.map +1 -1
  111. package/dist/Store/service.js +24 -6
  112. package/dist/Store/utils.d.ts +1 -1
  113. package/dist/Store/utils.d.ts.map +1 -1
  114. package/dist/Store/utils.js +3 -4
  115. package/dist/Store.d.ts +1 -1
  116. package/dist/adapters/SQL/Model.d.ts +31 -42
  117. package/dist/adapters/SQL/Model.d.ts.map +1 -1
  118. package/dist/adapters/SQL/Model.js +29 -38
  119. package/dist/adapters/SQL.d.ts +1 -1
  120. package/dist/adapters/ServiceBus.d.ts +11 -11
  121. package/dist/adapters/ServiceBus.d.ts.map +1 -1
  122. package/dist/adapters/ServiceBus.js +25 -21
  123. package/dist/adapters/cosmos-client.d.ts +3 -3
  124. package/dist/adapters/cosmos-client.d.ts.map +1 -1
  125. package/dist/adapters/cosmos-client.js +3 -3
  126. package/dist/adapters/index.d.ts +8 -2
  127. package/dist/adapters/index.d.ts.map +1 -1
  128. package/dist/adapters/index.js +8 -2
  129. package/dist/adapters/logger.d.ts +2 -2
  130. package/dist/adapters/logger.d.ts.map +1 -1
  131. package/dist/adapters/memQueue.d.ts +3 -3
  132. package/dist/adapters/memQueue.d.ts.map +1 -1
  133. package/dist/adapters/memQueue.js +3 -3
  134. package/dist/adapters/mongo-client.d.ts +3 -3
  135. package/dist/adapters/mongo-client.d.ts.map +1 -1
  136. package/dist/adapters/mongo-client.js +3 -3
  137. package/dist/adapters/redis-client.d.ts +3 -3
  138. package/dist/adapters/redis-client.d.ts.map +1 -1
  139. package/dist/adapters/redis-client.js +3 -3
  140. package/dist/api/ContextProvider.d.ts +8 -8
  141. package/dist/api/ContextProvider.d.ts.map +1 -1
  142. package/dist/api/ContextProvider.js +6 -6
  143. package/dist/api/codec.d.ts +1 -1
  144. package/dist/api/internal/RequestContextMiddleware.d.ts +2 -2
  145. package/dist/api/internal/RequestContextMiddleware.d.ts.map +1 -1
  146. package/dist/api/internal/RequestContextMiddleware.js +2 -2
  147. package/dist/api/internal/auth.d.ts +44 -6
  148. package/dist/api/internal/auth.d.ts.map +1 -1
  149. package/dist/api/internal/auth.js +160 -29
  150. package/dist/api/internal/events.d.ts +3 -3
  151. package/dist/api/internal/events.d.ts.map +1 -1
  152. package/dist/api/internal/events.js +10 -8
  153. package/dist/api/internal/health.d.ts +1 -1
  154. package/dist/api/layerUtils.d.ts +6 -6
  155. package/dist/api/layerUtils.d.ts.map +1 -1
  156. package/dist/api/layerUtils.js +5 -5
  157. package/dist/api/middlewares.d.ts +1 -1
  158. package/dist/api/reportError.d.ts +1 -1
  159. package/dist/api/routing/middleware/RouterMiddleware.d.ts +4 -4
  160. package/dist/api/routing/middleware/RouterMiddleware.d.ts.map +1 -1
  161. package/dist/api/routing/middleware/middleware.d.ts +39 -3
  162. package/dist/api/routing/middleware/middleware.d.ts.map +1 -1
  163. package/dist/api/routing/middleware/middleware.js +48 -16
  164. package/dist/api/routing/middleware.d.ts +1 -2
  165. package/dist/api/routing/middleware.d.ts.map +1 -1
  166. package/dist/api/routing/middleware.js +1 -2
  167. package/dist/api/routing/schema/jwt.d.ts +1 -1
  168. package/dist/api/routing/schema/jwt.d.ts.map +1 -1
  169. package/dist/api/routing/tsort.d.ts +1 -1
  170. package/dist/api/routing/tsort.d.ts.map +1 -1
  171. package/dist/api/routing/utils.d.ts +3 -3
  172. package/dist/api/routing/utils.d.ts.map +1 -1
  173. package/dist/api/routing.d.ts +80 -37
  174. package/dist/api/routing.d.ts.map +1 -1
  175. package/dist/api/routing.js +112 -40
  176. package/dist/api/setupRequest.d.ts +8 -5
  177. package/dist/api/setupRequest.d.ts.map +1 -1
  178. package/dist/api/setupRequest.js +12 -7
  179. package/dist/api/util.d.ts +1 -1
  180. package/dist/arbs.d.ts +1 -1
  181. package/dist/arbs.d.ts.map +1 -1
  182. package/dist/arbs.js +5 -3
  183. package/dist/errorReporter.d.ts +4 -4
  184. package/dist/errorReporter.d.ts.map +1 -1
  185. package/dist/errorReporter.js +20 -25
  186. package/dist/errors.d.ts +1 -1
  187. package/dist/fileUtil.d.ts +1 -1
  188. package/dist/fileUtil.d.ts.map +1 -1
  189. package/dist/index.d.ts +1 -1
  190. package/dist/logger/jsonLogger.d.ts +1 -1
  191. package/dist/logger/logFmtLogger.d.ts +1 -1
  192. package/dist/logger/shared.d.ts +1 -1
  193. package/dist/logger/shared.js +2 -2
  194. package/dist/logger.d.ts +1 -1
  195. package/dist/logger.d.ts.map +1 -1
  196. package/dist/otel.d.ts +75 -0
  197. package/dist/otel.d.ts.map +1 -0
  198. package/dist/otel.js +65 -0
  199. package/dist/rateLimit.d.ts +9 -3
  200. package/dist/rateLimit.d.ts.map +1 -1
  201. package/dist/rateLimit.js +5 -11
  202. package/dist/test.d.ts +2 -2
  203. package/dist/test.d.ts.map +1 -1
  204. package/dist/test.js +1 -1
  205. package/dist/vitest.d.ts +1 -1
  206. package/examples/query.ts +39 -35
  207. package/package.json +45 -37
  208. package/src/CUPS.ts +9 -11
  209. package/src/Emailer/Sendgrid.ts +17 -14
  210. package/src/Emailer/service.ts +9 -3
  211. package/src/MainFiberSet.ts +5 -6
  212. package/src/Model/Repository/Registry.ts +33 -0
  213. package/src/Model/Repository/ext.ts +96 -10
  214. package/src/Model/Repository/internal/internal.ts +213 -148
  215. package/src/Model/Repository/makeRepo.ts +12 -10
  216. package/src/Model/Repository/service.ts +31 -22
  217. package/src/Model/Repository/validation.ts +4 -4
  218. package/src/Model/Repository.ts +1 -0
  219. package/src/Model/dsl.ts +3 -3
  220. package/src/Model/filter/types/path/eager.ts +1 -2
  221. package/src/Model/query/dsl.ts +18 -18
  222. package/src/Model/query/new-kid-interpreter.ts +2 -2
  223. package/src/Model.ts +1 -0
  224. package/src/QueueMaker/SQLQueue.ts +144 -152
  225. package/src/QueueMaker/memQueue.ts +104 -103
  226. package/src/QueueMaker/sbqueue.ts +70 -86
  227. package/src/RequestContext.ts +14 -16
  228. package/src/RequestFiberSet.ts +2 -2
  229. package/src/Store/ContextMapContainer.ts +41 -2
  230. package/src/Store/Cosmos/query.ts +16 -20
  231. package/src/Store/Cosmos.ts +473 -348
  232. package/src/Store/Disk.ts +102 -65
  233. package/src/Store/Memory.ts +118 -83
  234. package/src/Store/SQL/Pg.ts +352 -0
  235. package/src/Store/SQL/query.ts +409 -0
  236. package/src/Store/SQL.ts +734 -0
  237. package/src/Store/codeFilter.ts +3 -1
  238. package/src/Store/index.ts +17 -2
  239. package/src/Store/service.ts +32 -8
  240. package/src/Store/utils.ts +23 -22
  241. package/src/adapters/SQL/Model.ts +41 -40
  242. package/src/adapters/ServiceBus.ts +125 -121
  243. package/src/adapters/cosmos-client.ts +2 -2
  244. package/src/adapters/index.ts +7 -0
  245. package/src/adapters/memQueue.ts +2 -2
  246. package/src/adapters/mongo-client.ts +2 -2
  247. package/src/adapters/redis-client.ts +2 -2
  248. package/src/api/ContextProvider.ts +12 -13
  249. package/src/api/internal/RequestContextMiddleware.ts +1 -1
  250. package/src/api/internal/auth.ts +246 -44
  251. package/src/api/internal/events.ts +13 -9
  252. package/src/api/layerUtils.ts +8 -8
  253. package/src/api/routing/middleware/RouterMiddleware.ts +4 -4
  254. package/src/api/routing/middleware/middleware.ts +55 -14
  255. package/src/api/routing/middleware.ts +0 -2
  256. package/src/api/routing.ts +298 -128
  257. package/src/api/setupRequest.ts +28 -8
  258. package/src/arbs.ts +4 -2
  259. package/src/errorReporter.ts +62 -74
  260. package/src/logger/shared.ts +1 -1
  261. package/src/otel.ts +152 -0
  262. package/src/rateLimit.ts +30 -22
  263. package/src/test.ts +1 -1
  264. package/test/auth.test.ts +101 -0
  265. package/test/contextProvider.test.ts +11 -11
  266. package/test/controller.test.ts +21 -30
  267. package/test/dist/auth.test.d.ts.map +1 -0
  268. package/test/dist/contextProvider.test.d.ts.map +1 -1
  269. package/test/dist/controller.test.d.ts.map +1 -1
  270. package/test/dist/date-query.test.d.ts.map +1 -0
  271. package/test/dist/fixtures.d.ts +26 -12
  272. package/test/dist/fixtures.d.ts.map +1 -1
  273. package/test/dist/fixtures.js +12 -10
  274. package/test/dist/query.test.d.ts.map +1 -1
  275. package/test/dist/rawQuery.test.d.ts.map +1 -1
  276. package/test/dist/repository-ext.test.d.ts.map +1 -0
  277. package/test/dist/requires.test.d.ts.map +1 -1
  278. package/test/dist/router-generator.test.d.ts.map +1 -0
  279. package/test/dist/routing-interruptibility.test.d.ts.map +1 -0
  280. package/test/dist/rpc-e2e-invalidation.test.d.ts.map +1 -0
  281. package/test/dist/rpc-multi-middleware.test.d.ts.map +1 -1
  282. package/test/dist/rpc-stream-fullstack.test.d.ts.map +1 -0
  283. package/test/dist/sql-store.test.d.ts.map +1 -0
  284. package/test/fixtures.ts +11 -9
  285. package/test/query.test.ts +216 -34
  286. package/test/rawQuery.test.ts +23 -19
  287. package/test/repository-ext.test.ts +60 -0
  288. package/test/requires.test.ts +6 -6
  289. package/test/router-generator.test.ts +183 -0
  290. package/test/routing-interruptibility.test.ts +63 -0
  291. package/test/rpc-e2e-invalidation.test.ts +251 -0
  292. package/test/rpc-multi-middleware.test.ts +78 -9
  293. package/test/rpc-stream-fullstack.test.ts +300 -0
  294. package/test/sql-store.test.ts +1064 -0
  295. package/test/validateSample.test.ts +15 -12
  296. package/tsconfig.examples.json +1 -1
  297. package/tsconfig.json +0 -1
  298. package/tsconfig.json.bak +2 -2
  299. package/tsconfig.src.json +35 -35
  300. package/tsconfig.test.json +2 -2
  301. package/dist/Operations.d.ts +0 -55
  302. package/dist/Operations.d.ts.map +0 -1
  303. package/dist/Operations.js +0 -102
  304. package/dist/OperationsRepo.d.ts +0 -41
  305. package/dist/OperationsRepo.d.ts.map +0 -1
  306. package/dist/OperationsRepo.js +0 -14
  307. package/eslint.config.mjs +0 -24
  308. package/src/Operations.ts +0 -235
  309. package/src/OperationsRepo.ts +0 -16
@@ -1,17 +1,21 @@
1
1
  /* eslint-disable unused-imports/no-unused-vars */
2
2
  /* eslint-disable @typescript-eslint/no-empty-object-type */
3
3
  /* eslint-disable @typescript-eslint/no-explicit-any */
4
- import { Effect, flow, Layer, Option, pipe, S, ServiceMap, Struct } from "effect-app"
4
+ import { SchemaTransformation } from "effect"
5
+ import { Context, Effect, flow, Layer, Option, pipe, S, Struct } from "effect-app"
5
6
  import { inspect } from "util"
6
7
  import { expect, expectTypeOf, it } from "vitest"
7
8
  import { setupRequestContextFromCurrent } from "../src/api/setupRequest.js"
8
9
  import { and, count, make, one, or, order, page, project, type QueryEnd, type QueryProjection, type QueryWhere, toFilter, where } from "../src/Model/query.js"
9
10
  import { makeRepo } from "../src/Model/Repository.js"
11
+ import { RepositoryRegistryLive } from "../src/Model/Repository/Registry.js"
10
12
  import { memFilter, MemoryStoreLive } from "../src/Store/Memory.js"
11
13
  import { SomeService } from "./fixtures.js"
12
14
 
15
+ const TestStoreLive = Layer.merge(MemoryStoreLive, RepositoryRegistryLive)
16
+
13
17
  const str = S.Struct({ _tag: S.Literal("string"), value: S.String })
14
- const num = S.Struct({ _tag: S.Literal("number"), value: S.Number })
18
+ const num = S.Struct({ _tag: S.Literal("number"), value: S.Finite })
15
19
  const someUnion = S.Union([str, num])
16
20
 
17
21
  export class Something extends S.Class<Something>("Something")({
@@ -19,7 +23,7 @@ export class Something extends S.Class<Something>("Something")({
19
23
  displayName: S.NonEmptyString255,
20
24
  name: S.NullOr(S.NonEmptyString255).withDefault,
21
25
  n: S.Date.withDefault,
22
- union: someUnion.pipe(S.withDefaultConstructor(() => ({ _tag: "string" as const, value: "hi" })))
26
+ union: someUnion.pipe(S.withConstructorDefault(Effect.succeed({ _tag: "string" as const, value: "hi" })))
23
27
  }) {}
24
28
  export declare namespace Something {
25
29
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
@@ -90,8 +94,8 @@ it("works", () => {
90
94
 
91
95
  const processed = memFilter(interpreted)(items.map((_) =>
92
96
  S.encodeUnknownSync(S.Struct({
93
- ...Something.omit("displayName"),
94
- displayName: S.Literal("Verona", "Riley")
97
+ ...Struct.omit(Something.fields, ["displayName"]),
98
+ displayName: S.Literals(["Verona", "Riley"])
95
99
  }))(_)
96
100
  ))
97
101
 
@@ -99,7 +103,7 @@ it("works", () => {
99
103
  })
100
104
 
101
105
  // @effect-diagnostics-next-line missingEffectServiceDependency:off
102
- class SomethingRepo extends ServiceMap.Service<SomethingRepo>()("SomethingRepo", {
106
+ class SomethingRepo extends Context.Service<SomethingRepo>()("SomethingRepo", {
103
107
  make: Effect.gen(function*() {
104
108
  return yield* makeRepo("Something", Something, {})
105
109
  })
@@ -112,7 +116,7 @@ class SomethingRepo extends ServiceMap.Service<SomethingRepo>()("SomethingRepo",
112
116
  })
113
117
  )
114
118
  .pipe(
115
- Layer.provide(MemoryStoreLive)
119
+ Layer.provide(TestStoreLive)
116
120
  )
117
121
  }
118
122
 
@@ -236,15 +240,15 @@ it("collect", () =>
236
240
  Effect.runPromise
237
241
  ))
238
242
 
239
- class Person extends S.ExtendedTaggedClass<Person, Person.Encoded>()("person", {
243
+ class Person extends S.TaggedClass<Person, Person.Encoded>()("person", {
240
244
  id: S.String,
241
245
  surname: S.String
242
246
  }) {}
243
- class Animal extends S.ExtendedTaggedClass<Animal, Animal.Encoded>()("animal", {
247
+ class Animal extends S.TaggedClass<Animal, Animal.Encoded>()("animal", {
244
248
  id: S.String,
245
249
  surname: S.String
246
250
  }) {}
247
- class Test extends S.ExtendedTaggedClass<Test, Test.Encoded>()("test", {
251
+ class Test extends S.TaggedClass<Test, Test.Encoded>()("test", {
248
252
  id: S.String
249
253
  }) {}
250
254
 
@@ -279,7 +283,7 @@ it(
279
283
  expect(result).toEqual([])
280
284
  expect(result2).toEqual([])
281
285
  })
282
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
286
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
283
287
  )
284
288
 
285
289
  it(
@@ -465,7 +469,7 @@ it(
465
469
 
466
470
  expect([]).toEqual([])
467
471
  })
468
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
472
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
469
473
  )
470
474
 
471
475
  it(
@@ -508,7 +512,7 @@ it(
508
512
 
509
513
  expect([]).toEqual([])
510
514
  })
511
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
515
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
512
516
  )
513
517
 
514
518
  it(
@@ -519,8 +523,8 @@ it(
519
523
  const schema = S.Struct({
520
524
  id: S.String,
521
525
  createdAt: S.Date.pipe(
522
- S.withDecodingDefault(() => new Date().toISOString()),
523
- S.withConstructorDefault(() => Option.some(new Date()))
526
+ S.withDecodingDefault(Effect.sync(() => new Date().toISOString())),
527
+ S.withConstructorDefault(Effect.sync(() => new Date()))
524
528
  )
525
529
  })
526
530
  const repo = yield* makeRepo(
@@ -532,8 +536,8 @@ it(
532
536
  const outputSchema = S.Struct({
533
537
  id: S.Literal("123"),
534
538
  createdAt: S.Date.pipe(
535
- S.withDecodingDefault(() => new Date().toISOString()),
536
- S.withConstructorDefault(() => Option.some(new Date()))
539
+ S.withDecodingDefault(Effect.sync(() => new Date().toISOString())),
540
+ S.withConstructorDefault(Effect.sync(() => new Date()))
537
541
  )
538
542
  })
539
543
 
@@ -541,7 +545,34 @@ it(
541
545
 
542
546
  expect(result).toEqual([])
543
547
  })
544
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
548
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
549
+ )
550
+
551
+ it(
552
+ "project with encodeKeys in projection maps encoded keys",
553
+ () =>
554
+ Effect
555
+ .gen(function*() {
556
+ const schema = S.Struct({
557
+ id: S.String,
558
+ a: S.Number
559
+ })
560
+
561
+ const repo = yield* makeRepo(
562
+ "test",
563
+ schema,
564
+ {
565
+ makeInitial: Effect.sync(() => [{ id: "1", a: 1 }])
566
+ }
567
+ )
568
+
569
+ const outputSchema = S.Struct({ b: S.Number }).pipe(S.encodeKeys({ b: "a" }))
570
+
571
+ const result = yield* repo.query(project(outputSchema))
572
+
573
+ expect(result).toStrictEqual([{ b: 1 }])
574
+ })
575
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
545
576
  )
546
577
 
547
578
  it(
@@ -551,7 +582,7 @@ it(
551
582
  .gen(function*() {
552
583
  const schema = S.Struct({
553
584
  id: S.String,
554
- literals: S.Literal("a", "b", "c")
585
+ literals: S.Literals(["a", "b", "c"])
555
586
  })
556
587
 
557
588
  type Schema = typeof schema.Type
@@ -571,7 +602,7 @@ it(
571
602
 
572
603
  expect(result).toEqual([])
573
604
  })
574
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
605
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
575
606
  )
576
607
 
577
608
  it(
@@ -581,7 +612,7 @@ it(
581
612
  .gen(function*() {
582
613
  const schema = S.Struct({
583
614
  id: S.String,
584
- literals: S.Union([S.Literal("a", "b", "c"), S.Null])
615
+ literals: S.Union([S.Literals(["a", "b", "c"]), S.Null])
585
616
  })
586
617
 
587
618
  type Schema = typeof schema.Type
@@ -615,7 +646,7 @@ it(
615
646
 
616
647
  expect(result).toEqual([])
617
648
  })
618
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
649
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
619
650
  )
620
651
 
621
652
  it(
@@ -659,7 +690,7 @@ it(
659
690
 
660
691
  expect(result).toEqual([])
661
692
  })
662
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
693
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
663
694
  )
664
695
 
665
696
  it("remove null from one constituent of a tagged union", () =>
@@ -672,7 +703,7 @@ it("remove null from one constituent of a tagged union", () =>
672
703
 
673
704
  class BB extends S.Class<BB>("BB")({
674
705
  id: S.Literal("BB"),
675
- b: S.NullOr(S.Number)
706
+ b: S.NullOr(S.Finite)
676
707
  }) {}
677
708
 
678
709
  type Union = AA | BB
@@ -708,7 +739,7 @@ it("remove null from one constituent of a tagged union", () =>
708
739
  })[]
709
740
  >()
710
741
  })
711
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
742
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
712
743
 
713
744
  it("refine 3", () =>
714
745
  Effect
@@ -746,7 +777,7 @@ it("refine 3", () =>
746
777
  const resQuer1 = yield* repo.query(where("id", "AA"))
747
778
  expectTypeOf(resQuer1).toEqualTypeOf<readonly AA[]>()
748
779
  })
749
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
780
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
750
781
 
751
782
  it("my test", () =>
752
783
  Effect
@@ -764,7 +795,7 @@ it("my test", () =>
764
795
  )
765
796
  expectTypeOf(resQuer1).toEqualTypeOf<readonly AA[]>()
766
797
  })
767
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
798
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
768
799
 
769
800
  it("refine inner without imposing a projection", () =>
770
801
  Effect
@@ -808,7 +839,7 @@ it("refine inner without imposing a projection", () =>
808
839
  where("union._tag", "AA"),
809
840
  // But if I wanna the whole Data as output ignoring the inner refinement
810
841
  // I wanna be able to do so
811
- project(S.Struct(Data.pick("union")))
842
+ project(Data.mapFields(Struct.pick(["union"])))
812
843
  )
813
844
 
814
845
  expectTypeOf(query2).toEqualTypeOf<
@@ -839,7 +870,7 @@ it("refine inner without imposing a projection", () =>
839
870
  }[]
840
871
  >()
841
872
  })
842
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
873
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
843
874
 
844
875
  it("does not allow string queries on arrays", () =>
845
876
  Effect
@@ -874,7 +905,7 @@ it("does not allow string queries on arrays", () =>
874
905
  expectTypeOf(good3).toEqualTypeOf<QueryWhere<Some, Some>>()
875
906
  expectTypeOf(good4).toEqualTypeOf<QueryWhere<Some, Some>>()
876
907
  })
877
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
908
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
878
909
 
879
910
  it("test array.length", () =>
880
911
  Effect
@@ -915,7 +946,7 @@ it("test array.length", () =>
915
946
  QueryWhere<Something, Something>
916
947
  >()
917
948
  })
918
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
949
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
919
950
 
920
951
  it("distribution over union", () =>
921
952
  Effect
@@ -939,7 +970,7 @@ it("distribution over union", () =>
939
970
  })[]
940
971
  >()
941
972
  })
942
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
973
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
943
974
 
944
975
  it("refine nested union", () =>
945
976
  Effect
@@ -980,7 +1011,158 @@ it("refine nested union", () =>
980
1011
  }[]
981
1012
  >()
982
1013
  })
983
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
1014
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
1015
+
1016
+ it("find with transformed id", () =>
1017
+ Effect
1018
+ .gen(function*() {
1019
+ const ConfiguratorId = S.NonEmptyString255
1020
+
1021
+ class PreconfigurationId extends S.Class<PreconfigurationId>("PreconfigurationId")({
1022
+ configuratorId: ConfiguratorId,
1023
+ label: S.NonEmptyString50
1024
+ }) {}
1025
+
1026
+ const PreconfigurationIdFromString = S.NonEmptyString255.pipe(
1027
+ S.decodeTo(
1028
+ S.toType(PreconfigurationId),
1029
+ SchemaTransformation.transformOrFail({
1030
+ decode: Effect.fnUntraced(function*(value) {
1031
+ const values = value.split("_")
1032
+ const label = yield* S.SchemaParser.decodeUnknownEffect(S.NonEmptyString50)(values.pop())
1033
+ const configuratorId = yield* S.SchemaParser.decodeUnknownEffect(ConfiguratorId)(
1034
+ values.join("_")
1035
+ )
1036
+ return new PreconfigurationId({ configuratorId, label })
1037
+ }),
1038
+ encode: (id) => Effect.succeed(S.NonEmptyString255(`${id.configuratorId}_${id.label}`))
1039
+ })
1040
+ ),
1041
+ S.revealCodec
1042
+ )
1043
+
1044
+ const Preconfiguration = S.Struct({
1045
+ id: PreconfigurationIdFromString,
1046
+ name: S.String
1047
+ })
1048
+
1049
+ const repo = yield* makeRepo("Preconfiguration", Preconfiguration, { idKey: "id" as const })
1050
+
1051
+ const id = new PreconfigurationId({
1052
+ configuratorId: S.NonEmptyString255("myConfigurator"),
1053
+ label: S.NonEmptyString50("myLabel")
1054
+ })
1055
+ const item = { id, name: "test preconfig" }
1056
+
1057
+ yield* repo.saveAndPublish([item])
1058
+
1059
+ const found = yield* repo.find(id)
1060
+ expect(Option.isSome(found)).toBe(true)
1061
+ expect(Option.getOrThrow(found).name).toBe("test preconfig")
1062
+ expect(Option.getOrThrow(found).id).toEqual(id)
1063
+
1064
+ const notFound = yield* repo.find(
1065
+ new PreconfigurationId({
1066
+ configuratorId: S.NonEmptyString255("other"),
1067
+ label: S.NonEmptyString50("nope")
1068
+ })
1069
+ )
1070
+ expect(Option.isNone(notFound)).toBe(true)
1071
+ })
1072
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
1073
+
1074
+ it("find with transformed id in tagged union", () =>
1075
+ Effect
1076
+ .gen(function*() {
1077
+ const ConfiguratorId = S.NonEmptyString255
1078
+
1079
+ class PreconfigurationId extends S.Class<PreconfigurationId>("PreconfigurationId")({
1080
+ configuratorId: ConfiguratorId,
1081
+ label: S.NonEmptyString50
1082
+ }) {}
1083
+
1084
+ const PreconfigurationIdFromString = S.NonEmptyString255.pipe(
1085
+ S.decodeTo(
1086
+ S.toType(PreconfigurationId),
1087
+ SchemaTransformation.transformOrFail({
1088
+ decode: Effect.fnUntraced(function*(value) {
1089
+ const values = value.split("_")
1090
+ const label = yield* S.SchemaParser.decodeUnknownEffect(S.NonEmptyString50)(values.pop())
1091
+ const configuratorId = yield* S.SchemaParser.decodeUnknownEffect(ConfiguratorId)(
1092
+ values.join("_")
1093
+ )
1094
+ return new PreconfigurationId({ configuratorId, label })
1095
+ }),
1096
+ encode: (id) => Effect.succeed(S.NonEmptyString255(`${id.configuratorId}_${id.label}`))
1097
+ })
1098
+ ),
1099
+ S.revealCodec
1100
+ )
1101
+
1102
+ class Draft extends S.TaggedClass<Draft>()("Draft", {
1103
+ id: PreconfigurationIdFromString,
1104
+ name: S.String
1105
+ }) {}
1106
+
1107
+ class Published extends S.TaggedClass<Published>()("Published", {
1108
+ id: PreconfigurationIdFromString,
1109
+ name: S.String,
1110
+ publishedAt: S.String
1111
+ }) {}
1112
+
1113
+ class Archived extends S.TaggedClass<Archived>()("Archived", {
1114
+ id: PreconfigurationIdFromString,
1115
+ name: S.String,
1116
+ archivedAt: S.String
1117
+ }) {}
1118
+
1119
+ const Preconfiguration = S.Union([Draft, Published, Archived])
1120
+
1121
+ const repo = yield* makeRepo("Preconfiguration", Preconfiguration, {})
1122
+
1123
+ const id1 = new PreconfigurationId({
1124
+ configuratorId: S.NonEmptyString255("conf1"),
1125
+ label: S.NonEmptyString50("draft1")
1126
+ })
1127
+ const id2 = new PreconfigurationId({
1128
+ configuratorId: S.NonEmptyString255("conf2"),
1129
+ label: S.NonEmptyString50("pub1")
1130
+ })
1131
+ const id3 = new PreconfigurationId({
1132
+ configuratorId: S.NonEmptyString255("conf3"),
1133
+ label: S.NonEmptyString50("arch1")
1134
+ })
1135
+
1136
+ const draft = new Draft({ id: id1, name: "my draft" })
1137
+ const published = new Published({ id: id2, name: "my published", publishedAt: "2024-01-01" })
1138
+ const archived = new Archived({ id: id3, name: "my archived", archivedAt: "2024-06-01" })
1139
+
1140
+ yield* repo.saveAndPublish([draft, published, archived])
1141
+
1142
+ // find each by their PreconfigurationId instance
1143
+ const foundDraft = yield* repo.find(id1)
1144
+ expect(Option.isSome(foundDraft)).toBe(true)
1145
+ expect(Option.getOrThrow(foundDraft)._tag).toBe("Draft")
1146
+ expect(Option.getOrThrow(foundDraft).name).toBe("my draft")
1147
+
1148
+ const foundPublished = yield* repo.find(id2)
1149
+ expect(Option.isSome(foundPublished)).toBe(true)
1150
+ expect(Option.getOrThrow(foundPublished)._tag).toBe("Published")
1151
+
1152
+ const foundArchived = yield* repo.find(id3)
1153
+ expect(Option.isSome(foundArchived)).toBe(true)
1154
+ expect(Option.getOrThrow(foundArchived)._tag).toBe("Archived")
1155
+
1156
+ // not found
1157
+ const notFound = yield* repo.find(
1158
+ new PreconfigurationId({
1159
+ configuratorId: S.NonEmptyString255("nope"),
1160
+ label: S.NonEmptyString50("nope")
1161
+ })
1162
+ )
1163
+ expect(Option.isNone(notFound)).toBe(true)
1164
+ })
1165
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
984
1166
 
985
1167
  it("refine union with nested union", () =>
986
1168
  Effect
@@ -1095,4 +1277,4 @@ it("refine union with nested union", () =>
1095
1277
  })[]
1096
1278
  >()
1097
1279
  })
1098
- .pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
1280
+ .pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
@@ -1,9 +1,10 @@
1
1
  import { describe, expect, it } from "@effect/vitest"
2
- import { Array, Config, Effect, flow, Layer, ManagedRuntime, Redacted, References, Result, S, ServiceMap } from "effect-app"
2
+ import { Array, Config, Context, Effect, flow, Layer, ManagedRuntime, Redacted, References, Result, S } from "effect-app"
3
3
  import { LogLevels } from "effect-app/utils"
4
4
  import { setupRequestContextFromCurrent } from "../src/api/setupRequest.js"
5
5
  import { and, or, project, where, whereEvery, whereSome } from "../src/Model/query.js"
6
6
  import { makeRepo } from "../src/Model/Repository/makeRepo.js"
7
+ import { RepositoryRegistryLive } from "../src/Model/Repository/Registry.js"
7
8
  import { CosmosStoreLayer } from "../src/Store/Cosmos.js"
8
9
  import { MemoryStoreLive } from "../src/Store/Memory.js"
9
10
 
@@ -24,7 +25,7 @@ class Something extends S.Class<Something>("Something")({
24
25
  id: S.String,
25
26
  name: S.String,
26
27
  description: S.String,
27
- items: S.Array(S.Struct({ id: S.String, value: S.Number, description: S.String }))
28
+ items: S.Array(S.Struct({ id: S.String, value: S.Finite, description: S.String }))
28
29
  }) {}
29
30
 
30
31
  const items = [
@@ -49,7 +50,7 @@ const items = [
49
50
  ]
50
51
 
51
52
  // @effect-diagnostics-next-line missingEffectServiceDependency:off
52
- class SomethingRepo extends ServiceMap.Service<SomethingRepo>()(
53
+ class SomethingRepo extends Context.Service<SomethingRepo>()(
53
54
  "SomethingRepo",
54
55
  {
55
56
  make: Effect.gen(function*() {
@@ -76,28 +77,31 @@ class SomethingRepo extends ServiceMap.Service<SomethingRepo>()(
76
77
  static readonly Test = this
77
78
  .layer
78
79
  .pipe(
79
- Layer.provide(MemoryStoreLive)
80
+ Layer.provide(Layer.merge(MemoryStoreLive, RepositoryRegistryLive))
80
81
  )
81
82
 
82
83
  static readonly TestCosmos = this
83
84
  .layer
84
85
  .pipe(
85
86
  Layer.provide(
86
- Effect.gen(function*() {
87
- const url = yield* Config.redacted("STORAGE_URL").pipe(
88
- Config.withDefault(
89
- Redacted.make(
90
- // the emulator doesn't implement array projections :/ so you need an actual cloud instance!
91
- "AccountEndpoint=http://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
87
+ Effect
88
+ .gen(function*() {
89
+ const url = yield* Config.redacted("STORAGE_URL").pipe(
90
+ Config.withDefault(
91
+ Redacted.make(
92
+ // the emulator doesn't implement array projections :/ so you need an actual cloud instance!
93
+ "AccountEndpoint=http://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
94
+ )
92
95
  )
93
96
  )
94
- )
95
- return CosmosStoreLayer({
96
- dbName: "test",
97
- prefix: "",
98
- url
97
+ return CosmosStoreLayer({
98
+ dbName: "test",
99
+ prefix: "",
100
+ url
101
+ })
102
+ .pipe(Layer.merge(RepositoryRegistryLive))
99
103
  })
100
- }).pipe(Layer.unwrap)
104
+ .pipe(Layer.unwrap)
101
105
  )
102
106
  )
103
107
  }
@@ -107,7 +111,7 @@ describe("select first-level array fields", () => {
107
111
  .gen(function*() {
108
112
  const repo = yield* SomethingRepo
109
113
 
110
- const projected = S.Struct({ name: S.String, items: S.Array(S.Struct({ id: S.String, value: S.Number })) })
114
+ const projected = S.Struct({ name: S.String, items: S.Array(S.Struct({ id: S.String, value: S.Finite })) })
111
115
 
112
116
  // ok crazy lol, "value" is a reserved word in CosmosDB, so we have to use t["value"] as a field name instead of t.value
113
117
  const items = yield* repo.queryRaw(projected, {
@@ -159,7 +163,7 @@ describe("select first-level array fields", () => {
159
163
  .pipe(Effect.provide(SomethingRepo.Test), rt.runPromise))
160
164
  })
161
165
 
162
- const projected = S.Struct({ name: S.String, items: S.Array(S.Struct({ id: S.String, value: S.Number })) })
166
+ const projected = S.Struct({ name: S.String, items: S.Array(S.Struct({ id: S.String, value: S.Finite })) })
163
167
 
164
168
  const expected = [
165
169
  {
@@ -405,7 +409,7 @@ describe("removeByIds", () => {
405
409
 
406
410
  yield* repo.saveAndPublish(items)
407
411
  const itemsAfterSave = yield* repo.all
408
- yield* repo.removeById(...items.slice(0, 2).map((_) => _.id))
412
+ yield* repo.removeById([items[0]!.id, items[1]!.id])
409
413
 
410
414
  const items2 = yield* repo.all
411
415
 
@@ -0,0 +1,60 @@
1
+ import { describe, expect, it } from "@effect/vitest"
2
+ import { Effect, Layer, S } from "effect-app"
3
+ import { setupRequestContextFromCurrent } from "../src/api/setupRequest.js"
4
+ import { makeRepo } from "../src/Model/Repository.js"
5
+ import { RepositoryRegistryLive } from "../src/Model/Repository/Registry.js"
6
+ import { MemoryStoreLive } from "../src/Store/Memory.js"
7
+
8
+ class BatchItem extends S.Class<BatchItem>("BatchItem")({
9
+ id: S.String,
10
+ label: S.String
11
+ }) {}
12
+
13
+ const TestStoreLive = Layer.merge(MemoryStoreLive, RepositoryRegistryLive)
14
+
15
+ describe("repository ext save/remove batching", () => {
16
+ it.effect("supports save batching overload", () =>
17
+ Effect
18
+ .gen(function*() {
19
+ const repo = yield* makeRepo("BatchItem", BatchItem, {})
20
+ const items = [
21
+ new BatchItem({ id: "1", label: "one" }),
22
+ new BatchItem({ id: "2", label: "two" }),
23
+ new BatchItem({ id: "3", label: "three" }),
24
+ new BatchItem({ id: "4", label: "four" })
25
+ ] as const
26
+
27
+ yield* repo.save(items, { batch: 2 })
28
+
29
+ const all = yield* repo.all
30
+ expect(all).toHaveLength(4)
31
+ expect(all.map((_) => _.id).toSorted()).toEqual(["1", "2", "3", "4"])
32
+ })
33
+ .pipe(
34
+ setupRequestContextFromCurrent(),
35
+ Effect.provide(TestStoreLive)
36
+ ))
37
+
38
+ it.effect("supports remove batching overload", () =>
39
+ Effect
40
+ .gen(function*() {
41
+ const repo = yield* makeRepo("BatchItem", BatchItem, {})
42
+ const items = [
43
+ new BatchItem({ id: "1", label: "one" }),
44
+ new BatchItem({ id: "2", label: "two" }),
45
+ new BatchItem({ id: "3", label: "three" }),
46
+ new BatchItem({ id: "4", label: "four" })
47
+ ] as const
48
+
49
+ yield* repo.save(items)
50
+ yield* repo.remove([items[0], items[1], items[2]], { batch: true })
51
+
52
+ const all = yield* repo.all
53
+ expect(all).toHaveLength(1)
54
+ expect(all[0]?.id).toBe("4")
55
+ })
56
+ .pipe(
57
+ setupRequestContextFromCurrent(),
58
+ Effect.provide(TestStoreLive)
59
+ ))
60
+ })
@@ -1,8 +1,7 @@
1
1
  import { describe, expect, expectTypeOf, it } from "@effect/vitest"
2
- import { Effect, Layer, Result, S, ServiceMap } from "effect-app"
2
+ import { Context, Effect, Layer, Result, RpcX, S } from "effect-app"
3
3
  import { NotLoggedInError, UnauthorizedError } from "effect-app/client"
4
4
  import { HttpHeaders } from "effect-app/http"
5
- import * as RpcX from "effect-app/rpc"
6
5
  import { MiddlewareMaker } from "effect-app/rpc"
7
6
  import type { unhandled } from "effect-app/Types"
8
7
  import { Rpc } from "effect/unstable/rpc"
@@ -63,11 +62,12 @@ const testSuite = (_mw: typeof middleware3) =>
63
62
  "works",
64
63
  Effect.fn(function*() {
65
64
  const defaultOpts = {
65
+ client: null as any, // TODO?
66
66
  headers: HttpHeaders.fromRecordUnsafe({}),
67
67
  payload: { _tag: "Test" },
68
68
  clientId: 0,
69
69
  requestId: "test-id" as any,
70
- rpc: { ...TestRpc, annotations: ServiceMap.make(_mw.requestContext, {}) }
70
+ rpc: { ...TestRpc, annotations: Context.make(_mw.requestContext, {}) }
71
71
  }
72
72
  const next = Effect.void as unknown as Effect.Effect<SuccessValue, unhandled, never>
73
73
  const layer = _mw.layer.pipe(
@@ -89,7 +89,7 @@ const testSuite = (_mw: typeof middleware3) =>
89
89
  headers: HttpHeaders.fromRecordUnsafe({ "x-user": "test-user", "x-is-manager": "true" }),
90
90
  rpc: {
91
91
  ...defaultOpts.rpc,
92
- annotations: ServiceMap.make(_mw.requestContext, { requireRoles: ["manager"] })
92
+ annotations: Context.make(_mw.requestContext, { requireRoles: ["manager"] })
93
93
  }
94
94
  })
95
95
  )
@@ -127,7 +127,7 @@ const testSuite = (_mw: typeof middleware3) =>
127
127
  Object.assign({ ...defaultOpts }, {
128
128
  rpc: {
129
129
  ...defaultOpts.rpc,
130
- annotations: ServiceMap.make(_mw.requestContext, { requireRoles: ["manager"] })
130
+ annotations: Context.make(_mw.requestContext, { requireRoles: ["manager"] })
131
131
  }
132
132
  })
133
133
  )
@@ -153,7 +153,7 @@ const testSuite = (_mw: typeof middleware3) =>
153
153
  {
154
154
  rpc: {
155
155
  ...defaultOpts.rpc,
156
- annotations: ServiceMap.make(_mw.requestContext, { requireRoles: ["manager"] })
156
+ annotations: Context.make(_mw.requestContext, { requireRoles: ["manager"] })
157
157
  }
158
158
  }
159
159
  )