@effect-app/infra 4.0.0-beta.13 → 4.0.0-beta.131
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 +864 -0
- package/dist/CUPS.d.ts +13 -5
- package/dist/CUPS.d.ts.map +1 -1
- package/dist/CUPS.js +10 -12
- package/dist/Emailer/service.d.ts +2 -2
- package/dist/Emailer/service.d.ts.map +1 -1
- package/dist/Emailer/service.js +3 -3
- package/dist/MainFiberSet.d.ts +2 -2
- package/dist/MainFiberSet.d.ts.map +1 -1
- package/dist/MainFiberSet.js +3 -3
- package/dist/Model/Repository/Registry.d.ts +20 -0
- package/dist/Model/Repository/Registry.d.ts.map +1 -0
- package/dist/Model/Repository/Registry.js +17 -0
- package/dist/Model/Repository/ext.d.ts +21 -3
- package/dist/Model/Repository/ext.d.ts.map +1 -1
- package/dist/Model/Repository/ext.js +54 -2
- package/dist/Model/Repository/internal/internal.d.ts +4 -4
- package/dist/Model/Repository/internal/internal.d.ts.map +1 -1
- package/dist/Model/Repository/internal/internal.js +31 -21
- package/dist/Model/Repository/makeRepo.d.ts +6 -5
- package/dist/Model/Repository/makeRepo.d.ts.map +1 -1
- package/dist/Model/Repository/makeRepo.js +4 -1
- package/dist/Model/Repository/service.d.ts +27 -22
- package/dist/Model/Repository/service.d.ts.map +1 -1
- package/dist/Model/Repository/validation.d.ts +59 -9
- package/dist/Model/Repository/validation.d.ts.map +1 -1
- package/dist/Model/Repository.d.ts +1 -0
- package/dist/Model/Repository.d.ts.map +1 -1
- package/dist/Model/Repository.js +2 -1
- package/dist/Model/query/new-kid-interpreter.d.ts.map +1 -1
- package/dist/Model/query/new-kid-interpreter.js +3 -3
- package/dist/Model.d.ts +1 -0
- package/dist/Model.d.ts.map +1 -1
- package/dist/Model.js +2 -1
- package/dist/Operations.d.ts +4 -4
- package/dist/Operations.d.ts.map +1 -1
- package/dist/Operations.js +56 -59
- package/dist/OperationsRepo.d.ts +4 -4
- package/dist/OperationsRepo.d.ts.map +1 -1
- package/dist/OperationsRepo.js +3 -3
- package/dist/QueueMaker/SQLQueue.d.ts +3 -6
- package/dist/QueueMaker/SQLQueue.d.ts.map +1 -1
- package/dist/QueueMaker/SQLQueue.js +105 -114
- package/dist/QueueMaker/errors.d.ts +1 -1
- package/dist/QueueMaker/errors.d.ts.map +1 -1
- package/dist/QueueMaker/memQueue.d.ts +6 -3
- package/dist/QueueMaker/memQueue.d.ts.map +1 -1
- package/dist/QueueMaker/memQueue.js +51 -62
- package/dist/QueueMaker/sbqueue.d.ts +5 -2
- package/dist/QueueMaker/sbqueue.d.ts.map +1 -1
- package/dist/QueueMaker/sbqueue.js +36 -52
- package/dist/RequestContext.d.ts +51 -21
- package/dist/RequestContext.d.ts.map +1 -1
- package/dist/RequestContext.js +5 -5
- package/dist/RequestFiberSet.d.ts +2 -2
- package/dist/RequestFiberSet.d.ts.map +1 -1
- package/dist/RequestFiberSet.js +5 -5
- package/dist/Store/ContextMapContainer.d.ts +18 -2
- package/dist/Store/ContextMapContainer.d.ts.map +1 -1
- package/dist/Store/ContextMapContainer.js +13 -3
- package/dist/Store/Cosmos.d.ts.map +1 -1
- package/dist/Store/Cosmos.js +308 -242
- package/dist/Store/Disk.d.ts +1 -1
- package/dist/Store/Disk.d.ts.map +1 -1
- package/dist/Store/Disk.js +25 -22
- package/dist/Store/Memory.d.ts +3 -3
- package/dist/Store/Memory.d.ts.map +1 -1
- package/dist/Store/Memory.js +27 -22
- package/dist/Store/SQL/Pg.d.ts +4 -0
- package/dist/Store/SQL/Pg.d.ts.map +1 -0
- package/dist/Store/SQL/Pg.js +189 -0
- package/dist/Store/SQL/query.d.ts +38 -0
- package/dist/Store/SQL/query.d.ts.map +1 -0
- package/dist/Store/SQL/query.js +367 -0
- package/dist/Store/SQL.d.ts +20 -0
- package/dist/Store/SQL.d.ts.map +1 -0
- package/dist/Store/SQL.js +381 -0
- package/dist/Store/index.d.ts +4 -1
- package/dist/Store/index.d.ts.map +1 -1
- package/dist/Store/index.js +15 -3
- package/dist/Store/service.d.ts +16 -5
- package/dist/Store/service.d.ts.map +1 -1
- package/dist/Store/service.js +24 -6
- package/dist/Store/utils.d.ts.map +1 -1
- package/dist/Store/utils.js +3 -4
- package/dist/adapters/ServiceBus.d.ts +6 -6
- package/dist/adapters/ServiceBus.d.ts.map +1 -1
- package/dist/adapters/ServiceBus.js +13 -15
- package/dist/adapters/cosmos-client.d.ts +2 -2
- package/dist/adapters/cosmos-client.d.ts.map +1 -1
- package/dist/adapters/cosmos-client.js +3 -3
- package/dist/adapters/logger.d.ts.map +1 -1
- package/dist/adapters/memQueue.d.ts +2 -2
- package/dist/adapters/memQueue.d.ts.map +1 -1
- package/dist/adapters/memQueue.js +3 -3
- package/dist/adapters/mongo-client.d.ts +2 -2
- package/dist/adapters/mongo-client.d.ts.map +1 -1
- package/dist/adapters/mongo-client.js +3 -3
- package/dist/adapters/redis-client.d.ts +2 -2
- package/dist/adapters/redis-client.d.ts.map +1 -1
- package/dist/adapters/redis-client.js +3 -3
- package/dist/api/ContextProvider.d.ts +6 -6
- package/dist/api/ContextProvider.d.ts.map +1 -1
- package/dist/api/ContextProvider.js +6 -6
- package/dist/api/internal/auth.d.ts +42 -4
- package/dist/api/internal/auth.d.ts.map +1 -1
- package/dist/api/internal/auth.js +160 -29
- package/dist/api/internal/events.d.ts +2 -2
- package/dist/api/internal/events.d.ts.map +1 -1
- package/dist/api/internal/events.js +11 -7
- package/dist/api/layerUtils.d.ts +5 -5
- package/dist/api/layerUtils.d.ts.map +1 -1
- package/dist/api/layerUtils.js +5 -5
- package/dist/api/routing/middleware/RouterMiddleware.d.ts +3 -3
- package/dist/api/routing/middleware/RouterMiddleware.d.ts.map +1 -1
- package/dist/api/routing/middleware/middleware.d.ts +37 -1
- package/dist/api/routing/middleware/middleware.d.ts.map +1 -1
- package/dist/api/routing/middleware/middleware.js +45 -14
- package/dist/api/routing.d.ts +4 -6
- package/dist/api/routing.d.ts.map +1 -1
- package/dist/api/routing.js +13 -6
- package/dist/api/setupRequest.d.ts +6 -3
- package/dist/api/setupRequest.d.ts.map +1 -1
- package/dist/api/setupRequest.js +11 -6
- package/dist/errorReporter.d.ts +3 -3
- package/dist/errorReporter.d.ts.map +1 -1
- package/dist/errorReporter.js +16 -23
- package/dist/logger.d.ts.map +1 -1
- package/dist/rateLimit.d.ts +8 -2
- package/dist/rateLimit.d.ts.map +1 -1
- package/dist/rateLimit.js +5 -11
- package/examples/query.ts +30 -26
- package/package.json +36 -22
- package/src/CUPS.ts +9 -11
- package/src/Emailer/service.ts +2 -2
- package/src/MainFiberSet.ts +2 -2
- package/src/Model/Repository/Registry.ts +33 -0
- package/src/Model/Repository/ext.ts +93 -6
- package/src/Model/Repository/internal/internal.ts +84 -76
- package/src/Model/Repository/makeRepo.ts +11 -8
- package/src/Model/Repository/service.ts +31 -22
- package/src/Model/Repository.ts +1 -0
- package/src/Model/query/new-kid-interpreter.ts +2 -2
- package/src/Model.ts +1 -0
- package/src/Operations.ts +78 -113
- package/src/OperationsRepo.ts +2 -2
- package/src/QueueMaker/SQLQueue.ts +121 -151
- package/src/QueueMaker/memQueue.ts +82 -103
- package/src/QueueMaker/sbqueue.ts +55 -85
- package/src/RequestContext.ts +4 -4
- package/src/RequestFiberSet.ts +4 -4
- package/src/Store/ContextMapContainer.ts +41 -2
- package/src/Store/Cosmos.ts +437 -343
- package/src/Store/Disk.ts +52 -49
- package/src/Store/Memory.ts +54 -48
- package/src/Store/SQL/Pg.ts +318 -0
- package/src/Store/SQL/query.ts +409 -0
- package/src/Store/SQL.ts +668 -0
- package/src/Store/index.ts +17 -2
- package/src/Store/service.ts +31 -7
- package/src/Store/utils.ts +23 -22
- package/src/adapters/ServiceBus.ts +111 -115
- package/src/adapters/cosmos-client.ts +2 -2
- package/src/adapters/memQueue.ts +2 -2
- package/src/adapters/mongo-client.ts +2 -2
- package/src/adapters/redis-client.ts +2 -2
- package/src/api/ContextProvider.ts +11 -11
- package/src/api/internal/auth.ts +246 -44
- package/src/api/internal/events.ts +14 -9
- package/src/api/layerUtils.ts +8 -8
- package/src/api/routing/middleware/RouterMiddleware.ts +4 -4
- package/src/api/routing/middleware/middleware.ts +52 -12
- package/src/api/routing.ts +17 -7
- package/src/api/setupRequest.ts +27 -7
- package/src/errorReporter.ts +58 -72
- package/src/rateLimit.ts +30 -22
- package/test/auth.test.ts +101 -0
- package/test/contextProvider.test.ts +11 -11
- package/test/controller.test.ts +18 -13
- package/test/dist/auth.test.d.ts.map +1 -0
- package/test/dist/contextProvider.test.d.ts.map +1 -1
- package/test/dist/controller.test.d.ts.map +1 -1
- package/test/dist/date-query.test.d.ts.map +1 -0
- package/test/dist/fixtures.d.ts +19 -9
- package/test/dist/fixtures.d.ts.map +1 -1
- package/test/dist/fixtures.js +11 -9
- package/test/dist/query.test.d.ts.map +1 -1
- package/test/dist/rawQuery.test.d.ts.map +1 -1
- package/test/dist/repository-ext.test.d.ts.map +1 -0
- package/test/dist/requires.test.d.ts.map +1 -1
- package/test/dist/routing-interruptibility.test.d.ts.map +1 -0
- package/test/dist/rpc-multi-middleware.test.d.ts.map +1 -1
- package/test/dist/sql-store.test.d.ts.map +1 -0
- package/test/fixtures.ts +10 -8
- package/test/query.test.ts +209 -31
- package/test/rawQuery.test.ts +23 -19
- package/test/repository-ext.test.ts +58 -0
- package/test/requires.test.ts +6 -5
- package/test/routing-interruptibility.test.ts +63 -0
- package/test/rpc-multi-middleware.test.ts +72 -3
- package/test/sql-store.test.ts +1064 -0
- package/test/validateSample.test.ts +12 -9
- package/tsconfig.json +0 -1
package/src/api/setupRequest.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { Effect, Layer, Tracer } from "effect-app"
|
|
1
|
+
import { Effect, Layer, Option, Tracer } from "effect-app"
|
|
2
2
|
import { NonEmptyString255 } from "effect-app/Schema"
|
|
3
|
+
import { SqlClient } from "effect/unstable/sql"
|
|
3
4
|
import { LocaleRef, RequestContext, spanAttributes } from "../RequestContext.js"
|
|
4
5
|
import { ContextMapContainer } from "../Store/ContextMapContainer.js"
|
|
5
6
|
import { storeId } from "../Store/Memory.js"
|
|
6
7
|
|
|
8
|
+
const withSqlTransaction = <R, E, A>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
|
|
9
|
+
Effect.serviceOption(SqlClient.SqlClient).pipe(
|
|
10
|
+
Effect.flatMap(Option.match({
|
|
11
|
+
onNone: () => self,
|
|
12
|
+
onSome: (sql) => sql.withTransaction(self).pipe(Effect.orDie)
|
|
13
|
+
}))
|
|
14
|
+
)
|
|
15
|
+
|
|
7
16
|
export const getRequestContext = Effect
|
|
8
17
|
.all({
|
|
9
18
|
span: Effect.currentSpan.pipe(Effect.orDie),
|
|
@@ -43,16 +52,25 @@ const withRequestSpan = (name = "request", options?: Tracer.SpanOptions) => <R,
|
|
|
43
52
|
)
|
|
44
53
|
)
|
|
45
54
|
|
|
55
|
+
export interface SetupRequestOptions {
|
|
56
|
+
readonly withTransaction?: boolean
|
|
57
|
+
}
|
|
58
|
+
|
|
46
59
|
export const setupRequestContextFromCurrent =
|
|
47
|
-
(name = "request", options?: Tracer.SpanOptions) => <R, E, A>(self: Effect.Effect<A, E, R>) =>
|
|
60
|
+
(name = "request", options?: Tracer.SpanOptions & SetupRequestOptions) => <R, E, A>(self: Effect.Effect<A, E, R>) =>
|
|
48
61
|
self
|
|
49
62
|
.pipe(
|
|
63
|
+
options?.withTransaction === true ? withSqlTransaction : (_) => _,
|
|
50
64
|
withRequestSpan(name, options),
|
|
51
|
-
Effect.provide(ContextMapContainer.layer)
|
|
65
|
+
Effect.provide(ContextMapContainer.layer, { local: true })
|
|
52
66
|
)
|
|
53
67
|
|
|
54
68
|
// TODO: consider integrating Effect.withParentSpan
|
|
55
|
-
export function setupRequestContext<R, E, A>(
|
|
69
|
+
export function setupRequestContext<R, E, A>(
|
|
70
|
+
self: Effect.Effect<A, E, R>,
|
|
71
|
+
requestContext: RequestContext,
|
|
72
|
+
options?: SetupRequestOptions
|
|
73
|
+
) {
|
|
56
74
|
const layer = Layer.mergeAll(
|
|
57
75
|
ContextMapContainer.layer,
|
|
58
76
|
Layer.succeed(LocaleRef, requestContext.locale),
|
|
@@ -60,8 +78,9 @@ export function setupRequestContext<R, E, A>(self: Effect.Effect<A, E, R>, reque
|
|
|
60
78
|
)
|
|
61
79
|
return self
|
|
62
80
|
.pipe(
|
|
81
|
+
options?.withTransaction === true ? withSqlTransaction : (_) => _,
|
|
63
82
|
withRequestSpan(requestContext.name),
|
|
64
|
-
Effect.provide(layer)
|
|
83
|
+
Effect.provide(layer, { local: true })
|
|
65
84
|
)
|
|
66
85
|
}
|
|
67
86
|
|
|
@@ -69,7 +88,7 @@ export function setupRequestContextWithCustomSpan<R, E, A>(
|
|
|
69
88
|
self: Effect.Effect<A, E, R>,
|
|
70
89
|
requestContext: RequestContext,
|
|
71
90
|
name: string,
|
|
72
|
-
options?: Tracer.SpanOptions
|
|
91
|
+
options?: Tracer.SpanOptions & SetupRequestOptions
|
|
73
92
|
) {
|
|
74
93
|
const layer = Layer.mergeAll(
|
|
75
94
|
ContextMapContainer.layer,
|
|
@@ -78,7 +97,8 @@ export function setupRequestContextWithCustomSpan<R, E, A>(
|
|
|
78
97
|
)
|
|
79
98
|
return self
|
|
80
99
|
.pipe(
|
|
100
|
+
options?.withTransaction === true ? withSqlTransaction : (_) => _,
|
|
81
101
|
withRequestSpan(name, options),
|
|
82
|
-
Effect.provide(layer)
|
|
102
|
+
Effect.provide(layer, { local: true })
|
|
83
103
|
)
|
|
84
104
|
}
|
package/src/errorReporter.ts
CHANGED
|
@@ -13,47 +13,41 @@ const tryCauseException = <E>(cause: Cause.Cause<E>, name: string): CauseExcepti
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export function reportError(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
const error = tryCauseException(cause, name)
|
|
31
|
-
|
|
32
|
-
yield* reportSentry(error, extras, LogLevelToSentry(level))
|
|
33
|
-
yield* InfraLogger
|
|
34
|
-
.logWithLevel(level, "Reporting error", cause)
|
|
35
|
-
.pipe(
|
|
36
|
-
Effect.annotateLogs(dropUndefined({
|
|
37
|
-
extras,
|
|
38
|
-
error: tryToReport(error),
|
|
39
|
-
cause: tryToJson(cause),
|
|
40
|
-
__error_name__: name
|
|
41
|
-
}))
|
|
42
|
-
)
|
|
43
|
-
.pipe(
|
|
44
|
-
Effect.catchCause((cause) => InfraLogger.logWarning("Failed to log error", cause)),
|
|
45
|
-
Effect.catchCause(() => InfraLogger.logFatal("Failed to log error cause"))
|
|
46
|
-
)
|
|
16
|
+
export function reportError(name: string) {
|
|
17
|
+
return Effect.fnUntraced(
|
|
18
|
+
function*(
|
|
19
|
+
cause: Cause.Cause<unknown>,
|
|
20
|
+
extras?: Record<string, unknown>,
|
|
21
|
+
level: LogLevel.Severity = "Error"
|
|
22
|
+
) {
|
|
23
|
+
if (Cause.hasInterruptsOnly(cause)) {
|
|
24
|
+
yield* InfraLogger.logDebug("Interrupted").pipe(Effect.annotateLogs("extras", JSON.stringify(extras ?? {})))
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
const error = tryCauseException(cause, name)
|
|
47
28
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
29
|
+
yield* reportSentry(error, extras, LogLevelToSentry(level))
|
|
30
|
+
yield* InfraLogger
|
|
31
|
+
.logWithLevel(level, "Reporting error", cause)
|
|
32
|
+
.pipe(
|
|
33
|
+
Effect.annotateLogs(dropUndefined({
|
|
34
|
+
extras,
|
|
35
|
+
error: tryToReport(error),
|
|
36
|
+
cause: tryToJson(cause),
|
|
37
|
+
__error_name__: name
|
|
38
|
+
})),
|
|
39
|
+
Effect.catchCause((cause) => InfraLogger.logWarning("Failed to log error", cause)),
|
|
40
|
+
Effect.catchCause(() => InfraLogger.logFatal("Failed to log error cause"))
|
|
55
41
|
)
|
|
56
|
-
|
|
42
|
+
|
|
43
|
+
return error
|
|
44
|
+
},
|
|
45
|
+
(effect) =>
|
|
46
|
+
Effect.tapCause(effect, (cause) =>
|
|
47
|
+
InfraLogger.logError("Failed to report error", cause).pipe(
|
|
48
|
+
Effect.tapCause(() => InfraLogger.logFatal("Failed to log error cause"))
|
|
49
|
+
))
|
|
50
|
+
)
|
|
57
51
|
}
|
|
58
52
|
|
|
59
53
|
function reportSentry(
|
|
@@ -72,39 +66,31 @@ function reportSentry(
|
|
|
72
66
|
}))
|
|
73
67
|
}
|
|
74
68
|
|
|
75
|
-
export function logError<E>(
|
|
76
|
-
|
|
77
|
-
) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}))
|
|
93
|
-
)
|
|
94
|
-
})
|
|
95
|
-
.pipe(
|
|
96
|
-
Effect.tapCause(() => InfraLogger.logFatal("Failed to log error cause"))
|
|
97
|
-
)
|
|
69
|
+
export function logError<E>(name: string) {
|
|
70
|
+
return Effect.fnUntraced(
|
|
71
|
+
function*(cause: Cause.Cause<E>, extras?: Record<string, unknown>) {
|
|
72
|
+
if (Cause.hasInterruptsOnly(cause)) {
|
|
73
|
+
yield* InfraLogger.logDebug("Interrupted").pipe(Effect.annotateLogs(dropUndefined({ extras })))
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
yield* InfraLogger
|
|
77
|
+
.logWarning("Logging error", cause)
|
|
78
|
+
.pipe(Effect.annotateLogs(dropUndefined({
|
|
79
|
+
extras,
|
|
80
|
+
cause: tryToJson(cause),
|
|
81
|
+
__error_name__: name
|
|
82
|
+
})))
|
|
83
|
+
},
|
|
84
|
+
(effect) => Effect.tapCause(effect, () => InfraLogger.logFatal("Failed to log error cause"))
|
|
85
|
+
)
|
|
98
86
|
}
|
|
99
87
|
|
|
100
|
-
export
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Sentry.captureMessage(message, scope)
|
|
88
|
+
export const reportMessage = Effect.fnUntraced(function*(message: string, extras?: Record<string, unknown>) {
|
|
89
|
+
const context = yield* getRC
|
|
90
|
+
const scope = new Sentry.Scope()
|
|
91
|
+
if (context) scope.setContext("context", { ...context })
|
|
92
|
+
if (extras) scope.setContext("extras", extras)
|
|
93
|
+
Sentry.captureMessage(message, scope)
|
|
107
94
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
95
|
+
console.warn(message, extras)
|
|
96
|
+
})
|
package/src/rateLimit.ts
CHANGED
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
// }
|
|
22
22
|
|
|
23
23
|
import { Array, type Duration, Effect, type NonEmptyArray } from "effect-app"
|
|
24
|
+
import { dual } from "effect-app/Function"
|
|
24
25
|
import type { Semaphore } from "effect/Semaphore"
|
|
26
|
+
import type { Concurrency } from "effect/Types"
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* Executes the specified effect, acquiring the specified number of permits
|
|
@@ -45,36 +47,42 @@ export function SEM_withPermitsDuration(permits: number, duration: Duration.Dura
|
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
-
forEachItem: (item: T, iWithinBatch: number, batchI: number) => Effect.Effect<A, E, R>,
|
|
51
|
-
forEachBatch: (a: NonEmptyArray<A>, i: number) => Effect.Effect<A2, E2, R2>
|
|
52
|
-
) {
|
|
53
|
-
return (items: Iterable<T>) =>
|
|
54
|
-
Effect.forEach(
|
|
55
|
-
Array.chunksOf(items, n),
|
|
56
|
-
(_, i) =>
|
|
57
|
-
Effect
|
|
58
|
-
.forEach(_, (_, j) => forEachItem(_, j, i), { concurrency: "inherit" })
|
|
59
|
-
.pipe(Effect.flatMap((_) => forEachBatch(_, i))),
|
|
60
|
-
{ concurrency: "inherit" }
|
|
61
|
-
)
|
|
50
|
+
export interface BatchOptions {
|
|
51
|
+
readonly concurrency?: Concurrency | undefined
|
|
62
52
|
}
|
|
63
53
|
|
|
64
|
-
export
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
)
|
|
69
|
-
|
|
54
|
+
export const batch: {
|
|
55
|
+
<T, A, E, R, A2, E2, R2>(
|
|
56
|
+
n: number,
|
|
57
|
+
forEachItem: (item: T, iWithinBatch: number, batchI: number) => Effect.Effect<A, E, R>,
|
|
58
|
+
forEachBatch: (a: NonEmptyArray<A>, i: number) => Effect.Effect<A2, E2, R2>,
|
|
59
|
+
options?: BatchOptions
|
|
60
|
+
): (items: Iterable<T>) => Effect.Effect<Array<A2>, E | E2, R | R2>
|
|
61
|
+
<T, A, E, R, A2, E2, R2>(
|
|
62
|
+
items: Iterable<T>,
|
|
63
|
+
n: number,
|
|
64
|
+
forEachItem: (item: T, iWithinBatch: number, batchI: number) => Effect.Effect<A, E, R>,
|
|
65
|
+
forEachBatch: (a: NonEmptyArray<A>, i: number) => Effect.Effect<A2, E2, R2>,
|
|
66
|
+
options?: BatchOptions
|
|
67
|
+
): Effect.Effect<Array<A2>, E | E2, R | R2>
|
|
68
|
+
} = dual(
|
|
69
|
+
(args) => typeof args[0] !== "number",
|
|
70
|
+
<T, A, E, R, A2, E2, R2>(
|
|
71
|
+
items: Iterable<T>,
|
|
72
|
+
n: number,
|
|
73
|
+
forEachItem: (item: T, iWithinBatch: number, batchI: number) => Effect.Effect<A, E, R>,
|
|
74
|
+
forEachBatch: (a: NonEmptyArray<A>, i: number) => Effect.Effect<A2, E2, R2>,
|
|
75
|
+
options?: BatchOptions
|
|
76
|
+
) =>
|
|
70
77
|
Effect.forEach(
|
|
71
78
|
Array.chunksOf(items, n),
|
|
72
79
|
(_, i) =>
|
|
73
80
|
Effect
|
|
74
81
|
.forEach(_, (_, j) => forEachItem(_, j, i), { concurrency: "inherit" })
|
|
75
|
-
.pipe(Effect.flatMap((_) => forEachBatch(_, i)))
|
|
82
|
+
.pipe(Effect.flatMap((_) => forEachBatch(_, i))),
|
|
83
|
+
{ concurrency: options?.concurrency }
|
|
76
84
|
)
|
|
77
|
-
|
|
85
|
+
)
|
|
78
86
|
|
|
79
87
|
// export function rateLimit(
|
|
80
88
|
// n: number,
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
+
import { Effect } from "effect-app"
|
|
3
|
+
import { HttpHeaders } from "effect-app/http"
|
|
4
|
+
import { SignJWT } from "jose"
|
|
5
|
+
import { checkJWTI, InvalidRequestError, InvalidTokenError, UnauthorizedError } from "../src/api/internal/auth.js"
|
|
6
|
+
|
|
7
|
+
const issuer = "https://issuer.example.com/"
|
|
8
|
+
const audience = "effect-app"
|
|
9
|
+
const secret = "test-secret-test-secret-test-secret"
|
|
10
|
+
|
|
11
|
+
const makeToken = () =>
|
|
12
|
+
new SignJWT({ scope: "read:all" })
|
|
13
|
+
.setProtectedHeader({ alg: "HS256", typ: "at+jwt" })
|
|
14
|
+
.setIssuer(issuer)
|
|
15
|
+
.setAudience(audience)
|
|
16
|
+
.setIssuedAt()
|
|
17
|
+
.setExpirationTime("10m")
|
|
18
|
+
.sign(new TextEncoder().encode(secret))
|
|
19
|
+
|
|
20
|
+
describe("checkJWTI", () => {
|
|
21
|
+
it.effect(
|
|
22
|
+
"validates a bearer token from headers",
|
|
23
|
+
Effect.fnUntraced(function*() {
|
|
24
|
+
const token = yield* Effect.promise(() => makeToken())
|
|
25
|
+
|
|
26
|
+
yield* checkJWTI({
|
|
27
|
+
audience,
|
|
28
|
+
issuer,
|
|
29
|
+
secret,
|
|
30
|
+
strict: true,
|
|
31
|
+
tokenSigningAlg: "HS256"
|
|
32
|
+
})(HttpHeaders.fromRecordUnsafe({ authorization: `Bearer ${token}` }))
|
|
33
|
+
})
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
it.effect(
|
|
37
|
+
"fails on malformed authorization headers",
|
|
38
|
+
Effect.fnUntraced(function*() {
|
|
39
|
+
const error = yield* Effect.flip(
|
|
40
|
+
checkJWTI({
|
|
41
|
+
audience,
|
|
42
|
+
issuer,
|
|
43
|
+
secret,
|
|
44
|
+
tokenSigningAlg: "HS256"
|
|
45
|
+
})(HttpHeaders.fromRecordUnsafe({ authorization: "Basic abc" }))
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
expect(error).toBeInstanceOf(InvalidRequestError)
|
|
49
|
+
expect(error.status).toBe(400)
|
|
50
|
+
})
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
it.effect(
|
|
54
|
+
"fails when the token is missing",
|
|
55
|
+
Effect.fnUntraced(function*() {
|
|
56
|
+
const error = yield* Effect.flip(
|
|
57
|
+
checkJWTI({
|
|
58
|
+
audience,
|
|
59
|
+
issuer,
|
|
60
|
+
secret,
|
|
61
|
+
tokenSigningAlg: "HS256"
|
|
62
|
+
})(HttpHeaders.empty)
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
expect(error).toBeInstanceOf(UnauthorizedError)
|
|
66
|
+
expect(error.status).toBe(401)
|
|
67
|
+
})
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
it.effect(
|
|
71
|
+
"allows missing tokens when auth is optional",
|
|
72
|
+
Effect.fnUntraced(function*() {
|
|
73
|
+
yield* checkJWTI({
|
|
74
|
+
audience,
|
|
75
|
+
authRequired: false,
|
|
76
|
+
issuer,
|
|
77
|
+
secret,
|
|
78
|
+
tokenSigningAlg: "HS256"
|
|
79
|
+
})(HttpHeaders.empty)
|
|
80
|
+
})
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
it.effect(
|
|
84
|
+
"fails when the token signature is invalid",
|
|
85
|
+
Effect.fnUntraced(function*() {
|
|
86
|
+
const token = yield* Effect.promise(() => makeToken())
|
|
87
|
+
|
|
88
|
+
const error = yield* Effect.flip(
|
|
89
|
+
checkJWTI({
|
|
90
|
+
audience,
|
|
91
|
+
issuer,
|
|
92
|
+
secret: "wrong-secret-wrong-secret-wrong-secret",
|
|
93
|
+
tokenSigningAlg: "HS256"
|
|
94
|
+
})(HttpHeaders.fromRecordUnsafe({ authorization: `Bearer ${token}` }))
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
expect(error).toBeInstanceOf(InvalidTokenError)
|
|
98
|
+
expect(error.status).toBe(401)
|
|
99
|
+
})
|
|
100
|
+
)
|
|
101
|
+
})
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
3
|
import { expectTypeOf, it } from "@effect/vitest"
|
|
4
|
-
import { Effect, Layer, Scope
|
|
4
|
+
import { Context, Effect, Layer, Scope } from "effect-app"
|
|
5
5
|
import { ContextProvider, mergeContextProviders, MergedContextProvider } from "../src/api/ContextProvider.js"
|
|
6
6
|
import { CustomError1, Some, SomeElse, SomeService } from "./fixtures.js"
|
|
7
7
|
|
|
8
8
|
// @effect-diagnostics-next-line missingEffectServiceDependency:off
|
|
9
|
-
class MyContextProvider extends
|
|
9
|
+
class MyContextProvider extends Context.Service<MyContextProvider>()(
|
|
10
10
|
"MyContextProvider",
|
|
11
11
|
{
|
|
12
12
|
make: Effect.gen(function*() {
|
|
@@ -20,7 +20,7 @@ class MyContextProvider extends ServiceMap.Service<MyContextProvider>()(
|
|
|
20
20
|
yield* Effect.logInfo("MyContextProviderGen", "this is a generator")
|
|
21
21
|
yield* Effect.succeed("this is a generator")
|
|
22
22
|
|
|
23
|
-
return Some.
|
|
23
|
+
return Some.context({ a: 1 })
|
|
24
24
|
})
|
|
25
25
|
})
|
|
26
26
|
}
|
|
@@ -28,7 +28,7 @@ class MyContextProvider extends ServiceMap.Service<MyContextProvider>()(
|
|
|
28
28
|
static readonly Default = Layer.effect(this, this.make)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
class MyContextProvider2 extends
|
|
31
|
+
class MyContextProvider2 extends Context.Service<MyContextProvider2>()(
|
|
32
32
|
"MyContextProvider2",
|
|
33
33
|
{
|
|
34
34
|
make: Effect.gen(function*() {
|
|
@@ -37,7 +37,7 @@ class MyContextProvider2 extends ServiceMap.Service<MyContextProvider2>()(
|
|
|
37
37
|
return Effect.gen(function*() {
|
|
38
38
|
// we test without dependencies, so that we end up with an R of never.
|
|
39
39
|
|
|
40
|
-
return SomeElse.
|
|
40
|
+
return SomeElse.context({ b: 2 })
|
|
41
41
|
})
|
|
42
42
|
})
|
|
43
43
|
}
|
|
@@ -45,7 +45,7 @@ class MyContextProvider2 extends ServiceMap.Service<MyContextProvider2>()(
|
|
|
45
45
|
static readonly Default = Layer.effect(this, this.make)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
class MyContextProvider2Gen extends
|
|
48
|
+
class MyContextProvider2Gen extends Context.Service<MyContextProvider2Gen>()(
|
|
49
49
|
"MyContextProvider2Gen",
|
|
50
50
|
{
|
|
51
51
|
make: Effect.gen(function*() {
|
|
@@ -54,7 +54,7 @@ class MyContextProvider2Gen extends ServiceMap.Service<MyContextProvider2Gen>()(
|
|
|
54
54
|
return function*() {
|
|
55
55
|
// we test without dependencies, so that we end up with an R of never
|
|
56
56
|
|
|
57
|
-
return SomeElse.
|
|
57
|
+
return SomeElse.context({ b: 2 })
|
|
58
58
|
}
|
|
59
59
|
})
|
|
60
60
|
}
|
|
@@ -63,7 +63,7 @@ class MyContextProvider2Gen extends ServiceMap.Service<MyContextProvider2Gen>()(
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
// @effect-diagnostics-next-line missingEffectServiceDependency:off
|
|
66
|
-
class MyContextProviderGen extends
|
|
66
|
+
class MyContextProviderGen extends Context.Service<MyContextProviderGen>()(
|
|
67
67
|
"MyContextProviderGen",
|
|
68
68
|
{
|
|
69
69
|
make: Effect.gen(function*() {
|
|
@@ -77,7 +77,7 @@ class MyContextProviderGen extends ServiceMap.Service<MyContextProviderGen>()(
|
|
|
77
77
|
yield* Effect.logInfo("MyContextProviderGen", "this is a generator")
|
|
78
78
|
yield* Effect.succeed("this is a generator")
|
|
79
79
|
|
|
80
|
-
return Some.
|
|
80
|
+
return Some.context({ a: 1 })
|
|
81
81
|
}
|
|
82
82
|
})
|
|
83
83
|
}
|
|
@@ -100,7 +100,7 @@ export const someContextProvider = ContextProvider({
|
|
|
100
100
|
// currently the effectful context provider cannot trigger an error when building the per request context
|
|
101
101
|
// if (Math.random() > 0.5) return yield* new CustomError2()
|
|
102
102
|
|
|
103
|
-
return Some.
|
|
103
|
+
return Some.context({ a: 1 })
|
|
104
104
|
})
|
|
105
105
|
})
|
|
106
106
|
})
|
|
@@ -119,7 +119,7 @@ export const someContextProviderGen = ContextProvider({
|
|
|
119
119
|
// currently the effectful context provider cannot trigger an error when building the per request context
|
|
120
120
|
// if (Math.random() > 0.5) return yield* new CustomError2()
|
|
121
121
|
|
|
122
|
-
return Some.
|
|
122
|
+
return Some.context({ a: 1 })
|
|
123
123
|
}
|
|
124
124
|
})
|
|
125
125
|
})
|
package/test/controller.test.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
3
|
import { type MakeContext, type MakeErrors, makeRouter } from "@effect-app/infra/api/routing"
|
|
4
4
|
import { expect, expectTypeOf, it } from "@effect/vitest"
|
|
5
|
-
import { Effect, Layer, S, Scope
|
|
5
|
+
import { Context, Effect, Layer, S, Scope } from "effect-app"
|
|
6
6
|
import { InvalidStateError, makeRpcClient, UnauthorizedError } from "effect-app/client"
|
|
7
7
|
import { DefaultGenericMiddlewares } from "effect-app/middleware"
|
|
8
8
|
import * as RpcX from "effect-app/rpc"
|
|
@@ -99,7 +99,7 @@ class MyContextProvider2
|
|
|
99
99
|
|
|
100
100
|
//
|
|
101
101
|
|
|
102
|
-
class Str extends
|
|
102
|
+
class Str extends Context.Service<Str, "str">()("str") {}
|
|
103
103
|
|
|
104
104
|
export class BogusMiddleware extends RpcX.RpcMiddleware.Tag<BogusMiddleware>()("BogusMiddleware") {
|
|
105
105
|
static Default = Layer.make(this, {
|
|
@@ -202,12 +202,17 @@ export const middleware3 = MiddlewareMaker
|
|
|
202
202
|
.middleware(Test)
|
|
203
203
|
.middleware(BogusMiddleware)
|
|
204
204
|
|
|
205
|
-
export const {
|
|
205
|
+
export const { TaggedRequestFor } = makeRpcClient(RequestContextMap)
|
|
206
|
+
const Req = TaggedRequestFor("Something")
|
|
207
|
+
const Command = Req.Command
|
|
208
|
+
const Query = Req.Query
|
|
206
209
|
|
|
207
|
-
export class Eff extends
|
|
208
|
-
export class Gen extends
|
|
210
|
+
export class Eff extends Command<Eff>()("Eff", {}, { success: S.Void }) {}
|
|
211
|
+
export class Gen extends Command<Gen>()("Gen", {}) {}
|
|
209
212
|
|
|
210
|
-
|
|
213
|
+
expectTypeOf(Eff.error).toEqualTypeOf<typeof Gen.error>()
|
|
214
|
+
|
|
215
|
+
export class DoSomething extends Command<DoSomething>()("DoSomething", {
|
|
211
216
|
id: S.String
|
|
212
217
|
}, { success: S.Void }) {}
|
|
213
218
|
|
|
@@ -225,20 +230,20 @@ export class DoSomething extends Req<DoSomething>()("DoSomething", {
|
|
|
225
230
|
// )
|
|
226
231
|
// )
|
|
227
232
|
|
|
228
|
-
export class GetSomething extends
|
|
233
|
+
export class GetSomething extends Query<GetSomething>()("GetSomething", {
|
|
229
234
|
id: S.String
|
|
230
235
|
}, { success: S.String }) {}
|
|
231
236
|
|
|
232
|
-
export class GetSomething2 extends
|
|
237
|
+
export class GetSomething2 extends Query<GetSomething2>()("GetSomething2", {
|
|
233
238
|
id: S.String
|
|
234
|
-
}, { success: S.
|
|
239
|
+
}, { success: S.FiniteFromString }) {}
|
|
235
240
|
|
|
236
|
-
const Something = { Eff, Gen, DoSomething, GetSomething, GetSomething2
|
|
241
|
+
const Something = { Eff, Gen, DoSomething, GetSomething, GetSomething2 }
|
|
237
242
|
|
|
238
243
|
// const client = ApiClientFactory.makeFor(Layer.empty)(Something)
|
|
239
244
|
// client.pipe(Effect.map(c => c.DoSomething.name))
|
|
240
245
|
|
|
241
|
-
export class SomethingService extends
|
|
246
|
+
export class SomethingService extends Context.Service<SomethingService>()(
|
|
242
247
|
"SomethingService",
|
|
243
248
|
{
|
|
244
249
|
make: Effect.gen(function*() {
|
|
@@ -258,7 +263,7 @@ declare const a: {
|
|
|
258
263
|
(opt: { b: 3 }): void
|
|
259
264
|
}
|
|
260
265
|
|
|
261
|
-
export class SomethingRepo extends
|
|
266
|
+
export class SomethingRepo extends Context.Service<SomethingRepo>()(
|
|
262
267
|
"SomethingRepo",
|
|
263
268
|
{
|
|
264
269
|
make: Effect.gen(function*() {
|
|
@@ -271,7 +276,7 @@ export class SomethingRepo extends ServiceMap.Service<SomethingRepo>()(
|
|
|
271
276
|
static Default = Layer.effect(this, this.make).pipe(Layer.provide(SomethingService.Default))
|
|
272
277
|
}
|
|
273
278
|
|
|
274
|
-
export class SomethingService2 extends
|
|
279
|
+
export class SomethingService2 extends Context.Service<SomethingService2>()(
|
|
275
280
|
"SomethingService2",
|
|
276
281
|
{
|
|
277
282
|
make: Effect.gen(function*() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.test.d.ts","sourceRoot":"","sources":["../auth.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextProvider.test.d.ts","sourceRoot":"","sources":["../contextProvider.test.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"contextProvider.test.d.ts","sourceRoot":"","sources":["../contextProvider.test.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAE1D,OAAO,EAAE,YAAY,EAAE,IAAI,EAAY,WAAW,EAAE,MAAM,eAAe,CAAA;AAkFzE,eAAO,MAAM,mBAAmB;;CAkB9B,CAAA;AACF,eAAO,MAAM,sBAAsB;;CAkBjC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.test.d.ts","sourceRoot":"","sources":["../controller.test.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAc,MAAM,+BAA+B,CAAA;AAE7F,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"controller.test.d.ts","sourceRoot":"","sources":["../controller.test.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAc,MAAM,+BAA+B,CAAA;AAE7F,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAC7D,OAAO,EAAoC,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAEvF,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AAGtC,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAG3D,OAAO,EAAE,cAAc,EAAsB,YAAY,EAAqB,YAAY,EAAoB,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAY,MAAM,eAAe,CAAA;;cAuE/G,QAAQ;;AADzE,cAAM,kBACJ,SAAQ,uBAA0F;IAElG,MAAM,CAAC,OAAO,uDAUZ;CACH;;AAID,cAAM,GAAI,SAAQ,QAAoC;CAAG;;;;;AAEzD,qBAAa,eAAgB,SAAQ,oBAA4D;IAC/F,MAAM,CAAC,OAAO,2CAUZ;CACH;AAkFD,eAAO,MAAM,WAAW;;;;;;;;;;YAKM,CAAA;AAE9B,eAAO,MAAQ,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAqC,CAAA;;;;;;;;;;;;;;;;;;;;AAKpE,qBAAa,GAAI,SAAQ,QAA8C;CAAG;;;;;;;;;;;;;;;;AAC1E,qBAAa,GAAI,SAAQ,QAAyB;CAAG;;;;;;;;;;;;;;;;;;;;;;AAIrD,qBAAa,WAAY,SAAQ,gBAEV;CAAG;;;;;;;;;;;;;;;;;;;;;;AAgB1B,qBAAa,YAAa,SAAQ,iBAET;CAAG;;;;;;;;;;;;;;;;;;;;;;AAE5B,qBAAa,aAAc,SAAQ,kBAEA;CAAG;;;;;;;;AAOtC,qBAAa,gBAAiB,SAAQ,qBASrC;IACC,MAAM,CAAC,OAAO,8CAAgC;CAC/C;;;;;;;;AASD,qBAAa,aAAc,SAAQ,kBASlC;IACC,MAAM,CAAC,OAAO,2CAA8E;CAC7F;;;;;;;;AAED,qBAAa,iBAAkB,SAAQ,sBAOtC;IACC,MAAM,CAAC,OAAO,+CAAgC;CAC/C;AAED,eAAO,MAAQ,MAAM;SA3KnB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2KqB,QAAQ;;0FAE9B,CAAA;AAED,eAAO,MAAM,EAAE;;;;;aA/Kb,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiLD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-query.test.d.ts","sourceRoot":"","sources":["../date-query.test.ts"],"names":[],"mappings":""}
|
package/test/dist/fixtures.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { Effect, Layer, S
|
|
1
|
+
import { Context, Effect, Layer, S } from "effect-app";
|
|
2
2
|
import { NotLoggedInError, UnauthorizedError } from "effect-app/client";
|
|
3
3
|
import { RpcContextMap, RpcX } from "effect-app/rpc";
|
|
4
|
-
declare const UserProfile_base: S.EnhancedClass<UserProfile,
|
|
4
|
+
declare const UserProfile_base: S.EnhancedClass<UserProfile, import("effect/Schema").Struct<{
|
|
5
5
|
id: S.String;
|
|
6
6
|
roles: S.$Array<S.String> & {
|
|
7
|
-
withDefault: S.withConstructorDefault<S.$Array<S.String
|
|
7
|
+
withDefault: S.withConstructorDefault<S.$Array<S.String>>;
|
|
8
|
+
withDecodingDefaultType: S.withDecodingDefaultType<S.$Array<S.String>>;
|
|
8
9
|
};
|
|
9
|
-
}>, {}> &
|
|
10
|
+
}>, {}> & Context.Opaque<UserProfile, UserProfile>;
|
|
10
11
|
export declare class UserProfile extends UserProfile_base {
|
|
11
12
|
}
|
|
12
|
-
declare const Some_base:
|
|
13
|
+
declare const Some_base: Context.OpaqueClass<Some, "Some", {
|
|
13
14
|
a: number;
|
|
14
15
|
}> & {
|
|
15
16
|
readonly make: Effect.Effect<{
|
|
@@ -18,7 +19,7 @@ declare const Some_base: ServiceMap.OpaqueClass<Some, "Some", {
|
|
|
18
19
|
};
|
|
19
20
|
export declare class Some extends Some_base {
|
|
20
21
|
}
|
|
21
|
-
declare const SomeElse_base:
|
|
22
|
+
declare const SomeElse_base: Context.OpaqueClass<SomeElse, "SomeElse", {
|
|
22
23
|
b: number;
|
|
23
24
|
}> & {
|
|
24
25
|
readonly make: Effect.Effect<{
|
|
@@ -27,7 +28,7 @@ declare const SomeElse_base: ServiceMap.OpaqueClass<SomeElse, "SomeElse", {
|
|
|
27
28
|
};
|
|
28
29
|
export declare class SomeElse extends SomeElse_base {
|
|
29
30
|
}
|
|
30
|
-
declare const SomeService_base:
|
|
31
|
+
declare const SomeService_base: Context.OpaqueClass<SomeService, "SomeService", {
|
|
31
32
|
a: number;
|
|
32
33
|
}> & {
|
|
33
34
|
readonly make: Effect.Effect<{
|
|
@@ -101,10 +102,19 @@ declare const Test_base: RpcX.RpcMiddleware.TagClass<Test, "Test", {
|
|
|
101
102
|
export declare class Test extends Test_base {
|
|
102
103
|
}
|
|
103
104
|
export declare const TestLive: Layer.Layer<Test, never, never>;
|
|
104
|
-
declare const
|
|
105
|
+
declare const Counter_base: Context.OpaqueClass<Counter, "Counter", {
|
|
106
|
+
a: number;
|
|
107
|
+
}> & {
|
|
108
|
+
readonly make: Effect.Effect<{
|
|
109
|
+
a: number;
|
|
110
|
+
}, never, never>;
|
|
111
|
+
};
|
|
112
|
+
export declare class Counter extends Counter_base {
|
|
113
|
+
}
|
|
114
|
+
declare const CustomError1_base: import("effect/Schema").Class<CustomError1, import("effect/Schema").TaggedStruct<"CustomError1", {}>, import("effect/Cause").YieldableError>;
|
|
105
115
|
export declare class CustomError1 extends CustomError1_base {
|
|
106
116
|
}
|
|
107
|
-
declare const CustomError2_base:
|
|
117
|
+
declare const CustomError2_base: import("effect/Schema").Class<CustomError2, import("effect/Schema").TaggedStruct<"CustomError2", {}>, import("effect/Cause").YieldableError>;
|
|
108
118
|
export declare class CustomError2 extends CustomError2_base {
|
|
109
119
|
}
|
|
110
120
|
export {};
|