MCPcopy Create free account
hub / github.com/effect-app/libs / extendRepo

Function extendRepo

packages/effect-app/src/Model/Repository/ext.ts:34–363  ·  view source on GitHub ↗
(
  repo: Repository<T, Encoded, Evt, ItemType, IdKey, RSchema, RPublish, RProvided>
)

Source from the content-addressed store, hash-verified

32 : undefined
33
34export const extendRepo = <
35 T,
36 Encoded extends FieldValues,
37 Evt,
38 ItemType extends string,
39 IdKey extends keyof T & keyof Encoded,
40 RSchema,
41 RPublish,
42 RProvided = never
43>(
44 repo: Repository<T, Encoded, Evt, ItemType, IdKey, RSchema, RPublish, RProvided>
45) => {
46 const get = (id: T[IdKey]) =>
47 repo.find(id).pipe(
48 Effect.flatMap(Option.match({
49 onNone: () => Effect.fail(new NotFoundError<ItemType>({ type: repo.itemType, id })),
50 onSome: Effect.succeed
51 }))
52 )
53 function saveManyWithPure_<
54 R,
55 A,
56 E,
57 S1 extends T,
58 S2 extends T
59 >(
60 items: Iterable<S1>,
61 pure: Effect.Effect<A, E, FixEnv<R, Evt, readonly S1[], readonly S2[]>>
62 ) {
63 return saveAllWithEffectInt(
64 runTerm(pure, [...items])
65 )
66 }
67
68 function saveWithPure_<
69 R,
70 A,
71 E,
72 S1 extends T,
73 S2 extends T
74 >(
75 item: S1,
76 pure: Effect.Effect<A, E, FixEnv<R, Evt, S1, S2>>
77 ) {
78 return saveAllWithEffectInt(
79 runTerm(pure, item)
80 .pipe(Effect
81 .map(([item, events, a]) => [[item], events, a]))
82 )
83 }
84
85 function saveAllWithEffectInt<
86 P extends T,
87 R,
88 E,
89 A
90 >(
91 gen: Effect.Effect<readonly [Iterable<P>, Iterable<Evt>, A], E, R>

Callers 1

makeRepoFunction · 0.90

Calls 11

runTermFunction · 0.90
asReadonlyArrayFunction · 0.85
getBatchSizeFunction · 0.85
saveAllWithEffectIntFunction · 0.85
pipeMethod · 0.65
makeMethod · 0.65
mapMethod · 0.65
forEachMethod · 0.65
logMethod · 0.65
failMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…