effect-start 0.15.0 → 0.16.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/src/RouteHook.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as Effect from "effect/Effect"
2
2
  import type * as Utils from "effect/Utils"
3
+ import * as Entity from "./Entity.ts"
3
4
  import * as Route from "./Route.ts"
4
5
 
5
6
  export type FilterResult<BOut, E, R> =
@@ -11,9 +12,9 @@ export type FilterHandlerInput<BIn, BOut, E, R> =
11
12
  | ((context: BIn) =>
12
13
  | FilterResult<BOut, E, R>
13
14
  | Generator<
14
- Utils.YieldWrap<Effect.Effect<any, E, R>>,
15
+ Utils.YieldWrap<Effect.Effect<unknown, E, R>>,
15
16
  { context: BOut },
16
- any
17
+ unknown
17
18
  >)
18
19
 
19
20
  export function filter<
@@ -34,26 +35,26 @@ export function filter<
34
35
  ): Route.RouteSet.RouteSet<
35
36
  D,
36
37
  SB,
37
- [...P, Route.Route.Route<{}, BOut, void, E, R>]
38
+ [
39
+ ...P,
40
+ Route.Route.Route<{}, BOut, unknown, E, R>,
41
+ ]
38
42
  > {
39
43
  const route = Route.make<
40
44
  {},
41
45
  BOut,
42
- void,
46
+ unknown,
43
47
  E,
44
48
  R
45
- >((context: BOut, next) =>
49
+ >((context: BOut, next: (ctx?: Partial<BOut>) => Entity.Entity<unknown>) =>
46
50
  Effect.gen(function*() {
47
51
  const filterResult = yield* normalized(context as unknown as BIn)
48
52
 
49
- yield* next(
50
- filterResult
51
- ? {
52
- ...context,
53
- ...filterResult.context,
54
- }
55
- : context,
56
- )
53
+ const mergedContext = filterResult
54
+ ? { ...context, ...filterResult.context }
55
+ : context
56
+
57
+ return yield* Entity.resolve(next(mergedContext as Partial<BOut>))
57
58
  })
58
59
  )
59
60
 
@@ -61,7 +62,7 @@ export function filter<
61
62
  [
62
63
  ...Route.items(self),
63
64
  route,
64
- ] as [...P, Route.Route.Route<{}, BOut, void, E, R>],
65
+ ] as [...P, Route.Route.Route<{}, BOut, unknown, E, R>],
65
66
  Route.descriptor(self),
66
67
  )
67
68
  }