@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.
Files changed (153) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/_cjs/RequestContext.cjs +23 -13
  3. package/_cjs/RequestContext.cjs.map +1 -1
  4. package/_cjs/_global.ext.cjs +7 -0
  5. package/_cjs/_global.ext.cjs.map +1 -1
  6. package/_cjs/api/codec.cjs +2 -6
  7. package/_cjs/api/codec.cjs.map +1 -1
  8. package/_cjs/api/express/schema/jwt.cjs +5 -26
  9. package/_cjs/api/express/schema/jwt.cjs.map +1 -1
  10. package/_cjs/api/setupRequest.cjs +2 -2
  11. package/_cjs/api/setupRequest.cjs.map +1 -1
  12. package/_cjs/errors.cjs +3 -1
  13. package/_cjs/errors.cjs.map +1 -1
  14. package/_cjs/services/Emailer/Sendgrid.cjs +5 -4
  15. package/_cjs/services/Emailer/Sendgrid.cjs.map +1 -1
  16. package/_cjs/services/Operations/live.cjs +12 -10
  17. package/_cjs/services/Operations/live.cjs.map +1 -1
  18. package/_cjs/services/QueueMaker/memQueue.cjs +17 -15
  19. package/_cjs/services/QueueMaker/memQueue.cjs.map +1 -1
  20. package/_cjs/services/QueueMaker/sbqueue.cjs +30 -29
  21. package/_cjs/services/QueueMaker/sbqueue.cjs.map +1 -1
  22. package/_cjs/services/QueueMaker/service.cjs +3 -3
  23. package/_cjs/services/QueueMaker/service.cjs.map +1 -1
  24. package/_cjs/services/Repository.cjs +2 -2
  25. package/_cjs/services/Repository.cjs.map +1 -1
  26. package/_cjs/services/RepositoryBase.cjs +31 -33
  27. package/_cjs/services/RepositoryBase.cjs.map +1 -1
  28. package/_cjs/services/RequestContextContainer.cjs +3 -3
  29. package/_cjs/services/RequestContextContainer.cjs.map +1 -1
  30. package/_cjs/services/Store/Cosmos.cjs +4 -4
  31. package/_cjs/services/Store/Cosmos.cjs.map +1 -1
  32. package/_cjs/services/Store/Disk.cjs +15 -13
  33. package/_cjs/services/Store/Disk.cjs.map +1 -1
  34. package/_cjs/services/Store/service.cjs +49 -40
  35. package/_cjs/services/Store/service.cjs.map +1 -1
  36. package/_cjs/services/simpledb/memdb.cjs +15 -15
  37. package/_cjs/services/simpledb/memdb.cjs.map +1 -1
  38. package/_cjs/services/simpledb/redisdb.cjs +15 -14
  39. package/_cjs/services/simpledb/redisdb.cjs.map +1 -1
  40. package/_cjs/services/simpledb/shared.cjs +3 -3
  41. package/_cjs/services/simpledb/shared.cjs.map +1 -1
  42. package/_src/RequestContext.ts +27 -28
  43. package/_src/_global.ext.ts +12 -4
  44. package/_src/_global.schema.ts +1 -1
  45. package/_src/api/codec.ts +3 -9
  46. package/_src/api/express/schema/jwt.ts +5 -32
  47. package/_src/api/express/schema/{routing.ts → routing.ts.bak} +10 -10
  48. package/_src/errors.ts +12 -5
  49. package/_src/services/Emailer/Sendgrid.ts +17 -14
  50. package/_src/services/QueueMaker/memQueue.ts +4 -3
  51. package/_src/services/QueueMaker/sbqueue.ts +4 -3
  52. package/_src/services/QueueMaker/service.ts +2 -2
  53. package/_src/services/Repository.ts +14 -13
  54. package/_src/services/RepositoryBase.ts +14 -37
  55. package/_src/services/Store/Cosmos.ts +23 -21
  56. package/_src/services/Store/Disk.ts +4 -2
  57. package/_src/services/Store/service.ts +59 -62
  58. package/_src/services/simpledb/memdb.ts +1 -2
  59. package/_src/services/simpledb/redisdb.ts +21 -17
  60. package/_src/services/simpledb/shared.ts +4 -5
  61. package/dist/RequestContext.d.ts +93 -77
  62. package/dist/RequestContext.d.ts.map +1 -1
  63. package/dist/RequestContext.js +24 -14
  64. package/dist/_global.ext.d.ts +7 -5
  65. package/dist/_global.ext.d.ts.map +1 -1
  66. package/dist/_global.ext.js +6 -2
  67. package/dist/_global.schema.d.ts +1 -1
  68. package/dist/_global.schema.d.ts.map +1 -1
  69. package/dist/_global.schema.js +1 -1
  70. package/dist/api/codec.d.ts +2 -3
  71. package/dist/api/codec.d.ts.map +1 -1
  72. package/dist/api/codec.js +3 -7
  73. package/dist/api/express/schema/jwt.d.ts +2 -4
  74. package/dist/api/express/schema/jwt.d.ts.map +1 -1
  75. package/dist/api/express/schema/jwt.js +5 -27
  76. package/dist/api/setupRequest.js +3 -3
  77. package/dist/errors.d.ts +6 -6
  78. package/dist/errors.d.ts.map +1 -1
  79. package/dist/errors.js +4 -2
  80. package/dist/services/Emailer/Sendgrid.d.ts +108 -108
  81. package/dist/services/Emailer/Sendgrid.d.ts.map +1 -1
  82. package/dist/services/Emailer/Sendgrid.js +6 -5
  83. package/dist/services/Operations/live.js +17 -15
  84. package/dist/services/Operations/service.d.ts +4 -4
  85. package/dist/services/Operations/service.d.ts.map +1 -1
  86. package/dist/services/QueueMaker/memQueue.d.ts +2 -2
  87. package/dist/services/QueueMaker/memQueue.d.ts.map +1 -1
  88. package/dist/services/QueueMaker/memQueue.js +17 -15
  89. package/dist/services/QueueMaker/sbqueue.d.ts +2 -2
  90. package/dist/services/QueueMaker/sbqueue.d.ts.map +1 -1
  91. package/dist/services/QueueMaker/sbqueue.js +26 -25
  92. package/dist/services/QueueMaker/service.d.ts +30 -16
  93. package/dist/services/QueueMaker/service.d.ts.map +1 -1
  94. package/dist/services/QueueMaker/service.js +4 -4
  95. package/dist/services/Repository.d.ts +10 -9
  96. package/dist/services/Repository.d.ts.map +1 -1
  97. package/dist/services/Repository.js +3 -3
  98. package/dist/services/RepositoryBase.d.ts +20 -21
  99. package/dist/services/RepositoryBase.d.ts.map +1 -1
  100. package/dist/services/RepositoryBase.js +32 -34
  101. package/dist/services/RequestContextContainer.d.ts +4 -4
  102. package/dist/services/RequestContextContainer.js +3 -3
  103. package/dist/services/Store/Cosmos.d.ts.map +1 -1
  104. package/dist/services/Store/Cosmos.js +6 -6
  105. package/dist/services/Store/Disk.d.ts.map +1 -1
  106. package/dist/services/Store/Disk.js +14 -13
  107. package/dist/services/Store/service.d.ts +6 -9
  108. package/dist/services/Store/service.d.ts.map +1 -1
  109. package/dist/services/Store/service.js +50 -43
  110. package/dist/services/simpledb/memdb.d.ts +3 -4
  111. package/dist/services/simpledb/memdb.d.ts.map +1 -1
  112. package/dist/services/simpledb/memdb.js +17 -17
  113. package/dist/services/simpledb/redisdb.d.ts +14 -10
  114. package/dist/services/simpledb/redisdb.d.ts.map +1 -1
  115. package/dist/services/simpledb/redisdb.js +17 -16
  116. package/dist/services/simpledb/shared.d.ts +24 -16
  117. package/dist/services/simpledb/shared.d.ts.map +1 -1
  118. package/dist/services/simpledb/shared.js +4 -4
  119. package/package.json +7 -56
  120. package/tsconfig.json +2 -1
  121. package/_cjs/api/express/makeJsonSchema.cjs +0 -151
  122. package/_cjs/api/express/makeJsonSchema.cjs.map +0 -1
  123. package/_cjs/api/express/makeJsonSchema.test.cjs +0 -50
  124. package/_cjs/api/express/makeJsonSchema.test.cjs.map +0 -1
  125. package/_cjs/api/express/makeOpenApiSpecs.cjs +0 -65
  126. package/_cjs/api/express/makeOpenApiSpecs.cjs.map +0 -1
  127. package/_cjs/api/express/schema/routing.cjs +0 -137
  128. package/_cjs/api/express/schema/routing.cjs.map +0 -1
  129. package/_cjs/api/writeDocs.cjs +0 -32
  130. package/_cjs/api/writeDocs.cjs.map +0 -1
  131. package/_cjs/test.arbs.cjs +0 -32
  132. package/_cjs/test.arbs.cjs.map +0 -1
  133. package/dist/api/express/makeJsonSchema.d.ts +0 -34
  134. package/dist/api/express/makeJsonSchema.d.ts.map +0 -1
  135. package/dist/api/express/makeJsonSchema.js +0 -131
  136. package/dist/api/express/makeJsonSchema.test.d.ts.map +0 -1
  137. package/dist/api/express/makeOpenApiSpecs.d.ts +0 -58
  138. package/dist/api/express/makeOpenApiSpecs.d.ts.map +0 -1
  139. package/dist/api/express/makeOpenApiSpecs.js +0 -55
  140. package/dist/api/express/schema/routing.d.ts +0 -62
  141. package/dist/api/express/schema/routing.d.ts.map +0 -1
  142. package/dist/api/express/schema/routing.js +0 -111
  143. package/dist/api/writeDocs.d.ts +0 -4
  144. package/dist/api/writeDocs.d.ts.map +0 -1
  145. package/dist/api/writeDocs.js +0 -24
  146. package/dist/test.arbs.d.ts +0 -13
  147. package/dist/test.arbs.d.ts.map +0 -1
  148. package/dist/test.arbs.js +0 -22
  149. /package/_src/api/express/{makeJsonSchema.test.ts → makeJsonSchema.test.ts.bak} +0 -0
  150. /package/_src/api/express/{makeJsonSchema.ts → makeJsonSchema.ts.bak} +0 -0
  151. /package/_src/api/express/{makeOpenApiSpecs.ts → makeOpenApiSpecs.ts.bak} +0 -0
  152. /package/_src/api/{writeDocs.ts → writeDocs.ts.bak} +0 -0
  153. /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
