@effect-app/infra 4.0.0-beta.24 → 4.0.0-beta.241
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 +1818 -0
- package/_check.sh +1 -1
- package/dist/CUPS.d.ts +12 -7
- package/dist/CUPS.d.ts.map +1 -1
- package/dist/CUPS.js +16 -12
- package/dist/Emailer/Sendgrid.d.ts +15 -15
- package/dist/Emailer/Sendgrid.d.ts.map +1 -1
- package/dist/Emailer/Sendgrid.js +21 -17
- package/dist/Emailer/fake.d.ts +1 -1
- package/dist/Emailer/fake.js +3 -3
- package/dist/Emailer/service.d.ts +13 -4
- package/dist/Emailer/service.d.ts.map +1 -1
- package/dist/Emailer/service.js +4 -3
- package/dist/Emailer.d.ts +1 -1
- package/dist/MainFiberSet.d.ts +12 -9
- package/dist/MainFiberSet.d.ts.map +1 -1
- package/dist/MainFiberSet.js +10 -6
- package/dist/Model/Repository/Registry.d.ts +21 -0
- package/dist/Model/Repository/Registry.d.ts.map +1 -0
- package/dist/Model/Repository/Registry.js +18 -0
- package/dist/Model/Repository/ext.d.ts +35 -16
- package/dist/Model/Repository/ext.d.ts.map +1 -1
- package/dist/Model/Repository/ext.js +60 -3
- package/dist/Model/Repository/internal/internal.d.ts +9 -6
- package/dist/Model/Repository/internal/internal.d.ts.map +1 -1
- package/dist/Model/Repository/internal/internal.js +141 -59
- package/dist/Model/Repository/legacy.d.ts +4 -2
- package/dist/Model/Repository/legacy.d.ts.map +1 -1
- package/dist/Model/Repository/makeRepo.d.ts +10 -6
- package/dist/Model/Repository/makeRepo.d.ts.map +1 -1
- package/dist/Model/Repository/makeRepo.js +5 -2
- package/dist/Model/Repository/service.d.ts +32 -24
- package/dist/Model/Repository/service.d.ts.map +1 -1
- package/dist/Model/Repository/validation.d.ts +47 -18
- package/dist/Model/Repository/validation.d.ts.map +1 -1
- package/dist/Model/Repository/validation.js +6 -6
- package/dist/Model/Repository.d.ts +2 -1
- package/dist/Model/Repository.d.ts.map +1 -1
- package/dist/Model/Repository.js +2 -1
- package/dist/Model/dsl.d.ts +6 -5
- package/dist/Model/dsl.d.ts.map +1 -1
- package/dist/Model/dsl.js +2 -3
- package/dist/Model/filter/filterApi.d.ts +5 -5
- package/dist/Model/filter/filterApi.d.ts.map +1 -1
- package/dist/Model/filter/types/errors.d.ts +1 -1
- package/dist/Model/filter/types/fields.d.ts +1 -1
- package/dist/Model/filter/types/path/common.d.ts +1 -1
- package/dist/Model/filter/types/path/eager.d.ts +1 -1
- package/dist/Model/filter/types/path/eager.d.ts.map +1 -1
- package/dist/Model/filter/types/path/eager.js +1 -1
- package/dist/Model/filter/types/path/index.d.ts +1 -1
- package/dist/Model/filter/types/utils.d.ts +1 -1
- package/dist/Model/filter/types/validator.d.ts +1 -1
- package/dist/Model/filter/types.d.ts +5 -5
- package/dist/Model/query/dsl.d.ts +216 -18
- package/dist/Model/query/dsl.d.ts.map +1 -1
- package/dist/Model/query/dsl.js +240 -5
- package/dist/Model/query/new-kid-interpreter.d.ts +116 -8
- package/dist/Model/query/new-kid-interpreter.d.ts.map +1 -1
- package/dist/Model/query/new-kid-interpreter.js +177 -6
- package/dist/Model/query.d.ts +1 -1
- package/dist/Model.d.ts +2 -1
- package/dist/Model.d.ts.map +1 -1
- package/dist/Model.js +2 -1
- package/dist/QueueMaker/SQLQueue.d.ts +7 -8
- package/dist/QueueMaker/SQLQueue.d.ts.map +1 -1
- package/dist/QueueMaker/SQLQueue.js +135 -117
- package/dist/QueueMaker/errors.d.ts +5 -3
- package/dist/QueueMaker/errors.d.ts.map +1 -1
- package/dist/QueueMaker/errors.js +4 -2
- package/dist/QueueMaker/memQueue.d.ts +9 -5
- package/dist/QueueMaker/memQueue.d.ts.map +1 -1
- package/dist/QueueMaker/memQueue.js +81 -65
- package/dist/QueueMaker/sbqueue.d.ts +8 -4
- package/dist/QueueMaker/sbqueue.d.ts.map +1 -1
- package/dist/QueueMaker/sbqueue.js +57 -55
- package/dist/QueueMaker/service.d.ts +4 -2
- package/dist/QueueMaker/service.d.ts.map +1 -1
- package/dist/QueueMaker/service.js +1 -1
- package/dist/RequestContext.d.ts +75 -35
- package/dist/RequestContext.d.ts.map +1 -1
- package/dist/RequestContext.js +14 -14
- package/dist/RequestFiberSet.d.ts +10 -7
- package/dist/RequestFiberSet.d.ts.map +1 -1
- package/dist/RequestFiberSet.js +12 -7
- package/dist/Store/ContextMapContainer.d.ts +22 -3
- package/dist/Store/ContextMapContainer.d.ts.map +1 -1
- package/dist/Store/ContextMapContainer.js +18 -4
- package/dist/Store/Cosmos/query.d.ts +13 -2
- package/dist/Store/Cosmos/query.d.ts.map +1 -1
- package/dist/Store/Cosmos/query.js +179 -41
- package/dist/Store/Cosmos.d.ts +2 -2
- package/dist/Store/Cosmos.d.ts.map +1 -1
- package/dist/Store/Cosmos.js +343 -244
- package/dist/Store/Disk.d.ts +3 -3
- package/dist/Store/Disk.d.ts.map +1 -1
- package/dist/Store/Disk.js +76 -36
- package/dist/Store/Memory.d.ts +7 -4
- package/dist/Store/Memory.d.ts.map +1 -1
- package/dist/Store/Memory.js +327 -62
- package/dist/Store/SQL/Pg.d.ts +4 -0
- package/dist/Store/SQL/Pg.d.ts.map +1 -0
- package/dist/Store/SQL/Pg.js +233 -0
- package/dist/Store/SQL/query.d.ts +49 -0
- package/dist/Store/SQL/query.d.ts.map +1 -0
- package/dist/Store/SQL/query.js +527 -0
- package/dist/Store/SQL.d.ts +21 -0
- package/dist/Store/SQL.d.ts.map +1 -0
- package/dist/Store/SQL.js +450 -0
- package/dist/Store/codeFilter.d.ts +2 -2
- package/dist/Store/codeFilter.d.ts.map +1 -1
- package/dist/Store/codeFilter.js +6 -3
- package/dist/Store/index.d.ts +6 -3
- package/dist/Store/index.d.ts.map +1 -1
- package/dist/Store/index.js +18 -4
- package/dist/Store/service.d.ts +39 -9
- package/dist/Store/service.d.ts.map +1 -1
- package/dist/Store/service.js +31 -7
- package/dist/Store/utils.d.ts +3 -2
- package/dist/Store/utils.d.ts.map +1 -1
- package/dist/Store/utils.js +5 -5
- package/dist/Store.d.ts +1 -1
- package/dist/adapters/SQL/Model.d.ts +32 -43
- package/dist/adapters/SQL/Model.d.ts.map +1 -1
- package/dist/adapters/SQL/Model.js +30 -39
- package/dist/adapters/SQL.d.ts +1 -1
- package/dist/adapters/ServiceBus.d.ts +14 -11
- package/dist/adapters/ServiceBus.d.ts.map +1 -1
- package/dist/adapters/ServiceBus.js +30 -21
- package/dist/adapters/cosmos-client.d.ts +5 -3
- package/dist/adapters/cosmos-client.d.ts.map +1 -1
- package/dist/adapters/cosmos-client.js +6 -4
- package/dist/adapters/index.d.ts +8 -2
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +8 -2
- package/dist/adapters/logger.d.ts +1 -1
- package/dist/adapters/logger.d.ts.map +1 -1
- package/dist/adapters/memQueue.d.ts +5 -3
- package/dist/adapters/memQueue.d.ts.map +1 -1
- package/dist/adapters/memQueue.js +6 -5
- package/dist/adapters/mongo-client.d.ts +4 -3
- package/dist/adapters/mongo-client.d.ts.map +1 -1
- package/dist/adapters/mongo-client.js +5 -3
- package/dist/adapters/redis-client.d.ts +6 -3
- package/dist/adapters/redis-client.d.ts.map +1 -1
- package/dist/adapters/redis-client.js +7 -3
- package/dist/api/ContextProvider.d.ts +12 -9
- package/dist/api/ContextProvider.d.ts.map +1 -1
- package/dist/api/ContextProvider.js +9 -7
- package/dist/api/codec.d.ts +1 -1
- package/dist/api/internal/RequestContextMiddleware.d.ts +3 -3
- package/dist/api/internal/RequestContextMiddleware.d.ts.map +1 -1
- package/dist/api/internal/RequestContextMiddleware.js +18 -7
- package/dist/api/internal/auth.d.ts +45 -7
- package/dist/api/internal/auth.d.ts.map +1 -1
- package/dist/api/internal/auth.js +162 -29
- package/dist/api/internal/events.d.ts +6 -4
- package/dist/api/internal/events.d.ts.map +1 -1
- package/dist/api/internal/events.js +18 -11
- package/dist/api/internal/health.d.ts +1 -1
- package/dist/api/layerUtils.d.ts +15 -7
- package/dist/api/layerUtils.d.ts.map +1 -1
- package/dist/api/layerUtils.js +7 -6
- package/dist/api/middlewares.d.ts +1 -1
- package/dist/api/reportError.d.ts +2 -2
- package/dist/api/reportError.d.ts.map +1 -1
- package/dist/api/reportError.js +3 -2
- package/dist/api/routing/middleware/RouterMiddleware.d.ts +5 -4
- package/dist/api/routing/middleware/RouterMiddleware.d.ts.map +1 -1
- package/dist/api/routing/middleware/middleware.d.ts +42 -3
- package/dist/api/routing/middleware/middleware.d.ts.map +1 -1
- package/dist/api/routing/middleware/middleware.js +53 -17
- package/dist/api/routing/middleware.d.ts +3 -4
- package/dist/api/routing/middleware.d.ts.map +1 -1
- package/dist/api/routing/middleware.js +1 -2
- package/dist/api/routing/schema/jwt.d.ts +1 -1
- package/dist/api/routing/schema/jwt.d.ts.map +1 -1
- package/dist/api/routing/schema/jwt.js +3 -2
- package/dist/api/routing/tsort.d.ts +1 -1
- package/dist/api/routing/tsort.d.ts.map +1 -1
- package/dist/api/routing/utils.d.ts +4 -4
- package/dist/api/routing/utils.d.ts.map +1 -1
- package/dist/api/routing/utils.js +3 -2
- package/dist/api/routing.d.ts +84 -38
- package/dist/api/routing.d.ts.map +1 -1
- package/dist/api/routing.js +115 -45
- package/dist/api/setupRequest.d.ts +13 -6
- package/dist/api/setupRequest.d.ts.map +1 -1
- package/dist/api/setupRequest.js +37 -11
- package/dist/api/util.d.ts +1 -1
- package/dist/arbs.d.ts +2 -2
- package/dist/arbs.d.ts.map +1 -1
- package/dist/arbs.js +5 -3
- package/dist/errorReporter.d.ts +7 -5
- package/dist/errorReporter.d.ts.map +1 -1
- package/dist/errorReporter.js +22 -26
- package/dist/errors.d.ts +1 -1
- package/dist/fileUtil.d.ts +2 -2
- package/dist/fileUtil.d.ts.map +1 -1
- package/dist/fileUtil.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/logger/jsonLogger.d.ts +2 -2
- package/dist/logger/jsonLogger.d.ts.map +1 -1
- package/dist/logger/jsonLogger.js +4 -2
- package/dist/logger/logFmtLogger.d.ts +2 -2
- package/dist/logger/logFmtLogger.d.ts.map +1 -1
- package/dist/logger/logFmtLogger.js +2 -2
- package/dist/logger/shared.d.ts +2 -2
- package/dist/logger/shared.d.ts.map +1 -1
- package/dist/logger/shared.js +3 -3
- package/dist/logger.d.ts +2 -2
- package/dist/logger.d.ts.map +1 -1
- package/dist/otel.d.ts +75 -0
- package/dist/otel.d.ts.map +1 -0
- package/dist/otel.js +65 -0
- package/dist/rateLimit.d.ts +12 -4
- package/dist/rateLimit.d.ts.map +1 -1
- package/dist/rateLimit.js +7 -12
- package/dist/test.d.ts +3 -3
- package/dist/test.d.ts.map +1 -1
- package/dist/test.js +2 -2
- package/dist/vitest.d.ts +1 -1
- package/examples/query.ts +46 -38
- package/package.json +46 -37
- package/src/CUPS.ts +15 -11
- package/src/Emailer/Sendgrid.ts +65 -57
- package/src/Emailer/fake.ts +2 -2
- package/src/Emailer/service.ts +13 -3
- package/src/MainFiberSet.ts +12 -10
- package/src/Model/Repository/Registry.ts +34 -0
- package/src/Model/Repository/ext.ts +103 -11
- package/src/Model/Repository/internal/internal.ts +266 -151
- package/src/Model/Repository/legacy.ts +3 -1
- package/src/Model/Repository/makeRepo.ts +15 -10
- package/src/Model/Repository/service.ts +35 -23
- package/src/Model/Repository/validation.ts +5 -5
- package/src/Model/Repository.ts +1 -0
- package/src/Model/dsl.ts +5 -4
- package/src/Model/filter/types/path/eager.ts +1 -2
- package/src/Model/filter/types.ts +4 -4
- package/src/Model/query/dsl.ts +456 -20
- package/src/Model/query/new-kid-interpreter.ts +281 -7
- package/src/Model.ts +1 -0
- package/src/QueueMaker/SQLQueue.ts +150 -153
- package/src/QueueMaker/errors.ts +3 -1
- package/src/QueueMaker/memQueue.ts +111 -105
- package/src/QueueMaker/sbqueue.ts +76 -88
- package/src/QueueMaker/service.ts +3 -1
- package/src/RequestContext.ts +15 -16
- package/src/RequestFiberSet.ts +12 -7
- package/src/Store/ContextMapContainer.ts +46 -3
- package/src/Store/Cosmos/query.ts +214 -50
- package/src/Store/Cosmos.ts +491 -350
- package/src/Store/Disk.ts +106 -66
- package/src/Store/Memory.ts +365 -91
- package/src/Store/SQL/Pg.ts +364 -0
- package/src/Store/SQL/query.ts +603 -0
- package/src/Store/SQL.ts +736 -0
- package/src/Store/codeFilter.ts +5 -2
- package/src/Store/index.ts +20 -3
- package/src/Store/service.ts +60 -11
- package/src/Store/utils.ts +25 -23
- package/src/adapters/SQL/Model.ts +42 -41
- package/src/adapters/ServiceBus.ts +131 -121
- package/src/adapters/cosmos-client.ts +5 -3
- package/src/adapters/index.ts +7 -0
- package/src/adapters/memQueue.ts +5 -4
- package/src/adapters/mongo-client.ts +4 -2
- package/src/adapters/redis-client.ts +6 -2
- package/src/api/ContextProvider.ts +19 -16
- package/src/api/internal/RequestContextMiddleware.ts +24 -6
- package/src/api/internal/auth.ts +248 -44
- package/src/api/internal/events.ts +21 -12
- package/src/api/layerUtils.ts +13 -9
- package/src/api/reportError.ts +2 -1
- package/src/api/routing/middleware/RouterMiddleware.ts +5 -4
- package/src/api/routing/middleware/middleware.ts +60 -15
- package/src/api/routing/middleware.ts +2 -4
- package/src/api/routing/schema/jwt.ts +2 -1
- package/src/api/routing/utils.ts +2 -1
- package/src/api/routing.ts +309 -139
- package/src/api/setupRequest.ts +63 -12
- package/src/arbs.ts +5 -3
- package/src/errorReporter.ts +65 -75
- package/src/fileUtil.ts +1 -1
- package/src/logger/jsonLogger.ts +3 -1
- package/src/logger/logFmtLogger.ts +1 -1
- package/src/logger/shared.ts +3 -2
- package/src/otel.ts +152 -0
- package/src/rateLimit.ts +34 -23
- package/src/test.ts +2 -2
- package/test/auth.test.ts +101 -0
- package/test/contextProvider.test.ts +14 -11
- package/test/controller.test.ts +25 -29
- package/test/cosmos-query.test.ts +159 -0
- package/test/dist/auth.test.d.ts.map +1 -0
- package/test/dist/contextProvider.test.d.ts.map +1 -1
- package/test/dist/controller.test.d.ts.map +1 -1
- package/test/dist/cosmos-query.test.d.ts.map +1 -0
- package/test/dist/date-query.test.d.ts.map +1 -0
- package/test/dist/fixtures.d.ts +30 -12
- package/test/dist/fixtures.d.ts.map +1 -1
- package/test/dist/fixtures.js +17 -10
- package/test/dist/query.test.d.ts.map +1 -1
- package/test/dist/rawQuery.test.d.ts.map +1 -1
- package/test/dist/repository-ext.test.d.ts.map +1 -0
- package/test/dist/requires.test.d.ts.map +1 -1
- package/test/dist/router-generator.test.d.ts.map +1 -0
- package/test/dist/routing-interruptibility.test.d.ts.map +1 -0
- package/test/dist/rpc-context-map-streaming.test.d.ts.map +1 -0
- package/test/dist/rpc-e2e-invalidation.test.d.ts.map +1 -0
- package/test/dist/rpc-multi-middleware.test.d.ts.map +1 -1
- package/test/dist/rpc-stream-fullstack.test.d.ts.map +1 -0
- package/test/dist/sql-store.test.d.ts.map +1 -0
- package/test/fixtures.ts +16 -9
- package/test/layerUtils.test.ts +1 -1
- package/test/query.test.ts +901 -38
- package/test/rawQuery.test.ts +338 -20
- package/test/repository-ext.test.ts +62 -0
- package/test/requires.test.ts +10 -5
- package/test/router-generator.test.ts +187 -0
- package/test/routing-interruptibility.test.ts +66 -0
- package/test/rpc-context-map-streaming.test.ts +262 -0
- package/test/rpc-e2e-invalidation.test.ts +256 -0
- package/test/rpc-multi-middleware.test.ts +84 -9
- package/test/rpc-stream-fullstack.test.ts +304 -0
- package/test/sql-store.test.ts +1711 -0
- package/test/validateSample.test.ts +17 -12
- package/tsconfig.examples.json +1 -1
- package/tsconfig.json +2 -1
- package/tsconfig.json.bak +2 -2
- package/tsconfig.src.json +35 -35
- package/tsconfig.test.json +2 -2
- package/dist/Operations.d.ts +0 -55
- package/dist/Operations.d.ts.map +0 -1
- package/dist/Operations.js +0 -102
- package/dist/OperationsRepo.d.ts +0 -41
- package/dist/OperationsRepo.d.ts.map +0 -1
- package/dist/OperationsRepo.js +0 -14
- package/eslint.config.mjs +0 -24
- package/src/Operations.ts +0 -235
- package/src/OperationsRepo.ts +0 -16
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
|
|
3
|
+
import * as Array from "effect-app/Array"
|
|
4
|
+
import type { NonEmptyReadonlyArray } from "effect-app/Array"
|
|
5
5
|
import { toNonEmptyArray } from "effect-app/Array"
|
|
6
|
+
import * as Chunk from "effect-app/Chunk"
|
|
6
7
|
import { NotFoundError } from "effect-app/client/errors"
|
|
8
|
+
import * as Context from "effect-app/Context"
|
|
9
|
+
import * as Effect from "effect-app/Effect"
|
|
7
10
|
import { flatMapOption } from "effect-app/Effect"
|
|
11
|
+
import * as Option from "effect-app/Option"
|
|
12
|
+
import * as S from "effect-app/Schema"
|
|
8
13
|
import { type Codec, NonNegativeInt } from "effect-app/Schema"
|
|
14
|
+
import * as Equivalence from "effect/Equivalence"
|
|
15
|
+
import { flow, pipe } from "effect/Function"
|
|
16
|
+
import * as Pipeable from "effect/Pipeable"
|
|
17
|
+
import * as PubSub from "effect/PubSub"
|
|
18
|
+
import * as Result from "effect/Result"
|
|
19
|
+
import * as SchemaAST from "effect/SchemaAST"
|
|
20
|
+
import * as Unify from "effect/Unify"
|
|
9
21
|
import { setupRequestContextFromCurrent } from "../../../api/setupRequest.js"
|
|
10
22
|
import { type FilterArgs, type PersistenceModelType, type StoreConfig, StoreMaker } from "../../../Store.js"
|
|
11
23
|
import { getContextMap } from "../../../Store/ContextMapContainer.js"
|
|
@@ -55,14 +67,14 @@ export function makeRepoInternal<
|
|
|
55
67
|
|
|
56
68
|
function make<RInitial = never, E = never, RPublish = never, RCtx = never>(
|
|
57
69
|
args: [Evt] extends [never] ? {
|
|
58
|
-
schemaContext?:
|
|
70
|
+
schemaContext?: Context.Context<RCtx>
|
|
59
71
|
makeInitial?: Effect.Effect<readonly T[], E, RInitial> | undefined
|
|
60
72
|
config?: Omit<StoreConfig<Encoded>, "partitionValue"> & {
|
|
61
73
|
partitionValue?: (e?: Encoded) => string
|
|
62
74
|
}
|
|
63
75
|
}
|
|
64
76
|
: {
|
|
65
|
-
schemaContext?:
|
|
77
|
+
schemaContext?: Context.Context<RCtx>
|
|
66
78
|
publishEvents: (evt: NonEmptyReadonlyArray<Evt>) => Effect.Effect<void, never, RPublish>
|
|
67
79
|
makeInitial?: Effect.Effect<readonly T[], E, RInitial> | undefined
|
|
68
80
|
config?: Omit<StoreConfig<Encoded>, "partitionValue"> & {
|
|
@@ -72,16 +84,16 @@ export function makeRepoInternal<
|
|
|
72
84
|
) {
|
|
73
85
|
return Effect
|
|
74
86
|
.gen(function*() {
|
|
75
|
-
const rctx:
|
|
87
|
+
const rctx: Context.Context<RCtx> = args.schemaContext ?? Context.empty() as any
|
|
76
88
|
const provideRctx = Effect.provide(rctx)
|
|
77
89
|
const encodeMany = flow(
|
|
78
90
|
S.encodeEffect(S.Array(schema)),
|
|
79
91
|
provideRctx,
|
|
80
|
-
Effect.withSpan("encodeMany", {}, { captureStackTrace: false })
|
|
92
|
+
Effect.withSpan("encodeMany", { attributes: { "app.entity": name } }, { captureStackTrace: false })
|
|
81
93
|
)
|
|
82
|
-
const decode = flow(S.
|
|
94
|
+
const decode = flow(S.decodeEffectConcurrently(schema), provideRctx)
|
|
83
95
|
const decodeMany = flow(
|
|
84
|
-
S.
|
|
96
|
+
S.decodeEffectConcurrently(S.Array(schema)),
|
|
85
97
|
provideRctx
|
|
86
98
|
)
|
|
87
99
|
|
|
@@ -104,7 +116,13 @@ export function makeRepoInternal<
|
|
|
104
116
|
allE,
|
|
105
117
|
(_) => decodeMany(_).pipe(Effect.orDie)
|
|
106
118
|
)
|
|
107
|
-
.pipe(
|
|
119
|
+
.pipe(
|
|
120
|
+
Effect.map((_) => _ as T[]),
|
|
121
|
+
Effect.withSpan("Repository.all", {
|
|
122
|
+
kind: "client",
|
|
123
|
+
attributes: { "app.entity": name }
|
|
124
|
+
}, { captureStackTrace: false })
|
|
125
|
+
)
|
|
108
126
|
|
|
109
127
|
const fieldsSchema = schema as unknown as { fields: any }
|
|
110
128
|
// assumes the id field never needs a service...
|
|
@@ -113,11 +131,14 @@ export function makeRepoInternal<
|
|
|
113
131
|
let ast = _.ast
|
|
114
132
|
if (ast._tag === "Declaration") ast = ast.typeParameters[0]!
|
|
115
133
|
|
|
116
|
-
// In v4, to get the encoded (from) side of a schema, use SchemaAST.toEncoded
|
|
117
134
|
const pickIdFromAst = (a: SchemaAST.AST) => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
135
|
+
// Unwrap Declaration (e.g. TaggedClass) to get the underlying Objects AST
|
|
136
|
+
let inner = a
|
|
137
|
+
if (inner._tag === "Declaration") inner = inner.typeParameters[0]!
|
|
138
|
+
// Pick from the original AST to preserve the full encoding chain (e.g. decodeTo transformations).
|
|
139
|
+
// Using toEncoded would lose transformation info needed to encode Type -> Encoded.
|
|
140
|
+
if (SchemaAST.isObjects(inner)) {
|
|
141
|
+
const field = inner.propertySignatures.find((_) => _.name === idKey)
|
|
121
142
|
if (field) {
|
|
122
143
|
return S.Struct({ [idKey]: S.make(field.type) }) as unknown as Codec<T, Encoded>
|
|
123
144
|
}
|
|
@@ -138,7 +159,7 @@ export function makeRepoInternal<
|
|
|
138
159
|
Effect.map((_: Record<string, unknown>) => _[idKey as string] as Encoded[IdKey])
|
|
139
160
|
)
|
|
140
161
|
const findEId = Effect.fnUntraced(function*(id: Encoded[IdKey]) {
|
|
141
|
-
yield* Effect.annotateCurrentSpan({
|
|
162
|
+
yield* Effect.annotateCurrentSpan({ "app.entity.id": id })
|
|
142
163
|
|
|
143
164
|
return yield* Effect.flatMap(
|
|
144
165
|
store.find(id),
|
|
@@ -151,7 +172,7 @@ export function makeRepoInternal<
|
|
|
151
172
|
})
|
|
152
173
|
// TODO: select the particular field, instead of as struct
|
|
153
174
|
const findE = Effect.fnUntraced(function*(id: T[IdKey]) {
|
|
154
|
-
yield* Effect.annotateCurrentSpan({
|
|
175
|
+
yield* Effect.annotateCurrentSpan({ "app.entity.id": id })
|
|
155
176
|
|
|
156
177
|
return yield* pipe(
|
|
157
178
|
encodeId({ [idKey]: id } as any),
|
|
@@ -161,9 +182,11 @@ export function makeRepoInternal<
|
|
|
161
182
|
)
|
|
162
183
|
})
|
|
163
184
|
|
|
164
|
-
const find = Effect.fn("find"
|
|
165
|
-
|
|
166
|
-
|
|
185
|
+
const find = Effect.fn("Repository.find", {
|
|
186
|
+
kind: "client",
|
|
187
|
+
attributes: { "app.entity": name }
|
|
188
|
+
})(function*(id: T[IdKey]) {
|
|
189
|
+
yield* Effect.annotateCurrentSpan({ "app.entity.id": id })
|
|
167
190
|
return yield* flatMapOption(findE(id), (_) => Effect.orDie(decode(_)))
|
|
168
191
|
})
|
|
169
192
|
|
|
@@ -188,73 +211,100 @@ export function makeRepoInternal<
|
|
|
188
211
|
Effect.andThen(saveAllE)
|
|
189
212
|
)
|
|
190
213
|
|
|
191
|
-
const saveAndPublish = Effect.fn("saveAndPublish"
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
214
|
+
const saveAndPublish = Effect.fn("Repository.saveAndPublish", { attributes: { "app.entity": name } })(
|
|
215
|
+
function*(items: Iterable<T>, events: Iterable<Evt> = []) {
|
|
216
|
+
const it = Chunk.fromIterable(items)
|
|
217
|
+
const evts = [...events]
|
|
218
|
+
yield* Effect.annotateCurrentSpan({
|
|
219
|
+
"app.entity.ids": Chunk.map(it, (_) => _[idKey]),
|
|
220
|
+
"app.event.count": evts.length
|
|
221
|
+
})
|
|
222
|
+
return yield* saveAll(it)
|
|
223
|
+
.pipe(
|
|
224
|
+
Effect.andThen(Effect.sync(() => toNonEmptyArray(evts))),
|
|
225
|
+
// TODO: for full consistency the events should be stored within the same database transaction, and then picked up.
|
|
226
|
+
(_) => flatMapOption(_, pub),
|
|
227
|
+
Effect.andThen(PubSub.publish(changeFeed, [Chunk.toArray(it), "save"] as [T[], "save" | "remove"])),
|
|
228
|
+
Effect.asVoid
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
)
|
|
204
232
|
|
|
205
|
-
const removeAndPublish = Effect.fn("removeAndPublish"
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
)
|
|
216
|
-
|
|
217
|
-
|
|
233
|
+
const removeAndPublish = Effect.fn("Repository.removeAndPublish", { attributes: { "app.entity": name } })(
|
|
234
|
+
function*(a: Iterable<T>, events: Iterable<Evt> = []) {
|
|
235
|
+
const { set } = yield* cms
|
|
236
|
+
const it = [...a]
|
|
237
|
+
const evts = [...events]
|
|
238
|
+
yield* Effect.annotateCurrentSpan({
|
|
239
|
+
"app.entity.ids": it.map((_) => _[idKey]),
|
|
240
|
+
"app.event.count": evts.length
|
|
241
|
+
})
|
|
242
|
+
const items = yield* encodeMany(it).pipe(Effect.orDie)
|
|
243
|
+
if (Array.isReadonlyArrayNonEmpty(items)) {
|
|
244
|
+
yield* store.batchRemove(
|
|
245
|
+
items.map((_) => (_[idKey])),
|
|
246
|
+
args.config?.partitionValue?.(items[0])
|
|
247
|
+
)
|
|
248
|
+
for (const e of items) {
|
|
249
|
+
set(e[idKey], undefined)
|
|
250
|
+
}
|
|
251
|
+
yield* Effect
|
|
252
|
+
.sync(() => toNonEmptyArray(evts))
|
|
253
|
+
// TODO: for full consistency the events should be stored within the same database transaction, and then picked up.
|
|
254
|
+
.pipe((_) => flatMapOption(_, pub))
|
|
255
|
+
|
|
256
|
+
yield* PubSub.publish(changeFeed, [it, "remove"] as [T[], "save" | "remove"])
|
|
218
257
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
// TODO: for full consistency the events should be stored within the same database transaction, and then picked up.
|
|
222
|
-
.pipe((_) => flatMapOption(_, pub))
|
|
258
|
+
}
|
|
259
|
+
)
|
|
223
260
|
|
|
224
|
-
|
|
261
|
+
const removeById = Effect.fn("Repository.removeById", { attributes: { "app.entity": name } })(
|
|
262
|
+
function*(idOrIds: T[IdKey] | ReadonlyArray<T[IdKey]>) {
|
|
263
|
+
const ids = globalThis.Array.isArray(idOrIds)
|
|
264
|
+
? idOrIds as readonly T[IdKey][]
|
|
265
|
+
: [idOrIds as T[IdKey]]
|
|
266
|
+
if (!Array.isReadonlyArrayNonEmpty(ids)) {
|
|
267
|
+
return
|
|
268
|
+
}
|
|
269
|
+
const { set } = yield* cms
|
|
270
|
+
const eids = yield* Effect.forEach(ids, (_) => encodeIdOnly(_ as any)).pipe(Effect.orDie)
|
|
271
|
+
yield* Effect.annotateCurrentSpan({ "app.entity.ids": eids })
|
|
272
|
+
yield* store.batchRemove(eids)
|
|
273
|
+
for (const id of eids) {
|
|
274
|
+
set(id, undefined)
|
|
275
|
+
}
|
|
276
|
+
yield* PubSub.publish(changeFeed, [[], "remove"] as [T[], "save" | "remove"])
|
|
225
277
|
}
|
|
226
|
-
|
|
278
|
+
)
|
|
227
279
|
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
280
|
+
const parseMany = Effect.fn("parseMany", {
|
|
281
|
+
attributes: { "app.entity": name, "app.query.mode": "transform" }
|
|
282
|
+
})(
|
|
283
|
+
function*(items: readonly PM[]) {
|
|
284
|
+
const cm = yield* cms
|
|
285
|
+
return yield* decodeMany(items.map((_) => mapReverse(_, cm.set))).pipe(Effect.orDie)
|
|
231
286
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
287
|
+
)
|
|
288
|
+
const decodeManyCache = new WeakMap<
|
|
289
|
+
S.Codec<any, any, any>,
|
|
290
|
+
(i: readonly any[]) => Effect.Effect<any, any, any>
|
|
291
|
+
>()
|
|
292
|
+
const getDecodeMany = (s: S.Codec<any, Encoded, any>) => {
|
|
293
|
+
let dec = decodeManyCache.get(s)
|
|
294
|
+
if (!dec) {
|
|
295
|
+
dec = S.decodeEffectConcurrently(S.Array(s))
|
|
296
|
+
decodeManyCache.set(s, dec)
|
|
238
297
|
}
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
schema: S.Codec<A, Encoded, R>
|
|
250
|
-
) =>
|
|
251
|
-
Effect
|
|
252
|
-
.flatMap(cms, (cm) =>
|
|
253
|
-
S
|
|
254
|
-
.decodeEffect(S.Array(schema))(
|
|
255
|
-
items.map((_) => mapReverse(_, cm.set))
|
|
256
|
-
)
|
|
257
|
-
.pipe(Effect.orDie, Effect.withSpan("parseMany2", {}, { captureStackTrace: false })))
|
|
298
|
+
return dec
|
|
299
|
+
}
|
|
300
|
+
const parseMany2 = Effect.fn("parseMany", {
|
|
301
|
+
attributes: { "app.entity": name, "app.query.mode": "transform" }
|
|
302
|
+
})(
|
|
303
|
+
function*<A, R>(items: readonly PM[], schema: S.Codec<A, Encoded, R>) {
|
|
304
|
+
const cm = yield* cms
|
|
305
|
+
return yield* getDecodeMany(schema)(items.map((_) => mapReverse(_, cm.set))).pipe(Effect.orDie)
|
|
306
|
+
}
|
|
307
|
+
)
|
|
258
308
|
const filter = <U extends keyof Encoded = keyof Encoded>(args: FilterArgs<Encoded, U>) =>
|
|
259
309
|
store
|
|
260
310
|
.filter(
|
|
@@ -276,26 +326,59 @@ export function makeRepoInternal<
|
|
|
276
326
|
const query: {
|
|
277
327
|
<A, R, From extends FieldValues>(
|
|
278
328
|
q: Q.QueryProjection<Encoded extends From ? From : never, A, R>
|
|
279
|
-
): Effect.Effect<readonly A[], S.SchemaError, R
|
|
329
|
+
): Effect.Effect<readonly A[], S.SchemaError, Exclude<R, RCtx>>
|
|
280
330
|
<A, R, EncodedRefined extends Encoded = Encoded>(
|
|
281
331
|
q: Q.QAll<NoInfer<Encoded>, NoInfer<EncodedRefined>, A, R>
|
|
282
|
-
): Effect.Effect<readonly A[], never, R
|
|
332
|
+
): Effect.Effect<readonly A[], never, Exclude<R, RCtx>>
|
|
283
333
|
} = (<A, R, EncodedRefined extends Encoded = Encoded>(q: Q.QAll<Encoded, EncodedRefined, A, R>) => {
|
|
284
|
-
const a = Q.toFilter(q)
|
|
285
|
-
|
|
334
|
+
const a = Q.toFilter(q, schema)
|
|
335
|
+
// Mode dispatch — see `Q.project` JSDoc for the contract:
|
|
336
|
+
// aggregate: GROUP BY + aggregate functions at DB level; decode raw rows with schema; SchemaError surfaces.
|
|
337
|
+
// project : decode raw encoded rows with schema; no PM reverse-mapping; SchemaError surfaces.
|
|
338
|
+
// collect : same as project, but schema yields Option and None rows are dropped.
|
|
339
|
+
// transform: PM reverse-map (re-inject _etag/PM state from cms cache) then decode; orDie.
|
|
340
|
+
const eff = a.mode === "aggregate"
|
|
341
|
+
? store
|
|
342
|
+
// `a.select` contains `{ key, aggregate }` items not expressible in FilterFunc<Encoded, U>'s
|
|
343
|
+
// `U extends keyof Encoded` generic. Cast is unavoidable until FilterFunc supports aggregate mode.
|
|
344
|
+
.filter(a as any)
|
|
345
|
+
// Decode raw aggregate rows directly — no PM reverse-mapping, no id/_etag needed.
|
|
346
|
+
.pipe(
|
|
347
|
+
Effect.andThen(
|
|
348
|
+
flow(
|
|
349
|
+
S.decodeEffectConcurrently(S.Array(a.schema ?? schema)),
|
|
350
|
+
provideRctx,
|
|
351
|
+
Effect.withSpan("parseMany", {
|
|
352
|
+
attributes: { "app.entity": name, "app.query.mode": "aggregate" }
|
|
353
|
+
})
|
|
354
|
+
)
|
|
355
|
+
)
|
|
356
|
+
)
|
|
357
|
+
: a.mode === "project"
|
|
286
358
|
? filter(a)
|
|
287
359
|
// TODO: mapFrom but need to support per field and dependencies
|
|
288
360
|
.pipe(
|
|
289
|
-
Effect.andThen(
|
|
361
|
+
Effect.andThen(
|
|
362
|
+
flow(
|
|
363
|
+
S.decodeEffectConcurrently(S.Array(a.schema ?? schema)),
|
|
364
|
+
provideRctx,
|
|
365
|
+
Effect.withSpan("parseMany", {
|
|
366
|
+
attributes: { "app.entity": name, "app.query.mode": "project" }
|
|
367
|
+
})
|
|
368
|
+
)
|
|
369
|
+
)
|
|
290
370
|
)
|
|
291
371
|
: a.mode === "collect"
|
|
292
372
|
? filter(a)
|
|
293
373
|
// TODO: mapFrom but need to support per field and dependencies
|
|
294
374
|
.pipe(
|
|
295
375
|
Effect.flatMap(flow(
|
|
296
|
-
S.
|
|
376
|
+
S.decodeEffectConcurrently(S.Array(a.schema)),
|
|
297
377
|
Effect.map(Array.getSomes),
|
|
298
|
-
provideRctx
|
|
378
|
+
provideRctx,
|
|
379
|
+
Effect.withSpan("parseMany", {
|
|
380
|
+
attributes: { "app.entity": name, "app.query.mode": "collect" }
|
|
381
|
+
})
|
|
299
382
|
))
|
|
300
383
|
)
|
|
301
384
|
: Effect.flatMap(
|
|
@@ -325,72 +408,89 @@ export function makeRepoInternal<
|
|
|
325
408
|
.map(eff, (_) => NonNegativeInt(_.length))
|
|
326
409
|
.pipe(Effect.catchTag("SchemaError", (e) => Effect.die(e)))
|
|
327
410
|
: eff,
|
|
328
|
-
Effect.
|
|
329
|
-
|
|
330
|
-
"
|
|
331
|
-
query
|
|
332
|
-
|
|
411
|
+
Effect.tap((r) =>
|
|
412
|
+
Effect.annotateCurrentSpan({
|
|
413
|
+
"app.query.ttype": a.ttype,
|
|
414
|
+
"app.query.mode": a.mode,
|
|
415
|
+
"db.response.returned_rows": Array.isArray(r) ? r.length : 1
|
|
416
|
+
})
|
|
417
|
+
),
|
|
418
|
+
Effect.withSpan("Repository.query", {
|
|
419
|
+
kind: "client",
|
|
420
|
+
attributes: { "app.entity": name }
|
|
333
421
|
}, { captureStackTrace: false })
|
|
334
422
|
)
|
|
335
423
|
}) as any
|
|
336
424
|
|
|
337
|
-
const validateSample = Effect.fn("validateSample")(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
425
|
+
const validateSample = Effect.fn("Repository.validateSample", { attributes: { "app.entity": name } })(
|
|
426
|
+
function*(options?: {
|
|
427
|
+
percentage?: number
|
|
428
|
+
maxItems?: number
|
|
429
|
+
}) {
|
|
430
|
+
const percentage = options?.percentage ?? 0.1 // default 10%
|
|
431
|
+
const maxItems = options?.maxItems
|
|
432
|
+
|
|
433
|
+
// 1. get all IDs with projection (bypasses main schema decode)
|
|
434
|
+
const allIds = yield* store
|
|
435
|
+
.filter({
|
|
436
|
+
t: null as unknown as Encoded,
|
|
437
|
+
select: [idKey as keyof Encoded]
|
|
438
|
+
})
|
|
439
|
+
.pipe(Effect.withSpan("Repository.filter", {
|
|
440
|
+
kind: "client",
|
|
441
|
+
attributes: { "app.entity": name }
|
|
442
|
+
}, { captureStackTrace: false }))
|
|
443
|
+
|
|
444
|
+
// 2. random subset
|
|
445
|
+
const shuffled = [...allIds].sort(() => Math.random() - 0.5)
|
|
446
|
+
const sampleSize = Math.min(
|
|
447
|
+
maxItems ?? Infinity,
|
|
448
|
+
Math.ceil(allIds.length * percentage)
|
|
449
|
+
)
|
|
450
|
+
const sample = shuffled.slice(0, sampleSize)
|
|
451
|
+
|
|
452
|
+
// 3. validate each item
|
|
453
|
+
const errors: ValidationError[] = []
|
|
454
|
+
|
|
455
|
+
for (const item of sample) {
|
|
456
|
+
const id = item[idKey]
|
|
457
|
+
const rawResult = yield* store.find(id).pipe(
|
|
458
|
+
Effect.withSpan("Repository.find", {
|
|
459
|
+
kind: "client",
|
|
460
|
+
attributes: { "app.entity": name, "app.entity.id": id }
|
|
461
|
+
}, { captureStackTrace: false })
|
|
462
|
+
)
|
|
366
463
|
|
|
367
|
-
|
|
368
|
-
const jitMResult = mapFrom(rawData) // apply jitM
|
|
464
|
+
if (Option.isNone(rawResult)) continue
|
|
369
465
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
provideRctx
|
|
373
|
-
)
|
|
466
|
+
const rawData = rawResult.value as Encoded
|
|
467
|
+
const jitMResult = mapFrom(rawData) // apply jitM
|
|
374
468
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
id,
|
|
379
|
-
rawData,
|
|
380
|
-
jitMResult,
|
|
381
|
-
error: decodeResult.failure
|
|
382
|
-
})
|
|
469
|
+
const decodeResult = yield* S.decodeEffectConcurrently(schema)(jitMResult).pipe(
|
|
470
|
+
Effect.result,
|
|
471
|
+
provideRctx
|
|
383
472
|
)
|
|
473
|
+
|
|
474
|
+
if (Result.isFailure(decodeResult)) {
|
|
475
|
+
errors.push(
|
|
476
|
+
ValidationError.make({
|
|
477
|
+
id,
|
|
478
|
+
rawData,
|
|
479
|
+
jitMResult,
|
|
480
|
+
error: decodeResult.failure
|
|
481
|
+
})
|
|
482
|
+
)
|
|
483
|
+
}
|
|
384
484
|
}
|
|
385
|
-
}
|
|
386
485
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
486
|
+
return ValidationResult.make({
|
|
487
|
+
total: NonNegativeInt(allIds.length),
|
|
488
|
+
sampled: NonNegativeInt(sample.length),
|
|
489
|
+
valid: NonNegativeInt(sample.length - errors.length),
|
|
490
|
+
errors
|
|
491
|
+
})
|
|
492
|
+
}
|
|
493
|
+
)
|
|
394
494
|
|
|
395
495
|
const r = {
|
|
396
496
|
changeFeed,
|
|
@@ -401,10 +501,17 @@ export function makeRepoInternal<
|
|
|
401
501
|
saveAndPublish,
|
|
402
502
|
removeAndPublish,
|
|
403
503
|
removeById,
|
|
504
|
+
seedNamespace: (namespace: string) => store.seedNamespace(namespace),
|
|
404
505
|
validateSample,
|
|
405
506
|
queryRaw<A, Out, QR>(schema: S.Codec<A, Out, QR>, q: Q.RawQuery<Encoded, Out>) {
|
|
406
|
-
const dec = S.
|
|
407
|
-
return store.queryRaw(q).pipe(
|
|
507
|
+
const dec = S.decodeEffectConcurrently(S.Array(schema))
|
|
508
|
+
return store.queryRaw(q).pipe(
|
|
509
|
+
Effect.flatMap(dec),
|
|
510
|
+
Effect.withSpan("Repository.queryRaw", {
|
|
511
|
+
kind: "client",
|
|
512
|
+
attributes: { "app.entity": name }
|
|
513
|
+
}, { captureStackTrace: false })
|
|
514
|
+
)
|
|
408
515
|
},
|
|
409
516
|
query(q: any) {
|
|
410
517
|
// eslint-disable-next-line prefer-rest-params
|
|
@@ -414,15 +521,23 @@ export function makeRepoInternal<
|
|
|
414
521
|
* @internal
|
|
415
522
|
*/
|
|
416
523
|
mapped: <A, R>(schema: S.Codec<A, any, R>) => {
|
|
417
|
-
const dec = S.
|
|
524
|
+
const dec = S.decodeEffectConcurrently(schema)
|
|
418
525
|
const encMany = S.encodeEffect(S.Array(schema))
|
|
419
|
-
const decMany = S.
|
|
526
|
+
const decMany = S.decodeEffectConcurrently(S.Array(schema))
|
|
527
|
+
const spanAttrs = { kind: "client" as const, attributes: { "app.entity": name } }
|
|
420
528
|
return {
|
|
421
529
|
all: allE.pipe(
|
|
422
530
|
Effect.flatMap(decMany),
|
|
423
|
-
Effect.map((_) => _ as any[])
|
|
531
|
+
Effect.map((_) => _ as any[]),
|
|
532
|
+
Effect.withSpan("Repository.mapped.all", spanAttrs, { captureStackTrace: false })
|
|
424
533
|
),
|
|
425
|
-
find: (id: T[IdKey]) =>
|
|
534
|
+
find: (id: T[IdKey]) =>
|
|
535
|
+
flatMapOption(findE(id), dec).pipe(
|
|
536
|
+
Effect.withSpan("Repository.mapped.find", {
|
|
537
|
+
...spanAttrs,
|
|
538
|
+
attributes: { ...spanAttrs.attributes, "app.entity.id": id }
|
|
539
|
+
}, { captureStackTrace: false })
|
|
540
|
+
),
|
|
426
541
|
// query: (q: any) => {
|
|
427
542
|
// const a = Q.toFilter(q)
|
|
428
543
|
|
|
@@ -441,12 +556,12 @@ export function makeRepoInternal<
|
|
|
441
556
|
// },
|
|
442
557
|
save: (...xes: any[]) =>
|
|
443
558
|
Effect.flatMap(encMany(xes), (_) => saveAllE(_)).pipe(
|
|
444
|
-
Effect.withSpan("mapped.save",
|
|
559
|
+
Effect.withSpan("Repository.mapped.save", spanAttrs, { captureStackTrace: false })
|
|
445
560
|
)
|
|
446
561
|
}
|
|
447
562
|
}
|
|
448
563
|
}
|
|
449
|
-
return r as Repository<T, Encoded, Evt, ItemType, IdKey, Exclude<R, RCtx>, RPublish>
|
|
564
|
+
return r as Repository<T, Encoded, Evt, ItemType, IdKey, Exclude<R, RCtx>, RPublish, RCtx>
|
|
450
565
|
})
|
|
451
566
|
.pipe(Effect
|
|
452
567
|
// .withSpan("Repository.make [effect-app/infra]", { attributes: { "repository.model_name": name } })
|
|
@@ -513,7 +628,7 @@ export function makeStore<Encoded extends FieldValues>() {
|
|
|
513
628
|
.pipe(
|
|
514
629
|
Effect.flatMap(Effect.forEach(encodeToEncoded())),
|
|
515
630
|
setupRequestContextFromCurrent("Repository.makeInitial [effect-app/infra]", {
|
|
516
|
-
attributes: { "
|
|
631
|
+
attributes: { "app.entity": name }
|
|
517
632
|
})
|
|
518
633
|
)
|
|
519
634
|
: undefined,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
3
|
-
import type { Effect, Option, S } from "effect-app"
|
|
4
3
|
import type { OptimisticConcurrencyException } from "effect-app/client/errors"
|
|
4
|
+
import type * as Effect from "effect-app/Effect"
|
|
5
|
+
import type * as Option from "effect-app/Option"
|
|
6
|
+
import type * as S from "effect-app/Schema"
|
|
5
7
|
|
|
6
8
|
export interface Mapped1<A, IdKey extends keyof A, R> {
|
|
7
9
|
all: Effect.Effect<A[], S.SchemaError, R>
|