@effect-app/infra 2.73.4 → 2.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/QueueMaker/errors.d.ts +1 -1
- package/dist/QueueMaker/errors.d.ts.map +1 -1
- package/dist/api/layerUtils.d.ts +22 -0
- package/dist/api/layerUtils.d.ts.map +1 -0
- package/dist/api/layerUtils.js +2 -0
- package/dist/api/routing/middleware/ContextProvider.d.ts +41 -0
- package/dist/api/routing/middleware/ContextProvider.d.ts.map +1 -0
- package/dist/api/routing/middleware/ContextProvider.js +27 -0
- package/dist/api/routing/middleware/DynamicMiddleware.d.ts +61 -0
- package/dist/api/routing/middleware/DynamicMiddleware.d.ts.map +1 -0
- package/dist/api/routing/middleware/DynamicMiddleware.js +45 -0
- package/dist/api/routing/middleware/dynamic-middleware.d.ts +26 -0
- package/dist/api/routing/middleware/dynamic-middleware.d.ts.map +1 -0
- package/dist/api/routing/middleware/dynamic-middleware.js +39 -0
- package/dist/api/routing/middleware/generic-middleware.d.ts +9 -0
- package/dist/api/routing/middleware/generic-middleware.d.ts.map +1 -0
- package/dist/api/routing/middleware/generic-middleware.js +20 -0
- package/dist/api/routing/middleware/middleware.d.ts +23 -0
- package/dist/api/routing/middleware/middleware.d.ts.map +1 -0
- package/dist/api/routing/middleware/middleware.js +91 -0
- package/dist/api/routing/middleware.d.ts +6 -0
- package/dist/api/routing/middleware.d.ts.map +1 -0
- package/dist/api/routing/middleware.js +8 -0
- package/dist/api/routing/tsort.d.ts +8 -0
- package/dist/api/routing/tsort.d.ts.map +1 -0
- package/dist/api/routing/tsort.js +51 -0
- package/dist/api/routing.d.ts +36 -46
- package/dist/api/routing.d.ts.map +1 -1
- package/dist/api/routing.js +7 -56
- package/package.json +33 -5
- package/src/api/layerUtils.ts +34 -0
- package/src/api/routing/middleware/ContextProvider.ts +148 -0
- package/src/api/routing/middleware/DynamicMiddleware.ts +317 -0
- package/src/api/routing/middleware/dynamic-middleware.ts +158 -0
- package/src/api/routing/middleware/generic-middleware.ts +38 -0
- package/src/api/routing/middleware/middleware.ts +120 -0
- package/src/api/routing/middleware.ts +7 -0
- package/src/api/routing/tsort.ts +56 -0
- package/src/api/routing.ts +47 -118
- package/test/controller.test.ts +212 -51
- package/test/dist/controller.legacy2.test.d.ts.map +1 -0
- package/test/dist/controller.legacy3.test.d.ts.map +1 -0
- package/test/dist/controller.test copy.d.ts +169 -0
- package/test/dist/controller.test copy.d.ts.map +1 -0
- package/test/dist/controller.test copy.js +152 -0
- package/test/dist/controller.test.d.ts.map +1 -1
- package/test/dist/controller6.test.d.ts.map +1 -0
- package/test/dist/controller7.test.d.ts.map +1 -0
- package/test/dist/filterApi.test.d.ts.map +1 -0
- package/dist/api/routing/DynamicMiddleware.d.ts +0 -91
- package/dist/api/routing/DynamicMiddleware.d.ts.map +0 -1
- package/dist/api/routing/DynamicMiddleware.js +0 -56
- package/src/api/routing/DynamicMiddleware.ts +0 -415
package/test/controller.test.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
|
-
import { type MakeContext, type MakeErrors, makeRouter } from "@effect-app/infra/api/routing"
|
|
3
|
+
import { type MakeContext, type MakeErrors, makeRouter, RequestCacheLayers } from "@effect-app/infra/api/routing"
|
|
4
4
|
import type { RequestContext } from "@effect-app/infra/RequestContext"
|
|
5
|
-
import { expectTypeOf } from "@effect/vitest"
|
|
6
|
-
import { Context, Effect, Layer, S } from "effect-app"
|
|
7
|
-
import {
|
|
8
|
-
import { HttpServerRequest } from "effect-app/http"
|
|
5
|
+
import { expect, expectTypeOf, it } from "@effect/vitest"
|
|
6
|
+
import { type Array, Context, Effect, Layer, Option, S } from "effect-app"
|
|
7
|
+
import { InvalidStateError, makeRpcClient, type RPCContextMap, UnauthorizedError } from "effect-app/client"
|
|
8
|
+
import { type HttpHeaders, type HttpRouter, HttpServerRequest } from "effect-app/http"
|
|
9
9
|
import { Class, TaggedError } from "effect-app/Schema"
|
|
10
|
-
import { ContextProvider, makeMiddleware, mergeContextProviders, MergedContextProvider } from "../src/api/routing/
|
|
10
|
+
import { ContextProvider, DefaultGenericMiddlewares, makeMiddleware, mergeContextProviders, MergedContextProvider } from "../src/api/routing/middleware.js"
|
|
11
|
+
import { sort } from "../src/api/routing/tsort.js"
|
|
11
12
|
import { SomeService } from "./query.test.js"
|
|
12
13
|
|
|
13
14
|
class UserProfile extends Context.assignTag<UserProfile, UserProfile>("UserProfile")(
|
|
14
15
|
Class<UserProfile>("UserProfile")({
|
|
15
|
-
id: S.String
|
|
16
|
+
id: S.String,
|
|
17
|
+
roles: S.Array(S.String)
|
|
16
18
|
})
|
|
17
19
|
) {
|
|
18
20
|
}
|
|
@@ -32,7 +34,7 @@ export class Some extends Context.TagMakeId("Some", Effect.succeed({ a: 1 }))<So
|
|
|
32
34
|
export class SomeElse extends Context.TagMakeId("SomeElse", Effect.succeed({ b: 2 }))<SomeElse>() {}
|
|
33
35
|
|
|
34
36
|
// @effect-diagnostics-next-line missingEffectServiceDependency:off
|
|
35
|
-
const
|
|
37
|
+
export const someContextProvider = ContextProvider({
|
|
36
38
|
effect: Effect.gen(function*() {
|
|
37
39
|
yield* SomeService
|
|
38
40
|
if (Math.random() > 0.5) return yield* new CustomError1()
|
|
@@ -59,7 +61,7 @@ class MyContextProvider extends Effect.Service<MyContextProvider>()("MyContextPr
|
|
|
59
61
|
if (Math.random() > 0.5) return yield* new CustomError1()
|
|
60
62
|
|
|
61
63
|
return Effect.gen(function*() {
|
|
62
|
-
// the only
|
|
64
|
+
// the only requiremeno you can have are the one provided by HttpRouter.HttpRouter.Provided
|
|
63
65
|
yield* HttpServerRequest.HttpServerRequest
|
|
64
66
|
|
|
65
67
|
// this is allowed here but mergeContextProviders/MergedContextProvider will trigger an error
|
|
@@ -74,65 +76,142 @@ class MyContextProvider extends Effect.Service<MyContextProvider>()("MyContextPr
|
|
|
74
76
|
})
|
|
75
77
|
}) {}
|
|
76
78
|
|
|
79
|
+
class RequestCacheContext extends Effect.Service<RequestCacheContext>()("RequestCacheContext", {
|
|
80
|
+
effect: Effect.gen(function*() {
|
|
81
|
+
return Effect.gen(function*() {
|
|
82
|
+
const ctx = yield* Layer.build(RequestCacheLayers)
|
|
83
|
+
return ctx as Context.Context<any> // todo: ugh.
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
}) {}
|
|
87
|
+
|
|
77
88
|
const merged = mergeContextProviders(MyContextProvider)
|
|
78
89
|
export const contextProvider2 = ContextProvider(merged)
|
|
79
90
|
export const contextProvider3 = MergedContextProvider(MyContextProvider)
|
|
80
|
-
|
|
81
|
-
expectTypeOf(contextProvider2).toEqualTypeOf<typeof contextProvider>()
|
|
91
|
+
expectTypeOf(contextProvider2).toEqualTypeOf<typeof someContextProvider>()
|
|
82
92
|
expectTypeOf(contextProvider3).toEqualTypeOf<typeof contextProvider2>()
|
|
93
|
+
const merged2 = mergeContextProviders(MyContextProvider, RequestCacheContext)
|
|
94
|
+
export const contextProvider22 = ContextProvider(merged2)
|
|
95
|
+
export const contextProvider23 = MergedContextProvider(MyContextProvider, RequestCacheContext)
|
|
96
|
+
expectTypeOf(contextProvider23).toEqualTypeOf<typeof contextProvider22>()
|
|
83
97
|
|
|
84
98
|
export type RequestContextMap = {
|
|
85
|
-
allowAnonymous: RPCContextMap.Inverted<
|
|
86
|
-
|
|
87
|
-
|
|
99
|
+
allowAnonymous: RPCContextMap.Inverted<UserProfile, typeof NotLoggedInError>
|
|
100
|
+
requireRoles: RPCContextMap.Custom<never, typeof UnauthorizedError, Array<string>>
|
|
101
|
+
test: RPCContextMap<never, typeof S.Never>
|
|
88
102
|
}
|
|
89
103
|
|
|
90
104
|
const Str = Context.GenericTag<"str", "str">("str")
|
|
91
105
|
const Str2 = Context.GenericTag<"str2", "str">("str2")
|
|
92
106
|
|
|
107
|
+
class AllowAnonymous extends Effect.Service<AllowAnonymous>()("AllowAnonymous", {
|
|
108
|
+
effect: Effect.gen(function*() {
|
|
109
|
+
return {
|
|
110
|
+
handle: Effect.fn(function*(opts: { allowAnonymous?: false }, headers: Record<string, string>) {
|
|
111
|
+
const isLoggedIn = !!headers["x-user"]
|
|
112
|
+
if (!isLoggedIn) {
|
|
113
|
+
if (!opts.allowAnonymous) {
|
|
114
|
+
return yield* new NotLoggedInError({ message: "Not logged in" })
|
|
115
|
+
}
|
|
116
|
+
return Option.none()
|
|
117
|
+
}
|
|
118
|
+
return Option.some(Context.make(
|
|
119
|
+
UserProfile,
|
|
120
|
+
{ id: "whatever", roles: ["user", "manager"] }
|
|
121
|
+
))
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
}) {}
|
|
126
|
+
|
|
127
|
+
class RequireRoles extends Effect.Service<RequireRoles>()("RequireRoles", {
|
|
128
|
+
effect: Effect.gen(function*() {
|
|
129
|
+
return {
|
|
130
|
+
handle: Effect.fn(
|
|
131
|
+
function*(cfg: { requireRoles?: readonly string[] }) {
|
|
132
|
+
// we don't know if the service will be provided or not, so we use option..
|
|
133
|
+
const userProfile = yield* Effect.serviceOption(UserProfile)
|
|
134
|
+
const { requireRoles } = cfg
|
|
135
|
+
if (requireRoles && !userProfile.value?.roles?.some((role) => requireRoles.includes(role))) {
|
|
136
|
+
return yield* new UnauthorizedError({ message: "don't have the right roles" })
|
|
137
|
+
}
|
|
138
|
+
return Option.none<Context<never>>()
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
}) {
|
|
144
|
+
static dependsOn = [AllowAnonymous]
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
class Test extends Effect.Service<Test>()("Test", {
|
|
148
|
+
effect: Effect.gen(function*() {
|
|
149
|
+
return {
|
|
150
|
+
handle: Effect.fn(function*() {
|
|
151
|
+
return Option.none<Context<never>>()
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
}) {}
|
|
156
|
+
|
|
157
|
+
export class MiddlewareLogger2 extends Effect.Service<MiddlewareLogger2>()("MiddlewareLogger2", {
|
|
158
|
+
effect: Effect.gen(function*() {
|
|
159
|
+
return <A, E>(
|
|
160
|
+
handle: (input: any, headers: HttpHeaders.Headers) => Effect.Effect<A, E, HttpRouter.HttpRouter.Provided>,
|
|
161
|
+
_moduleName: string
|
|
162
|
+
) =>
|
|
163
|
+
Effect.fnUntraced(function*(input: any, headers: HttpHeaders.Headers) {
|
|
164
|
+
return yield* handle(input, headers)
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
}) {}
|
|
168
|
+
|
|
169
|
+
// TODO: eventually it might be nice if we have total control over order somehow..
|
|
170
|
+
// [ AddRequestNameToSpanContext, RequestCacheContext, UninterruptibleMiddleware, Dynamic(or individual, AllowAnonymous, RequireRoles, Test - or whichever order) ]
|
|
93
171
|
const middleware = makeMiddleware<RequestContextMap>()({
|
|
172
|
+
// TODO: I guess it makes sense to support just passing array of context providers too, like dynamicMiddlewares?
|
|
173
|
+
contextProvider: MergedContextProvider(RequestCacheContext, MyContextProvider),
|
|
174
|
+
genericMiddlewares: [...DefaultGenericMiddlewares, MiddlewareLogger2],
|
|
175
|
+
// or is the better api to use constructors outside, like how contextProvider is used now?
|
|
176
|
+
dynamicMiddlewares: {
|
|
177
|
+
requireRoles: RequireRoles,
|
|
178
|
+
allowAnonymous: AllowAnonymous,
|
|
179
|
+
test: Test
|
|
180
|
+
},
|
|
181
|
+
// // TODO: 0..n of these generic middlewares?
|
|
94
182
|
dependencies: [Layer.effect(Str2, Str)],
|
|
95
|
-
contextProvider,
|
|
96
183
|
execute: (maker) =>
|
|
97
184
|
Effect.gen(function*() {
|
|
98
|
-
return maker(
|
|
99
|
-
|
|
100
|
-
.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return yield* handler(req, headers).pipe(
|
|
114
|
-
Effect.provide(ctx as Context.Context<GetEffectContext<RequestContextMap, (typeof _schema)["config"]>>)
|
|
115
|
-
// I do expect the ContextMaker to provide this
|
|
116
|
-
// Effect.provideService(Some, new Some({ a: 1 }))
|
|
117
|
-
)
|
|
118
|
-
})
|
|
119
|
-
.pipe(
|
|
120
|
-
Effect.provide(
|
|
121
|
-
Effect
|
|
122
|
-
.gen(function*() {
|
|
123
|
-
yield* Effect.annotateCurrentSpan("request.name", moduleName ? `${moduleName}.${req._tag}` : req._tag)
|
|
124
|
-
|
|
125
|
-
// const httpReq = yield* HttpServerRequest.HttpServerRequest
|
|
126
|
-
|
|
127
|
-
//
|
|
128
|
-
})
|
|
129
|
-
.pipe(Layer.effectDiscard)
|
|
130
|
-
)
|
|
131
|
-
)
|
|
132
|
-
})
|
|
185
|
+
return maker(
|
|
186
|
+
(_schema, handler) => (req, headers) =>
|
|
187
|
+
// contextProvider and dynamicMiddlewares are already provided here.
|
|
188
|
+
// aka this runs "last"
|
|
189
|
+
Effect
|
|
190
|
+
.gen(function*() {
|
|
191
|
+
// you can use only HttpRouter.HttpRouter.Provided here as additional context
|
|
192
|
+
// and what ContextMaker provides too
|
|
193
|
+
// const someElse = yield* SomeElse
|
|
194
|
+
yield* Some // provided by ContextMaker
|
|
195
|
+
yield* HttpServerRequest.HttpServerRequest // provided by HttpRouter.HttpRouter.Provided
|
|
196
|
+
|
|
197
|
+
return yield* handler(req, headers)
|
|
198
|
+
})
|
|
199
|
+
)
|
|
133
200
|
})
|
|
134
201
|
})
|
|
135
202
|
|
|
203
|
+
const middleware2 = makeMiddleware<RequestContextMap>()({
|
|
204
|
+
// TODO: I guess it makes sense to support just passing array of context providers too, like dynamicMiddlewares?
|
|
205
|
+
contextProvider: MergedContextProvider(RequestCacheContext, MyContextProvider),
|
|
206
|
+
genericMiddlewares: [...DefaultGenericMiddlewares, MiddlewareLogger2],
|
|
207
|
+
// or is the better api to use constructors outside, like how contextProvider is used now?
|
|
208
|
+
dynamicMiddlewares: {
|
|
209
|
+
requireRoles: RequireRoles,
|
|
210
|
+
allowAnonymous: AllowAnonymous,
|
|
211
|
+
test: Test
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
|
|
136
215
|
export type RequestConfig = {
|
|
137
216
|
/** Disable authentication requirement */
|
|
138
217
|
allowAnonymous?: true
|
|
@@ -141,7 +220,8 @@ export type RequestConfig = {
|
|
|
141
220
|
}
|
|
142
221
|
export const { TaggedRequest: Req } = makeRpcClient<RequestConfig, RequestContextMap>({
|
|
143
222
|
allowAnonymous: NotLoggedInError,
|
|
144
|
-
requireRoles: UnauthorizedError
|
|
223
|
+
requireRoles: UnauthorizedError,
|
|
224
|
+
test: S.Never
|
|
145
225
|
})
|
|
146
226
|
|
|
147
227
|
export class Eff extends Req<Eff>()("Eff", {}, { success: S.Void }) {}
|
|
@@ -207,6 +287,8 @@ export class SomethingService2 extends Effect.Service<SomethingService2>()("Some
|
|
|
207
287
|
|
|
208
288
|
export const { Router, matchAll, matchFor } = makeRouter(middleware, true)
|
|
209
289
|
|
|
290
|
+
export const r2 = makeRouter(middleware2, true)
|
|
291
|
+
|
|
210
292
|
const router = Router(Something)({
|
|
211
293
|
dependencies: [
|
|
212
294
|
SomethingRepo.Default,
|
|
@@ -269,6 +351,13 @@ const router = Router(Something)({
|
|
|
269
351
|
}
|
|
270
352
|
})
|
|
271
353
|
|
|
354
|
+
it("sorts based on requirements", () => {
|
|
355
|
+
const input = [RequireRoles, AllowAnonymous, Test]
|
|
356
|
+
const sorted = sort(input)
|
|
357
|
+
console.dir({ input, sorted }, { depth: 10 })
|
|
358
|
+
expect(sorted).toEqual([AllowAnonymous, RequireRoles, Test])
|
|
359
|
+
})
|
|
360
|
+
|
|
272
361
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
273
362
|
const matched = matchAll({ router })
|
|
274
363
|
expectTypeOf({} as Layer.Context<typeof matched>).toEqualTypeOf<SomeService | "str">()
|
|
@@ -278,3 +367,75 @@ expectTypeOf({} as MakeErrors<typeof router.make>).toEqualTypeOf<InvalidStateErr
|
|
|
278
367
|
expectTypeOf({} as makeContext).toEqualTypeOf<
|
|
279
368
|
SomethingService | SomethingRepo | SomethingService2
|
|
280
369
|
>()
|
|
370
|
+
|
|
371
|
+
const router2 = r2.Router(Something)({
|
|
372
|
+
dependencies: [
|
|
373
|
+
SomethingRepo.Default,
|
|
374
|
+
SomethingService.Default,
|
|
375
|
+
SomethingService2.Default
|
|
376
|
+
],
|
|
377
|
+
*effect(match) {
|
|
378
|
+
const repo = yield* SomethingRepo
|
|
379
|
+
const smth = yield* SomethingService
|
|
380
|
+
const smth2 = yield* SomethingService2
|
|
381
|
+
|
|
382
|
+
// this gets catched in 'routes' type
|
|
383
|
+
if (Math.random() > 0.5) {
|
|
384
|
+
return yield* new InvalidStateError("ciao")
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
console.log({ repo, smth, smth2 })
|
|
388
|
+
|
|
389
|
+
return match({
|
|
390
|
+
Eff: () =>
|
|
391
|
+
Effect
|
|
392
|
+
.gen(function*() {
|
|
393
|
+
const some = yield* Some
|
|
394
|
+
return yield* Effect.logInfo("Some", some)
|
|
395
|
+
}),
|
|
396
|
+
|
|
397
|
+
*Gen() {
|
|
398
|
+
const some = yield* Some
|
|
399
|
+
return yield* Effect.logInfo("Some", some)
|
|
400
|
+
},
|
|
401
|
+
*GetSomething(req) {
|
|
402
|
+
console.log(req.id)
|
|
403
|
+
|
|
404
|
+
const _b = yield* Effect.succeed(false)
|
|
405
|
+
if (_b) {
|
|
406
|
+
// expected errors here because RequestError is not a valid error for controllers
|
|
407
|
+
// yield* new RequestError(1 as any)
|
|
408
|
+
// return yield* new RequestError(1 as any)
|
|
409
|
+
}
|
|
410
|
+
if (Math.random() > 0.5) {
|
|
411
|
+
return yield* Effect.succeed("12")
|
|
412
|
+
}
|
|
413
|
+
if (!_b) {
|
|
414
|
+
return yield* new UnauthorizedError()
|
|
415
|
+
} else {
|
|
416
|
+
// expected an error here because a boolean is not a string
|
|
417
|
+
// return _b
|
|
418
|
+
return "12"
|
|
419
|
+
}
|
|
420
|
+
},
|
|
421
|
+
DoSomething: {
|
|
422
|
+
*raw() {
|
|
423
|
+
return yield* Effect.succeed(undefined)
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
GetSomething2: {
|
|
427
|
+
raw: Some.use(() => Effect.succeed("12"))
|
|
428
|
+
}
|
|
429
|
+
})
|
|
430
|
+
}
|
|
431
|
+
})
|
|
432
|
+
|
|
433
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
434
|
+
const matched2 = matchAll({ router: router2 })
|
|
435
|
+
expectTypeOf({} as Layer.Context<typeof matched2>).toEqualTypeOf<SomeService>()
|
|
436
|
+
|
|
437
|
+
type makeContext2 = MakeContext<typeof router2.make>
|
|
438
|
+
expectTypeOf({} as MakeErrors<typeof router2.make>).toEqualTypeOf<InvalidStateError>()
|
|
439
|
+
expectTypeOf({} as makeContext2).toEqualTypeOf<
|
|
440
|
+
SomethingService | SomethingRepo | SomethingService2
|
|
441
|
+
>()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.legacy2.test.d.ts","sourceRoot":"","sources":["../controller.legacy2.test.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEjC,OAAO,EAAW,MAAM,EAAY,KAAK,EAAE,CAAC,EAAY,MAAM,YAAY,CAAA;AAC1E,OAAO,EAAwC,KAAK,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC/G,OAAO,EAAe,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAOhE,MAAM,WAAW,GAAG;IAClB,OAAO,EA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
|
3
|
+
import { Effect, Layer, S } from "effect-app";
|
|
4
|
+
import { type RPCContextMap, UnauthorizedError } from "effect-app/client";
|
|
5
|
+
import { HttpServerRequest } from "effect-app/http";
|
|
6
|
+
export interface CTX {
|
|
7
|
+
context: RequestContext;
|
|
8
|
+
}
|
|
9
|
+
export type CTXMap = {
|
|
10
|
+
requireRoles: RPCContextMap.Custom<"", never, typeof UnauthorizedError, Array<string>>;
|
|
11
|
+
};
|
|
12
|
+
export declare const matchAll: <T extends {
|
|
13
|
+
[key: string]: {
|
|
14
|
+
Router: {
|
|
15
|
+
router: Effect<import("@effect/platform/HttpRouter").HttpRouter<any, any>, any, any>;
|
|
16
|
+
};
|
|
17
|
+
routes: Layer.Layer<any, any, any>;
|
|
18
|
+
moduleName: string;
|
|
19
|
+
};
|
|
20
|
+
}, A, E, R>(handlers: T, requestLayer: Layer.Layer<A, E, R>) => {
|
|
21
|
+
layer: Layer.Layer<never, Layer.Layer.Error<T[keyof T]["routes"]>, Layer.Layer.Context<T[keyof T]["routes"]>>;
|
|
22
|
+
Router: import("@effect/platform/HttpRouter").HttpRouter.TagClass<"RootRouter", "RootRouter", Effect.Effect.Success<T[keyof T]["Router"]["router"]> extends infer T_1 ? T_1 extends T_1 & Effect.Effect.Success<T[keyof T]["Router"]["router"]> ? T_1 extends import("@effect/platform/HttpRouter").HttpRouter<infer E_1, any> ? E_1 : never : never : never, R | Exclude<Effect.Effect.Success<T[keyof T]["Router"]["router"]> extends infer T_2 ? T_2 extends T_2 & Effect.Effect.Success<T[keyof T]["Router"]["router"]> ? T_2 extends import("@effect/platform/HttpRouter").HttpRouter<any, infer R_1> ? R_1 : never : never : never, A>>;
|
|
23
|
+
}, matchFor: <const ModuleName extends string, const Rsc extends Record<string, any>>(rsc: Rsc & {
|
|
24
|
+
meta: {
|
|
25
|
+
moduleName: ModuleName;
|
|
26
|
+
};
|
|
27
|
+
}) => {
|
|
28
|
+
<const Make extends {
|
|
29
|
+
dependencies: import("effect-app").Array<Layer.Layer.Any>;
|
|
30
|
+
effect: Effect<{ [K_1 in keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]: import("@effect-app/infra/api/routing").Handler<Rsc[K_1], any, any>; }, any, Make["strict"] extends false ? any : Make["dependencies"] extends infer T ? T extends Make["dependencies"] ? T extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k in keyof T]: Layer.Layer.Success<T[k]>; }[number] : never : never : never>;
|
|
31
|
+
strict?: boolean;
|
|
32
|
+
readonly ಠ_ಠ: never;
|
|
33
|
+
}>(make: Make): {
|
|
34
|
+
moduleName: ModuleName;
|
|
35
|
+
Router: import("@effect/platform/HttpRouter").HttpRouter.TagClass<import("@effect-app/infra/api/routing").RouterShape<Rsc>, `${ModuleName}Router`, never, Exclude<[{ [K_2 in keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]: Rpc.Rpc<Rsc[K_2], import("@effect-app/infra/api/routing")._R<ReturnType<import("@effect-app/infra/api/routing").MakeHandlers<Make, { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }>[K_2]["handler"]>>>; }[keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]] extends [Rpc.Rpc<any, infer R>] ? R : never, import("@effect/platform/HttpRouter").HttpRouter.Provided>>;
|
|
36
|
+
routes: Layer.Layer<import("@effect-app/infra/api/routing").RouterShape<Rsc>, import("@effect-app/infra/api/routing").MakeErrors<Make> | (Make["dependencies"] extends infer T_1 ? T_1 extends Make["dependencies"] ? T_1 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_1 in keyof T_1]: Layer.Layer.Error<T_1[k_1]>; }[number] : never : never : never), (Make["dependencies"] extends infer T_2 ? T_2 extends Make["dependencies"] ? T_2 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_2 in keyof T_2]: Layer.Layer.Context<T_2[k_2]>; }[number] : never : never : never) | Exclude<import("@effect-app/infra/api/routing").MakeContext<Make>, Make["dependencies"] extends infer T_3 ? T_3 extends Make["dependencies"] ? T_3 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_3 in keyof T_3]: Layer.Layer.Success<T_3[k_3]>; }[number] : never : never : never>>;
|
|
37
|
+
};
|
|
38
|
+
<const Make extends {
|
|
39
|
+
dependencies: import("effect-app").Array<Layer.Layer.Any>;
|
|
40
|
+
effect: Effect<{ [K in keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]: import("@effect-app/infra/api/routing").Handler<Rsc[K], any, any>; }, any, Make["strict"] extends false ? any : Make["dependencies"] extends infer T ? T extends Make["dependencies"] ? T extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k in keyof T]: Layer.Layer.Success<T[k]>; }[number] : never : never : never>;
|
|
41
|
+
strict?: boolean;
|
|
42
|
+
readonly ಠ_ಠ: never;
|
|
43
|
+
}>(make: Make): {
|
|
44
|
+
moduleName: ModuleName;
|
|
45
|
+
Router: import("@effect/platform/HttpRouter").HttpRouter.TagClass<import("@effect-app/infra/api/routing").RouterShape<Rsc>, `${ModuleName}Router`, never, Exclude<[{ [K_1 in keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]: Rpc.Rpc<Rsc[K_1], import("@effect-app/infra/api/routing")._R<ReturnType<import("@effect-app/infra/api/routing").MakeHandlers<Make, { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }>[K_1]["handler"]>>>; }[keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]] extends [Rpc.Rpc<any, infer R>] ? R : never, import("@effect/platform/HttpRouter").HttpRouter.Provided>>;
|
|
46
|
+
routes: Layer.Layer<import("@effect-app/infra/api/routing").RouterShape<Rsc>, import("@effect-app/infra/api/routing").MakeErrors<Make> | (Make["dependencies"] extends infer T_1 ? T_1 extends Make["dependencies"] ? T_1 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_1 in keyof T_1]: Layer.Layer.Error<T_1[k_1]>; }[number] : never : never : never), (Make["dependencies"] extends infer T_2 ? T_2 extends Make["dependencies"] ? T_2 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_2 in keyof T_2]: Layer.Layer.Context<T_2[k_2]>; }[number] : never : never : never) | Exclude<import("@effect-app/infra/api/routing").MakeContext<Make>, Make["dependencies"] extends infer T_3 ? T_3 extends Make["dependencies"] ? T_3 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_3 in keyof T_3]: Layer.Layer.Success<T_3[k_3]>; }[number] : never : never : never>>;
|
|
47
|
+
};
|
|
48
|
+
<const Make extends {
|
|
49
|
+
dependencies: import("effect-app").Array<Layer.Layer.Any>;
|
|
50
|
+
effect: Effect<{ [K in keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]: import("@effect-app/infra/api/routing").Handler<Rsc[K], any, any>; }, any, Make["strict"] extends false ? any : Make["dependencies"] extends infer T ? T extends Make["dependencies"] ? T extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k in keyof T]: Layer.Layer.Success<T[k]>; }[number] : never : never : never>;
|
|
51
|
+
strict?: boolean;
|
|
52
|
+
readonly ಠ_ಠ: never;
|
|
53
|
+
}>(make: Make): {
|
|
54
|
+
moduleName: ModuleName;
|
|
55
|
+
Router: import("@effect/platform/HttpRouter").HttpRouter.TagClass<import("@effect-app/infra/api/routing").RouterShape<Rsc>, `${ModuleName}Router`, never, Exclude<[{ [K_1 in keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]: Rpc.Rpc<Rsc[K_1], import("@effect-app/infra/api/routing")._R<ReturnType<import("@effect-app/infra/api/routing").MakeHandlers<Make, { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }>[K_1]["handler"]>>>; }[keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]] extends [Rpc.Rpc<any, infer R>] ? R : never, import("@effect/platform/HttpRouter").HttpRouter.Provided>>;
|
|
56
|
+
routes: Layer.Layer<import("@effect-app/infra/api/routing").RouterShape<Rsc>, import("@effect-app/infra/api/routing").MakeErrors<Make> | (Make["dependencies"] extends infer T_1 ? T_1 extends Make["dependencies"] ? T_1 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_1 in keyof T_1]: Layer.Layer.Error<T_1[k_1]>; }[number] : never : never : never), (Make["dependencies"] extends infer T_2 ? T_2 extends Make["dependencies"] ? T_2 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_2 in keyof T_2]: Layer.Layer.Context<T_2[k_2]>; }[number] : never : never : never) | Exclude<import("@effect-app/infra/api/routing").MakeContext<Make>, Make["dependencies"] extends infer T_3 ? T_3 extends Make["dependencies"] ? T_3 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_3 in keyof T_3]: Layer.Layer.Success<T_3[k_3]>; }[number] : never : never : never>>;
|
|
57
|
+
};
|
|
58
|
+
<const Make extends {
|
|
59
|
+
dependencies: import("effect-app").Array<Layer.Layer.Any>;
|
|
60
|
+
effect: Effect<{ [K in keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]: import("@effect-app/infra/api/routing").Handler<Rsc[K], any, any>; }, any, Make["dependencies"] extends infer T ? T extends Make["dependencies"] ? T extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k in keyof T]: Layer.Layer.Success<T[k]>; }[number] : never : never : never>;
|
|
61
|
+
strict?: boolean;
|
|
62
|
+
readonly ಠ_ಠ: never;
|
|
63
|
+
}>(make: Make): {
|
|
64
|
+
moduleName: ModuleName;
|
|
65
|
+
Router: import("@effect/platform/HttpRouter").HttpRouter.TagClass<import("@effect-app/infra/api/routing").RouterShape<Rsc>, `${ModuleName}Router`, never, Exclude<[{ [K_1 in keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]: Rpc.Rpc<Rsc[K_1], import("@effect-app/infra/api/routing")._R<ReturnType<import("@effect-app/infra/api/routing").MakeHandlers<Make, { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }>[K_1]["handler"]>>>; }[keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]] extends [Rpc.Rpc<any, infer R>] ? R : never, import("@effect/platform/HttpRouter").HttpRouter.Provided>>;
|
|
66
|
+
routes: Layer.Layer<import("@effect-app/infra/api/routing").RouterShape<Rsc>, import("@effect-app/infra/api/routing").MakeErrors<Make> | (Make["dependencies"] extends infer T_1 ? T_1 extends Make["dependencies"] ? T_1 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_1 in keyof T_1]: Layer.Layer.Error<T_1[k_1]>; }[number] : never : never : never), (Make["dependencies"] extends infer T_2 ? T_2 extends Make["dependencies"] ? T_2 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_2 in keyof T_2]: Layer.Layer.Context<T_2[k_2]>; }[number] : never : never : never) | Exclude<import("@effect-app/infra/api/routing").MakeContext<Make>, Make["dependencies"] extends infer T_3 ? T_3 extends Make["dependencies"] ? T_3 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_3 in keyof T_3]: Layer.Layer.Success<T_3[k_3]>; }[number] : never : never : never>>;
|
|
67
|
+
};
|
|
68
|
+
<const Make extends {
|
|
69
|
+
dependencies: import("effect-app").Array<Layer.Layer.Any>;
|
|
70
|
+
effect: Effect<{ [K in keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]: import("@effect-app/infra/api/routing").Handler<Rsc[K], any, any>; }, any, Make["dependencies"] extends infer T ? T extends Make["dependencies"] ? T extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k in keyof T]: Layer.Layer.Success<T[k]>; }[number] : never : never : never>;
|
|
71
|
+
strict?: boolean;
|
|
72
|
+
}>(make: Make): {
|
|
73
|
+
moduleName: ModuleName;
|
|
74
|
+
Router: import("@effect/platform/HttpRouter").HttpRouter.TagClass<import("@effect-app/infra/api/routing").RouterShape<Rsc>, `${ModuleName}Router`, never, Exclude<[{ [K_1 in keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]: Rpc.Rpc<Rsc[K_1], import("@effect-app/infra/api/routing")._R<ReturnType<import("@effect-app/infra/api/routing").MakeHandlers<Make, { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }>[K_1]["handler"]>>>; }[keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]] extends [Rpc.Rpc<any, infer R>] ? R : never, import("@effect/platform/HttpRouter").HttpRouter.Provided>>;
|
|
75
|
+
routes: Layer.Layer<import("@effect-app/infra/api/routing").RouterShape<Rsc>, import("@effect-app/infra/api/routing").MakeErrors<Make> | (Make["dependencies"] extends infer T_1 ? T_1 extends Make["dependencies"] ? T_1 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_1 in keyof T_1]: Layer.Layer.Error<T_1[k_1]>; }[number] : never : never : never), (Make["dependencies"] extends infer T_2 ? T_2 extends Make["dependencies"] ? T_2 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_2 in keyof T_2]: Layer.Layer.Context<T_2[k_2]>; }[number] : never : never : never) | Exclude<import("@effect-app/infra/api/routing").MakeContext<Make>, Make["dependencies"] extends infer T_3 ? T_3 extends Make["dependencies"] ? T_3 extends readonly [Layer.Layer.Any, ...Layer.Layer.Any[]] ? { [k_3 in keyof T_3]: Layer.Layer.Success<T_3[k_3]>; }[number] : never : never : never>>;
|
|
76
|
+
};
|
|
77
|
+
<const Make extends {
|
|
78
|
+
dependencies: [...Make["dependencies"], ...Exclude<Effect.Effect.Context<Make["effect"]>, import("effect/Types").Contravariant.Type<import("@effect-app/infra/api/routing").MakeDeps<Make>[typeof Layer.LayerTypeId]["_ROut"]>> extends never ? [] : [Layer.Layer<Exclude<Effect.Effect.Context<Make["effect"]>, import("effect/Types").Contravariant.Type<import("@effect-app/infra/api/routing").MakeDeps<Make>[typeof Layer.LayerTypeId]["_ROut"]>>, never, never>]];
|
|
79
|
+
effect: Effect<{ [K in keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }]: import("@effect-app/infra/api/routing").Handler<Rsc[K], any, any>; }, any, any>;
|
|
80
|
+
strict?: boolean;
|
|
81
|
+
}>(make: Make): {
|
|
82
|
+
moduleName: ModuleName;
|
|
83
|
+
Router: import("@effect/platform/HttpRouter").HttpRouter.TagClass<import("@effect-app/infra/api/routing").RouterShape<Rsc>, `${ModuleName}Router`, never, never>;
|
|
84
|
+
routes: any;
|
|
85
|
+
};
|
|
86
|
+
} & import("@effect-app/infra/api/routing").RouteMatcher<CTXMap, Rsc, HttpServerRequest.HttpServerRequest> & {
|
|
87
|
+
router: import("@effect-app/infra/api/routing").AddAction<{ [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }[keyof { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }], {}>;
|
|
88
|
+
router2: { [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; } extends infer T extends Record<string, import("@effect-app/infra/api/routing").AnyRequestModule> ? { [K in keyof T]: import("@effect-app/infra/api/routing").Method<{ [K in keyof Rsc as Rsc[K] extends import("@effect-app/infra/api/routing").AnyRequestModule ? K : never]: Rsc[K]; }, K, "d", {}>; } : never;
|
|
89
|
+
};
|
|
90
|
+
export type RequestConfig = {
|
|
91
|
+
/** Disable authentication requirement */
|
|
92
|
+
allowAnonymous?: true;
|
|
93
|
+
/** Control the roles that are required to access the resource */
|
|
94
|
+
allowRoles?: readonly string[];
|
|
95
|
+
};
|
|
96
|
+
export declare const Req: <Self>() => {
|
|
97
|
+
<Tag extends string, Payload extends S.Struct.Fields, C extends {
|
|
98
|
+
success: S.Schema.Any | S.Struct.Fields;
|
|
99
|
+
failure: S.Schema.Any | S.Struct.Fields;
|
|
100
|
+
}>(tag: Tag, fields: Payload, config: RequestConfig & C): S.TaggedRequestClass<Self, Tag, {
|
|
101
|
+
readonly _tag: S.tag<Tag>;
|
|
102
|
+
} & Payload, (RequestConfig & C)["success"] extends infer T ? T extends (RequestConfig & C)["success"] ? T extends import("effect/Schema").Struct.Fields ? S.TypeLiteral<T, []> : T extends S.Schema.Any ? T : never : never : never, ([((RequestConfig & C)["failure"] extends infer T_1 ? T_1 extends (RequestConfig & C)["failure"] ? T_1 extends import("effect/Schema").Struct.Fields ? S.TypeLiteral<T_1, []> : T_1 extends S.Schema.Any ? T_1 : never : never : never) | import("effect-app/client").GetEffectError<CTXMap, C>] extends [never] ? [] : [((RequestConfig & C)["failure"] extends infer T_1 ? T_1 extends (RequestConfig & C)["failure"] ? T_1 extends import("effect/Schema").Struct.Fields ? S.TypeLiteral<T_1, []> : T_1 extends S.Schema.Any ? T_1 : never : never : never) | import("effect-app/client").GetEffectError<CTXMap, C>]) extends infer T_2 ? T_2 extends ([((RequestConfig & C)["failure"] extends infer T_1 ? T_1 extends (RequestConfig & C)["failure"] ? T_1 extends import("effect/Schema").Struct.Fields ? S.TypeLiteral<T_1, []> : T_1 extends S.Schema.Any ? T_1 : never : never : never) | import("effect-app/client").GetEffectError<CTXMap, C>] extends [never] ? [] : [((RequestConfig & C)["failure"] extends infer T_1 ? T_1 extends (RequestConfig & C)["failure"] ? T_1 extends import("effect/Schema").Struct.Fields ? S.TypeLiteral<T_1, []> : T_1 extends S.Schema.Any ? T_1 : never : never : never) | import("effect-app/client").GetEffectError<CTXMap, C>]) ? T_2 extends readonly S.Schema.All[] ? S.Union<T_2> : typeof S.Never : never : never> & {
|
|
103
|
+
config: Omit<C, "success" | "failure">;
|
|
104
|
+
};
|
|
105
|
+
<Tag extends string, Payload_1 extends S.Struct.Fields, C_1 extends {
|
|
106
|
+
success: S.Schema.Any | S.Struct.Fields;
|
|
107
|
+
}>(tag: Tag, fields: Payload_1, config: RequestConfig & C_1): S.TaggedRequestClass<Self, Tag, {
|
|
108
|
+
readonly _tag: S.tag<Tag>;
|
|
109
|
+
} & Payload_1, (RequestConfig & C_1)["success"] extends infer T ? T extends (RequestConfig & C_1)["success"] ? T extends import("effect/Schema").Struct.Fields ? S.TypeLiteral<T, []> : T extends S.Schema.Any ? T : never : never : never, ([import("effect-app/client").GetEffectError<CTXMap, C_1>] extends [never] ? [] : [import("effect-app/client").GetEffectError<CTXMap, C_1>]) extends infer T_1 ? T_1 extends ([import("effect-app/client").GetEffectError<CTXMap, C_1>] extends [never] ? [] : [import("effect-app/client").GetEffectError<CTXMap, C_1>]) ? T_1 extends readonly S.Schema.All[] ? S.Union<T_1> : typeof S.Never : never : never> & {
|
|
110
|
+
config: Omit<C_1, "success" | "failure">;
|
|
111
|
+
};
|
|
112
|
+
<Tag extends string, Payload_2 extends S.Struct.Fields, C_2 extends {
|
|
113
|
+
failure: S.Schema.Any | S.Struct.Fields;
|
|
114
|
+
}>(tag: Tag, fields: Payload_2, config: RequestConfig & C_2): S.TaggedRequestClass<Self, Tag, {
|
|
115
|
+
readonly _tag: S.tag<Tag>;
|
|
116
|
+
} & Payload_2, typeof S.Void, ([((RequestConfig & C_2)["failure"] extends infer T ? T extends (RequestConfig & C_2)["failure"] ? T extends import("effect/Schema").Struct.Fields ? S.TypeLiteral<T, []> : T extends S.Schema.Any ? T : never : never : never) | import("effect-app/client").GetEffectError<CTXMap, C_2>] extends [never] ? [] : [((RequestConfig & C_2)["failure"] extends infer T ? T extends (RequestConfig & C_2)["failure"] ? T extends import("effect/Schema").Struct.Fields ? S.TypeLiteral<T, []> : T extends S.Schema.Any ? T : never : never : never) | import("effect-app/client").GetEffectError<CTXMap, C_2>]) extends infer T_1 ? T_1 extends ([((RequestConfig & C_2)["failure"] extends infer T ? T extends (RequestConfig & C_2)["failure"] ? T extends import("effect/Schema").Struct.Fields ? S.TypeLiteral<T, []> : T extends S.Schema.Any ? T : never : never : never) | import("effect-app/client").GetEffectError<CTXMap, C_2>] extends [never] ? [] : [((RequestConfig & C_2)["failure"] extends infer T ? T extends (RequestConfig & C_2)["failure"] ? T extends import("effect/Schema").Struct.Fields ? S.TypeLiteral<T, []> : T extends S.Schema.Any ? T : never : never : never) | import("effect-app/client").GetEffectError<CTXMap, C_2>]) ? T_1 extends readonly S.Schema.All[] ? S.Union<T_1> : typeof S.Never : never : never> & {
|
|
117
|
+
config: Omit<C_2, "success" | "failure">;
|
|
118
|
+
};
|
|
119
|
+
<Tag extends string, Payload_3 extends S.Struct.Fields, C_3 extends Record<string, any>>(tag: Tag, fields: Payload_3, config: C_3 & RequestConfig): S.TaggedRequestClass<Self, Tag, {
|
|
120
|
+
readonly _tag: S.tag<Tag>;
|
|
121
|
+
} & Payload_3, typeof S.Void, ([import("effect-app/client").GetEffectError<CTXMap, C_3>] extends [never] ? [] : [import("effect-app/client").GetEffectError<CTXMap, C_3>]) extends infer T ? T extends ([import("effect-app/client").GetEffectError<CTXMap, C_3>] extends [never] ? [] : [import("effect-app/client").GetEffectError<CTXMap, C_3>]) ? T extends readonly S.Schema.All[] ? S.Union<T> : typeof S.Never : never : never> & {
|
|
122
|
+
config: Omit<C_3, "success" | "failure">;
|
|
123
|
+
};
|
|
124
|
+
<Tag extends string, Payload_4 extends S.Struct.Fields>(tag: Tag, fields: Payload_4): S.TaggedRequestClass<Self, Tag, {
|
|
125
|
+
readonly _tag: S.tag<Tag>;
|
|
126
|
+
} & Payload_4, typeof S.Void, never>;
|
|
127
|
+
};
|
|
128
|
+
declare const GetSomething_base: S.TaggedRequestClass<GetSomething, "GetSomething", {
|
|
129
|
+
readonly _tag: S.tag<"GetSomething">;
|
|
130
|
+
} & {
|
|
131
|
+
id: typeof S.String;
|
|
132
|
+
}, typeof S.Void, S.Union<[typeof UnauthorizedError]>> & {
|
|
133
|
+
config: Omit<{
|
|
134
|
+
success: typeof S.Void;
|
|
135
|
+
}, "success" | "failure">;
|
|
136
|
+
};
|
|
137
|
+
export declare class GetSomething extends GetSomething_base {
|
|
138
|
+
}
|
|
139
|
+
declare const GetSomethingElse_base: S.TaggedRequestClass<GetSomethingElse, "GetSomethingElse", {
|
|
140
|
+
readonly _tag: S.tag<"GetSomethingElse">;
|
|
141
|
+
} & {
|
|
142
|
+
id: typeof S.String;
|
|
143
|
+
}, typeof S.String, S.Union<[typeof UnauthorizedError]>> & {
|
|
144
|
+
config: Omit<{
|
|
145
|
+
success: typeof S.String;
|
|
146
|
+
}, "success" | "failure">;
|
|
147
|
+
};
|
|
148
|
+
export declare class GetSomethingElse extends GetSomethingElse_base {
|
|
149
|
+
}
|
|
150
|
+
declare const SomethingService_base: import("effect/Effect").Service.Class<SomethingService, "SomethingService", {
|
|
151
|
+
readonly dependencies: readonly [];
|
|
152
|
+
readonly effect: Effect.Effect<{}, never, never>;
|
|
153
|
+
}>;
|
|
154
|
+
export declare class SomethingService extends SomethingService_base {
|
|
155
|
+
}
|
|
156
|
+
declare const SomethingRepo_base: import("effect/Effect").Service.Class<SomethingRepo, "SomethingRepo", {
|
|
157
|
+
readonly dependencies: readonly [Layer.Layer<SomethingService, never, never>];
|
|
158
|
+
readonly effect: Effect.Effect<{}, never, SomethingService>;
|
|
159
|
+
}>;
|
|
160
|
+
export declare class SomethingRepo extends SomethingRepo_base {
|
|
161
|
+
}
|
|
162
|
+
declare const SomethingService2_base: import("effect/Effect").Service.Class<SomethingService2, "SomethingService2", {
|
|
163
|
+
readonly dependencies: readonly [];
|
|
164
|
+
readonly effect: Effect.Effect<{}, never, never>;
|
|
165
|
+
}>;
|
|
166
|
+
export declare class SomethingService2 extends SomethingService2_base {
|
|
167
|
+
}
|
|
168
|
+
export {};
|
|
169
|
+
//# sourceMappingURL=controller.test%20copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.test copy.d.ts","sourceRoot":"","sources":["../controller.test copy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEjC,OAAO,EAAW,MAAM,EAAY,KAAK,EAAE,CAAC,EAAY,MAAM,YAAY,CAAA;AAC1E,OAAO,EAAwC,KAAK,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC/G,OAAO,EAAe,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAOhE,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,cAAc,CAAA;CACxB;AAED,MAAM,MAAM,MAAM,GAAG;IAGnB,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;CACvF,CAAA;AAmGD,eAAO,MAAQ,QAAQ;;;;;sBA2DnB,KACH;;;;;;GA5DwB,QAAQ;;;;;;uDAmG8B,KAAK,CAAC,GA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