Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/effect-app/src/client/apiClientFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ const makeApiClientFactory = Effect
mr.contextEffect.pipe(
Effect.flatMap((svcs) => {
const rpcEffect = TheClient
.use((client) => (client as any)[requestAttr]!(Request.make(input)) as Effect.Effect<any, any>)
.use((client) => (client as any)[requestAttr]!(input) as Effect.Effect<any, any>)
.pipe(
// local: true → isolate to this RPC call. `layers` is pure today
// (RequestName + caller-supplied requestLevelLayers), but the
Expand All @@ -324,7 +324,7 @@ const makeApiClientFactory = Effect
TheClient
.useSync((client) => {
const rpcStream = (client as any)[requestAttr]!(
Request.make(input)
input
) as Stream.Stream<any, any, any>
return rpcStream.pipe(
// Collect server invalidation keys from the "done" chunk, then discard it.
Expand Down
9 changes: 5 additions & 4 deletions packages/effect-app/src/client/clientFor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,23 +133,24 @@
RequestStreamHandlerWithInput<void, A, E, R, Request, Id, Final>

// make sure this is exported or d.ts of apiClientFactory breaks?!
export type RequestInputFromMake<I extends { readonly make: (...args: any[]) => any }> = Parameters<I["make"]> extends
[] ? void : Parameters<I["make"]>[0]
export type RequestInputFromMake<I extends { readonly "~type.make.in": unknown; readonly fields: S.Struct.Fields }> =
I["~type.make.in"]

// Has no input only when the request schema declares no payload fields (the auto-added
// `_tag` field is ignored). Any payload fields (even all-optional) produce a function handler.
type HasNoFields<I> = I extends { readonly fields: infer F extends S.Struct.Fields }
? [Exclude<keyof F, "_tag">] extends [never] ? true : false
: false

type RequestInput<I extends { readonly make: (...args: any[]) => any }> = Parameters<I["make"]>[0]
type RequestInput<I extends { readonly "~type.make.in": unknown; readonly fields: S.Struct.Fields }> =
I["~type.make.in"]

/**
* Caller-facing input type for a request. `void` when the request schema has no fields;
* otherwise `make`'s first param type.
*/
export type HandlerInput<I extends { readonly make: (...args: any[]) => any }> = HasNoFields<I> extends true ? void
export type HandlerInput<I extends { readonly fields: S.Struct.Fields }> = HasNoFields<I> extends true ? void
: RequestInput<I>

Check failure on line 153 in packages/effect-app/src/client/clientFor.ts

View workflow job for this annotation

GitHub Actions / Build

Type 'I' does not satisfy the constraint '{ readonly "~type.make.in": unknown; readonly fields: Fields; }'.

/** Extracts the final-value type from a stream request. Defaults to the success type when no `final` schema is set. */
type FinalTypeOf<T extends Req> = T extends { readonly final: infer F extends S.Top } ? F["Type"]
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/makeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,6 @@ export interface CommandBase<I = void, A = void, RA = unknown, RE = unknown> {

export interface EffectCommand<I = void, A = unknown, E = unknown> extends CommandBase<I, Fiber<A, E>, A, E> {}

export interface CommandFromRequest<I extends { readonly make: (...args: any[]) => any }, A = unknown, E = unknown>
export interface CommandFromRequest<I extends { readonly fields: S.Struct.Fields }, A = unknown, E = unknown>
extends EffectCommand<HandlerInput<I>, A, E>
{}
Loading