@effect-app/infra 0.132.2 → 0.133.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/_cjs/RequestContext.cjs +23 -13
- package/_cjs/RequestContext.cjs.map +1 -1
- package/_cjs/_global.ext.cjs +7 -0
- package/_cjs/_global.ext.cjs.map +1 -1
- package/_cjs/api/codec.cjs +2 -6
- package/_cjs/api/codec.cjs.map +1 -1
- package/_cjs/api/express/schema/jwt.cjs +5 -26
- package/_cjs/api/express/schema/jwt.cjs.map +1 -1
- package/_cjs/api/setupRequest.cjs +2 -2
- package/_cjs/api/setupRequest.cjs.map +1 -1
- package/_cjs/errors.cjs +3 -1
- package/_cjs/errors.cjs.map +1 -1
- package/_cjs/services/Emailer/Sendgrid.cjs +5 -4
- package/_cjs/services/Emailer/Sendgrid.cjs.map +1 -1
- package/_cjs/services/Operations/live.cjs +12 -10
- package/_cjs/services/Operations/live.cjs.map +1 -1
- package/_cjs/services/QueueMaker/memQueue.cjs +17 -15
- package/_cjs/services/QueueMaker/memQueue.cjs.map +1 -1
- package/_cjs/services/QueueMaker/sbqueue.cjs +30 -29
- package/_cjs/services/QueueMaker/sbqueue.cjs.map +1 -1
- package/_cjs/services/QueueMaker/service.cjs +3 -3
- package/_cjs/services/QueueMaker/service.cjs.map +1 -1
- package/_cjs/services/Repository.cjs +2 -2
- package/_cjs/services/Repository.cjs.map +1 -1
- package/_cjs/services/RepositoryBase.cjs +31 -33
- package/_cjs/services/RepositoryBase.cjs.map +1 -1
- package/_cjs/services/RequestContextContainer.cjs +3 -3
- package/_cjs/services/RequestContextContainer.cjs.map +1 -1
- package/_cjs/services/Store/Cosmos.cjs +4 -4
- package/_cjs/services/Store/Cosmos.cjs.map +1 -1
- package/_cjs/services/Store/Disk.cjs +15 -13
- package/_cjs/services/Store/Disk.cjs.map +1 -1
- package/_cjs/services/Store/service.cjs +49 -40
- package/_cjs/services/Store/service.cjs.map +1 -1
- package/_cjs/services/simpledb/memdb.cjs +15 -15
- package/_cjs/services/simpledb/memdb.cjs.map +1 -1
- package/_cjs/services/simpledb/redisdb.cjs +15 -14
- package/_cjs/services/simpledb/redisdb.cjs.map +1 -1
- package/_cjs/services/simpledb/shared.cjs +3 -3
- package/_cjs/services/simpledb/shared.cjs.map +1 -1
- package/_src/RequestContext.ts +27 -28
- package/_src/_global.ext.ts +12 -4
- package/_src/_global.schema.ts +1 -1
- package/_src/api/codec.ts +3 -9
- package/_src/api/express/schema/jwt.ts +5 -32
- package/_src/api/express/schema/{routing.ts → routing.ts.bak} +10 -10
- package/_src/errors.ts +12 -5
- package/_src/services/Emailer/Sendgrid.ts +17 -14
- package/_src/services/QueueMaker/memQueue.ts +4 -3
- package/_src/services/QueueMaker/sbqueue.ts +4 -3
- package/_src/services/QueueMaker/service.ts +2 -2
- package/_src/services/Repository.ts +14 -13
- package/_src/services/RepositoryBase.ts +14 -37
- package/_src/services/Store/Cosmos.ts +23 -21
- package/_src/services/Store/Disk.ts +4 -2
- package/_src/services/Store/service.ts +59 -62
- package/_src/services/simpledb/memdb.ts +1 -2
- package/_src/services/simpledb/redisdb.ts +21 -17
- package/_src/services/simpledb/shared.ts +4 -5
- package/dist/RequestContext.d.ts +93 -77
- package/dist/RequestContext.d.ts.map +1 -1
- package/dist/RequestContext.js +24 -14
- package/dist/_global.ext.d.ts +7 -5
- package/dist/_global.ext.d.ts.map +1 -1
- package/dist/_global.ext.js +6 -2
- package/dist/_global.schema.d.ts +1 -1
- package/dist/_global.schema.d.ts.map +1 -1
- package/dist/_global.schema.js +1 -1
- package/dist/api/codec.d.ts +2 -3
- package/dist/api/codec.d.ts.map +1 -1
- package/dist/api/codec.js +3 -7
- package/dist/api/express/schema/jwt.d.ts +2 -4
- package/dist/api/express/schema/jwt.d.ts.map +1 -1
- package/dist/api/express/schema/jwt.js +5 -27
- package/dist/api/setupRequest.js +3 -3
- package/dist/errors.d.ts +6 -6
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +4 -2
- package/dist/services/Emailer/Sendgrid.d.ts +108 -108
- package/dist/services/Emailer/Sendgrid.d.ts.map +1 -1
- package/dist/services/Emailer/Sendgrid.js +6 -5
- package/dist/services/Operations/live.js +17 -15
- package/dist/services/Operations/service.d.ts +4 -4
- package/dist/services/Operations/service.d.ts.map +1 -1
- package/dist/services/QueueMaker/memQueue.d.ts +2 -2
- package/dist/services/QueueMaker/memQueue.d.ts.map +1 -1
- package/dist/services/QueueMaker/memQueue.js +17 -15
- package/dist/services/QueueMaker/sbqueue.d.ts +2 -2
- package/dist/services/QueueMaker/sbqueue.d.ts.map +1 -1
- package/dist/services/QueueMaker/sbqueue.js +26 -25
- package/dist/services/QueueMaker/service.d.ts +30 -16
- package/dist/services/QueueMaker/service.d.ts.map +1 -1
- package/dist/services/QueueMaker/service.js +4 -4
- package/dist/services/Repository.d.ts +10 -9
- package/dist/services/Repository.d.ts.map +1 -1
- package/dist/services/Repository.js +3 -3
- package/dist/services/RepositoryBase.d.ts +20 -21
- package/dist/services/RepositoryBase.d.ts.map +1 -1
- package/dist/services/RepositoryBase.js +32 -34
- package/dist/services/RequestContextContainer.d.ts +4 -4
- package/dist/services/RequestContextContainer.js +3 -3
- package/dist/services/Store/Cosmos.d.ts.map +1 -1
- package/dist/services/Store/Cosmos.js +6 -6
- package/dist/services/Store/Disk.d.ts.map +1 -1
- package/dist/services/Store/Disk.js +14 -13
- package/dist/services/Store/service.d.ts +6 -9
- package/dist/services/Store/service.d.ts.map +1 -1
- package/dist/services/Store/service.js +50 -43
- package/dist/services/simpledb/memdb.d.ts +3 -4
- package/dist/services/simpledb/memdb.d.ts.map +1 -1
- package/dist/services/simpledb/memdb.js +17 -17
- package/dist/services/simpledb/redisdb.d.ts +14 -10
- package/dist/services/simpledb/redisdb.d.ts.map +1 -1
- package/dist/services/simpledb/redisdb.js +17 -16
- package/dist/services/simpledb/shared.d.ts +24 -16
- package/dist/services/simpledb/shared.d.ts.map +1 -1
- package/dist/services/simpledb/shared.js +4 -4
- package/package.json +7 -56
- package/tsconfig.json +2 -1
- package/_cjs/api/express/makeJsonSchema.cjs +0 -151
- package/_cjs/api/express/makeJsonSchema.cjs.map +0 -1
- package/_cjs/api/express/makeJsonSchema.test.cjs +0 -50
- package/_cjs/api/express/makeJsonSchema.test.cjs.map +0 -1
- package/_cjs/api/express/makeOpenApiSpecs.cjs +0 -65
- package/_cjs/api/express/makeOpenApiSpecs.cjs.map +0 -1
- package/_cjs/api/express/schema/routing.cjs +0 -137
- package/_cjs/api/express/schema/routing.cjs.map +0 -1
- package/_cjs/api/writeDocs.cjs +0 -32
- package/_cjs/api/writeDocs.cjs.map +0 -1
- package/_cjs/test.arbs.cjs +0 -32
- package/_cjs/test.arbs.cjs.map +0 -1
- package/dist/api/express/makeJsonSchema.d.ts +0 -34
- package/dist/api/express/makeJsonSchema.d.ts.map +0 -1
- package/dist/api/express/makeJsonSchema.js +0 -131
- package/dist/api/express/makeJsonSchema.test.d.ts.map +0 -1
- package/dist/api/express/makeOpenApiSpecs.d.ts +0 -58
- package/dist/api/express/makeOpenApiSpecs.d.ts.map +0 -1
- package/dist/api/express/makeOpenApiSpecs.js +0 -55
- package/dist/api/express/schema/routing.d.ts +0 -62
- package/dist/api/express/schema/routing.d.ts.map +0 -1
- package/dist/api/express/schema/routing.js +0 -111
- package/dist/api/writeDocs.d.ts +0 -4
- package/dist/api/writeDocs.d.ts.map +0 -1
- package/dist/api/writeDocs.js +0 -24
- package/dist/test.arbs.d.ts +0 -13
- package/dist/test.arbs.d.ts.map +0 -1
- package/dist/test.arbs.js +0 -22
- /package/_src/api/express/{makeJsonSchema.test.ts → makeJsonSchema.test.ts.bak} +0 -0
- /package/_src/api/express/{makeJsonSchema.ts → makeJsonSchema.ts.bak} +0 -0
- /package/_src/api/express/{makeOpenApiSpecs.ts → makeOpenApiSpecs.ts.bak} +0 -0
- /package/_src/api/{writeDocs.ts → writeDocs.ts.bak} +0 -0
- /package/_src/{test.arbs.ts → test.arbs.ts.bak} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
|
|
3
3
|
import { CosmosClient, CosmosClientLayer } from "@effect-app/infra-adapters/cosmos-client"
|
|
4
|
-
import { omit, pick } from "@effect-app/prelude/utils"
|
|
4
|
+
import { dropUndefinedT, omit, pick } from "@effect-app/prelude/utils"
|
|
5
5
|
import { OptimisticConcurrencyException } from "../../errors.js"
|
|
6
6
|
import {
|
|
7
7
|
buildCosmosQuery,
|
|
@@ -37,12 +37,12 @@ function makeCosmosStore({ prefix }: StorageConfig) {
|
|
|
37
37
|
const containerId = `${prefix}${name}`
|
|
38
38
|
yield* $(
|
|
39
39
|
Effect.promise(() =>
|
|
40
|
-
db.containers.createIfNotExists({
|
|
40
|
+
db.containers.createIfNotExists(dropUndefinedT({
|
|
41
41
|
id: containerId,
|
|
42
42
|
uniqueKeyPolicy: config?.uniqueKeys
|
|
43
43
|
? { uniqueKeys: config.uniqueKeys }
|
|
44
44
|
: undefined
|
|
45
|
-
})
|
|
45
|
+
}))
|
|
46
46
|
)
|
|
47
47
|
)
|
|
48
48
|
const defaultValues = config?.defaultValues ?? {}
|
|
@@ -61,24 +61,26 @@ function makeCosmosStore({ prefix }: StorageConfig) {
|
|
|
61
61
|
[
|
|
62
62
|
x,
|
|
63
63
|
Option.fromNullable(x._etag).match({
|
|
64
|
-
onNone: () =>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
64
|
+
onNone: () =>
|
|
65
|
+
dropUndefinedT({
|
|
66
|
+
operationType: "Create" as const,
|
|
67
|
+
resourceBody: {
|
|
68
|
+
...omit(x, "_etag"),
|
|
69
|
+
_partitionKey: config?.partitionValue(x)
|
|
70
|
+
},
|
|
71
|
+
partitionKey: config?.partitionValue(x)
|
|
72
|
+
}),
|
|
73
|
+
onSome: (eTag) =>
|
|
74
|
+
dropUndefinedT({
|
|
75
|
+
operationType: "Replace" as const,
|
|
76
|
+
id: x.id,
|
|
77
|
+
resourceBody: {
|
|
78
|
+
...omit(x, "_etag"),
|
|
79
|
+
_partitionKey: config?.partitionValue(x)
|
|
80
|
+
},
|
|
81
|
+
ifMatch: eTag,
|
|
82
|
+
partitionKey: config?.partitionValue(x)
|
|
83
|
+
})
|
|
82
84
|
})
|
|
83
85
|
] as const
|
|
84
86
|
)
|
|
@@ -38,10 +38,12 @@ function makeDiskStoreInt<Id extends string, PM extends PersistenceModelType<Id>
|
|
|
38
38
|
(json) =>
|
|
39
39
|
fu
|
|
40
40
|
.writeTextFile(file, json)
|
|
41
|
-
.withSpan("Disk.write.writeFile [effect-app/infra/Store]"
|
|
41
|
+
.withSpan("Disk.write.writeFile [effect-app/infra/Store]", {
|
|
42
|
+
attributes: { "disk.file_size": json.length }
|
|
43
|
+
})
|
|
42
44
|
)
|
|
43
45
|
.withSpan("Disk.write [effect-app/infra/Store]", {
|
|
44
|
-
attributes: { "disk.file": file
|
|
46
|
+
attributes: { "disk.file": file }
|
|
45
47
|
})
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import type { UniqueKey } from "@azure/cosmos"
|
|
3
|
-
import type { Parser, ParserEnv } from "@effect-app/schema/custom/Parser"
|
|
4
|
-
|
|
5
|
-
import type { These } from "@effect-app/prelude/schema"
|
|
6
3
|
import type { OptimisticConcurrencyException } from "../../errors.js"
|
|
7
4
|
import type { FieldValues } from "../../filter/types.js"
|
|
8
5
|
import type { QueryBuilder } from "./filterApi/query.js"
|
|
@@ -36,8 +33,8 @@ export type Where =
|
|
|
36
33
|
|
|
37
34
|
// default is where
|
|
38
35
|
export type StoreWhereFilter = {
|
|
39
|
-
type?: "where"
|
|
40
|
-
mode?: "and" | "or" // default is and
|
|
36
|
+
type?: "where" | undefined
|
|
37
|
+
mode?: "and" | "or" | undefined // default is and
|
|
41
38
|
where: readonly [
|
|
42
39
|
Where,
|
|
43
40
|
...(Where[])
|
|
@@ -67,10 +64,10 @@ export type FilterJoinSelect = {
|
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
export interface FilterArgs<PM extends PersistenceModelType<string>, U extends keyof PM = never> {
|
|
70
|
-
filter?: Filter<PM>
|
|
71
|
-
select?: NonEmptyReadonlyArray<U>
|
|
72
|
-
limit?: number
|
|
73
|
-
skip?: number
|
|
67
|
+
filter?: Filter<PM> | undefined
|
|
68
|
+
select?: NonEmptyReadonlyArray<U> | undefined
|
|
69
|
+
limit?: number | undefined
|
|
70
|
+
skip?: number | undefined
|
|
74
71
|
}
|
|
75
72
|
|
|
76
73
|
export type FilterFunc<PM extends PersistenceModelType<string>> = <U extends keyof PM = never>(
|
|
@@ -118,61 +115,61 @@ export const makeContextMap = (): ContextMap => {
|
|
|
118
115
|
eTag === undefined ? etags.delete(id) : etags.set(id, eTag)
|
|
119
116
|
}
|
|
120
117
|
|
|
121
|
-
const parsedCache = new Map<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
>()
|
|
125
|
-
|
|
126
|
-
const parserCache = new Map<
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
>()
|
|
130
|
-
|
|
131
|
-
const setAndReturn = <I, E, A>(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
) => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const parserEnv: ParserEnv = {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
118
|
+
// const parsedCache = new Map<
|
|
119
|
+
// Parser<any, any, any>,
|
|
120
|
+
// Map<unknown, These.These<unknown, unknown>>
|
|
121
|
+
// >()
|
|
122
|
+
|
|
123
|
+
// const parserCache = new Map<
|
|
124
|
+
// Parser<any, any, any>,
|
|
125
|
+
// (i: any) => These.These<any, any>
|
|
126
|
+
// >()
|
|
127
|
+
|
|
128
|
+
// const setAndReturn = <I, E, A>(
|
|
129
|
+
// p: Parser<I, E, A>,
|
|
130
|
+
// np: (i: I) => These.These<E, A>
|
|
131
|
+
// ) => {
|
|
132
|
+
// parserCache.set(p, np)
|
|
133
|
+
// return np
|
|
134
|
+
// }
|
|
135
|
+
|
|
136
|
+
// const parserEnv: ParserEnv = {
|
|
137
|
+
// // TODO: lax: true would turn off refinement checks, may help on large payloads
|
|
138
|
+
// // but of course removes confirming of validation rules (which may be okay for a database owned by the app, as we write safely)
|
|
139
|
+
// lax: false,
|
|
140
|
+
// cache: {
|
|
141
|
+
// getOrSetParser: (p) => parserCache.get(p) ?? setAndReturn(p, (i) => parserEnv.cache!.getOrSet(i, p)),
|
|
142
|
+
// getOrSetParsers: (parsers) => {
|
|
143
|
+
// return Object.entries(parsers).reduce((prev, [k, v]) => {
|
|
144
|
+
// prev[k] = parserEnv.cache!.getOrSetParser(v)
|
|
145
|
+
// return prev
|
|
146
|
+
// }, {} as any)
|
|
147
|
+
// },
|
|
148
|
+
// getOrSet: (i, parse): any => {
|
|
149
|
+
// const c = parsedCache.get(parse)
|
|
150
|
+
// if (c) {
|
|
151
|
+
// const f = c.get(i)
|
|
152
|
+
// if (f) {
|
|
153
|
+
// // console.log("$$$ cache hit", i)
|
|
154
|
+
// return f
|
|
155
|
+
// } else {
|
|
156
|
+
// const nf = parse(i, parserEnv)
|
|
157
|
+
// c.set(i, nf)
|
|
158
|
+
// return nf
|
|
159
|
+
// }
|
|
160
|
+
// } else {
|
|
161
|
+
// const nf = parse(i, parserEnv)
|
|
162
|
+
// parsedCache.set(parse, new Map([[i, nf]]))
|
|
163
|
+
// return nf
|
|
164
|
+
// }
|
|
165
|
+
// }
|
|
166
|
+
// }
|
|
167
|
+
// }
|
|
171
168
|
|
|
172
169
|
return {
|
|
173
170
|
get: getEtag,
|
|
174
|
-
set: setEtag
|
|
175
|
-
parserEnv
|
|
171
|
+
set: setEtag
|
|
172
|
+
// parserEnv
|
|
176
173
|
}
|
|
177
174
|
}
|
|
178
175
|
|
|
@@ -188,7 +185,7 @@ export const makeMap = Effect.sync(() => makeContextMap())
|
|
|
188
185
|
export class ContextMap extends TagClass<ContextMap, {
|
|
189
186
|
get: (id: string) => string | undefined
|
|
190
187
|
set: (id: string, eTag: string | undefined) => void
|
|
191
|
-
parserEnv: ParserEnv
|
|
188
|
+
// parserEnv: ParserEnv
|
|
192
189
|
}>() {
|
|
193
190
|
}
|
|
194
191
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { flow } from "@effect-app/core/Function"
|
|
2
|
-
import * as S from "@effect-app/schema"
|
|
3
2
|
|
|
4
3
|
import type { CachedRecord, DBRecord } from "./shared.js"
|
|
5
4
|
import { getRecordName, makeMap, SerializedDBRecord } from "./shared.js"
|
|
@@ -10,7 +9,7 @@ import type { Version } from "./simpledb.js"
|
|
|
10
9
|
// Do not try this at home.
|
|
11
10
|
const storage = makeMap<string, string>()
|
|
12
11
|
|
|
13
|
-
const parseSDB = SerializedDBRecord.
|
|
12
|
+
const parseSDB = SerializedDBRecord.parse
|
|
14
13
|
|
|
15
14
|
export function createContext<TKey extends string, EA, A extends DBRecord<TKey>>() {
|
|
16
15
|
return <REncode, RDecode, EDecode>(
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
|
|
3
|
-
import { flow
|
|
3
|
+
import { flow } from "@effect-app/core/Function"
|
|
4
4
|
import { RedisClient } from "@effect-app/infra-adapters/redis-client"
|
|
5
|
-
import * as S from "@effect-app/schema"
|
|
5
|
+
import * as S from "@effect-app/prelude/schema"
|
|
6
6
|
import type { Lock } from "redlock"
|
|
7
7
|
import type { CachedRecord, DBRecord, Index } from "./shared.js"
|
|
8
8
|
import { ConnectionException, CouldNotAquireDbLockException, getIndexName, getRecordName } from "./shared.js"
|
|
@@ -29,10 +29,8 @@ export function createContext<TKey extends string, EA, A extends DBRecord<TKey>>
|
|
|
29
29
|
return RedisClient
|
|
30
30
|
.flatMap((_) => _.hmgetAll(getKey(id)))
|
|
31
31
|
.flatMapOpt((v) =>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
S.condemnFail
|
|
35
|
-
)(v)
|
|
32
|
+
RedisSerializedDBRecord
|
|
33
|
+
.parse(v)
|
|
36
34
|
.map(({ data, version }) => ({
|
|
37
35
|
data: JSON.parse(data) as EA,
|
|
38
36
|
version
|
|
@@ -57,11 +55,14 @@ export function createContext<TKey extends string, EA, A extends DBRecord<TKey>>
|
|
|
57
55
|
.zipRight(getData(record))
|
|
58
56
|
// TODO: instead use MULTI & EXEC to make it in one command?
|
|
59
57
|
.flatMap((data) =>
|
|
60
|
-
hmSetRec(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
hmSetRec(
|
|
59
|
+
getKey(record.id),
|
|
60
|
+
new RedisSerializedDBRecord({
|
|
61
|
+
version,
|
|
62
|
+
timestamp: new Date(),
|
|
63
|
+
data
|
|
64
|
+
})
|
|
65
|
+
)
|
|
65
66
|
)
|
|
66
67
|
.zipRight(setIndex(record))
|
|
67
68
|
.orDie
|
|
@@ -71,11 +72,14 @@ export function createContext<TKey extends string, EA, A extends DBRecord<TKey>>
|
|
|
71
72
|
onSome: () =>
|
|
72
73
|
getData(record)
|
|
73
74
|
.flatMap((data) =>
|
|
74
|
-
hmSetRec(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
hmSetRec(
|
|
76
|
+
getKey(record.id),
|
|
77
|
+
new RedisSerializedDBRecord({
|
|
78
|
+
version,
|
|
79
|
+
timestamp: new Date(),
|
|
80
|
+
data
|
|
81
|
+
})
|
|
82
|
+
)
|
|
79
83
|
)
|
|
80
84
|
.orDie
|
|
81
85
|
.map(() => ({ version, data: record } as CachedRecord<A>))
|
|
@@ -190,6 +194,6 @@ export function createContext<TKey extends string, EA, A extends DBRecord<TKey>>
|
|
|
190
194
|
|
|
191
195
|
export class RedisSerializedDBRecord extends S.Class<RedisSerializedDBRecord>()({
|
|
192
196
|
version: S.string,
|
|
193
|
-
timestamp: S.
|
|
197
|
+
timestamp: S.Date,
|
|
194
198
|
data: S.string
|
|
195
199
|
}) {}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import * as S from "@effect-app/schema"
|
|
2
|
-
import type { SchemaAny } from "@effect-app/schema"
|
|
1
|
+
import * as S from "@effect-app/prelude/schema"
|
|
3
2
|
|
|
4
3
|
export class CouldNotAquireDbLockException
|
|
5
4
|
extends Data.TaggedError("CouldNotAquireDbLockException")<{ type: string; id: string; error: Error; message: string }>
|
|
@@ -30,15 +29,15 @@ export interface DBRecord<TKey extends string> {
|
|
|
30
29
|
|
|
31
30
|
export class SerializedDBRecord extends S.Class<SerializedDBRecord>()({
|
|
32
31
|
version: S.string,
|
|
33
|
-
timestamp: S.
|
|
32
|
+
timestamp: S.Date,
|
|
34
33
|
data: S.string
|
|
35
34
|
}) {}
|
|
36
35
|
|
|
37
36
|
// unknown -> string -> SDB?
|
|
38
|
-
export function makeSerialisedDBRecord(s:
|
|
37
|
+
export function makeSerialisedDBRecord(s: Schema<any, any>) {
|
|
39
38
|
return S.struct({
|
|
40
39
|
version: S.number,
|
|
41
|
-
timestamp: S.
|
|
40
|
+
timestamp: S.Date,
|
|
42
41
|
data: s
|
|
43
42
|
})
|
|
44
43
|
}
|
package/dist/RequestContext.d.ts
CHANGED
|
@@ -1,87 +1,102 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
declare const RequestContextParent_base:
|
|
4
|
-
_tag:
|
|
5
|
-
id:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
userProfile: import("@effect-app/schema").Field<import("@effect-app/schema").Schema<unknown, {
|
|
11
|
-
readonly sub: UserProfileId;
|
|
12
|
-
}, {
|
|
13
|
-
readonly sub: UserProfileId;
|
|
14
|
-
}, {
|
|
1
|
+
import { TaggedClass, NonEmptyString255, FromClass } from "@effect-app/prelude/schema";
|
|
2
|
+
import { Schema2 } from "@effect-app/prelude";
|
|
3
|
+
declare const RequestContextParent_base: Schema2.Class<{
|
|
4
|
+
readonly _tag: "RequestContext";
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly locale: "en" | "de";
|
|
8
|
+
readonly createdAt: string;
|
|
9
|
+
readonly userProfile?: {
|
|
15
10
|
readonly sub: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
} | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
readonly _tag: "RequestContext";
|
|
14
|
+
readonly id: string & Schema2.StringIdBrand;
|
|
15
|
+
readonly name: string & Schema2.NonEmptyString255Brand;
|
|
16
|
+
readonly locale: "en" | "de";
|
|
17
|
+
readonly createdAt: Date;
|
|
18
|
+
readonly userProfile?: {
|
|
19
|
+
readonly sub: string & Schema2.StringIdBrand & import("@effect-app/prelude/ids").UserProfileIdBrand;
|
|
20
|
+
} | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: string & Schema2.NonEmptyString255Brand;
|
|
23
|
+
readonly locale: "en" | "de";
|
|
24
|
+
readonly userProfile?: {
|
|
25
|
+
readonly sub: string & Schema2.StringIdBrand & import("@effect-app/prelude/ids").UserProfileIdBrand;
|
|
26
|
+
} | undefined;
|
|
27
|
+
readonly id?: string & Schema2.StringIdBrand;
|
|
28
|
+
readonly createdAt?: Date;
|
|
29
|
+
}, RequestContextParent, import("effect/Data").Case>;
|
|
29
30
|
export declare class RequestContextParent extends RequestContextParent_base {
|
|
30
31
|
}
|
|
31
|
-
declare const RequestContext_base:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}>, "optional", import("effect/Option").None<any>, import("effect/Option").None<any>>;
|
|
40
|
-
namespace: import("@effect-app/schema").Field<import("@effect-app/schema").Schema<unknown, import("@effect-app/schema").NonEmptyString255, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").NonEmptyString255>>, "optional", import("effect/Option").None<any>, import("effect/Option").None<any>>;
|
|
41
|
-
_tag: import("@effect-app/schema").Field<import("@effect-app/schema").DefaultSchema<unknown, "RequestContext", "RequestContext", "RequestContext", import("@effect-app/schema").LiteralApi<["RequestContext"]>>, "required", import("effect/Option").None<any>, import("effect/Option").None<any>>;
|
|
42
|
-
name: import("@effect-app/schema").Field<import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").NonEmptyString255, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").NonEmptyString255>> & import("@effect-app/schema").Utils<import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").NonEmptyString255, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").NonEmptyString255>>>, "required", import("effect/Option").None<any>, import("effect/Option").None<any>>;
|
|
43
|
-
userProfile: import("@effect-app/schema").Field<import("@effect-app/schema").Schema<unknown, {
|
|
44
|
-
readonly sub: UserProfileId;
|
|
45
|
-
}, {
|
|
46
|
-
readonly sub: UserProfileId;
|
|
47
|
-
}, {
|
|
32
|
+
declare const RequestContext_base: Schema2.Class<{
|
|
33
|
+
readonly _tag: "RequestContext";
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly rootId: string;
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly locale: "en" | "de";
|
|
38
|
+
readonly createdAt: string;
|
|
39
|
+
readonly userProfile?: {
|
|
48
40
|
readonly sub: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
41
|
+
} | undefined;
|
|
42
|
+
readonly parent?: {
|
|
43
|
+
readonly _tag: "RequestContext";
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly locale: "en" | "de";
|
|
47
|
+
readonly createdAt: string;
|
|
48
|
+
readonly userProfile?: {
|
|
49
|
+
readonly sub: string;
|
|
50
|
+
} | undefined;
|
|
51
|
+
} | undefined;
|
|
52
|
+
readonly namespace?: string | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
readonly _tag: "RequestContext";
|
|
55
|
+
readonly id: Schema2.StringId;
|
|
56
|
+
readonly rootId: string & Schema2.StringIdBrand;
|
|
57
|
+
readonly name: string & Schema2.NonEmptyString255Brand;
|
|
58
|
+
readonly locale: "en" | "de";
|
|
59
|
+
readonly createdAt: Date;
|
|
60
|
+
readonly userProfile?: {
|
|
61
|
+
readonly sub: string & Schema2.StringIdBrand & import("@effect-app/prelude/ids").UserProfileIdBrand;
|
|
62
|
+
} | undefined;
|
|
63
|
+
readonly parent?: RequestContextParent | undefined;
|
|
64
|
+
readonly namespace?: (string & Schema2.NonEmptyString255Brand) | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: string & Schema2.NonEmptyString255Brand;
|
|
67
|
+
readonly locale: "en" | "de";
|
|
68
|
+
readonly userProfile?: {
|
|
69
|
+
readonly sub: string & Schema2.StringIdBrand & import("@effect-app/prelude/ids").UserProfileIdBrand;
|
|
70
|
+
} | undefined;
|
|
71
|
+
readonly parent?: RequestContextParent | undefined;
|
|
72
|
+
readonly namespace?: (string & Schema2.NonEmptyString255Brand) | undefined;
|
|
73
|
+
readonly id?: Schema2.StringId;
|
|
74
|
+
readonly rootId?: string & Schema2.StringIdBrand;
|
|
75
|
+
readonly createdAt?: Date;
|
|
76
|
+
}, RequestContext, import("effect/Data").Case>;
|
|
62
77
|
/**
|
|
63
78
|
* @tsplus type RequestContext
|
|
64
79
|
* @tsplus companion RequestContext.Ops
|
|
65
80
|
*/
|
|
66
81
|
export declare class RequestContext extends RequestContext_base {
|
|
67
|
-
static inherit(this: void, parent: RequestContext, newSelf: RequestContextParent
|
|
82
|
+
static inherit(this: void, parent: RequestContext, newSelf: ConstructorParameters<typeof RequestContextParent>[0]): RequestContext;
|
|
68
83
|
static toMonitoring(this: void, self: RequestContext): {
|
|
69
|
-
parentOperationName?:
|
|
70
|
-
parentLocale?: "en" | "de"
|
|
71
|
-
operationName:
|
|
84
|
+
parentOperationName?: string & Schema2.NonEmptyString255Brand;
|
|
85
|
+
parentLocale?: "en" | "de";
|
|
86
|
+
operationName: string & Schema2.NonEmptyString255Brand;
|
|
72
87
|
locale: "en" | "de";
|
|
73
88
|
};
|
|
74
89
|
}
|
|
75
90
|
export declare namespace RequestContextParent {
|
|
76
|
-
const From_base:
|
|
91
|
+
const From_base: Schema2.FromClass<{
|
|
77
92
|
readonly _tag: "RequestContext";
|
|
78
93
|
readonly id: string;
|
|
79
94
|
readonly name: string;
|
|
95
|
+
readonly locale: "en" | "de";
|
|
96
|
+
readonly createdAt: string;
|
|
80
97
|
readonly userProfile?: {
|
|
81
98
|
readonly sub: string;
|
|
82
99
|
} | undefined;
|
|
83
|
-
readonly locale: "en" | "de";
|
|
84
|
-
readonly createdAt: string;
|
|
85
100
|
}>;
|
|
86
101
|
/**
|
|
87
102
|
* @tsplus type RequestContextParent.From
|
|
@@ -89,24 +104,29 @@ export declare namespace RequestContextParent {
|
|
|
89
104
|
*/
|
|
90
105
|
export class From extends From_base {
|
|
91
106
|
}
|
|
92
|
-
export interface ConstructorInput extends ConstructorInputApi<typeof RequestContextParent> {
|
|
93
|
-
}
|
|
94
|
-
export interface Fields extends FieldsClass<typeof RequestContextParent> {
|
|
95
|
-
}
|
|
96
107
|
export {};
|
|
97
108
|
}
|
|
98
109
|
export declare namespace RequestContext {
|
|
99
|
-
const From_base_1:
|
|
110
|
+
const From_base_1: Schema2.FromClass<{
|
|
100
111
|
readonly _tag: "RequestContext";
|
|
101
112
|
readonly id: string;
|
|
113
|
+
readonly rootId: string;
|
|
102
114
|
readonly name: string;
|
|
115
|
+
readonly locale: "en" | "de";
|
|
116
|
+
readonly createdAt: string;
|
|
103
117
|
readonly userProfile?: {
|
|
104
118
|
readonly sub: string;
|
|
105
119
|
} | undefined;
|
|
106
|
-
readonly
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
120
|
+
readonly parent?: {
|
|
121
|
+
readonly _tag: "RequestContext";
|
|
122
|
+
readonly id: string;
|
|
123
|
+
readonly name: string;
|
|
124
|
+
readonly locale: "en" | "de";
|
|
125
|
+
readonly createdAt: string;
|
|
126
|
+
readonly userProfile?: {
|
|
127
|
+
readonly sub: string;
|
|
128
|
+
} | undefined;
|
|
129
|
+
} | undefined;
|
|
110
130
|
readonly namespace?: string | undefined;
|
|
111
131
|
}>;
|
|
112
132
|
/**
|
|
@@ -115,10 +135,6 @@ export declare namespace RequestContext {
|
|
|
115
135
|
*/
|
|
116
136
|
export class From extends From_base_1 {
|
|
117
137
|
}
|
|
118
|
-
export interface ConstructorInput extends ConstructorInputApi<typeof RequestContext> {
|
|
119
|
-
}
|
|
120
|
-
export interface Fields extends FieldsClass<typeof RequestContext> {
|
|
121
|
-
}
|
|
122
138
|
export {};
|
|
123
139
|
}
|
|
124
140
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestContext.d.ts","sourceRoot":"","sources":["../_src/RequestContext.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"RequestContext.d.ts","sourceRoot":"","sources":["../_src/RequestContext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAW7C,qBACa,oBAAqB,SAAQ,yBAKxC;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL;;;GAGG;AACH,qBACa,cAAe,SAAQ,mBAclC;IACA,MAAM,CAAC,OAAO,CACZ,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,qBAAqB,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAUhE,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc;;;;;;CASrD;AAKD,yBAAiB,oBAAoB,CAAC;;;;;;;;;;;IACpC;;;OAGG;IACH,MAAM,OAAO,IAAK,SAAQ,SAAwC;KAAG;;CACtE;AACD,yBAAiB,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;IAC9B;;;OAGG;IACH,MAAM,OAAO,IAAK,SAAQ,WAAkC;KAAG;;CAChE"}
|