@effect-app/infra 4.0.0-beta.289 → 4.0.0-beta.290
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 +7 -0
- package/package.json +2 -2
- package/test/repository-ext.test.ts +64 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/infra",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.290",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"proper-lockfile": "^4.1.2",
|
|
11
11
|
"pure-rand": "8.4.0",
|
|
12
12
|
"query-string": "^9.4.0",
|
|
13
|
-
"effect-app": "4.0.0-beta.
|
|
13
|
+
"effect-app": "4.0.0-beta.290"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@azure/cosmos": "^4.9.3",
|
|
@@ -25,6 +25,52 @@ const union = S.Union([A, B, C])
|
|
|
25
25
|
|
|
26
26
|
const a = S.Struct({ id: S.String })
|
|
27
27
|
|
|
28
|
+
const nestedSourceItem = S.TaggedStruct("source-item", {
|
|
29
|
+
id: S.StringId,
|
|
30
|
+
label: S.String
|
|
31
|
+
})
|
|
32
|
+
const nestedProjectedItem = S.TaggedStruct("source-item", {
|
|
33
|
+
id: S.StringId
|
|
34
|
+
})
|
|
35
|
+
type NestedProjectedItem = typeof nestedProjectedItem.Type
|
|
36
|
+
const nestedSource = S.Struct({
|
|
37
|
+
id: S.String,
|
|
38
|
+
items: S.NonEmptyArray(nestedSourceItem),
|
|
39
|
+
label: S.String
|
|
40
|
+
})
|
|
41
|
+
const nestedProjection = S.Struct({
|
|
42
|
+
id: S.String,
|
|
43
|
+
items: S.NonEmptyArray(nestedProjectedItem)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const nestedProjectedItemsOf = (
|
|
47
|
+
items: readonly [NestedProjectedItem, ...NestedProjectedItem[]]
|
|
48
|
+
) => items
|
|
49
|
+
|
|
50
|
+
const nestedUnionSourceA = S.TaggedStruct("nested-a", {
|
|
51
|
+
id: S.String,
|
|
52
|
+
items: S.NonEmptyArray(nestedSourceItem),
|
|
53
|
+
label: S.String
|
|
54
|
+
})
|
|
55
|
+
const nestedUnionSourceB = S.TaggedStruct("nested-b", {
|
|
56
|
+
id: S.String,
|
|
57
|
+
items: S.NonEmptyArray(nestedSourceItem),
|
|
58
|
+
count: S.Number
|
|
59
|
+
})
|
|
60
|
+
const nestedUnionSource = S.Union([nestedUnionSourceA, nestedUnionSourceB])
|
|
61
|
+
const nestedUnionProjection = S.Union([
|
|
62
|
+
nestedUnionSourceA.mapFields((fields) => ({
|
|
63
|
+
id: fields.id,
|
|
64
|
+
_tag: fields._tag,
|
|
65
|
+
items: S.NonEmptyArray(nestedProjectedItem)
|
|
66
|
+
})),
|
|
67
|
+
nestedUnionSourceB.mapFields((fields) => ({
|
|
68
|
+
id: fields.id,
|
|
69
|
+
_tag: fields._tag,
|
|
70
|
+
items: S.NonEmptyArray(nestedProjectedItem)
|
|
71
|
+
}))
|
|
72
|
+
])
|
|
73
|
+
|
|
28
74
|
describe("repository ext save/remove batching", () => {
|
|
29
75
|
it.effect("supports projecting full repository schema", () =>
|
|
30
76
|
Effect
|
|
@@ -42,6 +88,24 @@ describe("repository ext save/remove batching", () => {
|
|
|
42
88
|
Effect.provide(TestStoreLive)
|
|
43
89
|
))
|
|
44
90
|
|
|
91
|
+
it.effect("supports nested DTO subset projections", () =>
|
|
92
|
+
Effect
|
|
93
|
+
.gen(function*() {
|
|
94
|
+
const repo = yield* makeRepo("NestedProjectionItem", nestedSource, {})
|
|
95
|
+
const unionRepo = yield* makeRepo("NestedUnionProjectionItem", nestedUnionSource, {})
|
|
96
|
+
const result = yield* repo.query(Q.project(nestedProjection, "project"))
|
|
97
|
+
const unionResult = yield* unionRepo.query(Q.project(nestedUnionProjection, "project"))
|
|
98
|
+
|
|
99
|
+
result.forEach((_) => nestedProjectedItemsOf(_.items))
|
|
100
|
+
unionResult.forEach((_) => nestedProjectedItemsOf(_.items))
|
|
101
|
+
expect(result).toEqual([])
|
|
102
|
+
expect(unionResult).toEqual([])
|
|
103
|
+
})
|
|
104
|
+
.pipe(
|
|
105
|
+
setupRequestContextFromCurrent(),
|
|
106
|
+
Effect.provide(TestStoreLive)
|
|
107
|
+
))
|
|
108
|
+
|
|
45
109
|
it.effect("supports save batching overload", () =>
|
|
46
110
|
Effect
|
|
47
111
|
.gen(function*() {
|