@effect-app/infra 0.83.12 → 0.84.0-next.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/.cache/effect/095519d034161945a8d2616a506d3e7f35a9b3d868814f44c747429c60fc4e7f.content +2 -36
- package/.cache/effect/095519d034161945a8d2616a506d3e7f35a9b3d868814f44c747429c60fc4e7f.hash +1 -1
- package/.cache/effect/134218688132dfbdea493cbe1f26e73449f2759121df35ddd5448346b59c9a8d.content +6 -24
- package/.cache/effect/134218688132dfbdea493cbe1f26e73449f2759121df35ddd5448346b59c9a8d.hash +1 -1
- package/.cache/effect/14eb9da4ca6d22162888c7fdb7f39ab772d2a2dc6625db6031ecdb32ac89158f.content +40 -75
- package/.cache/effect/14eb9da4ca6d22162888c7fdb7f39ab772d2a2dc6625db6031ecdb32ac89158f.hash +1 -1
- package/.cache/effect/1bfd92946b11da4292f2ed99dc0e322462b60559148f9524abc20e26f70779e1.hash +1 -1
- package/.cache/effect/49c1bd9ec26e6df78b994d8df0bfe21b119803fa4aa46349bf4679fd0f1e7cda.content +1 -3
- package/.cache/effect/49c1bd9ec26e6df78b994d8df0bfe21b119803fa4aa46349bf4679fd0f1e7cda.hash +1 -1
- package/.cache/effect/58d4ccde8bd2db7829706db5bebd01b99900ee83f0f6a8413b53d17cbd69f510.content +1 -1
- package/.cache/effect/58d4ccde8bd2db7829706db5bebd01b99900ee83f0f6a8413b53d17cbd69f510.hash +1 -1
- package/.cache/effect/72a5a16a6b62b63cd71719c833091128207d7e6c823cb32293549b3dd58c451b.content +7 -15
- package/.cache/effect/72a5a16a6b62b63cd71719c833091128207d7e6c823cb32293549b3dd58c451b.hash +1 -1
- package/.cache/effect/7a9c33db6aedaf00093a132c1d4e48e9d043cef05e932b8a37da24d44e224248.hash +1 -1
- package/.cache/effect/8594f0f42afc0641b00e88998000cc47382a1d07da31f4a148f7976701ca22d5.hash +1 -1
- package/.cache/effect/c67d971634d2dc8118b40452b61c9a51620c35809be4a89982476aa80701d852.hash +1 -1
- package/.cache/effect/f38adf43700dab905456a534a0690eaf882cff2cd576c731f23d6d14a3c3d659.content +1 -5
- package/.cache/effect/f38adf43700dab905456a534a0690eaf882cff2cd576c731f23d6d14a3c3d659.hash +1 -1
- package/CHANGELOG.md +14 -0
- package/_cjs/_ext/Array.cjs +3 -2
- package/_cjs/_ext/Array.cjs.map +1 -1
- package/_cjs/api/defaultErrorHandler.cjs +11 -10
- package/_cjs/api/defaultErrorHandler.cjs.map +1 -1
- package/_cjs/api/express/makeJsonSchema.cjs +3 -2
- package/_cjs/api/express/makeJsonSchema.cjs.map +1 -1
- package/_cjs/api/express/makeJsonSchema.test.cjs +2 -2
- package/_cjs/api/express/makeJsonSchema.test.cjs.map +1 -1
- package/_cjs/api/express/makeOpenApiSpecs.cjs +4 -3
- package/_cjs/api/express/makeOpenApiSpecs.cjs.map +1 -1
- package/_cjs/api/express/schema/requestHandler.cjs +24 -22
- package/_cjs/api/express/schema/requestHandler.cjs.map +1 -1
- package/_cjs/api/express/schema/routing.cjs +22 -20
- package/_cjs/api/express/schema/routing.cjs.map +1 -1
- package/_cjs/api/reportError.cjs +1 -1
- package/_cjs/api/routing.cjs +55 -53
- package/_cjs/api/routing.cjs.map +1 -1
- package/_cjs/api/setupRequest.cjs +3 -2
- package/_cjs/api/setupRequest.cjs.map +1 -1
- package/_cjs/api/writeDocs.cjs +5 -4
- package/_cjs/api/writeDocs.cjs.map +1 -1
- package/_cjs/errorReporter.cjs +11 -10
- package/_cjs/errorReporter.cjs.map +1 -1
- package/_cjs/errors.cjs +8 -8
- package/_cjs/errors.cjs.map +1 -1
- package/_cjs/instrument.cjs +2 -1
- package/_cjs/instrument.cjs.map +1 -1
- package/_cjs/logger/jsonLogger.cjs +4 -4
- package/_cjs/logger/jsonLogger.cjs.map +1 -1
- package/_cjs/logger/logFmtLogger.cjs +5 -5
- package/_cjs/logger/logFmtLogger.cjs.map +1 -1
- package/_cjs/logger/shared.cjs +4 -4
- package/_cjs/logger/shared.cjs.map +1 -1
- package/_cjs/rateLimit.cjs +8 -7
- package/_cjs/rateLimit.cjs.map +1 -1
- package/_cjs/services/Emailer/Sendgrid.cjs +13 -11
- package/_cjs/services/Emailer/Sendgrid.cjs.map +1 -1
- package/_cjs/services/Emailer/fake.cjs +5 -4
- package/_cjs/services/Emailer/fake.cjs.map +1 -1
- package/_cjs/services/Operations/live.cjs +31 -29
- package/_cjs/services/Operations/live.cjs.map +1 -1
- package/_cjs/services/Operations/service.cjs +1 -1
- package/_cjs/services/QueueMaker/errors.cjs +7 -6
- package/_cjs/services/QueueMaker/errors.cjs.map +1 -1
- package/_cjs/services/QueueMaker/memQueue.cjs +18 -17
- package/_cjs/services/QueueMaker/memQueue.cjs.map +1 -1
- package/_cjs/services/QueueMaker/sbqueue.cjs +16 -15
- package/_cjs/services/QueueMaker/sbqueue.cjs.map +1 -1
- package/_cjs/services/Repository.cjs +17 -16
- package/_cjs/services/Repository.cjs.map +1 -1
- package/_cjs/services/RepositoryBase.cjs +35 -33
- package/_cjs/services/RepositoryBase.cjs.map +1 -1
- package/_cjs/services/RequestContextContainer.cjs +11 -10
- package/_cjs/services/RequestContextContainer.cjs.map +1 -1
- package/_cjs/services/Store/Cosmos.cjs +49 -46
- package/_cjs/services/Store/Cosmos.cjs.map +1 -1
- package/_cjs/services/Store/Disk.cjs +19 -18
- package/_cjs/services/Store/Disk.cjs.map +1 -1
- package/_cjs/services/Store/Memory.cjs +27 -25
- package/_cjs/services/Store/Memory.cjs.map +1 -1
- package/_cjs/services/Store/Redis.cjs +16 -14
- package/_cjs/services/Store/Redis.cjs.map +1 -1
- package/_cjs/services/Store/codeFilter.test.cjs +1 -1
- package/_cjs/services/Store/index.cjs +6 -5
- package/_cjs/services/Store/index.cjs.map +1 -1
- package/_cjs/services/Store/service.cjs +1 -1
- package/_cjs/services/Store/service.cjs.map +1 -1
- package/_cjs/services/Store/utils.cjs +13 -13
- package/_cjs/services/Store/utils.cjs.map +1 -1
- package/_cjs/services/simpledb/cosmosdb.cjs +19 -17
- package/_cjs/services/simpledb/cosmosdb.cjs.map +1 -1
- package/_cjs/services/simpledb/diskdb.cjs +9 -8
- package/_cjs/services/simpledb/diskdb.cjs.map +1 -1
- package/_cjs/services/simpledb/memdb.cjs +11 -9
- package/_cjs/services/simpledb/memdb.cjs.map +1 -1
- package/_cjs/services/simpledb/mongodb.cjs +20 -18
- package/_cjs/services/simpledb/mongodb.cjs.map +1 -1
- package/_cjs/services/simpledb/redisdb.cjs +11 -10
- package/_cjs/services/simpledb/redisdb.cjs.map +1 -1
- package/_cjs/services/simpledb/shared.cjs +5 -5
- package/_cjs/services/simpledb/shared.cjs.map +1 -1
- package/_cjs/services/simpledb/simpledb.cjs +18 -17
- package/_cjs/services/simpledb/simpledb.cjs.map +1 -1
- package/_src/api/authorization.jwt.ts +1 -1
- package/_src/api/defaultErrorHandler.ts +2 -2
- package/_src/api/express/routing.ts.bak +8 -8
- package/_src/api/express/schema/requestHandler.ts +12 -12
- package/_src/api/express/schema/routing.ts +11 -11
- package/_src/api/routing.ts +14 -13
- package/_src/errorReporter.ts +1 -1
- package/_src/services/Emailer/Sendgrid.ts +1 -1
- package/_src/services/Operations/live.ts +5 -5
- package/_src/services/QueueMaker/errors.ts +1 -1
- package/_src/services/QueueMaker/memQueue.ts +2 -2
- package/_src/services/QueueMaker/sbqueue.ts +1 -1
- package/_src/services/Repository.ts +9 -9
- package/_src/services/RepositoryBase.ts +8 -6
- package/_src/services/RequestContextContainer.ts +1 -1
- package/_src/services/Store/Cosmos.ts +17 -12
- package/_src/services/Store/Disk.ts +4 -4
- package/_src/services/Store/Memory.ts +4 -4
- package/_src/services/Store/Redis.ts +1 -1
- package/_src/services/Store/index.test.ts.bak +5 -5
- package/_src/services/Store/index.ts +1 -1
- package/_src/services/Store/utils.ts +16 -16
- package/_src/services/simpledb/diskdb.ts +1 -1
- package/_src/services/simpledb/memdb.ts +1 -1
- package/_src/services/simpledb/redisdb.ts +1 -1
- package/_src/services/simpledb/shared.ts +1 -1
- package/_src/services/simpledb/simpledb.ts +3 -3
- package/dist/RequestContext.d.ts +20 -20
- package/dist/_ext/Array.js +4 -3
- package/dist/api/defaultErrorHandler.js +12 -11
- package/dist/api/express/makeJsonSchema.js +4 -3
- package/dist/api/express/makeOpenApiSpecs.js +5 -4
- package/dist/api/express/schema/requestHandler.d.ts +1 -1
- package/dist/api/express/schema/requestHandler.js +35 -33
- package/dist/api/express/schema/routing.d.ts +1 -1
- package/dist/api/express/schema/routing.js +23 -21
- package/dist/api/reportError.d.ts +3 -3
- package/dist/api/reportError.d.ts.map +1 -1
- package/dist/api/reportError.js +1 -1
- package/dist/api/routing.d.ts +2 -2
- package/dist/api/routing.d.ts.map +1 -1
- package/dist/api/routing.js +59 -57
- package/dist/api/setupRequest.d.ts +1 -1
- package/dist/api/setupRequest.d.ts.map +1 -1
- package/dist/api/setupRequest.js +4 -3
- package/dist/api/writeDocs.js +6 -5
- package/dist/errorReporter.js +12 -11
- package/dist/errors.d.ts +7 -7
- package/dist/errors.js +9 -9
- package/dist/filter.d.ts.map +1 -1
- package/dist/instrument.js +3 -2
- package/dist/logger/jsonLogger.d.ts +2 -2
- package/dist/logger/jsonLogger.d.ts.map +1 -1
- package/dist/logger/jsonLogger.js +5 -5
- package/dist/logger/logFmtLogger.d.ts +2 -2
- package/dist/logger/logFmtLogger.d.ts.map +1 -1
- package/dist/logger/logFmtLogger.js +6 -6
- package/dist/logger/shared.js +5 -5
- package/dist/rateLimit.d.ts +2 -2
- package/dist/rateLimit.d.ts.map +1 -1
- package/dist/rateLimit.js +9 -8
- package/dist/services/Emailer/Sendgrid.d.ts +1 -1
- package/dist/services/Emailer/Sendgrid.d.ts.map +1 -1
- package/dist/services/Emailer/Sendgrid.js +16 -14
- package/dist/services/Emailer/fake.d.ts +1 -1
- package/dist/services/Emailer/fake.d.ts.map +1 -1
- package/dist/services/Emailer/fake.js +6 -5
- package/dist/services/Emailer/service.d.ts +2 -2
- package/dist/services/Operations/live.d.ts +1 -1
- package/dist/services/Operations/live.d.ts.map +1 -1
- package/dist/services/Operations/live.js +39 -37
- package/dist/services/Operations/service.d.ts +7 -7
- package/dist/services/Operations/service.d.ts.map +1 -1
- package/dist/services/Operations/service.js +1 -1
- package/dist/services/QueueMaker/errors.d.ts +4 -4
- package/dist/services/QueueMaker/errors.d.ts.map +1 -1
- package/dist/services/QueueMaker/errors.js +7 -6
- package/dist/services/QueueMaker/memQueue.d.ts +1 -1
- package/dist/services/QueueMaker/memQueue.js +17 -16
- package/dist/services/QueueMaker/sbqueue.d.ts +2 -2
- package/dist/services/QueueMaker/sbqueue.d.ts.map +1 -1
- package/dist/services/QueueMaker/sbqueue.js +16 -15
- package/dist/services/Repository.d.ts +8 -8
- package/dist/services/Repository.d.ts.map +1 -1
- package/dist/services/Repository.js +18 -17
- package/dist/services/RepositoryBase.d.ts +24 -75
- package/dist/services/RepositoryBase.d.ts.map +1 -1
- package/dist/services/RepositoryBase.js +37 -35
- package/dist/services/RequestContextContainer.d.ts +4 -4
- package/dist/services/RequestContextContainer.d.ts.map +1 -1
- package/dist/services/RequestContextContainer.js +14 -13
- package/dist/services/Store/Cosmos.d.ts +2 -2
- package/dist/services/Store/Cosmos.d.ts.map +1 -1
- package/dist/services/Store/Cosmos.js +54 -51
- package/dist/services/Store/Disk.d.ts +2 -2
- package/dist/services/Store/Disk.d.ts.map +1 -1
- package/dist/services/Store/Disk.js +20 -19
- package/dist/services/Store/Memory.d.ts +3 -3
- package/dist/services/Store/Memory.d.ts.map +1 -1
- package/dist/services/Store/Memory.js +28 -26
- package/dist/services/Store/Redis.d.ts +2 -2
- package/dist/services/Store/Redis.d.ts.map +1 -1
- package/dist/services/Store/Redis.js +17 -15
- package/dist/services/Store/index.d.ts +1 -1
- package/dist/services/Store/index.d.ts.map +1 -1
- package/dist/services/Store/index.js +7 -6
- package/dist/services/Store/service.d.ts +5 -5
- package/dist/services/Store/service.js +2 -2
- package/dist/services/Store/utils.d.ts +3 -3
- package/dist/services/Store/utils.d.ts.map +1 -1
- package/dist/services/Store/utils.js +21 -21
- package/dist/services/simpledb/cosmosdb.d.ts +2 -2
- package/dist/services/simpledb/cosmosdb.d.ts.map +1 -1
- package/dist/services/simpledb/cosmosdb.js +19 -17
- package/dist/services/simpledb/diskdb.d.ts +2 -2
- package/dist/services/simpledb/diskdb.d.ts.map +1 -1
- package/dist/services/simpledb/diskdb.js +10 -9
- package/dist/services/simpledb/memdb.d.ts +3 -3
- package/dist/services/simpledb/memdb.d.ts.map +1 -1
- package/dist/services/simpledb/memdb.js +13 -11
- package/dist/services/simpledb/mongodb.d.ts +2 -2
- package/dist/services/simpledb/mongodb.d.ts.map +1 -1
- package/dist/services/simpledb/mongodb.js +16 -14
- package/dist/services/simpledb/redisdb.d.ts +8 -8
- package/dist/services/simpledb/redisdb.d.ts.map +1 -1
- package/dist/services/simpledb/redisdb.js +12 -11
- package/dist/services/simpledb/shared.d.ts +13 -13
- package/dist/services/simpledb/shared.js +6 -6
- package/dist/services/simpledb/simpledb.d.ts +4 -4
- package/dist/services/simpledb/simpledb.d.ts.map +1 -1
- package/dist/services/simpledb/simpledb.js +16 -15
- package/package.json +5 -5
|
@@ -155,7 +155,7 @@ export function project<
|
|
|
155
155
|
self: Repository<T, PM, Evt, ItemType>,
|
|
156
156
|
map: { filter?: Filter<PM>; collect?: (t: PM) => Option<S>; limit?: number; skip?: number }
|
|
157
157
|
) {
|
|
158
|
-
return self.projectEffect(Effect(map))
|
|
158
|
+
return self.projectEffect(Effect.sync(() => map))
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
/**
|
|
@@ -235,7 +235,7 @@ export function query<
|
|
|
235
235
|
// TODO: think about collectPM, collectE, and collect(Parsed)
|
|
236
236
|
map: { filter?: Filter<PM>; collect?: (t: T) => Option<S>; limit?: number; skip?: number }
|
|
237
237
|
) {
|
|
238
|
-
return self.queryEffect(Effect(map))
|
|
238
|
+
return self.queryEffect(Effect.sync(() => map))
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
/**
|
|
@@ -252,7 +252,7 @@ export function queryOne<
|
|
|
252
252
|
// TODO: think about collectPM, collectE, and collect(Parsed)
|
|
253
253
|
map: { filter?: Filter<PM>; collect?: (t: T) => Option<S> }
|
|
254
254
|
) {
|
|
255
|
-
return self.queryOneEffect(Effect(map))
|
|
255
|
+
return self.queryOneEffect(Effect.sync(() => map))
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
/**
|
|
@@ -290,7 +290,7 @@ export function queryAndSavePure<
|
|
|
290
290
|
// TODO: think about collectPM, collectE, and collect(Parsed)
|
|
291
291
|
map: { filter: Filter<PM>; collect?: (t: T) => Option<S>; limit?: number; skip?: number }
|
|
292
292
|
) {
|
|
293
|
-
return self.queryAndSavePureEffect(Effect(map))
|
|
293
|
+
return self.queryAndSavePureEffect(Effect.sync(() => map))
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
/**
|
|
@@ -443,7 +443,7 @@ export function queryAndSavePureBatched<
|
|
|
443
443
|
map: { filter: Filter<PM>; collect?: (t: T) => Option<S>; limit?: number; skip?: number },
|
|
444
444
|
batchSize = 100
|
|
445
445
|
) {
|
|
446
|
-
return self.queryAndSavePureEffectBatched(Effect(map), batchSize)
|
|
446
|
+
return self.queryAndSavePureEffectBatched(Effect.sync(() => map), batchSize)
|
|
447
447
|
}
|
|
448
448
|
|
|
449
449
|
/**
|
|
@@ -536,7 +536,7 @@ export interface OneDSLExt<T, Evt> {
|
|
|
536
536
|
* @tsplus fluent DSLExt updateWith
|
|
537
537
|
*/
|
|
538
538
|
export function updateWithOne<T, Evt, S1 extends T, S2 extends T>(self: OneDSL<T, Evt>, upd: (item: S1) => S2) {
|
|
539
|
-
return self.update((_: S1) => Effect(upd(_)))
|
|
539
|
+
return self.update((_: S1) => Effect.sync(() => upd(_)))
|
|
540
540
|
}
|
|
541
541
|
|
|
542
542
|
/**
|
|
@@ -546,7 +546,7 @@ export function updateWith<T, Evt, S1 extends T, S2 extends T>(
|
|
|
546
546
|
self: AllDSL<T, Evt>,
|
|
547
547
|
upd: (item: S1[]) => S2[]
|
|
548
548
|
) {
|
|
549
|
-
return self.update((_: S1[]) => Effect(upd(_)))
|
|
549
|
+
return self.update((_: S1[]) => Effect.sync(() => upd(_)))
|
|
550
550
|
}
|
|
551
551
|
|
|
552
552
|
export function makeOneDSL<T, Evt>(): OneDSL<T, Evt> {
|
|
@@ -603,14 +603,14 @@ export function makeDSL<S1, S2, Evt>() {
|
|
|
603
603
|
export interface DSLExt<S1, S2, Evt> extends ReturnType<typeof makeDSL<S1, S2, Evt>> {}
|
|
604
604
|
|
|
605
605
|
export function ifAny<T, R, E, A>(fn: (items: NonEmptyReadonlyArray<T>) => Effect<R, E, A>) {
|
|
606
|
-
return (items: Iterable<T>) => Effect(items.toNonEmptyArray).flatMapOpt(fn)
|
|
606
|
+
return (items: Iterable<T>) => Effect.sync(() => items.toNonEmptyArray).flatMapOpt(fn)
|
|
607
607
|
}
|
|
608
608
|
|
|
609
609
|
/**
|
|
610
610
|
* @tsplus fluent Iterable ifAny
|
|
611
611
|
*/
|
|
612
612
|
export function ifAny_<T, R, E, A>(items: Iterable<T>, fn: (items: NonEmptyReadonlyArray<T>) => Effect<R, E, A>) {
|
|
613
|
-
return Effect(items.toNonEmptyArray).flatMapOpt(fn)
|
|
613
|
+
return Effect.sync(() => items.toNonEmptyArray).flatMapOpt(fn)
|
|
614
614
|
}
|
|
615
615
|
|
|
616
616
|
/**
|
|
@@ -5,10 +5,9 @@ import { ContextMap, StoreMaker } from "./Store.js"
|
|
|
5
5
|
import type { Filter, StoreConfig, Where } from "./Store.js"
|
|
6
6
|
import type {} from "effect/Equal"
|
|
7
7
|
import type {} from "effect/Hash"
|
|
8
|
-
import type { Opt } from "@effect-app/core/Option"
|
|
9
8
|
import { makeCodec } from "@effect-app/infra/api/codec"
|
|
10
9
|
import { makeFilters } from "@effect-app/infra/filter"
|
|
11
|
-
import type { Schema } from "@effect-app/prelude"
|
|
10
|
+
import type { Option, Schema } from "@effect-app/prelude"
|
|
12
11
|
import { EParserFor } from "@effect-app/prelude/schema"
|
|
13
12
|
import type { InvalidStateError, OptimisticConcurrencyException } from "../errors.js"
|
|
14
13
|
|
|
@@ -21,7 +20,7 @@ export const RepositoryBase = <Service>() => {
|
|
|
21
20
|
) => {
|
|
22
21
|
abstract class RepositoryBaseC implements Repository<T, PM, Evt, ItemType> {
|
|
23
22
|
itemType: ItemType = itemType
|
|
24
|
-
abstract find: (id: T["id"]) => Effect<ContextMap | RequestContextContainer, never,
|
|
23
|
+
abstract find: (id: T["id"]) => Effect<ContextMap | RequestContextContainer, never, Option<T>>
|
|
25
24
|
abstract all: Effect<ContextMap, never, T[]>
|
|
26
25
|
abstract saveAndPublish: (
|
|
27
26
|
items: Iterable<T>,
|
|
@@ -130,7 +129,8 @@ export function makeRepo<
|
|
|
130
129
|
}
|
|
131
130
|
|
|
132
131
|
const saveAllE = (a: Iterable<E>) =>
|
|
133
|
-
Effect
|
|
132
|
+
Effect
|
|
133
|
+
.sync(() => a.toNonEmptyArray)
|
|
134
134
|
.flatMapOpt((a) =>
|
|
135
135
|
Do(($) => {
|
|
136
136
|
const { get, set } = $(ContextMap)
|
|
@@ -145,7 +145,8 @@ export function makeRepo<
|
|
|
145
145
|
|
|
146
146
|
const saveAndPublish = (items: Iterable<T>, events: Iterable<Evt> = []) =>
|
|
147
147
|
saveAll(items)
|
|
148
|
-
> Effect
|
|
148
|
+
> Effect
|
|
149
|
+
.sync(() => events.toNonEmptyArray)
|
|
149
150
|
// TODO: for full consistency the events should be stored within the same database transaction, and then picked up.
|
|
150
151
|
.flatMapOpt(publishEvents)
|
|
151
152
|
|
|
@@ -159,7 +160,8 @@ export function makeRepo<
|
|
|
159
160
|
set(e.id, undefined)
|
|
160
161
|
}
|
|
161
162
|
yield* $(
|
|
162
|
-
Effect
|
|
163
|
+
Effect
|
|
164
|
+
.sync(() => events.toNonEmptyArray)
|
|
163
165
|
// TODO: for full consistency the events should be stored within the same database transaction, and then picked up.
|
|
164
166
|
.flatMapOpt(publishEvents)
|
|
165
167
|
)
|
|
@@ -15,7 +15,7 @@ export abstract class RequestContextContainer extends TagClass<RequestContextCon
|
|
|
15
15
|
.flatMap((requestContext) =>
|
|
16
16
|
requestContext.isSome()
|
|
17
17
|
? requestContext.value.requestContext.map(Option.some)
|
|
18
|
-
: Effect(Option.none)
|
|
18
|
+
: Effect.sync(() => Option.none())
|
|
19
19
|
)
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -84,7 +84,7 @@ export function makeCosmosStore({ prefix }: StorageConfig) {
|
|
|
84
84
|
([i, batch]) =>
|
|
85
85
|
Effect
|
|
86
86
|
.promise(() => bulk(batch.map(([, op]) => op)))
|
|
87
|
-
.delay(Duration.
|
|
87
|
+
.delay(Duration.millis(i === 0 ? 0 : 1100))
|
|
88
88
|
.flatMap((responses) =>
|
|
89
89
|
Effect.gen(function*($) {
|
|
90
90
|
const r = responses.find((x) => x.statusCode === 412 || x.statusCode === 404)
|
|
@@ -188,10 +188,11 @@ export function makeCosmosStore({ prefix }: StorageConfig) {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
const s: Store<PM, Id> = {
|
|
191
|
-
all: Effect
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
all: Effect
|
|
192
|
+
.sync(() => ({
|
|
193
|
+
query: `SELECT * FROM ${name} f WHERE f.id != @id`,
|
|
194
|
+
parameters: [{ name: "@id", value: importedMarkerId }]
|
|
195
|
+
}))
|
|
195
196
|
.tap((q) => logQuery(q))
|
|
196
197
|
.flatMap((q) =>
|
|
197
198
|
Effect.promise(() =>
|
|
@@ -211,7 +212,8 @@ export function makeCosmosStore({ prefix }: StorageConfig) {
|
|
|
211
212
|
filter
|
|
212
213
|
.keys
|
|
213
214
|
.forEachEffect((k) =>
|
|
214
|
-
Effect
|
|
215
|
+
Effect
|
|
216
|
+
.sync(() => buildFilterJoinSelectCosmosQuery(filter, k, name, cursor?.skip, cursor?.limit))
|
|
215
217
|
.tap((q) => logQuery(q))
|
|
216
218
|
.flatMap((q) =>
|
|
217
219
|
Effect.promise(() =>
|
|
@@ -249,7 +251,8 @@ export function makeCosmosStore({ prefix }: StorageConfig) {
|
|
|
249
251
|
? filter
|
|
250
252
|
.keys
|
|
251
253
|
.forEachEffect((k) =>
|
|
252
|
-
Effect
|
|
254
|
+
Effect
|
|
255
|
+
.sync(() => buildFindJoinCosmosQuery(filter, k, name, skip, limit))
|
|
253
256
|
.tap((q) => logQuery(q))
|
|
254
257
|
.flatMap((q) =>
|
|
255
258
|
Effect.promise(() =>
|
|
@@ -262,7 +265,8 @@ export function makeCosmosStore({ prefix }: StorageConfig) {
|
|
|
262
265
|
)
|
|
263
266
|
)
|
|
264
267
|
.map((_) => _.flatMap((_) => _))
|
|
265
|
-
: Effect
|
|
268
|
+
: Effect
|
|
269
|
+
.sync(() => buildCosmosQuery(filter, name, importedMarkerId, skip, limit))
|
|
266
270
|
.tap((q) => logQuery(q))
|
|
267
271
|
.flatMap((q) =>
|
|
268
272
|
Effect.promise(() =>
|
|
@@ -325,10 +329,10 @@ export function makeCosmosStore({ prefix }: StorageConfig) {
|
|
|
325
329
|
)
|
|
326
330
|
)
|
|
327
331
|
}
|
|
328
|
-
return Effect({
|
|
332
|
+
return Effect.sync(() => ({
|
|
329
333
|
...e,
|
|
330
334
|
_etag: x.etag
|
|
331
|
-
})
|
|
335
|
+
}))
|
|
332
336
|
})
|
|
333
337
|
.instrument("cosmos.set")
|
|
334
338
|
.annotateLogs("cosmos.db", containerId),
|
|
@@ -356,13 +360,14 @@ export function makeCosmosStore({ prefix }: StorageConfig) {
|
|
|
356
360
|
if (seed) {
|
|
357
361
|
const m = yield* $(seed)
|
|
358
362
|
yield* $(
|
|
359
|
-
Effect
|
|
363
|
+
Effect
|
|
364
|
+
.sync(() => m.toNonEmptyArray)
|
|
360
365
|
.flatMapOpt((a) =>
|
|
361
366
|
s
|
|
362
367
|
.bulkSet(a)
|
|
363
368
|
.orDie
|
|
364
369
|
// we delay extra here, so that initial creation between Companies/POs also have an interval between them.
|
|
365
|
-
.delay(Duration.
|
|
370
|
+
.delay(Duration.millis(1100))
|
|
366
371
|
)
|
|
367
372
|
)
|
|
368
373
|
}
|
|
@@ -39,7 +39,7 @@ function makeDiskStoreInt<Id extends string, PM extends PersistenceModelType<Id>
|
|
|
39
39
|
const withPermit = sem.withPermits(1)
|
|
40
40
|
const flushToDisk = store.all.flatMap(fsStore.setRaw).apply(withPermit)
|
|
41
41
|
const flushToDiskInBackground = flushToDisk
|
|
42
|
-
.tapErrorCause((err) => Effect(console.error(err)))
|
|
42
|
+
.tapErrorCause((err) => Effect.sync(() => console.error(err)))
|
|
43
43
|
.uninterruptible
|
|
44
44
|
.forkDaemon
|
|
45
45
|
|
|
@@ -84,10 +84,10 @@ export function makeDiskStore({ prefix }: StorageConfig, dir: string) {
|
|
|
84
84
|
const storesSem = Semaphore.unsafeMake(1)
|
|
85
85
|
const primary = yield* $(makeDiskStoreInt(prefix, "primary", dir, name, seed))
|
|
86
86
|
const stores = new Map<string, Store<PM, Id>>([["primary", primary]])
|
|
87
|
-
const getStore = !config?.allowNamespace ? Effect.
|
|
87
|
+
const getStore = !config?.allowNamespace ? Effect.sync(() => primary) : storeId.get.flatMap((namespace) => {
|
|
88
88
|
const store = stores.get(namespace)
|
|
89
89
|
if (store) {
|
|
90
|
-
return Effect.
|
|
90
|
+
return Effect.sync(() => store)
|
|
91
91
|
}
|
|
92
92
|
if (!config.allowNamespace!(namespace)) {
|
|
93
93
|
throw new Error(`Namespace ${namespace} not allowed!`)
|
|
@@ -95,7 +95,7 @@ export function makeDiskStore({ prefix }: StorageConfig, dir: string) {
|
|
|
95
95
|
return storesSem.withPermits(1)(
|
|
96
96
|
Effect.suspend(() => {
|
|
97
97
|
const existing = stores.get(namespace)
|
|
98
|
-
if (existing) return Effect(existing)
|
|
98
|
+
if (existing) return Effect.sync(() => existing)
|
|
99
99
|
return makeDiskStoreInt<Id, PM>(prefix, namespace, dir, name, seed).tap((store) =>
|
|
100
100
|
Effect.sync(() => stores.set(namespace, store))
|
|
101
101
|
)
|
|
@@ -47,7 +47,7 @@ export function makeMemoryStoreInt<Id extends string, PM extends PersistenceMode
|
|
|
47
47
|
) {
|
|
48
48
|
return Effect.gen(function*($) {
|
|
49
49
|
const updateETag = makeUpdateETag(name)
|
|
50
|
-
const items_ = yield* $(seed ?? Effect([]))
|
|
50
|
+
const items_ = yield* $(seed ?? Effect.sync(() => []))
|
|
51
51
|
const items = new Map(items_.toChunk.map((_) => [_.id, _] as const))
|
|
52
52
|
const makeStore = (): ReadonlyMap<Id, PM> => new Map([...items.entries()].map(([id, e]) => [id, makeETag(e)]))
|
|
53
53
|
const store = Ref.unsafeMake(makeStore())
|
|
@@ -108,17 +108,17 @@ export const makeMemoryStore = () => ({
|
|
|
108
108
|
const storesSem = Semaphore.unsafeMake(1)
|
|
109
109
|
const primary = yield* $(makeMemoryStoreInt<Id, PM>(name, seed))
|
|
110
110
|
const stores = new Map([["primary", primary]])
|
|
111
|
-
const getStore = !config?.allowNamespace ? Effect.
|
|
111
|
+
const getStore = !config?.allowNamespace ? Effect.sync(() => primary) : storeId.get.flatMap((namespace) => {
|
|
112
112
|
const store = stores.get(namespace)
|
|
113
113
|
if (store) {
|
|
114
|
-
return Effect.
|
|
114
|
+
return Effect.sync(() => store)
|
|
115
115
|
}
|
|
116
116
|
if (!config.allowNamespace!(namespace)) {
|
|
117
117
|
throw new Error(`Namespace ${namespace} not allowed!`)
|
|
118
118
|
}
|
|
119
119
|
return storesSem.withPermits(1)(Effect.suspend(() => {
|
|
120
120
|
const store = stores.get(namespace)
|
|
121
|
-
if (store) return Effect(store)
|
|
121
|
+
if (store) return Effect.sync(() => store)
|
|
122
122
|
return makeMemoryStoreInt(name, seed).tap((store) => Effect.sync(() => stores.set(namespace, store)))
|
|
123
123
|
}))
|
|
124
124
|
})
|
|
@@ -22,7 +22,7 @@ export function makeRedisStore({ prefix }: StorageConfig) {
|
|
|
22
22
|
const key = `${prefix}${name}`
|
|
23
23
|
const current = yield* $(redis.get(key).orDie.provideService(RedisClient, redis))
|
|
24
24
|
if (!current.isSome()) {
|
|
25
|
-
const m = yield* $(seed ?? Effect([]))
|
|
25
|
+
const m = yield* $(seed ?? Effect.sync(() => []))
|
|
26
26
|
yield* $(
|
|
27
27
|
redis
|
|
28
28
|
.set(key, JSON.stringify({ data: [...m].map((e) => makeETag(e)) }))
|
|
@@ -17,7 +17,7 @@ describe("Optimistic Concurrency", () => {
|
|
|
17
17
|
{ _etag: string | undefined; id: string; a: string }
|
|
18
18
|
>()
|
|
19
19
|
const { make } = makeMemoryStore()
|
|
20
|
-
const store = yield* $(make("test", Effect(existing)))
|
|
20
|
+
const store = yield* $(make("test", Effect.sync(() => existing)))
|
|
21
21
|
|
|
22
22
|
const result1 = yield* $(store.set({ id: "1", a: "string", _etag: undefined }))
|
|
23
23
|
const result2_1 = yield* $(
|
|
@@ -51,7 +51,7 @@ describe("Optimistic Concurrency", () => {
|
|
|
51
51
|
{ _etag: string | undefined; id: string; a: string }
|
|
52
52
|
>()
|
|
53
53
|
const { make } = makeMemoryStore()
|
|
54
|
-
const store = yield* $(make("test", Effect(existing)))
|
|
54
|
+
const store = yield* $(make("test", Effect.sync(() => existing)))
|
|
55
55
|
|
|
56
56
|
const [result1] = yield* $(
|
|
57
57
|
store.bulkSet([{ id: "1", a: "string", _etag: undefined }])
|
|
@@ -89,7 +89,7 @@ describe("Optimistic Concurrency", () => {
|
|
|
89
89
|
{ _etag: string | undefined; id: string; a: string }
|
|
90
90
|
>()
|
|
91
91
|
const { make } = makeMemoryStore()
|
|
92
|
-
const store = yield* $(make("test", Effect(existing)))
|
|
92
|
+
const store = yield* $(make("test", Effect.sync(() => existing)))
|
|
93
93
|
|
|
94
94
|
const item1 = { id: "1", a: "string", _etag: undefined }
|
|
95
95
|
const item2 = { id: "2", a: "string", _etag: undefined }
|
|
@@ -102,8 +102,8 @@ describe("Optimistic Concurrency", () => {
|
|
|
102
102
|
const failResult = yield* $(
|
|
103
103
|
store.batchSet([{ id: "1", a: "another-string3", _etag: "abc" }]).result
|
|
104
104
|
)
|
|
105
|
-
expect(result1).toEqual(Option({ ...item1, _etag: expect.any(String) }))
|
|
106
|
-
expect(result2).toEqual(Option({ ...item2, _etag: expect.any(String) }))
|
|
105
|
+
expect(result1).toEqual(Option.some({ ...item1, _etag: expect.any(String) }))
|
|
106
|
+
expect(result2).toEqual(Option.some({ ...item2, _etag: expect.any(String) }))
|
|
107
107
|
expect(Exit.untraced(failResult)).toEqual(
|
|
108
108
|
Exit.fail(new OptimisticConcurrencyException("test", "1"))
|
|
109
109
|
)
|
|
@@ -20,7 +20,7 @@ export function StoreMakerLive(config: Config<StorageConfig>) {
|
|
|
20
20
|
const storageUrl = cfg.url.value
|
|
21
21
|
if (storageUrl.startsWith("mem://")) {
|
|
22
22
|
console.log("Using in memory store")
|
|
23
|
-
return Effect(makeMemoryStore())
|
|
23
|
+
return Effect.sync(() => makeMemoryStore())
|
|
24
24
|
}
|
|
25
25
|
if (storageUrl.startsWith("disk://")) {
|
|
26
26
|
const dir = storageUrl.replace("disk://", "")
|
|
@@ -41,19 +41,19 @@ export function codeFilter<E extends { id: string }, NE extends E>(filter: Filte
|
|
|
41
41
|
filter.type === "startsWith"
|
|
42
42
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
43
|
? lowercaseIfString((x as any)[filter.by]).startsWith(filter.value.toLowerCase())
|
|
44
|
-
? Option(x as unknown as NE)
|
|
45
|
-
: Option.none
|
|
44
|
+
? Option.some(x as unknown as NE)
|
|
45
|
+
: Option.none()
|
|
46
46
|
: filter.type === "endsWith"
|
|
47
47
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
48
|
? lowercaseIfString((x as any)[filter.by]).endsWith(filter.value.toLowerCase())
|
|
49
|
-
? Option(x as unknown as NE)
|
|
50
|
-
: Option.none
|
|
49
|
+
? Option.some(x as unknown as NE)
|
|
50
|
+
: Option.none()
|
|
51
51
|
: filter.type === "contains"
|
|
52
52
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
53
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
54
54
|
? lowercaseIfString((x as any)[filter.by]).includes(filter.value.toLowerCase())
|
|
55
|
-
? Option(x as unknown as NE)
|
|
56
|
-
: Option.none
|
|
55
|
+
? Option.some(x as unknown as NE)
|
|
56
|
+
: Option.none()
|
|
57
57
|
: filter.type === "join_find"
|
|
58
58
|
? filter.keys.some((k) => {
|
|
59
59
|
const value = get(x, k) as Record<string, unknown>[]
|
|
@@ -63,8 +63,8 @@ export function codeFilter<E extends { id: string }, NE extends E>(filter: Filte
|
|
|
63
63
|
&& value.some((v) => compareCaseInsensitive(v[filter.valueKey], filter.value))
|
|
64
64
|
)
|
|
65
65
|
})
|
|
66
|
-
? Option(x as unknown as NE)
|
|
67
|
-
: Option.none
|
|
66
|
+
? Option.some(x as unknown as NE)
|
|
67
|
+
: Option.none()
|
|
68
68
|
// TODO: support mixed or/and
|
|
69
69
|
: filter.mode === "or"
|
|
70
70
|
? filter
|
|
@@ -101,8 +101,8 @@ export function codeFilter<E extends { id: string }, NE extends E>(filter: Filte
|
|
|
101
101
|
return compareCaseInsensitive(k, p.value)
|
|
102
102
|
}
|
|
103
103
|
})
|
|
104
|
-
? Option(x as unknown as NE)
|
|
105
|
-
: Option.none
|
|
104
|
+
? Option.some(x as unknown as NE)
|
|
105
|
+
: Option.none()
|
|
106
106
|
: filter
|
|
107
107
|
.where
|
|
108
108
|
.every((p) => {
|
|
@@ -145,8 +145,8 @@ export function codeFilter<E extends { id: string }, NE extends E>(filter: Filte
|
|
|
145
145
|
: compareCaseInsensitive(k, p.value)
|
|
146
146
|
}
|
|
147
147
|
})
|
|
148
|
-
? Option(x as unknown as NE)
|
|
149
|
-
: Option.none
|
|
148
|
+
? Option.some(x as unknown as NE)
|
|
149
|
+
: Option.none()
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
export function codeFilterJoinSelect<E extends { id: string }, NE>(
|
|
@@ -159,15 +159,15 @@ export function codeFilterJoinSelect<E extends { id: string }, NE>(
|
|
|
159
159
|
const value = get(x, k)
|
|
160
160
|
// we mimic the behavior of cosmosdb; if the shape in db does not match what we're looking for, we imagine false hit
|
|
161
161
|
return value
|
|
162
|
-
? Option(
|
|
162
|
+
? Option.some(
|
|
163
163
|
(value as readonly NE[]).filterMap((v) =>
|
|
164
164
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
165
165
|
compareCaseInsensitive((v as any)[filter.valueKey], filter.value)
|
|
166
|
-
? Option({ ...v, _rootId: x.id })
|
|
167
|
-
: Option.none
|
|
166
|
+
? Option.some({ ...v, _rootId: x.id })
|
|
167
|
+
: Option.none()
|
|
168
168
|
)
|
|
169
169
|
)
|
|
170
|
-
: Option.none
|
|
170
|
+
: Option.none()
|
|
171
171
|
})
|
|
172
172
|
.flatMap((_) => _)
|
|
173
173
|
}
|
|
@@ -133,7 +133,7 @@ export function createContext<TKey extends string, EA, A extends DBRecord<TKey>>
|
|
|
133
133
|
function tryRead(filePath: string) {
|
|
134
134
|
return fu
|
|
135
135
|
.fileExists(filePath)
|
|
136
|
-
.flatMap((exists) => !exists ? Effect(Option.none) : readFile(filePath).map(Option.some))
|
|
136
|
+
.flatMap((exists) => !exists ? Effect.sync(() => Option.none()) : readFile(filePath).map(Option.some))
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
function getFilename(type: string, id: string) {
|
|
@@ -64,7 +64,7 @@ export function getRecordName(type: string, id: string) {
|
|
|
64
64
|
export function makeMap<TKey, T>() {
|
|
65
65
|
const map = new Map<TKey, T>()
|
|
66
66
|
return {
|
|
67
|
-
find: (k: TKey) => Effect(Option.fromNullable(map.get(k))),
|
|
67
|
+
find: (k: TKey) => Effect.sync(() => Option.fromNullable(map.get(k))),
|
|
68
68
|
[Symbol.iterator]: () => map[Symbol.iterator](),
|
|
69
69
|
set: (k: TKey, v: T) =>
|
|
70
70
|
Effect.sync(() => {
|
|
@@ -28,7 +28,7 @@ export interface RecordCache extends ReturnType<typeof makeLiveRecordCache> {}
|
|
|
28
28
|
// module tag
|
|
29
29
|
export const RecordCache = Tag<RecordCache>()
|
|
30
30
|
|
|
31
|
-
export const LiveRecordCache = Effect(makeLiveRecordCache()).toLayer(RecordCache)
|
|
31
|
+
export const LiveRecordCache = Effect.sync(() => makeLiveRecordCache()).toLayer(RecordCache)
|
|
32
32
|
|
|
33
33
|
const getM = <T>(type: string) => <R, E, A>(eff: (m: EffectMap<string, CachedRecord<T>>) => Effect<R, E, A>) =>
|
|
34
34
|
Effect.gen(function*($) {
|
|
@@ -90,7 +90,7 @@ export function store<R, E, R2, E2, TKey extends string, EA, A extends DBRecord<
|
|
|
90
90
|
c
|
|
91
91
|
.find(record.id)
|
|
92
92
|
.mapOpt((x) => x.version)
|
|
93
|
-
.flatMap((_) => _.match({ onNone: () => save(record, Option.none), onSome: confirmVersionAndSave(record) }))
|
|
93
|
+
.flatMap((_) => _.match({ onNone: () => save(record, Option.none()), onSome: confirmVersionAndSave(record) }))
|
|
94
94
|
.tap((r) => c.set(record.id, r))
|
|
95
95
|
.map((r) => r.data)
|
|
96
96
|
)
|
|
@@ -110,7 +110,7 @@ export function store<R, E, R2, E2, TKey extends string, EA, A extends DBRecord<
|
|
|
110
110
|
? new OptimisticLockException(type, record.id)
|
|
111
111
|
: Effect.unit
|
|
112
112
|
)
|
|
113
|
-
.zipRight(save(record, Option(cv)))
|
|
113
|
+
.zipRight(save(record, Option.some(cv)))
|
|
114
114
|
)
|
|
115
115
|
.scoped
|
|
116
116
|
}
|
package/dist/RequestContext.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ declare const RequestContextParent_base: import("@effect-app/schema").MNModel<im
|
|
|
5
5
|
id: import("@effect-app/schema").SchemaDefaultSchema<unknown, RequestId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<RequestId>> & import("@effect-app/schema").Utils<import("@effect-app/schema").SchemaDefaultSchema<unknown, RequestId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<RequestId>>> & {
|
|
6
6
|
EParser: import("@effect-app/schema/custom/_parser").Parser<string, any, RequestId>;
|
|
7
7
|
make: () => RequestId;
|
|
8
|
-
eq: import("effect/Equivalence")
|
|
9
|
-
withDefault: import("@effect-app/schema").Property<import("@effect-app/schema").SchemaDefaultSchema<unknown, RequestId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<RequestId>>, "required", import("effect/Option").None<any>, import("effect/Option").Some<["constructor", () => RequestId]>>;
|
|
8
|
+
eq: import("effect/Equivalence")<RequestId>;
|
|
9
|
+
withDefault: import("@effect-app/schema").Property<import("@effect-app/schema").SchemaDefaultSchema<unknown, RequestId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<RequestId>>, "required", import("effect/Option.impl").None<any>, import("effect/Option.impl").Some<["constructor", () => RequestId]>>;
|
|
10
10
|
};
|
|
11
11
|
name: import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").ReasonableString, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").ReasonableString>> & import("@effect-app/schema").Utils<import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").ReasonableString, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").ReasonableString>>>;
|
|
12
12
|
userProfile: import("@effect-app/schema").Property<import("@effect-app/schema").Schema<unknown, {
|
|
@@ -20,30 +20,30 @@ declare const RequestContextParent_base: import("@effect-app/schema").MNModel<im
|
|
|
20
20
|
sub: import("@effect-app/schema").Property<import("@effect-app/schema").SchemaDefaultSchema<unknown, UserProfileId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<UserProfileId>> & import("@effect-app/schema").Utils<import("@effect-app/schema").SchemaDefaultSchema<unknown, UserProfileId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<UserProfileId>>> & {
|
|
21
21
|
EParser: import("@effect-app/schema/custom/_parser").Parser<string, any, UserProfileId>;
|
|
22
22
|
make: () => UserProfileId;
|
|
23
|
-
eq: import("effect/Equivalence")
|
|
24
|
-
withDefault: import("@effect-app/schema").Property<import("@effect-app/schema").SchemaDefaultSchema<unknown, UserProfileId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<UserProfileId>>, "required", import("effect/Option").None<any>, import("effect/Option").Some<["constructor", () => UserProfileId]>>;
|
|
25
|
-
}, "required", import("effect/Option").None<any>, import("effect/Option").None<any>>;
|
|
23
|
+
eq: import("effect/Equivalence")<UserProfileId>;
|
|
24
|
+
withDefault: import("@effect-app/schema").Property<import("@effect-app/schema").SchemaDefaultSchema<unknown, UserProfileId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<UserProfileId>>, "required", import("effect/Option.impl").None<any>, import("effect/Option.impl").Some<["constructor", () => UserProfileId]>>;
|
|
25
|
+
}, "required", import("effect/Option.impl").None<any>, import("effect/Option.impl").None<any>>;
|
|
26
26
|
}>;
|
|
27
|
-
}>, "optional", import("effect/Option").None<any>, import("effect/Option").None<any>>;
|
|
27
|
+
}>, "optional", import("effect/Option.impl").None<any>, import("effect/Option.impl").None<any>>;
|
|
28
28
|
locale: import("@effect-app/schema").DefaultSchema<unknown, "en" | "de", "en" | "de", "en" | "de", import("@effect-app/schema").LiteralApi<["en", "de"]>>;
|
|
29
|
-
createdAt: import("@effect-app/schema").FromProperty<import("@effect-app/schema").Schema<unknown, Date, Date, string, {}>, "required", import("effect/Option").None<any>, import("effect/Option").Some<["constructor", () => Date]>>;
|
|
29
|
+
createdAt: import("@effect-app/schema").FromProperty<import("@effect-app/schema").Schema<unknown, Date, Date, string, {}>, "required", import("effect/Option.impl").None<any>, import("effect/Option.impl").Some<["constructor", () => Date]>>;
|
|
30
30
|
}>>, RequestContextParent, RequestContextParent.ConstructorInput, RequestContextParent.Encoded, RequestContextParent.Props> & import("@effect-app/schema").PropsExtensions<RequestContextParent.Props>;
|
|
31
31
|
export declare class RequestContextParent extends RequestContextParent_base {
|
|
32
32
|
}
|
|
33
33
|
declare const RequestContext_base: import("@effect-app/schema").MNModel<import("@effect-app/schema").SchemaProperties<import("@effect-app/schema").ToProps<{
|
|
34
|
-
id: import("@effect-app/schema").Property<import("@effect-app/schema").SchemaDefaultSchema<unknown, RequestId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<RequestId>>, "required", import("effect/Option").None<any>, import("effect/Option").Some<["constructor", () => RequestId]>>;
|
|
34
|
+
id: import("@effect-app/schema").Property<import("@effect-app/schema").SchemaDefaultSchema<unknown, RequestId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<RequestId>>, "required", import("effect/Option.impl").None<any>, import("effect/Option.impl").Some<["constructor", () => RequestId]>>;
|
|
35
35
|
rootId: import("@effect-app/schema").SchemaDefaultSchema<unknown, RequestId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<RequestId>> & import("@effect-app/schema").Utils<import("@effect-app/schema").SchemaDefaultSchema<unknown, RequestId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<RequestId>>> & {
|
|
36
36
|
EParser: import("@effect-app/schema/custom/_parser").Parser<string, any, RequestId>;
|
|
37
37
|
make: () => RequestId;
|
|
38
|
-
eq: import("effect/Equivalence")
|
|
39
|
-
withDefault: import("@effect-app/schema").Property<import("@effect-app/schema").SchemaDefaultSchema<unknown, RequestId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<RequestId>>, "required", import("effect/Option").None<any>, import("effect/Option").Some<["constructor", () => RequestId]>>;
|
|
38
|
+
eq: import("effect/Equivalence")<RequestId>;
|
|
39
|
+
withDefault: import("@effect-app/schema").Property<import("@effect-app/schema").SchemaDefaultSchema<unknown, RequestId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<RequestId>>, "required", import("effect/Option.impl").None<any>, import("effect/Option.impl").Some<["constructor", () => RequestId]>>;
|
|
40
40
|
};
|
|
41
41
|
parent: import("@effect-app/schema").Property<import("@effect-app/schema").Schema<unknown, RequestContextParent, RequestContextParent.ConstructorInput, RequestContextParent.Encoded, {
|
|
42
42
|
props: RequestContextParent.Props;
|
|
43
|
-
}>, "optional", import("effect/Option").None<any>, import("effect/Option").None<any>>;
|
|
44
|
-
namespace: import("@effect-app/schema").Property<import("@effect-app/schema").Schema<unknown, import("@effect-app/schema").ReasonableString, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").ReasonableString>>, "optional", import("effect/Option").None<any>, import("effect/Option").None<any>>;
|
|
45
|
-
_tag: import("@effect-app/schema").Property<import("@effect-app/schema").DefaultSchema<unknown, "RequestContext", "RequestContext", "RequestContext", import("@effect-app/schema").LiteralApi<["RequestContext"]>>, "required", import("effect/Option").None<any>, import("effect/Option").None<any>>;
|
|
46
|
-
name: import("@effect-app/schema").Property<import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").ReasonableString, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").ReasonableString>> & import("@effect-app/schema").Utils<import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").ReasonableString, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").ReasonableString>>>, "required", import("effect/Option").None<any>, import("effect/Option").None<any>>;
|
|
43
|
+
}>, "optional", import("effect/Option.impl").None<any>, import("effect/Option.impl").None<any>>;
|
|
44
|
+
namespace: import("@effect-app/schema").Property<import("@effect-app/schema").Schema<unknown, import("@effect-app/schema").ReasonableString, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").ReasonableString>>, "optional", import("effect/Option.impl").None<any>, import("effect/Option.impl").None<any>>;
|
|
45
|
+
_tag: import("@effect-app/schema").Property<import("@effect-app/schema").DefaultSchema<unknown, "RequestContext", "RequestContext", "RequestContext", import("@effect-app/schema").LiteralApi<["RequestContext"]>>, "required", import("effect/Option.impl").None<any>, import("effect/Option.impl").None<any>>;
|
|
46
|
+
name: import("@effect-app/schema").Property<import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").ReasonableString, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").ReasonableString>> & import("@effect-app/schema").Utils<import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").ReasonableString, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").ReasonableString>>>, "required", import("effect/Option.impl").None<any>, import("effect/Option.impl").None<any>>;
|
|
47
47
|
userProfile: import("@effect-app/schema").Property<import("@effect-app/schema").Schema<unknown, {
|
|
48
48
|
readonly sub: UserProfileId;
|
|
49
49
|
}, {
|
|
@@ -55,13 +55,13 @@ declare const RequestContext_base: import("@effect-app/schema").MNModel<import("
|
|
|
55
55
|
sub: import("@effect-app/schema").Property<import("@effect-app/schema").SchemaDefaultSchema<unknown, UserProfileId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<UserProfileId>> & import("@effect-app/schema").Utils<import("@effect-app/schema").SchemaDefaultSchema<unknown, UserProfileId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<UserProfileId>>> & {
|
|
56
56
|
EParser: import("@effect-app/schema/custom/_parser").Parser<string, any, UserProfileId>;
|
|
57
57
|
make: () => UserProfileId;
|
|
58
|
-
eq: import("effect/Equivalence")
|
|
59
|
-
withDefault: import("@effect-app/schema").Property<import("@effect-app/schema").SchemaDefaultSchema<unknown, UserProfileId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<UserProfileId>>, "required", import("effect/Option").None<any>, import("effect/Option").Some<["constructor", () => UserProfileId]>>;
|
|
60
|
-
}, "required", import("effect/Option").None<any>, import("effect/Option").None<any>>;
|
|
58
|
+
eq: import("effect/Equivalence")<UserProfileId>;
|
|
59
|
+
withDefault: import("@effect-app/schema").Property<import("@effect-app/schema").SchemaDefaultSchema<unknown, UserProfileId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<UserProfileId>>, "required", import("effect/Option.impl").None<any>, import("effect/Option.impl").Some<["constructor", () => UserProfileId]>>;
|
|
60
|
+
}, "required", import("effect/Option.impl").None<any>, import("effect/Option.impl").None<any>>;
|
|
61
61
|
}>;
|
|
62
|
-
}>, "optional", import("effect/Option").None<any>, import("effect/Option").None<any>>;
|
|
63
|
-
locale: import("@effect-app/schema").Property<import("@effect-app/schema").DefaultSchema<unknown, "en" | "de", "en" | "de", "en" | "de", import("@effect-app/schema").LiteralApi<["en", "de"]>>, "required", import("effect/Option").None<any>, import("effect/Option").None<any>>;
|
|
64
|
-
createdAt: import("@effect-app/schema").FromProperty<import("@effect-app/schema").Schema<unknown, Date, Date, string, {}>, "required", import("effect/Option").None<any>, import("effect/Option").Some<["constructor", () => Date]>>;
|
|
62
|
+
}>, "optional", import("effect/Option.impl").None<any>, import("effect/Option.impl").None<any>>;
|
|
63
|
+
locale: import("@effect-app/schema").Property<import("@effect-app/schema").DefaultSchema<unknown, "en" | "de", "en" | "de", "en" | "de", import("@effect-app/schema").LiteralApi<["en", "de"]>>, "required", import("effect/Option.impl").None<any>, import("effect/Option.impl").None<any>>;
|
|
64
|
+
createdAt: import("@effect-app/schema").FromProperty<import("@effect-app/schema").Schema<unknown, Date, Date, string, {}>, "required", import("effect/Option.impl").None<any>, import("effect/Option.impl").Some<["constructor", () => Date]>>;
|
|
65
65
|
}>>, RequestContext, RequestContext.ConstructorInput, RequestContext.Encoded, RequestContext.Props> & import("@effect-app/schema").PropsExtensions<RequestContext.Props>;
|
|
66
66
|
/**
|
|
67
67
|
* @tsplus type RequestContext
|
package/dist/_ext/Array.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "effect/Chunk";
|
|
2
|
-
import * as tsplus_module_2 from "
|
|
2
|
+
import * as tsplus_module_2 from "effect/Chunk.int";
|
|
3
|
+
import * as tsplus_module_3 from "@effect-app/prelude/_ext/misc";
|
|
3
4
|
import { inspect } from "util";
|
|
4
5
|
import { NotFoundError } from "../errors.js";
|
|
5
6
|
/**
|
|
@@ -10,7 +11,7 @@ import { NotFoundError } from "../errors.js";
|
|
|
10
11
|
* @tsplus fluent ReadonlyArray getFirstById
|
|
11
12
|
*/
|
|
12
13
|
export function getFirstById_(a, id, type) {
|
|
13
|
-
return
|
|
14
|
+
return tsplus_module_3.encaseMaybeInEffect_(tsplus_module_2.findFirst(tsplus_module_1.Chunk.fromIterable(a), (_) => _.id === id), () => new NotFoundError({ type, id }));
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* @tsplus fluent Object.Ops inspect
|
|
@@ -18,4 +19,4 @@ export function getFirstById_(a, id, type) {
|
|
|
18
19
|
export function RecordInspect(o, showHidden, depth, color) {
|
|
19
20
|
return inspect(o.subject, showHidden, depth, color);
|
|
20
21
|
}
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
22
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQXJyYXkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9fc3JjL19leHQvQXJyYXkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQ0EsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLE1BQU0sQ0FBQTtBQUM5QixPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sY0FBYyxDQUFBO0FBRTVDOzs7Ozs7R0FNRztBQUNILE1BQU0sVUFBVSxhQUFhLENBQzNCLENBQWMsRUFDZCxFQUFNLEVBQ04sSUFBVTtJQUVWLE9BQU8scUNBQUEsMEJBQUEsZ0JBQUEsS0FBSyxDQUNULFlBQVksQ0FBQyxDQUFDLENBQUMsRUFDTCxDQUFDLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FBQyxDQUFDLEVBQUUsS0FBSyxFQUFFLENBQUMsRUFDZCxHQUFHLEVBQUUsQ0FBQyxJQUFJLGFBQWEsQ0FBQyxFQUFFLElBQUksRUFBRSxFQUFFLEVBQUUsQ0FBQyxDQUFDLENBQUE7QUFDMUQsQ0FBQztBQUVEOztHQUVHO0FBQ0gsTUFBTSxVQUFVLGFBQWEsQ0FDM0IsQ0FBZ0IsRUFDaEIsVUFBZ0MsRUFDaEMsS0FBaUMsRUFDakMsS0FBMkI7SUFFM0IsT0FBTyxPQUFPLENBQUMsQ0FBQyxDQUFDLE9BQU8sRUFBRSxVQUFVLEVBQUUsS0FBSyxFQUFFLEtBQUssQ0FBQyxDQUFBO0FBQ3JELENBQUMifQ==
|