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

Class SomethingRepo

packages/infra/test/rawQuery.test.ts:66–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64
65// @effect-diagnostics-next-line missingEffectServiceDependency:off
66class SomethingRepo extends Context.Service<SomethingRepo>()(
67 "SomethingRepo",
68 {
69 make: Effect.gen(function*() {
70 const partitionKey = "test-" + new Date().getTime()
71 return yield* makeRepo("Something", Something, { config: { partitionValue: () => partitionKey } })
72 })
73 }
74) {
75 static readonly layer = Layer
76 .effect(
77 SomethingRepo,
78 Effect.gen(function*() {
79 const partitionKey = "test-" + new Date().getTime()
80 const repo = SomethingRepo.of(
81 yield* makeRepo("Something", Something, {
82 config: { partitionValue: () => partitionKey }
83 })
84 )
85 // not using makeInitial, because it will prevent inserting the various partitionkeyed items
86 yield* repo.saveAndPublish(items).pipe(setupRequestContextFromCurrent("init"))
87 return repo
88 })
89 )
90 static readonly Test = this
91 .layer
92 .pipe(
93 Layer.provide(Layer.merge(MemoryStoreLive, RepositoryRegistryLive))
94 )
95
96 static readonly TestCosmos = this
97 .layer
98 .pipe(
99 Layer.provide(
100 Effect
101 .gen(function*() {
102 const url = yield* Config.redacted("STORAGE_URL").pipe(
103 Config.withDefault(
104 Redacted.make(
105 // the emulator doesn't implement array projections :/ so you need an actual cloud instance!
106 "AccountEndpoint=http://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
107 )
108 )
109 )
110 return CosmosStoreLayer({
111 dbName: "test",
112 prefix: "",
113 url
114 })
115 .pipe(Layer.merge(RepositoryRegistryLive))
116 })
117 .pipe(Layer.unwrap)
118 )
119 )
120}
121
122describe("select first-level array fields", () => {
123 const test = Effect

Callers

nothing calls this directly

Calls 8

makeRepoFunction · 0.90
CosmosStoreLayerFunction · 0.85
mergeMethod · 0.80
ofMethod · 0.65
pipeMethod · 0.65
makeMethod · 0.65
provideMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…