@effect-app/infra 4.0.0-beta.247 → 4.0.0-beta.249
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 +24 -0
- package/dist/ContextProvider.d.ts +34 -0
- package/dist/ContextProvider.d.ts.map +1 -0
- package/dist/ContextProvider.js +40 -0
- package/dist/Emailer/Sendgrid.d.ts +109 -145
- package/dist/Emailer/Sendgrid.d.ts.map +1 -1
- package/dist/Emailer/Sendgrid.js +4 -3
- package/dist/Emailer/fake.d.ts +2 -2
- package/dist/Emailer/fake.d.ts.map +1 -1
- package/dist/Emailer/fake.js +2 -2
- package/dist/QueueMaker/SQLQueue.d.ts +2 -2
- package/dist/QueueMaker/SQLQueue.d.ts.map +1 -1
- package/dist/QueueMaker/SQLQueue.js +4 -4
- package/dist/QueueMaker/memQueue.d.ts +2 -2
- package/dist/QueueMaker/memQueue.d.ts.map +1 -1
- package/dist/QueueMaker/memQueue.js +4 -4
- package/dist/QueueMaker/sbqueue.d.ts +2 -2
- package/dist/QueueMaker/sbqueue.d.ts.map +1 -1
- package/dist/QueueMaker/sbqueue.js +4 -4
- package/dist/RequestFiberSet.js +2 -2
- package/dist/{adapters/SQL → SQL}/Model.d.ts +2 -2
- package/dist/SQL/Model.d.ts.map +1 -0
- package/dist/SQL/Model.js +469 -0
- package/dist/{adapters/SQL.d.ts → SQL.d.ts} +1 -1
- package/dist/SQL.d.ts.map +1 -0
- package/dist/{adapters/SQL.js → SQL.js} +1 -1
- package/dist/{adapters/ServiceBus.d.ts → ServiceBus.d.ts} +1 -1
- package/dist/ServiceBus.d.ts.map +1 -0
- package/dist/ServiceBus.js +108 -0
- package/dist/Store/ContextMapContainer.d.ts +2 -2
- package/dist/Store/ContextMapContainer.d.ts.map +1 -1
- package/dist/Store/ContextMapContainer.js +2 -2
- package/dist/Store/Cosmos/query.d.ts +4 -4
- package/dist/Store/Cosmos/query.d.ts.map +1 -1
- package/dist/Store/Cosmos/query.js +1 -1
- package/dist/Store/Cosmos.d.ts +2 -2
- package/dist/Store/Cosmos.d.ts.map +1 -1
- package/dist/Store/Cosmos.js +3 -3
- package/dist/Store/Disk.d.ts +3 -3
- package/dist/Store/Disk.d.ts.map +1 -1
- package/dist/Store/Disk.js +2 -2
- package/dist/Store/Memory.d.ts +3 -3
- package/dist/Store/Memory.d.ts.map +1 -1
- package/dist/Store/Memory.js +2 -2
- package/dist/Store/SQL/Pg.d.ts +2 -2
- package/dist/Store/SQL/Pg.d.ts.map +1 -1
- package/dist/Store/SQL/Pg.js +2 -2
- package/dist/Store/SQL/query.d.ts +3 -3
- package/dist/Store/SQL/query.d.ts.map +1 -1
- package/dist/Store/SQL/query.js +1 -1
- package/dist/Store/SQL.d.ts +3 -3
- package/dist/Store/SQL.d.ts.map +1 -1
- package/dist/Store/SQL.js +2 -2
- package/dist/Store/codeFilter.d.ts +4 -4
- package/dist/Store/codeFilter.d.ts.map +1 -1
- package/dist/Store/codeFilter.js +1 -1
- package/dist/Store/index.d.ts +3 -4
- package/dist/Store/index.d.ts.map +1 -1
- package/dist/Store/index.js +2 -3
- package/dist/Store/utils.d.ts +2 -2
- package/dist/Store/utils.d.ts.map +1 -1
- package/dist/Store/utils.js +1 -1
- package/dist/{api/codec.d.ts → codec.d.ts} +1 -1
- package/dist/codec.d.ts.map +1 -0
- package/dist/codec.js +5 -0
- package/dist/{adapters/cosmos-client.d.ts → cosmos-client.d.ts} +1 -1
- package/dist/cosmos-client.d.ts.map +1 -0
- package/dist/cosmos-client.js +11 -0
- package/dist/errorReporter.d.ts +1 -1
- package/dist/errorReporter.d.ts.map +1 -1
- package/dist/errorReporter.js +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/{api/internal → internal}/RequestContextMiddleware.d.ts +2 -2
- package/dist/internal/RequestContextMiddleware.d.ts.map +1 -0
- package/dist/internal/RequestContextMiddleware.js +46 -0
- package/dist/{api/internal → internal}/auth.d.ts +1 -1
- package/dist/internal/auth.d.ts.map +1 -0
- package/dist/internal/auth.js +180 -0
- package/dist/{api/internal → internal}/events.d.ts +1 -1
- package/dist/internal/events.d.ts.map +1 -0
- package/dist/internal/events.js +49 -0
- package/dist/{api/internal → internal}/health.d.ts +1 -1
- package/dist/internal/health.d.ts.map +1 -0
- package/dist/internal/health.js +5 -0
- package/dist/layerUtils.d.ts +32 -0
- package/dist/layerUtils.d.ts.map +1 -0
- package/dist/layerUtils.js +17 -0
- package/dist/logger/jsonLogger.d.ts +1 -1
- package/dist/logger/jsonLogger.d.ts.map +1 -1
- package/dist/logger/jsonLogger.js +2 -2
- package/dist/logger/logFmtLogger.d.ts +1 -1
- 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 +2 -2
- package/dist/logger.d.ts +1 -1
- package/dist/{adapters/memQueue.d.ts → memQueue.d.ts} +1 -1
- package/dist/memQueue.d.ts.map +1 -0
- package/dist/memQueue.js +21 -0
- package/dist/{api/middlewares.d.ts → middlewares.d.ts} +1 -1
- package/dist/middlewares.d.ts.map +1 -0
- package/dist/{api/middlewares.js → middlewares.js} +1 -1
- package/dist/{adapters/mongo-client.d.ts → mongo-client.d.ts} +1 -1
- package/dist/mongo-client.d.ts.map +1 -0
- package/dist/mongo-client.js +15 -0
- package/dist/{adapters/redis-client.d.ts → redis-client.d.ts} +1 -1
- package/dist/redis-client.d.ts.map +1 -0
- package/dist/redis-client.js +98 -0
- package/dist/reportError.d.ts +4 -0
- package/dist/reportError.d.ts.map +1 -0
- package/dist/reportError.js +28 -0
- package/dist/{api/routing → routing}/middleware/RouterMiddleware.d.ts +1 -1
- package/dist/routing/middleware/RouterMiddleware.d.ts.map +1 -0
- package/dist/{api/routing → routing}/middleware/RouterMiddleware.js +1 -1
- package/dist/{api/routing → routing}/middleware/middleware.d.ts +2 -2
- package/dist/routing/middleware/middleware.d.ts.map +1 -0
- package/dist/routing/middleware/middleware.js +128 -0
- package/dist/{api/routing → routing}/middleware.d.ts +1 -1
- package/dist/routing/middleware.d.ts.map +1 -0
- package/dist/{api/routing → routing}/middleware.js +1 -1
- package/dist/{api/routing → routing}/schema/jwt.d.ts +1 -1
- package/dist/routing/schema/jwt.d.ts.map +1 -0
- package/dist/routing/schema/jwt.js +13 -0
- package/dist/routing/tsort.d.ts +8 -0
- package/dist/routing/tsort.d.ts.map +1 -0
- package/dist/routing/tsort.js +51 -0
- package/dist/{api/routing → routing}/utils.d.ts +1 -1
- package/dist/routing/utils.d.ts.map +1 -0
- package/dist/routing/utils.js +45 -0
- package/dist/routing.d.ts +184 -0
- package/dist/routing.d.ts.map +1 -0
- package/dist/{api/routing.js → routing.js} +1 -1
- package/dist/{api/setupRequest.d.ts → setupRequest.d.ts} +2 -2
- package/dist/setupRequest.d.ts.map +1 -0
- package/dist/setupRequest.js +70 -0
- package/dist/{api/util.d.ts → util.d.ts} +1 -1
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +14 -0
- package/examples/query.ts +2 -2
- package/package.json +84 -200
- package/src/Emailer/Sendgrid.ts +20 -5
- package/src/Emailer/fake.ts +1 -1
- package/src/QueueMaker/SQLQueue.ts +3 -3
- package/src/QueueMaker/memQueue.ts +3 -3
- package/src/QueueMaker/sbqueue.ts +3 -3
- package/src/RequestFiberSet.ts +1 -1
- package/src/{adapters/SQL → SQL}/Model.ts +1 -1
- package/src/{adapters/ServiceBus.ts → ServiceBus.ts} +1 -1
- package/src/Store/ContextMapContainer.ts +1 -1
- package/src/Store/Cosmos/query.ts +3 -3
- package/src/Store/Cosmos.ts +4 -4
- package/src/Store/Disk.ts +2 -2
- package/src/Store/Memory.ts +4 -4
- package/src/Store/SQL/Pg.ts +3 -3
- package/src/Store/SQL/query.ts +2 -2
- package/src/Store/SQL.ts +3 -3
- package/src/Store/codeFilter.ts +3 -3
- package/src/Store/index.ts +2 -4
- package/src/Store/utils.ts +1 -1
- package/src/errorReporter.ts +1 -1
- package/src/index.ts +2 -1
- package/src/{api/internal → internal}/RequestContextMiddleware.ts +3 -3
- package/src/{api/internal → internal}/events.ts +2 -2
- package/src/{api/layerUtils.ts → layerUtils.ts} +1 -1
- package/src/logger/jsonLogger.ts +1 -1
- package/src/logger/logFmtLogger.ts +1 -1
- package/src/logger/shared.ts +1 -1
- package/src/{adapters/redis-client.ts → redis-client.ts} +1 -1
- package/src/{api/reportError.ts → reportError.ts} +1 -1
- package/src/{api/routing → routing}/middleware/middleware.ts +4 -4
- package/src/{api/routing.ts → routing.ts} +13 -13
- package/src/{api/setupRequest.ts → setupRequest.ts} +3 -3
- package/test/auth.test.ts +1 -1
- package/test/contextProvider.test.ts +1 -1
- package/test/controller.test.ts +3 -3
- package/test/cosmos-query.test.ts +1 -1
- package/test/dist/controller.test.d.ts.map +1 -1
- package/test/dist/query.test.d.ts.map +1 -1
- package/test/dist/rawQuery.test.d.ts.map +1 -1
- package/test/layerUtils.test.ts +1 -1
- package/test/query.test.ts +4 -4
- package/test/rawQuery.test.ts +4 -4
- package/test/repository-ext.test.ts +3 -3
- package/test/router-generator.test.ts +3 -3
- package/test/routing-interruptibility.test.ts +2 -2
- package/test/rpc-context-map-streaming.test.ts +3 -3
- package/test/rpc-e2e-invalidation.test.ts +2 -2
- package/test/rpc-multi-middleware.test.ts +1 -1
- package/test/rpc-stream-fullstack.test.ts +2 -2
- package/test/validateSample.test.ts +3 -3
- package/dist/Emailer/service.d.ts +0 -64
- package/dist/Emailer/service.d.ts.map +0 -1
- package/dist/Emailer/service.js +0 -7
- package/dist/Emailer.d.ts +0 -2
- package/dist/Emailer.d.ts.map +0 -1
- package/dist/Emailer.js +0 -2
- package/dist/Model/Repository/Registry.d.ts +0 -21
- package/dist/Model/Repository/Registry.d.ts.map +0 -1
- package/dist/Model/Repository/Registry.js +0 -18
- package/dist/Model/Repository/ext.d.ts +0 -60
- package/dist/Model/Repository/ext.d.ts.map +0 -1
- package/dist/Model/Repository/ext.js +0 -122
- package/dist/Model/Repository/internal/internal.d.ts +0 -62
- package/dist/Model/Repository/internal/internal.d.ts.map +0 -1
- package/dist/Model/Repository/internal/internal.js +0 -398
- package/dist/Model/Repository/legacy.d.ts +0 -21
- package/dist/Model/Repository/legacy.d.ts.map +0 -1
- package/dist/Model/Repository/legacy.js +0 -2
- package/dist/Model/Repository/makeRepo.d.ts +0 -53
- package/dist/Model/Repository/makeRepo.d.ts.map +0 -1
- package/dist/Model/Repository/makeRepo.js +0 -27
- package/dist/Model/Repository/service.d.ts +0 -97
- package/dist/Model/Repository/service.d.ts.map +0 -1
- package/dist/Model/Repository/service.js +0 -2
- package/dist/Model/Repository/validation.d.ts +0 -71
- package/dist/Model/Repository/validation.d.ts.map +0 -1
- package/dist/Model/Repository/validation.js +0 -32
- package/dist/Model/Repository.d.ts +0 -7
- package/dist/Model/Repository.d.ts.map +0 -1
- package/dist/Model/Repository.js +0 -7
- package/dist/Model/dsl.d.ts +0 -33
- package/dist/Model/dsl.d.ts.map +0 -1
- package/dist/Model/dsl.js +0 -43
- package/dist/Model/filter/filterApi.d.ts +0 -30
- package/dist/Model/filter/filterApi.d.ts.map +0 -1
- package/dist/Model/filter/filterApi.js +0 -2
- package/dist/Model/filter/types/errors.d.ts +0 -29
- package/dist/Model/filter/types/errors.d.ts.map +0 -1
- package/dist/Model/filter/types/errors.js +0 -2
- package/dist/Model/filter/types/fields.d.ts +0 -15
- package/dist/Model/filter/types/fields.d.ts.map +0 -1
- package/dist/Model/filter/types/fields.js +0 -2
- package/dist/Model/filter/types/path/common.d.ts +0 -316
- package/dist/Model/filter/types/path/common.d.ts.map +0 -1
- package/dist/Model/filter/types/path/common.js +0 -2
- package/dist/Model/filter/types/path/eager.d.ts +0 -95
- package/dist/Model/filter/types/path/eager.d.ts.map +0 -1
- package/dist/Model/filter/types/path/eager.js +0 -31
- package/dist/Model/filter/types/path/index.d.ts +0 -4
- package/dist/Model/filter/types/path/index.d.ts.map +0 -1
- package/dist/Model/filter/types/path/index.js +0 -3
- package/dist/Model/filter/types/utils.d.ts +0 -79
- package/dist/Model/filter/types/utils.d.ts.map +0 -1
- package/dist/Model/filter/types/utils.js +0 -2
- package/dist/Model/filter/types/validator.d.ts +0 -30
- package/dist/Model/filter/types/validator.d.ts.map +0 -1
- package/dist/Model/filter/types/validator.js +0 -2
- package/dist/Model/filter/types.d.ts +0 -5
- package/dist/Model/filter/types.d.ts.map +0 -1
- package/dist/Model/filter/types.js +0 -7
- package/dist/Model/query/dsl.d.ts +0 -446
- package/dist/Model/query/dsl.d.ts.map +0 -1
- package/dist/Model/query/dsl.js +0 -339
- package/dist/Model/query/new-kid-interpreter.d.ts +0 -136
- package/dist/Model/query/new-kid-interpreter.d.ts.map +0 -1
- package/dist/Model/query/new-kid-interpreter.js +0 -336
- package/dist/Model/query.d.ts +0 -15
- package/dist/Model/query.d.ts.map +0 -1
- package/dist/Model/query.js +0 -3
- package/dist/Model.d.ts +0 -5
- package/dist/Model.d.ts.map +0 -1
- package/dist/Model.js +0 -5
- package/dist/QueueMaker/service.d.ts +0 -13
- package/dist/QueueMaker/service.d.ts.map +0 -1
- package/dist/QueueMaker/service.js +0 -4
- package/dist/RequestContext.d.ts +0 -103
- package/dist/RequestContext.d.ts.map +0 -1
- package/dist/RequestContext.js +0 -49
- package/dist/Store/service.d.ts +0 -138
- package/dist/Store/service.d.ts.map +0 -1
- package/dist/Store/service.js +0 -95
- package/dist/Store.d.ts +0 -2
- package/dist/Store.d.ts.map +0 -1
- package/dist/Store.js +0 -2
- package/dist/adapters/SQL/Model.d.ts.map +0 -1
- package/dist/adapters/SQL/Model.js +0 -469
- package/dist/adapters/SQL.d.ts.map +0 -1
- package/dist/adapters/ServiceBus.d.ts.map +0 -1
- package/dist/adapters/ServiceBus.js +0 -108
- package/dist/adapters/cosmos-client.d.ts.map +0 -1
- package/dist/adapters/cosmos-client.js +0 -11
- package/dist/adapters/index.d.ts +0 -8
- package/dist/adapters/index.d.ts.map +0 -1
- package/dist/adapters/index.js +0 -8
- package/dist/adapters/logger.d.ts +0 -9
- package/dist/adapters/logger.d.ts.map +0 -1
- package/dist/adapters/logger.js +0 -3
- package/dist/adapters/memQueue.d.ts.map +0 -1
- package/dist/adapters/memQueue.js +0 -21
- package/dist/adapters/mongo-client.d.ts.map +0 -1
- package/dist/adapters/mongo-client.js +0 -15
- package/dist/adapters/redis-client.d.ts.map +0 -1
- package/dist/adapters/redis-client.js +0 -98
- package/dist/api/ContextProvider.d.ts +0 -34
- package/dist/api/ContextProvider.d.ts.map +0 -1
- package/dist/api/ContextProvider.js +0 -40
- package/dist/api/codec.d.ts.map +0 -1
- package/dist/api/codec.js +0 -5
- package/dist/api/internal/RequestContextMiddleware.d.ts.map +0 -1
- package/dist/api/internal/RequestContextMiddleware.js +0 -46
- package/dist/api/internal/auth.d.ts.map +0 -1
- package/dist/api/internal/auth.js +0 -180
- package/dist/api/internal/events.d.ts.map +0 -1
- package/dist/api/internal/events.js +0 -49
- package/dist/api/internal/health.d.ts.map +0 -1
- package/dist/api/internal/health.js +0 -5
- package/dist/api/layerUtils.d.ts +0 -32
- package/dist/api/layerUtils.d.ts.map +0 -1
- package/dist/api/layerUtils.js +0 -17
- package/dist/api/middlewares.d.ts.map +0 -1
- package/dist/api/reportError.d.ts +0 -4
- package/dist/api/reportError.d.ts.map +0 -1
- package/dist/api/reportError.js +0 -28
- package/dist/api/routing/middleware/RouterMiddleware.d.ts.map +0 -1
- package/dist/api/routing/middleware/middleware.d.ts.map +0 -1
- package/dist/api/routing/middleware/middleware.js +0 -128
- package/dist/api/routing/middleware.d.ts.map +0 -1
- package/dist/api/routing/schema/jwt.d.ts.map +0 -1
- package/dist/api/routing/schema/jwt.js +0 -13
- package/dist/api/routing/tsort.d.ts +0 -8
- package/dist/api/routing/tsort.d.ts.map +0 -1
- package/dist/api/routing/tsort.js +0 -51
- package/dist/api/routing/utils.d.ts.map +0 -1
- package/dist/api/routing/utils.js +0 -45
- package/dist/api/routing.d.ts +0 -184
- package/dist/api/routing.d.ts.map +0 -1
- package/dist/api/setupRequest.d.ts.map +0 -1
- package/dist/api/setupRequest.js +0 -70
- package/dist/api/util.d.ts.map +0 -1
- package/dist/api/util.js +0 -14
- package/src/Emailer/service.ts +0 -62
- package/src/Emailer.ts +0 -1
- package/src/Model/Repository/Registry.ts +0 -34
- package/src/Model/Repository/ext.ts +0 -375
- package/src/Model/Repository/internal/internal.ts +0 -692
- package/src/Model/Repository/legacy.ts +0 -29
- package/src/Model/Repository/makeRepo.ts +0 -144
- package/src/Model/Repository/service.ts +0 -639
- package/src/Model/Repository/validation.ts +0 -31
- package/src/Model/Repository.ts +0 -6
- package/src/Model/dsl.ts +0 -129
- package/src/Model/filter/filterApi.ts +0 -60
- package/src/Model/filter/types/errors.ts +0 -47
- package/src/Model/filter/types/fields.ts +0 -50
- package/src/Model/filter/types/path/common.ts +0 -404
- package/src/Model/filter/types/path/eager.ts +0 -297
- package/src/Model/filter/types/path/index.ts +0 -4
- package/src/Model/filter/types/utils.ts +0 -128
- package/src/Model/filter/types/validator.ts +0 -46
- package/src/Model/filter/types.ts +0 -6
- package/src/Model/query/dsl.ts +0 -2546
- package/src/Model/query/new-kid-interpreter.ts +0 -484
- package/src/Model/query.ts +0 -13
- package/src/Model.ts +0 -4
- package/src/QueueMaker/service.ts +0 -19
- package/src/RequestContext.ts +0 -62
- package/src/Store/service.ts +0 -233
- package/src/Store.ts +0 -1
- package/src/adapters/index.ts +0 -7
- package/src/adapters/logger.ts +0 -3
- /package/src/{api/ContextProvider.ts → ContextProvider.ts} +0 -0
- /package/src/{adapters/SQL.ts → SQL.ts} +0 -0
- /package/src/{api/codec.ts → codec.ts} +0 -0
- /package/src/{adapters/cosmos-client.ts → cosmos-client.ts} +0 -0
- /package/src/{api/internal → internal}/auth.ts +0 -0
- /package/src/{api/internal → internal}/health.ts +0 -0
- /package/src/{adapters/memQueue.ts → memQueue.ts} +0 -0
- /package/src/{api/middlewares.ts → middlewares.ts} +0 -0
- /package/src/{adapters/mongo-client.ts → mongo-client.ts} +0 -0
- /package/src/{api/routing → routing}/middleware/RouterMiddleware.ts +0 -0
- /package/src/{api/routing → routing}/middleware.ts +0 -0
- /package/src/{api/routing → routing}/schema/jwt.ts +0 -0
- /package/src/{api/routing → routing}/tsort.ts +0 -0
- /package/src/{api/routing → routing}/utils.ts +0 -0
- /package/src/{api/util.ts → util.ts} +0 -0
|
@@ -1,484 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
3
|
-
import * as Array from "effect-app/Array"
|
|
4
|
-
import { toNonEmptyArray } from "effect-app/Array"
|
|
5
|
-
import * as Option from "effect-app/Option"
|
|
6
|
-
import * as S from "effect-app/Schema"
|
|
7
|
-
import { dropUndefinedT } from "effect-app/utils"
|
|
8
|
-
import { identity, pipe } from "effect/Function"
|
|
9
|
-
import * as Match from "effect/Match"
|
|
10
|
-
import * as SchemaAST from "effect/SchemaAST"
|
|
11
|
-
import type { FilterResult } from "../filter/filterApi.js"
|
|
12
|
-
import type { FieldValues } from "../filter/types.js"
|
|
13
|
-
import type { FieldPath } from "../filter/types/path/eager.js"
|
|
14
|
-
import { make, type Q, type QAll } from "../query/dsl.js"
|
|
15
|
-
|
|
16
|
-
export type AggregateIrExpression =
|
|
17
|
-
| { readonly _tag: "agg-count" }
|
|
18
|
-
| { readonly _tag: "agg-count-when"; readonly filter: readonly FilterResult[] }
|
|
19
|
-
| { readonly _tag: "agg-sum"; readonly field: string }
|
|
20
|
-
| { readonly _tag: "agg-min"; readonly field: string }
|
|
21
|
-
| { readonly _tag: "agg-max"; readonly field: string }
|
|
22
|
-
|
|
23
|
-
export type AggregateIrItem =
|
|
24
|
-
| AggregateIrExpression
|
|
25
|
-
| { readonly _tag: "agg-field"; readonly path: string }
|
|
26
|
-
|
|
27
|
-
export type ComputedProjectionMathIrExpression =
|
|
28
|
-
| {
|
|
29
|
-
readonly _tag: "field"
|
|
30
|
-
readonly field: string
|
|
31
|
-
}
|
|
32
|
-
| {
|
|
33
|
-
readonly _tag: "mul"
|
|
34
|
-
readonly left: ComputedProjectionMathIrExpression
|
|
35
|
-
readonly right: ComputedProjectionMathIrExpression
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type ComputedProjectionIrExpression =
|
|
39
|
-
| {
|
|
40
|
-
readonly _tag: "relation-count"
|
|
41
|
-
readonly path: string
|
|
42
|
-
readonly filter: readonly FilterResult[]
|
|
43
|
-
}
|
|
44
|
-
| {
|
|
45
|
-
readonly _tag: "relation-any"
|
|
46
|
-
readonly path: string
|
|
47
|
-
readonly filter: readonly FilterResult[]
|
|
48
|
-
}
|
|
49
|
-
| {
|
|
50
|
-
readonly _tag: "relation-every"
|
|
51
|
-
readonly path: string
|
|
52
|
-
readonly filter: readonly FilterResult[]
|
|
53
|
-
}
|
|
54
|
-
| {
|
|
55
|
-
readonly _tag: "relation-distinct-count"
|
|
56
|
-
readonly path: string
|
|
57
|
-
readonly field: string
|
|
58
|
-
readonly filter: readonly FilterResult[]
|
|
59
|
-
}
|
|
60
|
-
| {
|
|
61
|
-
readonly _tag: "relation-sum"
|
|
62
|
-
readonly path: string
|
|
63
|
-
readonly field: string
|
|
64
|
-
readonly filter: readonly FilterResult[]
|
|
65
|
-
}
|
|
66
|
-
| {
|
|
67
|
-
readonly _tag: "relation-sum-expr"
|
|
68
|
-
readonly path: string
|
|
69
|
-
readonly expression: ComputedProjectionMathIrExpression
|
|
70
|
-
readonly filter: readonly FilterResult[]
|
|
71
|
-
}
|
|
72
|
-
| {
|
|
73
|
-
readonly _tag: "relation-sum-expr-by"
|
|
74
|
-
readonly path: string
|
|
75
|
-
readonly expression: ComputedProjectionMathIrExpression
|
|
76
|
-
readonly unit: string
|
|
77
|
-
readonly filter: readonly FilterResult[]
|
|
78
|
-
}
|
|
79
|
-
| {
|
|
80
|
-
readonly _tag: "relation-sum-expr-normalized"
|
|
81
|
-
readonly path: string
|
|
82
|
-
readonly expression: ComputedProjectionMathIrExpression
|
|
83
|
-
readonly unit: string
|
|
84
|
-
readonly toBase: string
|
|
85
|
-
readonly factors: Readonly<Record<string, number>>
|
|
86
|
-
readonly filter: readonly FilterResult[]
|
|
87
|
-
}
|
|
88
|
-
| {
|
|
89
|
-
readonly _tag: "relation-collect"
|
|
90
|
-
readonly path: string
|
|
91
|
-
readonly field: string
|
|
92
|
-
readonly distinct: boolean
|
|
93
|
-
readonly filter: readonly FilterResult[]
|
|
94
|
-
}
|
|
95
|
-
| {
|
|
96
|
-
readonly _tag: "relation-collect-fields"
|
|
97
|
-
readonly path: string
|
|
98
|
-
readonly fields: readonly string[]
|
|
99
|
-
readonly distinct: boolean
|
|
100
|
-
readonly filter: readonly FilterResult[]
|
|
101
|
-
}
|
|
102
|
-
| {
|
|
103
|
-
readonly _tag: "relation-length"
|
|
104
|
-
readonly path: string
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
type Result<TFieldValues extends FieldValues, A = TFieldValues, R = never> = {
|
|
108
|
-
filter: FilterResult[]
|
|
109
|
-
schema: S.Codec<A, TFieldValues, R> | undefined
|
|
110
|
-
limit: number | undefined
|
|
111
|
-
skip: number | undefined
|
|
112
|
-
order: { key: FieldPath<TFieldValues>; direction: "ASC" | "DESC" }[]
|
|
113
|
-
ttype: "one" | "many" | "count" | undefined
|
|
114
|
-
mode: "collect" | "project" | "transform" | "aggregate" | undefined
|
|
115
|
-
computed: Record<string, ComputedProjectionIrExpression> | undefined
|
|
116
|
-
aggregateMap: Record<string, AggregateIrItem> | undefined
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const interpret = <
|
|
120
|
-
TFieldValues extends FieldValues,
|
|
121
|
-
TFieldValuesRefined extends TFieldValues = TFieldValues,
|
|
122
|
-
A = TFieldValues,
|
|
123
|
-
R = never
|
|
124
|
-
>(_: QAll<TFieldValues, TFieldValuesRefined, A, R>) => {
|
|
125
|
-
const a = _ as Q<TFieldValues>
|
|
126
|
-
|
|
127
|
-
const data: Result<TFieldValues, any, any> = {
|
|
128
|
-
filter: [],
|
|
129
|
-
schema: undefined,
|
|
130
|
-
limit: undefined,
|
|
131
|
-
skip: undefined,
|
|
132
|
-
order: [],
|
|
133
|
-
ttype: undefined,
|
|
134
|
-
mode: undefined,
|
|
135
|
-
computed: undefined,
|
|
136
|
-
aggregateMap: undefined
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const upd = (
|
|
140
|
-
v: Result<TFieldValues, any, any>
|
|
141
|
-
) => {
|
|
142
|
-
data.filter.push(...v.filter)
|
|
143
|
-
data.order.push(...v.order)
|
|
144
|
-
if (v.limit !== undefined) data.limit = v.limit
|
|
145
|
-
if (v.skip !== undefined) data.skip = v.skip
|
|
146
|
-
if (v.ttype !== undefined) data.ttype = v.ttype
|
|
147
|
-
if (v.schema !== undefined) data.schema = v.schema
|
|
148
|
-
if (v.mode !== undefined) data.mode = v.mode
|
|
149
|
-
if (v.computed !== undefined) data.computed = v.computed
|
|
150
|
-
if (v.aggregateMap !== undefined) data.aggregateMap = v.aggregateMap
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const applyPath = (path: string) => (_: FilterResult): FilterResult =>
|
|
154
|
-
_.t === "where" || _.t === "and" || _.t === "or"
|
|
155
|
-
? { ..._, path: `${path}.-1.${_.path}` }
|
|
156
|
-
: { ..._, result: _.result.map(applyPath(path)) }
|
|
157
|
-
|
|
158
|
-
pipe(
|
|
159
|
-
a,
|
|
160
|
-
Match.valueTags({
|
|
161
|
-
value: () => {
|
|
162
|
-
// data.filter.push(value)
|
|
163
|
-
},
|
|
164
|
-
where: ({ current, operation, relation, subPath }) => {
|
|
165
|
-
upd(interpret(current))
|
|
166
|
-
if (typeof operation === "function") {
|
|
167
|
-
data.filter.push(
|
|
168
|
-
{
|
|
169
|
-
t: "where-scope",
|
|
170
|
-
result: interpret(operation(make())).filter.map(subPath ? applyPath(subPath) : identity),
|
|
171
|
-
relation
|
|
172
|
-
}
|
|
173
|
-
)
|
|
174
|
-
} else {
|
|
175
|
-
data.filter.push(
|
|
176
|
-
{
|
|
177
|
-
t: "where",
|
|
178
|
-
path: operation[0],
|
|
179
|
-
op: operation.length === 2 ? "eq" : operation[1],
|
|
180
|
-
value: operation.length === 2 ? operation[1] : operation[2]
|
|
181
|
-
}
|
|
182
|
-
)
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
and: ({ current, operation, relation }) => {
|
|
186
|
-
upd(interpret(current))
|
|
187
|
-
if (typeof operation === "function") {
|
|
188
|
-
data.filter.push(
|
|
189
|
-
{ t: "and-scope", result: interpret(operation(make())).filter, relation }
|
|
190
|
-
)
|
|
191
|
-
} else {
|
|
192
|
-
data.filter.push(
|
|
193
|
-
{
|
|
194
|
-
t: "and",
|
|
195
|
-
path: operation[0],
|
|
196
|
-
op: operation.length === 2 ? "eq" : operation[1],
|
|
197
|
-
value: operation.length === 2 ? operation[1] : operation[2]
|
|
198
|
-
}
|
|
199
|
-
)
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
or: ({ current, operation, relation }) => {
|
|
203
|
-
upd(interpret(current))
|
|
204
|
-
if (typeof operation === "function") {
|
|
205
|
-
data.filter.push(
|
|
206
|
-
{ t: "or-scope", result: interpret(operation(make())).filter, relation }
|
|
207
|
-
)
|
|
208
|
-
} else {
|
|
209
|
-
data.filter.push(
|
|
210
|
-
{
|
|
211
|
-
t: "or",
|
|
212
|
-
path: operation[0],
|
|
213
|
-
op: operation.length === 2 ? "eq" : operation[1],
|
|
214
|
-
value: operation.length === 2 ? operation[1] : operation[2]
|
|
215
|
-
}
|
|
216
|
-
)
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
one: ({ current }) => {
|
|
220
|
-
upd(interpret(current))
|
|
221
|
-
data.limit = 1
|
|
222
|
-
data.ttype = "one"
|
|
223
|
-
},
|
|
224
|
-
count: ({ current }) => {
|
|
225
|
-
upd(interpret(current))
|
|
226
|
-
data.ttype = "count"
|
|
227
|
-
data.schema = S.Struct({ id: S.String }) as any
|
|
228
|
-
},
|
|
229
|
-
order: ({ current, direction, field }) => {
|
|
230
|
-
upd(interpret(current))
|
|
231
|
-
data.order.push({ key: field, direction })
|
|
232
|
-
},
|
|
233
|
-
page: (v) => {
|
|
234
|
-
upd(interpret(v.current))
|
|
235
|
-
data.limit = v.take
|
|
236
|
-
data.skip = v.skip
|
|
237
|
-
},
|
|
238
|
-
project: (v) => {
|
|
239
|
-
upd(interpret(v.current))
|
|
240
|
-
if (v.mode === "aggregate" && v.aggregateMap) {
|
|
241
|
-
data.schema = v.schema
|
|
242
|
-
data.mode = "aggregate"
|
|
243
|
-
data.aggregateMap = Object.fromEntries(
|
|
244
|
-
Object.entries(v.aggregateMap).map(([key, expression]) => {
|
|
245
|
-
switch (expression._tag) {
|
|
246
|
-
case "agg-field":
|
|
247
|
-
return [key, { _tag: "agg-field" as const, path: expression.path }]
|
|
248
|
-
case "agg-count":
|
|
249
|
-
return [key, { _tag: "agg-count" as const }]
|
|
250
|
-
case "agg-count-when": {
|
|
251
|
-
const filter = interpret(expression.operation(make())).filter
|
|
252
|
-
return [key, { _tag: "agg-count-when" as const, filter }]
|
|
253
|
-
}
|
|
254
|
-
case "agg-sum":
|
|
255
|
-
return [key, { _tag: "agg-sum" as const, field: expression.field }]
|
|
256
|
-
case "agg-min":
|
|
257
|
-
return [key, { _tag: "agg-min" as const, field: expression.field }]
|
|
258
|
-
case "agg-max":
|
|
259
|
-
return [key, { _tag: "agg-max" as const, field: expression.field }]
|
|
260
|
-
}
|
|
261
|
-
})
|
|
262
|
-
)
|
|
263
|
-
return
|
|
264
|
-
}
|
|
265
|
-
if (v.computed && v.mode === "transform") {
|
|
266
|
-
throw new Error("Computed projections require mode 'project' or 'collect', not 'transform'")
|
|
267
|
-
}
|
|
268
|
-
data.schema = v.schema
|
|
269
|
-
data.mode = v.computed
|
|
270
|
-
? v.mode === "collect" ? "collect" : "project"
|
|
271
|
-
: v.mode
|
|
272
|
-
data.computed = v.computed
|
|
273
|
-
? Object.fromEntries(
|
|
274
|
-
Object.entries(v.computed).map(([key, expression]) => {
|
|
275
|
-
const e = expression
|
|
276
|
-
const op = "operation" in e ? e.operation : undefined
|
|
277
|
-
const filter = op ? interpret(op(make())).filter.map(applyPath(e.path)) : []
|
|
278
|
-
switch (e._tag) {
|
|
279
|
-
case "relation-count":
|
|
280
|
-
case "relation-any":
|
|
281
|
-
case "relation-every":
|
|
282
|
-
return [key, { _tag: e._tag, path: e.path, filter } as ComputedProjectionIrExpression]
|
|
283
|
-
case "relation-distinct-count":
|
|
284
|
-
case "relation-sum":
|
|
285
|
-
return [
|
|
286
|
-
key,
|
|
287
|
-
{ _tag: e._tag, path: e.path, field: e.field, filter } as ComputedProjectionIrExpression
|
|
288
|
-
]
|
|
289
|
-
case "relation-sum-expr":
|
|
290
|
-
return [
|
|
291
|
-
key,
|
|
292
|
-
{ _tag: e._tag, path: e.path, expression: e.expression, filter } as ComputedProjectionIrExpression
|
|
293
|
-
]
|
|
294
|
-
case "relation-sum-expr-by":
|
|
295
|
-
return [
|
|
296
|
-
key,
|
|
297
|
-
{
|
|
298
|
-
_tag: e._tag,
|
|
299
|
-
path: e.path,
|
|
300
|
-
expression: e.expression,
|
|
301
|
-
unit: e.unit,
|
|
302
|
-
filter
|
|
303
|
-
} as ComputedProjectionIrExpression
|
|
304
|
-
]
|
|
305
|
-
case "relation-sum-expr-normalized":
|
|
306
|
-
return [
|
|
307
|
-
key,
|
|
308
|
-
{
|
|
309
|
-
_tag: e._tag,
|
|
310
|
-
path: e.path,
|
|
311
|
-
expression: e.expression,
|
|
312
|
-
unit: e.unit,
|
|
313
|
-
toBase: e.toBase,
|
|
314
|
-
factors: e.factors,
|
|
315
|
-
filter
|
|
316
|
-
} as ComputedProjectionIrExpression
|
|
317
|
-
]
|
|
318
|
-
case "relation-collect":
|
|
319
|
-
return [
|
|
320
|
-
key,
|
|
321
|
-
{
|
|
322
|
-
_tag: e._tag,
|
|
323
|
-
path: e.path,
|
|
324
|
-
field: e.field,
|
|
325
|
-
distinct: e.distinct,
|
|
326
|
-
filter
|
|
327
|
-
} as ComputedProjectionIrExpression
|
|
328
|
-
]
|
|
329
|
-
case "relation-collect-fields":
|
|
330
|
-
return [
|
|
331
|
-
key,
|
|
332
|
-
{
|
|
333
|
-
_tag: e._tag,
|
|
334
|
-
path: e.path,
|
|
335
|
-
fields: e.fields,
|
|
336
|
-
distinct: e.distinct,
|
|
337
|
-
filter
|
|
338
|
-
} as ComputedProjectionIrExpression
|
|
339
|
-
]
|
|
340
|
-
case "relation-length":
|
|
341
|
-
return [key, { _tag: e._tag, path: e.path } as ComputedProjectionIrExpression]
|
|
342
|
-
}
|
|
343
|
-
})
|
|
344
|
-
)
|
|
345
|
-
: undefined
|
|
346
|
-
}
|
|
347
|
-
})
|
|
348
|
-
)
|
|
349
|
-
|
|
350
|
-
return data
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
const walkTransformation = (t: S.AST.AST): S.AST.AST => {
|
|
354
|
-
if (S.AST.isDeclaration(t) && t.typeParameters.length > 0) {
|
|
355
|
-
return walkTransformation(t.typeParameters[0]!)
|
|
356
|
-
}
|
|
357
|
-
return t
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
export const toFilter = <
|
|
361
|
-
TFieldValues extends FieldValues,
|
|
362
|
-
A,
|
|
363
|
-
R,
|
|
364
|
-
TFieldValuesRefined extends TFieldValues = TFieldValues
|
|
365
|
-
>(
|
|
366
|
-
q: QAll<TFieldValues, TFieldValuesRefined, A, R>,
|
|
367
|
-
baseSchema?: S.Schema<unknown>
|
|
368
|
-
) => {
|
|
369
|
-
// TODO: Native interpreter for each db adapter, instead of the intermediate "new-kid" format
|
|
370
|
-
const a = interpret(q)
|
|
371
|
-
|
|
372
|
-
// Aggregate mode: build select entirely from aggregateMap (no schema-driven field list)
|
|
373
|
-
if (a.mode === "aggregate" && a.aggregateMap) {
|
|
374
|
-
const aggSelect = Object.entries(a.aggregateMap).map(([key, item]) => {
|
|
375
|
-
if (item._tag === "agg-field") {
|
|
376
|
-
return { key, path: item.path }
|
|
377
|
-
}
|
|
378
|
-
return { key, aggregate: item }
|
|
379
|
-
})
|
|
380
|
-
return dropUndefinedT({
|
|
381
|
-
t: null as unknown as TFieldValues,
|
|
382
|
-
limit: a.limit,
|
|
383
|
-
skip: a.skip,
|
|
384
|
-
select: Option.getOrUndefined(toNonEmptyArray(aggSelect)) as any,
|
|
385
|
-
schema: a.schema,
|
|
386
|
-
computed: undefined,
|
|
387
|
-
order: Option.getOrUndefined(toNonEmptyArray(a.order)),
|
|
388
|
-
ttype: a.ttype,
|
|
389
|
-
mode: "aggregate" as const,
|
|
390
|
-
filter: a.filter.length ? a.filter : undefined
|
|
391
|
-
})
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
const schema = a.schema
|
|
395
|
-
let select: (keyof TFieldValues | { key: string; subKeys: string[] } | {
|
|
396
|
-
key: string
|
|
397
|
-
computed: ComputedProjectionIrExpression
|
|
398
|
-
})[] = []
|
|
399
|
-
// TODO: support more complex (nested) schemas?
|
|
400
|
-
if (schema) {
|
|
401
|
-
const t = walkTransformation(SchemaAST.toEncoded(schema.ast))
|
|
402
|
-
if (S.AST.isObjects(t)) {
|
|
403
|
-
select = t.propertySignatures.map((_) => _.name as string)
|
|
404
|
-
for (const prop of t.propertySignatures) {
|
|
405
|
-
if (S.AST.isArrays(prop.type)) {
|
|
406
|
-
// make sure we only select when there are actually type literals in the tuple...
|
|
407
|
-
// otherwise we might be dealing with strings etc.
|
|
408
|
-
// TODO; be more strict, can't support arrays with unions that have non TypeLiteral members etc..
|
|
409
|
-
const arraySelect = {
|
|
410
|
-
key: prop.name as string,
|
|
411
|
-
subKeys: Array.flatMap(
|
|
412
|
-
prop.type.rest,
|
|
413
|
-
(x) => {
|
|
414
|
-
const t = walkTransformation(x)
|
|
415
|
-
return S.AST.isObjects(t) ? t.propertySignatures.map((y) => y.name as string) : []
|
|
416
|
-
}
|
|
417
|
-
)
|
|
418
|
-
}
|
|
419
|
-
if (arraySelect.subKeys.length > 0) {
|
|
420
|
-
select.push(arraySelect)
|
|
421
|
-
// make sure we don't double select?
|
|
422
|
-
if (select.includes(prop.name as string)) {
|
|
423
|
-
select.splice(select.indexOf(prop.name as string), 1)
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
const computed = a.computed
|
|
431
|
-
const getSelectKey = (_: (typeof select)[number]) => {
|
|
432
|
-
if (typeof _ === "string") {
|
|
433
|
-
return _
|
|
434
|
-
}
|
|
435
|
-
if (typeof _ === "object" && _ !== null && "key" in _) {
|
|
436
|
-
return _.key
|
|
437
|
-
}
|
|
438
|
-
return String(_)
|
|
439
|
-
}
|
|
440
|
-
const schemaKeys = select.map(getSelectKey)
|
|
441
|
-
const nonEncodedSchemaKeys = (() => {
|
|
442
|
-
if (!baseSchema) {
|
|
443
|
-
return [] as string[]
|
|
444
|
-
}
|
|
445
|
-
const encoded = walkTransformation(SchemaAST.toEncoded(baseSchema.ast))
|
|
446
|
-
if (!S.AST.isObjects(encoded)) {
|
|
447
|
-
return [] as string[]
|
|
448
|
-
}
|
|
449
|
-
const encodedKeys = encoded.propertySignatures.map((_) => _.name as string)
|
|
450
|
-
return schemaKeys.filter((key) => !encodedKeys.includes(key))
|
|
451
|
-
})()
|
|
452
|
-
const missingComputedKeys = nonEncodedSchemaKeys.filter((key) => !(computed && key in computed))
|
|
453
|
-
|
|
454
|
-
if (Array.isArrayNonEmpty(missingComputedKeys)) {
|
|
455
|
-
throw new Error(`Missing computed projections for schema keys: ${missingComputedKeys.join(", ")}`)
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
if (computed) {
|
|
459
|
-
const computedKeys = Object.keys(computed)
|
|
460
|
-
const extraComputedKeys = computedKeys.filter((key) => !schemaKeys.includes(key))
|
|
461
|
-
if (Array.isArrayNonEmpty(extraComputedKeys)) {
|
|
462
|
-
throw new Error(`Computed projection keys must exist in projection schema: ${extraComputedKeys.join(", ")}`)
|
|
463
|
-
}
|
|
464
|
-
select = select.filter((_) => {
|
|
465
|
-
const key = getSelectKey(_)
|
|
466
|
-
return !(key in computed)
|
|
467
|
-
})
|
|
468
|
-
select.push(...Object.entries(computed).map(([key, expression]) => ({ key, computed: expression })))
|
|
469
|
-
}
|
|
470
|
-
return dropUndefinedT({
|
|
471
|
-
t: null as unknown as TFieldValues,
|
|
472
|
-
limit: a.limit,
|
|
473
|
-
skip: a.skip,
|
|
474
|
-
select: Option.getOrUndefined(toNonEmptyArray(select)),
|
|
475
|
-
schema,
|
|
476
|
-
computed,
|
|
477
|
-
order: Option.getOrUndefined(toNonEmptyArray(a.order)),
|
|
478
|
-
ttype: a.ttype,
|
|
479
|
-
mode: a.mode ?? "transform",
|
|
480
|
-
filter: a.filter.length
|
|
481
|
-
? a.filter
|
|
482
|
-
: undefined
|
|
483
|
-
})
|
|
484
|
-
}
|
package/src/Model/query.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from "./query/dsl.js"
|
|
2
|
-
export * from "./query/new-kid-interpreter.js"
|
|
3
|
-
|
|
4
|
-
export interface RawQuery<Encoded, Out> {
|
|
5
|
-
cosmos: (vals: { name: string }) => {
|
|
6
|
-
query: string
|
|
7
|
-
parameters: {
|
|
8
|
-
name: string
|
|
9
|
-
value: any
|
|
10
|
-
}[]
|
|
11
|
-
}
|
|
12
|
-
memory: (t: readonly Encoded[]) => readonly Out[]
|
|
13
|
-
}
|
package/src/Model.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { NonEmptyReadonlyArray } from "effect-app/Array"
|
|
2
|
-
import type * as Effect from "effect-app/Effect"
|
|
3
|
-
import type * as Scope from "effect/Scope"
|
|
4
|
-
import { RequestContext } from "../RequestContext.js"
|
|
5
|
-
|
|
6
|
-
export interface QueueBase<Evt, DrainEvt> {
|
|
7
|
-
drain: <DrainE, DrainR>(
|
|
8
|
-
makeHandleEvent: (ks: DrainEvt) => Effect.Effect<void, DrainE, DrainR>,
|
|
9
|
-
sessionId?: string
|
|
10
|
-
) => Effect.Effect<never, never, Scope.Scope | DrainR>
|
|
11
|
-
publish: (
|
|
12
|
-
...messages: NonEmptyReadonlyArray<Evt>
|
|
13
|
-
) => Effect.Effect<void>
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface QueueMakerOps {}
|
|
17
|
-
export const QueueMaker: QueueMakerOps = {}
|
|
18
|
-
|
|
19
|
-
export const QueueMeta = RequestContext
|
package/src/RequestContext.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import * as Context from "effect-app/Context"
|
|
2
|
-
import { UserProfileId } from "effect-app/ids"
|
|
3
|
-
import * as S from "effect-app/Schema"
|
|
4
|
-
import { NonEmptyString255 } from "effect-app/Schema"
|
|
5
|
-
|
|
6
|
-
export const Locale = S.Literals(["en", "de"])
|
|
7
|
-
export type Locale = typeof Locale.Type
|
|
8
|
-
|
|
9
|
-
export class LocaleRef extends Context.Reference("Locale", { defaultValue: (): Locale => "en" }) {}
|
|
10
|
-
|
|
11
|
-
export class RequestContext extends S.Opaque<
|
|
12
|
-
RequestContext,
|
|
13
|
-
RequestContext.Encoded
|
|
14
|
-
>()(S.Struct({
|
|
15
|
-
span: S.Struct({
|
|
16
|
-
traceId: S.String,
|
|
17
|
-
spanId: S.String,
|
|
18
|
-
sampled: S.Boolean
|
|
19
|
-
}),
|
|
20
|
-
name: NonEmptyString255,
|
|
21
|
-
locale: Locale,
|
|
22
|
-
sourceId: S.optional(NonEmptyString255), // TODO?
|
|
23
|
-
namespace: NonEmptyString255,
|
|
24
|
-
/** @deprecated */
|
|
25
|
-
userProfile: S.optional(S.Struct({ sub: UserProfileId })) //
|
|
26
|
-
})) {
|
|
27
|
-
// static Tag = Context.Tag<RequestContext>()
|
|
28
|
-
|
|
29
|
-
static toMonitoring(this: void, self: RequestContext) {
|
|
30
|
-
return {
|
|
31
|
-
operationName: self.name,
|
|
32
|
-
locale: self.locale
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const spanAttributes = (ctx: Pick<RequestContext, "locale" | "namespace"> & Partial<RequestContext>) => ({
|
|
38
|
-
"code.function.name": ctx.name,
|
|
39
|
-
"app.locale": ctx.locale,
|
|
40
|
-
"app.tenant.id": ctx.namespace,
|
|
41
|
-
...ctx.sourceId ? { "client.id": ctx.sourceId } : {},
|
|
42
|
-
...(ctx.userProfile?.sub
|
|
43
|
-
? {
|
|
44
|
-
"user.id": ctx
|
|
45
|
-
.userProfile
|
|
46
|
-
.sub,
|
|
47
|
-
"user.roles": "roles" in ctx
|
|
48
|
-
.userProfile
|
|
49
|
-
? ctx.userProfile.roles
|
|
50
|
-
: undefined
|
|
51
|
-
}
|
|
52
|
-
: {})
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
// codegen:start {preset: model}
|
|
56
|
-
//
|
|
57
|
-
export namespace RequestContext {
|
|
58
|
-
export interface Encoded extends S.StructNestedEncoded<typeof RequestContext> {}
|
|
59
|
-
}
|
|
60
|
-
//
|
|
61
|
-
// codegen:end
|
|
62
|
-
//
|