@effect-app/infra 4.0.0-beta.303 → 4.0.0-beta.304
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
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.304",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"proper-lockfile": "^4.1.2",
|
|
16
16
|
"pure-rand": "8.4.0",
|
|
17
17
|
"query-string": "^9.4.0",
|
|
18
|
-
"effect-app": "4.0.0-beta.
|
|
18
|
+
"effect-app": "4.0.0-beta.304"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@azure/cosmos": "^4.9.3",
|
|
@@ -170,7 +170,75 @@ describe("repository ext save/remove batching", () => {
|
|
|
170
170
|
.pipe(Effect.provideService(DataDependencies.DataDependencyRecorder, recorder))
|
|
171
171
|
|
|
172
172
|
expect(yield* Ref.get(readsRef)).toEqual(new Set([DataDependencies.repo("DependencyItem")]))
|
|
173
|
-
expect(yield* Ref.get(writesRef)).toEqual(new Set([DataDependencies.repo("DependencyItem")]))
|
|
173
|
+
expect(yield* Ref.get(writesRef)).toEqual(new Set([DataDependencies.repo("DependencyItem", ["1"])]))
|
|
174
|
+
})
|
|
175
|
+
.pipe(
|
|
176
|
+
setupRequestContextFromCurrent(),
|
|
177
|
+
Effect.provide(TestStoreLive)
|
|
178
|
+
))
|
|
179
|
+
|
|
180
|
+
it.effect("narrows direct repository reads to the requested entity", () =>
|
|
181
|
+
Effect
|
|
182
|
+
.gen(function*() {
|
|
183
|
+
const readsRef = yield* Ref.make(DataDependencies.empty())
|
|
184
|
+
const writesRef = yield* Ref.make(DataDependencies.empty())
|
|
185
|
+
const recorder = DataDependencies.makeDataDependencyRecorder(readsRef, writesRef)
|
|
186
|
+
|
|
187
|
+
yield* Effect
|
|
188
|
+
.gen(function*() {
|
|
189
|
+
const repo = yield* makeRepo("DependencyItem", BatchItem, {})
|
|
190
|
+
yield* repo.find("1")
|
|
191
|
+
})
|
|
192
|
+
.pipe(Effect.provideService(DataDependencies.DataDependencyRecorder, recorder))
|
|
193
|
+
|
|
194
|
+
expect(yield* Ref.get(readsRef)).toEqual(new Set([DataDependencies.repo("DependencyItem", ["1"])]))
|
|
195
|
+
})
|
|
196
|
+
.pipe(
|
|
197
|
+
setupRequestContextFromCurrent(),
|
|
198
|
+
Effect.provide(TestStoreLive)
|
|
199
|
+
))
|
|
200
|
+
|
|
201
|
+
it("matches entity dependencies by overlapping ids with a coarse fallback", () => {
|
|
202
|
+
const item1 = new Set([DataDependencies.repo("DependencyItem", ["1"])])
|
|
203
|
+
const item2 = new Set([DataDependencies.repo("DependencyItem", ["2"])])
|
|
204
|
+
const collection = new Set([DataDependencies.repo("DependencyItem")])
|
|
205
|
+
|
|
206
|
+
expect(DataDependencies.intersects(item1, item2)).toBe(false)
|
|
207
|
+
expect(DataDependencies.intersects(item1, item1)).toBe(true)
|
|
208
|
+
expect(DataDependencies.intersects(collection, item2)).toBe(true)
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
it("decodes repository dependencies produced before entity ids were added", () => {
|
|
212
|
+
expect(
|
|
213
|
+
S.decodeUnknownSync(DataDependencies.DataDependency)({
|
|
214
|
+
type: "repo",
|
|
215
|
+
name: "DependencyItem"
|
|
216
|
+
})
|
|
217
|
+
)
|
|
218
|
+
.toEqual(DataDependencies.repo("DependencyItem"))
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
it.effect("matches an explicit query scope to a write alias", () =>
|
|
222
|
+
Effect
|
|
223
|
+
.gen(function*() {
|
|
224
|
+
const readsRef = yield* Ref.make(DataDependencies.empty())
|
|
225
|
+
const writesRef = yield* Ref.make(DataDependencies.empty())
|
|
226
|
+
const recorder = DataDependencies.makeDataDependencyRecorder(readsRef, writesRef)
|
|
227
|
+
|
|
228
|
+
yield* Effect
|
|
229
|
+
.gen(function*() {
|
|
230
|
+
const repo = yield* makeRepo("DependencyItem", BatchItem, {
|
|
231
|
+
dependencyIds: (item) => [item.id, `alias-${item.id}`]
|
|
232
|
+
})
|
|
233
|
+
yield* repo.save(new BatchItem({ id: "1", label: "one" }))
|
|
234
|
+
yield* repo.all.pipe(DataDependencies.withRepoReadScope("DependencyItem", ["alias-1"]))
|
|
235
|
+
})
|
|
236
|
+
.pipe(Effect.provideService(DataDependencies.DataDependencyRecorder, recorder))
|
|
237
|
+
|
|
238
|
+
expect(yield* Ref.get(readsRef)).toEqual(new Set([DataDependencies.repo("DependencyItem", ["alias-1"])]))
|
|
239
|
+
expect(yield* Ref.get(writesRef)).toEqual(
|
|
240
|
+
new Set([DataDependencies.repo("DependencyItem", ["1", "alias-1"])])
|
|
241
|
+
)
|
|
174
242
|
})
|
|
175
243
|
.pipe(
|
|
176
244
|
setupRequestContextFromCurrent(),
|
|
@@ -358,8 +358,8 @@ it.live(
|
|
|
358
358
|
const writes = yield* Ref.get(writesRef)
|
|
359
359
|
expect(values).toStrictEqual([1, 2, 3])
|
|
360
360
|
// Each emitted value writes to RepoItem; routing drains the writes per chunk and the client
|
|
361
|
-
// accumulates
|
|
362
|
-
expect(writes).toStrictEqual(new Set([DataDependencies.repo("RepoItem")]))
|
|
361
|
+
// accumulates their entity ids into one dependency.
|
|
362
|
+
expect(writes).toStrictEqual(new Set([DataDependencies.repo("RepoItem", ["1", "2", "3"])]))
|
|
363
363
|
}, Effect.provide(TestLayer)),
|
|
364
364
|
{ timeout: 10_000 }
|
|
365
365
|
)
|
|
@@ -377,7 +377,7 @@ it.live(
|
|
|
377
377
|
const command = yield* withDependencyCapture(client.SaveRepoItem.handler({ id: "1", label: "one" }))
|
|
378
378
|
expect(Exit.isSuccess(command.result)).toBe(true)
|
|
379
379
|
expect(command.dependencies.reads).toStrictEqual(DataDependencies.empty())
|
|
380
|
-
expect(command.dependencies.writes).toStrictEqual(new Set([DataDependencies.repo("RepoItem")]))
|
|
380
|
+
expect(command.dependencies.writes).toStrictEqual(new Set([DataDependencies.repo("RepoItem", ["1"])]))
|
|
381
381
|
}, Effect.provide(TestLayer)),
|
|
382
382
|
{ timeout: 10_000 }
|
|
383
383
|
)
|
|
@@ -411,7 +411,7 @@ it.live(
|
|
|
411
411
|
// A command writing an UNRELATED repo => the query is NOT invalidated (negative control).
|
|
412
412
|
const saveOther = yield* withDependencyCapture(client.SaveOtherItem.handler({ id: "2", label: "two" }))
|
|
413
413
|
expect(Exit.isSuccess(saveOther.result)).toBe(true)
|
|
414
|
-
expect(saveOther.dependencies.writes).toStrictEqual(new Set([DataDependencies.repo("OtherItem")]))
|
|
414
|
+
expect(saveOther.dependencies.writes).toStrictEqual(new Set([DataDependencies.repo("OtherItem", ["2"])]))
|
|
415
415
|
expect(invalidatedBy(saveOther.dependencies.writes)).toStrictEqual([])
|
|
416
416
|
}, Effect.provide(TestLayer)),
|
|
417
417
|
{ timeout: 10_000 }
|