@effect-app/infra 4.0.0-beta.308 → 4.0.0-beta.309
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 +76 -9
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.309",
|
|
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.309"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@azure/cosmos": "^4.9.3",
|
|
@@ -3,7 +3,7 @@ import * as DataDependencies from "effect-app/DataDependencies"
|
|
|
3
3
|
import * as Effect from "effect-app/Effect"
|
|
4
4
|
import * as Layer from "effect-app/Layer"
|
|
5
5
|
import { Q } from "effect-app/Model"
|
|
6
|
-
import { makeRepo } from "effect-app/Model/Repository"
|
|
6
|
+
import { makeRepo, repositoryDependency } from "effect-app/Model/Repository"
|
|
7
7
|
import { RepositoryRegistryLive } from "effect-app/Model/Repository/Registry"
|
|
8
8
|
import * as S from "effect-app/Schema"
|
|
9
9
|
import { setupRequestContextFromCurrent } from "effect-app/setupRequest"
|
|
@@ -16,6 +16,16 @@ class BatchItem extends S.Class<BatchItem>("BatchItem")({
|
|
|
16
16
|
label: S.String
|
|
17
17
|
}) {}
|
|
18
18
|
|
|
19
|
+
class DependencyItem extends S.Class<DependencyItem>("DependencyItem")({
|
|
20
|
+
id: S.String,
|
|
21
|
+
label: repositoryDependency(S.StringId)
|
|
22
|
+
}) {}
|
|
23
|
+
|
|
24
|
+
class NestedDependencyItem extends S.Class<NestedDependencyItem>("NestedDependencyItem")({
|
|
25
|
+
id: S.String,
|
|
26
|
+
parts: S.Array(S.Struct({ id: repositoryDependency(S.String) }))
|
|
27
|
+
}) {}
|
|
28
|
+
|
|
19
29
|
const TestStoreLive = Layer.merge(MemoryStoreLive, RepositoryRegistryLive)
|
|
20
30
|
|
|
21
31
|
const A = S.TaggedStruct("A", { id: S.String })
|
|
@@ -218,7 +228,7 @@ describe("repository ext save/remove batching", () => {
|
|
|
218
228
|
.toEqual(DataDependencies.repo("DependencyItem"))
|
|
219
229
|
})
|
|
220
230
|
|
|
221
|
-
it.effect("
|
|
231
|
+
it.effect("derives matching read and write scopes from a schema annotation", () =>
|
|
222
232
|
Effect
|
|
223
233
|
.gen(function*() {
|
|
224
234
|
const readsRef = yield* Ref.make(DataDependencies.empty())
|
|
@@ -227,17 +237,42 @@ describe("repository ext save/remove batching", () => {
|
|
|
227
237
|
|
|
228
238
|
yield* Effect
|
|
229
239
|
.gen(function*() {
|
|
230
|
-
const repo = yield* makeRepo("DependencyItem",
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
yield* repo.save(new BatchItem({ id: "1", label: "one" }))
|
|
234
|
-
yield* repo.all.pipe(DataDependencies.withRepoReadScope("DependencyItem", ["alias-1"]))
|
|
240
|
+
const repo = yield* makeRepo("DependencyItem", DependencyItem, {})
|
|
241
|
+
yield* repo.save(new DependencyItem({ id: "1", label: S.StringId("label-one") }))
|
|
242
|
+
yield* repo.query(Q.where("label", "label-one"))
|
|
235
243
|
})
|
|
236
244
|
.pipe(Effect.provideService(DataDependencies.DataDependencyRecorder, recorder))
|
|
237
245
|
|
|
238
|
-
expect(yield* Ref.get(readsRef)).toEqual(new Set([DataDependencies.repo("DependencyItem", ["
|
|
246
|
+
expect(yield* Ref.get(readsRef)).toEqual(new Set([DataDependencies.repo("DependencyItem", ["label-one"])]))
|
|
247
|
+
expect(yield* Ref.get(writesRef)).toEqual(
|
|
248
|
+
new Set([DataDependencies.repo("DependencyItem", ["1", "label-one"])])
|
|
249
|
+
)
|
|
250
|
+
})
|
|
251
|
+
.pipe(
|
|
252
|
+
setupRequestContextFromCurrent(),
|
|
253
|
+
Effect.provide(TestStoreLive)
|
|
254
|
+
))
|
|
255
|
+
|
|
256
|
+
it.effect("derives a nested annotated relationship scope from whereSome", () =>
|
|
257
|
+
Effect
|
|
258
|
+
.gen(function*() {
|
|
259
|
+
const readsRef = yield* Ref.make(DataDependencies.empty())
|
|
260
|
+
const writesRef = yield* Ref.make(DataDependencies.empty())
|
|
261
|
+
const recorder = DataDependencies.makeDataDependencyRecorder(readsRef, writesRef)
|
|
262
|
+
|
|
263
|
+
yield* Effect
|
|
264
|
+
.gen(function*() {
|
|
265
|
+
const repo = yield* makeRepo("NestedDependencyItem", NestedDependencyItem, {})
|
|
266
|
+
yield* repo.save(new NestedDependencyItem({ id: "root", parts: [{ id: "part-1" }] }))
|
|
267
|
+
yield* repo.query(Q.whereSome("parts", Q.where("id", "part-1")))
|
|
268
|
+
})
|
|
269
|
+
.pipe(Effect.provideService(DataDependencies.DataDependencyRecorder, recorder))
|
|
270
|
+
|
|
271
|
+
expect(yield* Ref.get(readsRef)).toEqual(
|
|
272
|
+
new Set([DataDependencies.repo("NestedDependencyItem", ["part-1"])])
|
|
273
|
+
)
|
|
239
274
|
expect(yield* Ref.get(writesRef)).toEqual(
|
|
240
|
-
new Set([DataDependencies.repo("
|
|
275
|
+
new Set([DataDependencies.repo("NestedDependencyItem", ["root", "part-1"])])
|
|
241
276
|
)
|
|
242
277
|
})
|
|
243
278
|
.pipe(
|
|
@@ -245,6 +280,38 @@ describe("repository ext save/remove batching", () => {
|
|
|
245
280
|
Effect.provide(TestStoreLive)
|
|
246
281
|
))
|
|
247
282
|
|
|
283
|
+
it.effect("records previous and next relationship aliases", () =>
|
|
284
|
+
Effect
|
|
285
|
+
.gen(function*() {
|
|
286
|
+
const readsRef = yield* Ref.make(DataDependencies.empty())
|
|
287
|
+
const writesRef = yield* Ref.make(DataDependencies.empty())
|
|
288
|
+
const recorder = DataDependencies.makeDataDependencyRecorder(readsRef, writesRef)
|
|
289
|
+
|
|
290
|
+
yield* Effect
|
|
291
|
+
.gen(function*() {
|
|
292
|
+
const repo = yield* makeRepo("DependencyItem", BatchItem, {
|
|
293
|
+
dependencyIds: (item) => [item.id, `label-${item.label}`]
|
|
294
|
+
})
|
|
295
|
+
yield* repo.save(new BatchItem({ id: "1", label: "old" }))
|
|
296
|
+
yield* recorder.drainWrites
|
|
297
|
+
|
|
298
|
+
yield* repo.save(new BatchItem({ id: "1", label: "new" }))
|
|
299
|
+
expect(yield* recorder.drainWrites).toEqual(
|
|
300
|
+
new Set([DataDependencies.repo("DependencyItem", ["1", "label-new", "label-old"])])
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
yield* repo.removeById("1")
|
|
304
|
+
expect(yield* recorder.drainWrites).toEqual(
|
|
305
|
+
new Set([DataDependencies.repo("DependencyItem", ["1", "label-new"])])
|
|
306
|
+
)
|
|
307
|
+
})
|
|
308
|
+
.pipe(Effect.provideService(DataDependencies.DataDependencyRecorder, recorder))
|
|
309
|
+
})
|
|
310
|
+
.pipe(
|
|
311
|
+
setupRequestContextFromCurrent(),
|
|
312
|
+
Effect.provide(TestStoreLive)
|
|
313
|
+
))
|
|
314
|
+
|
|
248
315
|
it.effect("records repository and affected-query write dependencies", () =>
|
|
249
316
|
Effect
|
|
250
317
|
.gen(function*() {
|