@effect-app/infra 4.0.0-beta.11 → 4.0.0-beta.111
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.
- package/CHANGELOG.md +729 -0
- package/dist/CUPS.d.ts +3 -3
- package/dist/CUPS.d.ts.map +1 -1
- package/dist/CUPS.js +3 -3
- package/dist/Emailer/service.d.ts +3 -3
- package/dist/Emailer/service.d.ts.map +1 -1
- package/dist/Emailer/service.js +3 -3
- package/dist/MainFiberSet.d.ts +2 -2
- package/dist/MainFiberSet.d.ts.map +1 -1
- package/dist/MainFiberSet.js +3 -3
- package/dist/Model/Repository/internal/internal.d.ts +3 -3
- package/dist/Model/Repository/internal/internal.d.ts.map +1 -1
- package/dist/Model/Repository/internal/internal.js +21 -16
- package/dist/Model/Repository/makeRepo.d.ts +2 -2
- package/dist/Model/Repository/makeRepo.d.ts.map +1 -1
- package/dist/Model/Repository/makeRepo.js +1 -1
- package/dist/Model/Repository/validation.d.ts +5 -4
- package/dist/Model/Repository/validation.d.ts.map +1 -1
- package/dist/Model/query/dsl.d.ts +9 -9
- package/dist/Operations.d.ts +2 -2
- package/dist/Operations.d.ts.map +1 -1
- package/dist/Operations.js +3 -3
- package/dist/OperationsRepo.d.ts +2 -2
- package/dist/OperationsRepo.d.ts.map +1 -1
- package/dist/OperationsRepo.js +3 -3
- package/dist/QueueMaker/SQLQueue.d.ts +2 -4
- package/dist/QueueMaker/SQLQueue.d.ts.map +1 -1
- package/dist/QueueMaker/SQLQueue.js +8 -6
- package/dist/QueueMaker/errors.d.ts +1 -1
- package/dist/QueueMaker/errors.d.ts.map +1 -1
- package/dist/QueueMaker/memQueue.js +3 -3
- package/dist/QueueMaker/sbqueue.js +3 -3
- package/dist/RequestContext.d.ts +19 -14
- package/dist/RequestContext.d.ts.map +1 -1
- package/dist/RequestContext.js +5 -5
- package/dist/RequestFiberSet.d.ts +2 -2
- package/dist/RequestFiberSet.d.ts.map +1 -1
- package/dist/RequestFiberSet.js +5 -5
- package/dist/Store/ContextMapContainer.d.ts +19 -3
- package/dist/Store/ContextMapContainer.d.ts.map +1 -1
- package/dist/Store/ContextMapContainer.js +13 -3
- package/dist/Store/Cosmos.d.ts.map +1 -1
- package/dist/Store/Cosmos.js +136 -68
- package/dist/Store/Disk.d.ts.map +1 -1
- package/dist/Store/Disk.js +3 -4
- package/dist/Store/Memory.d.ts +2 -2
- package/dist/Store/Memory.d.ts.map +1 -1
- package/dist/Store/Memory.js +4 -4
- package/dist/Store/SQL/Pg.d.ts +4 -0
- package/dist/Store/SQL/Pg.d.ts.map +1 -0
- package/dist/Store/SQL/Pg.js +186 -0
- package/dist/Store/SQL/query.d.ts +38 -0
- package/dist/Store/SQL/query.d.ts.map +1 -0
- package/dist/Store/SQL/query.js +367 -0
- package/dist/Store/SQL.d.ts +20 -0
- package/dist/Store/SQL.d.ts.map +1 -0
- package/dist/Store/SQL.js +370 -0
- package/dist/Store/index.d.ts +4 -1
- package/dist/Store/index.d.ts.map +1 -1
- package/dist/Store/index.js +12 -2
- package/dist/Store/service.d.ts +11 -5
- package/dist/Store/service.d.ts.map +1 -1
- package/dist/Store/service.js +24 -6
- package/dist/adapters/ServiceBus.d.ts +6 -6
- package/dist/adapters/ServiceBus.d.ts.map +1 -1
- package/dist/adapters/ServiceBus.js +9 -9
- package/dist/adapters/cosmos-client.d.ts +2 -2
- package/dist/adapters/cosmos-client.d.ts.map +1 -1
- package/dist/adapters/cosmos-client.js +3 -3
- package/dist/adapters/logger.d.ts.map +1 -1
- package/dist/adapters/memQueue.d.ts +2 -2
- package/dist/adapters/memQueue.d.ts.map +1 -1
- package/dist/adapters/memQueue.js +3 -3
- package/dist/adapters/mongo-client.d.ts +2 -2
- package/dist/adapters/mongo-client.d.ts.map +1 -1
- package/dist/adapters/mongo-client.js +3 -3
- package/dist/adapters/redis-client.d.ts +3 -3
- package/dist/adapters/redis-client.d.ts.map +1 -1
- package/dist/adapters/redis-client.js +3 -3
- package/dist/api/ContextProvider.d.ts +6 -6
- package/dist/api/ContextProvider.d.ts.map +1 -1
- package/dist/api/ContextProvider.js +6 -6
- package/dist/api/internal/auth.d.ts +1 -1
- package/dist/api/internal/events.d.ts +2 -2
- package/dist/api/internal/events.d.ts.map +1 -1
- package/dist/api/internal/events.js +6 -4
- package/dist/api/layerUtils.d.ts +5 -5
- package/dist/api/layerUtils.d.ts.map +1 -1
- package/dist/api/layerUtils.js +5 -5
- package/dist/api/routing/middleware/RouterMiddleware.d.ts +3 -3
- package/dist/api/routing/middleware/RouterMiddleware.d.ts.map +1 -1
- package/dist/api/routing/middleware/middleware.d.ts +35 -1
- package/dist/api/routing/middleware/middleware.d.ts.map +1 -1
- package/dist/api/routing/middleware/middleware.js +39 -1
- package/dist/api/routing.d.ts +1 -5
- package/dist/api/routing.d.ts.map +1 -1
- package/dist/api/routing.js +3 -2
- package/dist/api/setupRequest.d.ts +6 -3
- package/dist/api/setupRequest.d.ts.map +1 -1
- package/dist/api/setupRequest.js +11 -6
- package/dist/logger.d.ts.map +1 -1
- package/examples/query.ts +30 -26
- package/package.json +32 -18
- package/src/CUPS.ts +2 -2
- package/src/Emailer/service.ts +2 -2
- package/src/MainFiberSet.ts +2 -2
- package/src/Model/Repository/internal/internal.ts +75 -59
- package/src/Model/Repository/makeRepo.ts +2 -2
- package/src/Operations.ts +2 -2
- package/src/OperationsRepo.ts +2 -2
- package/src/QueueMaker/SQLQueue.ts +8 -7
- package/src/QueueMaker/memQueue.ts +2 -2
- package/src/QueueMaker/sbqueue.ts +2 -2
- package/src/RequestContext.ts +4 -4
- package/src/RequestFiberSet.ts +4 -4
- package/src/Store/ContextMapContainer.ts +41 -2
- package/src/Store/Cosmos.ts +352 -255
- package/src/Store/Disk.ts +2 -3
- package/src/Store/Memory.ts +4 -4
- package/src/Store/SQL/Pg.ts +328 -0
- package/src/Store/SQL/query.ts +409 -0
- package/src/Store/SQL.ts +686 -0
- package/src/Store/index.ts +15 -1
- package/src/Store/service.ts +26 -7
- package/src/adapters/ServiceBus.ts +8 -8
- package/src/adapters/cosmos-client.ts +2 -2
- package/src/adapters/memQueue.ts +2 -2
- package/src/adapters/mongo-client.ts +2 -2
- package/src/adapters/redis-client.ts +2 -2
- package/src/api/ContextProvider.ts +11 -11
- package/src/api/internal/events.ts +6 -5
- package/src/api/layerUtils.ts +8 -8
- package/src/api/routing/middleware/RouterMiddleware.ts +4 -4
- package/src/api/routing/middleware/middleware.ts +43 -0
- package/src/api/routing.ts +3 -3
- package/src/api/setupRequest.ts +27 -7
- package/test/contextProvider.test.ts +11 -11
- package/test/controller.test.ts +12 -9
- package/test/dist/contextProvider.test.d.ts.map +1 -1
- package/test/dist/controller.test.d.ts.map +1 -1
- package/test/dist/date-query.test.d.ts.map +1 -0
- package/test/dist/fixtures.d.ts +18 -8
- package/test/dist/fixtures.d.ts.map +1 -1
- package/test/dist/fixtures.js +11 -9
- package/test/dist/query.test.d.ts.map +1 -1
- package/test/dist/rawQuery.test.d.ts.map +1 -1
- package/test/dist/requires.test.d.ts.map +1 -1
- package/test/dist/rpc-multi-middleware.test.d.ts.map +1 -1
- package/test/dist/sql-store.test.d.ts.map +1 -0
- package/test/fixtures.ts +10 -8
- package/test/query.test.ts +162 -16
- package/test/rawQuery.test.ts +19 -17
- package/test/requires.test.ts +6 -5
- package/test/rpc-multi-middleware.test.ts +72 -3
- package/test/sql-store.test.ts +1064 -0
- package/test/validateSample.test.ts +1 -1
- package/tsconfig.json +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
3
|
import { expectTypeOf, it } from "@effect/vitest"
|
|
4
|
-
import { Effect, Layer, Scope
|
|
4
|
+
import { Context, Effect, Layer, Scope } from "effect-app"
|
|
5
5
|
import { ContextProvider, mergeContextProviders, MergedContextProvider } from "../src/api/ContextProvider.js"
|
|
6
6
|
import { CustomError1, Some, SomeElse, SomeService } from "./fixtures.js"
|
|
7
7
|
|
|
8
8
|
// @effect-diagnostics-next-line missingEffectServiceDependency:off
|
|
9
|
-
class MyContextProvider extends
|
|
9
|
+
class MyContextProvider extends Context.Service<MyContextProvider>()(
|
|
10
10
|
"MyContextProvider",
|
|
11
11
|
{
|
|
12
12
|
make: Effect.gen(function*() {
|
|
@@ -20,7 +20,7 @@ class MyContextProvider extends ServiceMap.Service<MyContextProvider>()(
|
|
|
20
20
|
yield* Effect.logInfo("MyContextProviderGen", "this is a generator")
|
|
21
21
|
yield* Effect.succeed("this is a generator")
|
|
22
22
|
|
|
23
|
-
return Some.
|
|
23
|
+
return Some.contextMap({ a: 1 })
|
|
24
24
|
})
|
|
25
25
|
})
|
|
26
26
|
}
|
|
@@ -28,7 +28,7 @@ class MyContextProvider extends ServiceMap.Service<MyContextProvider>()(
|
|
|
28
28
|
static readonly Default = Layer.effect(this, this.make)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
class MyContextProvider2 extends
|
|
31
|
+
class MyContextProvider2 extends Context.Service<MyContextProvider2>()(
|
|
32
32
|
"MyContextProvider2",
|
|
33
33
|
{
|
|
34
34
|
make: Effect.gen(function*() {
|
|
@@ -37,7 +37,7 @@ class MyContextProvider2 extends ServiceMap.Service<MyContextProvider2>()(
|
|
|
37
37
|
return Effect.gen(function*() {
|
|
38
38
|
// we test without dependencies, so that we end up with an R of never.
|
|
39
39
|
|
|
40
|
-
return SomeElse.
|
|
40
|
+
return SomeElse.contextMap({ b: 2 })
|
|
41
41
|
})
|
|
42
42
|
})
|
|
43
43
|
}
|
|
@@ -45,7 +45,7 @@ class MyContextProvider2 extends ServiceMap.Service<MyContextProvider2>()(
|
|
|
45
45
|
static readonly Default = Layer.effect(this, this.make)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
class MyContextProvider2Gen extends
|
|
48
|
+
class MyContextProvider2Gen extends Context.Service<MyContextProvider2Gen>()(
|
|
49
49
|
"MyContextProvider2Gen",
|
|
50
50
|
{
|
|
51
51
|
make: Effect.gen(function*() {
|
|
@@ -54,7 +54,7 @@ class MyContextProvider2Gen extends ServiceMap.Service<MyContextProvider2Gen>()(
|
|
|
54
54
|
return function*() {
|
|
55
55
|
// we test without dependencies, so that we end up with an R of never
|
|
56
56
|
|
|
57
|
-
return SomeElse.
|
|
57
|
+
return SomeElse.contextMap({ b: 2 })
|
|
58
58
|
}
|
|
59
59
|
})
|
|
60
60
|
}
|
|
@@ -63,7 +63,7 @@ class MyContextProvider2Gen extends ServiceMap.Service<MyContextProvider2Gen>()(
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
// @effect-diagnostics-next-line missingEffectServiceDependency:off
|
|
66
|
-
class MyContextProviderGen extends
|
|
66
|
+
class MyContextProviderGen extends Context.Service<MyContextProviderGen>()(
|
|
67
67
|
"MyContextProviderGen",
|
|
68
68
|
{
|
|
69
69
|
make: Effect.gen(function*() {
|
|
@@ -77,7 +77,7 @@ class MyContextProviderGen extends ServiceMap.Service<MyContextProviderGen>()(
|
|
|
77
77
|
yield* Effect.logInfo("MyContextProviderGen", "this is a generator")
|
|
78
78
|
yield* Effect.succeed("this is a generator")
|
|
79
79
|
|
|
80
|
-
return Some.
|
|
80
|
+
return Some.contextMap({ a: 1 })
|
|
81
81
|
}
|
|
82
82
|
})
|
|
83
83
|
}
|
|
@@ -100,7 +100,7 @@ export const someContextProvider = ContextProvider({
|
|
|
100
100
|
// currently the effectful context provider cannot trigger an error when building the per request context
|
|
101
101
|
// if (Math.random() > 0.5) return yield* new CustomError2()
|
|
102
102
|
|
|
103
|
-
return Some.
|
|
103
|
+
return Some.contextMap({ a: 1 })
|
|
104
104
|
})
|
|
105
105
|
})
|
|
106
106
|
})
|
|
@@ -119,7 +119,7 @@ export const someContextProviderGen = ContextProvider({
|
|
|
119
119
|
// currently the effectful context provider cannot trigger an error when building the per request context
|
|
120
120
|
// if (Math.random() > 0.5) return yield* new CustomError2()
|
|
121
121
|
|
|
122
|
-
return Some.
|
|
122
|
+
return Some.contextMap({ a: 1 })
|
|
123
123
|
}
|
|
124
124
|
})
|
|
125
125
|
})
|
package/test/controller.test.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
3
|
import { type MakeContext, type MakeErrors, makeRouter } from "@effect-app/infra/api/routing"
|
|
4
4
|
import { expect, expectTypeOf, it } from "@effect/vitest"
|
|
5
|
-
import { Effect, Layer, S, Scope
|
|
5
|
+
import { Context, Effect, Layer, S, Scope } from "effect-app"
|
|
6
6
|
import { InvalidStateError, makeRpcClient, UnauthorizedError } from "effect-app/client"
|
|
7
7
|
import { DefaultGenericMiddlewares } from "effect-app/middleware"
|
|
8
8
|
import * as RpcX from "effect-app/rpc"
|
|
@@ -99,7 +99,7 @@ class MyContextProvider2
|
|
|
99
99
|
|
|
100
100
|
//
|
|
101
101
|
|
|
102
|
-
class Str extends
|
|
102
|
+
class Str extends Context.Service<Str, "str">()("str") {}
|
|
103
103
|
|
|
104
104
|
export class BogusMiddleware extends RpcX.RpcMiddleware.Tag<BogusMiddleware>()("BogusMiddleware") {
|
|
105
105
|
static Default = Layer.make(this, {
|
|
@@ -202,10 +202,13 @@ export const middleware3 = MiddlewareMaker
|
|
|
202
202
|
.middleware(Test)
|
|
203
203
|
.middleware(BogusMiddleware)
|
|
204
204
|
|
|
205
|
-
export const {
|
|
205
|
+
export const { TaggedRequestFor } = makeRpcClient(RequestContextMap)
|
|
206
|
+
const Req = TaggedRequestFor("Something")
|
|
206
207
|
|
|
207
208
|
export class Eff extends Req<Eff>()("Eff", {}, { success: S.Void }) {}
|
|
208
|
-
export class Gen extends Req<Gen>()("Gen", {}
|
|
209
|
+
export class Gen extends Req<Gen>()("Gen", {}) {}
|
|
210
|
+
|
|
211
|
+
expectTypeOf(Eff.error).toEqualTypeOf<typeof Gen.error>()
|
|
209
212
|
|
|
210
213
|
export class DoSomething extends Req<DoSomething>()("DoSomething", {
|
|
211
214
|
id: S.String
|
|
@@ -231,14 +234,14 @@ export class GetSomething extends Req<GetSomething>()("GetSomething", {
|
|
|
231
234
|
|
|
232
235
|
export class GetSomething2 extends Req<GetSomething2>()("GetSomething2", {
|
|
233
236
|
id: S.String
|
|
234
|
-
}, { success: S.
|
|
237
|
+
}, { success: S.FiniteFromString }) {}
|
|
235
238
|
|
|
236
|
-
const Something = { Eff, Gen, DoSomething, GetSomething, GetSomething2
|
|
239
|
+
const Something = { Eff, Gen, DoSomething, GetSomething, GetSomething2 }
|
|
237
240
|
|
|
238
241
|
// const client = ApiClientFactory.makeFor(Layer.empty)(Something)
|
|
239
242
|
// client.pipe(Effect.map(c => c.DoSomething.name))
|
|
240
243
|
|
|
241
|
-
export class SomethingService extends
|
|
244
|
+
export class SomethingService extends Context.Service<SomethingService>()(
|
|
242
245
|
"SomethingService",
|
|
243
246
|
{
|
|
244
247
|
make: Effect.gen(function*() {
|
|
@@ -258,7 +261,7 @@ declare const a: {
|
|
|
258
261
|
(opt: { b: 3 }): void
|
|
259
262
|
}
|
|
260
263
|
|
|
261
|
-
export class SomethingRepo extends
|
|
264
|
+
export class SomethingRepo extends Context.Service<SomethingRepo>()(
|
|
262
265
|
"SomethingRepo",
|
|
263
266
|
{
|
|
264
267
|
make: Effect.gen(function*() {
|
|
@@ -271,7 +274,7 @@ export class SomethingRepo extends ServiceMap.Service<SomethingRepo>()(
|
|
|
271
274
|
static Default = Layer.effect(this, this.make).pipe(Layer.provide(SomethingService.Default))
|
|
272
275
|
}
|
|
273
276
|
|
|
274
|
-
export class SomethingService2 extends
|
|
277
|
+
export class SomethingService2 extends Context.Service<SomethingService2>()(
|
|
275
278
|
"SomethingService2",
|
|
276
279
|
{
|
|
277
280
|
make: Effect.gen(function*() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextProvider.test.d.ts","sourceRoot":"","sources":["../contextProvider.test.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"contextProvider.test.d.ts","sourceRoot":"","sources":["../contextProvider.test.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAE1D,OAAO,EAAE,YAAY,EAAE,IAAI,EAAY,WAAW,EAAE,MAAM,eAAe,CAAA;AAkFzE,eAAO,MAAM,mBAAmB;;CAkB9B,CAAA;AACF,eAAO,MAAM,sBAAsB;;CAkBjC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.test.d.ts","sourceRoot":"","sources":["../controller.test.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAc,MAAM,+BAA+B,CAAA;AAE7F,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"controller.test.d.ts","sourceRoot":"","sources":["../controller.test.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAc,MAAM,+BAA+B,CAAA;AAE7F,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAC7D,OAAO,EAAoC,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAEvF,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AAGtC,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAG3D,OAAO,EAAE,cAAc,EAAsB,YAAY,EAAqB,YAAY,EAAoB,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAY,MAAM,eAAe,CAAA;;cAuE/G,QAAQ;;AADzE,cAAM,kBACJ,SAAQ,uBAA0F;IAElG,MAAM,CAAC,OAAO,uDAUZ;CACH;;AAID,cAAM,GAAI,SAAQ,QAAoC;CAAG;;;;;AAEzD,qBAAa,e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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0LP,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-query.test.d.ts","sourceRoot":"","sources":["../date-query.test.ts"],"names":[],"mappings":""}
|
package/test/dist/fixtures.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { Effect, Layer, S
|
|
1
|
+
import { Context, Effect, Layer, S } from "effect-app";
|
|
2
2
|
import { NotLoggedInError, UnauthorizedError } from "effect-app/client";
|
|
3
3
|
import { RpcContextMap, RpcX } from "effect-app/rpc";
|
|
4
4
|
declare const UserProfile_base: S.EnhancedClass<UserProfile, S.Struct<{
|
|
5
5
|
id: S.String;
|
|
6
6
|
roles: S.$Array<S.String> & {
|
|
7
|
-
withDefault: S.withConstructorDefault<S.$Array<S.String
|
|
7
|
+
withDefault: S.withConstructorDefault<S.$Array<S.String>>;
|
|
8
|
+
withDecodingDefaultType: S.withDecodingDefaultType<S.$Array<S.String>>;
|
|
8
9
|
};
|
|
9
|
-
}>, {}> &
|
|
10
|
+
}>, {}> & Context.Opaque<UserProfile, UserProfile>;
|
|
10
11
|
export declare class UserProfile extends UserProfile_base {
|
|
11
12
|
}
|
|
12
|
-
declare const Some_base:
|
|
13
|
+
declare const Some_base: Context.OpaqueClass<Some, "Some", {
|
|
13
14
|
a: number;
|
|
14
15
|
}> & {
|
|
15
16
|
readonly make: Effect.Effect<{
|
|
@@ -18,7 +19,7 @@ declare const Some_base: ServiceMap.OpaqueClass<Some, "Some", {
|
|
|
18
19
|
};
|
|
19
20
|
export declare class Some extends Some_base {
|
|
20
21
|
}
|
|
21
|
-
declare const SomeElse_base:
|
|
22
|
+
declare const SomeElse_base: Context.OpaqueClass<SomeElse, "SomeElse", {
|
|
22
23
|
b: number;
|
|
23
24
|
}> & {
|
|
24
25
|
readonly make: Effect.Effect<{
|
|
@@ -27,7 +28,7 @@ declare const SomeElse_base: ServiceMap.OpaqueClass<SomeElse, "SomeElse", {
|
|
|
27
28
|
};
|
|
28
29
|
export declare class SomeElse extends SomeElse_base {
|
|
29
30
|
}
|
|
30
|
-
declare const SomeService_base:
|
|
31
|
+
declare const SomeService_base: Context.OpaqueClass<SomeService, "SomeService", {
|
|
31
32
|
a: number;
|
|
32
33
|
}> & {
|
|
33
34
|
readonly make: Effect.Effect<{
|
|
@@ -101,10 +102,19 @@ declare const Test_base: RpcX.RpcMiddleware.TagClass<Test, "Test", {
|
|
|
101
102
|
export declare class Test extends Test_base {
|
|
102
103
|
}
|
|
103
104
|
export declare const TestLive: Layer.Layer<Test, never, never>;
|
|
104
|
-
declare const
|
|
105
|
+
declare const Counter_base: Context.OpaqueClass<Counter, "Counter", {
|
|
106
|
+
a: number;
|
|
107
|
+
}> & {
|
|
108
|
+
readonly make: Effect.Effect<{
|
|
109
|
+
a: number;
|
|
110
|
+
}, never, never>;
|
|
111
|
+
};
|
|
112
|
+
export declare class Counter extends Counter_base {
|
|
113
|
+
}
|
|
114
|
+
declare const CustomError1_base: import("effect/Schema").Class<CustomError1, S.TaggedStruct<"CustomError1", {}>, import("effect/Cause").YieldableError>;
|
|
105
115
|
export declare class CustomError1 extends CustomError1_base {
|
|
106
116
|
}
|
|
107
|
-
declare const CustomError2_base:
|
|
117
|
+
declare const CustomError2_base: import("effect/Schema").Class<CustomError2, S.TaggedStruct<"CustomError2", {}>, import("effect/Cause").YieldableError>;
|
|
108
118
|
export declare class CustomError2 extends CustomError2_base {
|
|
109
119
|
}
|
|
110
120
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAS,
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,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UnauthorizedError } from "effect-app/client";
|
|
3
3
|
import { RpcContextMap, RpcX } from "effect-app/rpc";
|
|
4
|
-
import {
|
|
5
|
-
export class UserProfile extends
|
|
4
|
+
import { TaggedErrorClass } from "effect-app/Schema";
|
|
5
|
+
export class UserProfile extends Context.assignTag("UserProfile")(S.Class("UserProfile")({
|
|
6
6
|
id: S.String,
|
|
7
7
|
roles: S.Array(S.String)
|
|
8
8
|
})) {
|
|
9
9
|
}
|
|
10
|
-
export class Some extends
|
|
10
|
+
export class Some extends Context.Opaque()("Some", { make: Effect.succeed({ a: 1 }) }) {
|
|
11
11
|
}
|
|
12
|
-
export class SomeElse extends
|
|
12
|
+
export class SomeElse extends Context.Opaque()("SomeElse", { make: Effect.succeed({ b: 2 }) }) {
|
|
13
13
|
}
|
|
14
14
|
const MakeSomeService = Effect.succeed({ a: 1 });
|
|
15
|
-
export class SomeService extends
|
|
15
|
+
export class SomeService extends Context.Opaque()("SomeService", { make: MakeSomeService }) {
|
|
16
16
|
static Default = this.toLayer(this.make);
|
|
17
17
|
}
|
|
18
18
|
// functionally equivalent to the one above
|
|
@@ -90,8 +90,10 @@ export const TestLive = Layer.effect(Test, Effect.gen(function* () {
|
|
|
90
90
|
return yield* effect;
|
|
91
91
|
});
|
|
92
92
|
}));
|
|
93
|
-
export class
|
|
93
|
+
export class Counter extends Context.Opaque()("Counter", { make: Effect.succeed({ a: 0 }) }) {
|
|
94
94
|
}
|
|
95
|
-
export class
|
|
95
|
+
export class CustomError1 extends TaggedErrorClass()("CustomError1", {}) {
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
export class CustomError2 extends TaggedErrorClass()("CustomError2", {}) {
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZml4dHVyZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9maXh0dXJlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIj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mappings":"
|
|
1
|
+
{"version":3,"file":"query.test.d.ts","sourceRoot":"","sources":["../query.test.ts"],"names":[],"mappings":"AAIA,OAAO,EAA8C,CAAC,EAAU,MAAM,YAAY,CAAA;;;;;;;;;;;;;;;;;AAalF,qBAAa,SAAU,SAAQ,cAM7B;CAAG;AACL,MAAM,CAAC,OAAO,WAAW,SAAS,CAAC;IAEjC,UAAiB,OAAQ,SAAQ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,SAAS,CAAC;KAAG;CACtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rawQuery.test.d.ts","sourceRoot":"","sources":["../rawQuery.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,cAAc,
|
|
1
|
+
{"version":3,"file":"rawQuery.test.d.ts","sourceRoot":"","sources":["../rawQuery.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,cAAc,EAA4C,MAAM,YAAY,CAAA;AAQzH,eAAO,MAAM,EAAE,6CAWb,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requires.test.d.ts","sourceRoot":"","sources":["../requires.test.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"requires.test.d.ts","sourceRoot":"","sources":["../requires.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,EAAU,CAAC,EAAE,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAEvE,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AAKtC,OAAO,EAAE,cAAc,EAAyC,YAAY,EAAoB,IAAI,EAAE,kBAAkB,EAA0B,cAAc,EAAmC,IAAI,EAAY,MAAM,eAAe,CAAA;;cAGnK,IAAI;;AADzE,qBAAa,sBACX,SAAQ,2BAA8F;IAEtG,MAAM,CAAC,OAAO,oDASZ;CACH;AAqBD,eAAO,MAAM,eAAe;;;;;;;;;;SAMK,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-multi-middleware.test.d.ts","sourceRoot":"","sources":["../rpc-multi-middleware.test.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,KAAK,
|
|
1
|
+
{"version":3,"file":"rpc-multi-middleware.test.d.ts","sourceRoot":"","sources":["../rpc-multi-middleware.test.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,KAAK,EAAe,MAAM,QAAQ,CAAA;AAC5D,OAAO,EAAW,CAAC,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGhD,OAAO,EAAE,GAAG,EAAE,SAAS,EAAkD,MAAM,qBAAqB,CAAA;AAGpG,OAAO,EAAE,cAAc,EAAyC,YAAY,EAA0B,kBAAkB,EAA0B,cAAc,EAAmC,IAAI,EAAY,WAAW,EAAE,MAAM,eAAe,CAAA;AAErP,QAAA,MAAM,UAAU;;;;;;;;;;oCAGmB,CAAA;AAGnC,qBAAa,oBAAqB,SAAQ,UAAU;CAAG;;;;;;;;;;;;AAEvD,cAAM,UAAW,SAAQ,eAKkB;CACzC;AAsCF,eAAO,MAAM,OAAO,iEAMhB,CAAA;AAgBJ,eAAO,MAAM,YAAY,2HAItB,CAAA;AAEH,eAAO,MAAM,YAAY,yIAgB2B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-store.test.d.ts","sourceRoot":"","sources":["../sql-store.test.ts"],"names":[],"mappings":""}
|
package/test/fixtures.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Effect, Layer, S, Scope
|
|
1
|
+
import { Context, Effect, Layer, S, Scope } from "effect-app"
|
|
2
2
|
import { NotLoggedInError, UnauthorizedError } from "effect-app/client"
|
|
3
3
|
import { RpcContextMap, RpcX } from "effect-app/rpc"
|
|
4
|
-
import {
|
|
4
|
+
import { TaggedErrorClass } from "effect-app/Schema"
|
|
5
5
|
|
|
6
|
-
export class UserProfile extends
|
|
6
|
+
export class UserProfile extends Context.assignTag<UserProfile, UserProfile>("UserProfile")(
|
|
7
7
|
S.Class<UserProfile>("UserProfile")({
|
|
8
8
|
id: S.String,
|
|
9
9
|
roles: S.Array(S.String)
|
|
@@ -11,10 +11,10 @@ export class UserProfile extends ServiceMap.assignTag<UserProfile, UserProfile>(
|
|
|
11
11
|
) {
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export class Some extends
|
|
15
|
-
export class SomeElse extends
|
|
14
|
+
export class Some extends Context.Opaque<Some>()("Some", { make: Effect.succeed({ a: 1 }) }) {}
|
|
15
|
+
export class SomeElse extends Context.Opaque<SomeElse>()("SomeElse", { make: Effect.succeed({ b: 2 }) }) {}
|
|
16
16
|
const MakeSomeService = Effect.succeed({ a: 1 })
|
|
17
|
-
export class SomeService extends
|
|
17
|
+
export class SomeService extends Context.Opaque<SomeService>()("SomeService", { make: MakeSomeService }) {
|
|
18
18
|
static readonly Default = this.toLayer(this.make)
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -128,5 +128,7 @@ export const TestLive = Layer.effect(
|
|
|
128
128
|
})
|
|
129
129
|
)
|
|
130
130
|
|
|
131
|
-
export class
|
|
132
|
-
|
|
131
|
+
export class Counter extends Context.Opaque<Counter>()("Counter", { make: Effect.succeed({ a: 0 }) }) {}
|
|
132
|
+
|
|
133
|
+
export class CustomError1 extends TaggedErrorClass<CustomError1>()("CustomError1", {}) {}
|
|
134
|
+
export class CustomError2 extends TaggedErrorClass<CustomError2>()("CustomError2", {}) {}
|
package/test/query.test.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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 {
|
|
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"
|
|
@@ -11,7 +12,7 @@ import { memFilter, MemoryStoreLive } from "../src/Store/Memory.js"
|
|
|
11
12
|
import { SomeService } from "./fixtures.js"
|
|
12
13
|
|
|
13
14
|
const str = S.Struct({ _tag: S.Literal("string"), value: S.String })
|
|
14
|
-
const num = S.Struct({ _tag: S.Literal("number"), value: S.
|
|
15
|
+
const num = S.Struct({ _tag: S.Literal("number"), value: S.Finite })
|
|
15
16
|
const someUnion = S.Union([str, num])
|
|
16
17
|
|
|
17
18
|
export class Something extends S.Class<Something>("Something")({
|
|
@@ -19,7 +20,7 @@ export class Something extends S.Class<Something>("Something")({
|
|
|
19
20
|
displayName: S.NonEmptyString255,
|
|
20
21
|
name: S.NullOr(S.NonEmptyString255).withDefault,
|
|
21
22
|
n: S.Date.withDefault,
|
|
22
|
-
union: someUnion.pipe(S.
|
|
23
|
+
union: someUnion.pipe(S.withConstructorDefault(Effect.succeed({ _tag: "string" as const, value: "hi" })))
|
|
23
24
|
}) {}
|
|
24
25
|
export declare namespace Something {
|
|
25
26
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
@@ -90,8 +91,8 @@ it("works", () => {
|
|
|
90
91
|
|
|
91
92
|
const processed = memFilter(interpreted)(items.map((_) =>
|
|
92
93
|
S.encodeUnknownSync(S.Struct({
|
|
93
|
-
...
|
|
94
|
-
displayName: S.
|
|
94
|
+
...Struct.omit(Something.fields, ["displayName"]),
|
|
95
|
+
displayName: S.Literals(["Verona", "Riley"])
|
|
95
96
|
}))(_)
|
|
96
97
|
))
|
|
97
98
|
|
|
@@ -99,7 +100,7 @@ it("works", () => {
|
|
|
99
100
|
})
|
|
100
101
|
|
|
101
102
|
// @effect-diagnostics-next-line missingEffectServiceDependency:off
|
|
102
|
-
class SomethingRepo extends
|
|
103
|
+
class SomethingRepo extends Context.Service<SomethingRepo>()("SomethingRepo", {
|
|
103
104
|
make: Effect.gen(function*() {
|
|
104
105
|
return yield* makeRepo("Something", Something, {})
|
|
105
106
|
})
|
|
@@ -156,8 +157,6 @@ it("works with repo", () =>
|
|
|
156
157
|
|
|
157
158
|
expectTypeOf(smtArr).toEqualTypeOf<readonly Something[]>()
|
|
158
159
|
|
|
159
|
-
console.log(" $$$$$$")
|
|
160
|
-
console.log(Struct.pick(["id", "displayName"]))
|
|
161
160
|
expect(q1).toEqual(items.slice(0, 2).toReversed().map(Struct.pick(["id", "displayName"])))
|
|
162
161
|
expect(q2).toEqual(items.slice(0, 2).toReversed().map(Struct.pick(["displayName"])))
|
|
163
162
|
})
|
|
@@ -521,8 +520,8 @@ it(
|
|
|
521
520
|
const schema = S.Struct({
|
|
522
521
|
id: S.String,
|
|
523
522
|
createdAt: S.Date.pipe(
|
|
524
|
-
S.withDecodingDefault(() => new Date().toISOString()),
|
|
525
|
-
S.withConstructorDefault(() =>
|
|
523
|
+
S.withDecodingDefault(Effect.sync(() => new Date().toISOString())),
|
|
524
|
+
S.withConstructorDefault(Effect.sync(() => new Date()))
|
|
526
525
|
)
|
|
527
526
|
})
|
|
528
527
|
const repo = yield* makeRepo(
|
|
@@ -534,8 +533,8 @@ it(
|
|
|
534
533
|
const outputSchema = S.Struct({
|
|
535
534
|
id: S.Literal("123"),
|
|
536
535
|
createdAt: S.Date.pipe(
|
|
537
|
-
S.withDecodingDefault(() => new Date().toISOString()),
|
|
538
|
-
S.withConstructorDefault(() =>
|
|
536
|
+
S.withDecodingDefault(Effect.sync(() => new Date().toISOString())),
|
|
537
|
+
S.withConstructorDefault(Effect.sync(() => new Date()))
|
|
539
538
|
)
|
|
540
539
|
})
|
|
541
540
|
|
|
@@ -553,7 +552,7 @@ it(
|
|
|
553
552
|
.gen(function*() {
|
|
554
553
|
const schema = S.Struct({
|
|
555
554
|
id: S.String,
|
|
556
|
-
literals: S.
|
|
555
|
+
literals: S.Literals(["a", "b", "c"])
|
|
557
556
|
})
|
|
558
557
|
|
|
559
558
|
type Schema = typeof schema.Type
|
|
@@ -583,7 +582,7 @@ it(
|
|
|
583
582
|
.gen(function*() {
|
|
584
583
|
const schema = S.Struct({
|
|
585
584
|
id: S.String,
|
|
586
|
-
literals: S.Union([S.
|
|
585
|
+
literals: S.Union([S.Literals(["a", "b", "c"]), S.Null])
|
|
587
586
|
})
|
|
588
587
|
|
|
589
588
|
type Schema = typeof schema.Type
|
|
@@ -674,7 +673,7 @@ it("remove null from one constituent of a tagged union", () =>
|
|
|
674
673
|
|
|
675
674
|
class BB extends S.Class<BB>("BB")({
|
|
676
675
|
id: S.Literal("BB"),
|
|
677
|
-
b: S.NullOr(S.
|
|
676
|
+
b: S.NullOr(S.Finite)
|
|
678
677
|
}) {}
|
|
679
678
|
|
|
680
679
|
type Union = AA | BB
|
|
@@ -810,7 +809,7 @@ it("refine inner without imposing a projection", () =>
|
|
|
810
809
|
where("union._tag", "AA"),
|
|
811
810
|
// But if I wanna the whole Data as output ignoring the inner refinement
|
|
812
811
|
// I wanna be able to do so
|
|
813
|
-
project(
|
|
812
|
+
project(Data.mapFields(Struct.pick(["union"])))
|
|
814
813
|
)
|
|
815
814
|
|
|
816
815
|
expectTypeOf(query2).toEqualTypeOf<
|
|
@@ -984,6 +983,153 @@ it("refine nested union", () =>
|
|
|
984
983
|
})
|
|
985
984
|
.pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
|
|
986
985
|
|
|
986
|
+
it("find with transformed id", () =>
|
|
987
|
+
Effect
|
|
988
|
+
.gen(function*() {
|
|
989
|
+
const ConfiguratorId = S.NonEmptyString255
|
|
990
|
+
|
|
991
|
+
class PreconfigurationId extends S.Class<PreconfigurationId>("PreconfigurationId")({
|
|
992
|
+
configuratorId: ConfiguratorId,
|
|
993
|
+
label: S.NonEmptyString50
|
|
994
|
+
}) {}
|
|
995
|
+
|
|
996
|
+
const PreconfigurationIdFromString = S.NonEmptyString255.pipe(
|
|
997
|
+
S.decodeTo(
|
|
998
|
+
S.toType(PreconfigurationId),
|
|
999
|
+
SchemaTransformation.transformOrFail({
|
|
1000
|
+
decode: Effect.fnUntraced(function*(value) {
|
|
1001
|
+
const values = value.split("_")
|
|
1002
|
+
const label = yield* S.SchemaParser.decodeUnknownEffect(S.NonEmptyString50)(values.pop())
|
|
1003
|
+
const configuratorId = yield* S.SchemaParser.decodeUnknownEffect(ConfiguratorId)(values.join("_"))
|
|
1004
|
+
return new PreconfigurationId({ configuratorId, label })
|
|
1005
|
+
}),
|
|
1006
|
+
encode: (id) => Effect.succeed(S.NonEmptyString255(`${id.configuratorId}_${id.label}`))
|
|
1007
|
+
})
|
|
1008
|
+
),
|
|
1009
|
+
S.revealCodec
|
|
1010
|
+
)
|
|
1011
|
+
|
|
1012
|
+
const Preconfiguration = S.Struct({
|
|
1013
|
+
id: PreconfigurationIdFromString,
|
|
1014
|
+
name: S.String
|
|
1015
|
+
})
|
|
1016
|
+
|
|
1017
|
+
const repo = yield* makeRepo("Preconfiguration", Preconfiguration, { idKey: "id" as const })
|
|
1018
|
+
|
|
1019
|
+
const id = new PreconfigurationId({
|
|
1020
|
+
configuratorId: S.NonEmptyString255("myConfigurator"),
|
|
1021
|
+
label: S.NonEmptyString50("myLabel")
|
|
1022
|
+
})
|
|
1023
|
+
const item = { id, name: "test preconfig" }
|
|
1024
|
+
|
|
1025
|
+
yield* repo.saveAndPublish([item])
|
|
1026
|
+
|
|
1027
|
+
const found = yield* repo.find(id)
|
|
1028
|
+
expect(Option.isSome(found)).toBe(true)
|
|
1029
|
+
expect(Option.getOrThrow(found).name).toBe("test preconfig")
|
|
1030
|
+
expect(Option.getOrThrow(found).id).toEqual(id)
|
|
1031
|
+
|
|
1032
|
+
const notFound = yield* repo.find(
|
|
1033
|
+
new PreconfigurationId({
|
|
1034
|
+
configuratorId: S.NonEmptyString255("other"),
|
|
1035
|
+
label: S.NonEmptyString50("nope")
|
|
1036
|
+
})
|
|
1037
|
+
)
|
|
1038
|
+
expect(Option.isNone(notFound)).toBe(true)
|
|
1039
|
+
})
|
|
1040
|
+
.pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
|
|
1041
|
+
|
|
1042
|
+
it("find with transformed id in tagged union", () =>
|
|
1043
|
+
Effect
|
|
1044
|
+
.gen(function*() {
|
|
1045
|
+
const ConfiguratorId = S.NonEmptyString255
|
|
1046
|
+
|
|
1047
|
+
class PreconfigurationId extends S.Class<PreconfigurationId>("PreconfigurationId")({
|
|
1048
|
+
configuratorId: ConfiguratorId,
|
|
1049
|
+
label: S.NonEmptyString50
|
|
1050
|
+
}) {}
|
|
1051
|
+
|
|
1052
|
+
const PreconfigurationIdFromString = S.NonEmptyString255.pipe(
|
|
1053
|
+
S.decodeTo(
|
|
1054
|
+
S.toType(PreconfigurationId),
|
|
1055
|
+
SchemaTransformation.transformOrFail({
|
|
1056
|
+
decode: Effect.fnUntraced(function*(value) {
|
|
1057
|
+
const values = value.split("_")
|
|
1058
|
+
const label = yield* S.SchemaParser.decodeUnknownEffect(S.NonEmptyString50)(values.pop())
|
|
1059
|
+
const configuratorId = yield* S.SchemaParser.decodeUnknownEffect(ConfiguratorId)(values.join("_"))
|
|
1060
|
+
return new PreconfigurationId({ configuratorId, label })
|
|
1061
|
+
}),
|
|
1062
|
+
encode: (id) => Effect.succeed(S.NonEmptyString255(`${id.configuratorId}_${id.label}`))
|
|
1063
|
+
})
|
|
1064
|
+
),
|
|
1065
|
+
S.revealCodec
|
|
1066
|
+
)
|
|
1067
|
+
|
|
1068
|
+
class Draft extends S.TaggedClass<Draft>()("Draft", {
|
|
1069
|
+
id: PreconfigurationIdFromString,
|
|
1070
|
+
name: S.String
|
|
1071
|
+
}) {}
|
|
1072
|
+
|
|
1073
|
+
class Published extends S.TaggedClass<Published>()("Published", {
|
|
1074
|
+
id: PreconfigurationIdFromString,
|
|
1075
|
+
name: S.String,
|
|
1076
|
+
publishedAt: S.String
|
|
1077
|
+
}) {}
|
|
1078
|
+
|
|
1079
|
+
class Archived extends S.TaggedClass<Archived>()("Archived", {
|
|
1080
|
+
id: PreconfigurationIdFromString,
|
|
1081
|
+
name: S.String,
|
|
1082
|
+
archivedAt: S.String
|
|
1083
|
+
}) {}
|
|
1084
|
+
|
|
1085
|
+
const Preconfiguration = S.Union([Draft, Published, Archived])
|
|
1086
|
+
|
|
1087
|
+
const repo = yield* makeRepo("Preconfiguration", Preconfiguration, {})
|
|
1088
|
+
|
|
1089
|
+
const id1 = new PreconfigurationId({
|
|
1090
|
+
configuratorId: S.NonEmptyString255("conf1"),
|
|
1091
|
+
label: S.NonEmptyString50("draft1")
|
|
1092
|
+
})
|
|
1093
|
+
const id2 = new PreconfigurationId({
|
|
1094
|
+
configuratorId: S.NonEmptyString255("conf2"),
|
|
1095
|
+
label: S.NonEmptyString50("pub1")
|
|
1096
|
+
})
|
|
1097
|
+
const id3 = new PreconfigurationId({
|
|
1098
|
+
configuratorId: S.NonEmptyString255("conf3"),
|
|
1099
|
+
label: S.NonEmptyString50("arch1")
|
|
1100
|
+
})
|
|
1101
|
+
|
|
1102
|
+
const draft = new Draft({ id: id1, name: "my draft" })
|
|
1103
|
+
const published = new Published({ id: id2, name: "my published", publishedAt: "2024-01-01" })
|
|
1104
|
+
const archived = new Archived({ id: id3, name: "my archived", archivedAt: "2024-06-01" })
|
|
1105
|
+
|
|
1106
|
+
yield* repo.saveAndPublish([draft, published, archived])
|
|
1107
|
+
|
|
1108
|
+
// find each by their PreconfigurationId instance
|
|
1109
|
+
const foundDraft = yield* repo.find(id1)
|
|
1110
|
+
expect(Option.isSome(foundDraft)).toBe(true)
|
|
1111
|
+
expect(Option.getOrThrow(foundDraft)._tag).toBe("Draft")
|
|
1112
|
+
expect(Option.getOrThrow(foundDraft).name).toBe("my draft")
|
|
1113
|
+
|
|
1114
|
+
const foundPublished = yield* repo.find(id2)
|
|
1115
|
+
expect(Option.isSome(foundPublished)).toBe(true)
|
|
1116
|
+
expect(Option.getOrThrow(foundPublished)._tag).toBe("Published")
|
|
1117
|
+
|
|
1118
|
+
const foundArchived = yield* repo.find(id3)
|
|
1119
|
+
expect(Option.isSome(foundArchived)).toBe(true)
|
|
1120
|
+
expect(Option.getOrThrow(foundArchived)._tag).toBe("Archived")
|
|
1121
|
+
|
|
1122
|
+
// not found
|
|
1123
|
+
const notFound = yield* repo.find(
|
|
1124
|
+
new PreconfigurationId({
|
|
1125
|
+
configuratorId: S.NonEmptyString255("nope"),
|
|
1126
|
+
label: S.NonEmptyString50("nope")
|
|
1127
|
+
})
|
|
1128
|
+
)
|
|
1129
|
+
expect(Option.isNone(notFound)).toBe(true)
|
|
1130
|
+
})
|
|
1131
|
+
.pipe(Effect.provide(MemoryStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
|
|
1132
|
+
|
|
987
1133
|
it("refine union with nested union", () =>
|
|
988
1134
|
Effect
|
|
989
1135
|
.gen(function*() {
|