@effect-app/infra 0.203.1 → 0.204.0
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 +19 -0
- package/_cjs/api/routing/base.cjs.map +1 -1
- package/_cjs/api/routing/makeRequestHandler.cjs +3 -2
- package/_cjs/api/routing/makeRequestHandler.cjs.map +1 -1
- package/_cjs/api/routing/match.cjs.map +1 -1
- package/_cjs/api/setupRequest.cjs +1 -1
- package/_cjs/api/setupRequest.cjs.map +1 -1
- package/_cjs/services/RepositoryBase.cjs +8 -23
- package/_cjs/services/RepositoryBase.cjs.map +1 -1
- package/dist/api/routing/base.d.ts +7 -4
- package/dist/api/routing/base.d.ts.map +1 -1
- package/dist/api/routing/base.js +1 -1
- package/dist/api/routing/makeRequestHandler.d.ts +3 -3
- package/dist/api/routing/makeRequestHandler.d.ts.map +1 -1
- package/dist/api/routing/makeRequestHandler.js +4 -3
- package/dist/api/routing/match.d.ts +1 -1
- package/dist/api/routing/match.d.ts.map +1 -1
- package/dist/api/routing/match.js +1 -1
- package/dist/api/setupRequest.js +2 -2
- package/dist/services/QueueMaker/memQueue.d.ts +1 -1
- package/dist/services/QueueMaker/sbqueue.d.ts +1 -1
- package/dist/services/RepositoryBase.d.ts.map +1 -1
- package/dist/services/RepositoryBase.js +16 -18
- package/dist/services/Store/index.d.ts +1 -1
- package/dist/services/Store/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/routing/base.ts +8 -0
- package/src/api/routing/makeRequestHandler.ts +24 -3
- package/src/api/routing/match.ts +4 -0
- package/src/api/setupRequest.ts +1 -1
- package/src/services/RepositoryBase.ts +19 -27
|
@@ -397,8 +397,9 @@ export function makeRepo<
|
|
|
397
397
|
return Effect
|
|
398
398
|
.gen(function*($) {
|
|
399
399
|
const rctx = yield* $(Effect.context<R>())
|
|
400
|
-
const
|
|
400
|
+
const encodeMany = flow(S.encode(S.array(schema)), Effect.provide(rctx), Effect.withSpan("encodeMany"))
|
|
401
401
|
const decode = flow(S.decode(schema), Effect.provide(rctx))
|
|
402
|
+
const decodeMany = flow(S.decode(S.array(schema)), Effect.provide(rctx), Effect.withSpan("decodeMany"))
|
|
402
403
|
|
|
403
404
|
const store = yield* $(mkStore(args.makeInitial, args.config))
|
|
404
405
|
const { get } = yield* $(ContextMapContainer)
|
|
@@ -420,10 +421,12 @@ export function makeRepo<
|
|
|
420
421
|
})
|
|
421
422
|
))
|
|
422
423
|
|
|
423
|
-
const all = Effect
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
424
|
+
const all = Effect
|
|
425
|
+
.flatMap(
|
|
426
|
+
allE,
|
|
427
|
+
(_) => decodeMany(_).pipe(Effect.orDie)
|
|
428
|
+
)
|
|
429
|
+
.pipe(Effect.map((_) => _ as T[]))
|
|
427
430
|
|
|
428
431
|
const structSchema = schema as unknown as { struct: typeof schema }
|
|
429
432
|
const i = ("struct" in structSchema ? structSchema["struct"] : schema).pipe((_) =>
|
|
@@ -488,12 +491,7 @@ export function makeRepo<
|
|
|
488
491
|
.pipe(Effect.asUnit)
|
|
489
492
|
|
|
490
493
|
const saveAll = (a: Iterable<T>) =>
|
|
491
|
-
|
|
492
|
-
.forEach(
|
|
493
|
-
Array.from(a),
|
|
494
|
-
(_) => encode(_),
|
|
495
|
-
{ concurrency: "inherit", batching: true }
|
|
496
|
-
)
|
|
494
|
+
encodeMany(Array.from(a))
|
|
497
495
|
.pipe(
|
|
498
496
|
Effect.orDie,
|
|
499
497
|
Effect.andThen(saveAllE)
|
|
@@ -515,9 +513,7 @@ export function makeRepo<
|
|
|
515
513
|
return Effect.gen(function*($) {
|
|
516
514
|
const { get, set } = yield* $(cms)
|
|
517
515
|
const it = [...a]
|
|
518
|
-
const items = yield* $(
|
|
519
|
-
Effect.forEach(it, (_) => encode(_), { concurrency: "inherit", batching: true }).pipe(Effect.orDie)
|
|
520
|
-
)
|
|
516
|
+
const items = yield* $(encodeMany(it).pipe(Effect.orDie))
|
|
521
517
|
// TODO: we should have a batchRemove on store so the adapter can actually batch...
|
|
522
518
|
for (const e of items) {
|
|
523
519
|
yield* $(store.remove(mapToPersistenceModel(e, get)))
|
|
@@ -562,7 +558,6 @@ export function makeRepo<
|
|
|
562
558
|
? r.utils.parseMany2(_, a.schema as any)
|
|
563
559
|
: r.utils.parseMany(_)
|
|
564
560
|
)
|
|
565
|
-
.pipe(Effect.withSpan("parseMany"))
|
|
566
561
|
)
|
|
567
562
|
return pipe(
|
|
568
563
|
a.ttype === "one"
|
|
@@ -594,18 +589,16 @@ export function makeRepo<
|
|
|
594
589
|
*/
|
|
595
590
|
utils: {
|
|
596
591
|
parseMany: (items) =>
|
|
597
|
-
Effect
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
592
|
+
Effect
|
|
593
|
+
.flatMap(cms, (cm) =>
|
|
594
|
+
decodeMany(items.map((_) => mapReverse(_, cm.set)))
|
|
595
|
+
.pipe(Effect.orDie, Effect.withSpan("parseMany"))),
|
|
601
596
|
parseMany2: (items, schema) =>
|
|
602
|
-
Effect
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
})
|
|
608
|
-
.pipe(Effect.orDie)),
|
|
597
|
+
Effect
|
|
598
|
+
.flatMap(cms, (cm) =>
|
|
599
|
+
S
|
|
600
|
+
.decode(S.array(schema))(items.map((_) => mapReverse(_, cm.set) as unknown as Omit<PM, "_etag">))
|
|
601
|
+
.pipe(Effect.orDie, Effect.withSpan("parseMany2"))),
|
|
609
602
|
filter: <U extends keyof PM = keyof PM>(args: FilterArgs<PM, U>) =>
|
|
610
603
|
store
|
|
611
604
|
.filter(args)
|
|
@@ -620,7 +613,6 @@ export function makeRepo<
|
|
|
620
613
|
)
|
|
621
614
|
},
|
|
622
615
|
mapped: <A, R>(schema: S.Schema<A, any, R>) => {
|
|
623
|
-
// const enc = S.encode(schema)
|
|
624
616
|
const dec = S.decode(schema)
|
|
625
617
|
const encMany = S.encode(S.array(schema))
|
|
626
618
|
const decMany = S.decode(S.array(schema))
|