@effect-app/infra 3.0.13 → 3.0.15
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 +15 -0
- package/dist/Emailer/service.d.ts +4 -4
- package/dist/Emailer/service.d.ts.map +1 -1
- package/dist/MainFiberSet.d.ts +6 -6
- package/dist/MainFiberSet.d.ts.map +1 -1
- package/dist/MainFiberSet.js +1 -1
- package/dist/Model/Repository/ext.d.ts +9 -9
- package/dist/Model/Repository/ext.d.ts.map +1 -1
- package/dist/Model/Repository/ext.js +1 -1
- package/dist/Model/Repository/internal/internal.d.ts +12 -12
- package/dist/Model/Repository/internal/internal.d.ts.map +1 -1
- package/dist/Model/Repository/internal/internal.js +1 -1
- package/dist/Model/Repository/legacy.d.ts +6 -6
- package/dist/Model/Repository/legacy.d.ts.map +1 -1
- package/dist/Model/Repository/makeRepo.d.ts +2 -2
- package/dist/Model/Repository/makeRepo.d.ts.map +1 -1
- package/dist/Model/Repository/service.d.ts +5 -5
- package/dist/Model/Repository/service.d.ts.map +1 -1
- package/dist/Model/dsl.d.ts +14 -14
- package/dist/Model/dsl.d.ts.map +1 -1
- package/dist/Model/dsl.js +1 -1
- package/dist/Model/query/dsl.d.ts +1 -1
- package/dist/Model/query/dsl.d.ts.map +1 -1
- package/dist/Operations.d.ts +37 -37
- package/dist/Operations.d.ts.map +1 -1
- package/dist/Operations.js +1 -1
- package/dist/QueueMaker/SQLQueue.d.ts +1 -1
- package/dist/QueueMaker/SQLQueue.d.ts.map +1 -1
- package/dist/QueueMaker/SQLQueue.js +1 -1
- package/dist/QueueMaker/errors.d.ts +3 -3
- package/dist/QueueMaker/errors.d.ts.map +1 -1
- package/dist/QueueMaker/errors.js +1 -1
- package/dist/QueueMaker/memQueue.d.ts +1 -1
- package/dist/QueueMaker/memQueue.d.ts.map +1 -1
- package/dist/QueueMaker/memQueue.js +1 -1
- package/dist/QueueMaker/sbqueue.d.ts +1 -1
- package/dist/QueueMaker/sbqueue.d.ts.map +1 -1
- package/dist/QueueMaker/sbqueue.js +1 -1
- package/dist/QueueMaker/service.d.ts +2 -2
- package/dist/QueueMaker/service.d.ts.map +1 -1
- package/dist/RequestFiberSet.d.ts +17 -17
- package/dist/RequestFiberSet.d.ts.map +1 -1
- package/dist/RequestFiberSet.js +1 -1
- package/dist/Store/Cosmos.js +1 -1
- package/dist/Store/Disk.d.ts +1 -1
- package/dist/Store/Disk.d.ts.map +1 -1
- package/dist/Store/Disk.js +1 -1
- package/dist/Store/Memory.d.ts +2 -2
- package/dist/Store/Memory.d.ts.map +1 -1
- package/dist/Store/Memory.js +1 -1
- package/dist/Store/service.d.ts +12 -12
- package/dist/Store/service.d.ts.map +1 -1
- package/dist/Store/utils.d.ts +1 -1
- package/dist/Store/utils.d.ts.map +1 -1
- package/dist/Store/utils.js +1 -1
- package/dist/adapters/ServiceBus.d.ts +12 -12
- package/dist/adapters/ServiceBus.d.ts.map +1 -1
- package/dist/adapters/ServiceBus.js +1 -1
- package/dist/adapters/cosmos-client.d.ts +1 -1
- package/dist/adapters/cosmos-client.d.ts.map +1 -1
- package/dist/adapters/mongo-client.d.ts +1 -1
- package/dist/adapters/mongo-client.d.ts.map +1 -1
- package/dist/adapters/redis-client.d.ts +4 -4
- package/dist/adapters/redis-client.d.ts.map +1 -1
- package/dist/adapters/redis-client.js +1 -1
- package/dist/api/ContextProvider.d.ts +5 -5
- package/dist/api/ContextProvider.d.ts.map +1 -1
- package/dist/api/internal/middlewares.d.ts +1 -1
- package/dist/api/internal/middlewares.d.ts.map +1 -1
- package/dist/api/internal/middlewares.js +1 -1
- package/dist/api/layerUtils.d.ts +1 -1
- package/dist/api/layerUtils.d.ts.map +1 -1
- package/dist/api/layerUtils.js +1 -1
- package/dist/api/middlewares.d.ts +1 -1
- package/dist/api/middlewares.d.ts.map +1 -1
- package/dist/api/reportError.d.ts +2 -2
- package/dist/api/reportError.d.ts.map +1 -1
- package/dist/api/reportError.js +2 -2
- package/dist/api/routing/middleware/RouterMiddleware.d.ts +1 -1
- package/dist/api/routing/middleware/RouterMiddleware.d.ts.map +1 -1
- package/dist/api/routing.d.ts +22 -22
- package/dist/api/routing.d.ts.map +1 -1
- package/dist/api/routing.js +1 -1
- package/dist/api/setupRequest.d.ts +3 -3
- package/dist/api/setupRequest.d.ts.map +1 -1
- package/dist/api/setupRequest.js +1 -1
- package/dist/errorReporter.d.ts +2 -2
- package/dist/errorReporter.d.ts.map +1 -1
- package/dist/errorReporter.js +1 -1
- package/dist/rateLimit.d.ts +4 -4
- package/dist/rateLimit.d.ts.map +1 -1
- package/dist/rateLimit.js +4 -4
- package/package.json +2 -2
- package/src/Emailer/service.ts +1 -1
- package/src/MainFiberSet.ts +4 -3
- package/src/Model/Repository/ext.ts +13 -13
- package/src/Model/Repository/internal/internal.ts +13 -13
- package/src/Model/Repository/legacy.ts +6 -6
- package/src/Model/Repository/makeRepo.ts +2 -2
- package/src/Model/Repository/service.ts +5 -5
- package/src/Model/dsl.ts +25 -22
- package/src/Model/query/dsl.ts +1 -1
- package/src/Operations.ts +20 -20
- package/src/QueueMaker/SQLQueue.ts +1 -1
- package/src/QueueMaker/errors.ts +4 -4
- package/src/QueueMaker/memQueue.ts +1 -1
- package/src/QueueMaker/sbqueue.ts +1 -1
- package/src/QueueMaker/service.ts +3 -3
- package/src/RequestFiberSet.ts +9 -8
- package/src/Store/Cosmos.ts +1 -1
- package/src/Store/Disk.ts +2 -2
- package/src/Store/Memory.ts +2 -2
- package/src/Store/service.ts +10 -10
- package/src/Store/utils.ts +1 -1
- package/src/adapters/ServiceBus.ts +14 -10
- package/src/adapters/cosmos-client.ts +1 -1
- package/src/adapters/mongo-client.ts +1 -1
- package/src/adapters/redis-client.ts +4 -4
- package/src/api/ContextProvider.ts +11 -11
- package/src/api/internal/middlewares.ts +1 -1
- package/src/api/layerUtils.ts +9 -2
- package/src/api/middlewares.ts +1 -1
- package/src/api/reportError.ts +2 -2
- package/src/api/routing/middleware/RouterMiddleware.ts +1 -1
- package/src/api/routing.ts +42 -39
- package/src/api/setupRequest.ts +4 -4
- package/src/errorReporter.ts +3 -3
- package/src/rateLimit.ts +12 -12
- package/test/controller.test.ts +3 -8
- package/test/dist/controller.test.d.ts.map +1 -1
- package/test/dist/fixtures.d.ts +1 -1
- package/test/requires.test.ts +1 -1
package/src/api/routing.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
5
|
import { Rpc, RpcGroup, type RpcSerialization, RpcServer } from "@effect/rpc"
|
|
6
|
-
import {
|
|
6
|
+
import { Effect, Layer, type NonEmptyReadonlyArray, Predicate, S, Schema, type Scope } from "effect-app"
|
|
7
7
|
import { type HttpHeaders } from "effect-app/http"
|
|
8
8
|
import { type GetEffectContext, type GetEffectError, type RpcContextMap } from "effect-app/rpc/RpcContextMap"
|
|
9
9
|
import { type TypeTestId } from "effect-app/TypeTest"
|
|
@@ -67,7 +67,7 @@ interface HandlerBase<Action extends AnyRequestModule, RT extends RequestType, A
|
|
|
67
67
|
new(): {}
|
|
68
68
|
_tag: RT
|
|
69
69
|
stack: string
|
|
70
|
-
handler: (req: S.Schema.Type<Action>, headers: HttpHeaders.Headers) => Effect<A, E, R>
|
|
70
|
+
handler: (req: S.Schema.Type<Action>, headers: HttpHeaders.Headers) => Effect.Effect<A, E, R>
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export interface Handler<Action extends AnyRequestModule, RT extends RequestType, R> extends
|
|
@@ -93,10 +93,10 @@ type FilterRequestModules<T> = {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
type RpcRouteR<
|
|
96
|
-
T extends [any, (req: any, headers: HttpHeaders.Headers) => Effect<any, any, any>]
|
|
96
|
+
T extends [any, (req: any, headers: HttpHeaders.Headers) => Effect.Effect<any, any, any>]
|
|
97
97
|
> = T extends [
|
|
98
98
|
any,
|
|
99
|
-
(...args: any[]) => Effect<any, any, infer R>
|
|
99
|
+
(...args: any[]) => Effect.Effect<any, any, infer R>
|
|
100
100
|
] ? R
|
|
101
101
|
: never
|
|
102
102
|
|
|
@@ -108,7 +108,7 @@ type Match<
|
|
|
108
108
|
> = {
|
|
109
109
|
// note: the defaults of = never prevent the whole router to error (??)
|
|
110
110
|
<A extends GetSuccessShape<Resource[Key], RT>, R2 = never, E = never>(
|
|
111
|
-
f: Effect<A, E, R2>
|
|
111
|
+
f: Effect.Effect<A, E, R2>
|
|
112
112
|
): Handler<
|
|
113
113
|
Resource[Key],
|
|
114
114
|
RT,
|
|
@@ -119,7 +119,7 @@ type Match<
|
|
|
119
119
|
>
|
|
120
120
|
|
|
121
121
|
<A extends GetSuccessShape<Resource[Key], RT>, R2 = never, E = never>(
|
|
122
|
-
f: (req: S.Schema.Type<Resource[Key]>) => Effect<A, E, R2>
|
|
122
|
+
f: (req: S.Schema.Type<Resource[Key]>) => Effect.Effect<A, E, R2>
|
|
123
123
|
): Handler<
|
|
124
124
|
Resource[Key],
|
|
125
125
|
RT,
|
|
@@ -185,7 +185,7 @@ export const makeRouter = <
|
|
|
185
185
|
req: S.Schema.Type<Action>
|
|
186
186
|
) => Generator<
|
|
187
187
|
YieldWrap<
|
|
188
|
-
Effect<
|
|
188
|
+
Effect.Effect<
|
|
189
189
|
any,
|
|
190
190
|
S.Schema.Type<GetFailure<Action>> | S.ParseResult.ParseError,
|
|
191
191
|
// the actual implementation of the handler may just require the dynamic context provided by the middleware
|
|
@@ -202,7 +202,7 @@ export const makeRouter = <
|
|
|
202
202
|
RT extends RequestType
|
|
203
203
|
> = (
|
|
204
204
|
req: S.Schema.Type<Action>
|
|
205
|
-
) => Effect<
|
|
205
|
+
) => Effect.Effect<
|
|
206
206
|
GetSuccessShape<Action, RT>,
|
|
207
207
|
S.Schema.Type<GetFailure<Action>> | S.ParseResult.ParseError,
|
|
208
208
|
// the actual implementation of the handler may just require the dynamic context provided by the middleware
|
|
@@ -213,7 +213,7 @@ export const makeRouter = <
|
|
|
213
213
|
type HandlerEff<
|
|
214
214
|
Action extends AnyRequestModule,
|
|
215
215
|
RT extends RequestType
|
|
216
|
-
> = Effect<
|
|
216
|
+
> = Effect.Effect<
|
|
217
217
|
GetSuccessShape<Action, RT>,
|
|
218
218
|
S.Schema.Type<GetFailure<Action>> | S.ParseResult.ParseError,
|
|
219
219
|
// the actual implementation of the handler may just require the dynamic context provided by the middleware
|
|
@@ -307,18 +307,19 @@ export const makeRouter = <
|
|
|
307
307
|
Exclude<
|
|
308
308
|
Exclude<
|
|
309
309
|
// retrieves context R from the actual implementation of the handler
|
|
310
|
-
Impl[K] extends { raw: any }
|
|
311
|
-
|
|
310
|
+
Impl[K] extends { raw: any }
|
|
311
|
+
? Impl[K]["raw"] extends (...args: any[]) => Effect.Effect<any, any, infer R> ? R
|
|
312
|
+
: Impl[K]["raw"] extends Effect.Effect<any, any, infer R> ? R
|
|
312
313
|
: Impl[K]["raw"] extends (...args: any[]) => Generator<
|
|
313
|
-
YieldWrap<Effect<any, any, infer R>>,
|
|
314
|
+
YieldWrap<Effect.Effect<any, any, infer R>>,
|
|
314
315
|
any,
|
|
315
316
|
any
|
|
316
317
|
> ? R
|
|
317
318
|
: never
|
|
318
|
-
: Impl[K] extends (...args: any[]) => Effect<any, any, infer R> ? R
|
|
319
|
-
: Impl[K] extends Effect<any, any, infer R> ? R
|
|
319
|
+
: Impl[K] extends (...args: any[]) => Effect.Effect<any, any, infer R> ? R
|
|
320
|
+
: Impl[K] extends Effect.Effect<any, any, infer R> ? R
|
|
320
321
|
: Impl[K] extends (...args: any[]) => Generator<
|
|
321
|
-
YieldWrap<Effect<any, any, infer R>>,
|
|
322
|
+
YieldWrap<Effect.Effect<any, any, infer R>>,
|
|
322
323
|
any,
|
|
323
324
|
any
|
|
324
325
|
> ? R
|
|
@@ -347,7 +348,9 @@ export const makeRouter = <
|
|
|
347
348
|
dependencies: MakeDependencies,
|
|
348
349
|
make: (
|
|
349
350
|
match: any
|
|
350
|
-
) =>
|
|
351
|
+
) =>
|
|
352
|
+
| Effect.Effect<THandlers, MakeE, MakeR>
|
|
353
|
+
| Generator<YieldWrap<Effect.Effect<any, MakeE, MakeR>>, THandlers, any>
|
|
351
354
|
) => {
|
|
352
355
|
const dependenciesL = (dependencies ? Layer.mergeAll(...dependencies as any) : Layer.empty) as Layer.Layer<
|
|
353
356
|
LayerUtils.GetLayersSuccess<MakeDependencies>,
|
|
@@ -359,7 +362,7 @@ export const makeRouter = <
|
|
|
359
362
|
.gen(function*() {
|
|
360
363
|
const finalMake = ((make as any)[Symbol.toStringTag] === "GeneratorFunction"
|
|
361
364
|
? Effect.fnUntraced(make as any)(router3) as any
|
|
362
|
-
: make(router3) as any) as Effect<THandlers, MakeE, MakeR>
|
|
365
|
+
: make(router3) as any) as Effect.Effect<THandlers, MakeE, MakeR>
|
|
363
366
|
|
|
364
367
|
const controllers = yield* finalMake
|
|
365
368
|
|
|
@@ -384,7 +387,7 @@ export const makeRouter = <
|
|
|
384
387
|
} as any
|
|
385
388
|
: resource,
|
|
386
389
|
(payload: any, headers: any) =>
|
|
387
|
-
(handler.handler(payload, headers) as Effect<unknown, unknown, unknown>).pipe(
|
|
390
|
+
(handler.handler(payload, headers) as Effect.Effect<unknown, unknown, unknown>).pipe(
|
|
388
391
|
Effect.withSpan(`Request.${meta.moduleName}.${resource._tag}`, {
|
|
389
392
|
captureStackTrace: () => handler.stack // capturing the handler stack is the main reason why we are doing the span here
|
|
390
393
|
})
|
|
@@ -398,11 +401,11 @@ export const makeRouter = <
|
|
|
398
401
|
req: any,
|
|
399
402
|
headers: HttpHeaders.Headers
|
|
400
403
|
) => Effect.Effect<
|
|
401
|
-
Effect.Success<ReturnType<THandlers[K]["handler"]>>,
|
|
402
|
-
| Effect.Error<ReturnType<THandlers[K]["handler"]>>
|
|
404
|
+
Effect.Effect.Success<ReturnType<THandlers[K]["handler"]>>,
|
|
405
|
+
| Effect.Effect.Error<ReturnType<THandlers[K]["handler"]>>
|
|
403
406
|
| GetEffectError<RequestContextMap, Resource[K]["config"]>,
|
|
404
407
|
Exclude<
|
|
405
|
-
Effect.Context<ReturnType<THandlers[K]["handler"]>>,
|
|
408
|
+
Effect.Effect.Context<ReturnType<THandlers[K]["handler"]>>,
|
|
406
409
|
ContextProviderA | GetEffectContext<RequestContextMap, Resource[K]["config"]>
|
|
407
410
|
>
|
|
408
411
|
>
|
|
@@ -426,7 +429,7 @@ export const makeRouter = <
|
|
|
426
429
|
acc[`${meta.moduleName}.${resource._tag}`] = handler
|
|
427
430
|
return acc
|
|
428
431
|
}, {} as Record<string, any>) as any // TODO
|
|
429
|
-
})) as unknown as Layer<
|
|
432
|
+
})) as unknown as Layer.Layer<
|
|
430
433
|
{ [K in keyof RequestModules]: Rpc.Handler<K> },
|
|
431
434
|
MakeE,
|
|
432
435
|
RpcRouteR<typeof mapped[keyof typeof mapped]>
|
|
@@ -457,10 +460,10 @@ export const makeRouter = <
|
|
|
457
460
|
// Multiple times duplicated the "good" overload, so that errors will only mention the last overload when failing
|
|
458
461
|
<
|
|
459
462
|
const Make extends {
|
|
460
|
-
dependencies?:
|
|
463
|
+
dependencies?: ReadonlyArray<Layer.Layer.Any>
|
|
461
464
|
effect: (match: typeof router3) => Generator<
|
|
462
465
|
YieldWrap<
|
|
463
|
-
Effect<
|
|
466
|
+
Effect.Effect<
|
|
464
467
|
any,
|
|
465
468
|
any,
|
|
466
469
|
any
|
|
@@ -479,9 +482,9 @@ export const makeRouter = <
|
|
|
479
482
|
never,
|
|
480
483
|
| MakeErrors<Make>
|
|
481
484
|
| Service.MakeDepsE<Make>
|
|
482
|
-
| Layer.Error<typeof middleware.Default>,
|
|
485
|
+
| Layer.Layer.Error<typeof middleware.Default>,
|
|
483
486
|
| Service.MakeDepsIn<Make>
|
|
484
|
-
| Layer.Context<typeof middleware.Default>
|
|
487
|
+
| Layer.Layer.Context<typeof middleware.Default>
|
|
485
488
|
| Exclude<
|
|
486
489
|
MakeContext<Make>,
|
|
487
490
|
MakeDepsOut<Make>
|
|
@@ -494,10 +497,10 @@ export const makeRouter = <
|
|
|
494
497
|
}
|
|
495
498
|
<
|
|
496
499
|
const Make extends {
|
|
497
|
-
dependencies?:
|
|
500
|
+
dependencies?: ReadonlyArray<Layer.Layer.Any>
|
|
498
501
|
effect: (match: typeof router3) => Generator<
|
|
499
502
|
YieldWrap<
|
|
500
|
-
Effect<
|
|
503
|
+
Effect.Effect<
|
|
501
504
|
any,
|
|
502
505
|
any,
|
|
503
506
|
any
|
|
@@ -514,9 +517,9 @@ export const makeRouter = <
|
|
|
514
517
|
never,
|
|
515
518
|
| MakeErrors<Make>
|
|
516
519
|
| Service.MakeDepsE<Make>
|
|
517
|
-
| Layer.Error<typeof middleware.Default>,
|
|
520
|
+
| Layer.Layer.Error<typeof middleware.Default>,
|
|
518
521
|
| Service.MakeDepsIn<Make>
|
|
519
|
-
| Layer.Context<typeof middleware.Default>
|
|
522
|
+
| Layer.Layer.Context<typeof middleware.Default>
|
|
520
523
|
| Exclude<
|
|
521
524
|
MakeContext<Make>,
|
|
522
525
|
MakeDepsOut<Make>
|
|
@@ -560,22 +563,22 @@ export type MakeDeps<Make> = Make extends { readonly dependencies: ReadonlyArray
|
|
|
560
563
|
? Make["dependencies"][number]
|
|
561
564
|
: never
|
|
562
565
|
|
|
563
|
-
export type MakeErrors<Make> = /*Make extends { readonly effect: (_: any) => Effect<any, infer E, any> } ? E
|
|
564
|
-
: Make extends { readonly effect: (_: any) => Effect<any, never, any> } ? never
|
|
566
|
+
export type MakeErrors<Make> = /*Make extends { readonly effect: (_: any) => Effect.Effect<any, infer E, any> } ? E
|
|
567
|
+
: Make extends { readonly effect: (_: any) => Effect.Effect<any, never, any> } ? never
|
|
565
568
|
: */
|
|
566
|
-
Make extends { readonly effect: (_: any) => Generator<YieldWrap<Effect<any, never, any>>, any, any> } ? never
|
|
567
|
-
: Make extends { readonly effect: (_: any) => Generator<YieldWrap<Effect<any, infer E, any>>, any, any> } ? E
|
|
569
|
+
Make extends { readonly effect: (_: any) => Generator<YieldWrap<Effect.Effect<any, never, any>>, any, any> } ? never
|
|
570
|
+
: Make extends { readonly effect: (_: any) => Generator<YieldWrap<Effect.Effect<any, infer E, any>>, any, any> } ? E
|
|
568
571
|
: never
|
|
569
572
|
|
|
570
|
-
export type MakeContext<Make> = /*Make extends { readonly effect: (_: any) => Effect<any, any, infer R> } ? R
|
|
571
|
-
: Make extends { readonly effect: (_: any) => Effect<any, any, never> } ? never
|
|
573
|
+
export type MakeContext<Make> = /*Make extends { readonly effect: (_: any) => Effect.Effect<any, any, infer R> } ? R
|
|
574
|
+
: Make extends { readonly effect: (_: any) => Effect.Effect<any, any, never> } ? never
|
|
572
575
|
: */
|
|
573
|
-
Make extends { readonly effect: (_: any) => Generator<YieldWrap<Effect<any, any, never>>, any, any> } ? never
|
|
574
|
-
: Make extends { readonly effect: (_: any) => Generator<YieldWrap<Effect<any, any, infer R>>, any, any> } ? R
|
|
576
|
+
Make extends { readonly effect: (_: any) => Generator<YieldWrap<Effect.Effect<any, any, never>>, any, any> } ? never
|
|
577
|
+
: Make extends { readonly effect: (_: any) => Generator<YieldWrap<Effect.Effect<any, any, infer R>>, any, any> } ? R
|
|
575
578
|
: never
|
|
576
579
|
|
|
577
580
|
export type MakeHandlers<Make, _Handlers extends Record<string, any>> = /*Make extends
|
|
578
|
-
{ readonly effect: (_: any) => Effect<{ [K in keyof Handlers]: AnyHandler<Handlers[K]> }, any, any> }
|
|
581
|
+
{ readonly effect: (_: any) => Effect.Effect<{ [K in keyof Handlers]: AnyHandler<Handlers[K]> }, any, any> }
|
|
579
582
|
? Effect.Success<ReturnType<Make["effect"]>>
|
|
580
583
|
: */
|
|
581
584
|
Make extends { readonly effect: (_: any) => Generator<YieldWrap<any>, infer S, any> } ? S
|
package/src/api/setupRequest.ts
CHANGED
|
@@ -26,7 +26,7 @@ export const getRC = Effect.all({
|
|
|
26
26
|
namespace: storeId
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
-
const withRequestSpan = (name = "request", options?: Tracer.SpanOptions) => <R, E, A>(f: Effect<A, E, R>) =>
|
|
29
|
+
const withRequestSpan = (name = "request", options?: Tracer.SpanOptions) => <R, E, A>(f: Effect.Effect<A, E, R>) =>
|
|
30
30
|
Effect.andThen(
|
|
31
31
|
getRC,
|
|
32
32
|
(ctx) =>
|
|
@@ -43,7 +43,7 @@ const withRequestSpan = (name = "request", options?: Tracer.SpanOptions) => <R,
|
|
|
43
43
|
)
|
|
44
44
|
|
|
45
45
|
export const setupRequestContextFromCurrent =
|
|
46
|
-
(name = "request", options?: Tracer.SpanOptions) => <R, E, A>(self: Effect<A, E, R>) =>
|
|
46
|
+
(name = "request", options?: Tracer.SpanOptions) => <R, E, A>(self: Effect.Effect<A, E, R>) =>
|
|
47
47
|
self
|
|
48
48
|
.pipe(
|
|
49
49
|
withRequestSpan(name, options),
|
|
@@ -51,7 +51,7 @@ export const setupRequestContextFromCurrent =
|
|
|
51
51
|
)
|
|
52
52
|
|
|
53
53
|
// TODO: consider integrating Effect.withParentSpan
|
|
54
|
-
export function setupRequestContext<R, E, A>(self: Effect<A, E, R>, requestContext: RequestContext) {
|
|
54
|
+
export function setupRequestContext<R, E, A>(self: Effect.Effect<A, E, R>, requestContext: RequestContext) {
|
|
55
55
|
const layer = Layer.mergeAll(
|
|
56
56
|
ContextMapContainer.layer,
|
|
57
57
|
Layer.succeed(LocaleRef, requestContext.locale),
|
|
@@ -65,7 +65,7 @@ export function setupRequestContext<R, E, A>(self: Effect<A, E, R>, requestConte
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export function setupRequestContextWithCustomSpan<R, E, A>(
|
|
68
|
-
self: Effect<A, E, R>,
|
|
68
|
+
self: Effect.Effect<A, E, R>,
|
|
69
69
|
requestContext: RequestContext,
|
|
70
70
|
name: string,
|
|
71
71
|
options?: Tracer.SpanOptions
|
package/src/errorReporter.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { getRC } from "./api/setupRequest.js"
|
|
|
5
5
|
import { CauseException, tryToJson, tryToReport } from "./errors.js"
|
|
6
6
|
import { InfraLogger } from "./logger.js"
|
|
7
7
|
|
|
8
|
-
const tryCauseException = <E>(cause: Cause<E>, name: string): CauseException<E> => {
|
|
8
|
+
const tryCauseException = <E>(cause: Cause.Cause<E>, name: string): CauseException<E> => {
|
|
9
9
|
try {
|
|
10
10
|
return new CauseException(cause, name)
|
|
11
11
|
} catch {
|
|
@@ -17,7 +17,7 @@ export function reportError(
|
|
|
17
17
|
name: string
|
|
18
18
|
) {
|
|
19
19
|
return (
|
|
20
|
-
cause: Cause<unknown>,
|
|
20
|
+
cause: Cause.Cause<unknown>,
|
|
21
21
|
extras?: Record<string, unknown>,
|
|
22
22
|
level: LogLevel.LogLevel = LogLevel.Error
|
|
23
23
|
) =>
|
|
@@ -75,7 +75,7 @@ function reportSentry(
|
|
|
75
75
|
export function logError<E>(
|
|
76
76
|
name: string
|
|
77
77
|
) {
|
|
78
|
-
return (cause: Cause<E>, extras?: Record<string, unknown>) =>
|
|
78
|
+
return (cause: Cause.Cause<E>, extras?: Record<string, unknown>) =>
|
|
79
79
|
Effect
|
|
80
80
|
.gen(function*() {
|
|
81
81
|
if (Cause.isInterruptedOnly(cause)) {
|
package/src/rateLimit.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// * failure, or interruption.
|
|
6
6
|
// */
|
|
7
7
|
// export function withPermitsDuration(permits: number, duration: Duration) {
|
|
8
|
-
// return (self: TSemaphore): <R, E, A>(effect: Effect<R, E, A>) => Effect<R, E, A> => {
|
|
8
|
+
// return (self: TSemaphore): <R, E, A>(effect: Effect.Effect<R, E, A>) => Effect.Effect<R, E, A> => {
|
|
9
9
|
// return effect =>
|
|
10
10
|
// Effect.uninterruptibleMask(
|
|
11
11
|
// restore =>
|
|
@@ -29,8 +29,8 @@ import type { Semaphore } from "effect-app/Effect"
|
|
|
29
29
|
* delayed by duration after the effect completes execution, whether by success,
|
|
30
30
|
* failure, or interruption.
|
|
31
31
|
*/
|
|
32
|
-
export function SEM_withPermitsDuration(permits: number, duration: Duration) {
|
|
33
|
-
return (self: Semaphore): <R, E, A>(effect: Effect<A, E, R>) => Effect<A, E, R> => {
|
|
32
|
+
export function SEM_withPermitsDuration(permits: number, duration: Duration.Duration) {
|
|
33
|
+
return (self: Semaphore): <R, E, A>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R> => {
|
|
34
34
|
return (effect) =>
|
|
35
35
|
Effect.uninterruptibleMask(
|
|
36
36
|
(restore) =>
|
|
@@ -47,8 +47,8 @@ export function SEM_withPermitsDuration(permits: number, duration: Duration) {
|
|
|
47
47
|
|
|
48
48
|
export function batchPar<R, E, A, R2, E2, A2, T>(
|
|
49
49
|
n: number,
|
|
50
|
-
forEachItem: (item: T, iWithinBatch: number, batchI: number) => Effect<A, E, R>,
|
|
51
|
-
forEachBatch: (a: NonEmptyArray<A>, i: number) => Effect<A2, E2, R2>
|
|
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
52
|
) {
|
|
53
53
|
return (items: Iterable<T>) =>
|
|
54
54
|
Effect.forEach(
|
|
@@ -63,8 +63,8 @@ export function batchPar<R, E, A, R2, E2, A2, T>(
|
|
|
63
63
|
|
|
64
64
|
export function batch<R, E, A, R2, E2, A2, T>(
|
|
65
65
|
n: number,
|
|
66
|
-
forEachItem: (item: T, iWithinBatch: number, batchI: number) => Effect<A, E, R>,
|
|
67
|
-
forEachBatch: (a: NonEmptyArray<A>, i: number) => Effect<A2, E2, R2>
|
|
66
|
+
forEachItem: (item: T, iWithinBatch: number, batchI: number) => Effect.Effect<A, E, R>,
|
|
67
|
+
forEachBatch: (a: NonEmptyArray<A>, i: number) => Effect.Effect<A2, E2, R2>
|
|
68
68
|
) {
|
|
69
69
|
return (items: Iterable<T>) =>
|
|
70
70
|
Effect.forEach(
|
|
@@ -82,8 +82,8 @@ export function batch<R, E, A, R2, E2, A2, T>(
|
|
|
82
82
|
// ) {
|
|
83
83
|
// return <T>(items: Iterable<T>) =>
|
|
84
84
|
// <R, E, A, R2, E2, A2>(
|
|
85
|
-
// forEachItem: (i: T) => Effect<R, E, A>,
|
|
86
|
-
// forEachBatch: (a: Chunk<A>) => Effect<R2, E2, A2>
|
|
85
|
+
// forEachItem: (i: T) => Effect.Effect<R, E, A>,
|
|
86
|
+
// forEachBatch: (a: Chunk<A>) => Effect.Effect<R2, E2, A2>
|
|
87
87
|
// ) =>
|
|
88
88
|
// Stream.fromCollection(items)
|
|
89
89
|
// .rechunk(n)
|
|
@@ -94,11 +94,11 @@ export function batch<R, E, A, R2, E2, A2, T>(
|
|
|
94
94
|
|
|
95
95
|
export function naiveRateLimit(
|
|
96
96
|
n: number,
|
|
97
|
-
d: Duration
|
|
97
|
+
d: Duration.Duration
|
|
98
98
|
) {
|
|
99
99
|
return <T>(items: Iterable<T>) => (<R, E, A, R2, E2, A2>(
|
|
100
|
-
forEachItem: (i: T) => Effect<A, E, R>,
|
|
101
|
-
forEachBatch: (a: A[]) => Effect<A2, E2, R2>
|
|
100
|
+
forEachItem: (i: T) => Effect.Effect<A, E, R>,
|
|
101
|
+
forEachBatch: (a: A[]) => Effect.Effect<A2, E2, R2>
|
|
102
102
|
) =>
|
|
103
103
|
Effect.forEach(
|
|
104
104
|
Array.chunk_(items, n),
|
package/test/controller.test.ts
CHANGED
|
@@ -205,12 +205,7 @@ export const middleware3 = MiddlewareMaker
|
|
|
205
205
|
.middleware(Test)
|
|
206
206
|
.middleware(BogusMiddleware)
|
|
207
207
|
|
|
208
|
-
export const { TaggedRequest: Req } = makeRpcClient(RequestContextMap)
|
|
209
|
-
/** Disable authentication requirement */
|
|
210
|
-
allowAnonymous?: true
|
|
211
|
-
/** Control the roles that are required to access the resource */
|
|
212
|
-
allowRoles?: readonly string[]
|
|
213
|
-
}>()
|
|
208
|
+
export const { TaggedRequest: Req } = makeRpcClient(RequestContextMap)
|
|
214
209
|
|
|
215
210
|
export class Eff extends Req<Eff>()("Eff", {}, { success: S.Void }) {}
|
|
216
211
|
export class Gen extends Req<Gen>()("Gen", {}, { success: S.Void }) {}
|
|
@@ -352,7 +347,7 @@ it("sorts based on requirements", () => {
|
|
|
352
347
|
|
|
353
348
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
354
349
|
const matched = matchAll({ router })
|
|
355
|
-
expectTypeOf({} as Layer.Context<typeof matched>).toEqualTypeOf<
|
|
350
|
+
expectTypeOf({} as Layer.Layer.Context<typeof matched>).toEqualTypeOf<
|
|
356
351
|
RpcSerialization.RpcSerialization | SomeService | "str"
|
|
357
352
|
>()
|
|
358
353
|
|
|
@@ -410,7 +405,7 @@ const router2 = r2.Router(Something)({
|
|
|
410
405
|
|
|
411
406
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
412
407
|
const matched2 = matchAll({ router: router2 })
|
|
413
|
-
expectTypeOf({} as Layer.Context<typeof matched2>).toEqualTypeOf<
|
|
408
|
+
expectTypeOf({} as Layer.Layer.Context<typeof matched2>).toEqualTypeOf<
|
|
414
409
|
RpcSerialization.RpcSerialization | SomeService | "str"
|
|
415
410
|
>()
|
|
416
411
|
|
|
@@ -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;AAC7F,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD,OAAO,EAAW,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;AAKtC,OAAO,EAAE,cAAc,EAAsB,YAAY,EAAqB,YAAY,EAAoB,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAY,MAAM,eAAe,CAAA;;cA0E/G,QAAQ;;AADzE,cAAM,kBACJ,SAAQ,uBAA0F;IAElG,MAAM,CAAC,OAAO,uDAUZ;CACH;;;;;AAMD,qBAAa,eAAgB,SAAQ,oBAA4D;IAC/F,MAAM,CAAC,OAAO,6CAUZ;CACH;AAkFD,eAAO,MAAM,WAAW;;;;;;;;;;YAKM,CAAA;AAE9B,eAAO,MAAuB,GAAG
|
|
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;AAC7F,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD,OAAO,EAAW,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;AAKtC,OAAO,EAAE,cAAc,EAAsB,YAAY,EAAqB,YAAY,EAAoB,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAY,MAAM,eAAe,CAAA;;cA0E/G,QAAQ;;AADzE,cAAM,kBACJ,SAAQ,uBAA0F;IAElG,MAAM,CAAC,OAAO,uDAUZ;CACH;;;;;AAMD,qBAAa,eAAgB,SAAQ,oBAA4D;IAC/F,MAAM,CAAC,OAAO,6CAUZ;CACH;AAkFD,eAAO,MAAM,WAAW;;;;;;;;;;YAKM,CAAA;AAE9B,eAAO,MAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAqC,CAAA;;;;;;;;;;;;;;AAEtE,qBAAa,GAAI,SAAQ,QAA0C;CAAG;;;;;;;;;;;;;;AACtE,qBAAa,GAAI,SAAQ,QAA0C;CAAG;;;;;;;;;;;;;;;;AAEtE,qBAAa,WAAY,SAAQ,gBAEV;CAAG;;;;;;;;;;;;;;;;AAgB1B,qBAAa,YAAa,SAAQ,iBAET;CAAG;;;;;;;;;;;;;;;;AAE5B,qBAAa,aAAc,SAAQ,kBAEA;CAAG;;;;;AAItC,qBAAa,gBAAiB,SAAQ,qBAKpC;CAAG;;;;;AASL,qBAAa,aAAc,SAAQ,kBAOjC;CAAG;;;;;AAEL,qBAAa,iBAAkB,SAAQ,sBAKrC;CAAG;AAEL,eAAO,MAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAE,QAAQ;;qGAE9B,CAAA;AAED,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEd,CAAA"}
|
package/test/dist/fixtures.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ declare const SomeElse_base: (abstract new (service: {
|
|
|
63
63
|
} & {
|
|
64
64
|
use: <X>(body: (_: {
|
|
65
65
|
b: number;
|
|
66
|
-
}) => X) => X extends Effect.Effect<infer A, infer E_1, infer R_3> ? Effect.Effect<A, E_1,
|
|
66
|
+
}) => X) => X extends Effect.Effect<infer A, infer E_1, infer R_3> ? Effect.Effect<A, E_1, R_3 | SomeElse> : Effect.Effect<X, never, SomeElse>;
|
|
67
67
|
};
|
|
68
68
|
export declare class SomeElse extends SomeElse_base {
|
|
69
69
|
}
|
package/test/requires.test.ts
CHANGED
|
@@ -70,7 +70,7 @@ const testSuite = (_mw: typeof middleware3) =>
|
|
|
70
70
|
payload: { _tag: "Test" },
|
|
71
71
|
clientId: 0,
|
|
72
72
|
rpc: { ...Rpc.fromTaggedRequest(TestRequest), annotations: Context.make(_mw.requestContext, {}) },
|
|
73
|
-
next: Effect.void as unknown as Effect<SuccessValue, never, any>
|
|
73
|
+
next: Effect.void as unknown as Effect.Effect<SuccessValue, never, any>
|
|
74
74
|
}
|
|
75
75
|
const layer = _mw.layer.pipe(
|
|
76
76
|
Layer.provide([
|