@effect-app/infra 4.0.0-beta.112 → 4.0.0-beta.113
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 +14 -0
- package/dist/Model/Repository/Registry.d.ts +20 -0
- package/dist/Model/Repository/Registry.d.ts.map +1 -0
- package/dist/Model/Repository/Registry.js +17 -0
- package/dist/Model/Repository/internal/internal.d.ts.map +1 -1
- package/dist/Model/Repository/internal/internal.js +2 -1
- package/dist/Model/Repository/makeRepo.d.ts +3 -2
- package/dist/Model/Repository/makeRepo.d.ts.map +1 -1
- package/dist/Model/Repository/makeRepo.js +4 -1
- package/dist/Model/Repository/service.d.ts +5 -0
- package/dist/Model/Repository/service.d.ts.map +1 -1
- package/dist/Model/Repository.d.ts +1 -0
- package/dist/Model/Repository.d.ts.map +1 -1
- package/dist/Model/Repository.js +2 -1
- package/dist/Model.d.ts +1 -0
- package/dist/Model.d.ts.map +1 -1
- package/dist/Model.js +2 -1
- package/dist/OperationsRepo.d.ts +1 -1
- package/dist/Store/Cosmos.d.ts.map +1 -1
- package/dist/Store/Cosmos.js +10 -10
- package/dist/Store/Disk.d.ts.map +1 -1
- package/dist/Store/Disk.js +22 -18
- package/dist/Store/Memory.d.ts.map +1 -1
- package/dist/Store/Memory.js +23 -18
- package/dist/Store/SQL/Pg.d.ts.map +1 -1
- package/dist/Store/SQL/Pg.js +27 -21
- package/dist/Store/SQL.d.ts.map +1 -1
- package/dist/Store/SQL.js +52 -40
- package/dist/Store/index.d.ts +1 -1
- package/dist/Store/index.d.ts.map +1 -1
- package/dist/Store/index.js +4 -2
- package/dist/Store/service.d.ts +5 -0
- package/dist/Store/service.d.ts.map +1 -1
- package/dist/Store/service.js +1 -1
- package/dist/api/internal/RequestContextMiddleware.d.ts +1 -1
- package/package.json +6 -2
- package/src/Model/Repository/Registry.ts +33 -0
- package/src/Model/Repository/internal/internal.ts +1 -0
- package/src/Model/Repository/makeRepo.ts +5 -2
- package/src/Model/Repository/service.ts +6 -0
- package/src/Model/Repository.ts +1 -0
- package/src/Model.ts +1 -0
- package/src/Store/Cosmos.ts +10 -12
- package/src/Store/Disk.ts +35 -30
- package/src/Store/Memory.ts +25 -18
- package/src/Store/SQL/Pg.ts +29 -42
- package/src/Store/SQL.ts +58 -83
- package/src/Store/index.ts +2 -1
- package/src/Store/service.ts +5 -0
- package/test/dist/query.test.d.ts.map +1 -1
- package/test/dist/rawQuery.test.d.ts.map +1 -1
- package/test/query.test.ts +22 -19
- package/test/rawQuery.test.ts +4 -2
- package/test/validateSample.test.ts +11 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.test.d.ts","sourceRoot":"","sources":["../query.test.ts"],"names":[],"mappings":"AAIA,OAAO,EAA8C,CAAC,EAAU,MAAM,YAAY,CAAA;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"query.test.d.ts","sourceRoot":"","sources":["../query.test.ts"],"names":[],"mappings":"AAIA,OAAO,EAA8C,CAAC,EAAU,MAAM,YAAY,CAAA;;;;;;;;;;;;;;;;;AAgBlF,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,
|
|
1
|
+
{"version":3,"file":"rawQuery.test.d.ts","sourceRoot":"","sources":["../rawQuery.test.ts"],"names":[],"mappings":"AACA,OAAO,EAA+C,cAAc,EAAmC,MAAM,YAAY,CAAA;AASzH,eAAO,MAAM,EAAE,6CAWb,CAAA"}
|
package/test/query.test.ts
CHANGED
|
@@ -8,9 +8,12 @@ import { expect, expectTypeOf, it } from "vitest"
|
|
|
8
8
|
import { setupRequestContextFromCurrent } from "../src/api/setupRequest.js"
|
|
9
9
|
import { and, count, make, one, or, order, page, project, type QueryEnd, type QueryProjection, type QueryWhere, toFilter, where } from "../src/Model/query.js"
|
|
10
10
|
import { makeRepo } from "../src/Model/Repository.js"
|
|
11
|
+
import { RepositoryRegistryLive } from "../src/Model/Repository/Registry.js"
|
|
11
12
|
import { memFilter, MemoryStoreLive } from "../src/Store/Memory.js"
|
|
12
13
|
import { SomeService } from "./fixtures.js"
|
|
13
14
|
|
|
15
|
+
const TestStoreLive = Layer.merge(MemoryStoreLive, RepositoryRegistryLive)
|
|
16
|
+
|
|
14
17
|
const str = S.Struct({ _tag: S.Literal("string"), value: S.String })
|
|
15
18
|
const num = S.Struct({ _tag: S.Literal("number"), value: S.Finite })
|
|
16
19
|
const someUnion = S.Union([str, num])
|
|
@@ -113,7 +116,7 @@ class SomethingRepo extends Context.Service<SomethingRepo>()("SomethingRepo", {
|
|
|
113
116
|
})
|
|
114
117
|
)
|
|
115
118
|
.pipe(
|
|
116
|
-
Layer.provide(
|
|
119
|
+
Layer.provide(TestStoreLive)
|
|
117
120
|
)
|
|
118
121
|
}
|
|
119
122
|
|
|
@@ -280,7 +283,7 @@ it(
|
|
|
280
283
|
expect(result).toEqual([])
|
|
281
284
|
expect(result2).toEqual([])
|
|
282
285
|
})
|
|
283
|
-
.pipe(Effect.provide(
|
|
286
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
|
|
284
287
|
)
|
|
285
288
|
|
|
286
289
|
it(
|
|
@@ -466,7 +469,7 @@ it(
|
|
|
466
469
|
|
|
467
470
|
expect([]).toEqual([])
|
|
468
471
|
})
|
|
469
|
-
.pipe(Effect.provide(
|
|
472
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
|
|
470
473
|
)
|
|
471
474
|
|
|
472
475
|
it(
|
|
@@ -509,7 +512,7 @@ it(
|
|
|
509
512
|
|
|
510
513
|
expect([]).toEqual([])
|
|
511
514
|
})
|
|
512
|
-
.pipe(Effect.provide(
|
|
515
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
|
|
513
516
|
)
|
|
514
517
|
|
|
515
518
|
it(
|
|
@@ -542,7 +545,7 @@ it(
|
|
|
542
545
|
|
|
543
546
|
expect(result).toEqual([])
|
|
544
547
|
})
|
|
545
|
-
.pipe(Effect.provide(
|
|
548
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
|
|
546
549
|
)
|
|
547
550
|
|
|
548
551
|
it(
|
|
@@ -572,7 +575,7 @@ it(
|
|
|
572
575
|
|
|
573
576
|
expect(result).toEqual([])
|
|
574
577
|
})
|
|
575
|
-
.pipe(Effect.provide(
|
|
578
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
|
|
576
579
|
)
|
|
577
580
|
|
|
578
581
|
it(
|
|
@@ -616,7 +619,7 @@ it(
|
|
|
616
619
|
|
|
617
620
|
expect(result).toEqual([])
|
|
618
621
|
})
|
|
619
|
-
.pipe(Effect.provide(
|
|
622
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
|
|
620
623
|
)
|
|
621
624
|
|
|
622
625
|
it(
|
|
@@ -660,7 +663,7 @@ it(
|
|
|
660
663
|
|
|
661
664
|
expect(result).toEqual([])
|
|
662
665
|
})
|
|
663
|
-
.pipe(Effect.provide(
|
|
666
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise)
|
|
664
667
|
)
|
|
665
668
|
|
|
666
669
|
it("remove null from one constituent of a tagged union", () =>
|
|
@@ -709,7 +712,7 @@ it("remove null from one constituent of a tagged union", () =>
|
|
|
709
712
|
})[]
|
|
710
713
|
>()
|
|
711
714
|
})
|
|
712
|
-
.pipe(Effect.provide(
|
|
715
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
|
|
713
716
|
|
|
714
717
|
it("refine 3", () =>
|
|
715
718
|
Effect
|
|
@@ -747,7 +750,7 @@ it("refine 3", () =>
|
|
|
747
750
|
const resQuer1 = yield* repo.query(where("id", "AA"))
|
|
748
751
|
expectTypeOf(resQuer1).toEqualTypeOf<readonly AA[]>()
|
|
749
752
|
})
|
|
750
|
-
.pipe(Effect.provide(
|
|
753
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
|
|
751
754
|
|
|
752
755
|
it("my test", () =>
|
|
753
756
|
Effect
|
|
@@ -765,7 +768,7 @@ it("my test", () =>
|
|
|
765
768
|
)
|
|
766
769
|
expectTypeOf(resQuer1).toEqualTypeOf<readonly AA[]>()
|
|
767
770
|
})
|
|
768
|
-
.pipe(Effect.provide(
|
|
771
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
|
|
769
772
|
|
|
770
773
|
it("refine inner without imposing a projection", () =>
|
|
771
774
|
Effect
|
|
@@ -840,7 +843,7 @@ it("refine inner without imposing a projection", () =>
|
|
|
840
843
|
}[]
|
|
841
844
|
>()
|
|
842
845
|
})
|
|
843
|
-
.pipe(Effect.provide(
|
|
846
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
|
|
844
847
|
|
|
845
848
|
it("does not allow string queries on arrays", () =>
|
|
846
849
|
Effect
|
|
@@ -875,7 +878,7 @@ it("does not allow string queries on arrays", () =>
|
|
|
875
878
|
expectTypeOf(good3).toEqualTypeOf<QueryWhere<Some, Some>>()
|
|
876
879
|
expectTypeOf(good4).toEqualTypeOf<QueryWhere<Some, Some>>()
|
|
877
880
|
})
|
|
878
|
-
.pipe(Effect.provide(
|
|
881
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
|
|
879
882
|
|
|
880
883
|
it("test array.length", () =>
|
|
881
884
|
Effect
|
|
@@ -916,7 +919,7 @@ it("test array.length", () =>
|
|
|
916
919
|
QueryWhere<Something, Something>
|
|
917
920
|
>()
|
|
918
921
|
})
|
|
919
|
-
.pipe(Effect.provide(
|
|
922
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
|
|
920
923
|
|
|
921
924
|
it("distribution over union", () =>
|
|
922
925
|
Effect
|
|
@@ -940,7 +943,7 @@ it("distribution over union", () =>
|
|
|
940
943
|
})[]
|
|
941
944
|
>()
|
|
942
945
|
})
|
|
943
|
-
.pipe(Effect.provide(
|
|
946
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
|
|
944
947
|
|
|
945
948
|
it("refine nested union", () =>
|
|
946
949
|
Effect
|
|
@@ -981,7 +984,7 @@ it("refine nested union", () =>
|
|
|
981
984
|
}[]
|
|
982
985
|
>()
|
|
983
986
|
})
|
|
984
|
-
.pipe(Effect.provide(
|
|
987
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
|
|
985
988
|
|
|
986
989
|
it("find with transformed id", () =>
|
|
987
990
|
Effect
|
|
@@ -1037,7 +1040,7 @@ it("find with transformed id", () =>
|
|
|
1037
1040
|
)
|
|
1038
1041
|
expect(Option.isNone(notFound)).toBe(true)
|
|
1039
1042
|
})
|
|
1040
|
-
.pipe(Effect.provide(
|
|
1043
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
|
|
1041
1044
|
|
|
1042
1045
|
it("find with transformed id in tagged union", () =>
|
|
1043
1046
|
Effect
|
|
@@ -1128,7 +1131,7 @@ it("find with transformed id in tagged union", () =>
|
|
|
1128
1131
|
)
|
|
1129
1132
|
expect(Option.isNone(notFound)).toBe(true)
|
|
1130
1133
|
})
|
|
1131
|
-
.pipe(Effect.provide(
|
|
1134
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
|
|
1132
1135
|
|
|
1133
1136
|
it("refine union with nested union", () =>
|
|
1134
1137
|
Effect
|
|
@@ -1243,4 +1246,4 @@ it("refine union with nested union", () =>
|
|
|
1243
1246
|
})[]
|
|
1244
1247
|
>()
|
|
1245
1248
|
})
|
|
1246
|
-
.pipe(Effect.provide(
|
|
1249
|
+
.pipe(Effect.provide(TestStoreLive), setupRequestContextFromCurrent(), Effect.runPromise))
|
package/test/rawQuery.test.ts
CHANGED
|
@@ -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
|
|
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
|
|
|
@@ -76,7 +77,7 @@ class SomethingRepo extends Context.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
|
|
@@ -98,6 +99,7 @@ class SomethingRepo extends Context.Service<SomethingRepo>()(
|
|
|
98
99
|
prefix: "",
|
|
99
100
|
url
|
|
100
101
|
})
|
|
102
|
+
.pipe(Layer.merge(RepositoryRegistryLive))
|
|
101
103
|
})
|
|
102
104
|
.pipe(Layer.unwrap)
|
|
103
105
|
)
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { Effect, S } from "effect-app"
|
|
1
|
+
import { Effect, Layer, S } from "effect-app"
|
|
2
2
|
import { describe, expect, it } from "vitest"
|
|
3
3
|
import { setupRequestContextFromCurrent } from "../src/api/setupRequest.js"
|
|
4
4
|
import { makeRepo, ValidationError, ValidationResult } from "../src/Model/Repository.js"
|
|
5
|
+
import { RepositoryRegistryLive } from "../src/Model/Repository/Registry.js"
|
|
5
6
|
import { MemoryStoreLive } from "../src/Store/Memory.js"
|
|
6
7
|
|
|
8
|
+
const TestStoreLive = Layer.merge(MemoryStoreLive, RepositoryRegistryLive)
|
|
9
|
+
|
|
7
10
|
// simple schema for valid items
|
|
8
11
|
class SimpleItem extends S.Class<SimpleItem>("SimpleItem")({
|
|
9
12
|
id: S.String,
|
|
@@ -32,7 +35,7 @@ describe("validateSample", () => {
|
|
|
32
35
|
expect(result.errors).toHaveLength(0)
|
|
33
36
|
})
|
|
34
37
|
.pipe(
|
|
35
|
-
Effect.provide(
|
|
38
|
+
Effect.provide(TestStoreLive),
|
|
36
39
|
setupRequestContextFromCurrent(),
|
|
37
40
|
Effect.runPromise
|
|
38
41
|
))
|
|
@@ -80,7 +83,7 @@ describe("validateSample", () => {
|
|
|
80
83
|
expect(failingIds).toContain("3")
|
|
81
84
|
})
|
|
82
85
|
.pipe(
|
|
83
|
-
Effect.provide(
|
|
86
|
+
Effect.provide(TestStoreLive),
|
|
84
87
|
setupRequestContextFromCurrent(),
|
|
85
88
|
Effect.runPromise
|
|
86
89
|
))
|
|
@@ -98,7 +101,7 @@ describe("validateSample", () => {
|
|
|
98
101
|
expect(result.errors).toHaveLength(0)
|
|
99
102
|
})
|
|
100
103
|
.pipe(
|
|
101
|
-
Effect.provide(
|
|
104
|
+
Effect.provide(TestStoreLive),
|
|
102
105
|
setupRequestContextFromCurrent(),
|
|
103
106
|
Effect.runPromise
|
|
104
107
|
))
|
|
@@ -127,7 +130,7 @@ describe("validateSample", () => {
|
|
|
127
130
|
expect(result.errors).toHaveLength(0)
|
|
128
131
|
})
|
|
129
132
|
.pipe(
|
|
130
|
-
Effect.provide(
|
|
133
|
+
Effect.provide(TestStoreLive),
|
|
131
134
|
setupRequestContextFromCurrent(),
|
|
132
135
|
Effect.runPromise
|
|
133
136
|
))
|
|
@@ -161,7 +164,7 @@ describe("validateSample", () => {
|
|
|
161
164
|
expect(result.errors).toHaveLength(0)
|
|
162
165
|
})
|
|
163
166
|
.pipe(
|
|
164
|
-
Effect.provide(
|
|
167
|
+
Effect.provide(TestStoreLive),
|
|
165
168
|
setupRequestContextFromCurrent(),
|
|
166
169
|
Effect.runPromise
|
|
167
170
|
))
|
|
@@ -208,7 +211,7 @@ describe("validateSample", () => {
|
|
|
208
211
|
expect((error.error as any)._tag).toBe("SchemaError")
|
|
209
212
|
})
|
|
210
213
|
.pipe(
|
|
211
|
-
Effect.provide(
|
|
214
|
+
Effect.provide(TestStoreLive),
|
|
212
215
|
setupRequestContextFromCurrent(),
|
|
213
216
|
Effect.runPromise
|
|
214
217
|
))
|
|
@@ -230,7 +233,7 @@ describe("validateSample", () => {
|
|
|
230
233
|
expect(result.errors).toHaveLength(0)
|
|
231
234
|
})
|
|
232
235
|
.pipe(
|
|
233
|
-
Effect.provide(
|
|
236
|
+
Effect.provide(TestStoreLive),
|
|
234
237
|
setupRequestContextFromCurrent(),
|
|
235
238
|
Effect.runPromise
|
|
236
239
|
))
|