@effect-app/infra 4.0.0-beta.121 → 4.0.0-beta.123
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 +17 -0
- package/dist/CUPS.d.ts.map +1 -1
- package/dist/CUPS.js +8 -10
- package/dist/Model/Repository/ext.d.ts +15 -3
- package/dist/Model/Repository/ext.d.ts.map +1 -1
- package/dist/Model/Repository/ext.js +25 -2
- package/dist/Model/Repository/internal/internal.d.ts +1 -1
- package/dist/Model/Repository/internal/internal.d.ts.map +1 -1
- package/dist/Model/Repository/internal/internal.js +9 -8
- package/dist/Model/Repository/makeRepo.d.ts +3 -3
- package/dist/Model/Repository/makeRepo.d.ts.map +1 -1
- package/dist/Model/Repository/service.d.ts +21 -21
- package/dist/Model/Repository/service.d.ts.map +1 -1
- package/dist/Model/query/new-kid-interpreter.d.ts +2 -2
- package/dist/Operations.d.ts +2 -2
- package/dist/Operations.d.ts.map +1 -1
- package/dist/Operations.js +54 -57
- package/dist/OperationsRepo.d.ts +2 -2
- package/dist/QueueMaker/SQLQueue.d.ts +2 -3
- package/dist/QueueMaker/SQLQueue.d.ts.map +1 -1
- package/dist/QueueMaker/SQLQueue.js +104 -115
- package/dist/QueueMaker/memQueue.d.ts +2 -2
- package/dist/QueueMaker/memQueue.d.ts.map +1 -1
- package/dist/QueueMaker/memQueue.js +51 -62
- package/dist/QueueMaker/sbqueue.d.ts.map +1 -1
- package/dist/QueueMaker/sbqueue.js +34 -50
- package/dist/Store/ContextMapContainer.d.ts +1 -1
- package/dist/Store/Cosmos.d.ts.map +1 -1
- package/dist/Store/Cosmos.js +304 -306
- package/dist/Store/Disk.d.ts +1 -1
- package/dist/Store/Disk.d.ts.map +1 -1
- package/dist/Store/Disk.js +2 -2
- package/dist/Store/Memory.d.ts +1 -1
- package/dist/Store/Memory.d.ts.map +1 -1
- package/dist/Store/Memory.js +2 -2
- package/dist/Store/SQL/Pg.d.ts.map +1 -1
- package/dist/Store/SQL/Pg.js +147 -149
- package/dist/Store/SQL.d.ts.map +1 -1
- package/dist/Store/SQL.js +6 -6
- package/dist/Store/utils.d.ts.map +1 -1
- package/dist/Store/utils.js +3 -4
- package/dist/adapters/ServiceBus.d.ts.map +1 -1
- package/dist/adapters/ServiceBus.js +7 -9
- package/dist/api/internal/auth.d.ts.map +1 -1
- package/dist/api/internal/auth.js +1 -1
- package/dist/api/routing/middleware/middleware.d.ts.map +1 -1
- package/dist/api/routing/middleware/middleware.js +2 -2
- package/dist/errorReporter.d.ts +3 -3
- package/dist/errorReporter.d.ts.map +1 -1
- package/dist/errorReporter.js +16 -23
- package/package.json +14 -14
- package/src/CUPS.ts +7 -9
- package/src/Model/Repository/ext.ts +71 -6
- package/src/Model/Repository/internal/internal.ts +13 -25
- package/src/Model/Repository/makeRepo.ts +4 -4
- package/src/Model/Repository/service.ts +22 -21
- package/src/Operations.ts +76 -111
- package/src/QueueMaker/SQLQueue.ts +119 -150
- package/src/QueueMaker/memQueue.ts +81 -102
- package/src/QueueMaker/sbqueue.ts +51 -81
- package/src/Store/Cosmos.ts +481 -484
- package/src/Store/Disk.ts +52 -53
- package/src/Store/Memory.ts +49 -50
- package/src/Store/SQL/Pg.ts +247 -250
- package/src/Store/SQL.ts +420 -426
- package/src/Store/utils.ts +23 -22
- package/src/adapters/ServiceBus.ts +106 -110
- package/src/api/internal/auth.ts +8 -6
- package/src/api/routing/middleware/middleware.ts +10 -11
- package/src/errorReporter.ts +58 -72
- package/test/dist/auth.test.d.ts.map +1 -0
- package/test/dist/fixtures.d.ts +1 -1
- package/test/dist/repository-ext.test.d.ts.map +1 -0
- package/test/repository-ext.test.ts +58 -0
package/src/Store/Disk.ts
CHANGED
|
@@ -132,66 +132,65 @@ export function makeDiskStore({ prefix }: StorageConfig, dir: string) {
|
|
|
132
132
|
fs.mkdirSync(dir)
|
|
133
133
|
}
|
|
134
134
|
return {
|
|
135
|
-
make:
|
|
135
|
+
make: Effect.fnUntraced(function*<IdKey extends keyof Encoded, Encoded extends FieldValues, R, E>(
|
|
136
136
|
name: string,
|
|
137
137
|
idKey: IdKey,
|
|
138
138
|
seed?: Effect.Effect<Iterable<Encoded>, E, R>,
|
|
139
139
|
config?: StoreConfig<Encoded>
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
semaphores.set(ns, sem)
|
|
151
|
-
}
|
|
152
|
-
return sem
|
|
140
|
+
) {
|
|
141
|
+
const primary = yield* makeDiskStoreInt(prefix, idKey, "primary", dir, name, seed, config?.defaultValues)
|
|
142
|
+
const stores = new Map<string, Store<IdKey, Encoded>>([["primary", primary]])
|
|
143
|
+
const ctx = yield* Effect.context<R>()
|
|
144
|
+
const semaphores = new Map<string, Semaphore.Semaphore>()
|
|
145
|
+
const getSem = (ns: string) => {
|
|
146
|
+
let sem = semaphores.get(ns)
|
|
147
|
+
if (!sem) {
|
|
148
|
+
sem = Semaphore.makeUnsafe(1)
|
|
149
|
+
semaphores.set(ns, sem)
|
|
153
150
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
151
|
+
return sem
|
|
152
|
+
}
|
|
153
|
+
const ensureStore = (namespace: string) =>
|
|
154
|
+
getSem(namespace).withPermits(1)(
|
|
155
|
+
Effect.suspend(() => {
|
|
156
|
+
const existing = stores.get(namespace)
|
|
157
|
+
if (existing) return Effect.succeed(existing)
|
|
158
|
+
if (config?.allowNamespace && !config.allowNamespace(namespace)) {
|
|
159
|
+
throw new Error(`Namespace ${namespace} not allowed!`)
|
|
160
|
+
}
|
|
161
|
+
return makeDiskStoreInt<IdKey, Encoded, R, E>(
|
|
162
|
+
prefix,
|
|
163
|
+
idKey,
|
|
164
|
+
namespace,
|
|
165
|
+
dir,
|
|
166
|
+
name,
|
|
167
|
+
seed,
|
|
168
|
+
config?.defaultValues
|
|
169
|
+
)
|
|
170
|
+
.pipe(
|
|
171
|
+
Effect.orDie,
|
|
172
|
+
Effect.provide(ctx),
|
|
173
|
+
Effect.tap((store) => Effect.sync(() => stores.set(namespace, store)))
|
|
170
174
|
)
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
})
|
|
177
|
-
)
|
|
178
|
-
const getStore = !config?.allowNamespace
|
|
179
|
-
? Effect.succeed(primary)
|
|
180
|
-
: storeId.asEffect().pipe(Effect.flatMap((namespace) => ensureStore(namespace)))
|
|
175
|
+
})
|
|
176
|
+
)
|
|
177
|
+
const getStore = !config?.allowNamespace
|
|
178
|
+
? Effect.succeed(primary)
|
|
179
|
+
: storeId.asEffect().pipe(Effect.flatMap((namespace) => ensureStore(namespace)))
|
|
181
180
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
181
|
+
const s: Store<IdKey, Encoded> = {
|
|
182
|
+
seedNamespace: (namespace) => ensureStore(namespace).pipe(Effect.asVoid),
|
|
183
|
+
all: Effect.flatMap(getStore, (_) => _.all),
|
|
184
|
+
find: (...args) => Effect.flatMap(getStore, (_) => _.find(...args)),
|
|
185
|
+
filter: (...args) => Effect.flatMap(getStore, (_) => _.filter(...args)),
|
|
186
|
+
set: (...args) => Effect.flatMap(getStore, (_) => _.set(...args)),
|
|
187
|
+
batchSet: (...args) => Effect.flatMap(getStore, (_) => _.batchSet(...args)),
|
|
188
|
+
bulkSet: (...args) => Effect.flatMap(getStore, (_) => _.bulkSet(...args)),
|
|
189
|
+
batchRemove: (...args) => Effect.flatMap(getStore, (_) => _.batchRemove(...args)),
|
|
190
|
+
queryRaw: (...args) => Effect.flatMap(getStore, (_) => _.queryRaw(...args))
|
|
191
|
+
}
|
|
192
|
+
return s
|
|
193
|
+
})
|
|
195
194
|
}
|
|
196
195
|
})
|
|
197
196
|
}
|
package/src/Store/Memory.ts
CHANGED
|
@@ -252,61 +252,60 @@ export function makeMemoryStoreInt<IdKey extends keyof Encoded, Encoded extends
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
export const makeMemoryStore = () => ({
|
|
255
|
-
make:
|
|
255
|
+
make: Effect.fnUntraced(function*<IdKey extends keyof Encoded, Encoded extends FieldValues, R, E>(
|
|
256
256
|
modelName: string,
|
|
257
257
|
idKey: IdKey,
|
|
258
258
|
seed?: Effect.Effect<Iterable<Encoded>, E, R>,
|
|
259
259
|
config?: StoreConfig<Encoded>
|
|
260
|
-
)
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
semaphores.set(ns, sem)
|
|
277
|
-
}
|
|
278
|
-
return sem
|
|
279
|
-
}
|
|
280
|
-
const ensureStore = (namespace: string) =>
|
|
281
|
-
getSem(namespace).withPermits(1)(Effect.suspend(() => {
|
|
282
|
-
const store = stores.get(namespace)
|
|
283
|
-
if (store) return Effect.succeed(store)
|
|
284
|
-
if (config?.allowNamespace && !config.allowNamespace(namespace)) {
|
|
285
|
-
throw new Error(`Namespace ${namespace} not allowed!`)
|
|
286
|
-
}
|
|
287
|
-
return makeMemoryStoreInt(modelName, idKey, namespace, seed, config?.defaultValues)
|
|
288
|
-
.pipe(
|
|
289
|
-
Effect.orDie,
|
|
290
|
-
Effect.provide(ctx),
|
|
291
|
-
Effect.tap((store) => Effect.sync(() => stores.set(namespace, store)))
|
|
292
|
-
)
|
|
293
|
-
}))
|
|
294
|
-
const getStore = !config?.allowNamespace
|
|
295
|
-
? Effect.succeed(primary)
|
|
296
|
-
: storeId.asEffect().pipe(Effect.flatMap((namespace) => ensureStore(namespace)))
|
|
297
|
-
const s: Store<IdKey, Encoded> = {
|
|
298
|
-
seedNamespace: (namespace) => ensureStore(namespace).pipe(Effect.asVoid),
|
|
299
|
-
all: Effect.flatMap(getStore, (_) => _.all),
|
|
300
|
-
queryRaw: (...args) => Effect.flatMap(getStore, (_) => _.queryRaw(...args)),
|
|
301
|
-
find: (...args) => Effect.flatMap(getStore, (_) => _.find(...args)),
|
|
302
|
-
filter: (...args) => Effect.flatMap(getStore, (_) => _.filter(...args)),
|
|
303
|
-
set: (...args) => Effect.flatMap(getStore, (_) => _.set(...args)),
|
|
304
|
-
batchSet: (...args) => Effect.flatMap(getStore, (_) => _.batchSet(...args)),
|
|
305
|
-
bulkSet: (...args) => Effect.flatMap(getStore, (_) => _.bulkSet(...args)),
|
|
306
|
-
batchRemove: (...args) => Effect.flatMap(getStore, (_) => _.batchRemove(...args))
|
|
260
|
+
) {
|
|
261
|
+
const primary = yield* makeMemoryStoreInt<IdKey, Encoded, R, E>(
|
|
262
|
+
modelName,
|
|
263
|
+
idKey,
|
|
264
|
+
"primary",
|
|
265
|
+
seed,
|
|
266
|
+
config?.defaultValues
|
|
267
|
+
)
|
|
268
|
+
const ctx = yield* Effect.context<R>()
|
|
269
|
+
const stores = new Map([["primary", primary]])
|
|
270
|
+
const semaphores = new Map<string, Semaphore.Semaphore>()
|
|
271
|
+
const getSem = (ns: string) => {
|
|
272
|
+
let sem = semaphores.get(ns)
|
|
273
|
+
if (!sem) {
|
|
274
|
+
sem = Semaphore.makeUnsafe(1)
|
|
275
|
+
semaphores.set(ns, sem)
|
|
307
276
|
}
|
|
308
|
-
return
|
|
309
|
-
}
|
|
277
|
+
return sem
|
|
278
|
+
}
|
|
279
|
+
const ensureStore = (namespace: string) =>
|
|
280
|
+
getSem(namespace).withPermits(1)(Effect.suspend(() => {
|
|
281
|
+
const store = stores.get(namespace)
|
|
282
|
+
if (store) return Effect.succeed(store)
|
|
283
|
+
if (config?.allowNamespace && !config.allowNamespace(namespace)) {
|
|
284
|
+
throw new Error(`Namespace ${namespace} not allowed!`)
|
|
285
|
+
}
|
|
286
|
+
return makeMemoryStoreInt(modelName, idKey, namespace, seed, config?.defaultValues)
|
|
287
|
+
.pipe(
|
|
288
|
+
Effect.orDie,
|
|
289
|
+
Effect.provide(ctx),
|
|
290
|
+
Effect.tap((store) => Effect.sync(() => stores.set(namespace, store)))
|
|
291
|
+
)
|
|
292
|
+
}))
|
|
293
|
+
const getStore = !config?.allowNamespace
|
|
294
|
+
? Effect.succeed(primary)
|
|
295
|
+
: storeId.asEffect().pipe(Effect.flatMap((namespace) => ensureStore(namespace)))
|
|
296
|
+
const s: Store<IdKey, Encoded> = {
|
|
297
|
+
seedNamespace: (namespace) => ensureStore(namespace).pipe(Effect.asVoid),
|
|
298
|
+
all: Effect.flatMap(getStore, (_) => _.all),
|
|
299
|
+
queryRaw: (...args) => Effect.flatMap(getStore, (_) => _.queryRaw(...args)),
|
|
300
|
+
find: (...args) => Effect.flatMap(getStore, (_) => _.find(...args)),
|
|
301
|
+
filter: (...args) => Effect.flatMap(getStore, (_) => _.filter(...args)),
|
|
302
|
+
set: (...args) => Effect.flatMap(getStore, (_) => _.set(...args)),
|
|
303
|
+
batchSet: (...args) => Effect.flatMap(getStore, (_) => _.batchSet(...args)),
|
|
304
|
+
bulkSet: (...args) => Effect.flatMap(getStore, (_) => _.bulkSet(...args)),
|
|
305
|
+
batchRemove: (...args) => Effect.flatMap(getStore, (_) => _.batchRemove(...args))
|
|
306
|
+
}
|
|
307
|
+
return s
|
|
308
|
+
})
|
|
310
309
|
})
|
|
311
310
|
|
|
312
311
|
export const MemoryStoreLive = StoreMaker.toLayer(Effect.sync(() => makeMemoryStore()))
|