- operationType: "Create" as const,
66
- resourceBody: {
67
- ...omit(x, "_etag"),
68
- _partitionKey: config?.partitionValue(x)
69
- } as any,
70
- partitionKey: config?.partitionValue(x)
71
- }),
72
- onSome: (eTag) => ({
73
- operationType: "Replace" as const,
74
- id: x.id,
75
- resourceBody: {
76
- ...omit(x, "_etag"),
77
- _partitionKey: config?.partitionValue(x)
78
- } as any,
79
- ifMatch: eTag,
80
- partitionKey: config?.partitionValue(x)
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, "disk.file_size": json.length }
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
- Parser<any, any, any>,
123
- Map<unknown, These.These<unknown, unknown>>
124
- >()
125
-
126
- const parserCache = new Map<
127
- Parser<any, any, any>,
128
- (i: any) => These.These<any, any>
129
- >()
130
-
131
- const setAndReturn = <I, E, A>(
132
- p: Parser<I, E, A>,
133
- np: (i: I) => These.These<E, A>
134
- ) => {
135
- parserCache.set(p, np)
136
- return np
137
- }
138
-
139
- const parserEnv: ParserEnv = {
140
- // TODO: lax: true would turn off refinement checks, may help on large payloads
141
- // but of course removes confirming of validation rules (which may be okay for a database owned by the app, as we write safely)
142
- lax: false,
143
- cache: {
144
- getOrSetParser: (p) => parserCache.get(p) ?? setAndReturn(p, (i) => parserEnv.cache!.getOrSet(i, p)),
145
- getOrSetParsers: (parsers) => {
146
- return Object.entries(parsers).reduce((prev, [k, v]) => {
147
- prev[k] = parserEnv.cache!.getOrSetParser(v)
148
- return prev
149
- }, {} as any)
150
- },
151
- getOrSet: (i, parse): any => {
152
- const c = parsedCache.get(parse)
153
- if (c) {
154
- const f = c.get(i)
155
- if (f) {
156
- // console.log("$$$ cache hit", i)
157
- return f
158
- } else {
159
- const nf = parse(i, parserEnv)
160
- c.set(i, nf)
161
- return nf
162
- }
163
- } else {
164
- const nf = parse(i, parserEnv)
165
- parsedCache.set(parse, new Map([[i, nf]]))
166
- return nf
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.Parser >= S.condemnFail
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, pipe } from "@effect-app/core/Function"
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
- pipe(
33
- RedisSerializedDBRecord.Parser,
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(getKey(record.id), {
61
- version,
62
- timestamp: new Date(),
63
- data
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(getKey(record.id), {
75
- version,
76
- timestamp: new Date(),
77
- data
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.date,
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.date,
32
+ timestamp: S.Date,
34
33
  data: S.string
35
34
  }) {}
36
35
 
37
36
  // unknown -> string -> SDB?
38
- export function makeSerialisedDBRecord(s: SchemaAny) {
37
+ export function makeSerialisedDBRecord(s: Schema<any, any>) {
39
38
  return S.struct({
40
39
  version: S.number,
41
- timestamp: S.date,
40
+ timestamp: S.Date,
42
41
  data: s
43
42
  })
44
43
  }
@@ -1,87 +1,102 @@
1
- import { useClassFeaturesForSchema, ExtendedClass, literal, NonEmptyString255, struct, date, FromClass, ConstructorInputApi, FieldsClass } from "@effect-app/prelude/schema";
2
- import { UserProfileId } from "@effect-app/prelude/ids";
3
- declare const RequestContextParent_base: import("@effect-app/schema").ExtendedClass<import("@effect-app/schema").SchemaProperties<import("@effect-app/schema").ToProps<{
4
- _tag: import("@effect-app/schema").DefaultSchema<unknown, "RequestContext", "RequestContext", "RequestContext", import("@effect-app/schema").LiteralApi<["RequestContext"]>>;
5
- id: import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").NonEmptyString50, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").NonEmptyString255> & import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").NonEmptyString50>> & import("@effect-app/schema").Utils<import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").NonEmptyString50, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").NonEmptyString255> & import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").NonEmptyString50>>> & {
6
- withDefault: import("@effect-app/schema").Field<import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").NonEmptyString50, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").NonEmptyString50>>, "required", import("effect/Option").None<any>, import("effect/Option").Some<["constructor", () => import("@effect-app/schema").NonEmptyString50]>>;
7
- make: () => import("@effect-app/prelude/schema").StringId;
8
- };
9
- name: 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>>>;
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
- fields: import("@effect-app/schema").ToProps<{
18
- sub: import("@effect-app/schema").SchemaDefaultSchema<unknown, UserProfileId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<UserProfileId>> & import("@effect-app/schema").Utils<import("@effect-app/schema").SchemaDefaultSchema<unknown, UserProfileId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<UserProfileId>>> & {
19
- EParser: import("@effect-app/schema/custom/_parser").Parser<string, any, UserProfileId>;
20
- make: () => UserProfileId;
21
- eq: import("effect/Equivalence").Equivalence<UserProfileId>;
22
- withDefault: import("@effect-app/schema").Field<import("@effect-app/schema").SchemaDefaultSchema<unknown, UserProfileId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<UserProfileId>>, "required", import("effect/Option").None<any>, import("effect/Option").Some<["constructor", () => UserProfileId]>>;
23
- };
24
- }>;
25
- }>, "optional", import("effect/Option").None<any>, import("effect/Option").None<any>>;
26
- locale: import("@effect-app/schema").DefaultSchema<unknown, "en" | "de", "en" | "de", "en" | "de", import("@effect-app/schema").LiteralApi<["en", "de"]>>;
27
- createdAt: import("@effect-app/schema").SpecificField<import("@effect-app/schema").Schema<unknown, Date, Date, string, {}>, "required", import("effect/Option").None<any>, import("effect/Option").Some<["constructor", () => Date]>>;
28
- }>>, RequestContextParent, RequestContextParent.ConstructorInput, RequestContextParent.From, RequestContextParent.Fields> & import("@effect-app/schema").PropsExtensions<RequestContextParent.Fields>;
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: import("@effect-app/schema").ExtendedClass<import("@effect-app/schema").SchemaProperties<import("@effect-app/schema").ToProps<{
32
- id: import("@effect-app/schema").Field<import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").NonEmptyString50, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").NonEmptyString50>>, "required", import("effect/Option").None<any>, import("effect/Option").Some<["constructor", () => import("@effect-app/schema").NonEmptyString50]>>;
33
- rootId: import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").NonEmptyString50, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").NonEmptyString255> & import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").NonEmptyString50>> & import("@effect-app/schema").Utils<import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").NonEmptyString50, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").NonEmptyString255> & import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").NonEmptyString50>>> & {
34
- withDefault: import("@effect-app/schema").Field<import("@effect-app/schema").SchemaDefaultSchema<unknown, import("@effect-app/schema").NonEmptyString50, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/schema").NonEmptyString50>>, "required", import("effect/Option").None<any>, import("effect/Option").Some<["constructor", () => import("@effect-app/schema").NonEmptyString50]>>;
35
- make: () => import("@effect-app/prelude/schema").StringId;
36
- };
37
- parent: import("@effect-app/schema").Field<import("@effect-app/schema").Schema<unknown, RequestContextParent, RequestContextParent.ConstructorInput, RequestContextParent.From, {
38
- fields: RequestContextParent.Fields;
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
- fields: import("@effect-app/schema").ToProps<{
51
- sub: import("@effect-app/schema").SchemaDefaultSchema<unknown, UserProfileId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<UserProfileId>> & import("@effect-app/schema").Utils<import("@effect-app/schema").SchemaDefaultSchema<unknown, UserProfileId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<UserProfileId>>> & {
52
- EParser: import("@effect-app/schema/custom/_parser").Parser<string, any, UserProfileId>;
53
- make: () => UserProfileId;
54
- eq: import("effect/Equivalence").Equivalence<UserProfileId>;
55
- withDefault: import("@effect-app/schema").Field<import("@effect-app/schema").SchemaDefaultSchema<unknown, UserProfileId, string, string, import("@effect-app/schema").ApiSelfType<import("@effect-app/prelude/schema").StringId> & import("@effect-app/schema").ApiSelfType<UserProfileId>>, "required", import("effect/Option").None<any>, import("effect/Option").Some<["constructor", () => UserProfileId]>>;
56
- };
57
- }>;
58
- }>, "optional", import("effect/Option").None<any>, import("effect/Option").None<any>>;
59
- locale: import("@effect-app/schema").Field<import("@effect-app/schema").DefaultSchema<unknown, "en" | "de", "en" | "de", "en" | "de", import("@effect-app/schema").LiteralApi<["en", "de"]>>, "required", import("effect/Option").None<any>, import("effect/Option").None<any>>;
60
- createdAt: import("@effect-app/schema").SpecificField<import("@effect-app/schema").Schema<unknown, Date, Date, string, {}>, "required", import("effect/Option").None<any>, import("effect/Option").Some<["constructor", () => Date]>>;
61
- }>>, RequestContext, RequestContext.ConstructorInput, RequestContext.From, RequestContext.Fields> & import("@effect-app/schema").PropsExtensions<RequestContext.Fields>;
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.ConstructorInput): RequestContext;
82
+ static inherit(this: void, parent: RequestContext, newSelf: ConstructorParameters<typeof RequestContextParent>[0]): RequestContext;
68
83
  static toMonitoring(this: void, self: RequestContext): {
69
- parentOperationName?: import("@effect-app/schema").NonEmptyString255 | undefined;
70
- parentLocale?: "en" | "de" | undefined;
71
- operationName: import("@effect-app/schema").NonEmptyString255;
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: import("@effect-app/schema").FromClass<{
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: import("@effect-app/schema").FromClass<{
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 locale: "en" | "de";
107
- readonly createdAt: string;
108
- readonly rootId: string;
109
- readonly parent?: RequestContextParent.From | undefined;
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,EAAa,aAAa,EAAE,MAAM,yBAAyB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElE,qBACa,oBAAqB,SAAQ,yBAYxC;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL;;;GAGG;AACH,qBACa,cAAe,SAAQ,mBAWlC;IACA,MAAM,CAAC,OAAO,CACZ,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,oBAAoB,CAAC,gBAAgB;IAUhD,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;IACrE,MAAM,WAAW,gBACf,SAAQ,mBAAmB,CAAC,OAAO,oBAAoB,CAAC;KAAG;IAC7D,MAAM,WAAW,MAAO,SAAQ,WAAW,CAAC,OAAO,oBAAoB,CAAC;KAAG;;CAC5E;AACD,yBAAiB,cAAc,CAAC;;;;;;;;;;;;;;IAC9B;;;OAGG;IACH,MAAM,OAAO,IAAK,SAAQ,WAAkC;KAAG;IAC/D,MAAM,WAAW,gBACf,SAAQ,mBAAmB,CAAC,OAAO,cAAc,CAAC;KAAG;IACvD,MAAM,WAAW,MAAO,SAAQ,WAAW,CAAC,OAAO,cAAc,CAAC;KAAG;;CACtE"}
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"}