Skip to content

Commit

Permalink
access-api remove InvocationResponder type as it is essentially Servi…
Browse files Browse the repository at this point in the history
…ceMethod with defaults
  • Loading branch information
gobengo committed Jan 13, 2023
1 parent 94614d0 commit fa1245e
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions packages/access-api/src/ucanto/types.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
import {
Capability,
InferInvokedCapability,
Invocation,
InvocationContext,
Match,
ParsedCapability,
RequestDecoder,
RequestEncoder,
ResponseDecoder,
ResponseEncoder,
Result,
ServiceMethod,
TheCapabilityParser,
} from '@ucanto/interface'

export interface ClientCodec extends RequestEncoder, ResponseDecoder {}

export interface ServerCodec extends RequestDecoder, ResponseEncoder {}

/**
* A single ucanto service method.
*/
export type InvocationResponder<
C extends Capability,
Success = unknown,
Failure extends { error: true } = { error: true }
> = (
invocation: Invocation<C>,
context: InvocationContext
) => Promise<Result<Success, Failure>>

/**
* Select from T the property names whose values are of type V
*/
Expand All @@ -47,7 +32,9 @@ export type InferService<
Match<ParsedCapability>
>
> = {
[K in KeysWithValue<S, CP>]: InvocationResponder<
InferInvokedCapability<S[K] extends CP ? S[K] : never>
[K in KeysWithValue<S, CP>]: ServiceMethod<
InferInvokedCapability<S[K] extends CP ? S[K] : never>,
unknown,
{ error: true }
>
}

0 comments on commit fa1245e

Please sign in to comment.