@effect-app/infra 4.0.0-beta.5 → 4.0.0-beta.52
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 +335 -0
- package/dist/Emailer/Sendgrid.js +1 -1
- package/dist/Emailer/service.d.ts +1 -1
- package/dist/Model/query/dsl.d.ts +9 -9
- package/dist/QueueMaker/SQLQueue.d.ts +3 -3
- package/dist/QueueMaker/SQLQueue.d.ts.map +1 -1
- package/dist/QueueMaker/SQLQueue.js +3 -3
- package/dist/QueueMaker/memQueue.d.ts.map +1 -1
- package/dist/QueueMaker/memQueue.js +10 -9
- package/dist/QueueMaker/sbqueue.d.ts.map +1 -1
- package/dist/QueueMaker/sbqueue.js +11 -9
- package/dist/RequestFiberSet.d.ts.map +1 -1
- package/dist/RequestFiberSet.js +4 -4
- package/dist/Store/ContextMapContainer.d.ts +1 -1
- package/dist/Store/Cosmos.js +1 -1
- package/dist/Store/Disk.d.ts.map +1 -1
- package/dist/Store/Disk.js +2 -3
- package/dist/Store/Memory.d.ts.map +1 -1
- package/dist/Store/Memory.js +1 -1
- package/dist/adapters/SQL/Model.d.ts +2 -5
- package/dist/adapters/SQL/Model.d.ts.map +1 -1
- package/dist/adapters/SQL/Model.js +21 -13
- package/dist/adapters/ServiceBus.js +3 -3
- package/dist/adapters/redis-client.d.ts +1 -1
- package/dist/api/internal/auth.d.ts +1 -1
- package/dist/api/internal/events.d.ts.map +1 -1
- package/dist/api/internal/events.js +6 -4
- 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 +1 -1
- package/dist/api/routing.d.ts.map +1 -1
- package/dist/api/routing.js +1 -1
- package/dist/errorReporter.d.ts +1 -1
- package/dist/errorReporter.d.ts.map +1 -1
- package/dist/errorReporter.js +1 -1
- package/dist/fileUtil.d.ts.map +1 -1
- package/dist/fileUtil.js +3 -2
- package/dist/rateLimit.js +1 -1
- package/examples/query.ts +28 -24
- package/package.json +16 -16
- package/src/Emailer/Sendgrid.ts +1 -1
- package/src/QueueMaker/SQLQueue.ts +3 -4
- package/src/QueueMaker/memQueue.ts +41 -42
- package/src/QueueMaker/sbqueue.ts +65 -62
- package/src/RequestFiberSet.ts +3 -3
- package/src/Store/Cosmos.ts +10 -10
- package/src/Store/Disk.ts +1 -2
- package/src/Store/Memory.ts +2 -4
- package/src/adapters/SQL/Model.ts +76 -71
- package/src/adapters/ServiceBus.ts +2 -2
- package/src/api/internal/events.ts +4 -3
- package/src/api/routing/schema/jwt.ts +2 -3
- package/src/api/routing.ts +4 -3
- package/src/errorReporter.ts +1 -1
- package/src/fileUtil.ts +2 -1
- package/src/rateLimit.ts +2 -2
- package/test/controller.test.ts +4 -2
- package/test/dist/controller.test.d.ts.map +1 -1
- package/test/dist/fixtures.d.ts.map +1 -1
- package/test/dist/fixtures.js +4 -4
- package/test/dist/rpc-multi-middleware.test.d.ts.map +1 -1
- package/test/fixtures.ts +3 -3
- package/test/query.test.ts +2 -4
- package/test/rawQuery.test.ts +17 -15
- package/test/rpc-multi-middleware.test.ts +1 -1
- package/tsconfig.json +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/infra",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.52",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
@@ -8,46 +8,46 @@
|
|
|
8
8
|
"change-case": "^5.4.4",
|
|
9
9
|
"cross-fetch": "^4.1.0",
|
|
10
10
|
"express-oauth2-jwt-bearer": "^1.7.4",
|
|
11
|
-
"fast-check": "~4.
|
|
11
|
+
"fast-check": "~4.6.0",
|
|
12
12
|
"path-parser": "^6.1.0",
|
|
13
13
|
"proper-lockfile": "^4.1.2",
|
|
14
14
|
"pure-rand": "7.0.1",
|
|
15
15
|
"query-string": "^9.3.1",
|
|
16
|
-
"effect-app": "4.0.0-beta.
|
|
16
|
+
"effect-app": "4.0.0-beta.52"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@azure/cosmos": "^4.9.
|
|
19
|
+
"@azure/cosmos": "^4.9.2",
|
|
20
20
|
"@azure/service-bus": "^7.9.5",
|
|
21
|
-
"@sentry/node": "10.
|
|
22
|
-
"@sentry/opentelemetry": "10.
|
|
21
|
+
"@sentry/node": "10.46.0",
|
|
22
|
+
"@sentry/opentelemetry": "10.46.0",
|
|
23
23
|
"@types/express": "^5.0.6",
|
|
24
|
-
"@types/node": "25.
|
|
24
|
+
"@types/node": "25.5.0",
|
|
25
25
|
"@types/proper-lockfile": "^4.1.4",
|
|
26
26
|
"@types/redis": "^2.8.32",
|
|
27
27
|
"@types/redlock": "^4.0.8",
|
|
28
28
|
"express": "^5.2.1",
|
|
29
29
|
"jwks-rsa": "2.1.4",
|
|
30
30
|
"jwt-decode": "^4.0.0",
|
|
31
|
-
"mongodb": "7.1.
|
|
31
|
+
"mongodb": "7.1.1",
|
|
32
32
|
"redis": "^3.1.2",
|
|
33
33
|
"redlock": "^4.2.0",
|
|
34
34
|
"strip-ansi": "^7.2.0",
|
|
35
|
-
"typescript": "~
|
|
36
|
-
"vitest": "^4.
|
|
37
|
-
"@effect-app/eslint-shared-config": "0.5.7-beta.
|
|
35
|
+
"typescript": "~6.0.2",
|
|
36
|
+
"vitest": "^4.1.2",
|
|
37
|
+
"@effect-app/eslint-shared-config": "0.5.7-beta.6"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@azure/cosmos": "^4.9.
|
|
40
|
+
"@azure/cosmos": "^4.9.2",
|
|
41
41
|
"@azure/service-bus": "^7.9.5",
|
|
42
|
-
"@effect/vitest": "^4.0.0-beta.
|
|
42
|
+
"@effect/vitest": "^4.0.0-beta.43",
|
|
43
43
|
"@sendgrid/helpers": "^8.0.0",
|
|
44
44
|
"@sendgrid/mail": "^8.1.6",
|
|
45
|
-
"@sentry/node": "10.
|
|
46
|
-
"@sentry/opentelemetry": "10.
|
|
45
|
+
"@sentry/node": "10.46.0",
|
|
46
|
+
"@sentry/opentelemetry": "10.46.0",
|
|
47
47
|
"jwt-decode": "^4.0.0",
|
|
48
48
|
"redis": "^3.1.2",
|
|
49
49
|
"redlock": "^4.2.0",
|
|
50
|
-
"effect": "^4.0.0-beta.
|
|
50
|
+
"effect": "^4.0.0-beta.43",
|
|
51
51
|
"express": "^5.2.1"
|
|
52
52
|
},
|
|
53
53
|
"typesVersions": {
|
package/src/Emailer/Sendgrid.ts
CHANGED
|
@@ -42,7 +42,7 @@ const makeSendgrid = ({ apiKey, defaultFrom, defaultReplyTo, realMail, subjectPr
|
|
|
42
42
|
(err, result) =>
|
|
43
43
|
err
|
|
44
44
|
? resume(Effect.fail(err))
|
|
45
|
-
: resume(Effect.sync(() => result
|
|
45
|
+
: resume(Effect.sync(() => result))
|
|
46
46
|
)
|
|
47
47
|
)
|
|
48
48
|
.pipe(Effect.mapError((raw) => new SendMailError({ raw })))
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { getRequestContext, setupRequestContextWithCustomSpan } from "@effect-app/infra/api/setupRequest"
|
|
2
2
|
import { reportNonInterruptedFailure } from "@effect-app/infra/QueueMaker/errors"
|
|
3
3
|
import { type QueueBase, QueueMeta } from "@effect-app/infra/QueueMaker/service"
|
|
4
|
-
import { SqlClient } from "effect/unstable/sql"
|
|
5
4
|
import { subMinutes } from "date-fns"
|
|
6
|
-
import { Effect, Fiber, Option, S, Tracer } from "effect-app"
|
|
5
|
+
import { Effect, Fiber, type NonEmptyReadonlyArray, Option, S, Tracer } from "effect-app"
|
|
7
6
|
import type { NonEmptyString255 } from "effect-app/Schema"
|
|
8
7
|
import { pretty } from "effect-app/utils"
|
|
9
|
-
import
|
|
8
|
+
import { SqlClient } from "effect/unstable/sql"
|
|
10
9
|
import { SQLModel } from "../adapters/SQL.js"
|
|
11
10
|
import { InfraLogger } from "../logger.js"
|
|
12
11
|
|
|
13
|
-
export const QueueId = S.
|
|
12
|
+
export const QueueId = S.Finite.pipe(S.brand("QueueId"))
|
|
14
13
|
export type QueueId = typeof QueueId.Type
|
|
15
14
|
|
|
16
15
|
// TODO: let the model track and Auto Generate versionColumn on every update instead
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Cause, Tracer } from "effect"
|
|
2
|
-
import { Effect, Fiber, flow, S } from "effect-app"
|
|
3
|
-
import * as Q from "effect/Queue"
|
|
2
|
+
import { Effect, Fiber, flow, type NonEmptyReadonlyArray, S } from "effect-app"
|
|
4
3
|
import { pretty } from "effect-app/utils"
|
|
4
|
+
import * as Q from "effect/Queue"
|
|
5
5
|
import { MemQueue } from "../adapters/memQueue.js"
|
|
6
6
|
import { getRequestContext, setupRequestContextWithCustomSpan } from "../api/setupRequest.js"
|
|
7
7
|
import { InfraLogger } from "../logger.js"
|
|
8
8
|
import { reportNonInterruptedFailure, reportNonInterruptedFailureCause } from "./errors.js"
|
|
9
|
-
import type { NonEmptyReadonlyArray } from "effect-app"
|
|
10
9
|
import { type QueueBase, QueueMeta } from "./service.js"
|
|
11
10
|
|
|
12
11
|
export function makeMemQueue<
|
|
@@ -26,8 +25,12 @@ export function makeMemQueue<
|
|
|
26
25
|
const qDrain = yield* mem.getOrCreateQueue(queueDrainName)
|
|
27
26
|
|
|
28
27
|
const wireSchema = S.Struct({ body: schema, meta: QueueMeta })
|
|
28
|
+
const wireSchemaJson = S.fromJsonString(wireSchema)
|
|
29
|
+
const encodePublish = S.encodeEffect(wireSchemaJson)
|
|
29
30
|
const drainW = S.Struct({ body: drainSchema, meta: QueueMeta })
|
|
30
|
-
const
|
|
31
|
+
const drainWJson = S.fromJsonString(drainW)
|
|
32
|
+
|
|
33
|
+
const parseDrain = flow(S.decodeUnknownEffect(drainWJson), Effect.orDie)
|
|
31
34
|
|
|
32
35
|
const queue = {
|
|
33
36
|
publish: (...messages: NonEmptyReadonlyArray<Evt>) =>
|
|
@@ -37,10 +40,8 @@ export function makeMemQueue<
|
|
|
37
40
|
Effect
|
|
38
41
|
.forEach(messages, (m) =>
|
|
39
42
|
// we JSON encode, because that is what the wire also does, and it reveals holes in e.g unknown encoders (Date->String)
|
|
40
|
-
|
|
43
|
+
encodePublish({ body: m, meta: requestContext }).pipe(
|
|
41
44
|
Effect.orDie,
|
|
42
|
-
Effect
|
|
43
|
-
.map(JSON.stringify),
|
|
44
45
|
// .tap((msg) => info("Publishing Mem Message: " + utils.inspect(msg)))
|
|
45
46
|
Effect.flatMap((_) => Q.offer(q, _))
|
|
46
47
|
), { discard: true })
|
|
@@ -58,42 +59,40 @@ export function makeMemQueue<
|
|
|
58
59
|
const reportError = reportNonInterruptedFailureCause({ name: "MemQueue.drain." + queueDrainName })
|
|
59
60
|
const processMessage = (msg: string) =>
|
|
60
61
|
// we JSON parse, because that is what the wire also does, and it reveals holes in e.g unknown encoders (Date->String)
|
|
61
|
-
|
|
62
|
-
.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"queue.name": queueDrainName,
|
|
84
|
-
"queue.sessionId": sessionId,
|
|
85
|
-
"queue.input": body
|
|
86
|
-
}
|
|
62
|
+
parseDrain(msg).pipe(
|
|
63
|
+
Effect.orDie,
|
|
64
|
+
Effect
|
|
65
|
+
.flatMap(({ body, meta }) => {
|
|
66
|
+
let effect = InfraLogger
|
|
67
|
+
.logDebug(`[${queueDrainName}] Processing incoming message`)
|
|
68
|
+
.pipe(
|
|
69
|
+
Effect.annotateLogs({ body: pretty(body), meta: pretty(meta) }),
|
|
70
|
+
Effect.andThen(handleEvent(body)),
|
|
71
|
+
silenceAndReportError,
|
|
72
|
+
(_) =>
|
|
73
|
+
setupRequestContextWithCustomSpan(
|
|
74
|
+
_,
|
|
75
|
+
meta,
|
|
76
|
+
`queue.drain: ${queueDrainName}.${body._tag}`,
|
|
77
|
+
{
|
|
78
|
+
captureStackTrace: false,
|
|
79
|
+
kind: "consumer",
|
|
80
|
+
attributes: {
|
|
81
|
+
"queue.name": queueDrainName,
|
|
82
|
+
"queue.sessionId": sessionId,
|
|
83
|
+
"queue.input": body
|
|
87
84
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
if (meta.span) {
|
|
89
|
+
effect = Effect.withParentSpan(effect, Tracer.externalSpan(meta.span))
|
|
90
|
+
}
|
|
91
|
+
return effect
|
|
92
|
+
})
|
|
93
|
+
)
|
|
94
|
+
return Q
|
|
95
|
+
.take(qDrain)
|
|
97
96
|
.pipe(
|
|
98
97
|
Effect
|
|
99
98
|
.flatMap((x) =>
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Tracer } from "effect"
|
|
2
|
-
import { Cause, Effect, flow, S } from "effect-app"
|
|
2
|
+
import { Cause, Effect, flow, type NonEmptyReadonlyArray, S } from "effect-app"
|
|
3
3
|
import type { StringId } from "effect-app/Schema"
|
|
4
4
|
import { pretty } from "effect-app/utils"
|
|
5
5
|
import { Receiver, Sender } from "../adapters/ServiceBus.js"
|
|
6
6
|
import { getRequestContext, setupRequestContextWithCustomSpan } from "../api/setupRequest.js"
|
|
7
7
|
import { InfraLogger } from "../logger.js"
|
|
8
8
|
import { reportNonInterruptedFailure, reportNonInterruptedFailureCause, reportQueueError } from "./errors.js"
|
|
9
|
-
import type { NonEmptyReadonlyArray } from "effect-app"
|
|
10
9
|
import { type QueueBase, QueueMeta } from "./service.js"
|
|
11
10
|
|
|
12
11
|
export function makeServiceBusQueue<
|
|
@@ -22,8 +21,11 @@ export function makeServiceBusQueue<
|
|
|
22
21
|
body: schema,
|
|
23
22
|
meta: QueueMeta
|
|
24
23
|
})
|
|
24
|
+
const wireSchemaJson = S.fromJsonString(wireSchema)
|
|
25
|
+
const encodePublish = S.encodeEffect(wireSchemaJson)
|
|
25
26
|
const drainW = S.Struct({ body: drainSchema, meta: QueueMeta })
|
|
26
|
-
const
|
|
27
|
+
const drainWJson = S.fromJsonString(drainW)
|
|
28
|
+
const parseDrain = flow(S.decodeUnknownEffect(drainWJson), Effect.orDie)
|
|
27
29
|
|
|
28
30
|
return Effect.gen(function*() {
|
|
29
31
|
const sender = yield* Sender
|
|
@@ -40,55 +42,51 @@ export function makeServiceBusQueue<
|
|
|
40
42
|
handleEvent: (ks: DrainEvt) => Effect.Effect<void, DrainE, DrainR>,
|
|
41
43
|
sessionId?: string
|
|
42
44
|
) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
attributes: {
|
|
74
|
-
"queue.name": receiver.name,
|
|
75
|
-
"queue.sessionId": sessionId,
|
|
76
|
-
"queue.input": body
|
|
77
|
-
}
|
|
45
|
+
function processMessage(messageBody: unknown) {
|
|
46
|
+
return parseDrain(messageBody).pipe(
|
|
47
|
+
Effect.orDie,
|
|
48
|
+
Effect
|
|
49
|
+
.flatMap(({ body, meta }) => {
|
|
50
|
+
let effect = InfraLogger
|
|
51
|
+
.logDebug(`[${receiver.name}] Processing incoming message`)
|
|
52
|
+
.pipe(
|
|
53
|
+
Effect.annotateLogs({
|
|
54
|
+
body: pretty(body),
|
|
55
|
+
meta: pretty(meta)
|
|
56
|
+
}),
|
|
57
|
+
Effect.andThen(handleEvent(body)),
|
|
58
|
+
Effect.orDie
|
|
59
|
+
)
|
|
60
|
+
// we silenceAndReportError here, so that the error is reported, and moves into the Exit.
|
|
61
|
+
.pipe(
|
|
62
|
+
silenceAndReportError,
|
|
63
|
+
(_) =>
|
|
64
|
+
setupRequestContextWithCustomSpan(
|
|
65
|
+
_,
|
|
66
|
+
meta,
|
|
67
|
+
`queue.drain: ${receiver.name}${sessionId ? `#${sessionId}` : ""}.${body._tag}`,
|
|
68
|
+
{
|
|
69
|
+
captureStackTrace: false,
|
|
70
|
+
kind: "consumer",
|
|
71
|
+
attributes: {
|
|
72
|
+
"queue.name": receiver.name,
|
|
73
|
+
"queue.sessionId": sessionId,
|
|
74
|
+
"queue.input": body
|
|
78
75
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
)
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
)
|
|
79
|
+
if (meta.span) {
|
|
80
|
+
effect = Effect.withParentSpan(effect, Tracer.externalSpan(meta.span))
|
|
81
|
+
}
|
|
82
|
+
return effect
|
|
83
|
+
}),
|
|
84
|
+
Effect
|
|
85
|
+
// we reportError here, so that we report the error only, and keep flowing
|
|
86
|
+
.tapCause(reportError),
|
|
87
|
+
// we still need to flatten the Exit.
|
|
88
|
+
Effect.flatMap((_) => _)
|
|
89
|
+
)
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
return receiver
|
|
@@ -111,17 +109,22 @@ export function makeServiceBusQueue<
|
|
|
111
109
|
getRequestContext
|
|
112
110
|
.pipe(
|
|
113
111
|
Effect.flatMap((requestContext) =>
|
|
114
|
-
Effect
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
112
|
+
Effect
|
|
113
|
+
.forEach(messages, (m) =>
|
|
114
|
+
encodePublish({
|
|
115
|
+
body: m,
|
|
116
|
+
meta: requestContext
|
|
117
|
+
})
|
|
118
|
+
.pipe(
|
|
119
|
+
Effect.orDie,
|
|
120
|
+
Effect.map((body) => ({
|
|
121
|
+
body,
|
|
122
|
+
messageId: m.id, /* correllationid: requestId */
|
|
123
|
+
contentType: "application/json",
|
|
124
|
+
sessionId: "sessionId" in m ? m.sessionId as string : undefined as unknown as string // TODO: optional
|
|
125
|
+
}))
|
|
126
|
+
))
|
|
127
|
+
.pipe(Effect.flatMap((msgs) => sender.sendMessages(msgs)))
|
|
125
128
|
),
|
|
126
129
|
Effect.withSpan("queue.publish: " + sender.name, {
|
|
127
130
|
kind: "producer",
|
package/src/RequestFiberSet.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { Effect, Fiber, FiberSet, Layer, ServiceMap, type Tracer } from "effect-app"
|
|
2
|
+
import { Effect, Fiber, FiberSet, Layer, Option, ServiceMap, type Tracer } from "effect-app"
|
|
3
3
|
import { reportRequestError, reportUnknownRequestError } from "./api/reportError.js"
|
|
4
4
|
import { InfraLogger } from "./logger.js"
|
|
5
5
|
|
|
@@ -8,8 +8,8 @@ const getRootParentSpan = Effect.gen(function*() {
|
|
|
8
8
|
Effect.catchTag("NoSuchElementError", () => Effect.succeed(null))
|
|
9
9
|
)
|
|
10
10
|
if (!span) return span
|
|
11
|
-
while (span._tag === "Span" && span.parent
|
|
12
|
-
span = span.parent
|
|
11
|
+
while (span._tag === "Span" && Option.isSome(span.parent)) {
|
|
12
|
+
span = span.parent.value
|
|
13
13
|
}
|
|
14
14
|
return span
|
|
15
15
|
})
|
package/src/Store/Cosmos.ts
CHANGED
|
@@ -328,15 +328,13 @@ function makeCosmosStore({ prefix }: StorageConfig) {
|
|
|
328
328
|
.query<M>(q, { partitionKey: mainPartitionKey })
|
|
329
329
|
.fetchAll()
|
|
330
330
|
.then(({ resources }) =>
|
|
331
|
-
resources.map((_) =>
|
|
332
|
-
(
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}) as any
|
|
339
|
-
)
|
|
331
|
+
resources.map((_) => ({
|
|
332
|
+
...pipe(
|
|
333
|
+
defaultValues,
|
|
334
|
+
Struct.pick(f.select!.filter((_) => typeof _ === "string") as never[])
|
|
335
|
+
),
|
|
336
|
+
...mapReverseId(_ as any)
|
|
337
|
+
}))
|
|
340
338
|
)
|
|
341
339
|
: container
|
|
342
340
|
.items
|
|
@@ -404,7 +402,9 @@ function makeCosmosStore({ prefix }: StorageConfig) {
|
|
|
404
402
|
Effect
|
|
405
403
|
.flatMap((x) => {
|
|
406
404
|
if (x.statusCode === 412 || x.statusCode === 404 || x.statusCode === 409) {
|
|
407
|
-
return Effect.fail(
|
|
405
|
+
return Effect.fail(
|
|
406
|
+
new OptimisticConcurrencyException({ type: name, id: e[idKey], code: x.statusCode })
|
|
407
|
+
)
|
|
408
408
|
}
|
|
409
409
|
if (x.statusCode > 299 || x.statusCode < 200) {
|
|
410
410
|
return Effect.die(
|
package/src/Store/Disk.ts
CHANGED
|
@@ -66,11 +66,10 @@ function makeDiskStoreInt<IdKey extends keyof Encoded, Encoded extends FieldValu
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// lock file for cross-process coordination during initialization
|
|
69
|
-
const lockFile = file + ".lock"
|
|
70
69
|
|
|
71
70
|
// wrap initialization in file lock to prevent race conditions in multi-worker setups
|
|
72
71
|
const store = yield* fu.withFileLock(
|
|
73
|
-
|
|
72
|
+
file,
|
|
74
73
|
Effect.gen(function*() {
|
|
75
74
|
const shouldSeed = !(fs.existsSync(file))
|
|
76
75
|
|
package/src/Store/Memory.ts
CHANGED
|
@@ -24,7 +24,7 @@ export function memFilter<T extends FieldValues, U extends keyof T = never>(f: F
|
|
|
24
24
|
)
|
|
25
25
|
const n = Struct.pick(i, keys)
|
|
26
26
|
subKeys.forEach((subKey) => {
|
|
27
|
-
n[subKey.key] = i[subKey.key]!.map(Struct.pick(subKey.subKeys))
|
|
27
|
+
n[subKey.key] = i[subKey.key]!.map(Struct.pick(subKey.subKeys as never[]))
|
|
28
28
|
})
|
|
29
29
|
return n as M
|
|
30
30
|
}) as any
|
|
@@ -72,9 +72,7 @@ export function memFilter<T extends FieldValues, U extends keyof T = never>(f: F
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const defaultNs: NonEmptyString255 = NonEmptyString255("primary")
|
|
75
|
-
export class storeId
|
|
76
|
-
extends ServiceMap.Reference("StoreId", { defaultValue: (): NonEmptyString255 => defaultNs })
|
|
77
|
-
{}
|
|
75
|
+
export class storeId extends ServiceMap.Reference("StoreId", { defaultValue: (): NonEmptyString255 => defaultNs }) {}
|
|
78
76
|
|
|
79
77
|
function logQuery(f: FilterArgs<any, any>, defaultValues?: any) {
|
|
80
78
|
return InfraLogger
|